关键代码:
const [selectedKeys, setSelectedKeys] = useState([]);
const [selectRows, setSelectRows] = useState([]);
const [selectedSingleRows, setSelectedSingleRows] = useState([]); //单条编辑
const rowSelection = {
// type: ‘checkbox’,
selectedRowKeys: selectedKeys,
onChange: (selectedRowKeys, selectedRows) => {
selectedRows = selectedRows.map(String);
console.log(“RowKeys”,selectedRows);
// setSelectedRows(selectedRows);
setSelectedKeys(selectedRowKeys);
setSelectRows(selectedRows);
},
// onSelect(selectedRows) {
// setSelectRows(selectedRows);
// },
// onSelectAll(selectedRows) {
// setSelectRows(selectedRows);
// }
// getCheckboxProps: (record) => ({
// checked: (selectedRows.indexOf(record.id)>-1?true:false)
// }),
};
const onFinish = (values) => {
console.log(‘Success:’, values);
console.log(‘ids’,selectRows);
batchEdit({ ids:modalTitle==’批量编辑’?selectedKeys:selectedSingleRows,checkState:values.checkState,extendCheck:values.extendCheck}).then((res) => {
if (res.data.code !== 200) {
message.error(res.data.msg);
} else {
search();
setBatchEditVisible(false);
setSelectRows([])
setSelectedKeys([])
}
});
};
原创文章,作者:kepupublish,如若转载,请注明出处:https://blog.ytso.com/tech/pnotes/277460.html