fix: 🐛 增删改查组件删除之后清空table表格的选中状态

增删改查组件删除之后清空table表格的选中状态#IAWJGG
This commit is contained in:
胡少翔
2024-10-15 13:35:52 +08:00
parent 6a0341323c
commit 4937f82d0f

View File

@@ -151,6 +151,7 @@
</div> </div>
<!-- 列表 --> <!-- 列表 -->
<el-table <el-table
ref="tableRef"
v-loading="loading" v-loading="loading"
v-bind="contentConfig.table" v-bind="contentConfig.table"
:data="pageData" :data="pageData"
@@ -497,6 +498,7 @@ import {
type UploadInstance, type UploadInstance,
type UploadRawFile, type UploadRawFile,
type UploadUserFile, type UploadUserFile,
type TableInstance,
} from "element-plus"; } from "element-plus";
import ExcelJS from "exceljs"; import ExcelJS from "exceljs";
import { reactive, ref } from "vue"; import { reactive, ref } from "vue";
@@ -577,6 +579,8 @@ const request = props.contentConfig.request ?? {
limitName: "pageSize", limitName: "pageSize",
}; };
const tableRef = ref<TableInstance>();
// 行选中 // 行选中
const selectionData = ref<IObject[]>([]); const selectionData = ref<IObject[]>([]);
// 删除ID集合 用于批量删除 // 删除ID集合 用于批量删除
@@ -607,6 +611,9 @@ function handleDelete(id?: number | string) {
if (props.contentConfig.deleteAction) { if (props.contentConfig.deleteAction) {
props.contentConfig.deleteAction(ids).then(() => { props.contentConfig.deleteAction(ids).then(() => {
ElMessage.success("删除成功"); ElMessage.success("删除成功");
removeIds.value = [];
//清空选中项
tableRef.value?.clearSelection();
handleRefresh(true); handleRefresh(true);
}); });
} else { } else {