From c12ce4c405d92c0bf11e876468108d1edb134ff2 Mon Sep 17 00:00:00 2001
From: lkk <364857242@qq.com>
Date: 星期四, 31 七月 2025 17:55:10 +0800
Subject: [PATCH] 1

---
 src/views/hosp/project/index.vue |  200 +++++++++++++++++++++++++++++++-------------------
 1 files changed, 124 insertions(+), 76 deletions(-)

diff --git a/src/views/hosp/project/index.vue b/src/views/hosp/project/index.vue
index f9a55f2..3a457bc 100644
--- a/src/views/hosp/project/index.vue
+++ b/src/views/hosp/project/index.vue
@@ -1162,8 +1162,8 @@
         this.$nextTick(() => {
           const lastId = newVal[newVal.length - 1] || "532";
           const node = this.findNodeById(this.deptOptions, lastId);
-          this.queryParams.proId = lastId
-          this.getList()
+          this.queryParams.proId = lastId;
+          this.getList();
           if (node) {
             this.$refs.tree1.setCurrentKey(lastId);
             const nodeElement = document.querySelector(
@@ -1193,7 +1193,7 @@
   },
   created() {
     // this.getConsumables();
-    // this.getDeptList();
+    this.getDeptList();
     // this.getDeptTree().then(() => {
     //   this.precomputePinyin();
     // });
@@ -1252,7 +1252,6 @@
 
         if (this.treeDate?.id) {
           this.treeId.push(this.treeDate.id);
-          
         } else {
           this.treeId.push("532");
         }
@@ -1384,12 +1383,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;
@@ -1544,10 +1547,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) => {
@@ -1565,7 +1568,7 @@
         .finally(() => {
           this.loadings = false; // 鏃犺鎴愬姛鎴栧け璐ワ紝缁撴潫鍔犺浇
         });
-    },
+    }, */
     handleNodeClick(date) {
       this.treeDate = date;
       this.xiugaiList = {};
@@ -1723,28 +1726,39 @@
       }
     },
     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) {
-            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);
-          }
-        })
-        .finally(() => {
-          this.updateLoading = false;
-        });
-      this.open = 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("鍔犺浇鏁版嵁澶辫触");
+      })
     },
     handleUpdate(row) {
       this.reset();
@@ -1752,48 +1766,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) => {
@@ -1887,19 +1932,22 @@
       console.log(this.treeId);
     }, */
     async handleSuccess(isY) {
-  this.cancel();
+      this.cancel();
 
-  if (this.proParent || isY) {
-    // 绛夊緟宸︿晶鏍戝姞杞藉拰鎷奸煶澶勭悊
-    await this.getDeptTree();
-    this.precomputePinyin();
-  }
+      if (this.proParent || isY) {
+        // 绛夊緟宸︿晶鏍戝姞杞藉拰鎷奸煶澶勭悊
+        await this.getDeptTree();
+        this.precomputePinyin();
+      }
 
-  // 绛夊緟鍙充晶琛ㄦ牸鍒锋柊
-  await this.getList();
+      // 绛夊緟鍙充晶琛ㄦ牸鍒锋柊
+      await this.getList();
+      
+      // 绔嬪嵆鍒锋柊褰撳墠椤圭洰鏁版嵁锛岀‘淇濇暟鎹槸鏈�鏂扮殑
+      await this.refreshCurrentProjectData();
 
-  this.pageLoading = false; // 鉁� 缁熶竴鍔犺浇鐘舵�佹帶鍒�
-},
+      this.pageLoading = false; // 鉁� 缁熶竴鍔犺浇鐘舵�佹帶鍒�
+    },
     submit() {
       this.ChangeList.forEach((item) => {
         this.form.proPrice = item.ckdj;

--
Gitblit v1.8.0