From fc5c3dcc0305f60f2e12373e6f5ec547408bb758 Mon Sep 17 00:00:00 2001 From: fit2cloud-chenyw Date: Tue, 27 Jul 2021 15:04:56 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=B8=8B=E6=8B=89=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=85=A8=E9=83=A8=E9=80=89=E9=A1=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../widget/DeWidget/DeSelectGrid.vue | 49 +++++++++++++++++-- 1 file changed, 46 insertions(+), 3 deletions(-) diff --git a/frontend/src/components/widget/DeWidget/DeSelectGrid.vue b/frontend/src/components/widget/DeWidget/DeSelectGrid.vue index 452186fdbc..d03e024a00 100644 --- a/frontend/src/components/widget/DeWidget/DeSelectGrid.vue +++ b/frontend/src/components/widget/DeWidget/DeSelectGrid.vue @@ -8,7 +8,7 @@ {{ node.label }} - {{ node.label }} + {{ node.label }} + {{ node.label }} @@ -70,7 +71,13 @@ export default { label: 'text', children: 'children' }, - keyWord: null + keyWord: null, + allNode: { + id: (-2 << 16) + '', + text: this.$t('commons.all'), + checked: false, + indeterminate: false + } } }, computed: { @@ -89,6 +96,11 @@ export default { !sourceValid && (this.options.value = []) sourceValid && !Array.isArray(sourceValue) && (this.options.value = sourceValue.split(',')) !this.inDraw && (this.options.value = []) + if (!this.inDraw) { + this.options.value = [] + this.allNode.indeterminate = false + this.allNode.checked = false + } this.setMutiBox() } else { !sourceValid && (this.options.value = null) @@ -122,6 +134,7 @@ export default { this.options.attrs.datas.forEach(data => { data.checked = (this.options.value && this.options.value.includes(data.id)) }) + this.setAllNodeStatus() } }, setRadioBox() { @@ -150,6 +163,36 @@ export default { values.splice(index, 1) } + this.setAllNodeStatus() + + this.options.value = values + this.setCondition() + }, + // 勾选数据项 会影响全选节点的状态 + setAllNodeStatus() { + const nodeSize = this.options.attrs.datas.length + const checkedSize = this.options.attrs.datas.filter(item => item.checked).length + if (nodeSize === checkedSize) { + this.allNode.checked = true + this.allNode.indeterminate = false + } else if (checkedSize === 0) { + this.allNode.checked = false + this.allNode.indeterminate = false + } else { + this.allNode.checked = false + this.allNode.indeterminate = true + } + }, + allCheckChange(data) { + data.indeterminate = false + const values = [] + // this.options.value = [] + this.options.attrs.datas.forEach(item => { + item.checked = data.checked + // data.checked && this.options.value.push(item.id) + data.checked && values.push(item.id) + }) + this.options.value = values this.setCondition() },