|
@@ -206,28 +206,21 @@
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- /** 责任部门:与新增隐患台账的举一反三责任部门同源(getAllDepartments 扁平化) */
|
|
|
|
|
|
|
+ /** 责任部门:仅取 deptTree.value[0].children,不递归 */
|
|
|
const deptTree = ref<DeptTree[]>([]);
|
|
const deptTree = ref<DeptTree[]>([]);
|
|
|
- function flattenDeptTree(nodes: DeptTree[] | undefined): Array<{ id: number; deptName: string }> {
|
|
|
|
|
- if (!nodes?.length) return [];
|
|
|
|
|
- const list: Array<{ id: number; deptName: string }> = [];
|
|
|
|
|
- const walk = (items: DeptTree[]) => {
|
|
|
|
|
- items.forEach((n) => {
|
|
|
|
|
- if (n.id != null) list.push({ id: n.id, deptName: n.deptName });
|
|
|
|
|
- if (n.children?.length) walk(n.children);
|
|
|
|
|
- });
|
|
|
|
|
- };
|
|
|
|
|
- walk(nodes);
|
|
|
|
|
- return list;
|
|
|
|
|
- }
|
|
|
|
|
- const deptOptions = computed(() => flattenDeptTree(deptTree.value));
|
|
|
|
|
|
|
+ const deptOptions = computed(() => {
|
|
|
|
|
+ const firstChildren = deptTree.value?.[0]?.children ?? [];
|
|
|
|
|
+ return firstChildren
|
|
|
|
|
+ .filter((n) => n.id != null)
|
|
|
|
|
+ .map((n) => ({ id: Number(n.id), deptName: n.deptName }));
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
const associationOtObligationDeptIdsArray = ref<number[]>([]);
|
|
const associationOtObligationDeptIdsArray = ref<number[]>([]);
|
|
|
|
|
|
|
|
const loadDeptOptions = async () => {
|
|
const loadDeptOptions = async () => {
|
|
|
try {
|
|
try {
|
|
|
const deptRes = await getAllDepartments();
|
|
const deptRes = await getAllDepartments();
|
|
|
- const fullTree = (deptRes as DeptTree[]) ?? [];
|
|
|
|
|
- deptTree.value = Array.isArray(fullTree) && fullTree[0]?.children ? fullTree[0].children : [];
|
|
|
|
|
|
|
+ deptTree.value = (deptRes as DeptTree[]) ?? [];
|
|
|
} catch (e) {
|
|
} catch (e) {
|
|
|
console.error('获取部门列表失败:', e);
|
|
console.error('获取部门列表失败:', e);
|
|
|
deptTree.value = [];
|
|
deptTree.value = [];
|