From d1deef73e9c402c57600bfa2384037ba78a97de7 Mon Sep 17 00:00:00 2001
From: 闫增涛 <1829501689@qq.com>
Date: 星期二, 26 三月 2024 15:09:51 +0800
Subject: [PATCH] 云学习bug修改

---
 packageBookService/pages/bookServices/detail/components/tree/index.js |   53 ++++++++++++++++++++++++++++++++++++++++++++++-------
 1 files changed, 46 insertions(+), 7 deletions(-)

diff --git a/packageBookService/pages/bookServices/detail/components/tree/index.js b/packageBookService/pages/bookServices/detail/components/tree/index.js
index 85c10dc..8cd026a 100644
--- a/packageBookService/pages/bookServices/detail/components/tree/index.js
+++ b/packageBookService/pages/bookServices/detail/components/tree/index.js
@@ -37,15 +37,31 @@
     }
   },
   data: {
+    
     activeValues: [1, 2],
     webpageSrc: '',
     cloudShoppingCart: []
   },
   onShow() {
   },
+  observers: {
+    'treeList': function (newValue) {
 
+    }
+  },
 
   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');
@@ -182,15 +198,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 +246,6 @@
           }
         }
         else if (id == node.id && node.sysType == "CmsItem") {
-          debugger
           node.checked = !node.checked  // 灏嗙洰鏍囬」鐨� check 灞炴�ц缃负 true
         }
       }
@@ -243,6 +253,23 @@
         findAndUpdate(node); // 瀵规瘡涓《灞傝妭鐐规墽琛屾煡鎵惧拰鏇存柊鎿嶄綔
       }
       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
+      })
     },
 
     // 绔犺妭鍕鹃��
@@ -272,7 +299,12 @@
     // 瀛愰」鍕鹃��
     checkResource(e) {
       const citem = e.currentTarget.dataset.item
-      this.checkResoucrceInfo(this.properties.treeList, citem.id)
+      console.log(e);
+      const updataList = this.checkResoucrceInfo(this.properties.treeList, citem.id)
+      console.log(updataList);
+      this.setData({
+        treeList: updataList
+      })
     },
     // 鍔犲叆璐墿杞�
     async onCloudShoppingCart() {
@@ -305,4 +337,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