提交 07f2c312 编写于 作者: Skyeye云's avatar Skyeye云

团队权限静态页面完成

上级 ba704782
......@@ -22,13 +22,14 @@ layui.config({
tableTree.render({
id: 'messageTable',
elem: '#messageTable',
data: [{"id": "123qwe", "name": "阿萨斯多", "pId": "0", "lay_is_open": true},
{"id": "123qwe1", "name": "阿萨斯多qqq", "pId": "123qwe", "lay_is_open": true}],
data: [],
// 该参数不能删除,分页参数无效,目前只能通过设置10000来保证当前页最大的数据量
limit: 10000,
cols: [[
{ field: 'name', title: '名称', width: 120 },
{ field: 'menuNameEn', title: '部门', width: 150 },
{ field: 'orderNum', title: '邮箱', width: 150 },
{ field: 'desktopName', title: '联系方式', width: 120 },
{ field: 'name', title: '名称', width: 160 },
{ field: 'departmentName', title: '部门', width: 120 },
{ field: 'phone', title: '联系方式', width: 140 },
{ field: 'email', title: '邮箱', width: 200 },
{ title: systemLanguage["com.skyeye.operation"][languageType], fixed: 'right', align: 'center', width: 150, toolbar: '#tableBar' }
]],
done: function(json) {
......@@ -44,26 +45,52 @@ layui.config({
tableTree.getTable().on('tool(messageTable)', function (obj) {
var data = obj.data;
var layEvent = obj.event;
if (layEvent === 'removeRole') { // 移除角色
if (layEvent === 'removeRole') {
// 移除角色和该角色下的用户
$.each(treeTableData, function(index, item) {
if (item.id == data.id) {
if (item.id == data.id || item.pId == data.id) {
treeTableData.splice(index, 1);
}
});
reloadTreeTable();
} else if (layEvent === 'addUser') { // 添加成员
var roleId = data.id;
systemCommonUtil.userReturnList = [];
systemCommonUtil.chooseOrNotMy = "1"; // 人员列表中是否包含自己--1.包含;其他参数不包含
systemCommonUtil.chooseOrNotEmail = "2"; // 人员列表中是否必须绑定邮箱--1.必须;其他参数没必要
systemCommonUtil.checkType = "1"; // 人员选择类型,1.多选;其他。单选
systemCommonUtil.openSysUserStaffChoosePage(function (userReturnList) {
console.log(userReturnList)
var userList = [].concat(userReturnList);
$.each(userList, function (i, item) {
// 一个用户在一个团队中只能属于一个角色
var checkParams = getInPoingArr(treeTableData, "id", item.id);
if (checkParams == null) {
item['pId'] = roleId;
treeTableData.push(item);
}
});
reloadTreeTable();
});
} else if (layEvent === 'removeUser') { // 移除成员
var roleId = data.pId;
var userId = data.id;
$.each(treeTableData, function(index, item) {
if (!isNull(item) && item.pId == roleId && item.id == userId) {
treeTableData.splice(index, 1);
}
});
reloadTreeTable();
}
});
}
// 刷新成员树表格
function reloadTreeTable() {
var data = $.extend(true, [], treeTableData);
tableTree.reload("messageTable", {data: data});
loadAuthList();
}
loadAuthList();
form.on('select(objectType)', function(data) {
loadAuthList();
......@@ -72,6 +99,7 @@ layui.config({
matchingLanguage();
form.render();
form.on('submit(formAddBean)', function (data) {
console.log(treeTableData)
if (winui.verifyForm(data.elem)) {
var params = {
dictName: $("#dictName").val(),
......@@ -88,8 +116,65 @@ layui.config({
});
function loadAuthList() {
var data = $.extend(true, [], treeTableData);
var objectType = $('#objectType').val();
teamObjectPermissionUtil.insertPageShow(objectType, 'authList', form);
// 加载该受用类型的团队可以设置哪些权限
var colsList = teamObjectPermissionUtil.getAuthCols(objectType);
$('#authList').html(getDataUseHandlebars($('#authTableTemplate').html(), {list: colsList}));
$.each(colsList, function (i, item) {
// 给数据设置权限组的key,
$.each(data, function (j, bean) {
bean.authGroupKey = item.id;
});
loadAuthTreeTable(item.id, item.cols, data);
});
form.on('checkbox(checkClick)', function(obj) {
// var checkRow = $("#useTable input[type='checkbox'][name='tableCheckRow']:checked");
var id = $(this).attr('id');
var str = id.split('_');
var authGroupKey = str[0];
var authKey = str[1];
var roleId = str[2];
var userId = str[3];
var checkBoxId = authGroupKey + '_' + authKey + '_' + roleId + '_' + userId;
var name = authGroupKey + '_' + authKey + '_' + roleId;
var _table = $(`div[lay-id='${authGroupKey}']`);
if (isNull(userId)) {
// 如果用户id为空,代表点击的是角色的选择box,需要把name是这个的都选中
if (obj.elem.checked) {
_table.find(`input[name='${name}']`).prop("checked", true);
} else {
_table.find(`input[name='${name}']`).prop("checked", false);
}
} else {
if (obj.elem.checked) {
if (_table.find(`input[name='${name}']:checked`).length
== _table.find(`input[name='${name}']`).length - 1) {
$(`input[id='${name}_']`).prop("checked", true);
}
} else {
$(`input[id='${name}_']`).prop("checked", false);
}
}
form.render('checkbox');
});
}
function loadAuthTreeTable(id, cols, data) {
tableTree.render({
id: id,
elem: '#' + id,
data: data,
// 该参数不能删除,分页参数无效,目前只能通过设置10000来保证当前页最大的数据量
limit: 10000,
cols: [cols],
}, {
keyId: 'id',
keyPid: 'pId',
title: 'name',
defaultShow: true,
});
}
$("body").on("click", "#addRole", function() {
......@@ -104,7 +189,7 @@ layui.config({
turnData["pId"] = '0';
turnData["lay_is_open"] = true;
treeTableData.push(turnData);
tableTree.reload("messageTable", {data: treeTableData});
reloadTreeTable();
} else {
winui.window.msg("角色重复", {icon: 2, time: 2000});
}
......
......@@ -44,6 +44,7 @@
<div class="layui-form-item layui-col-xs12">
<label class="layui-form-label">成员信息:</label>
<div class="layui-input-block">
<div class="winui-tip alert-info" id="showInfo">一个用户在一个团队中只能属于一个角色。</div>
<div class="winui-toolbar">
<div class="winui-tool" style="text-align: left;">
<button id="addRole" class="winui-toolbtn" type="button"><i class="fa fa-plus" aria-hidden="true"></i>添加角色</button>
......@@ -80,33 +81,14 @@
</script>
<script type="text/x-handlebars-template" id="authTableTemplate">
{{#json}}
{{#list}}
<div class="layui-form-item layui-col-xs12">
<label class="layui-form-label">{{bean.name}}<i class="red">*</i></label>
<label class="layui-form-label">{{title}}<i class="red">*</i></label>
<div class="layui-input-block">
<table class="layui-table">
<thead>
<tr>
<th>成员</th>
{{#each rows}}
<th>{{name}}</th>
{{/each}}
</tr>
</thead>
<tbody id="{{bean.key}}" class="insurance-table">
{{#each roleList}}
<tr>
<td>{{name}}</td>
{{#each ../rows}}
<th>{{name}}</th>
{{/each}}
</tr>
{{/each}}
</tbody>
</table>
<table id="{{id}}" lay-filter="{{id}}"></table>
</div>
</div>
{{/json}}
{{/list}}
</script>
<script src="../../assets/lib/layui/layui.js"></script>
......
......@@ -2,55 +2,51 @@
// 团队成员权限工具
var teamObjectPermissionUtil = {
template: `{{#json}}
<div class="layui-form-item layui-col-xs12">
<label class="layui-form-label">{{bean.name}}<i class="red">*</i></label>
<div class="layui-input-block">
<table class="layui-table">
<thead>
<tr>
<th>成员</th>
{{#each rows}}
<th>{{name}}</th>
{{/each}}
</tr>
</thead>
<tbody id="{{bean.key}}" class="insurance-table">
{{#each roleList}}
<tr>
<td>{{name}}</td>
{{#each ../rows}}
<th>{{name}}</th>
{{/each}}
</tr>
{{/each}}
</tbody>
</table>
</div>
</div>
{{/json}}`,
// 新增时的展示
insertPageShow: function (objectType, showBoxId, form) {
getAuthCols: function (objectType) {
if (isNull(objectType)) {
$(`#${showBoxId}`).html('');
} else {
jsGetJsonFile("../../json/teamObjectLink.json", function(data) {
var authStrList = data[objectType];
var str = ``;
$.each(authStrList, function(i, item) {
var bean = {
key: item,
name: skyeyeClassEnum[item].name
};
var authBtnJson = skyeyeClassEnumUtil.getEnumDataListByClassName(item);
authBtnJson["bean"] = bean;
str += getDataUseHandlebars($('#authTableTemplate').html(), {json: authBtnJson});
return [];
} else {
var teamObjectType = skyeyeClassEnumUtil.getEnumDataListByClassName("teamObjectType").rows;
var pageAuthList = getInPoingArr(teamObjectType, "id", objectType, "pageAuth");
if (pageAuthList == null) {
return [];
}
var result = [];
$.each(pageAuthList, function(i, enumKey) {
var map = {
id: enumKey,
title: skyeyeClassEnum[enumKey].name
};
// 获取枚举中需要鉴权的内容
var authBtnJson = skyeyeClassEnumUtil.getEnumDataListByClassName(enumKey).rows;
var cols = [];
cols.push({
field: 'name',
title: '名称',
width: 160
});
$.each(authBtnJson, function(j, item) {
cols.push({
field: item.id,
title: item.name,
align: 'center',
width: 140,
templet: function(row) {
var roleId = row.pId == '0' ? row.id : row.pId;
var authGroupKey = row.authGroupKey;
var authKey = $(this)[0].field;
var userId = row.pId == '0' ? '' : row.id;
var checkBoxId = authGroupKey + '_' + authKey + '_' + roleId + '_' + userId;
var name = authGroupKey + '_' + authKey + '_' + roleId;
return `<input type="checkbox" id="${checkBoxId}" name="${name}" lay-filter="checkClick"/>`;
}
});
});
$(`#${showBoxId}`).html(str);
map['cols'] = cols;
result.push(map);
});
return result;
}
form.render();
}
}
......@@ -67,7 +67,6 @@ layui.define(['table', 'jquery'], function (exports) {
}
// 整理数据初始状态
var loadData = false;
const parseData = obj.parseData || {};
obj.parseData = (res) => {
if (JSON.stringify(parseData) !== "{}") {
......@@ -75,7 +74,6 @@ layui.define(['table', 'jquery'], function (exports) {
}
this._initDo()
res.rows = this._parse(res.rows);
loadData = true;
return res;
}
......@@ -88,9 +86,6 @@ layui.define(['table', 'jquery'], function (exports) {
}
}
table.render(obj);
if (!loadData) {
this._initDo()
}
}
// 重载
......
......@@ -433,12 +433,9 @@ layui.config({
//获取选中节点
var zTree = ztr.getCheckedNodes(true);
for (var i = 0; i < zTree.length; i++) {
if(zTree[i].folderType === 'isPeople'){//选中节点是人
addToArray({
id: zTree[i].id,
name: zTree[i].name,
email: zTree[i].email
});
if(zTree[i].folderType === 'isPeople'){
// 选中节点是人
addToArray(zTree[i]);
setUpTreeNodeCheckOrNot(zTree[i].id, true);
}
}
......@@ -504,12 +501,7 @@ layui.config({
//如果该元素在集合中不存在
if(!inArray) {
var j = {
id: data.id,
name: data.name,
email: data.email
};
userOperatorReturnList.push(j);
userOperatorReturnList.push(data);
showPeople();
}
}
......
......@@ -23,7 +23,6 @@
"skyeyeView": {"name": "视图枚举", "className": "skyeye-pro#com.skyeye.common.SkyeyeViewEnum"},
"teamObjectType": {"name": "团队适用对象枚举", "className": "skyeye-pro#com.skyeye.team.classenum.TeamObjectTypeEnum"},
"contactsAuthEnum": {"name": "联系人", "className": "skyeye-pro#com.skyeye.contacts.classenum.ContactsAuthEnum"}
}
\ No newline at end of file
{
"1": ["contactsAuthEnum"],
"2": ["contactsAuthEnum"],
"3": []
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册