|
|
|
@ -105,7 +105,7 @@ function openMembersManageLayer(data) { |
|
|
|
|
function addUserMembers() { |
|
|
|
|
let ids = global_members.filter(item => item.memberType === 'USER').map(item => item.memberId); |
|
|
|
|
openUserSelectLayer(false, ids).then(users => { |
|
|
|
|
choosePermisOps().then(p => { |
|
|
|
|
choosePermitsOps('USER').then(p => { |
|
|
|
|
saveMembers(convertMembers(users, 'USER', p)); |
|
|
|
|
}) |
|
|
|
|
}) |
|
|
|
@ -117,7 +117,7 @@ function openMembersManageLayer(data) { |
|
|
|
|
function addOrgMembers() { |
|
|
|
|
let ids = global_members.filter(item => item.memberType === 'ORG').map(item => item.memberId); |
|
|
|
|
openOrgSelectLayer('p-casc').then(orgs => { |
|
|
|
|
choosePermisOps().then(p => { |
|
|
|
|
choosePermitsOps('ORG').then(p => { |
|
|
|
|
saveMembers(convertMembers(orgs, 'ORG', p)); |
|
|
|
|
}) |
|
|
|
|
}) |
|
|
|
@ -132,9 +132,10 @@ function openMembersManageLayer(data) { |
|
|
|
|
showErrorMsg('请至少选择一条数据'); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
choosePermisOps().then(p => { |
|
|
|
|
const hasOrg = members.some(member => member.memberType === 'ORG'); |
|
|
|
|
choosePermitsOps(hasOrg ? 'ORG' : 'USER').then(p => { |
|
|
|
|
let params = members.map(m => { |
|
|
|
|
return {id: m.id, permisType: p} |
|
|
|
|
return {id: m.id, permisType: p.permitsType, applyChildren: p.applyChildren} |
|
|
|
|
}); |
|
|
|
|
saveMembers(params); |
|
|
|
|
}) |
|
|
|
@ -180,35 +181,34 @@ function openMembersManageLayer(data) { |
|
|
|
|
* 选择权限弹框 |
|
|
|
|
* @returns {Promise<unknown>} |
|
|
|
|
*/ |
|
|
|
|
function choosePermisOps() { |
|
|
|
|
function choosePermitsOps(memberType) { |
|
|
|
|
const isOrg = memberType === 'ORG'; |
|
|
|
|
const applyChild = isOrg ? 'checked' : '' |
|
|
|
|
return new Promise(resolve => { |
|
|
|
|
layer.open({ |
|
|
|
|
type: 1, |
|
|
|
|
title: '选择权限', |
|
|
|
|
btn: ['确定'], |
|
|
|
|
content: `<div class="layui-form permis-choose" style="padding-left: 20px">
|
|
|
|
|
content: `<div class="layui-form permis-choose" lay-filter="permits-choose-form" style="padding-left: 20px; padding-top: 20px;">
|
|
|
|
|
<div class="layui-form-item"> |
|
|
|
|
<div class="layui-inline"> |
|
|
|
|
<input type="checkbox" lay-skin="primary" value="read" title="查看权限" checked> |
|
|
|
|
<input type="radio" name="permitsType" lay-skin="primary" value="read" title="仅查看权限" checked> |
|
|
|
|
<input type="radio" name="permitsType" lay-skin="primary" value="read,write" title="查看和修改权限"> |
|
|
|
|
</div> |
|
|
|
|
</div> |
|
|
|
|
<div class="layui-form-item"> |
|
|
|
|
<div class="layui-inline"> |
|
|
|
|
<input type="checkbox" lay-skin="primary" value="write" title="修改权限"> |
|
|
|
|
<input type="checkbox" name="applyChildren" lay-skin="primary" ${isOrg ? '' : 'disabled'} value="1" ${applyChild} title="将此权限设置应用到下级所有部门"> |
|
|
|
|
</div> |
|
|
|
|
</div> |
|
|
|
|
</div>`, |
|
|
|
|
success: function () { |
|
|
|
|
form.render('checkbox'); |
|
|
|
|
form.render(); |
|
|
|
|
}, |
|
|
|
|
yes: function (index) { |
|
|
|
|
let values = []; |
|
|
|
|
$('.permis-choose input[type="checkbox"]:checked').each((i, elem) => values.push($(elem).val())); |
|
|
|
|
if (values.length === 0) { |
|
|
|
|
showErrorMsg('请至少选择一个选项'); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
resolve && resolve(values.join(',')); |
|
|
|
|
let value = form.val('permits-choose-form'); |
|
|
|
|
value.applyChildren = !!value.applyChildren |
|
|
|
|
resolve && resolve(value); |
|
|
|
|
layer.close(index) |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
@ -228,17 +228,18 @@ function openMembersManageLayer(data) { |
|
|
|
|
* 转换成员对象 |
|
|
|
|
* @param items |
|
|
|
|
* @param memberType |
|
|
|
|
* @param permis |
|
|
|
|
* @param permits |
|
|
|
|
* @returns {*} |
|
|
|
|
*/ |
|
|
|
|
function convertMembers(items, memberType, permis) { |
|
|
|
|
function convertMembers(items, memberType, permits) { |
|
|
|
|
return items.map(item => { |
|
|
|
|
return { |
|
|
|
|
directoryId: data.id, |
|
|
|
|
memberId: memberType === 'USER' ? item.userId : item.id, |
|
|
|
|
memberName: memberType === 'USER' ? item.userName : item.context, |
|
|
|
|
memberType: memberType, |
|
|
|
|
permisType: permis, |
|
|
|
|
permisType: permits.permitsType, |
|
|
|
|
applyChildren: permits.applyChildren |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|