From 90760f9d6d9ce2cc1314e25b3bd6e1643769dc61 Mon Sep 17 00:00:00 2001
From: gaoluyang <2820782392@qq.com>
Date: 星期三, 04 十一月 2026 17:11:33 +0800
Subject: [PATCH] feat(erp): 来票分摊合计允许小于来票金额,未分摊部分可后续编辑补充订单

---
 src/views/erp/purchase/invoice/modules/order-allocation-field.vue |   13 +++++++++++--
 src/views/erp/purchase/invoice/modules/form.vue                   |    9 +++++----
 2 files changed, 16 insertions(+), 6 deletions(-)

diff --git a/src/views/erp/purchase/invoice/modules/form.vue b/src/views/erp/purchase/invoice/modules/form.vue
index a27755d..429b686 100644
--- a/src/views/erp/purchase/invoice/modules/form.vue
+++ b/src/views/erp/purchase/invoice/modules/form.vue
@@ -57,21 +57,22 @@
     }
     modalApi.lock();
     const data = (await formApi.getValues()) as ErpPurchaseInvoiceApi.PurchaseInvoice;
-    // 鏍¢獙閲囪喘璁㈠崟鍒嗘憡锛氳嚦灏戜竴寮犺鍗曪紝涓斿垎鎽婂悎璁� = 鏉ョエ閲戦
+    // 鏍¢獙閲囪喘璁㈠崟鍒嗘憡锛氳嚦灏戜竴寮犺鍗曪紝鍒嗘憡鍚堣涓嶈兘澶т簬鏉ョエ閲戦锛堝厑璁稿皬浜庯紝鏈垎鎽婇儴鍒嗗彲鍚庣画缂栬緫琛ュ厖璁㈠崟锛�
     const allocations = data.orderAllocations ?? [];
     if (allocations.length === 0) {
       modalApi.unlock();
-      message.error('璇疯嚦灏戦�夋嫨涓�寮犻噰璐鍗曪紝骞舵妸鏉ョエ閲戦鍒嗘憡鍒拌鍗曚笂');
+      message.error('璇疯嚦灏戦�夋嫨涓�寮犻噰璐鍗�');
       return;
     }
     const allocationTotal = allocations.reduce(
       (sum, row) => sum + Number(row.price ?? 0),
       0,
     );
-    if (Math.abs(allocationTotal - Number(data.price ?? 0)) > 0.001) {
+    const invoicePrice = Number(data.price ?? 0);
+    if (allocationTotal - invoicePrice > 0.001) {
       modalApi.unlock();
       message.error(
-        `鍚勯噰璐鍗曞垎鎽婂悎璁� ${allocationTotal.toFixed(2)} 鍏冧笌鏉ョエ閲戦 ${Number(data.price ?? 0).toFixed(2)} 鍏冧笉涓�鑷达紝璇风偣鍑汇�岃嚜鍔ㄥ垎鎽娿�嶆垨璋冩暣鍒嗘憡閲戦`,
+        `鍚勯噰璐鍗曞垎鎽婂悎璁� ${allocationTotal.toFixed(2)} 鍏冨ぇ浜庢潵绁ㄩ噾棰� ${invoicePrice.toFixed(2)} 鍏冿紙瓒呭嚭 ${(allocationTotal - invoicePrice).toFixed(2)} 鍏冿級锛岃鍑忓皯鍒嗘憡閲戦鎴栨彁楂樻潵绁ㄩ噾棰漙,
       );
       return;
     }
diff --git a/src/views/erp/purchase/invoice/modules/order-allocation-field.vue b/src/views/erp/purchase/invoice/modules/order-allocation-field.vue
index 7d043ac..ab300f3 100644
--- a/src/views/erp/purchase/invoice/modules/order-allocation-field.vue
+++ b/src/views/erp/purchase/invoice/modules/order-allocation-field.vue
@@ -360,7 +360,7 @@
         鑷姩鍒嗘憡
       </Button>
       <span class="text-xs text-gray-400">
-        涓�寮犳潵绁ㄥ彲鍏宠仈鍚屼竴渚涘簲鍟嗙殑澶氬紶閲囪喘璁㈠崟锛涢粯璁ゆ寜鏈紑绁ㄩ噾棰濊嚜鍔ㄥ垎鎽婏紝鍙墜宸ヨ皟鏁�
+        涓�寮犳潵绁ㄥ彲鍏宠仈鍚屼竴渚涘簲鍟嗙殑澶氬紶閲囪喘璁㈠崟锛涘垎鎽婂悎璁′笉鑳藉ぇ浜庢潵绁ㄩ噾棰濓紝鏈垎鎽婇儴鍒嗗彲鍚庣画缂栬緫琛ュ厖
       </span>
     </div>
     <Table
@@ -419,8 +419,17 @@
       <span>
         鏉ョエ閲戦锛�<span class="font-medium">{{ formatAmount(invoicePrice) }}</span> 鍏�
       </span>
-      <span :class="diff === 0 ? 'text-green-600' : 'text-red-500'">
+      <span
+        :class="
+          diff < 0
+            ? 'text-red-500'
+            : diff === 0
+              ? 'text-green-600'
+              : 'text-orange-500'
+        "
+      >
         寰呭垎鎽婂樊棰濓細<span class="font-medium">{{ formatAmount(diff) }}</span> 鍏�
+        <span v-if="diff > 0" class="text-xs">锛堟湭鍒嗘憡锛屽彲淇濆瓨鍚庣紪杈戣ˉ鍏呰鍗曪級</span>
       </span>
     </div>
 

--
Gitblit v1.9.3