From 75242bbba28ae8902ddf86d33febb497d79e5fc3 Mon Sep 17 00:00:00 2001
From: gaoluyang <2820782392@qq.com>
Date: 星期一, 03 八月 2026 10:45:27 +0800
Subject: [PATCH] 银川 1.首页修改 2.ai辅助功能
---
src/views/crm/saleQuotation/modules/form.vue | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++----
1 files changed, 52 insertions(+), 4 deletions(-)
diff --git a/src/views/crm/saleQuotation/modules/form.vue b/src/views/crm/saleQuotation/modules/form.vue
index 8fa938f..a52beb5 100644
--- a/src/views/crm/saleQuotation/modules/form.vue
+++ b/src/views/crm/saleQuotation/modules/form.vue
@@ -1,4 +1,5 @@
<script lang="ts" setup>
+import type { CrmSaleQuotationAiApi } from '#/api/crm/saleQuotation/ai';
import type { CrmSaleQuotationApi } from '#/api/crm/saleQuotation';
import { computed, ref, watch } from 'vue';
@@ -6,7 +7,7 @@
import { useVbenModal } from '#/packages/effects/common-ui/src';
import { erpPriceMultiply } from '#/packages/utils/src';
-import { message } from 'ant-design-vue';
+import { message, Alert } from 'ant-design-vue';
import { useVbenForm } from '#/adapter/form';
import {
@@ -22,6 +23,7 @@
const emit = defineEmits(['success']);
const formData = ref<CrmSaleQuotationApi.SaleQuotation>();
const itemFormRef = ref();
+const ocrCustomerName = ref('');
const getTitle = computed(() => {
return formData.value?.id
@@ -85,14 +87,52 @@
async onOpenChange(isOpen: boolean) {
if (!isOpen) {
formData.value = undefined;
+ ocrCustomerName.value = '';
return;
}
- const data = modalApi.getData<CrmSaleQuotationApi.SaleQuotation>();
+ const data = modalApi.getData<CrmSaleQuotationApi.SaleQuotation & { ocrData?: CrmSaleQuotationAiApi.OcrResultVO }>();
if (!data || !data.id) {
formData.value = {} as CrmSaleQuotationApi.SaleQuotation;
await formApi.resetForm();
- // 鏂板鏃讹紝閲嶇疆骞舵坊鍔犱竴琛岀┖鏁版嵁
- itemFormRef.value?.resetData();
+ // OCR 璇嗗埆鏁版嵁棰勫~
+ if (data?.ocrData) {
+ const ocr = data.ocrData;
+ await formApi.setValues({
+ name: ocr.name,
+ quotationTime: ocr.quotationTime,
+ validUntil: ocr.validUntil,
+ taxRate: ocr.taxRate,
+ discountPercent: ocr.discountPercent,
+ remark: ocr.remark,
+ });
+ if (ocr.items?.length) {
+ itemFormRef.value?.setData(ocr.items.map((item) => ({
+ id: undefined as unknown as number,
+ itemId: undefined as unknown as number,
+ itemName: item.itemName || '',
+ itemCode: '',
+ itemBarCode: undefined,
+ itemSpecification: item.itemSpec || '',
+ itemUnitName: '',
+ itemUnitName2: undefined,
+ itemUnitName3: undefined,
+ itemPrice: undefined as unknown as number,
+ quotationPrice: item.quotationPrice || 0,
+ count: item.count || 1,
+ totalPrice: erpPriceMultiply(item.quotationPrice || 0, item.count || 1) ?? 0,
+ taxPercent: undefined,
+ taxPrice: undefined,
+ remark: undefined,
+ })));
+ } else {
+ itemFormRef.value?.resetData();
+ }
+ // 瀛樺偍 OCR 璇嗗埆鐨勫鎴峰悕绉帮紝鐢ㄤ簬鐣岄潰鎻愮ず
+ ocrCustomerName.value = ocr.customerName || '';
+ } else {
+ // 鏂板鏃讹紝閲嶇疆骞舵坊鍔犱竴琛岀┖鏁版嵁
+ itemFormRef.value?.resetData();
+ }
return;
}
modalApi.lock();
@@ -110,6 +150,14 @@
<template>
<Modal :title="getTitle" class="w-[80%]">
+ <Alert
+ v-if="ocrCustomerName"
+ type="info"
+ show-icon
+ class="mx-4 mb-4"
+ message="AI 璇嗗埆鍒板鎴峰悕绉帮紝璇峰湪瀹㈡埛閫夋嫨鍣ㄤ腑鎵嬪姩鍖归厤 CRM 瀹㈡埛"
+ :description="`璇嗗埆缁撴灉锛�${ocrCustomerName}`"
+ />
<Form class="mx-4">
<template #items>
<ItemForm
--
Gitblit v1.9.3