From e48af621e9c9a6fd97cdcff2cafa515347d05995 Mon Sep 17 00:00:00 2001
From: qx <1084500556@qq.com>
Date: 星期一, 04 八月 2025 15:19:13 +0800
Subject: [PATCH] :“体检项目、常规检查

---
 src/views/hosp/project/index.vue |  403 ++++++++++++++++++++++++++++++++++++++++++++-------------
 1 files changed, 311 insertions(+), 92 deletions(-)

diff --git a/src/views/hosp/project/index.vue b/src/views/hosp/project/index.vue
index 04c2fe4..a4485d8 100644
--- a/src/views/hosp/project/index.vue
+++ b/src/views/hosp/project/index.vue
@@ -1,5 +1,5 @@
 <template>
-  <div class="app-container">
+  <div class="app-container" v-loading="pageLoading">
     <el-row :gutter="20">
       <el-col :span="3" :xs="24">
         <div class="head-container">
@@ -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>
@@ -77,9 +77,20 @@
               <dict-tag :options="dict.type.sys_yes_no" :value="scope.row.proCheckMethod" />
             </template>
           </el-table-column>
+          <el-table-column label="鏄惁澶栭��" align="center" prop="proDelivery" :show-overflow-tooltip="true" width="75px">
+            <template v-slot="scope">
+              {{
+                scope.row.proDelivery === 0
+                  ? "鏄�"
+                  : scope.row.proDelivery === 1
+                    ? "鍚�"
+                    : ""
+              }}
+            </template>
+          </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>
@@ -229,6 +240,16 @@
         <el-form-item label="鎺掑簭" prop="xh">
           <el-input v-model="form.xh" placeholder="璇疯緭鍏ユ帓搴�" style="width: 200px" />
         </el-form-item>
+        <el-form-item label="鏄惁鍙備笌寮傚父" prop="sfcyyc">
+          <el-select v-model="form.sfcyyc" placeholder="璇烽�夋嫨鏄惁鍙備笌寮傚父" style="width: 260px">
+            <el-option v-for="dict in dictTypesy" :key="dict.value" :label="dict.label" :value="dict.value"></el-option>
+          </el-select>
+        </el-form-item>
+        <el-form-item label="鏄惁澶栭��" prop="proDelivery">
+          <el-select v-model="form.proDelivery" placeholder="璇烽�夋嫨鏄惁澶栭��" style="width: 200px">
+            <el-option v-for="dict in wsTypesy" :key="dict.value" :label="dict.label" :value="dict.value"></el-option>
+          </el-select>
+        </el-form-item>
       </el-form>
       <el-button style="margin-left: 40px" type="primary" plain size="mini" icon="el-icon-plus"
         @click="addmembers">鏂板琛�</el-button>
@@ -370,8 +391,8 @@
 </template>
 
 <script>
-import debounce from 'lodash/debounce';
-import cnchar from 'cnchar';
+import debounce from "lodash/debounce";
+import cnchar from "cnchar";
 import Packagese from "@/components/Packagese";
 import {
   getProject,
@@ -428,6 +449,7 @@
       }
     };
     return {
+      pageLoading: true,
       xiugais: true,
       xiugaiList: [],
       deptOptions: [],
@@ -441,6 +463,26 @@
       },
       xmmc: "",
       chargeId: [],
+      dictTypesy: [
+        {
+          value: "0",
+          label: "鏄�",
+        },
+        {
+          value: "1",
+          label: "鍚�",
+        },
+      ],
+      wsTypesy: [
+        {
+          value: "1",
+          label: "鏄�",
+        },
+        {
+          value: "0",
+          label: "鍚�",
+        },
+      ],
       List: false,
       deptName: "",
       deptOption: [],
@@ -515,6 +557,8 @@
         proScope: "",
         proSex: "2",
         resultType: "",
