| | |
| | | <script lang="ts" setup> |
| | | import type { VxeTableGridOptions } from '#/adapter/vxe-table'; |
| | | import type { ErpPurchaseInvoiceApi } from '#/api/erp/purchase/invoice'; |
| | | import type { ErpPurchaseInvoiceAiApi } from '#/api/erp/purchase/invoice/ai'; |
| | | |
| | | import { Page, useVbenModal } from '@vben/common-ui'; |
| | | import { downloadFileFromBlobPart } from '@vben/utils'; |
| | | |
| | | import { Button, message, Tag } from 'ant-design-vue'; |
| | | import { nextTick, ref } from 'vue'; |
| | | |
| | | import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table'; |
| | | import { |
| | | deletePurchaseInvoice, |
| | | exportPurchaseInvoice, |
| | | getPurchaseInvoicePage, |
| | | updatePurchaseInvoiceStatus, |
| | | } from '#/api/erp/purchase/invoice'; |
| | | import { $t } from '#/locales'; |
| | | |
| | | import { useGridColumns, useGridFormSchema } from './data'; |
| | | import Form from './modules/form.vue'; |
| | | import OcrUpload from './modules/ocr-upload.vue'; |
| | | |
| | | defineOptions({ name: 'ErpPurchaseInvoice' }); |
| | | |
| | |
| | | connectedComponent: Form, |
| | | destroyOnClose: true, |
| | | }); |
| | | |
| | | const ocrUploadRef = ref<InstanceType<typeof OcrUpload>>(); |
| | | |
| | | /** 刷新表格 */ |
| | | function handleRefresh() { |
| | |
| | | /** 创建来票 */ |
| | | function handleCreate() { |
| | | formModalApi.setData({ formType: 'create' }).open(); |
| | | } |
| | | |
| | | /** 识别录入 */ |
| | | function handleOcrCreate() { |
| | | ocrUploadRef.value?.open(); |
| | | } |
| | | |
| | | /** OCR 识别结果确认 */ |
| | | function handleOcrSuccess(data: ErpPurchaseInvoiceAiApi.OcrResultVO) { |
| | | nextTick(() => { |
| | | formModalApi.setData({ formType: 'create', ocrData: data } as any).open(); |
| | | }); |
| | | } |
| | | |
| | | /** 编辑来票 */ |
| | |
| | | try { |
| | | await deletePurchaseInvoice(row.id!); |
| | | message.success($t('ui.actionMessage.deleteSuccess', [row.no])); |
| | | handleRefresh(); |
| | | } finally { |
| | | hideLoading(); |
| | | } |
| | | } |
| | | |
| | | /** 更新来票状态(审核/反审核) */ |
| | | async function handleUpdateStatus( |
| | | row: ErpPurchaseInvoiceApi.PurchaseInvoice, |
| | | status: number, |
| | | ) { |
| | | const hideLoading = message.loading({ |
| | | content: '更新状态中...', |
| | | duration: 0, |
| | | }); |
| | | try { |
| | | await updatePurchaseInvoiceStatus(row.id!, status); |
| | | message.success('更新状态成功'); |
| | | handleRefresh(); |
| | | } finally { |
| | | hideLoading(); |
| | |
| | | <template> |
| | | <Page auto-content-height> |
| | | <FormModal @success="handleRefresh" /> |
| | | <OcrUpload ref="ocrUploadRef" @success="handleOcrSuccess" /> |
| | | <Grid table-title="来票列表"> |
| | | <template #toolbar-tools> |
| | | <TableAction |
| | |
| | | icon: ACTION_ICON.ADD, |
| | | auth: ['erp:purchase-invoice:create'], |
| | | onClick: handleCreate, |
| | | }, |
| | | { |
| | | label: '识别录入', |
| | | type: 'primary', |
| | | auth: ['erp:purchase-invoice:create'], |
| | | onClick: handleOcrCreate, |
| | | }, |
| | | { |
| | | label: $t('ui.actionTitle.export'), |
| | |
| | | <Tag v-if="!row.hasAttachment" color="warning">未上传</Tag> |
| | | <Tag v-else color="success">已上传</Tag> |
| | | </template> |
| | | <template #auditStatus="{ row }"> |
| | | <Tag v-if="row.auditStatus === 10" color="warning">未审核</Tag> |
| | | <Tag v-else-if="row.auditStatus === 20" color="success">已审核</Tag> |
| | | <Tag v-else color="default">--</Tag> |
| | | </template> |
| | | <template #actions="{ row }"> |
| | | <TableAction |
| | | :actions="[ |
| | |
| | | type: 'link', |
| | | icon: ACTION_ICON.EDIT, |
| | | auth: ['erp:purchase-invoice:update'], |
| | | ifShow: row.auditStatus === 10, |
| | | onClick: handleEdit.bind(null, row), |
| | | }, |
| | | { |
| | | label: '审核', |
| | | type: 'link', |
| | | icon: ACTION_ICON.AUDIT, |
| | | auth: ['erp:purchase-invoice:update-status'], |
| | | ifShow: row.auditStatus === 10, |
| | | onClick: handleUpdateStatus.bind(null, row, 20), |
| | | }, |
| | | { |
| | | label: '反审核', |
| | | type: 'link', |
| | | icon: ACTION_ICON.VIEW, |
| | | auth: ['erp:purchase-invoice:update-status'], |
| | | ifShow: row.auditStatus === 20, |
| | | onClick: handleUpdateStatus.bind(null, row, 10), |
| | | }, |
| | | { |
| | | label: $t('common.delete'), |
| | |
| | | danger: true, |
| | | icon: ACTION_ICON.DELETE, |
| | | auth: ['erp:purchase-invoice:delete'], |
| | | ifShow: row.auditStatus !== 20, |
| | | popConfirm: { |
| | | title: $t('ui.actionMessage.deleteConfirm', [row.no]), |
| | | confirm: handleDelete.bind(null, row), |