✨(component): 优化 table 与 transfer 复选逻辑
This commit is contained in:
parent
78559592e9
commit
4f5b8b7194
@ -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;
|
||||
});
|
||||
const ids = datasources.map((item) => {return item[props.id]});
|
||||
tableSelectedKeys.value = [...ids];
|
||||
} else {
|
||||
// unSelected
|
||||
tableSelectedKeys.value = [];
|
||||
}
|
||||
tableSelectedKeys.value = arr;
|
||||
};
|
||||
|
||||
watch(
|
||||
|
@ -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 = [];
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user