From e4994fccfb49ebfb108ba62cbd82aea4e004f6d8 Mon Sep 17 00:00:00 2001
From: gaoluyang <2820782392@qq.com>
Date: 星期四, 15 十月 2026 10:02:46 +0800
Subject: [PATCH] fix(mes/qc): 不合格品处理单的不合格物料改查 MDM 物料

---
 src/views/erp/purchase/return/modules/item-form.vue |   45 +++++++++++++++++++++++++--------------------
 1 files changed, 25 insertions(+), 20 deletions(-)

diff --git a/src/views/erp/purchase/return/modules/item-form.vue b/src/views/erp/purchase/return/modules/item-form.vue
index d37402a..38c08b9 100644
--- a/src/views/erp/purchase/return/modules/item-form.vue
+++ b/src/views/erp/purchase/return/modules/item-form.vue
@@ -7,12 +7,11 @@
   erpCountInputFormatter,
   erpPriceInputFormatter,
   erpPriceMultiply,
-} from '..\..\..\..\..\packages\utils\src';
+} from '@vben/utils';
 
 import { Input, InputNumber, Select } from 'ant-design-vue';
 
 import { TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
-import { getProductSimpleList } from '#/api/erp/product/product';
 import { getWarehouseStockCount } from '#/api/erp/stock/stock';
 import { getWarehouseSimpleList } from '#/api/erp/stock/warehouse';
 
@@ -40,7 +39,6 @@
 ]);
 
 const tableData = ref<ErpPurchaseReturnApi.PurchaseReturnItem[]>([]); // 琛ㄦ牸鏁版嵁
-const productOptions = ref<any[]>([]); // 浜у搧涓嬫媺閫夐」
 const warehouseOptions = ref<any[]>([]); // 浠撳簱涓嬫媺閫夐」
 
 /** 鑾峰彇琛ㄦ牸鍚堣鏁版嵁 */
@@ -155,6 +153,7 @@
 /** 澶勭悊琛屾暟鎹彉鏇� */
 function handleRowChange(row: any) {
   // TODO 鑺嬭壙
+  recalcRow(row);
   const index = tableData.value.findIndex((item) => item.seq === row.seq);
   if (index === -1) {
     tableData.value.push(row);
@@ -164,13 +163,28 @@
   emit('update:items', [...tableData.value]);
 }
 
-/** 鍒濆鍖栬鏁版嵁 */
-function initRow(row: ErpPurchaseReturnApi.PurchaseReturnItem) {
+/**
+ * 閲嶇畻琛岄噾棰濓紙鍗曚环涓�**鍚◣**鍗曚环锛�
+ * 鍚◣閲戦 = 鍚◣鍗曚环 脳 鏁伴噺锛涚◣棰� = 鍚◣閲戦 脳 绋庣巼锛涗笉鍚◣閲戦 = 鍚◣閲戦 - 绋庨
+ */
+function recalcRow(row: ErpPurchaseReturnApi.PurchaseReturnItem) {
   if (row.productPrice && row.count) {
-    row.totalProductPrice = erpPriceMultiply(row.productPrice, row.count) ?? 0;
+    const taxInclusivePrice = erpPriceMultiply(row.productPrice, row.count) ?? 0;
     row.taxPrice =
-      erpPriceMultiply(row.totalProductPrice, (row.taxPercent || 0) / 100) ?? 0;
-    row.totalPrice = row.totalProductPrice + row.taxPrice;
+      erpPriceMultiply(taxInclusivePrice, (row.taxPercent || 0) / 100) ?? 0;
+    row.totalProductPrice = taxInclusivePrice - row.taxPrice;
+    row.totalPrice = taxInclusivePrice;
+  }
+}
+
+/**
+ * 鍒濆鍖栬鏁版嵁
+ * 宸叉湁鍗曟嵁鐨勬槑缁嗚锛堝甫 id锛夋部鐢ㄥ悗绔繑鍥炵殑閲戦锛岄伩鍏嶅巻鍙插崟鎹鏂板彛寰勮鐩栵紱
+ * 鍙湁鏈繚瀛樼殑鏂板琛屾墠鎸夋柊鍙e緞閲嶇畻銆�
+ */
+function initRow(row: ErpPurchaseReturnApi.PurchaseReturnItem) {
+  if (!row.id) {
+    recalcRow(row);
   }
 }
 
@@ -195,7 +209,6 @@
 
 /** 鍒濆鍖� */
 onMounted(async () => {
-  productOptions.value = await getProductSimpleList();
   warehouseOptions.value = await getWarehouseSimpleList();
 });
 </script>
@@ -215,15 +228,7 @@
       />
     </template>
     <template #productId="{ row }">
-      <Select
-        disabled
-        v-model:value="row.productId"
-        :options="productOptions"
-        :field-names="{ label: 'name', value: 'id' }"
-        class="w-full"
-        placeholder="璇烽�夋嫨浜у搧"
-        show-search
-      />
+      <span>{{ row.productName || '-' }}</span>
     </template>
     <template #count="{ row }">
       <InputNumber
@@ -283,11 +288,11 @@
           <div class="flex space-x-4">
             <span>鏁伴噺锛歿{ erpCountInputFormatter(summaries.count) }}</span>
             <span>
-              閲戦锛歿{ erpPriceInputFormatter(summaries.totalProductPrice) }}
+              涓嶅惈绋庨噾棰濓細{{ erpPriceInputFormatter(summaries.totalProductPrice) }}
             </span>
             <span>绋庨锛歿{ erpPriceInputFormatter(summaries.taxPrice) }}</span>
             <span>
-              绋庨鍚堣锛歿{ erpPriceInputFormatter(summaries.totalPrice) }}
+              鍚◣鍚堣锛歿{ erpPriceInputFormatter(summaries.totalPrice) }}
             </span>
           </div>
         </div>

--
Gitblit v1.9.3