From a342672f32352c1337b8977c25c101725fccedd5 Mon Sep 17 00:00:00 2001
From: gaoluyang <2820782392@qq.com>
Date: 星期四, 24 九月 2026 10:48:27 +0800
Subject: [PATCH] fix: MOM 1.产品选择组件修改

---
 src/views/erp/sale/return/modules/item-form.vue |   41 ++++++++++++++++++++++++-----------------
 1 files changed, 24 insertions(+), 17 deletions(-)

diff --git a/src/views/erp/sale/return/modules/item-form.vue b/src/views/erp/sale/return/modules/item-form.vue
index 04cb817..1664f09 100644
--- a/src/views/erp/sale/return/modules/item-form.vue
+++ b/src/views/erp/sale/return/modules/item-form.vue
@@ -14,9 +14,9 @@
 import { Input, InputNumber, Select } from 'ant-design-vue';
 
 import { TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
-import { getItemPage } from '#/api/mdm/item';
 import { getWarehouseStockCount } from '#/api/erp/stock/stock';
 import { getWarehouseSimpleList } from '#/api/erp/stock/warehouse';
+import { MdmItemSelect } from '#/views/basicData/mdm/components';
 
 import { useFormItemColumns } from '../data';
 
@@ -44,7 +44,6 @@
 ]);
 
 const tableData = ref<ErpSaleReturnApi.SaleReturnItem[]>([]); // 琛ㄦ牸鏁版嵁
-const productOptions = ref<MdmItemApi.Item[]>([]); // 鐗╂枡涓嬫媺閫夐」
 const warehouseOptions = ref<any[]>([]); // 浠撳簱涓嬫媺閫夐」
 
 /** 鑾峰彇琛ㄦ牸鍚堣鏁版嵁 */
@@ -164,11 +163,14 @@
   emit('update:items', [...tableData.value]);
 }
 
-/** 澶勭悊浜у搧鍙樻洿锛氫紭鍏堜粠鍏宠仈璁㈠崟鐗╂枡涓~鍏咃紝鍏滃簳浠庡叏閮ㄧ墿鏂欎腑鏌ユ壘 */
-function handleProductChange(row: ErpSaleReturnApi.SaleReturnItem) {
+/** 澶勭悊浜у搧鍙樻洿锛氫紭鍏堜粠鍏宠仈璁㈠崟鐗╂枡涓~鍏咃紝鍏滃簳浣跨敤寮规閫変腑鐨勭墿鏂� */
+function handleProductChange(
+  row: ErpSaleReturnApi.SaleReturnItem,
+  item?: MdmItemApi.Item,
+) {
   // 浼樺厛浠庡叧鑱旇鍗曠殑鐗╂枡涓煡鎵�
   const orderItem = props.orderItems.find(
-    (item) => item.productId === row.productId,
+    (order) => order.productId === row.productId,
   );
   if (orderItem) {
     row.productName = orderItem.productName;
@@ -181,14 +183,12 @@
     handleRowChange(row);
     return;
   }
-  // 鍏滃簳锛氫粠鍏ㄩ儴鐗╂枡涓煡鎵�
-  const product = productOptions.value.find((item) => item.id === row.productId);
-  if (product) {
-    row.productName = product.name || '';
-    row.productPrice = product.salesPrice ?? 0;
-    row.productUnitId = product.unitMeasureId;
-    row.productUnitName = product.unitMeasureName;
-    row.productBarCode = product.barCode;
+  if (item) {
+    row.productName = item.name || '';
+    row.productPrice = item.salesPrice ?? 0;
+    row.productUnitId = item.unitMeasureId;
+    row.productUnitName = item.unitMeasureName;
+    row.productBarCode = item.barCode;
     row.taxPercent = 0;
     row.count = row.count || 1;
     handleRowChange(row);
@@ -250,8 +250,6 @@
 
 /** 鍒濆鍖� */
 onMounted(async () => {
-  const res = await getItemPage({ pageNo: 1, pageSize: 100, status: 0 });
-  productOptions.value = res.list || [];
   warehouseOptions.value = await getWarehouseSimpleList();
 });
 </script>
@@ -272,15 +270,24 @@
     </template>
     <template #productId="{ row }">
       <Select
+        v-if="orderItems?.length"
         :disabled="disabled"
         v-model:value="row.productId"
-        :options="orderItems?.length ? orderItems : productOptions"
-        :field-names="orderItems?.length ? { label: 'productName', value: 'productId' } : { label: 'name', value: 'id' }"
+        :options="orderItems"
+        :field-names="{ label: 'productName', value: 'productId' }"
         class="w-full"
         placeholder="璇烽�夋嫨浜у搧"
         show-search
         @change="handleProductChange(row)"
       />
+      <MdmItemSelect
+        v-else
+        v-model:model-value="row.productId"
+        :label="row.productName"
+        :disabled="disabled"
+        placeholder="璇烽�夋嫨浜у搧"
+        @change="(item) => handleProductChange(row, item)"
+      />
     </template>
     <template #count="{ row }">
       <InputNumber

--
Gitblit v1.9.3