<script lang="ts" setup>
|
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
import type { ErpFinancePaymentApi } from '#/api/erp/finance/payment';
|
|
import { ref } from 'vue';
|
import { useRouter } from 'vue-router';
|
|
import { Page, useVbenModal } from '@vben/common-ui';
|
import { downloadFileFromBlobPart, isEmpty } from '@vben/utils';
|
|
import { message } from 'ant-design-vue';
|
|
import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
|
import {
|
deleteFinancePayment,
|
exportFinancePayment,
|
getFinancePaymentApproveProcessList,
|
getFinancePaymentPage,
|
} from '#/api/erp/finance/payment';
|
import { $t } from '#/locales';
|
|
import { useGridColumns, useGridFormSchema } from './data';
|
import Form from './modules/form.vue';
|
import ProcessSelectModal from './modules/process-select-modal.vue';
|
|
/** ERP 付款单列表 */
|
defineOptions({ name: 'ErpFinancePayment' });
|
|
const router = useRouter();
|
|
const [FormModal, formModalApi] = useVbenModal({
|
connectedComponent: Form,
|
destroyOnClose: true,
|
});
|
|
const [ProcessModal, processModalApi] = useVbenModal({
|
connectedComponent: ProcessSelectModal,
|
destroyOnClose: true,
|
});
|
|
/** 刷新表格 */
|
function handleRefresh() {
|
gridApi.query();
|
}
|
|
/** 导出表格 */
|
async function handleExport() {
|
const data = await exportFinancePayment(await gridApi.formApi.getValues());
|
downloadFileFromBlobPart({ fileName: '付款单.xls', source: data });
|
}
|
|
/** 新增付款单 */
|
function handleCreate() {
|
formModalApi.setData({ formType: 'create' }).open();
|
}
|
|
/** 编辑付款单 */
|
function handleEdit(row: ErpFinancePaymentApi.FinancePayment) {
|
formModalApi.setData({ formType: 'edit', id: row.id }).open();
|
}
|
|
/** 删除付款单 */
|
async function handleDelete(ids: number[]) {
|
const hideLoading = message.loading({
|
content: $t('ui.actionMessage.deleting'),
|
duration: 0,
|
});
|
try {
|
await deleteFinancePayment(ids);
|
message.success($t('ui.actionMessage.deleteSuccess'));
|
handleRefresh();
|
} finally {
|
hideLoading();
|
}
|
}
|
|
/** 提交审批 - 先获取流程列表 */
|
async function handleSubmit(row: ErpFinancePaymentApi.FinancePayment) {
|
const hideLoading = message.loading({
|
content: '获取审批流程...',
|
duration: 0,
|
});
|
try {
|
const processList = await getFinancePaymentApproveProcessList();
|
hideLoading();
|
if (!processList || processList.length === 0) {
|
message.warning('暂无可用审批流程,请先配置 BPM 流程');
|
return;
|
}
|
// 打开流程选择弹窗
|
processModalApi.setData({ id: row.id, processList }).open();
|
} catch {
|
hideLoading();
|
}
|
}
|
|
/** 查看审批详情 */
|
function handleProcessDetail(row: ErpFinancePaymentApi.FinancePayment) {
|
if (!row.processInstanceId) {
|
message.warning('该付款单尚未提交审批');
|
return;
|
}
|
router.push({
|
name: 'BpmProcessInstanceDetail',
|
query: { id: row.processInstanceId },
|
});
|
}
|
|
const checkedIds = ref<number[]>([]);
|
function handleRowCheckboxChange({
|
records,
|
}: {
|
records: ErpFinancePaymentApi.FinancePayment[];
|
}) {
|
checkedIds.value = records.map((item) => item.id!);
|
}
|
|
/** 查看详情 */
|
function handleDetail(row: ErpFinancePaymentApi.FinancePayment) {
|
formModalApi.setData({ formType: 'detail', id: row.id }).open();
|
}
|
|
const [Grid, gridApi] = useVbenVxeGrid({
|
formOptions: {
|
schema: useGridFormSchema(),
|
},
|
gridOptions: {
|
columns: useGridColumns(),
|
height: 'auto',
|
keepSource: true,
|
proxyConfig: {
|
ajax: {
|
query: async ({ page }, formValues) => {
|
return await getFinancePaymentPage({
|
pageNo: page.currentPage,
|
pageSize: page.pageSize,
|
...formValues,
|
});
|
},
|
},
|
},
|
rowConfig: {
|
keyField: 'id',
|
isHover: true,
|
},
|
toolbarConfig: {
|
refresh: true,
|
search: true,
|
},
|
} as VxeTableGridOptions<ErpFinancePaymentApi.FinancePayment>,
|
gridEvents: {
|
checkboxAll: handleRowCheckboxChange,
|
checkboxChange: handleRowCheckboxChange,
|
},
|
});
|
</script>
|
|
<template>
|
<Page auto-content-height><FormModal @success="handleRefresh" />
|
<ProcessModal @success="handleRefresh" />
|
<Grid table-title="付款单列表">
|
<template #toolbar-tools>
|
<TableAction
|
:actions="[
|
{
|
label: $t('ui.actionTitle.create', ['付款单']),
|
type: 'primary',
|
icon: ACTION_ICON.ADD,
|
auth: ['erp:finance-payment:create'],
|
onClick: handleCreate,
|
},
|
{
|
label: $t('ui.actionTitle.export'),
|
type: 'primary',
|
icon: ACTION_ICON.DOWNLOAD,
|
auth: ['erp:finance-payment:export'],
|
onClick: handleExport,
|
},
|
{
|
label: '批量删除',
|
type: 'primary',
|
danger: true,
|
disabled: isEmpty(checkedIds),
|
icon: ACTION_ICON.DELETE,
|
auth: ['erp:finance-payment:delete'],
|
popConfirm: {
|
title: `是否删除所选中数据?`,
|
confirm: handleDelete.bind(null, checkedIds),
|
},
|
},
|
]"
|
/>
|
</template>
|
<template #invoice="{ row }">
|
<span v-if="row.invoice">
|
{{ row.invoice.no
|
}}{{ row.invoice.invoiceNo ? ` / ${row.invoice.invoiceNo}` : '' }}
|
</span>
|
<span v-else>--</span>
|
</template>
|
<template #actions="{ row }">
|
<TableAction
|
:actions="[
|
{
|
label: $t('common.detail'),
|
type: 'link',
|
icon: ACTION_ICON.VIEW,
|
auth: ['erp:finance-payment:query'],
|
onClick: handleDetail.bind(null, row),
|
},
|
{
|
label: $t('common.edit'),
|
type: 'link',
|
icon: ACTION_ICON.EDIT,
|
auth: ['erp:finance-payment:update'],
|
ifShow: () => row.status !== 20 && row.status !== 15,
|
onClick: handleEdit.bind(null, row),
|
},
|
{
|
label: '提交审核',
|
type: 'link',
|
icon: ACTION_ICON.AUDIT,
|
auth: ['erp:finance-payment:update'],
|
ifShow: () => row.status === 10,
|
onClick: handleSubmit.bind(null, row),
|
},
|
{
|
label: '查看审批',
|
type: 'link',
|
icon: ACTION_ICON.VIEW,
|
auth: ['erp:finance-payment:query'],
|
ifShow: () => row.status !== 10 && !!row.processInstanceId,
|
onClick: handleProcessDetail.bind(null, row),
|
},
|
{
|
label: $t('common.delete'),
|
type: 'link',
|
danger: true,
|
icon: ACTION_ICON.DELETE,
|
auth: ['erp:finance-payment:delete'],
|
ifShow: () => row.status !== 15,
|
popConfirm: {
|
title: $t('ui.actionMessage.deleteConfirm', [row.no]),
|
confirm: handleDelete.bind(null, [row.id!]),
|
},
|
},
|
]"
|
/>
|
</template>
|
</Grid>
|
</Page>
|
</template>
|