From eca9b2e5c274aae761ad2388818194eff4dacb47 Mon Sep 17 00:00:00 2001
From: lkk <364857242@qq.com>
Date: 星期一, 04 八月 2025 15:19:32 +0800
Subject: [PATCH] 1

---
 src/views/hosp/project/index.vue |  197 ++++++++++++++++++++++++++++++++-----------------
 1 files changed, 128 insertions(+), 69 deletions(-)

diff --git a/src/views/hosp/project/index.vue b/src/views/hosp/project/index.vue
index ec93cd3..339d010 100644
--- a/src/views/hosp/project/index.vue
+++ b/src/views/hosp/project/index.vue
@@ -1193,7 +1193,7 @@
   },
   created() {
     // this.getConsumables();
-    // this.getDeptList();
+    this.getDeptList();
     // this.getDeptTree().then(() => {
     //   this.precomputePinyin();
     // });
@@ -1213,11 +1213,21 @@
       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,
             });
           }
@@ -1225,6 +1235,17 @@
         });
       };
       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() {
@@ -1246,7 +1267,7 @@
       try {
         const response = await deptTree111();
         this.deptOptions = response.data;
-
+        this.precomputePinyin();
         // 淇濊瘉 treeId 鏄暟缁勬牸寮�
         this.treeId = [];
 
@@ -1278,16 +1299,6 @@
       }
     },
 
-    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);
@@ -1383,12 +1394,16 @@
       this.form.hisXmbm = "";
       this.form.hisXmmc = "";
       this.form.hisdj = "";
-      this.loading = true;
+      // this.loading = true;
       this.proParent = false;
       this.form.proPrice = 0.0;
       this.form.proName = "";
       this.form.proId = null;
       this.form.resultType = "1";
