| | |
| | | const traverse = (nodes) => { |
| | | nodes.forEach((node) => { |
| | | if (node.label) { |
| | | const lowerSpell = node.label.spell("low", "array").join(""); |
| | | const upperSpell = node.label.spell("up", "array").join(""); |
| | | const lowerSpell = cnchar |
| | | .spell(node.label, "low", "array") |
| | | .join(""); // 完整小写拼音 |
| | | const upperSpell = cnchar.spell(node.label, "up", "array").join(""); // 完整大写拼音 |
| | | const shortPinyin = node.label |
| | | .split("") |
| | | .map( |
| | | (char) => |
| | | cnchar.spell(char, "array")[0]?.[0]?.toLowerCase() || char |
| | | ) // 拼音首字母 |
| | | .join(""); |
| | | this.pinyinCache.set(node.id, { |
| | | lowerSpell, |
| | | upperSpell, |
| | | shortPinyin, // 缓存拼音简写 |
| | | label: node.label, |
| | | }); |
| | | } |
| | |
| | | }); |
| | | }; |
| | | traverse(this.deptOptions); |
| | | }, |
| | | filterNode(value, data) { |
| | | if (!value) return true; // 如果搜索值为空,返回所有节点 |
| | | const cached = this.pinyinCache.get(data.id); |
| | | if (!cached) return false; // 如果没有缓存数据,不显示该节点 |
| | | const searchLower = value.toLowerCase(); // 将搜索词转为小写 |
| | | return ( |
| | | cached.label.includes(value) || // 直接匹配汉字 |
| | | cached.shortPinyin.includes(searchLower) || // 匹配拼音简写 |
| | | cached.lowerSpell.includes(searchLower) // 匹配完整拼音 |
| | | ); |
| | | }, |
| | | |
| | | async loadPage() { |
| | |
| | | try { |
| | | const response = await deptTree111(); |
| | | this.deptOptions = response.data; |
| | | |
| | | this.precomputePinyin(); |
| | | // 保证 treeId 是数组格式 |
| | | this.treeId = []; |
| | | |
| | |
| | | } |
| | | }, |
| | | |
| | | filterNode(value, data) { |
| | | if (!value) return true; |
| | | const cached = this.pinyinCache.get(data.id); |
| | | if (!cached) return false; |
| | | return ( |
| | | cached.label.includes(value) || |
| | | cached.lowerSpell.includes(value) || |
| | | cached.upperSpell.includes(value) |
| | | ); |
| | | }, |
| | | filterNode2(value, data) { |
| | | if (!value) return true; |
| | | return data.xmmc.includes(value); |
| | |
| | | this.form.proName = ""; |
| | | this.form.proId = null; |
| | | this.form.resultType = "1"; |
| | | |
| | | |
| | | // 先获取科室列表数据 |
| | | this.getDeptList(); |
| | | |
| | | |
| | | getlist().then((response) => { |
| | | if (response.code == 200) { |
| | | this.loading = false; |
| | |
| | | this.form = {}; |
| | | this.proParent = true; |
| | | this.isPriceDisabled = true; |
| | | |
| | | |
| | | // 先加载科室列表数据,再设置表单数据 |
| | | Promise.all([ |
| | | listDept(this.queryParams), |
| | | getlist() |
| | | ]).then(([deptResponse, listResponse]) => { |
| | | // 先设置科室列表 |
| | | this.parentNameList = deptResponse.data; |
| | | |
| | | // 再设置表单数据 |
| | | this.form = this.xiugaiList; |
| | | this.form.proStatus = this.form.proStatus.toString(); |
| | | this.form.sfcyyc = this.form.sfcyyc.toString(); |
| | | |
| | | // 处理项目选项 |
| | | if (listResponse.code == 200) { |
| | | this.loading = false; |
| | | this.projectOptions = []; |
| | | const project = { proId: 0, proName: "主类目", children: [] }; |
| | | project.children = this.handleTree(listResponse.data.list, "proId"); |
| | | this.key = listResponse.data.key; |
| | | this.projectOptions.push(project); |
| | | } |
| | | |
| | | this.open = true; |
| | | }).catch((error) => { |
| | | console.error("加载数据失败:", error); |
| | | this.$message.error("加载数据失败"); |
| | | }) |
| | | Promise.all([listDept(this.queryParams), getlist()]) |
| | | .then(([deptResponse, listResponse]) => { |
| | | // 先设置科室列表 |
| | | this.parentNameList = deptResponse.data; |
| | | |
| | | // 再设置表单数据 |
| | | this.form = this.xiugaiList; |
| | | this.form.proStatus = this.form.proStatus.toString(); |
| | | this.form.sfcyyc = this.form.sfcyyc.toString(); |
| | | |
| | | // 处理项目选项 |
| | | if (listResponse.code == 200) { |
| | | this.loading = false; |
| | | this.projectOptions = []; |
| | | const project = { proId: 0, proName: "主类目", children: [] }; |
| | | project.children = this.handleTree(listResponse.data.list, "proId"); |
| | | this.key = listResponse.data.key; |
| | | this.projectOptions.push(project); |
| | | } |
| | | |
| | | this.open = true; |
| | | }) |
| | | .catch((error) => { |
| | | console.error("加载数据失败:", error); |
| | | this.$message.error("加载数据失败"); |
| | | }); |
| | | }, |
| | | handleUpdate(row) { |
| | | this.reset(); |
| | |
| | | |
| | | // 等待右侧表格刷新 |
| | | await this.getList(); |
| | | |
| | | |
| | | // 立即刷新当前项目数据,确保数据是最新的 |
| | | await this.refreshCurrentProjectData(); |
| | | |