From 40c02156f1e004e1e8fbdad0fc83218fd335e64f Mon Sep 17 00:00:00 2001 From: yiwenZhou <67539158+ywywZhou@users.noreply.github.com> Date: Mon, 13 Nov 2023 11:34:26 +0800 Subject: [PATCH] =?UTF-8?q?optimization:=20ip=E9=80=89=E6=8B=A9=E5=99=A8?= =?UTF-8?q?=E4=BA=A4=E4=BA=92=E4=BC=98=E5=8C=96=20(#7136)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../RenderForm/IpSelector/IpSelectorTable.vue | 19 +++++-- .../IpSelector/StaticIpAddingPanel.vue | 49 ++++++++++++++----- 2 files changed, 51 insertions(+), 17 deletions(-) diff --git a/frontend/desktop/src/components/common/RenderForm/IpSelector/IpSelectorTable.vue b/frontend/desktop/src/components/common/RenderForm/IpSelector/IpSelectorTable.vue index f433b6446d..21253608ae 100644 --- a/frontend/desktop/src/components/common/RenderForm/IpSelector/IpSelectorTable.vue +++ b/frontend/desktop/src/components/common/RenderForm/IpSelector/IpSelectorTable.vue @@ -107,6 +107,10 @@ type: Array, default: () => ([]) }, + searchResult: { + type: Array, + default: () => ([]) + }, listInPage: { type: Array, default: () => ([]) @@ -180,6 +184,12 @@ this.$emit('handleSelectionChange', val) }, deep: true + }, + isSearchMode (val) { + // 如果在搜索情况下全选,取消时则需要重新判断是否为全选 + if (!val && this.listAllSelected) { + this.listAllSelected = this.selectedIp.length === this.staticIpList.length + } } }, created () { @@ -188,6 +198,7 @@ item.checked = this.staticIpTableConfig.includes(item.id) }) } + this.listAllSelected = this.selectedIp.length === this.staticIpList.length }, methods: { handleSelectionChange (data) { @@ -206,7 +217,7 @@ return h('div', [ h('bk-checkbox', { props: { - indeterminate: this.judegeIndeterminate(), + indeterminate: this.judgeIndeterminate(), value: this.listAllSelected }, on: { @@ -217,7 +228,7 @@ }) ]) }, - judegeIndeterminate () { + judgeIndeterminate () { let selectedIp = tools.deepClone(this.selectedIp) if (selectedIp.length === 0) { return false @@ -233,7 +244,8 @@ this.selectedIp = [] this.listAllSelected = false } else { - this.selectedIp = [...this.staticIpList] + const list = this.isSearchMode ? this.searchResult : this.staticIpList + this.selectedIp = [...list] this.listAllSelected = true } }, @@ -322,7 +334,6 @@ text-align: center; color: #c4c6cc; .add-ip-btn { - margin: 0 -2px 0 -2px; color: #3a84ff; cursor: pointer; } diff --git a/frontend/desktop/src/components/common/RenderForm/IpSelector/StaticIpAddingPanel.vue b/frontend/desktop/src/components/common/RenderForm/IpSelector/StaticIpAddingPanel.vue index c18a54e4d9..a3756d2630 100644 --- a/frontend/desktop/src/components/common/RenderForm/IpSelector/StaticIpAddingPanel.vue +++ b/frontend/desktop/src/components/common/RenderForm/IpSelector/StaticIpAddingPanel.vue @@ -17,15 +17,16 @@ @search="onIpSearch">
-