From c77086ad2d7949ab36dd0c4e0b59907e672dd64f Mon Sep 17 00:00:00 2001
From: 云 <2163098428@qq.com>
Date: 星期五, 18 九月 2026 15:04:42 +0800
Subject: [PATCH] Merge remote-tracking branch 'refs/remotes/origin/dev_pro2.0' into dev_宁夏_九泓化工
---
src/views/erp/purchase/invoice/index.vue | 194 ++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 194 insertions(+), 0 deletions(-)
diff --git a/src/views/erp/purchase/invoice/index.vue b/src/views/erp/purchase/invoice/index.vue
new file mode 100644
index 0000000..2878f23
--- /dev/null
+++ b/src/views/erp/purchase/invoice/index.vue
@@ -0,0 +1,194 @@
+<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,
+} 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' });
+
+const [FormModal, formModalApi] = useVbenModal({
+ connectedComponent: Form,
+ destroyOnClose: true,
+});
+
+const ocrUploadRef = ref<InstanceType<typeof OcrUpload>>();
+
+/** 鍒锋柊琛ㄦ牸 */
+function handleRefresh() {
+ gridApi.query();
+}
+
+/** 瀵煎嚭琛ㄦ牸 */
+async function handleExport() {
+ const formValues = await gridApi.formApi.getValues();
+ const data = await exportPurchaseInvoice(formValues);
+ downloadFileFromBlobPart({ fileName: '鏉ョエ.xls', source: data });
+}
+
+/** 鍒涘缓鏉ョエ */
+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();
+ });
+}
+
+/** 缂栬緫鏉ョエ */
+function handleEdit(row: ErpPurchaseInvoiceApi.PurchaseInvoice) {
+ formModalApi.setData({ formType: 'edit', id: row.id }).open();
+}
+
+/** 鏌ョ湅鏉ョエ璇︽儏 */
+function handleDetail(row: ErpPurchaseInvoiceApi.PurchaseInvoice) {
+ formModalApi.setData({ formType: 'detail', id: row.id }).open();
+}
+
+/** 鍒犻櫎鏉ョエ */
+async function handleDelete(row: ErpPurchaseInvoiceApi.PurchaseInvoice) {
+ const hideLoading = message.loading({
+ content: $t('ui.actionMessage.deleting', [row.no]),
+ duration: 0,
+ });
+ try {
+ await deletePurchaseInvoice(row.id!);
+ message.success($t('ui.actionMessage.deleteSuccess', [row.no]));
+ handleRefresh();
+ } finally {
+ hideLoading();
+ }
+}
+
+const [Grid, gridApi] = useVbenVxeGrid({
+ formOptions: {
+ schema: useGridFormSchema(),
+ },
+ gridOptions: {
+ columns: useGridColumns(),
+ height: 'auto',
+ keepSource: true,
+ proxyConfig: {
+ ajax: {
+ query: async ({ page }, formValues) => {
+ return await getPurchaseInvoicePage({
+ pageNo: page.currentPage,
+ pageSize: page.pageSize,
+ ...formValues,
+ });
+ },
+ },
+ },
+ rowConfig: {
+ keyField: 'id',
+ isHover: true,
+ },
+ toolbarConfig: {
+ refresh: true,
+ search: true,
+ },
+ } as VxeTableGridOptions<ErpPurchaseInvoiceApi.PurchaseInvoice>,
+});
+</script>
+
+<template>
+ <Page auto-content-height>
+ <FormModal @success="handleRefresh" />
+ <OcrUpload ref="ocrUploadRef" @success="handleOcrSuccess" />
+ <Grid table-title="鏉ョエ鍒楄〃">
+ <template #toolbar-tools>
+ <TableAction
+ :actions="[
+ {
+ label: $t('ui.actionTitle.create', ['鏉ョエ']),
+ type: 'primary',
+ 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'),
+ type: 'primary',
+ icon: ACTION_ICON.DOWNLOAD,
+ auth: ['erp:purchase-invoice:export'],
+ onClick: handleExport,
+ },
+ ]"
+ />
+ </template>
+ <template #no="{ row }">
+ <Button type="link" @click="handleDetail(row)">
+ {{ row.no }}
+ </Button>
+ </template>
+ <template #orderNo="{ row }">
+ <span>{{ row.order?.no ?? '--' }}</span>
+ </template>
+ <template #attachment="{ row }">
+ <Tag v-if="!row.hasAttachment" color="warning">鏈笂浼�</Tag>
+ <Tag v-else color="success">宸蹭笂浼�</Tag>
+ </template>
+ <template #actions="{ row }">
+ <TableAction
+ :actions="[
+ {
+ label: $t('common.detail'),
+ type: 'link',
+ icon: ACTION_ICON.VIEW,
+ auth: ['erp:purchase-invoice:query'],
+ onClick: handleDetail.bind(null, row),
+ },
+ {
+ label: $t('common.edit'),
+ type: 'link',
+ icon: ACTION_ICON.EDIT,
+ auth: ['erp:purchase-invoice:update'],
+ onClick: handleEdit.bind(null, row),
+ },
+ {
+ label: $t('common.delete'),
+ type: 'link',
+ danger: true,
+ icon: ACTION_ICON.DELETE,
+ auth: ['erp:purchase-invoice:delete'],
+ popConfirm: {
+ title: $t('ui.actionMessage.deleteConfirm', [row.no]),
+ confirm: handleDelete.bind(null, row),
+ },
+ },
+ ]"
+ />
+ </template>
+ </Grid>
+ </Page>
+</template>
--
Gitblit v1.9.3