3.7.1版本发布

This commit is contained in:
JEECG
2024-09-10 15:40:34 +08:00
parent 17c68f6d53
commit 13cb18b707
106 changed files with 2832 additions and 1721 deletions

View File

@ -1,6 +1,5 @@
<template>
<BasicDrawer
title="部门角色权限配置"
:width="650"
:loading="loading"
showFooter
@ -9,18 +8,35 @@
@close="onClose"
@register="registerDrawer"
>
<template #title>
部门角色权限配置
<a-dropdown>
<Icon icon="ant-design:more-outlined" class="more-icon" />
<template #overlay>
<a-menu @click="treeMenuClick">
<a-menu-item key="checkAll">{{ t('component.tree.selectAll') }}</a-menu-item>
<a-menu-item key="cancelCheck">{{ t('component.tree.unSelectAll') }}</a-menu-item>
<div class="line"></div>
<a-menu-item key="openAll">{{ t('component.tree.expandAll') }}</a-menu-item>
<a-menu-item key="closeAll">{{ t('component.tree.unExpandAll') }}</a-menu-item>
<div class="line"></div>
<a-menu-item key="relation">{{ t('component.tree.checkStrictly') }}</a-menu-item>
<a-menu-item key="standAlone">{{ t('component.tree.checkUnStrictly') }}</a-menu-item>
</a-menu>
</template>
</a-dropdown>
</template>
<div>
<a-spin :spinning="loading">
<template v-if="treeData.length > 0">
<BasicTree
title="所拥有的部门权限"
toolbar
checkable
:treeData="treeData"
:checkedKeys="checkedKeys"
:selectedKeys="selectedKeys"
:expandedKeys="expandedKeys"
:checkStrictly="checkStrictly"
:checkStrictly="true"
:clickRowToExpand="false"
@check="onCheck"
@expand="onExpand"
@ -49,10 +65,11 @@
import { BasicTree } from '/@/components/Tree/index';
import { BasicDrawer, useDrawer, useDrawerInner } from '/@/components/Drawer';
import { useMessage } from '/@/hooks/web/useMessage';
import { useI18n } from '/@/hooks/web/useI18n';
import DepartRoleDataRuleDrawer from './DepartRoleDataRuleDrawer.vue';
import { queryTreeListForDeptRole, queryDeptRolePermission, saveDeptRolePermission } from '../depart.user.api';
import { translateTitle } from "@/utils/common/compUtils";
import { DEPART_ROLE_AUTH_CONFIG_KEY } from '/@/enums/cacheEnum';
defineEmits(['register']);
const { createMessage } = useMessage();
@ -65,25 +82,42 @@
const expandedKeys = ref<Array<any>>([]);
const selectedKeys = ref<Array<any>>([]);
const allTreeKeys = ref<Array<any>>([]);
const checkStrictly = ref(true);
//父子节点选中状态是否关联 true不关联false关联
const checkStrictly = ref(false);
const { t } = useI18n();
// 注册抽屉组件
const [registerDrawer, { closeDrawer }] = useDrawerInner((data) => {
roleId.value = data.record.id;
departId.value = data.record.departId;
loadData();
loadData({
success: (ids) => {
// update-begin--author:liaozhiyang---date:20240704---for【TV360X-1619】同步系统角色改法加上缓存默认层级关联修正原生层级关联bug
const localData = localStorage.getItem(DEPART_ROLE_AUTH_CONFIG_KEY);
if (localData) {
const obj = JSON.parse(localData);
obj.level && treeMenuClick({ key: obj.level });
obj.expand && treeMenuClick({ key: obj.expand });
} else {
// expandedKeys.value = ids;
}
// update-end--author:liaozhiyang---date:20240704---for【TV360X-1619】同步系统角色改法加上缓存默认层级关联修正原生层级关联bug
},
});
});
// 注册数据规则授权弹窗抽屉
const [registerDataRuleDrawer, dataRuleDrawer] = useDrawer();
async function loadData() {
async function loadData(options: any = {}) {
try {
loading.value = true;
// 用户角色授权功能,查询菜单权限树
const { ids, treeList } = await queryTreeListForDeptRole({ departId: departId.value });
if (ids.length > 0) {
allTreeKeys.value = ids;
expandedKeys.value = ids;
// update-begin--author:liaozhiyang---date:20240704---for【TV360X-1619】同步系统角色改法加上缓存默认层级关联修正原生层级关联bug
options.success?.(ids);
// update-end--author:liaozhiyang---date:20240704---for【TV360X-1619】同步系统角色改法加上缓存默认层级关联修正原生层级关联bug
//update-begin---author:wangshuai---date:2024-04-08---for:【issues/1169】我的部门功能中的【部门权限】中未翻译 t('') 多语言---
treeData.value = translateTitle(treeList);
//update-end---author:wangshuai---date:2024-04-08---for:【issues/1169】我的部门功能中的【部门权限】中未翻译 t('') 多语言---
@ -107,14 +141,59 @@
loading.value = false;
}
// tree勾选复选框事件
function onCheck(event) {
/**
* 点击选中
* 2024-07-04
* liaozhiyang
*/
function onCheck(o, e) {
// checkStrictly: true=>层级独立false=>层级关联.
if (checkStrictly.value) {
checkedKeys.value = event.checked;
checkedKeys.value = o.checked ? o.checked : o;
} else {
checkedKeys.value = event;
const keys = getNodeAllKey(e.node, 'children', 'key');
if (e.checked) {
// 反复操作下可能会有重复的keys得用new Set去重下
checkedKeys.value = [...new Set([...checkedKeys.value, ...keys])];
} else {
const result = removeMatchingItems(checkedKeys.value, keys);
checkedKeys.value = result;
}
}
}
/**
* 2024-07-04
* liaozhiyang
* 删除相匹配数组的项
*/
function removeMatchingItems(arr1, arr2) {
// 使用哈希表记录 arr2 中的元素
const hashTable = {};
for (const item of arr2) {
hashTable[item] = true;
}
// 使用 filter 方法遍历第一个数组,过滤出不在哈希表中存在的项
return arr1.filter((item) => !hashTable[item]);
}
/**
* 2024-07-04
* liaozhiyang
* 获取当前节点及以下所有子孙级的key
*/
function getNodeAllKey(node: any, children: any, key: string) {
const result: any = [];
result.push(node[key]);
const recursion = (data) => {
data.forEach((item: any) => {
result.push(item[key]);
if (item[children]?.length) {
recursion(item[children]);
}
});
};
node[children]?.length && recursion(node[children]);
return result;
}
// tree展开事件
function onExpand($expandedKeys) {
@ -158,4 +237,61 @@
}
}
}
/**
* 树菜单选择
* @param key
*/
function treeMenuClick({ key }) {
if (key === 'checkAll') {
checkedKeys.value = allTreeKeys.value;
} else if (key === 'cancelCheck') {
checkedKeys.value = [];
} else if (key === 'openAll') {
expandedKeys.value = allTreeKeys.value;
saveLocalOperation('expand', 'openAll');
} else if (key === 'closeAll') {
expandedKeys.value = [];
saveLocalOperation('expand', 'closeAll');
} else if (key === 'relation') {
checkStrictly.value = false;
saveLocalOperation('level', 'relation');
} else {
checkStrictly.value = true;
saveLocalOperation('level', 'standAlone');
}
}
/**
* 2024-07-04
* liaozhiyang
* */
const saveLocalOperation = (key, value) => {
const localData = localStorage.getItem(DEPART_ROLE_AUTH_CONFIG_KEY);
const obj = localData ? JSON.parse(localData) : {};
obj[key] = value;
localStorage.setItem(DEPART_ROLE_AUTH_CONFIG_KEY, JSON.stringify(obj));
};
</script>
<style lang="less" scoped>
/** 固定操作按钮 */
.jeecg-basic-tree {
position: absolute;
width: 618px;
}
.line {
height: 1px;
width: 100%;
border-bottom: 1px solid #f0f0f0;
}
.more-icon {
font-size: 20px !important;
color: black;
display: inline-flex;
float: right;
margin-right: 2px;
cursor: pointer;
}
:deep(.jeecg-tree-header) {
border-bottom: none;
}
</style>

View File

@ -3,7 +3,7 @@
<BasicTable @register="registerTable" :rowSelection="rowSelection">
<!--插槽:table标题-->
<template #tableTitle>
<a-button type="primary" preIcon="ant-design:plus-outlined" @click="addDepartRole">添加部门角色</a-button>
<a-button type="primary" preIcon="ant-design:plus-outlined" @click="addDepartRole" :disabled="!departId">添加部门角色</a-button>
<template v-if="selectedRowKeys.length > 0">
<a-divider type="vertical" />
<a-dropdown>

View File

@ -3,8 +3,8 @@
<BasicTable @register="registerTable" :rowSelection="rowSelection">
<!--插槽:table标题-->
<template #tableTitle>
<a-button type="primary" preIcon="ant-design:plus-outlined" @click="selectAddUser">添加已有用户</a-button>
<a-button type="primary" preIcon="ant-design:plus-outlined" @click="createUser">新建用户</a-button>
<a-button type="primary" preIcon="ant-design:plus-outlined" @click="selectAddUser" :disabled="!departId">添加已有用户</a-button>
<a-button type="primary" preIcon="ant-design:plus-outlined" @click="createUser" :disabled="!departId">新建用户</a-button>
<template v-if="selectedRowKeys.length > 0">
<a-dropdown>
<template #overlay>
@ -29,7 +29,7 @@
</BasicTable>
<UserDrawer @register="registerDrawer" @success="onUserDrawerSuccess" />
<DepartRoleUserAuthDrawer @register="registerUserAuthDrawer" />
<UserSelectModal rowKey="id" @register="registerSelUserModal" @getSelectResult="onSelectUserOk" />
<UserSelectModal ref="userSelectModalRef" rowKey="id" @register="registerSelUserModal" @getSelectResult="onSelectUserOk" />
</template>
<script lang="ts" setup>
@ -50,6 +50,7 @@
const props = defineProps({
data: { require: true, type: Object },
});
const userSelectModalRef: any = ref(null);
// 当前选中的部门ID可能会为空代表未选择部门
const departId = computed(() => props.data?.id);
@ -93,6 +94,9 @@
beforeFetch(params) {
params.depId = departId.value;
},
// update-begin--author:liaozhiyang---date:20240717---for【TV360X-1861】没部门时不加载用户信息
immediate: !!departId.value,
// update-end--author:liaozhiyang---date:20240717---for【TV360X-1861】没部门时不加载用户信息
},
});
@ -155,6 +159,9 @@
// 选择添加已有用户
function selectAddUser() {
// update-begin--author:liaozhiyang---date:20240308---for【TV360X-1613】再次打开还是上次的选中用户没置空
userSelectModalRef.value.rowSelection.selectedRowKeys = [];
// update-end--author:liaozhiyang---date:20240308---for【TV360X-1613】再次打开还是上次的选中用户没置空
selUserModal.openModal();
}