diff --git a/web/src/views/xg/xsjcxx/stuRoster/index.vue b/web/src/views/xg/xsjcxx/stuRoster/index.vue index 930026c3..06f0a3c6 100644 --- a/web/src/views/xg/xsjcxx/stuRoster/index.vue +++ b/web/src/views/xg/xsjcxx/stuRoster/index.vue @@ -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('获取部门树失败,请重试');