✨(component): 优化 table 与 transfer 复选逻辑
This commit is contained in:
parent
78559592e9
commit
4f5b8b7194
@ -263,18 +263,18 @@ watch(
|
|||||||
{ deep: true }
|
{ deep: true }
|
||||||
);
|
);
|
||||||
|
|
||||||
const changeAll = (checked: any) => {
|
const changeAll = (isChecked: boolean) => {
|
||||||
const ids = props.dataSource.map((item: any) => {
|
// Selected
|
||||||
return item[props.id];
|
if(isChecked) {
|
||||||
});
|
const datasources = props.dataSource.filter((item: any, index: number) => {
|
||||||
let arr = [...tableSelectedKeys.value];
|
return !props.getCheckboxProps(item, index).disabled;
|
||||||
arr.splice(0, ids.length);
|
|
||||||
if (checked) {
|
|
||||||
ids.forEach((id) => {
|
|
||||||
arr.push(id);
|
|
||||||
});
|
});
|
||||||
|
const ids = datasources.map((item) => {return item[props.id]});
|
||||||
|
tableSelectedKeys.value = [...ids];
|
||||||
|
} else {
|
||||||
|
// unSelected
|
||||||
|
tableSelectedKeys.value = [];
|
||||||
}
|
}
|
||||||
tableSelectedKeys.value = arr;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
|
@ -48,12 +48,12 @@ const hasRightChecked = ref(false);
|
|||||||
|
|
||||||
const allLeftChange = (isChecked: boolean) => {
|
const allLeftChange = (isChecked: boolean) => {
|
||||||
if (isChecked) {
|
if (isChecked) {
|
||||||
const ids = leftDataSource.value.map((item: any) => {
|
const datasources = leftDataSource.value.filter((item: any) => {
|
||||||
if(!item.disabled) {
|
return !item.disabled
|
||||||
return item[props.id];
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
leftSelectedKeys.value = ids;
|
const ids = datasources.map((item) => {return item[props.id]});
|
||||||
|
console.log(JSON.stringify(ids))
|
||||||
|
leftSelectedKeys.value = [...ids];
|
||||||
} else {
|
} else {
|
||||||
leftSelectedKeys.value = [];
|
leftSelectedKeys.value = [];
|
||||||
}
|
}
|
||||||
@ -81,12 +81,12 @@ watch(
|
|||||||
|
|
||||||
const allRightChange = (checked: any) => {
|
const allRightChange = (checked: any) => {
|
||||||
if (checked) {
|
if (checked) {
|
||||||
const ids = rightDataSource.value.map((item: any) => {
|
const datasources = rightDataSource.value.filter((item: any) => {
|
||||||
if(!item.disabled) {
|
return !item.disabled
|
||||||
return item[props.id];
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
rightSelectedKeys.value = ids;
|
const ids = datasources.map((item) => { return item[props.id]})
|
||||||
|
console.log(JSON.stringify(ids))
|
||||||
|
rightSelectedKeys.value = [...ids];
|
||||||
} else {
|
} else {
|
||||||
rightSelectedKeys.value = [];
|
rightSelectedKeys.value = [];
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user