perf: 【ANTD】优化一些 todo 提到的问题

This commit is contained in:
puhui999
2025-05-20 15:08:54 +08:00
parent 074eb0e83d
commit 98a742895d
20 changed files with 87 additions and 101 deletions

View File

@@ -5,7 +5,7 @@ import type {
} from '#/adapter/vxe-table';
import type { Demo03StudentApi } from '#/api/infra/demo/demo03/inner';
import { computed, h, ref } from 'vue';
import { h, ref } from 'vue';
import { Page, useVbenModal } from '@vben/common-ui';
import { Download, Plus, Trash2 } from '@vben/icons';
@@ -66,15 +66,6 @@ async function onDelete(row: Demo03StudentApi.Demo03Student) {
}
}
const deleteIds = ref<number[]>([]); // 待删除学生 ID
const showDeleteBatchBtn = computed(() => isEmpty(deleteIds.value));
function setDeleteIds({
records,
}: {
records: Demo03StudentApi.Demo03Student[];
}) {
deleteIds.value = records.map((item) => item.id);
}
/** 批量删除学生 */
async function onDeleteBatch() {
const hideLoading = message.loading({
@@ -91,6 +82,15 @@ async function onDeleteBatch() {
}
}
const deleteIds = ref<number[]>([]); // 待删除学生 ID
function setDeleteIds({
records,
}: {
records: Demo03StudentApi.Demo03Student[];
}) {
deleteIds.value = records.map((item) => item.id);
}
/** 导出表格 */
async function onExport() {
const data = await exportDemo03Student(await gridApi.formApi.getValues());
@@ -190,7 +190,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
type="primary"
danger
class="ml-2"
:disabled="showDeleteBatchBtn"
:disabled="isEmpty(deleteIds)"
@click="onDeleteBatch"
v-access:code="['infra:demo03-student:delete']"
>