优化:部门新增类型字段,用于标识部门是系统内置或自定义

1.系统内置部门不允许禁用、删除、修改上级部门
2.抽取 getAncestors 方法,用于复用获取祖级列表
3.删除部门时,自动删除角色和部门关联
This commit is contained in:
2023-03-19 22:10:37 +08:00
parent 6b73aeb8a9
commit b345e4450d
16 changed files with 169 additions and 52 deletions

View File

@@ -10,12 +10,14 @@ export interface DeptRecord {
description?: string;
sort: number;
status?: number;
type?: number;
createUserString?: string;
createTime?: string;
updateUserString?: string;
updateTime?: string;
children?: Array<DeptRecord>;
parentName?: string;
disabled?: boolean;
}
export interface DeptParam {

View File

@@ -129,13 +129,18 @@
v-model="record.status"
:checked-value="1"
:unchecked-value="2"
:disabled="!checkPermission(['system:dept:update'])"
:disabled="record.disabled || !checkPermission(['system:dept:update'])"
@change="handleChangeStatus(record)"
/>
</template>
</a-table-column>
<a-table-column title="类型" align="center">
<template #cell="{ record }">
<a-tag v-if="record.type === 1" color="red">系统内置</a-tag>
<a-tag v-else color="arcoblue">自定义</a-tag>
</template>
</a-table-column>
<a-table-column title="描述" data-index="description" />
<a-table-column title="创建人" data-index="createUserString" />
<a-table-column title="创建时间" data-index="createTime" />
<a-table-column
v-if="checkPermission(['system:dept:update', 'system:dept:delete'])"
@@ -162,6 +167,7 @@
type="text"
size="small"
title="删除"
:disabled="record.disabled"
>
<template #icon><icon-delete /></template>删除
</a-button>
@@ -182,7 +188,7 @@
@cancel="handleCancel"
>
<a-form ref="formRef" :model="form" :rules="rules" size="large">
<a-form-item label="上级部门" field="parentId">
<a-form-item label="上级部门" field="parentId" :disabled="form.disabled">
<a-tree-select
v-model="form.parentId"
:data="treeData"
@@ -345,6 +351,7 @@
form: {} as DeptRecord,
// 表单验证规则
rules: {
parentId: [{ required: true, message: '请选择上级部门' }],
name: [{ required: true, message: '请输入部门名称' }],
sort: [{ required: true, message: '请输入部门排序' }],
},
@@ -412,6 +419,7 @@
description: '',
sort: 999,
status: 1,
disabled: false,
};
proxy.$refs.formRef?.resetFields();
};