<!DOCTYPE html>
|
<html xmlns="http://www.w3.org/1999/xhtml">
|
<head>
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
<title>人员权限</title>
|
<meta name="renderer" content="webkit">
|
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
|
<link rel="stylesheet" href="../../layuiadmin/layui/css/layui.css" media="all">
|
<link rel="stylesheet" href="../../layuiadmin/style/admin.css" media="all">
|
<script src="../../layuiadmin/layui/layui.js"></script>
|
<script src="../../layuiadmin/treeTable.js"></script>
|
<script src="../../layuiadmin/Scripts/json2.js"></script>
|
<script src="../../layuiadmin/Scripts/jquery-1.4.1.js"></script>
|
<script src="../../layuiadmin/Scripts/webConfig.js"></script>
|
<script src="../../layuiadmin/layui/lay/modules/util.js"></script>
|
<style media="screen">
|
.custom-tree-item-clicked {
|
color: #FC9003
|
}
|
.layui-form-item .layui-inline {
|
margin-bottom: 5px;
|
margin-right: 0px;
|
}
|
</style>
|
</head>
|
<body>
|
<div class="layui-fluid">
|
<div class="layui-col-md12">
|
<div class="layui-card" style="padding: 1px">
|
<div class="layui-card-body" style="padding: 1px;">
|
<form class="layui-form" action="" lay-filter="component-form-group">
|
<div class="layui-card-header">
|
<div class="layui-btn-group">
|
<button type="button" class="layui-btn layui-btn-normal layui-btn-radius" lay-submit="" lay-filter="get_Refresh">刷新</button>
|
<button type="button" id="add-btn" class="layui-btn layui-btn-normal layui-btn-radius" lay-submit="" lay-filter="Saver">授权</button>
|
<button type="button" class="layui-btn layui-btn-normal layui-btn-radius" lay-submit="" lay-filter="Exit">退出</button>
|
|
</div>
|
|
</div>
|
<div class="layui-collapse">
|
<div class="layui-colla-item">
|
<div class="layui-form-item" style="border-top: solid 1px #F6F6F6;">
|
<div class="layui-row" style="padding:10px 0">
|
<div class="layui-col-xs3 layui-inline">
|
<div id="treeUser" lay-filter="treeUser" class="demo-tree demo-tree-box" style="height:650px;overflow: scroll;"></div>
|
</div>
|
<div class="layui-col-xs9 layui-inline">
|
<div>
|
<table class="" id="mainTable" lay-filter="mainTable"></table>
|
</div>
|
</div>
|
</div>
|
</div>
|
</div>
|
</div>
|
</form>
|
</div>
|
</div>
|
</div>
|
</div>
|
|
<script src="../../layuiadmin/layui/zgqlayui.js"></script>
|
<script src="../../layuiadmin/zgqCustom/zgqCustom.js"></script>
|
<script src="../../layuiadmin/PubCustom.js"></script>
|
<script>
|
//获取参数
|
var params = get_UrlVars();
|
if (typeof (params[params[0]]) == "undefined") {
|
var OperationType = 1;//操作类型
|
var TreeFlag = true;//操作类型
|
} else {
|
debugger;
|
var OperationType = params[params[0]];//操作类型
|
var linterid = params[params[1]];//源单id
|
var HSouceBillType = params[params[2]];//源单类型
|
}
|
|
var treeCkData = { id: 0 };
|
var TagId = "";
|
var TagParentId = "";
|
|
layui.config({
|
base: '../../layuiadmin/' //静态资源所在路径
|
}).extend({
|
index: 'lib/index', //主入口模块
|
}).use(['tree', 'index', 'form', 'table', 'element', 'laypage', 'laydate'], function () {
|
var $ = layui.$
|
, admin = layui.admin
|
, layer = layui.layer
|
, table = layui.table
|
, form = layui.form
|
, element = layui.element
|
, laypage = layui.laypage
|
, laydate = layui.laydate
|
, util = layui.util
|
, tree = layui.tree
|
var sGnbm = "";
|
if (TreeFlag == "false") {
|
//$(".layui-col-xs3").css("display", "none"); //隐藏树型
|
//$(".layui-col-xs9").css("width", "100%"); //设置宽度
|
}
|
else {
|
tree.render({
|
elem: '#treeUser',
|
data: getData(),
|
showCheckbox: false, //是否显示复选框
|
id: 'demoId',
|
isJump: false, //是否允许点击节点时弹出新窗口跳转
|
showLine: true,//是否开启连接线
|
onlyIconControl: true, //点击后不收缩
|
isopen: false, //加载完毕后的展开状态,默认值:true
|
accordion: false,
|
click: function (obj) {
|
//点击高光
|
if (obj.data.id !== treeCkData.id) {
|
$('div[data-id="' + obj.data.id + '"] span').eq(1).last().addClass("custom-tree-item-clicked");
|
$('div[data-id="' + treeCkData.id + '"] span').eq(1).last().removeClass('custom-tree-item-clicked');
|
treeCkData = obj.data;
|
TagId = obj.data.id;
|
TagParentId = obj.data.ParentID;
|
}
|
//else {
|
// $('div[data-id="' + treeCkData.id + '"] span').eq(1).last().removeClass('custom-tree-item-clicked');
|
// treeCkData = { id: 0 };
|
// TagId = "";
|
// TagParentId = "";
|
//}
|
sGnbm = obj.data.id;
|
get_Display(sGnbm);
|
}
|
});
|
}
|
|
|
|
var option = {
|
id: 'mainTable'
|
,elem: '#mainTable'
|
//, toolbar: '#toolbarDemo'
|
, height: '650'
|
, limit: Number.MAX_VALUE // 数据表格默认全部显示
|
, page: false
|
, cellMinWidth: 90
|
, cols: [[
|
{ type: 'checkbox', fixed: 'left', width: 60 }
|
, { field: 'hid', title: 'hid', sort: true, hide: true }
|
, { field: 'gnbm', title: 'gnbm', sort: true, hide: true }
|
, { field: 'AuthorityHID', title: 'AuthorityHID', edit: 'text', sort: true, hide: true }
|
, {
|
field: 'AuthorityID', title: '是否权限', templet: function (row) {
|
if (row.AuthorityID == 1) {
|
return "<span style='color:green;'>是</span>";
|
}
|
else {
|
return "否";
|
}
|
}
|
}
|
//, {
|
// field: 'AuthorityHID', title: '是否权限', templet: function (row) {
|
// var html = "<input type='checkbox' lay-skin='primary' lay-filter='checkboxIsSelected' table-index='" + row.LAY_TABLE_INDEX + "' class='checkboxIsSelected' value='" + row.AuthorityHID + "' ";
|
// if (row.AuthorityID == 1) {
|
// html += " checked ";
|
// }
|
// html += ">";
|
// return html;
|
// }}
|
, { field: 'gnms', title: '功能说明' }
|
]], done: function (res, page, count) {
|
|
//可以自行添加判断的条件是否选中
|
//这句才是真正选中,通过设置关键字LAY_CHECKED为true选中,这里只对第一行选中
|
for (var i = 0; i < res.data.length; i++) {
|
if (res.data[i].AuthorityID == 1) {
|
res.data[i]["LAY_CHECKED"] = 'true';
|
//下面三句是通过更改css来实现选中的效果
|
var index = res.data[i]['LAY_TABLE_INDEX'];
|
$('tr[data-index=' + index + '] input[type="checkbox"]').prop('checked', true);
|
$('tr[data-index=' + index + '] input[type="checkbox"]').next().addClass('layui-form-checked');
|
}
|
}
|
|
}
|
};
|
|
var index = layer.load(0, { shade: false });
|
//进入页面显示的缓存列表
|
get_Display(sGnbm);
|
|
|
//退出
|
form.on('submit(Exit)', function (data) {
|
if (OperationType == 1) {
|
//关闭页签
|
Pub_Close(2);
|
}
|
else {
|
//关闭页签
|
Pub_Close(1);
|
}
|
});
|
|
//刷新按钮
|
form.on('submit(get_Refresh)', function () {//提交
|
layer.confirm('继续对当前所选用户进行更改权限?', { icon: 3, title: '提示' }, function (index) {
|
location.replace('PowerInformation.html?OperationType=3&linterid=' + linterid + '&HSouceBillType=');
|
});
|
})
|
|
//监听选中数据
|
table.on('checkbox(mainTable)', function (obj) {
|
//console.log(obj.checked); //当前是否选中状态
|
//console.log(obj.data); //选中行的相关数据
|
//console.log(obj.type); //如果触发的是全选,则为:all,如果触发的是单选,则为:one
|
if (obj.type == 'one') {
|
if (obj.checked) {
|
//同步更新表格和缓存对应的值
|
obj.update({
|
AuthorityHID: 1,
|
});
|
}
|
else {
|
//同步更新表格和缓存对应的值
|
obj.update({
|
AuthorityHID: 0,
|
});
|
}
|
}
|
else {
|
if (obj.checked) {
|
//同步更新表格和缓存对应的值
|
var tableBak = table.cache["mainTable"]; //获取表格数据
|
buttonArr = [];//清空数组
|
for (var i = 0; i < tableBak.length; i++) {
|
tableBak[i].AuthorityHID = 1;
|
buttonArr.push(tableBak[i]); //将之前的数据存储
|
}
|
//table.reload("mainTable", {
|
// data: buttonArr //将数据重新载入表格
|
//})
|
}
|
else {
|
//同步更新表格和缓存对应的值
|
var tableBak = table.cache["mainTable"]; //获取表格数据
|
buttonArr = [];//清空数组
|
for (var i = 0; i < tableBak.length; i++) {
|
tableBak[i].AuthorityHID = 0;
|
buttonArr.push(tableBak[i]); //将之前的数据存储
|
}
|
//table.reload("mainTable", {
|
// data: buttonArr //将数据重新载入表格
|
//})
|
|
|
}
|
}
|
|
});
|
|
//保存
|
form.on('submit(Saver)', function (data) {
|
if (TagId == "" || TagId == null) {
|
layer.alert("左侧点击树型数据已失效!", { icon: 5 });
|
return false;
|
}
|
var sSubStr = JSON.stringify(table.cache['mainTable']);
|
var sMainSub = TagId + ';' + sSubStr + ';' + linterid;
|
//console.log(sMainSub);
|
//return false;
|
$.ajax(
|
{
|
type: "POST",
|
url: GetWEBURL() + "/Gy_MaintenanceMode/SaverPower", //方法所在页面和方法名
|
async: true,
|
data: { "msg": sMainSub },
|
dataType: "json",
|
success: function (data) {
|
if (data.count == 1) { // 说明验证成功了,
|
layer.msg(data.Message, { time: 1 * 1000, icon: 1 }, function () {
|
$('#add-btn').addClass("layui-btn-disabled").attr("disabled", true);
|
get_Display(sGnbm);
|
});
|
}
|
else {
|
layer.alert(data.Message);
|
}
|
layer.closeAll("loading");
|
},
|
error: function (err) {
|
layer.alert("错误:" + err);
|
}
|
});
|
|
|
|
});
|
|
//加载数据表格
|
function get_Display(sGnbm) {
|
$.ajax({
|
url: GetWEBURL() + '/PublicPageMethod/PowerList',
|
type: "GET",
|
data: { "czybm": linterid, "sGnbm": sGnbm },
|
success: function (data1) {
|
if (data1.count == 1) {
|
option.data = data1.data;
|
table.render(option);
|
layer.close(index);
|
}
|
}, error: function () {
|
layer.close(index);
|
layer.alert("接口请求失败!", { icon: 5 });
|
}
|
});
|
}
|
|
//以上是layui模块
|
});
|
|
//查询树状数据
|
function getData() {
|
var treeData;
|
|
$.ajax({
|
url: GetWEBURL() + '/Gy_MaintenanceMode/PowerLoadTree',
|
type: "GET",
|
//data: { "sWhere": sWhere },
|
async: false,
|
success: function (result) {
|
var data = result.data;
|
//生成数据对象集合
|
treeData = LoadTree(data);
|
|
}
|
});
|
return treeData;
|
}
|
/**处理树形展示数据,要求有ID和ParentID、title字段**/
|
function LoadTree(data) {
|
let map = {};
|
let treeData = [];
|
data.forEach(it => {
|
map[it.id.toUpperCase()] = it; //ID为每个节点的id
|
})
|
//生成结果集
|
data.forEach(it => {
|
const parent = map[it.ParentID.toUpperCase()]; //ParentID为父节点的id
|
if (parent) {
|
if (!Array.isArray(parent.children)) parent.children = [];
|
parent.children.push(it);
|
} else {
|
treeData.push(it)
|
}
|
})
|
return treeData;
|
}
|
|
</script>
|
|
</body>
|
</html>
|