From 7b307741022678632e06bbed3c996a8ddd013759 Mon Sep 17 00:00:00 2001
From: gaoluyang <2820782392@qq.com>
Date: 星期二, 25 八月 2026 14:46:33 +0800
Subject: [PATCH] fix: MOM 1.采购来票登记时选好采购订单后提示可来票金额

---
 src/views/erp/purchase/invoice/modules/purchase-order-select.vue |    6 +++
 src/views/erp/finance/payment/data.ts                            |   12 ++----
 src/views/erp/purchase/invoice/modules/form.vue                  |    6 ++-
 src/views/erp/finance/payment/modules/form.vue                   |    6 +-
 src/views/erp/purchase/invoice/data.ts                           |   48 ++++++++++++++++++++----
 src/api/erp/purchase/order/index.ts                              |    1 
 6 files changed, 58 insertions(+), 21 deletions(-)

diff --git a/src/api/erp/purchase/order/index.ts b/src/api/erp/purchase/order/index.ts
index f28d66a..4508346 100644
--- a/src/api/erp/purchase/order/index.ts
+++ b/src/api/erp/purchase/order/index.ts
@@ -13,6 +13,7 @@
     totalCount?: number; // 鍚堣鏁伴噺
     totalPrice?: number; // 鍚堣閲戦锛屽崟浣嶏細鍏�
     totalProductPrice?: number; // 浜у搧閲戦锛屽崟浣嶏細鍏�
+    totalTaxPrice?: number; // 鍚堣绋庨锛屽崟浣嶏細鍏�
     discountPercent?: number; // 浼樻儬鐜囷紝鐧惧垎姣�
     discountPrice?: number; // 浼樻儬閲戦锛屽崟浣嶏細鍏�
     depositPrice?: number; // 瀹氶噾閲戦锛屽崟浣嶏細鍏�
