微调
This commit is contained in:
@@ -21,6 +21,7 @@
|
||||
</el-form-item>
|
||||
<el-form-item label="图标" prop="icon" :label-width="100">
|
||||
<IconSelect
|
||||
v-model="formContent.icon"
|
||||
:iconValue="formContent.icon"
|
||||
@update:icon-value="iconValue => formContent.icon = iconValue"
|
||||
placeholder="选择一个图标"
|
||||
|
||||
@@ -9,12 +9,12 @@
|
||||
<!-- :data='userData' -->
|
||||
<!-- 表格 header 按钮 -->
|
||||
<template #tableHeader>
|
||||
<el-button type='primary' :icon='CirclePlus' @click="openDialog('add')">新增</el-button>
|
||||
<el-button v-auth.resource="'add'" type='primary' :icon='CirclePlus' @click="openDialog('add')">新增</el-button>
|
||||
</template>
|
||||
<!-- 表格操作 -->
|
||||
<template #operation='scope'>
|
||||
<el-button type='primary' link :icon='EditPen' @click="openDialog('edit', scope.row)">编辑</el-button>
|
||||
<el-button type='primary' link :icon='Delete' @click='handleDelete(scope.row)'>删除</el-button>
|
||||
<el-button v-auth.testScript="'edit'" type='primary' link :icon='EditPen' @click="openDialog('edit', scope.row)">编辑</el-button>
|
||||
<el-button v-auth.resource="'delete'" type='primary' link :icon='Delete' @click='handleDelete(scope.row)'>删除</el-button>
|
||||
</template>
|
||||
</ProTable>
|
||||
|
||||
|
||||
@@ -146,10 +146,14 @@ const open = async (sign: string, data: Role.RoleBO, AllFunction: Function.ResFu
|
||||
const allIds = getAllIds(AllFunction);
|
||||
// 匹配 roleFunctions 中的 id 并设置 checkedKeys
|
||||
const checkedKeys = allIds.filter(id => roleFunctions.some(roleFunc => roleFunc.id === id));
|
||||
|
||||
// 过滤出叶子节点
|
||||
const leafCheckedKeys = filterLeafNodes(AllFunction, checkedKeys);
|
||||
|
||||
// 设置 functionList 和 checkedKeys
|
||||
functionList.value = AllFunction;
|
||||
checkedKeysRef.value = checkedKeys;
|
||||
|
||||
checkedKeysRef.value = leafCheckedKeys;
|
||||
|
||||
// nextTick(() => {
|
||||
// // 触发一次更新,确保表单中的数据被更新
|
||||
// dialogFormRef.value?.validate();
|
||||
@@ -166,14 +170,32 @@ const open = async (sign: string, data: Role.RoleBO, AllFunction: Function.ResFu
|
||||
}
|
||||
}
|
||||
|
||||
const filterLeafNodes = (functions: Function.ResFunction[], checkedKeys: string[]): string[] => {
|
||||
const leafNodes: string[] = [];
|
||||
const isLeafNode = (func: Function.ResFunction) => !func.children || func.children.length === 0;
|
||||
|
||||
const traverse = (funcs: Function.ResFunction[]) => {
|
||||
for (const func of funcs) {
|
||||
if (isLeafNode(func)) {
|
||||
if (checkedKeys.includes(func.id)) {
|
||||
leafNodes.push(func.id);
|
||||
}
|
||||
} else {
|
||||
traverse(func.children);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
traverse(functions);
|
||||
return leafNodes;
|
||||
};
|
||||
const getAllIds = (functions: Function.ResFunction[]): string[] => {
|
||||
const ids: string[] = [];
|
||||
|
||||
const traverse = (func: Function.ResFunction) => {
|
||||
ids.push(func.id);
|
||||
if (func.children && func.children.length > 0) {
|
||||
func.children.forEach(child => traverse(child));
|
||||
func.children.forEach((child: any) => traverse(child));
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -8,17 +8,17 @@
|
||||
<!-- :requestApi="getRoleList" -->
|
||||
<!-- 表格 header 按钮 -->
|
||||
<template #tableHeader='scope'>
|
||||
<el-button type='primary' :icon='CirclePlus' @click="openDrawer('新增角色')">新增</el-button>
|
||||
<el-button type='danger' :icon='Delete' plain :disabled='!scope.isSelected'
|
||||
<el-button v-auth.role="'add'" type='primary' :icon='CirclePlus' @click="openDrawer('新增角色')">新增</el-button>
|
||||
<el-button v-auth.role="'batchDelete'" type='danger' :icon='Delete' plain :disabled='!scope.isSelected'
|
||||
@click='batchDelete(scope.selectedListIds)'>
|
||||
批量删除
|
||||
</el-button>
|
||||
</template>
|
||||
<!-- 表格操作 -->
|
||||
<template #operation='scope'>
|
||||
<el-button type='primary' link :icon='EditPen' @click="openDrawer('编辑角色', scope.row)">编辑</el-button>
|
||||
<el-button v-if="scope.row.type !== 0 && scope.row.type !== 1" type='primary' link :icon='Delete' @click='deleteAccount(scope.row)'>删除</el-button>
|
||||
<el-button type='primary' link :icon='Share' @click="openDrawer('设置权限', scope.row)">设置权限</el-button>
|
||||
<el-button v-auth.role="'edit'" type='primary' link :icon='EditPen' @click="openDrawer('编辑角色', scope.row)">编辑</el-button>
|
||||
<el-button v-auth.role="'delete'" v-if="scope.row.type !== 0 && scope.row.type !== 1" type='primary' link :icon='Delete' @click='deleteAccount(scope.row)'>删除</el-button>
|
||||
<el-button v-auth.role="'SetPermissions'" type='primary' link :icon='Share' @click="openDrawer('设置权限', scope.row)">设置权限</el-button>
|
||||
</template>
|
||||
|
||||
</ProTable>
|
||||
|
||||
@@ -8,17 +8,17 @@
|
||||
<!-- :data='userData' -->
|
||||
<!-- 表格 header 按钮 -->
|
||||
<template #tableHeader='scope'>
|
||||
<el-button type='primary' :icon='CirclePlus' @click="openDialog('add')">新增</el-button>
|
||||
<el-button type='danger' :icon='Delete' plain :disabled='!scope.isSelected'
|
||||
<el-button v-auth.user="'add'" type='primary' :icon='CirclePlus' @click="openDialog('add')">新增</el-button>
|
||||
<el-button v-auth.user="'batchDelete'" type='danger' :icon='Delete' plain :disabled='!scope.isSelected'
|
||||
@click='batchDelete(scope.selectedListIds)'>
|
||||
批量删除
|
||||
</el-button>
|
||||
</template>
|
||||
<!-- 表格操作 -->
|
||||
<template #operation='scope'>
|
||||
<el-button type='primary' link :icon='EditPen' @click="openDialog('edit', scope.row)">编辑</el-button>
|
||||
<el-button type='primary' link :icon='Delete' @click='handleDelete(scope.row)'>删除</el-button>
|
||||
<el-button type='primary' link :icon='Delete' @click='EditPassWord(scope.row)'>修改密码</el-button>
|
||||
<el-button v-auth.user="'edit'" type='primary' link :icon='EditPen' @click="openDialog('edit', scope.row)">编辑</el-button>
|
||||
<el-button v-auth.user="'delete'" type='primary' link :icon='Delete' @click='handleDelete(scope.row)'>删除</el-button>
|
||||
<el-button v-auth.user="'editPassWord'" type='primary' link :icon='Delete' @click='EditPassWord(scope.row)'>修改密码</el-button>
|
||||
</template>
|
||||
|
||||
</ProTable>
|
||||
|
||||
Reference in New Issue
Block a user