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/erp';
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';
@@ -67,8 +67,6 @@ async function onDelete(row: Demo03StudentApi.Demo03Student) {
}
}
const deleteIds = ref<number[]>([]); // 待删除学生 ID
const showDeleteBatchBtn = computed(() => isEmpty(deleteIds.value));
/** 批量删除学生 */
async function onDeleteBatch() {
const hideLoading = message.loading({
@@ -85,6 +83,15 @@ async function onDeleteBatch() {
}
}
const deleteIds = ref<number[]>([]); // 待删除学生 ID
function setDeleteIds({
records,
}: {
records: Demo03StudentApi.Demo03Grade[];
}) {
deleteIds.value = records.map((item) => item.id);
}
/** 导出表格 */
async function onExport() {
const data = await exportDemo03Student(await gridApi.formApi.getValues());
@@ -143,20 +150,8 @@ const [Grid, gridApi] = useVbenVxeGrid({
cellClick: ({ row }: { row: Demo03StudentApi.Demo03Student }) => {
selectDemo03Student.value = row;
},
checkboxAll: ({
records,
}: {
records: Demo03StudentApi.Demo03Student[];
}) => {
deleteIds.value = records.map((item) => item.id);
},
checkboxChange: ({
records,
}: {
records: Demo03StudentApi.Demo03Student[];
}) => {
deleteIds.value = records.map((item) => item.id);
},
checkboxAll: setDeleteIds,
checkboxChange: setDeleteIds,
},
});
</script>
@@ -190,7 +185,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']"
>