From 0b523220931d70aa752c3beaca5ed32ca85511c5 Mon Sep 17 00:00:00 2001
From: 闫增涛 <1829501689@qq.com>
Date: 星期四, 28 三月 2024 11:36:05 +0800
Subject: [PATCH] Merge refs/remotes/origin/master into refs/heads/master

---
 packageBookService/pages/bookServices/detail/components/tree/index.js |  138 +++++++++++++++++++++++++++++++++++++++++----
 1 files changed, 125 insertions(+), 13 deletions(-)

diff --git a/packageBookService/pages/bookServices/detail/components/tree/index.js b/packageBookService/pages/bookServices/detail/components/tree/index.js
index 85c10dc..1486ac7 100644
--- a/packageBookService/pages/bookServices/detail/components/tree/index.js
+++ b/packageBookService/pages/bookServices/detail/components/tree/index.js
@@ -34,25 +34,70 @@
     isShowCheck: {
       type: Boolean,
       value: false,
+    },
+    paymentPage: {
+      type: Boolean,
+      value: false,
+    },
+    superior: {
+      type: Boolean,
+      value: false,
     }
   },
   data: {
+    sonPurchaseSaleMethodId: '',
+    superiorPurchaseSaleMethodId: [],
     activeValues: [1, 2],
     webpageSrc: '',
     cloudShoppingCart: []
   },
+  ready() {
+    this.setData({
+
+    })
+    console.log('鍑嗗');
+  },
   onShow() {
+    debugger
+    this.setData({
+      sonPurchaseSaleMethodId: ''
+    })
+  },
+  onLoad() {
+    this.setData({
+      sonPurchaseSaleMethodId: ''
+    })
+  },
+  observers: {
+    'openIds': function (newValue) {
+      // var myEventDetail = {
+      // }
+      // var myEventOption = {
+      //   bubbles: true,
+      //   composed: true
+      // }
+      // this.triggerEvent('handleTree', myEventDetail, myEventOption)
+    }
   },
 
-
   methods: {
+
+    handleList(tree) {
+      for (let index = 0; index < tree.length; index++) {
+        const item = tree[index];
+        if (item.sysType == 'CmsItem' && !item.checked) {
+
+        }
+        if (item.children && item.children.length > 0) {
+          this.handleList(item.children)
+        }
+      }
+    },
     // 鑺傜偣灞曞紑
     handleChange(e) {
-      // console.log(this.properties.treeList, 'this.properties.treeList');
       this.setData({
-        activeValues: e.detail.value,
+        openIds: e.detail.value,
       });
-      // console.log('浼犻��', this.properties.buyIds);
     },
     handleCheck(data) {
       for (let index = 0; index < data.length; index++) {
@@ -182,15 +227,10 @@
     },
     // 鎷垮埌褰撳墠椤瑰瓙椤�
     flattenTree(tree) {
-
       let result = [];
-
       function flatten(node) {
-
         result.push(node);
-
         if (node.children && node.children.length > 0) {
-
           node.children.forEach(child => {
             flatten(child);
           });
@@ -235,7 +275,6 @@
           }
         }
         else if (id == node.id && node.sysType == "CmsItem") {
-          debugger
           node.checked = !node.checked  // 灏嗙洰鏍囬」鐨� check 灞炴�ц缃负 true
         }
       }
@@ -245,20 +284,57 @@
       return tree; // 杩斿洖淇敼鍚庣殑瀹屾暣鏁扮粍
     },
 
+    checkAll() {
+      const ids = []
+      const list = []
+      this.properties.treeList.forEach(item => {
+        if (item.children && item.children.length > 0) {
+          list.push(...this.flattenTree([item]))
+        }
+      })
+      list.forEach(item => {
+        ids.push(item.id)
+      })
+      const updataList = this.findAndUpdateItemsByIds(this.properties.treeList, ids);
+      this.setData({
+        treeList: updataList
+      })
+    },
+
     // 绔犺妭鍕鹃��
     checkResourceTitle(e) {
       // 杩欎釜鏃跺�檆hecked鐨勫�兼槸fals
+      let checkResourceTitleList = []
       const item = e.currentTarget.dataset.item
+      //
       let list = this.flattenTree([item])
       let ids = []
       list.forEach(item => {
         ids.push(item.id)
       })
+      // console.log(list, 'list789');
       const updatedTreeList = this.findAndUpdateItemsByIds(this.properties.treeList, ids);
       this.setData({
         treeList: updatedTreeList  // 鏇存柊 treeList 鏁版嵁
       });
-      console.log(list, 'list');
+
+      if (!list.checked) {
+        if (this.properties.superior) {
+          console.log(852);
+
+          this.properties.superior = false
+          this.setData({
+            superiorPurchaseSaleMethodId: []
+          })
+        }
+        if (!this.properties.superior) {
+          this.setData({
+            superiorPurchaseSaleMethodId: list
+          })
+        }
+      }
+
+      // console.log(this.data.superiorPurchaseSaleMethodId, 'superiorPurchaseSaleMethodId');
       list.forEach(items => {
         console.log(items.checked, 'itesasd');
         if (!items.checked) {
@@ -267,12 +343,41 @@
           })
         }
       })
-      this.onCloudShoppingCart()
+      // this.onCloudShoppingCart()
     },
     // 瀛愰」鍕鹃��
     checkResource(e) {
       const citem = e.currentTarget.dataset.item
-      this.checkResoucrceInfo(this.properties.treeList, citem.id)
+      console.log(citem, '5648');
+      const updataList = this.checkResoucrceInfo(this.properties.treeList, citem.id)
+      console.log(citem.checked, 'citem.checked');
+      if (!citem.checked) {
+        //閫変腑鐨勬椂鍊欐坊鍔爄d
+        let sonPurchaseSaleMethodId = this.data.sonPurchaseSaleMethodId || []
+        console.log(this.properties.paymentPage, 'this.properties.paymentPage');
+        if (this.properties.paymentPage) {
+          console.log(789987);
+          sonPurchaseSaleMethodId = []
+          this.properties.paymentPage = false
+        }
+        if (!this.properties.paymentPage) {
+          sonPurchaseSaleMethodId.push(citem.saleMethod[0].Id)
+        }
+
+
+        this.setData({
+          sonPurchaseSaleMethodId: sonPurchaseSaleMethodId
+        })
+        console.log(this.data.sonPurchaseSaleMethodId);
+      } else {
+        // 鍙栨秷閫変腑鐨勬椂鍊欏垹闄d
+
+      }
+
+      this.setData({
+        treeList: updataList,
+
+      })
     },
     // 鍔犲叆璐墿杞�
     async onCloudShoppingCart() {
@@ -305,4 +410,11 @@
       // }
     },
   },
+  onCheckAllChange(e) {
+    // debugger
+    // console.log('checkbox', e.detail.value);
+    // this.setData({
+    //   checkAllValues: event.detail,
+    // });
+  }
 })
\ No newline at end of file

--
Gitblit v1.9.1