From 21230681ce497427ec17b93e1c66dc58ae739446 Mon Sep 17 00:00:00 2001
From: lkk <364857242@qq.com>
Date: 星期三, 22 一月 2025 15:19:52 +0800
Subject: [PATCH] 111

---
 src/views/hosp/order/index.vue |  168 ++++++++++++++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 158 insertions(+), 10 deletions(-)

diff --git a/src/views/hosp/order/index.vue b/src/views/hosp/order/index.vue
index c5e9a65..31be2bf 100644
--- a/src/views/hosp/order/index.vue
+++ b/src/views/hosp/order/index.vue
@@ -673,7 +673,7 @@
                         :props="defaultProps"
                         show-checkbox
                         node-key="proId"
-                        @check="handleCurrentChecked"
+                        @check-change="handleCurrentChecked"
                         :default-checked-keys="checkedkey"
                         :filter-node-method="filterNode"
                         ref="tree"
@@ -966,7 +966,7 @@
                         :props="defaultProp"
                         show-checkbox
                         node-key="id"
-                        @check="handlepackage"
+                        @check-change="handlepackage"
                         :default-checked-keys="checkedkeys"
                         :filter-node-method="filterpackage"
                         ref="treas"
@@ -1027,7 +1027,7 @@
                         :props="defaultProps"
                         show-checkbox
                         node-key="proId"
-                        @check="handleCurrentChecked"
+                        @check-change="handleCurrentChecked"
                         :default-checked-keys="checkedkey"
                         :filter-node-method="filterNode"
                         ref="tree"
@@ -1180,7 +1180,7 @@
             </el-table-column>
           </el-table>
 
-          <!-- <h3 style="font-weight: 600">鍚堣锛歿{ marryalls }}鍏�</h3> -->
+          <h3 style="font-weight: 600">鍚堣锛歿{ marryalls }}鍏�</h3>
         </div>
       </div>
 
@@ -2513,8 +2513,88 @@
         // }
       }
     },
