From d889c4dc0f9f0a3cf775d7fae507a31dee050074 Mon Sep 17 00:00:00 2001 From: yzp Date: Tue, 11 Apr 2023 13:52:33 +0800 Subject: [PATCH] =?UTF-8?q?BUG:CoolumnSetting=E7=9A=84=E9=87=8D=E7=BD=AE?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=E4=B8=8D=E5=8F=AF=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/components/Table/columnSetting.vue | 23 +++++++++++++------ 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/snowy-admin-web/src/components/Table/columnSetting.vue b/snowy-admin-web/src/components/Table/columnSetting.vue index ea491e9c..9d2edaf3 100644 --- a/snowy-admin-web/src/components/Table/columnSetting.vue +++ b/snowy-admin-web/src/components/Table/columnSetting.vue @@ -45,17 +45,26 @@ } }, mounted() { - this.columnsSetting = this.columns.map((value) => ({ - ...value, - checked: true - })) - this.originColumns = [...this.columnsSetting] + this.columnsSetting = this.columns.map((value) => { + if (value.checked == undefined) { + return { + ...value, + checked: true + } + } else return value + }) + // 这里要用深的拷贝,否则,勾选了字段时会修改了originColumns里的内容 + this.originColumns = this.columnsSetting.map((value) => ({ ...value })) + // 处理全选组件 + const notCheckedList = this.columnsSetting.filter((value) => !value.checked) + if (notCheckedList.length) this.checkAll = false }, methods: { reset() { - this.originColumns = [...this.columnsSetting] + this.columnsSetting = this.originColumns.map((value) => ({ ...value })) this.indeterminate = false - this.checkAll = true + const checkedList = this.columnsSetting.filter((value) => value.checked) + this.checkAll = checkedList.length === this.columnsSetting.length this.emitColumnChange() }, onChange() {