+        sfcyyc: "0",
+        proDelivery: "1",
       },
       rules: {
         createTime: [
@@ -548,9 +592,13 @@
         this.$nextTick(() => {
           const lastId = newVal[newVal.length - 1] || "532";
           const node = this.findNodeById(this.deptOptions, lastId);
+          this.queryParams.proId = lastId
+          this.getList()
           if (node) {
-            this.$refs.tree.setCurrentKey(lastId);
-            const nodeElement = document.querySelector(`.el-tree-node[data-key="${lastId}"] .el-tree-node__content`);
+            this.$refs.tree1.setCurrentKey(lastId);
+            const nodeElement = document.querySelector(
+              `.el-tree-node[data-key="${lastId}"] .el-tree-node__content`
+            );
             if (nodeElement) {
               nodeElement.click();
             }
@@ -574,28 +622,94 @@
     },
   },
   created() {
-    this.getConsumables();
+    // this.getConsumables();
     this.getDeptList();
-    this.getDeptTree().then(() => {
-      this.precomputePinyin();
-    });
+    // this.getDeptTree().then(() => {
+    //   this.precomputePinyin();
+    // });
   },
   mounted() {
-    this.getDeptTree().then(() => {
-      this.precomputePinyin();
-    });
+    // this.getDeptTree().then(() => {
+    //   this.precomputePinyin();
+    // });
+    this.loadPage();
   },
   methods: {
-    debounceFilter: debounce(function(val) {
-      this.$refs.tree.filter(val);
+    async loadPage() {
+      this.pageLoading = true;
+      try {
+        await Promise.all([
+          this.getDeptTree(), // 鑾峰彇宸︿晶鏍�
+          //this.getList(),  鑾峰彇鍙充晶琛ㄦ牸
+        ]);
+      } catch (error) {
+        console.error("鍔犺浇椤甸潰鍑洪敊", error);
+      } finally {
+        this.pageLoading = false; // 涓や釜閮藉姞杞藉畬鍐嶅叧闂� loading
+      }
+    },
+
+    async getDeptTree() {
+      this.loadings = true;
+      try {
+        const response = await deptTree111();
+        this.deptOptions = response.data;
+        this.precomputePinyin();
+        // 淇濊瘉 treeId 鏄暟缁勬牸寮�
+        this.treeId = [];
+
+        if (this.treeDate?.id) {
+          this.treeId.push(this.treeDate.id);
+        } else {
+          this.treeId.push("532");
+        }
+      } catch (error) {
+        console.error("鍔犺浇閮ㄩ棬鏍戝け璐ワ細", error);
+      } finally {
+        this.loadings = false; // loading 鐘舵�佺粨鏉�
+      }
+    },
+
+    async getList() {
+      this.loading = true;
+      let data = {
+        proName: this.queryParams.proName,
+        checkType: this.queryParams.checkType,
+        deptId: this.queryParams.deptId,
+        proId: this.queryParams.proId,
+      };
+      try {
+        const res = await getAllChildListById(data); // 鏇挎崲鎴愪綘瀹為檯鐨勬帴鍙�
+        this.projectList = res.data.list;
+      } finally {
+        this.loading = false;
+      }
+    },
+
+    debounceFilter: debounce(function (val) {
+      this.$refs.tree1.filter(val);
     }, 300),
     precomputePinyin() {
       const traverse = (nodes) => {
-        nodes.forEach(node => {
+        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 +717,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) {
@@ -671,15 +786,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;
+          // this.loading = false;
           this.projectOptions = [];
           const project = { proId: 0, proName: "涓荤被鐩�", children: [] };
           project.children = this.handleTree(response.data.list, "proId");
@@ -690,24 +806,23 @@
             this.form.proParentId = row.proId || 0;
             this.open = true;
           } else if (this.treeDate.id) {
-           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;
-                }
+            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;
+                  }
+                });
               });
-            });
-           }
-            
-           
+            }
+
             this.open = true;
           } else {
-             this.form.proParentId = "0"
+            this.form.proParentId = "0";
             this.open = true;
           }
         }