-
     handlepackage(data, checked, checkedNodes) {
+      if (checked == true) {
+        this.$refs.treas.setCheckedKeys([data.id]);
+        let datas = {
+          zhId: data.id,
+        };
+
+        getlistByZhId(datas).then((res) => {
+          this.packagedataList = res.data.tjProjectList;
+          for (var i = 0; i < this.packagedataList.length; i++) {
+            let proId = this.packagedataList[i].proId;
+            getProSonDxList(proId).then((res) => {
+              this.TreedataList = res.data.list;
+              this.TreedataList.forEach((item) => {
+                this.Datalists.push(item);
+              });
+
+              // 鍚堝苟 Datalists 鍜� DataList 鍒� DataList3
+              this.DataList3 = this.DataList.concat(this.Datalists);
+
+              // 娓呯┖绱姞鍣�
+              this.marryalls = 0;
+              this.TotalPrice1 = 0;
+
+              // 閲嶆柊璁$畻浠锋牸
+              this.DataList3.forEach((item) => {
+                console.log(item.proPrice);
+                this.TotalPrice1 += item.proPrice * item.sl;
+                this.marryalls += item.proPrice; 
+              });
+
+              // 涓烘瘡涓」鐩坊鍔� propinName
+              this.Datalists.forEach((item1) => {
+                this.packagedataList.forEach((item3) => {
+                  if (item1.proParentId == item3.proId) {
+                    item1.propinName = item3.proName;
+                  }
+                });
+              });
+            });
+          }
+        });
+      } else if (checked == false) {
+        let datas = {
+          zhId: data.id,
+        };
+
+        this.marryalls = 0;
+
+        // 娓呯┖ Datalists 鍜� DataList3
+        this.Datalists = [];
+        this.DataList3 = [...this.DataList]; // 閲嶆柊璁剧疆 DataList3锛屼粎鍖呭惈鍘熷 DataList
+
+        getlistByZhId(datas).then((res) => {
+          this.packagedataList = res.data.tjProjectList;
+          for (var i = 0; i < this.packagedataList.length; i++) {
+            let proId = this.packagedataList[i].proId;
+            getProSonDxList(proId).then((res) => {
+              this.TreedataList = res.data.list;
+              this.checkedListkey = this.checkedListkey.filter(
+                (id) => id !== proId
+              );
+
+              // 浠� DataList3 涓Щ闄ょ浉鍏崇殑瀛愰」
+              this.DataList3 = this.DataList3.filter(
+                (item) => item.proParentId !== proId
+              );
+
+              // 鏇存柊鎬讳环鏍�
+              this.TotalPrice1 = 0; // 娓呯┖浠锋牸
+              this.DataList3.forEach((item) => {
+                this.TotalPrice1 += item.proPrice;
+              });
+            });
+          }
+        });
+      }
+    },
+
+    /* handlepackage(data, checked, checkedNodes) {
+      console.log(checked, 3333);
+
       if (checked.checkedNodes.length != 0) {
         this.$refs.treas.setCheckedKeys([data.id]);
         let datas = {
@@ -2537,7 +2617,7 @@
                     this.marryalls += item1.proPrice;
                     // this.TotalPrice1 = this.marryalls;
                     this.TotalPrice1 = 0;
-                    console.log(this.DataList3, 9999999999);
+
                     if (this.DataList3.length != 0) {
                       this.DataList3.forEach((item) => {
                         console.log(item.proPrice);
@@ -2557,7 +2637,7 @@
         });
       } else if (checked.checkedNodes.length == 0) {
       }
-    },
+    }, */
 
     renderContent(h, { node, data, store }) {
       return (
@@ -2664,9 +2744,10 @@
     },
 
     // 鐐瑰嚮鑾峰彇姣忎釜鏍戣妭鐐�
-    handleCurrentChecked(data, checked, checkedNodes) {
+    /*  handleCurrentChecked(data, checked, checkedNodes) {
       this.dataObj = data;
-      if (checked.checkedNodes.length != 0) {
+      this.checkedObj = checked;
+      if (checked == true) {
         this.$refs.tree.setCheckedKeys([data.proId]);
         let proId = data.proId;
         getProSonDxList(proId).then((res) => {
@@ -2699,11 +2780,78 @@
           //   }
           // }
         });
-      } else if (checked.checkedNodes.length == 0) {
+      } else if (checked == false) {
         let proId = data.proId;
         getProSonDxList(proId).then((res) => {
           this.TreedataList = res.data.list;
           this.checkedListkey = [];
+          this.TreedataList.forEach((item) => {
+            item.disabled = true;
+          });
+          this.DataList3.forEach((item, index) => {
+            if (item.proParentId == this.dataObj.proId) {
+              this.DataList3.splice(index, this.TreedataList.length);
+            }
+          });
+
+          // 鎵嬪姩鏇存柊鎬讳环鏍�
+          this.TotalPrice1 = 0;
+          this.DataList3.forEach((item, index) => {
+            this.TotalPrice1 += item.proPrice * item.sl;
+          });
+        });
+      }
+    }, */
+    handleCurrentChecked(data, checked, checkedNodes) {
+      this.dataObj = data;
+      this.checkedObj = checked;
+
+      if (checked === true) {
+        this.$refs.tree.setCheckedKeys([data.proId]);
+        let proId = data.proId;
+        getProSonDxList(proId).then((res) => {
+          this.TreedataList = res.data.list;
+          this.TreedataList.forEach((item) => {
+            item.disabled = true;
+            this.checkedListkey.push(item.proId);
+            this.DataList3.push(item);
+            this.spliceData();
+            this.DataList3.forEach((item1) => {
+              this.TotalPrice1 += item1.proPrice * item1.sl;
+              if (item1.proParentId == data.proId) {
+                item1.propinName = data.proName;
+                item1.propinPrice = this.dataObj.proPrice;
+              }
+            });
+          });
+
+          // 鏇存柊鎬讳环鏍�
+          this.TotalPrice1 = 0;
+          this.DataList3.forEach((item) => {
+            this.TotalPrice1 += item.proPrice * item.sl;
+          });
+        });
+      } else if (checked === false) {
+        // 褰撳彇娑堥�変腑鏃�
+        let proId = data.proId;
+        getProSonDxList(proId).then((res) => {
+          this.TreedataList = res.data.list;
+
+          // 浠庡凡閫夊垪琛ㄤ腑绉婚櫎璇ラ」鐩殑 ID
+          this.checkedListkey = this.checkedListkey.filter(
+            (id) => id !== proId
+          );
+
+          // 浠� DataList3 涓Щ闄ょ浉鍏崇殑瀛愰」
+          this.DataList3 = this.DataList3.filter(
+            (item) => item.proParentId !== proId
+          );
+
+          // 鏇存柊鎬讳环鏍�
+          this.TotalPrice1 = 0;
+          this.DataList3.forEach((item) => {
+            this.TotalPrice1 += item.proPrice * item.sl;
+          });
         });
       }
     },

--
Gitblit v1.8.0