| | |
| | | webpageSrc: '', |
| | | cloudShoppingCart: [], |
| | | selectAll: [], |
| | | shoppingCart: true |
| | | shoppingCart: true, |
| | | stop: false, |
| | | }, |
| | | ready() { |
| | | this.setData({ |
| | |
| | | }, |
| | | |
| | | methods: { |
| | | |
| | | handleList(tree) { |
| | | for (let index = 0; index < tree.length; index++) { |
| | | const item = tree[index]; |
| | |
| | | } |
| | | } |
| | | tree.forEach(node => { |
| | | |
| | | flatten(node); |
| | | }); |
| | | // console.log(result, 'result'); |
| | |
| | | }, |
| | | |
| | | // 变为true |
| | | findAndUpdateItemsByIds(tree, ids) { |
| | | findAndUpdateItemsByIds(tree, ids, state) { |
| | | function findAndUpdate(node) { |
| | | if (ids.includes(node.id)) { |
| | | // console.log(node, 'node'); |
| | | node.checked = !node.checked // 将目标项的 check 属性设置为 true |
| | | node.checked = state // 将目标项的 check 属性设置为 true |
| | | } |
| | | if (node.children && node.children.length > 0) { |
| | | for (let child of node.children) { |
| | |
| | | } |
| | | } |
| | | } |
| | | |
| | | for (let node of tree) { |
| | | |
| | | findAndUpdate(node); // 对每个顶层节点执行查找和更新操作 |
| | | } |
| | | // console.log(tree, 'tree345'); |
| | |
| | | } |
| | | return tree; // 返回修改后的完整数组 |
| | | }, |
| | | |
| | | // 全选 |
| | | checkAll() { |
| | | const ids = [] |
| | | const list = [] |
| | |
| | | }) |
| | | list.forEach(item => { |
| | | ids.push(item.id) |
| | | |
| | | checked = item.checked |
| | | }) |
| | | |
| | | |
| | | const updataList = this.findAndUpdateItemsByIds(this.properties.treeList, ids); |
| | | |
| | | const flag = list.findIndex(item => item.checked == false) > -1 ? true : false |
| | | const updataList = this.findAndUpdateItemsByIds(this.properties.treeList, ids, flag); |
| | | console.log(checked, 'list'); |
| | | if (!checked) { |
| | | this.setData({ |
| | | selectAll: list |
| | | }) |
| | | |
| | | } |
| | | |
| | | this.setData({ |
| | | treeList: updataList |
| | | }) |
| | |
| | | |
| | | // 章节勾选 |
| | | checkResourceTitle(e) { |
| | | const flag = e.detail.checked |
| | | debugger |
| | | // 这个时候checked的值是fals |
| | | let checkResourceTitleList = [] |
| | | const item = e.currentTarget.dataset.item |
| | |
| | | ids.push(item.id) |
| | | }) |
| | | // console.log(list, 'list789'); |
| | | const updatedTreeList = this.findAndUpdateItemsByIds(this.properties.treeList, ids); |
| | | const updatedTreeList = this.findAndUpdateItemsByIds(this.properties.treeList, ids, flag); |
| | | this.setData({ |
| | | treeList: updatedTreeList // 更新 treeList 数据 |
| | | }); |
| | | console.log(list, 'list.checked'); |
| | | if (!list.checked) { |
| | | |
| | | |
| | | this.setData({ |
| | | superiorPurchaseSaleMethodId: list |
| | | }) |
| | | |
| | | } |
| | | |
| | | // console.log(this.data.superiorPurchaseSaleMethodId, 'superiorPurchaseSaleMethodId'); |
| | | list.forEach(items => { |
| | | console.log(items.checked, 'itesasd'); |
| | |
| | | cloudShoppingCart: items |
| | | }) |
| | | } |
| | | }) |
| | | this.setData({ |
| | | openIds: this.data.openIds |
| | | }) |
| | | }, |
| | | // 子项勾选 |
| | |
| | | |
| | | }, |
| | | }, |
| | | onCheckAllChange(e) { |
| | | // debugger |
| | | // console.log('checkbox', e.detail.value); |
| | | // this.setData({ |
| | | // checkAllValues: event.detail, |
| | | // }); |
| | | }, |
| | | |
| | | catchtap() {} |
| | | }) |