From 0496b0e8078775203d51d62765766c5db3ebeb71 Mon Sep 17 00:00:00 2001
From: liu <2021943741@qq.com>
Date: 星期三, 26 八月 2026 09:42:06 +0800
Subject: [PATCH] feat(erp): 采购来票新增发票OCR识别录入功能

---
 src/views/erp/purchase/invoice/index.vue |   75 ++++++++++++-------------------------
 1 files changed, 24 insertions(+), 51 deletions(-)

diff --git a/src/views/erp/purchase/invoice/index.vue b/src/views/erp/purchase/invoice/index.vue
index 6c1dd21..2878f23 100644
--- a/src/views/erp/purchase/invoice/index.vue
+++ b/src/views/erp/purchase/invoice/index.vue
@@ -1,34 +1,34 @@
 <script lang="ts" setup>
 import type { VxeTableGridOptions } from '#/adapter/vxe-table';
 import type { ErpPurchaseInvoiceApi } from '#/api/erp/purchase/invoice';
-
-import { useRouter } from 'vue-router';
+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,
-  submitPurchaseInvoice,
 } 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 { push } = useRouter();
 
 const [FormModal, formModalApi] = useVbenModal({
   connectedComponent: Form,
   destroyOnClose: true,
 });
+
+const ocrUploadRef = ref<InstanceType<typeof OcrUpload>>();
 
 /** 鍒锋柊琛ㄦ牸 */
 function handleRefresh() {
@@ -45,6 +45,18 @@
 /** 鍒涘缓鏉ョエ */
 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();
+  });
 }
 
 /** 缂栬緫鏉ョエ */
@@ -70,29 +82,6 @@
   } finally {
     hideLoading();
   }
-}
-
-/** 鎻愪氦瀹℃牳 */
-async function handleSubmit(row: ErpPurchaseInvoiceApi.PurchaseInvoice) {
-  const hideLoading = message.loading({
-    content: '鎻愪氦瀹℃牳涓�...',
-    duration: 0,
-  });
-  try {
-    await submitPurchaseInvoice(row.id!);
-    message.success('鎻愪氦瀹℃牳鎴愬姛');
-    handleRefresh();
-  } finally {
-    hideLoading();
-  }
-}
-
-/** 鏌ョ湅瀹℃壒璇︽儏 */
-function handleProcessDetail(row: ErpPurchaseInvoiceApi.PurchaseInvoice) {
-  push({
-    name: 'BpmProcessInstanceDetail',
-    query: { id: row.processInstanceId },
-  });
 }
 
 const [Grid, gridApi] = useVbenVxeGrid({
@@ -129,6 +118,7 @@
 <template>
   <Page auto-content-height>
     <FormModal @success="handleRefresh" />
+    <OcrUpload ref="ocrUploadRef" @success="handleOcrSuccess" />
     <Grid table-title="鏉ョエ鍒楄〃">
       <template #toolbar-tools>
         <TableAction
@@ -139,6 +129,12 @@
               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'),
@@ -162,13 +158,6 @@
         <Tag v-if="!row.hasAttachment" color="warning">鏈笂浼�</Tag>
         <Tag v-else color="success">宸蹭笂浼�</Tag>
       </template>
-      <template #auditStatus="{ row }">
-        <Tag v-if="row.auditStatus === 0" color="default">鏈彁浜�</Tag>
-        <Tag v-else-if="row.auditStatus === 10" color="warning">瀹℃壒涓�</Tag>
-        <Tag v-else-if="row.auditStatus === 20" color="success">瀹℃牳閫氳繃</Tag>
-        <Tag v-else-if="row.auditStatus === 30" color="error">瀹℃牳涓嶉�氳繃</Tag>
-        <Tag v-else-if="row.auditStatus === 40" color="default">宸蹭綔搴�</Tag>
-      </template>
       <template #actions="{ row }">
         <TableAction
           :actions="[
@@ -184,22 +173,7 @@
               type: 'link',
               icon: ACTION_ICON.EDIT,
               auth: ['erp:purchase-invoice:update'],
-              ifShow: row.auditStatus === 0,
               onClick: handleEdit.bind(null, row),
-            },
-            {
-              label: '鎻愪氦瀹℃牳',
-              type: 'link',
-              auth: ['erp:purchase-invoice:update'],
-              onClick: handleSubmit.bind(null, row),
-              ifShow: row.auditStatus === 0,
-            },
-            {
-              label: '鏌ョ湅瀹℃壒',
-              type: 'link',
-              auth: ['erp:purchase-invoice:query'],
-              onClick: handleProcessDetail.bind(null, row),
-              ifShow: row.auditStatus !== 0 && !!row.processInstanceId,
             },
             {
               label: $t('common.delete'),
@@ -207,7 +181,6 @@
               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),

--
Gitblit v1.9.3