From d98f7e1dd0919cc50d5133ebc3d276d1122b73b9 Mon Sep 17 00:00:00 2001 From: Xu Zhimeng Date: Wed, 5 Jul 2023 16:00:43 +0800 Subject: [PATCH 1/2] =?UTF-8?q?feat:=20CustomTable=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E5=A4=9A=E9=80=89=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/CustomTable/index.vue | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/components/CustomTable/index.vue b/src/components/CustomTable/index.vue index 2959d9a..becf7cb 100644 --- a/src/components/CustomTable/index.vue +++ b/src/components/CustomTable/index.vue @@ -50,6 +50,10 @@ export default { canSelect: { type: Boolean, default: true + }, + multiple: { + type: Boolean, + default: false } }, data() { @@ -60,17 +64,24 @@ export default { methods: { // 实现单击选中/反选功能 customRow(record) { + const key = record[this.rowKey] return { - class: this.innerSelectedRowKeys.includes(record[this.rowKey]) ? 'ant-table-row-selected' : '', + class: this.innerSelectedRowKeys.includes(key) ? 'ant-table-row-selected' : '', on: { click: () => { if(!this.canSelect) { return } - if (this.innerSelectedRowKeys.includes(record[this.rowKey])) { - this.innerSelectedRowKeys = [] + if (this.innerSelectedRowKeys.includes(key)) { + const findIndex = this.innerSelectedRowKeys.findIndex(k => k == key) + this.innerSelectedRowKeys.splice(findIndex, 1) } else { - this.innerSelectedRowKeys = [record[this.rowKey]] + if(this.multiple) { + this.innerSelectedRowKeys.push(key) + } + else { + this.innerSelectedRowKeys = [key] + } } this.$emit('update:selectedRowKeys', this.innerSelectedRowKeys) } From 0fd52c80cf9935a8a50475e91a4de648ccb4b9ee Mon Sep 17 00:00:00 2001 From: Xu Zhimeng Date: Fri, 7 Jul 2023 15:45:09 +0800 Subject: [PATCH 2/2] =?UTF-8?q?feat:=20CustomTable=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E5=90=8C=E6=AD=A5=E9=80=89=E4=B8=AD=E7=9A=84=E8=A1=8C=E5=8A=9F?= =?UTF-8?q?=E8=83=BD(selectionRows)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/CustomTable/index.vue | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/components/CustomTable/index.vue b/src/components/CustomTable/index.vue index becf7cb..5e11459 100644 --- a/src/components/CustomTable/index.vue +++ b/src/components/CustomTable/index.vue @@ -19,7 +19,6 @@