From 1914f6cd22ec9e880d5b8ffcc393ed1fcb744655 Mon Sep 17 00:00:00 2001
From: lkk <364857242@qq.com>
Date: 星期三, 22 一月 2025 18:51:40 +0800
Subject: [PATCH] 33

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

diff --git a/src/views/hosp/order/index.vue b/src/views/hosp/order/index.vue
index c5e9a65..be4a6e1 100644
--- a/src/views/hosp/order/index.vue
+++ b/src/views/hosp/order/index.vue
@@ -612,7 +612,7 @@
                         :props="defaultProp"
                         show-checkbox
                         node-key="id"
-                        @check="handlepackage"
+                        @check-change="handlepackage"
                         :default-checked-keys="checkedkeys"
                         :filter-node-method="filterpackage"
                         ref="treas"
@@ -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"
@@ -2294,6 +2294,36 @@
       //   return [rowspan, 1];
       // }
     },
+     objectspanmethod({ row, column, rowIndex, columnIndex }) {
+      let fields = ["propinName"];
+      let cellValue = row[column.property];
+      if (cellValue && fields.includes(column.property)) {
+        let prevRow = this.Datalists[rowIndex - 1];
+        let nextRow = this.Datalists[rowIndex + 1];
+        if (prevRow && prevRow[column.property] === cellValue) {
+          return { rowspan: 0, colspan: 0 };
+        } else {
+          let countRowspan = 1;
+          while (nextRow && nextRow[column.property] === cellValue) {
+            nextRow = this.Datalists[++countRowspan + rowIndex];
+          }
+
+          if (countRowspan > 1) {
+            return { rowspan: countRowspan, colspan: 1 };
+          }
+        }
+      }
+
+      // if (columnIndex == 3) {
+      //   let rowspan = 0;
+      //   this.DataLists.forEach((element) => {
+      //     if (element.propinName === row.propinName) {
+      //       rowspan++;
+      //     }
+      //   });
+      //   return [rowspan, 1];
+      // }
+    },
     filterpackage(value, data) {
       if (!value) return true;
       if (data.zhmc.indexOf(value) !== -1) {
@@ -2513,8 +2543,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 * item.sl;
+              });
+
+              // 涓烘瘡涓」鐩坊鍔� 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 +2647,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 +2667,7 @@
         });
       } else if (checked.checkedNodes.length == 0) {
       }
-    },
+    }, */
 
     renderContent(h, { node, data, store }) {
       return (
@@ -2579,6 +2689,8 @@
       this.orderId = row.orderId;
       this.cusId = row.tjCusIdCard;
       this.userId = row.userId;
+      console.log(row, 666);
+
       this.customer = {
         cusIdcard: row.tjCusIdCard,
         cusName: row.tjCustomerName,
@@ -2664,9 +2776,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 +2812,81 @@
           //   }
           // }
         });
-      } 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;
+        console.log(data,9898);
+        
+        getProSonDxList(proId).then((res) => {
+          this.TreedataList = res.data.list;
+          this.TreedataList.forEach((item) => {
+            // item.disabled = true;
+            this.checkedListkey.push(item.proId);
+            this.Datalists.push(item);
+            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