@@ -715,6 +830,7 @@
       this.title = "浣撴椤圭洰淇℃伅缁存姢";
       this.form.deptId = this.queryParams.deptId || null;
       this.form.proCheckMethod = "N";
+      this.form.proDelivery = "1";
       if (this.key === "Y") {
         gettreeList().then((response) => {
           this.deptOptionstree = response.data;
@@ -760,7 +876,10 @@
       listSfxm(this.querycharge).then((response) => {
         this.sfxmList = response.rows;
         response.rows.forEach((item, index) => {
-          item.newID = (this.querycharge.pageNum - 1) * this.querycharge.pageSize + index + 1;
+          item.newID =
+            (this.querycharge.pageNum - 1) * this.querycharge.pageSize +
+            index +
+            1;
         });
         this.total = response.total;
         this.loading = false;
@@ -786,7 +905,8 @@
       getListByXmId(this.queryParam).then((response) => {
         this.sfxmList = response.data.date;
         response.data.date.forEach((item, index) => {
-          item.newID = (this.queryParam.page - 1) * this.queryParam.pageSize + index + 1;
+          item.newID =
+            (this.queryParam.page - 1) * this.queryParam.pageSize + index + 1;
         });
         this.total = response.data.total;
         this.loading = false;
@@ -817,16 +937,15 @@
         this.deptList = this.handleTree(response.data, "proId");
       });
     },
-    getDeptTree() {
+    /* getDeptTree() {
       return deptTree111().then((response) => {
         this.deptOptions = response.data;
         this.treeId.push(this.treeDate.id);
       });
-    },
+    }, */
     handleNodeClick(date) {
-     
       this.treeDate = date;
-      console.log(this.treeDate)
+      this.xiugaiList = {};
       this.xiugais = date.qf === "0";
       let proId = date.id;
       getInfoByProId(proId).then((response) => {
@@ -841,8 +960,13 @@
       this.loading = true;
       getAllChildListById(data).then((response) => {
         if (response.code == 200) {
-          this.projectList = response.data.list.length >= 1 ? this.handleTree(response.data.list, "proId") : [];
-          this.ListId = this.projectList.length ? [this.projectList[0].proId] : [];
+          this.projectList =
+            response.data.list.length >= 1
+              ? this.handleTree(response.data.list, "proId")
+              : [];
+          this.ListId = this.projectList.length
+            ? [this.projectList[0].proId]
+            : [];
           this.key = response.data.key;
           this.loading = false;
         }
@@ -861,6 +985,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() {
@@ -891,6 +1020,7 @@
         tjStandardList: [],
         proStatus: "0",
         resultType: "1",
+        proDelivery: "1",
       };
       this.resetForm("form");
     },
@@ -900,7 +1030,7 @@
     resetQuery() {
       this.resetForm("queryForm");
       this.queryParams.proId = undefined;
-      this.$refs.tree.setCurrentKey(null);
+      this.$refs.tree1.setCurrentKey(null);
       this.handleQuery();
     },
     flexColumnWidth(column) {
@@ -971,21 +1101,38 @@
       }
     },
     handleUpdate1() {
-      this.form = this.xiugaiList;
-      this.form.proStatus = this.form.proStatus.toString();
+      // this.updateLoading = true;
+      this.form = {};
       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;
+
+        this.open = true;
+      }).catch((error) => {
+        this.$message.error("鍔犺浇鏁版嵁澶辫触");
+      })
     },
     handleUpdate(row) {
       this.reset();
@@ -993,34 +1140,52 @@
       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.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;
+        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.proDelivery = this.form.proDelivery.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.open = true;
+          this.title = "浣撴椤圭洰淇℃伅缁存姢";
         });
-        this.open = true;
-        this.title = "浣撴椤圭洰淇℃伅缁存姢";
-      });
+      })
+
     },
     getSelectValue(val) {
       this.form.consumablesList.forEach((formitem) => {
@@ -1037,15 +1202,28 @@
     },
     submitForm() {
       this.noclick = true;
+      this.pageLoading = true;
       this.$refs["form"].validate((valid) => {
         if (valid) {
           const isUpdate = this.form.proId != null;
           if (this.form.tjStandardList) {
             this.form.tjStandardList.forEach((item) => {
-              item.tjSex = item.tjSex === "鐢�" || item.tjSex === "0" ? "0" : (item.tjSex === "濂�" || item.tjSex === "1" ? "1" : null);
-              item.tjType = {
-                "濠村効": 0, "骞煎効": 1, "鍎跨": 2, "灏戝勾": 3, "闈掑勾": 4, "涓勾": 5, "鑰佸勾": 6
-              }[item.tjType] || null;
+              item.tjSex =
+                item.tjSex === "鐢�" || item.tjSex === "0"
+                  ? "0"
+                  : item.tjSex === "濂�" || item.tjSex === "1"
+                    ? "1"
+                    : null;
+              item.tjType =
+                {
+                  濠村効: 0,
+                  骞煎効: 1,
+                  鍎跨: 2,
+                  灏戝勾: 3,
+                  闈掑勾: 4,
+                  涓勾: 5,
+                  鑰佸勾: 6,
+                }[item.tjType] || null;
             });
           }
           this.form.lisXmbm = this.form.lisXmbm;
@@ -1056,6 +1234,11 @@
             this.processSubmission(isUpdate, true);
           }
         }
+      });
+      this.deptName = "";
+      // 鎵嬪姩璋冪敤杩囨护鏂规硶锛堥渶绛夊緟 DOM 鏇存柊锛�
+      this.$nextTick(() => {
+        this.$refs.tree1.filter(this.deptName);
       });
     },
     processSubmission(isUpdate, isY) {
@@ -1081,7 +1264,24 @@
         }
       }
     },
