作者 dong

资料管理删除按钮

1 <template> 1 <template>
2 <div> 2 <div>
3 <!--引用表格--> 3 <!--引用表格-->
4 - <BasicTable @register="registerTable" :rowSelection="rowSelection" @change="handleTableChange"> 4 + <BasicTable @register="registerTable" :rowSelection="rowSelection">
5 <!--插槽:table标题--> 5 <!--插槽:table标题-->
6 <template #tableTitle> 6 <template #tableTitle>
7 <a-button type="primary" v-auth="'embeddings:embeddings:add'" @click="handleAdd" preIcon="ant-design:plus-outlined"> 新增</a-button> 7 <a-button type="primary" v-auth="'embeddings:embeddings:add'" @click="handleAdd" preIcon="ant-design:plus-outlined"> 新增</a-button>
@@ -162,7 +162,7 @@ @@ -162,7 +162,7 @@
162 success: handleSuccess, 162 success: handleSuccess,
163 }, 163 },
164 }); 164 });
165 - const [registerTable, { reload, setPagination }, { rowSelection, selectedRowKeys }] = tableContext; 165 + const [registerTable, { reload }, { rowSelection, selectedRowKeys }] = tableContext;
166 166
167 // 高级查询配置 167 // 高级查询配置
168 const superQueryConfig = reactive(superQuerySchema); 168 const superQueryConfig = reactive(superQuerySchema);
@@ -214,43 +214,14 @@ @@ -214,43 +214,14 @@
214 * 删除事件 214 * 删除事件
215 */ 215 */
216 async function handleDelete(record) { 216 async function handleDelete(record) {
217 - resetPaginationAfterDelete();  
218 await deleteOne({ id: record.id }, handleSuccess); 217 await deleteOne({ id: record.id }, handleSuccess);
219 } 218 }
220 /** 219 /**
221 * 批量删除事件 220 * 批量删除事件
222 */ 221 */
223 async function batchHandleDelete() { 222 async function batchHandleDelete() {
224 - resetPaginationAfterDelete();  
225 await batchDelete({ ids: selectedRowKeys.value }, handleSuccess); 223 await batchDelete({ ids: selectedRowKeys.value }, handleSuccess);
226 } 224 }
227 -  
228 - // 新增:删除操作后重置分页状态  
229 - function resetPaginationAfterDelete() {  
230 - // 获取当前分页状态  
231 - const currentPagination = pagination.value;  
232 -  
233 - // 计算删除后总页数  
234 - const totalPages = Math.ceil((currentPagination.total - 1) / currentPagination.pageSize);  
235 -  
236 - // 如果当前页码大于总页数,则回到最后一页  
237 - if (currentPagination.current > totalPages && totalPages > 0) {  
238 - pagination.value = {  
239 - ...currentPagination,  
240 - current: totalPages,  
241 - total: currentPagination.total - 1,  
242 - };  
243 - } else {  
244 - // 否则保持当前页,但更新总数  
245 - pagination.value = {  
246 - ...currentPagination,  
247 - total: currentPagination.total - 1,  
248 - };  
249 - }  
250 -  
251 - // 设置表格分页状态  
252 - setPagination(pagination.value);  
253 - }  
254 /** 225 /**
255 * 成功回调 226 * 成功回调
256 */ 227 */