From 056f30dda1073fbb6f8abc8577169fc26767ad4a Mon Sep 17 00:00:00 2001 From: qx <1084500556@qq.com> Date: 星期四, 17 四月 2025 17:30:09 +0800 Subject: [PATCH] qx --- src/views/hosp/project/index.vue | 94 +++++++++++++++++++++++++++------------------- 1 files changed, 55 insertions(+), 39 deletions(-) diff --git a/src/views/hosp/project/index.vue b/src/views/hosp/project/index.vue index 0e6a6a9..1726610 100644 --- a/src/views/hosp/project/index.vue +++ b/src/views/hosp/project/index.vue @@ -9,8 +9,8 @@ <div class="scrollable-container"> <div class="content"> <el-tree :data="deptOptions" :props="defaultProps" :expand-on-click-node="false" - :filter-node-method="filterNode" ref="tree" node-key="id" :default-expanded-keys="treeId" - highlight-current @node-click="handleNodeClick" :render-content="renderContent" v-loading="loadings"/> + :filter-node-method="filterNode" ref="tree1" node-key="id" :default-expanded-keys="treeId" + highlight-current @node-click="handleNodeClick" :render-content="renderContent" v-loading="loadings" /> </div> </div> </el-col> @@ -79,7 +79,7 @@ </el-table-column> <el-table-column label="椤圭洰鏍囧噯鍊�" align="center" prop="proScope" :show-overflow-tooltip="true" width="90px"> </el-table-column> - <el-table-column label="Lis椤圭洰鍚嶇О" align="center" prop="lisXmmc" :show-overflow-tooltip="true" width="200px"> + <el-table-column label="Lis椤圭洰鍚嶇О" align="center" prop="lisXmmc" :show-overflow-tooltip="true" width="200px"> </el-table-column> <el-table-column label="Lis缂栫爜" align="center" prop="lisXmbm" :show-overflow-tooltip="true" width="90px"> </el-table-column> @@ -549,7 +549,7 @@ const lastId = newVal[newVal.length - 1] || "532"; const node = this.findNodeById(this.deptOptions, lastId); if (node) { - this.$refs.tree.setCurrentKey(lastId); + this.$refs.tree1.setCurrentKey(lastId); const nodeElement = document.querySelector(`.el-tree-node[data-key="${lastId}"] .el-tree-node__content`); if (nodeElement) { nodeElement.click(); @@ -586,16 +586,25 @@ }); }, methods: { - debounceFilter: debounce(function(val) { - this.$refs.tree.filter(val); + debounceFilter: debounce(function (val) { + this.$refs.tree1.filter(val); }, 300), precomputePinyin() { 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(''); - this.pinyinCache.set(node.id, { lowerSpell, upperSpell, label: node.label }); + 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 + }); } if (node.children) traverse(node.children); }); @@ -603,13 +612,14 @@ traverse(this.deptOptions); }, filterNode(value, data) { - if (!value) return true; + if (!value) return true; // 濡傛灉鎼滅储鍊间负绌猴紝杩斿洖鎵�鏈夎妭鐐� const cached = this.pinyinCache.get(data.id); - if (!cached) return false; + if (!cached) return false; // 濡傛灉娌℃湁缂撳瓨鏁版嵁锛屼笉鏄剧ず璇ヨ妭鐐� + const searchLower = value.toLowerCase(); // 灏嗘悳绱㈣瘝杞负灏忓啓 return ( - cached.label.includes(value) || - cached.lowerSpell.includes(value) || - cached.upperSpell.includes(value) + cached.label.includes(value) || // 鐩存帴鍖归厤姹夊瓧 + cached.shortPinyin.includes(searchLower) || // 鍖归厤鎷奸煶绠�鍐� + cached.lowerSpell.includes(searchLower) // 鍖归厤瀹屾暣鎷奸煶 ); }, filterNode2(value, data) { @@ -690,30 +700,24 @@ this.form.proParentId = row.proId || 0; this.open = true; } else if (this.treeDate.id) { - if(this.treeDate.qf == "0"){ - this.form.proParentId = "0" - this.projectOptions.forEach((item) => { - item.children.forEach((item1) => { - if (this.treeDate.id == item1.deptId) { - this.form.deptId = item1.deptId; - } + if (this.treeDate.qf == "0") { + this.form.proParentId = "0" + this.form.deptId = this.treeDate.id + } else { + this.form.proParentId = this.treeDate.id; + this.projectOptions.forEach((item) => { + item.children.forEach((item1) => { + if (this.form.proParentId == item1.proId) { + this.form.deptId = item1.deptId; + } + }); }); - }); - }else{ - this.form.proParentId = this.treeDate.id; - this.projectOptions.forEach((item) => { - item.children.forEach((item1) => { - if (this.form.proParentId == item1.proId) { - this.form.deptId = item1.deptId; - } - }); - }); - } - - + } + + this.open = true; } else { - this.form.proParentId = "0" + this.form.proParentId = "0" this.open = true; } } @@ -830,9 +834,9 @@ }); }, handleNodeClick(date) { - + this.treeDate = date; - console.log(this.treeDate) + this.xiugaiList ={} this.xiugais = date.qf === "0"; let proId = date.id; getInfoByProId(proId).then((response) => { @@ -867,6 +871,11 @@ let data = { proId: this.queryParams.proId }; getAllChildListById(data).then(() => { this.loading = false; + }); + this.deptName = ""; + // 鎵嬪姩璋冪敤杩囨护鏂规硶锛堥渶绛夊緟 DOM 鏇存柊锛� + this.$nextTick(() => { + this.$refs.tree1.filter(this.deptName); }); }, handleClose() { @@ -906,7 +915,7 @@ resetQuery() { this.resetForm("queryForm"); this.queryParams.proId = undefined; - this.$refs.tree.setCurrentKey(null); + this.$refs.tree1.setCurrentKey(null); this.handleQuery(); }, flexColumnWidth(column) { @@ -977,6 +986,7 @@ } }, handleUpdate1() { + this.form ={} this.form = this.xiugaiList; this.form.proStatus = this.form.proStatus.toString(); this.proParent = true; @@ -989,6 +999,7 @@ project.children = this.handleTree(response.data.list, "proId"); this.key = response.data.key; this.projectOptions.push(project); + console.log( this.projectOptions,11111) } }); this.open = true; @@ -1063,6 +1074,11 @@ } } }); + this.deptName = ""; + // 鎵嬪姩璋冪敤杩囨护鏂规硶锛堥渶绛夊緟 DOM 鏇存柊锛� + this.$nextTick(() => { + this.$refs.tree1.filter(this.deptName); + }); }, processSubmission(isUpdate, isY) { if (isUpdate) { @@ -1122,7 +1138,7 @@ this.getList(); this.$modal.msgSuccess("鍒犻櫎鎴愬姛"); }) - .catch(() => {}); + .catch(() => { }); }, handleExport() { this.download( -- Gitblit v1.8.0