diff --git a/src/views/erp/finance/payment/data.ts b/src/views/erp/finance/payment/data.ts
index 5e15d1e..2d40c12 100644
--- a/src/views/erp/finance/payment/data.ts
+++ b/src/views/erp/finance/payment/data.ts
@@ -152,18 +152,14 @@
       formItemClass: 'col-span-3',
     },
     {
-      fieldName: 'accountId',
+      fieldName: 'accountName',
       label: '浠樻璐︽埛',
-      component: 'ApiSelect',
+      component: 'Input',
+      rules: 'required',
       componentProps: {
-        placeholder: '璇烽�夋嫨浠樻璐︽埛',
+        placeholder: '璇疯緭鍏ヤ粯娆捐处鎴�',
         allowClear: true,
-        showSearch: true,
-        api: getAccountSimpleList,
-        labelField: 'name',
-        valueField: 'id',
       },
-      help: '浠樻璐︽埛鏁版嵁鏉ヨ嚜銆愯储鍔$鐞� 鈫� 缁撶畻璐︽埛銆戣彍鍗曠淮鎶ょ殑寮�鍚姸鎬佽处鎴凤紝鏃犻�夐」鏃惰鍏堝湪缁撶畻璐︽埛椤甸潰鏂板銆�',
     },
     {
       fieldName: 'totalPrice',
diff --git a/src/views/erp/finance/payment/modules/form.vue b/src/views/erp/finance/payment/modules/form.vue
index b7652ed..3a29e85 100644
--- a/src/views/erp/finance/payment/modules/form.vue
+++ b/src/views/erp/finance/payment/modules/form.vue
@@ -29,7 +29,7 @@
   id: undefined,
   no: '',
   supplierId: undefined,
-  accountId: undefined,
+  accountName: undefined,
   financeUserId: undefined,
   paymentTime: undefined,
   remark: '',
@@ -176,11 +176,11 @@
     formApi.setDisabled(formType.value === 'detail');
     formApi.updateSchema(useFormSchema(formType.value));
     if (!data || !data.id) {
-      // 鏂板鏃讹紝榛樿閫変腑璐︽埛
+      // 鏂板鏃讹紝榛樿濉叆榛樿缁撶畻璐︽埛鍚嶇О
       const accountList = await getAccountSimpleList();
       const defaultAccount = accountList.find((item) => item.defaultStatus);
       if (defaultAccount) {
-        await formApi.setValues({ accountId: defaultAccount.id });
+        await formApi.setValues({ accountName: defaultAccount.name });
       }
       return;
     }
diff --git a/src/views/erp/purchase/invoice/data.ts b/src/views/erp/purchase/invoice/data.ts
index a371839..018c084 100644
--- a/src/views/erp/purchase/invoice/data.ts
+++ b/src/views/erp/purchase/invoice/data.ts
@@ -1,7 +1,10 @@
+import type { Ref } from 'vue';
 import type { VbenFormSchema } from '#/adapter/form';
 import type { VxeTableGridOptions } from '#/adapter/vxe-table';
 
 import { getSupplierSimpleList } from '#/api/srm/supplier';
+
+import { z } from '#/adapter/form';
 
 import { markRaw } from 'vue';
 
@@ -11,7 +14,9 @@
 export type FormType = 'create' | 'detail' | 'edit';
 
 /** 鏂板/淇敼鐨勮〃鍗� */
-export function useFormSchema(): VbenFormSchema[] {
+export function useFormSchema(
+  orderTotalTaxPrice?: Ref<number | undefined>,
+): VbenFormSchema[] {
   return [
     {
       fieldName: 'id',
@@ -41,8 +46,15 @@
       },
       componentProps: (_values, form) => ({
         placeholder: '璇烽�夋嫨閲囪喘璁㈠崟',
-        onChange: (order: { supplierName?: string } | undefined) => {
+        onChange: (
+          order:
+            | { supplierName?: string; totalTaxPrice?: number }
+            | undefined,
+        ) => {
           form.setFieldValue('supplierName', order?.supplierName);
+          if (orderTotalTaxPrice) {
+            orderTotalTaxPrice.value = order?.totalTaxPrice;
+          }
         },
       }),
     },
@@ -78,11 +90,37 @@
       label: '鏉ョエ閲戦锛堝厓锛�',
       component: 'InputNumber',
       rules: 'required',
+      description: () =>
+        orderTotalTaxPrice?.value != null
+          ? `閲囪喘璁㈠崟鏈紑绁ㄩ噾棰濓細${Number(orderTotalTaxPrice.value).toFixed(2)} 鍏僠
+          : '',
       componentProps: {
         class: '!w-full',
         placeholder: '璇疯緭鍏ユ潵绁ㄩ噾棰�',
         min: 0,
         precision: 2,
+      },
+      dependencies: {
+        triggerFields: ['purchaseOrderId'],
+        componentProps: () => ({
+          class: '!w-full',
+          placeholder: '璇疯緭鍏ユ潵绁ㄩ噾棰�',
+          min: 0,
+          max: orderTotalTaxPrice?.value ?? undefined,
+          precision: 2,
+        }),
+        rules: () => {
+          const max = orderTotalTaxPrice?.value;
+          if (max != null) {
+            return z
+              .number({ message: '璇疯緭鍏ユ潵绁ㄩ噾棰�' })
+              .min(0, '鏉ョエ閲戦涓嶈兘灏忎簬 0')
+              .max(max, `鏉ョエ閲戦涓嶈兘澶т簬鏈紑绁ㄩ噾棰� ${Number(max).toFixed(2)}`);
+          }
+          return z
+            .number({ message: '璇疯緭鍏ユ潵绁ㄩ噾棰�' })
+            .min(0, '鏉ョエ閲戦涓嶈兘灏忎簬 0');
+        },
       },
     },
     {
@@ -180,12 +218,6 @@
     {
       title: '鏉ョエ閲戦锛堝厓锛�',
       field: 'price',
-      minWidth: 150,
-      formatter: 'formatAmount2',
-    },
-    {
-      title: '鍓╀綑鍙粯閲戦',
-      field: 'remainingInvoicePrice',
       minWidth: 150,
       formatter: 'formatAmount2',
     },
diff --git a/src/views/erp/purchase/invoice/modules/form.vue b/src/views/erp/purchase/invoice/modules/form.vue
index 74d0462..12036c8 100644
--- a/src/views/erp/purchase/invoice/modules/form.vue
+++ b/src/views/erp/purchase/invoice/modules/form.vue
@@ -22,6 +22,7 @@
 const emit = defineEmits(['success']);
 const formData = ref<ErpPurchaseInvoiceApi.PurchaseInvoice>();
 const formType = ref<FormType>('create');
+const orderTotalTaxPrice = ref<number>(); // 鎵�閫夐噰璐鍗曞悎璁$◣棰濓紙鏈紑绁ㄩ噾棰濓紝鐢ㄤ簬鎻愮ず涓庢牎楠岋級
 
 const getTitle = computed(() => {
   if (formType.value === 'create') {
@@ -42,7 +43,7 @@
   },
   wrapperClass: 'grid-cols-2',
   layout: 'horizontal',
-  schema: useFormSchema(),
+  schema: useFormSchema(orderTotalTaxPrice),
   showDefaultActions: false,
 });
 
@@ -71,12 +72,13 @@
   async onOpenChange(isOpen: boolean) {
     if (!isOpen) {
       formData.value = undefined;
+      orderTotalTaxPrice.value = undefined;
       return;
     }
     const data = modalApi.getData<{ formType: FormType; id?: number }>();
     formType.value = data.formType;
     formApi.setDisabled(formType.value === 'detail');
-    formApi.updateSchema(useFormSchema());
+    formApi.updateSchema(useFormSchema(orderTotalTaxPrice));
     await formApi.resetForm();
     if (!data || !data.id) {
       return;
diff --git a/src/views/erp/purchase/invoice/modules/purchase-order-select.vue b/src/views/erp/purchase/invoice/modules/purchase-order-select.vue
index a3e1109..ddfc9e5 100644
--- a/src/views/erp/purchase/invoice/modules/purchase-order-select.vue
+++ b/src/views/erp/purchase/invoice/modules/purchase-order-select.vue
@@ -92,6 +92,12 @@
         minWidth: 120,
       },
       {
+        field: 'totalTaxPrice',
+        title: '鏈紑绁ㄩ噾棰�',
+        formatter: 'formatAmount2',
+        minWidth: 120,
+      },
+      {
         field: 'status',
         title: '鐘舵��',
         minWidth: 100,

--
Gitblit v1.9.3