1、在表格組件中需要進行批量刪除
2、首先我們需要傳回的參數為所選中的id數組,
在刪除事件綁定相應的方法,在方法中我們要實現的是將選中刪除的數據的id傳回到后台中去,而接口中的id會在selectedRows中
所有我們將這里的selectedRows更新selectedRows中,當然在初始的state我們定義為空
3、回到刪除方法中
handleDeleteOk = () => {
confirm({
title: '確認要刪除嗎',
onOk() {
const idList = [];
//將選中的數據中的id循環到我們自己定義的idList中
this.state.selectedRows.forEach(item => {
const id = item.registrationId;
//push到idList中
idList.push(id);
});
const { dispatch } = this.props;
dispatch({
type: 'recycleBin/batchRemove',
payload: {
registrationIdList: idList,
},
}).then(() => {
this.getPageList();
});
},
onCancel() {},
});
};
4、OK
————————————————
版權聲明:本文為CSDN博主「WebViewSuper」的原創文章,遵循 CC 4.0 BY-SA 版權協議,轉載請附上原文出處鏈接及本聲明。
原文鏈接:https://blog.csdn.net/weixin_45416217/java/article/details/103767455
