From 98c2ffeee3c0c2dfc2d5f311b793695a33bf6a3f Mon Sep 17 00:00:00 2001 From: xiayifan Date: Tue, 2 Jun 2020 14:47:29 +0800 Subject: [PATCH] fix mutiSelectComponents filter result incorrect --- .../ui/src/components/multiselectGroup.vue | 35 ++++++++++++++----- 1 file changed, 26 insertions(+), 9 deletions(-) diff --git a/mindinsight/ui/src/components/multiselectGroup.vue b/mindinsight/ui/src/components/multiselectGroup.vue index 0c67262..51f0977 100644 --- a/mindinsight/ui/src/components/multiselectGroup.vue +++ b/mindinsight/ui/src/components/multiselectGroup.vue @@ -48,7 +48,8 @@ limitations under the License. popper-class="tooltip-show-content" :content="item.label" placement="top"> - {{item.label}} @@ -79,7 +80,8 @@ limitations under the License. popper-class="tooltip-show-content" :content="item.label" placement="top"> - {{item.label}} @@ -172,7 +174,12 @@ export default { break; } const listItem = this.checkListArr[i]; - if ((listItem.show && !listItem.checked) || listItem.checked) { + if (listItem.checked) { + this.selectedNumber++; + if (listItem.show) { + this.multiSelectedItemNames[listItem.label] = true; + } + } else if (listItem.show) { listItem.checked = true; this.multiSelectedItemNames[listItem.label] = true; this.selectedNumber++; @@ -222,13 +229,14 @@ export default { // Filter the tags that do not meet the conditions in the operation bar and hide them this.checkListArr.forEach((listItem) => { if (listItem.checked) { - this.multiSelectedItemNames[listItem.label] = true; this.selectedNumber++; } if (reg.test(listItem.label)) { listItem.show = true; if (!listItem.checked) { itemSelectAll = false; + } else { + this.multiSelectedItemNames[listItem.label] = true; } } else { listItem.show = false; @@ -236,7 +244,9 @@ export default { }); // Update the selected status of the Select All button if (this.isLimit && !itemSelectAll) { - itemSelectAll = this.selectedNumber >= this.limitNum || this.selectedNumber >= this.checkListArr.length; + itemSelectAll = + this.selectedNumber >= this.limitNum || + this.selectedNumber >= this.checkListArr.length; } this.operateSelectAll = itemSelectAll; this.$emit('selectedChange', this.multiSelectedItemNames); @@ -275,7 +285,9 @@ export default { } }); if (this.isLimit && !itemSelectAll) { - itemSelectAll = this.selectedNumber >= this.limitNum || this.selectedNumber >= this.checkListArr.length; + itemSelectAll = + this.selectedNumber >= this.limitNum || + this.selectedNumber >= this.checkListArr.length; } this.operateSelectAll = itemSelectAll; // Return a dictionary containing selected items. @@ -307,9 +319,9 @@ export default { reg = new RegExp(this.valiableSearchInput); } this.multiSelectedItemNames = {}; + this.selectedNumber = 0; let itemSelectAll = true; if (this.isLimit) { - this.selectedNumber = 0; const loopCount = this.checkListArr.length; for (let i = 0; i < loopCount; i++) { const listItem = this.checkListArr[i]; @@ -317,17 +329,22 @@ export default { if (this.selectedNumber >= this.limitNum) { listItem.checked = false; } else { - this.multiSelectedItemNames[listItem.label] = true; this.selectedNumber++; } } if (reg.test(listItem.label)) { listItem.show = true; + if (listItem.checked) { + this.multiSelectedItemNames[listItem.label] = true; + } } else { listItem.show = false; } } - if (this.selectedNumber >= this.limitNum || this.selectedNumber >= this.checkListArr.length) { + if ( + this.selectedNumber >= this.limitNum || + this.selectedNumber >= this.checkListArr.length + ) { itemSelectAll = true; } else { itemSelectAll = false; -- GitLab