From f39e83047893486e31b8d8ed385c274948033f68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=93=E6=B4=81?= <209192278@qq.com> Date: Fri, 17 Feb 2023 18:07:29 +0800 Subject: [PATCH 1/2] =?UTF-8?q?dengjie=20:=20=E8=A7=A3=E5=86=B3=E9=83=A8?= =?UTF-8?q?=E9=97=A8=E9=80=89=E6=8B=A9=E5=99=A8=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/components/common/DeptPicker.vue | 119 ++++++++++-------- 1 file changed, 64 insertions(+), 55 deletions(-) diff --git a/flowable-engine-web/src/components/common/DeptPicker.vue b/flowable-engine-web/src/components/common/DeptPicker.vue index c02c9fd..bee8062 100644 --- a/flowable-engine-web/src/components/common/DeptPicker.vue +++ b/flowable-engine-web/src/components/common/DeptPicker.vue @@ -7,11 +7,11 @@ - + -
@@ -20,7 +20,6 @@
-
已选 {{ selectList.length }} 项 @@ -120,40 +119,47 @@ export default { * @param checked 是否选中 */ handleCheckChange(data, checked) { - // 左侧有选择框 - if (this.showCheckbox) { - // 左侧有选择框 + 多选 - if (this.multiple) { - //不添加重复的数据到右边 - for (let i = 0; i < this.selectList.length; i++) { - if (this.selectList[i].value === data.value) { - this.selectList.splice(i, 1); - break; + // if (data.children === undefined) { + // 左侧有选择框 + if (this.showCheckbox) { + // 左侧有选择框 + 多选 + if (this.multiple ) { + //不添加重复的数据到右边 + for (let i = 0; i < this.selectList.length; i++) { + if (this.selectList[i].value === data.value) { + this.selectList.splice(i, 1); + break; + } } - } - if (checked) { - this.selectList.push(data); - } else if (data === '1') { - this.$refs.tree.setCheckedKeys([]); - this.selectList = []; - } - } else {// 左侧有选择框 + 单选 - //不添加重复的数据到右边 - for (let i = 0; i < this.selectList.length; i++) { - if (this.selectList[i].value === data.value) { - this.selectList.splice(i, 1); - break; + if (checked) { + if(data.children === undefined){ + this.selectList.push(data); + } + + } else if (data === '1') { + this.$refs.tree.setCheckedKeys([]); + this.selectList = []; + } + } else {// 左侧有选择框 + 单选 + console.log('左侧有选择框 + 单选') + //不添加重复的数据到右边 + for (let i = 0; i < this.selectList.length; i++) { + if (this.selectList[i].value === data.value) { + this.selectList.splice(i, 1); + break; + } + } + if (checked) { + this.$refs.tree.setCheckedNodes([data]); + // this.$refs.tree.setCheckedKeys([]); + this.selectList = [data]; + } else if (data === '1') { + this.selectList = []; + this.$refs.tree.setCheckedKeys([]); } - } - if (checked) { - this.$refs.tree.setCheckedNodes([data]); - this.selectList = [data]; - } else if (data === '1') { - this.$refs.tree.setCheckedKeys([]); - this.selectList = []; } } - } + // } this._value = this.selectList }, @@ -164,19 +170,21 @@ export default { * @param check checked(checkbox选择框)是否选中 */ handle(node, check) { - if (this.multiple) { - //不添加重复的数据到右边 - for (let i = 0; i < this.selectList.length; i++) { - if (this.selectList[i].value === node.value) { - this.selectList.splice(i, 1); - break; + if (check.isLeaf !== false) { + if (this.multiple) { + //不添加重复的数据到右边 + for (let i = 0; i < this.selectList.length; i++) { + if (this.selectList[i].value === node.value) { + this.selectList.splice(i, 1); + break; + } } + check.checked = true + this.selectList.push(node); + } else { + check.checked = true + this.selectList = [node]; } - check.checked = true - this.selectList.push(node); - } else { - check.checked = true - this.selectList = [node]; } this._value = this.selectList }, @@ -203,9 +211,10 @@ export default { cancelButtonText: "取消", type: "warning" }).then(() => { - this.handleCheckChange("1"); if (!this.showCheckbox) { this.selectList = [] + }else { + this.handleCheckChange("1"); } }); }, @@ -221,15 +230,15 @@ export default {