Commit 4a1a19e9 by fengshuonan

增加一个部门的下拉框

parent fed7b80c
/**
* Copyright 2018-2020 stylefeng & fengshuonan (https://gitee.com/stylefeng)
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package cn.stylefeng.guns.modular.system.controller;
import cn.stylefeng.roses.core.base.controller.BaseController;
import cn.stylefeng.roses.core.util.ToolUtil;
import cn.stylefeng.roses.kernel.model.exception.RequestEmptyException;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
/**
* 通用控制器
*
* @author fengshuonan
* @Date 2017年2月17日20:27:22
*/
@Controller
@RequestMapping("/system")
public class SystemController extends BaseController {
private String PREFIX = "/common/";
/**
* 通用的树列表选择器
*/
@RequestMapping("/commonTree")
public String deptTreeList(@RequestParam("formName") String formName,
@RequestParam("formId") String formId,
@RequestParam("treeUrl") String treeUrl, Model model) {
if (ToolUtil.isOneEmpty(formName, formId, treeUrl)) {
throw new RequestEmptyException("请求数据不完整!");
}
try {
model.addAttribute("formName", URLDecoder.decode(formName, "UTF-8"));
model.addAttribute("formId", URLDecoder.decode(formId, "UTF-8"));
model.addAttribute("treeUrl", URLDecoder.decode(treeUrl, "UTF-8"));
} catch (UnsupportedEncodingException e) {
throw new RequestEmptyException("请求数据不完整!");
}
return PREFIX + "common_tree_dlg.html";
}
}
<!DOCTYPE html>
<html lang="en">
@/**
@ * 本页面所用的模板变量
@ *
@ * treeUrl : 加载树的url
@ * fromName : 需要设置的显示名称
@ * fromId : 需要设置的隐藏id
@ **/
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>${title!"Guns管理系统"}</title>
<meta name="description" content="Guns管理系统">
<meta name="author" content="stylefeng">
<!-- Bootstrap Core CSS -->
<link href="${ctxPath}/assets/common/plugins/bootstrap/css/bootstrap.min.css" rel="stylesheet">
<!-- Custom CSS -->
<link href="${ctxPath}/assets/common/static/css/style.css" rel="stylesheet">
<link href="${ctxPath}/assets/common/static/stylefeng/feng.css" rel="stylesheet">
<!--其他插件css-->
<link href="${ctxPath}/assets/common/plugins/ztree/zTreeStyle.css" rel="stylesheet" type="text/css"/>
</head>
<body class="fix-header fix-sidebar card-no-border">
<div id="main-wrapper">
<div class="container-fluid">
<div class="row p-10" style="background: #f2f7f8;">
<ul id="zTree" class="ztree"></ul>
</div>
<div class="row p-10" style="background: #CFD4D5;">
<div style="float:left;margin: auto">
<button class="btn btn-sm btn-info" type="button" id="saveButton">
<i class="ace-icon fa fa-check"></i> 保存
</button>
<button class="btn btn-sm btn-danger" type="button" id="closeButton">
<i class="ace-icon fa fa-close"></i> 关闭
</button>
</div>
</div>
</div>
</div>
<!-- jquery -->
<script src="${ctxPath}/assets/common/plugins/jquery/jquery.min.js"></script>
<!-- Bootstrap tether Core JavaScript -->
<script src="${ctxPath}/assets/common/plugins/bootstrap/js/tether.min.js"></script>
<script src="${ctxPath}/assets/common/plugins/bootstrap/js/bootstrap.min.js"></script>
<!--Guns JavaScript -->
<script src="${ctxPath}/assets/common/static/stylefeng/Feng.js"></script>
<script src="${ctxPath}/assets/common/static/stylefeng/ajax-object.js"></script>
<!-- vue -->
<script src="${ctxPath}/assets/common/plugins/vue/vue.js"></script>
<!-- 加入contextPath属性和session超时的配置 -->
<script type="text/javascript">
Feng.addCtx("${ctxPath}");
Feng.sessionTimeoutRegistry();
</script>
<!--其他插件js-->
<script src="${ctxPath}/assets/common/plugins/ztree/jquery.ztree.all.min.js"></script>
<script src="${ctxPath}/assets/common/plugins/ztree/ztree-object.js"></script>
<script type="text/javascript">
var ZTreeDlg = {};
ZTreeDlg.onClickItem = function (e, treeId, treeNode) {
${formName} = ZTreeDlg.instance.getSelectedVal();
${formId} = treeNode.id;
};
$(function () {
var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
$("#closeButton").bind("click", function () {
parent.layer.close(index);
});
$("#saveButton").bind("click", function () {
parent.layer.close(index);
});
var ztree = new $ZTree("zTree", "${treeUrl}");
ztree.bindOnClick(ZTreeDlg.onClickItem);
ztree.init();
ZTreeDlg.instance = ztree;
});
</script>
</body>
</html>
@layout("/common/_dialog.html",{plugins:["laydate","sweet-alert"],js:["/assets/modular/system/user/user_info.js"]}){ @layout("/common/_dialog.html",{plugins:["laydate","sweet-alert","layer"],js:["/assets/modular/system/user/user_info.js"]}){
<div class="container-fluid"> <div class="container-fluid">
<form id="userAddForm" \@submit="submitForm"> <form id="userAddForm" \@submit="submitForm">
<div class="row"> <div class="row">
...@@ -55,7 +55,7 @@ ...@@ -55,7 +55,7 @@
<div class="form-group"> <div class="form-group">
<h5>部门 <span class="text-danger">*</span></h5> <h5>部门 <span class="text-danger">*</span></h5>
<div class="controls"> <div class="controls">
<input v-model="detpName" id="detpName" type="text" class="form-control"> <input v-model="deptName" id="detpName" \@click="showDeptSelectTree" type="text" class="form-control" autocomplete="off">
<input v-model="deptid" type="hidden" class="form-control"> <input v-model="deptid" type="hidden" class="form-control">
</div> </div>
</div> </div>
......
@layout("/common/_container.html"){ @layout("/common/_tree_dialog.html"){
<script type="text/javascript"> <script type="text/javascript">
$(function () { $(function () {
var index = parent.layer.getFrameIndex(window.name); //获取窗口索引 var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
$("#closeButton").bind("click", function () {
$("#btn_close").bind("click", function () {
parent.layer.close(index); parent.layer.close(index);
}); });
$("#btn_save").bind("click", function () { $("#saveButton").bind("click", function () {
var ids = Feng.zTreeCheckedNodes("zTree"); var ids = Feng.zTreeCheckedNodes("zTree");
var ajax = new $ax(Feng.ctxPath + "/mgr/setRole", function (data) { var ajax = new $ax(Feng.ctxPath + "/mgr/setRole", function (data) {
Feng.success("分配角色成功!"); Feng.success("分配角色成功!");
...@@ -42,38 +39,9 @@ ...@@ -42,38 +39,9 @@
} }
} }
}; };
var ztree = new $ZTree("zTree", "/role/roleTreeListByUserId/${userId}"); var ztree = new $ZTree("zTree", "/role/roleTreeListByUserId/${userId}");
ztree.setSettings(setting); ztree.setSettings(setting);
ztree.init(); ztree.init();
} }
</script> </script>
<!-- 配置grid -->
<div class="container"
style="padding: 0px 10px !important; margin-top: -10px; text-align: center !important;">
<div class="row">
<div class="ibox float-e-margins">
<div class="ibox-title">
<h5>${userAccount!}</h5>
</div>
<div class="ibox-content">
<ul id="zTree" class="ztree"></ul>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<button class="btn btn-sm btn-info" type="button" id="btn_save">
<i class="ace-icon fa fa-check bigger-110"></i> 保存
</button>
&nbsp;
<button class="btn btn-sm btn-danger" type="button" id="btn_close">
<i class="ace-icon fa fa-close bigger-110"></i> 关闭
</button>
</div>
</div>
</div>
@} @}
...@@ -13,7 +13,7 @@ var UserInfoDlg = { ...@@ -13,7 +13,7 @@ var UserInfoDlg = {
name: "", name: "",
birthday: "", birthday: "",
deptid: "", deptid: "",
detpName: "", deptName: "",
phone: "" phone: ""
} }
}; };
...@@ -111,6 +111,19 @@ $(function () { ...@@ -111,6 +111,19 @@ $(function () {
Feng.alert(result); Feng.alert(result);
e.preventDefault(); e.preventDefault();
} }
},
showDeptSelectTree: function () {
var formName = encodeURIComponent("parent.UserInfoDlg.app.deptName");
var formId = encodeURIComponent("parent.UserInfoDlg.app.deptid");
var treeUrl = encodeURIComponent(Feng.ctxPath + "/dept/tree");
layer.open({
type: 2,
title: '部门选择',
area: ['300px', '400px'],
content: Feng.ctxPath + '/system/commonTree?formName=' + formName + "&formId=" + formId + "&treeUrl=" + treeUrl
});
} }
} }
}); });
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment