From a241b66efcc41e973290a6722fb7a4d79b833ea1 Mon Sep 17 00:00:00 2001
From: 云 <2163098428@qq.com>
Date: 星期二, 13 十月 2026 09:54:32 +0800
Subject: [PATCH] feat(bi): 为图表配置接口添加名称字段

---
 src/views/erp/purchase/order/modules/item-form.vue |   58 ++++++++++++++++++++++++++++++----------------------------
 1 files changed, 30 insertions(+), 28 deletions(-)

diff --git a/src/views/erp/purchase/order/modules/item-form.vue b/src/views/erp/purchase/order/modules/item-form.vue
index 31bdad9..7ba1dc1 100644
--- a/src/views/erp/purchase/order/modules/item-form.vue
+++ b/src/views/erp/purchase/order/modules/item-form.vue
@@ -1,5 +1,5 @@
 <script lang="ts" setup>
-import type { ErpProductApi } from '#/api/erp/product/product';
+import type { MdmItemApi } from '#/api/mdm/item';
 import type { ErpPurchaseOrderApi } from '#/api/erp/purchase/order';
 
 import { computed, nextTick, onMounted, ref, watch } from 'vue';
@@ -8,13 +8,12 @@
   erpCountInputFormatter,
   erpPriceInputFormatter,
   erpPriceMultiply,
-} from '..\..\..\..\..\packages\utils\src';
+} from '@vben/utils';
 
-import { Input, InputNumber, Select } from 'ant-design-vue';
+import { Input, InputNumber, Switch } from 'ant-design-vue';
 
 import { TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
-import { getProductSimpleList } from '#/api/erp/product/product';
-import { getStockCount } from '#/api/erp/stock/stock';
+import { MdmItemSelect } from '#/views/basicData/mdm/components';
 
 import { useFormItemColumns } from '../data';
 
@@ -37,7 +36,6 @@
 ]);
 
 const tableData = ref<ErpPurchaseOrderApi.PurchaseOrderItem[]>([]); // 琛ㄦ牸鏁版嵁
-const productOptions = ref<ErpProductApi.Product[]>([]); // 浜у搧涓嬫媺閫夐」
 
 /** 鑾峰彇琛ㄦ牸鍚堣鏁版嵁 */
 const summaries = computed(() => {
@@ -124,16 +122,15 @@
   const newRow = {
     id: undefined,
     productId: undefined,
-    productUnitName: undefined, // 浜у搧鍗曚綅
-    productBarCode: undefined, // 浜у搧鏉$爜
+    productUnitName: undefined,
     productPrice: undefined,
-    stockCount: undefined,
     count: 1,
     totalProductPrice: undefined,
     taxPercent: 0,
     taxPrice: undefined,
     totalPrice: undefined,
     remark: undefined,
+    qcCheckFlag: false,
   };
   tableData.value.push(newRow);
   // 閫氱煡鐖剁粍浠舵洿鏂�
@@ -152,18 +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.unitId;
-  row.productBarCode = product.barCode;
-  row.productUnitName = product.unitName;
-  row.productName = product.name;
-  row.stockCount = (await getStockCount(productId)) || 0;
-  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);
 }
@@ -212,8 +206,7 @@
 });
 
 /** 鍒濆鍖� */
-onMounted(async () => {
-  productOptions.value = await getProductSimpleList();
+onMounted(() => {
   // 鐩殑锛氭柊澧炴椂锛岄粯璁ゆ坊鍔犱竴琛�
   if (tableData.value.length === 0) {
     handleAdd();
@@ -224,15 +217,14 @@
 <template>
   <Grid class="w-full">
     <template #productId="{ row }">
-      <Select
-        v-model:value="row.productId"
-        :options="productOptions"
-        :field-names="{ label: 'name', value: 'id' }"
-        class="w-full"
+      <MdmItemSelect
+        v-if="!disabled"
+        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>
     <template #count="{ row }">
       <InputNumber
@@ -258,6 +250,16 @@
       <Input v-if="!disabled" v-model:value="row.remark" class="w-full" />
       <span v-else>{{ row.remark || '-' }}</span>
     </template>
+    <template #qcCheckFlag="{ row }">
+      <Switch
+        v-if="!disabled"
+        v-model:checked="row.qcCheckFlag"
+        checked-children="鏄�"
+        un-checked-children="鍚�"
+        @change="handleRowChange(row)"
+      />
+      <span v-else>{{ row.qcCheckFlag ? '鏄�' : '鍚�' }}</span>
+    </template>
     <template #taxPercent="{ row }">
       <InputNumber
         v-if="!disabled"

--
Gitblit v1.9.3