From 4f5b8b7194362e975953269ccc07cd3a5360980f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=B1=E7=9C=A0=E5=84=80=E5=BC=8F?= <854085467@qq.com> Date: Wed, 10 Aug 2022 23:22:30 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8(component):=20=E4=BC=98=E5=8C=96=20ta?= =?UTF-8?q?ble=20=E4=B8=8E=20transfer=20=E5=A4=8D=E9=80=89=E9=80=BB?= =?UTF-8?q?=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../component/src/component/table/index.vue | 22 +++++++++---------- .../src/component/transfer/index.vue | 20 ++++++++--------- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/package/component/src/component/table/index.vue b/package/component/src/component/table/index.vue index 3be0d862..18a83437 100644 --- a/package/component/src/component/table/index.vue +++ b/package/component/src/component/table/index.vue @@ -263,18 +263,18 @@ watch( { deep: true } ); -const changeAll = (checked: any) => { - const ids = props.dataSource.map((item: any) => { - return item[props.id]; - }); - let arr = [...tableSelectedKeys.value]; - arr.splice(0, ids.length); - if (checked) { - ids.forEach((id) => { - arr.push(id); +const changeAll = (isChecked: boolean) => { + // Selected + if(isChecked) { + const datasources = props.dataSource.filter((item: any, index: number) => { + return !props.getCheckboxProps(item, index).disabled; }); - } - tableSelectedKeys.value = arr; + const ids = datasources.map((item) => {return item[props.id]}); + tableSelectedKeys.value = [...ids]; + } else { + // unSelected + tableSelectedKeys.value = []; + } }; watch( diff --git a/package/component/src/component/transfer/index.vue b/package/component/src/component/transfer/index.vue index f781fd74..d64b8f77 100644 --- a/package/component/src/component/transfer/index.vue +++ b/package/component/src/component/transfer/index.vue @@ -48,12 +48,12 @@ const hasRightChecked = ref(false); const allLeftChange = (isChecked: boolean) => { if (isChecked) { - const ids = leftDataSource.value.map((item: any) => { - if(!item.disabled) { - return item[props.id]; - } + const datasources = leftDataSource.value.filter((item: any) => { + return !item.disabled }); - leftSelectedKeys.value = ids; + const ids = datasources.map((item) => {return item[props.id]}); + console.log(JSON.stringify(ids)) + leftSelectedKeys.value = [...ids]; } else { leftSelectedKeys.value = []; } @@ -81,12 +81,12 @@ watch( const allRightChange = (checked: any) => { if (checked) { - const ids = rightDataSource.value.map((item: any) => { - if(!item.disabled) { - return item[props.id]; - } + const datasources = rightDataSource.value.filter((item: any) => { + return !item.disabled }); - rightSelectedKeys.value = ids; + const ids = datasources.map((item) => { return item[props.id]}) + console.log(JSON.stringify(ids)) + rightSelectedKeys.value = [...ids]; } else { rightSelectedKeys.value = []; }