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/data.ts |   48 ++++++++++++++++++++++++++++++++++++++++--------
 1 files changed, 40 insertions(+), 8 deletions(-)

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',
     },

--
Gitblit v1.9.3