<%@ page language="java" import="java.util.*" pageEncoding="UTF-8" %>
|
<%
|
String path = request.getContextPath();
|
String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
|
+ path + "/";
|
%>
|
|
<!DOCTYPE HTML>
|
<html>
|
<head>
|
<base href="<%=basePath%>">
|
<meta charset="UTF-8">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
<title>选择模块</title>
|
<!--[if !IE]><!-->
|
<link href="static/plugins/font-awesome/css/font-awesome.css" rel="stylesheet" type="text/css">
|
<!--<![endif]-->
|
<!--[if gt IE 8]>
|
<link href="static/plugins/font-awesome/css/font-awesome.css" rel="stylesheet" type="text/css">
|
<![endif]-->
|
<link href="static/plugins/jquery-easyui/themes/bootstrap/easyui.css" rel="stylesheet" type="text/css">
|
<link rel="stylesheet" href="static/styles/initialize.css" type="text/css">
|
<link rel="stylesheet" href="static/styles/common.css" type="text/css">
|
|
<script type="text/javascript" src="static/plugins/jquery/jquery.min.js"></script>
|
<script type="text/javascript" src="static/plugins/jquery-easyui/jquery.easyui.min.js"></script>
|
<script type="text/javascript" src="static/plugins/jquery-easyui/plugins/datagrid-scrollview.js"></script>
|
<script type="text/javascript" src="static/plugins/jquery-easyui/locale/easyui-lang-zh_CN.js"></script>
|
<script type="text/javascript" src="static/plugins/slimScroll/jquery.slimscroll.min.js"></script>
|
<script type="text/javascript" src="static/scripts/ResizeScroll.js"></script>
|
<script type="text/javascript" src="static/plugins/layer/layer.js"></script>
|
|
<script type="text/javascript" src="static/plugins/spinjs/spin.js"></script>
|
<script type="text/javascript" src="static/plugins/spinjs/jquery.spin.js"></script>
|
<script type="text/javascript" src="static/plugins/jquery.blockUI.js"></script>
|
|
<script type="text/javascript" src="static/wcp/scripts/wcp.js"></script>
|
<script type="text/javascript" src="static/wcp/scripts/libs/wcp.layer.js"></script>
|
<script type="text/javascript" src="static/wcp/scripts/libs/wcp.blockUI.js"></script>
|
<script type="text/javascript" src="static/wcp/scripts/libs/wcp.spin.js"></script>
|
<script type="text/javascript" src="static/wcp/scripts/libs/wcp.jquery.js"></script>
|
|
<!--[if lt IE 9]>
|
<script type="text/javascript" src="static/plugins/json2.js"></script>
|
<![endif]-->
|
<style>
|
html, body {
|
height: 100%;
|
}
|
|
.container {
|
width: 100%;
|
height: 100%;
|
padding: 10px;
|
}
|
|
.left {
|
width: 50%;
|
float: left;
|
}
|
|
.right {
|
width: 50%;
|
float: right;
|
}
|
|
.search {
|
clear: both;
|
}
|
</style>
|
|
</head>
|
<body>
|
<div class="container">
|
<div class="left">
|
<div class="easyui-panel pt-tree" style="border-right: none;">
|
<ul id="ul_module"></ul>
|
</div>
|
</div>
|
<div class="right">
|
<table id="dg_hasSelect"></table>
|
</div>
|
<div id="tb">
|
<a href="javascript:void(0);" onclick="delAll();" class="pt-btn pt-btn-danger"><i class="fa fa-trash-o"></i>全部删除</a>
|
</div>
|
<div class="search">
|
<div class="easyui-panel" style="padding:20px 20px; border-top:none;">
|
<input class="easyui-searchbox" data-options="prompt:'请输入模块名称',searcher:doSearch" style="width:100%">
|
|
</div>
|
</div>
|
|
<div class="pt-form-btn" style="bottom:0px;">
|
<div class="form-group">
|
<button type="button" class="pt-btn pt-btn-info" onclick="doSave();">确定</button>
|
<button type="reset" class="pt-btn pt-btn-default" onclick="doClose();">关闭</button>
|
</div>
|
</div>
|
</div>
|
</body>
|
|
<script>
|
//窗口参数,用于弹窗传递
|
var params = {
|
opts: null,
|
callBack: null
|
};
|
|
var multiSelect = "${multiSelect}" == "true";
|
|
//模块树URL
|
var url = "config/module/getModuleListByTree";
|
var data = [];
|
var dg;
|
|
var moduleTree = $("#ul_module").tree({
|
method: "post",
|
url: url,
|
animate: true,
|
checkbox: true,
|
cascadeCheck: false,
|
onBeforeLoad: function (node, param) {
|
new ResizeScroll({
|
"id": "#ul_module",
|
"height": "378"
|
});
|
|
wcp.ui.setBusy("#ul_module");
|
},
|
onLoadSuccess: function (node, data) {
|
wcp.ui.clearBusy("#ul_module");
|
new ResizeScroll({
|
"id": "#ul_module",
|
"height": "378"
|
});
|
|
//初始化树时,判断是否已经有备选的,如果有,则勾上
|
var hasRows = dg.datagrid("getRows");
|
if (hasRows != null) {
|
for (var i = 0; i < data.length; i++) {
|
for (var j = 0; j < hasRows.length; j++) {
|
if (data[i].id == hasRows[j].id) {
|
node = moduleTree.tree('find', data[i].id)
|
moduleTree.tree('check', node.target);
|
break;
|
}
|
}
|
}
|
}
|
|
},
|
onLoadError: function (args) {
|
wcp.ui.clearBusy("#ul_module");
|
},
|
onCheck: function (node, checked) {
|
//单选
|
if (checked & multiSelect == false) {
|
var allCheckedNodes = $('#ul_module').tree("getChecked");
|
for (var i = 0; i < allCheckedNodes.length; i++) {
|
var tempNode = allCheckedNodes[i];
|
|
if (tempNode.id != node.id) {
|
moduleTree.tree('uncheck', tempNode.target);
|
}
|
}
|
}
|
if (checked) {
|
var state = false;
|
var hasRows = dg.datagrid("getRows");
|
if (hasRows != null) {
|
for (var i = 0; i < hasRows.length; i++) {
|
if (node.id == hasRows[i].id) {
|
state = true;
|
break;
|
}
|
}
|
if (state != true) {
|
dg.datagrid("appendRow", {
|
"name": node.text,
|
"id": node.id,
|
"moduleIcon": node.iconCls
|
});
|
}
|
|
}
|
|
} else {
|
var hasRows = dg.datagrid("getRows");
|
if (hasRows != null) {
|
for (var i = 0; i < hasRows.length; i++) {
|
if (node.id == hasRows[i].id) {
|
dg.datagrid("deleteRow", i);
|
}
|
}
|
}
|
}
|
}
|
});
|
$(function () {
|
dg = $('#dg_hasSelect').datagrid({
|
data: data,
|
fitColumns: true,
|
nowrap: true,
|
rownumbers: true,
|
height: 380,
|
idField: "id",
|
emptyMsg: "没有找到匹配的记录",
|
toolbar: "#tb",
|
// frozenColumns:[[{field:'ck',checkbox:true}]],
|
columns: [[
|
{
|
field: 'name',
|
title: '模块名称',
|
width: 200
|
},
|
{
|
field: 'id',
|
title: '操作',
|
width: 100,
|
align: 'center',
|
formatter: function (value, row, index) {
|
return '<a href="javascript:void(0);" onclick="delTableRow(this,\'' + value + '\');" class="pt-color-danger"><i class="fa fa-trash-o" title="删除"></i></a>';
|
}
|
}
|
|
]],
|
|
onLoadSuccess: function () {
|
new ResizeScroll({
|
"id": ".datagrid-body",
|
"height": "311",
|
"index": 1
|
});
|
|
}
|
});
|
});
|
|
function delTableRow(target, value) {
|
var tr = $(target).closest('tr.datagrid-row');
|
var index = parseInt(tr.attr('datagrid-row-index'));
|
dg.datagrid('deleteRow', index);
|
var node = moduleTree.tree('find', value)
|
moduleTree.tree('uncheck', node.target);
|
}
|
|
//查询数据
|
function doSearch(value) {
|
moduleTree.tree({
|
queryParams: {
|
searchText: value
|
}
|
})
|
}
|
|
//确定按钮事件
|
function doSave() {
|
var hasRows = dg.datagrid("getRows");
|
//分隔符
|
var separator = params.opts.separator ? params.opts.separator : ",";
|
|
var ids = "";
|
var names = "";
|
|
for (var i = 0; i < hasRows.length; i++) {
|
ids += hasRows[i].id + separator;
|
names += hasRows[i].name + separator;
|
}
|
ids = ids.slice(0, -1);
|
names = names.slice(0, -1);
|
|
if (params.opts.layerOpener) {
|
if (params.opts.idElement) {
|
params.opts.layerOpener.$("#" + params.opts.idElement).val(ids);
|
}
|
if (params.opts.nameElement) {
|
params.opts.layerOpener.$("#" + params.opts.nameElement).val(names);
|
}
|
try {
|
params.opts.layerOpener.$("#" + params.opts.idElement).textbox("setValue", ids);
|
} catch (e) {
|
}
|
try {
|
params.opts.layerOpener.$("#" + params.opts.nameElement).textbox("setValue", names);
|
} catch (e) {
|
}
|
}
|
|
//回调函数
|
if (params.callBack) {
|
params.callBack(hasRows);
|
}
|
|
var index = top.layer.getFrameIndex(window.name); //获取窗口索引
|
top.layer.close(index);
|
}
|
|
function doClose() { //关闭按钮事件
|
var index = top.layer.getFrameIndex(window.name); //获取窗口索引
|
top.layer.close(index);
|
}
|
|
function delAll() {
|
var hasRows = dg.datagrid("getRows");
|
if (hasRows != null) {
|
var length = hasRows.length;
|
var arr = [];
|
for (var i = 0; i < length; i++) {
|
arr.push(hasRows[i]["id"]);
|
}
|
for (var i = 0; i < length; i++) {
|
var node = moduleTree.tree('find', arr[i])
|
if (node) {
|
moduleTree.tree('uncheck', node.target); //uncheck时,自动删除右边datagrid的数据
|
}
|
|
}
|
}
|
}
|
</script>
|
</html>
|