增加:编目系统修改目录页面成员授权增加应用到下级的选项

master
guoxin 1 year ago
parent 84cd539ff5
commit f5ed96dca8
  1. 3
      dbsql/update/update202309.sql
  2. 5
      shandan-system/src/main/java/com/keyware/shandan/bianmu/entity/DirectoryMembersVo.java
  3. 16
      shandan-system/src/main/java/com/keyware/shandan/bianmu/service/DirPermissionService.java
  4. 39
      shandan-system/src/main/resources/static/js/business/directory/member.js

@ -0,0 +1,3 @@
alter table BIANMU.B_DIRECTORY_MEMBERS add APPLY_CHILDREN bit default 0;
comment on column BIANMU.B_DIRECTORY_MEMBERS.APPLY_CHILDREN is '是否应用到子节点';

@ -50,6 +50,11 @@ public class DirectoryMembersVo extends BaseEntity {
*/
@TableField("PERMIS_TYPE")
private String permisType;
/**
* 是否应用到子节点
*/
@TableField("APPLY_CHILDREN")
private Boolean applyChildren;
/**
* 设置部门

@ -1,6 +1,7 @@
package com.keyware.shandan.bianmu.service;
import cn.hutool.core.lang.Assert;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.keyware.shandan.bianmu.entity.DirectoryMembersVo;
import com.keyware.shandan.bianmu.entity.DirectoryVo;
@ -78,6 +79,21 @@ public class DirPermissionService {
selectUserList().forEach(u -> userCache.put(u.getUserId(), u));
putMemberCache(membersService.listByUserId(user.getUserId()));
putMemberCache(membersService.listByOrgId(user.getOrgId()));
if (user.getOrg() != null) {
SysOrg org = user.getOrg();
List<String> parentsIdList = Arrays.asList(org.getOrgPath().split("\\|"));
LambdaQueryWrapper<DirectoryMembersVo> query = new LambdaQueryWrapper<>();
query.in(DirectoryMembersVo::getMemberId, parentsIdList);
membersService.list(query).stream().filter(DirectoryMembersVo::getApplyChildren).forEach(m -> {
m.setMemberId(user.getUserId());
m.setMemberType(DirectoryMembersVo.MemberType.USER);
m.setId(null);
putMemberCache(Collections.singletonList(m));
});
}
roleCache.put(user.getUserId(), roleService.getUserRoles(user.getUserId()));
refreshPermisCache(user);

@ -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
}
})
}