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/purchase/order/modules/item-form.vue |   35 ++++++++++++++---------------------
 1 files changed, 14 insertions(+), 21 deletions(-)

diff --git a/src/views/erp/purchase/order/modules/item-form.vue b/src/views/erp/purchase/order/modules/item-form.vue
index 009246a..7ba1dc1 100644
--- a/src/views/erp/purchase/order/modules/item-form.vue
+++ b/src/views/erp/purchase/order/modules/item-form.vue
@@ -10,10 +10,10 @@
   erpPriceMultiply,
 } from '@vben/utils';
 
-import { Input, InputNumber, Select, Switch } from 'ant-design-vue';
+import { Input, InputNumber, Switch } from 'ant-design-vue';
 
 import { TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
-import { getItemPage } from '#/api/mdm/item';
+import { MdmItemSelect } from '#/views/basicData/mdm/components';
 
 import { useFormItemColumns } from '../data';
 
@@ -36,7 +36,6 @@
 ]);
 
 const tableData = ref<ErpPurchaseOrderApi.PurchaseOrderItem[]>([]); // 琛ㄦ牸鏁版嵁
-const productOptions = ref<MdmItemApi.Item[]>([]); // 浜у搧涓嬫媺閫夐」
 
 /** 鑾峰彇琛ㄦ牸鍚堣鏁版嵁 */
 const summaries = computed(() => {
@@ -150,16 +149,15 @@
 }
 
 /** 澶勭悊浜у搧鍙樻洿 */
-async function handleProductChange(productId: any, row: any) {
-  const product = productOptions.value.find((p) => p.id === productId);
-  if (!product) {
+function handleProductChange(item: MdmItemApi.Item | undefined, row: any) {
+  if (!item?.id) {
     return;
   }
-  row.productId = productId;
-  row.productUnitId = product.unitMeasureId;
-  row.productUnitName = product.unitMeasureName;
-  row.productName = product.name;
-  row.productPrice = product.purchasePrice || 0;
+  row.productId = item.id;
+  row.productUnitId = item.unitMeasureId;
+  row.productUnitName = item.unitMeasureName;
+  row.productName = item.name;
+  row.productPrice = item.purchasePrice || 0;
   row.count = row.count || 1;
   handleRowChange(row);
 }
@@ -208,9 +206,7 @@
 });
 
 /** 鍒濆鍖� */
-onMounted(async () => {
-  const res = await getItemPage({ pageNo: 1, pageSize: 100, status: 0 });
-  productOptions.value = res.list || [];
+onMounted(() => {
   // 鐩殑锛氭柊澧炴椂锛岄粯璁ゆ坊鍔犱竴琛�
   if (tableData.value.length === 0) {
     handleAdd();
@@ -221,15 +217,12 @@
 <template>
   <Grid class="w-full">
     <template #productId="{ row }">
-      <Select
+      <MdmItemSelect
         v-if="!disabled"
-        v-model:value="row.productId"
-        :options="productOptions"
-        :field-names="{ label: 'name', value: 'id' }"
-        class="w-full"
+        v-model:model-value="row.productId"
+        :label="row.productName"
         placeholder="璇烽�夋嫨浜у搧"
-        show-search
-        @change="handleProductChange($event, row)"
+        @change="(item) => handleProductChange(item, row)"
       />
       <span v-else>{{ row.productName || '-' }}</span>
     </template>

--
Gitblit v1.9.3