mirror of
https://github.com/vbenjs/vue-vben-admin.git
synced 2025-01-25 02:58:43 +08:00
Co-authored-by: luojingzhou <luojingzhou@kezaihui.com>
This commit is contained in:
parent
f32d2715ef
commit
5335ae7578
@ -44,7 +44,8 @@
|
||||
rowSelection: {
|
||||
type: 'checkbox',
|
||||
selectedRowKeys: checkedKeys,
|
||||
onChange: onSelectChange,
|
||||
onSelect: onSelect,
|
||||
onSelectAll: onSelectAll,
|
||||
},
|
||||
});
|
||||
|
||||
@ -52,16 +53,30 @@
|
||||
console.log(getForm().getFieldsValue());
|
||||
}
|
||||
|
||||
function onSelectChange(selectedRowKeys: (string | number)[]) {
|
||||
console.log(selectedRowKeys);
|
||||
checkedKeys.value = selectedRowKeys;
|
||||
function onSelect(record, selected) {
|
||||
if (selected) {
|
||||
checkedKeys.value = [...checkedKeys.value, record.id];
|
||||
} else {
|
||||
checkedKeys.value = checkedKeys.value.filter((id) => id !== record.id);
|
||||
}
|
||||
}
|
||||
function onSelectAll(selected, selectedRows, changeRows) {
|
||||
const changeIds = changeRows.map((item) => item.id);
|
||||
if (selected) {
|
||||
checkedKeys.value = [...checkedKeys.value, ...changeIds];
|
||||
} else {
|
||||
checkedKeys.value = checkedKeys.value.filter((id) => {
|
||||
return !changeIds.includes(id);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
registerTable,
|
||||
getFormValues,
|
||||
checkedKeys,
|
||||
onSelectChange,
|
||||
onSelect,
|
||||
onSelectAll,
|
||||
};
|
||||
},
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user