+
+      // 鍏堣幏鍙栫瀹ゅ垪琛ㄦ暟鎹�
+      this.getDeptList();
+
       getlist().then((response) => {
         if (response.code == 200) {
           this.loading = false;
@@ -1543,10 +1558,10 @@
     getDeptList() {
       listDept(this.queryParams).then((response) => {
         this.parentNameList = response.data;
-        this.deptList = this.handleTree(response.data, "proId");
+        this.deptList = this.handleTree(response.data, "deptId");
       });
     },
-    getDeptTree() {
+    /* getDeptTree() {
       this.loadings = true;
       return deptTree111()
         .then((response) => {
@@ -1564,7 +1579,7 @@
         .finally(() => {
           this.loadings = false; // 鏃犺鎴愬姛鎴栧け璐ワ紝缁撴潫鍔犺浇
         });
-    },
+    }, */
     handleNodeClick(date) {
       this.treeDate = date;
       this.xiugaiList = {};
@@ -1722,28 +1737,38 @@
       }
     },
     handleUpdate1() {
-      this.updateLoading = true;
+      // this.updateLoading = true;
       this.form = {};
-      this.form = this.xiugaiList;
-      this.form.proStatus = this.form.proStatus.toString();
-      this.form.sfcyyc = this.form.sfcyyc.toString();
       this.proParent = true;
       this.isPriceDisabled = true;
-      getlist()
-        .then((response) => {
-          if (response.code == 200) {
+
+      // 鍏堝姞杞界瀹ゅ垪琛ㄦ暟鎹紝鍐嶈缃〃鍗曟暟鎹�
+      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(response.data.list, "proId");
-            this.key = response.data.key;
+            project.children = this.handleTree(listResponse.data.list, "proId");
+            this.key = listResponse.data.key;
             this.projectOptions.push(project);
           }
+
+          this.open = true;
         })
-        .finally(() => {
-          this.updateLoading = false;
+        .catch((error) => {
+          console.error("鍔犺浇鏁版嵁澶辫触:", error);
+          this.$message.error("鍔犺浇鏁版嵁澶辫触");
         });
-      this.open = true;
     },
     handleUpdate(row) {
       this.reset();
@@ -1751,48 +1776,79 @@
       const proId = row.proId || this.ids;
       this.proParent = false;
       this.isPriceDisabled = false;
-      getProject(proId).then((response) => {
-        this.form = response.data;
-        this.showPrise = this.form.proParentId === "0";
-        this.showRentPrise = !this.showPrise;
-        this.form.proStatus = this.form.proStatus.toString();
-        this.form.sfcyyc = this.form.sfcyyc.toString();
-        this.form.consumablesList = response.data.consumablesList;
-        this.form.tjStandardList = response.data.tjStandardList;
-        if (this.form.tjStandardList) {
-          this.form.tjStandardList.forEach((item) => {
-            item.tjSex =
-              item.tjSex === "0" || item.tjSex === "鐢�"
-                ? "鐢�"
-                : item.tjSex === "1" || item.tjSex === "濂�"
-                ? "濂�"
-                : null;
-            item.tjType =
-              {
-                0: "濠村効",
-                1: "骞煎効",
-                2: "鍎跨",
-                3: "灏戝勾",
-                4: "闈掑勾",
-                5: "涓勾",
-                6: "鑰佸勾",
-              }[item.tjType] || item.tjType;
-          });
-        }
-        getlist().then((response) => {
-          if (response.code == 200) {
-            // this.loading = false;
-            this.projectOptions = [];
-            const project = { proId: 0, proName: "涓荤被鐩�", children: [] };
-            project.children = this.handleTree(response.data.list, "proId");
-            this.key = response.data.key;
-            this.projectOptions.push(project);
+      listDept(this.queryParams).then((response) => {
+        this.parentNameList = response.data;
+        // this.deptList = this.handleTree(response.data, "proId");
+        getProject(proId).then((response) => {
+          this.form = response.data;
+          this.form.deptId = response.data.deptId;
+          this.showPrise = this.form.proParentId === "0";
+          this.showRentPrise = !this.showPrise;
+          this.form.proStatus = this.form.proStatus.toString();
+          this.form.sfcyyc = this.form.sfcyyc.toString();
+          this.form.consumablesList = response.data.consumablesList;
+          this.form.tjStandardList = response.data.tjStandardList;
+          if (this.form.tjStandardList) {
+            this.form.tjStandardList.forEach((item) => {
+              item.tjSex =
+                item.tjSex === "0" || item.tjSex === "鐢�"
+                  ? "鐢�"
+                  : item.tjSex === "1" || item.tjSex === "濂�"
+                  ? "濂�"
+                  : null;
+              item.tjType =
+                {
+                  0: "濠村効",
+                  1: "骞煎効",
+                  2: "鍎跨",
+                  3: "灏戝勾",
+                  4: "闈掑勾",
+                  5: "涓勾",
+                  6: "鑰佸勾",
+                }[item.tjType] || item.tjType;
+            });
           }
+          getlist().then((response) => {
+            if (response.code == 200) {
+              // this.loading = false;
+              this.projectOptions = [];
+              const project = { proId: 0, proName: "涓荤被鐩�", children: [] };
+              project.children = this.handleTree(response.data.list, "proId");
+              this.key = response.data.key;
+              this.projectOptions.push(project);
+            }
+          });
+          // this.loadPage();
+          this.open = true;
+          this.title = "浣撴椤圭洰淇℃伅缁存姢";
         });
-        // this.loadPage();
-        this.open = true;
-        this.title = "浣撴椤圭洰淇℃伅缁存姢";
       });
+    },
+    // 鍒锋柊褰撳墠閫変腑椤圭洰鐨勬暟鎹�
+    async refreshCurrentProjectData() {
+      if (this.id) {
+        try {
+          const response = await getInfoByProId(this.id);
+          this.xiugaiList = response.data;
+          console.log("鍒锋柊椤圭洰鏁版嵁鎴愬姛:", this.xiugaiList);
+          return response.data;
+        } catch (error) {
+          console.error("鍒锋柊椤圭洰鏁版嵁澶辫触:", error);
+          this.$message.error("鍒锋柊椤圭洰鏁版嵁澶辫触");
+          this.xiugaiList = null; // 鍒锋柊澶辫触鏃堕噸缃负 null
+          return null;
+        }
+      }
+      return null;
+    },
+    // 璋冭瘯鏂规硶锛氭鏌ュ綋鍓嶆暟鎹姸鎬�
+    debugDataState() {
+      console.log("=== 鏁版嵁鐘舵�佽皟璇� ===");
+      console.log("褰撳墠ID:", this.id);
+      console.log("xiugaiList:", this.xiugaiList);
+      console.log("form:", this.form);
+      console.log("treeDate:", this.treeDate);
+      console.log("==================");
     },
     getSelectValue(val) {
       this.form.consumablesList.forEach((formitem) => {
@@ -1897,6 +1953,9 @@
       // 绛夊緟鍙充晶琛ㄦ牸鍒锋柊
       await this.getList();
 
+      // 绔嬪嵆鍒锋柊褰撳墠椤圭洰鏁版嵁锛岀‘淇濇暟鎹槸鏈�鏂扮殑
+      await this.refreshCurrentProjectData();
+
       this.pageLoading = false; // 鉁� 缁熶竴鍔犺浇鐘舵�佹帶鍒�
     },
     submit() {

--
Gitblit v1.8.0