From 076497c7faf7253268d435b87cebacb017d7f735 Mon Sep 17 00:00:00 2001 From: lideqin <694785430@qq.com> Date: Tue, 16 Apr 2024 13:56:04 +0800 Subject: [PATCH] =?UTF-8?q?[update]=20=E6=8E=88=E6=9D=83=E9=83=A8=E9=97=A8?= =?UTF-8?q?=E5=85=88=E5=8B=BE=E9=80=89=E5=A4=8D=E9=80=89=E6=A1=86=E5=86=8D?= =?UTF-8?q?=E5=88=87=E6=8D=A2=E6=A0=91=E6=93=8D=E4=BD=9C=EF=BC=8C=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E5=AD=90=E8=8A=82=E7=82=B9=E9=80=89=E4=B8=AD=E5=AE=9E?= =?UTF-8?q?=E9=99=85=E6=B2=A1=E9=80=89=E4=B8=AD=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../jerobiz/modal/JSelectDepartModal.vue | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/src/components/jerobiz/modal/JSelectDepartModal.vue b/src/components/jerobiz/modal/JSelectDepartModal.vue index bb215e3e..4583d0fc 100644 --- a/src/components/jerobiz/modal/JSelectDepartModal.vue +++ b/src/components/jerobiz/modal/JSelectDepartModal.vue @@ -304,9 +304,39 @@ export default { } return rows }, + // 获取currKeys及其子节点 + getChildrenTreeData (currKeys, treeData) { + const childrenKeys = [] + for (let i = 0; i < treeData.length; i++) { + if (currKeys.includes(treeData[i].key)) { + childrenKeys.push(treeData[i].key) + if (treeData[i].children) { + const childrenKeysArr = this.getChildrenKeys(treeData[i].children) + childrenKeys.push(...childrenKeysArr) + } + } + if (treeData[i].children) { + childrenKeys.push(...this.getChildrenTreeData(currKeys, treeData[i].children)) + } + } + return childrenKeys + }, + // 把传入的树结构key值全部存成一个数组 + getChildrenKeys (treeData) { + const arr = [] + for (const item of treeData) { + arr.push(item.key) + if (item.children) { + arr.push(...this.getChildrenKeys(item.children)) + } + } + return arr + }, switchCheckStrictly (v) { if (v === 1) { this.checkStrictly = false + this.checkedKeys = this.getChildrenTreeData(this.checkedKeys, this.treeData) + this.checkedRows = this.getCheckedRows(this.checkedKeys) } else if (v === 2) { this.checkStrictly = true }