提交修改

This commit is contained in:
zlwu committed 2025-08-02 09:45:09 +08:00
1 parent 6e6be1ecbe
commit b81479819f
1 file changed
+12 -3
+12 -3
View File
@@ -841,25 +841,34 @@ watchEffect(() => {
}
});
// 递归处理树数据,将所有节点的disabled属性设置为false
const processTreeData = (data: any[]): any[] => {
return data.map((node) => ({
...node,
disabled: false, // 强制设置为false,允许所有节点勾选
children: node.children ? processTreeData(node.children) : undefined
}));
};
/** 查询部门下拉树结构 */
const getDeptTree = async () => {
try {
const res = await api.XgDeptTreeSelect(101);
// XgDeptTreeSelect返回的数据结构与deptTreeSelect不同,需要进行适当处理
if (res.data && Array.isArray(res.data)) {
deptOptions.value = res.data;
deptOptions.value = processTreeData(res.data);
} else {
console.warn('部门树数据格式不符合预期');
// 回退到默认处理
const backup = await api.deptTreeSelect();
deptOptions.value = backup.data.data;
deptOptions.value = processTreeData(backup.data.data);
}
} catch (error) {
console.error('获取部门树失败:', error);
// 如果API调用失败,可以使用默认的deptTreeSelect作为备选
try {
const backup = await api.deptTreeSelect();
deptOptions.value = backup.data.data;
deptOptions.value = processTreeData(backup.data.data);
} catch (backupError) {
console.error('备选API也失败:', backupError);
ElMessage.error('获取部门树失败,请重试');