feat:【antd】【erp 系统】purchase/return 重构 1/4

This commit is contained in:
YunaiV
2025-10-04 21:04:30 +08:00
parent 655b3d87c0
commit 1350342715

View File

@@ -19,53 +19,55 @@ import {
import { $t } from '#/locales'; import { $t } from '#/locales';
import { useGridColumns, useGridFormSchema } from './data'; import { useGridColumns, useGridFormSchema } from './data';
import PurchaseInForm from './modules/purchase-return-form.vue'; import Form from './modules/form.vue';
/** ERP 采购入库列表 */ /** ERP 采购退货列表 */
defineOptions({ name: 'ErpPurchaseIn' }); defineOptions({ name: 'ErpPurchaseReturn' });
const [FormModal, formModalApi] = useVbenModal({ const [FormModal, formModalApi] = useVbenModal({
connectedComponent: PurchaseInForm, connectedComponent: Form,
destroyOnClose: true, destroyOnClose: true,
}); });
/** 刷新表格 */ /** 刷新表格 */
function onRefresh() { function handleRefresh() {
gridApi.query(); gridApi.query();
} }
// TODO @Xuzhiqiang批量删除待实现
const checkedIds = ref<number[]>([]); const checkedIds = ref<number[]>([]);
function handleRowCheckboxChange({
/** 详情 */ records,
function handleDetail(row: ErpPurchaseReturnApi.PurchaseReturn) { }: {
formModalApi.setData({ type: 'detail', id: row.id }).open(); records: ErpPurchaseReturnApi.PurchaseReturn[];
}) {
checkedIds.value = records.map((item) => item.id!);
} }
/** 新增 */ /** 新增采购退货 */
function handleCreate() { function handleCreate() {
formModalApi.setData({ type: 'create' }).open(); formModalApi.setData({ type: 'create' }).open();
} }
/** 编辑 */ /** 编辑采购退货 */
function handleEdit(row: ErpPurchaseReturnApi.PurchaseReturn) { function handleEdit(row: ErpPurchaseReturnApi.PurchaseReturn) {
formModalApi.setData({ type: 'edit', id: row.id }).open(); formModalApi.setData({ type: 'edit', id: row.id }).open();
} }
/** 删除 */ /** 查看详情 */
function handleDetail(row: ErpPurchaseReturnApi.PurchaseReturn) {
formModalApi.setData({ type: 'detail', id: row.id }).open();
}
/** 删除采购退货 */
async function handleDelete(ids: number[]) { async function handleDelete(ids: number[]) {
const hideLoading = message.loading({ const hideLoading = message.loading({
content: $t('ui.actionMessage.deleting'), content: $t('ui.actionMessage.deleting'),
duration: 0, duration: 0,
key: 'action_process_msg',
}); });
try { try {
await deletePurchaseReturn(ids); await deletePurchaseReturn(ids);
message.success({ message.success($t('ui.actionMessage.deleteSuccess'));
content: $t('ui.actionMessage.deleteSuccess'), handleRefresh();
key: 'action_process_msg',
});
onRefresh();
} finally { } finally {
hideLoading(); hideLoading();
} }
@@ -79,21 +81,17 @@ async function handleUpdateStatus(
const hideLoading = message.loading({ const hideLoading = message.loading({
content: `确定${status === 20 ? '审批' : '反审批'}该订单吗?`, content: `确定${status === 20 ? '审批' : '反审批'}该订单吗?`,
duration: 0, duration: 0,
key: 'action_process_msg',
}); });
try { try {
await updatePurchaseReturnStatus({ id: row.id!, status }); await updatePurchaseReturnStatus(row.id!, status);
message.success({ message.success(`${status === 20 ? '审批' : '反审批'}成功`);
content: `${status === 20 ? '审批' : '反审批'}成功`, handleRefresh();
key: 'action_process_msg',
});
onRefresh();
} finally { } finally {
hideLoading(); hideLoading();
} }
} }
/** 导出 */ /** 导出表格 */
async function handleExport() { async function handleExport() {
const data = await exportPurchaseReturn(await gridApi.formApi.getValues()); const data = await exportPurchaseReturn(await gridApi.formApi.getValues());
downloadFileFromBlobPart({ fileName: '采购退货.xls', source: data }); downloadFileFromBlobPart({ fileName: '采购退货.xls', source: data });
@@ -127,6 +125,10 @@ const [Grid, gridApi] = useVbenVxeGrid({
search: true, search: true,
}, },
} as VxeTableGridOptions<ErpPurchaseReturnApi.PurchaseReturn>, } as VxeTableGridOptions<ErpPurchaseReturnApi.PurchaseReturn>,
gridEvents: {
checkboxAll: handleRowCheckboxChange,
checkboxChange: handleRowCheckboxChange,
},
}); });
</script> </script>
@@ -138,7 +140,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
url="https://doc.iocoder.cn/erp/purchase/" url="https://doc.iocoder.cn/erp/purchase/"
/> />
</template> </template>
<FormModal @success="onRefresh" /> <FormModal @success="handleRefresh" />
<Grid table-title="采购退货列表"> <Grid table-title="采购退货列表">
<template #toolbar-tools> <template #toolbar-tools>
@@ -167,14 +169,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
auth: ['erp:purchase-return:delete'], auth: ['erp:purchase-return:delete'],
popConfirm: { popConfirm: {
title: `是否删除所选中数据?`, title: `是否删除所选中数据?`,
confirm: () => { confirm: handleDelete.bind(null, checkedIds),
const checkboxRecords = gridApi.grid.getCheckboxRecords();
if (checkboxRecords.length === 0) {
message.warning('请选择要删除的数据');
return;
}
handleDelete(checkboxRecords.map((item) => item.id!));
},
}, },
}, },
]" ]"