From 6373c12e97dc5d52ad87271d1adb6743b0052607 Mon Sep 17 00:00:00 2001
From: liu <2021943741@qq.com>
Date: 星期三, 26 八月 2026 17:18:47 +0800
Subject: [PATCH] feat(erp): 采购来票选单过滤已开完票订单并修正未开票金额口径

---
 src/views/erp/purchase/invoice/data.ts |   71 ++++++++++++++++++++---------------
 1 files changed, 40 insertions(+), 31 deletions(-)

diff --git a/src/views/erp/purchase/invoice/data.ts b/src/views/erp/purchase/invoice/data.ts
index e222159..c315066 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(
+  orderRemainInvoicePrice?: Ref<number | undefined>,
+): VbenFormSchema[] {
   return [
     {
       fieldName: 'id',
@@ -41,8 +46,15 @@
       },
       componentProps: (_values, form) => ({
         placeholder: '璇烽�夋嫨閲囪喘璁㈠崟',
-        onChange: (order: { supplierName?: string } | undefined) => {
+        onChange: (
+          order:
+            | { supplierName?: string; remainInvoicePrice?: number }
+            | undefined,
+        ) => {
           form.setFieldValue('supplierName', order?.supplierName);
+          if (orderRemainInvoicePrice) {
+            orderRemainInvoicePrice.value = order?.remainInvoicePrice;
+          }
         },
       }),
     },
@@ -78,11 +90,37 @@
       label: '鏉ョエ閲戦锛堝厓锛�',
       component: 'InputNumber',
       rules: 'required',
+      description: () =>
+        orderRemainInvoicePrice?.value != null
+          ? `閲囪喘璁㈠崟鏈紑绁ㄩ噾棰濓細${Number(orderRemainInvoicePrice.value).toFixed(2)} 鍏僠
+          : '',
       componentProps: {
         class: '!w-full',
         placeholder: '璇疯緭鍏ユ潵绁ㄩ噾棰�',
         min: 0,
         precision: 2,
+      },
+      dependencies: {
+        triggerFields: ['purchaseOrderId'],
+        componentProps: () => ({
+          class: '!w-full',
+          placeholder: '璇疯緭鍏ユ潵绁ㄩ噾棰�',
+          min: 0,
+          max: orderRemainInvoicePrice?.value ?? undefined,
+          precision: 2,
+        }),
+        rules: () => {
+          const max = orderRemainInvoicePrice?.value;
+          if (max != null) {
+            return z
+              .number({ message: '璇疯緭鍏ユ潵绁ㄩ噾棰�' })
+              .min(0, '鏉ョエ閲戦涓嶈兘灏忎簬 0')
+              .max(max, `鏉ョエ閲戦涓嶈兘澶т簬鏈紑绁ㄩ噾棰� ${Number(max).toFixed(2)}`);
+          }
+          return z
+            .number({ message: '璇疯緭鍏ユ潵绁ㄩ噾棰�' })
+            .min(0, '鏉ョエ閲戦涓嶈兘灏忎簬 0');
+        },
       },
     },
     {
@@ -148,22 +186,6 @@
         valueField: 'id',
       },
     },
-    {
-      fieldName: 'auditStatus',
-      label: '瀹℃壒鐘舵��',
-      component: 'Select',
-      componentProps: {
-        options: [
-          { label: '鏈彁浜�', value: 0 },
-          { label: '瀹℃壒涓�', value: 10 },
-          { label: '瀹℃牳閫氳繃', value: 20 },
-          { label: '瀹℃牳涓嶉�氳繃', value: 30 },
-          { label: '宸蹭綔搴�', value: 40 },
-        ],
-        placeholder: '璇烽�夋嫨瀹℃壒鐘舵��',
-        allowClear: true,
-      },
-    },
   ];
 }
 
@@ -200,12 +222,6 @@
       formatter: 'formatAmount2',
     },
     {
-      title: '鍓╀綑鍙粯閲戦',
-      field: 'remainingInvoicePrice',
-      minWidth: 150,
-      formatter: 'formatAmount2',
-    },
-    {
       title: '鏉ョエ鏃ユ湡',
       field: 'invoiceTime',
       minWidth: 150,
@@ -222,13 +238,6 @@
       minWidth: 100,
       fixed: 'right',
       slots: { default: 'attachment' },
-    },
-    {
-      title: '瀹℃壒鐘舵��',
-      field: 'auditStatus',
-      minWidth: 100,
-      fixed: 'right',
-      slots: { default: 'auditStatus' },
     },
     {
       title: '鎿嶄綔',

--
Gitblit v1.9.3