feat: 用户管理调整部门使用树形选择器
This commit is contained in:
parent
eab4b6ba2a
commit
1c4e042c4b
@ -1695,20 +1695,18 @@
|
||||
</p>
|
||||
<a-form layout="vertical">
|
||||
<a-form-item label="选择部门">
|
||||
<a-select
|
||||
<a-tree-select
|
||||
v-model:value="transferDeptId"
|
||||
placeholder="请选择部门"
|
||||
style="width: 100%"
|
||||
>
|
||||
<a-select-option :value="0">未分配部门</a-select-option>
|
||||
<a-select-option
|
||||
v-for="dept in departments"
|
||||
:key="dept.id"
|
||||
:value="dept.id"
|
||||
>
|
||||
{{ dept.deptName }}
|
||||
</a-select-option>
|
||||
</a-select>
|
||||
:tree-data="departmentTreeSelectData"
|
||||
:field-names="{ children: 'children', label: 'title', value: 'value' }"
|
||||
tree-default-expand-all
|
||||
allow-clear
|
||||
show-search
|
||||
:filter-tree-node="filterDeptTreeNode"
|
||||
tree-node-filter-prop="title"
|
||||
/>
|
||||
</a-form-item>
|
||||
</a-form>
|
||||
</div>
|
||||
@ -2499,6 +2497,38 @@ const getDepartmentLevel = (record: DepartmentOverview): number => {
|
||||
return 3
|
||||
}
|
||||
|
||||
// 部门树形选择器数据 - 用于调整用户部门
|
||||
const departmentTreeSelectData = computed(() => {
|
||||
// 构建树形结构
|
||||
const buildTree = (parentId: number | null): any[] => {
|
||||
return departments.value
|
||||
.filter(d => (d.parentId || null) === parentId)
|
||||
.map(d => {
|
||||
const children = buildTree(d.id!)
|
||||
const node: any = {
|
||||
title: `${d.deptName} (${d.deptType === 'demand' ? '需求' : '接单'})`,
|
||||
value: d.id,
|
||||
key: d.id
|
||||
}
|
||||
if (children.length > 0) {
|
||||
node.children = children
|
||||
}
|
||||
return node
|
||||
})
|
||||
}
|
||||
|
||||
// 添加"未分配部门"选项
|
||||
return [
|
||||
{ title: '未分配部门', value: 0, key: 0 },
|
||||
...buildTree(null)
|
||||
]
|
||||
})
|
||||
|
||||
// 过滤部门树节点
|
||||
const filterDeptTreeNode = (inputValue: string, treeNode: any) => {
|
||||
return treeNode.title.toLowerCase().includes(inputValue.toLowerCase())
|
||||
}
|
||||
|
||||
// 上级部门选项(分层级)- 用于部门编辑弹窗
|
||||
const parentDepartmentOptions = computed(() => {
|
||||
// 排除当前正在编辑的部门及其子部门
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user