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: {
|
rowSelection: {
|
||||||
type: 'checkbox',
|
type: 'checkbox',
|
||||||
selectedRowKeys: checkedKeys,
|
selectedRowKeys: checkedKeys,
|
||||||
onChange: onSelectChange,
|
onSelect: onSelect,
|
||||||
|
onSelectAll: onSelectAll,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -52,16 +53,30 @@
|
|||||||
console.log(getForm().getFieldsValue());
|
console.log(getForm().getFieldsValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
function onSelectChange(selectedRowKeys: (string | number)[]) {
|
function onSelect(record, selected) {
|
||||||
console.log(selectedRowKeys);
|
if (selected) {
|
||||||
checkedKeys.value = selectedRowKeys;
|
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 {
|
return {
|
||||||
registerTable,
|
registerTable,
|
||||||
getFormValues,
|
getFormValues,
|
||||||
checkedKeys,
|
checkedKeys,
|
||||||
onSelectChange,
|
onSelect,
|
||||||
|
onSelectAll,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user