-    handleSuccess(isY) {
+    async handleSuccess(isY) {
+      this.cancel();
+
+      if (this.proParent || isY) {
+        // 绛夊緟宸︿晶鏍戝姞杞藉拰鎷奸煶澶勭悊
+        await this.getDeptTree();
+        this.precomputePinyin();
+      }
+
+      // 绛夊緟鍙充晶琛ㄦ牸鍒锋柊
+      await this.getList();
+
+      // 绔嬪嵆鍒锋柊褰撳墠椤圭洰鏁版嵁锛岀‘淇濇暟鎹槸鏈�鏂扮殑
+      await this.refreshCurrentProjectData();
+
+      this.pageLoading = false; // 鉁� 缁熶竴鍔犺浇鐘舵�佹帶鍒�
+    },
+    /* handleSuccess(isY) {
       this.cancel();
       this.getList();
       if (this.proParent || isY) {
@@ -1089,6 +1289,21 @@
           this.precomputePinyin();
         });
       }
+    }, */
+    // 鍒锋柊褰撳墠閫変腑椤圭洰鐨勬暟鎹�
+    async refreshCurrentProjectData() {
+      if (this.id) {
+        try {
+          const response = await getInfoByProId(this.id);
+          this.xiugaiList = response.data;
+          return response.data;
+        } catch (error) {
+          this.$message.error("鍒锋柊椤圭洰鏁版嵁澶辫触");
+          this.xiugaiList = null; // 鍒锋柊澶辫触鏃堕噸缃负 null
+          return null;
+        }
+      }
+      return null;
     },
     submit() {
       this.ChangeList.forEach((item) => {
@@ -1099,6 +1314,10 @@
         this.sfxmId = parseInt(item.id);
       });
       this.dialogTableVisible = false;
+      this.getDeptList();
+      this.getDeptTree().then(() => {
+        this.precomputePinyin();
+      });
     },
     handleDelete(row) {
       const proIds = row.proId || this.ids;
@@ -1116,7 +1335,7 @@
           this.getList();
           this.$modal.msgSuccess("鍒犻櫎鎴愬姛");
         })
-        .catch(() => {});
+        .catch(() => { });
     },
     handleExport() {
       this.download(

--
Gitblit v1.8.0