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