From f630e7e4d50ba22da8f42336196a02dbae850ced Mon Sep 17 00:00:00 2001
From: 云 <2163098428@qq.com>
Date: 星期一, 10 八月 2026 17:54:32 +0800
Subject: [PATCH] refactor(erp): 优化采购发票和财务付款审核流程

---
 src/views/erp/sale/order/modules/item-form.vue |   61 +++++++++++++++++++-----------
 1 files changed, 38 insertions(+), 23 deletions(-)

diff --git a/src/views/erp/sale/order/modules/item-form.vue b/src/views/erp/sale/order/modules/item-form.vue
index 3c42fec..ffd3207 100644
--- a/src/views/erp/sale/order/modules/item-form.vue
+++ b/src/views/erp/sale/order/modules/item-form.vue
@@ -1,5 +1,4 @@
 <script lang="ts" setup>
-import type { ErpProductApi } from '#/api/erp/product/product';
 import type { ErpSaleOrderApi } from '#/api/erp/sale/order';
 
 import { computed, nextTick, onMounted, ref, watch } from 'vue';
@@ -8,13 +7,12 @@
   erpCountInputFormatter,
   erpPriceInputFormatter,
   erpPriceMultiply,
-} from '../../../../../packages/utils/src';
+} from '@vben/utils';
 
-import { Input, InputNumber, Select } from 'ant-design-vue';
+import { Input, InputNumber, Select, Tag } 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';
 
@@ -36,8 +34,7 @@
   'update:totalPrice',
 ]);
 
-const tableData = ref<ErpSaleOrderApi.SaleOrderItem[]>([]); // 琛ㄦ牸鏁版嵁
-const productOptions = ref<ErpProductApi.Product[]>([]); // 浜у搧涓嬫媺閫夐」
+const tableData = ref<ErpSaleOrderApi.SaleOrderItem[]>([]);
 
 /** 鑾峰彇琛ㄦ牸鍚堣鏁版嵁 */
 const summaries = computed(() => {
@@ -124,8 +121,7 @@
   const newRow = {
     id: undefined,
     productId: undefined,
-    productUnitName: undefined, // 浜у搧鍗曚綅
-    productBarCode: undefined, // 浜у搧鏉$爜
+    productUnitName: undefined,
     productPrice: undefined,
     stockCount: undefined,
     count: 1,
@@ -134,6 +130,7 @@
     taxPrice: undefined,
     totalPrice: undefined,
     remark: undefined,
+    needProduction: 1,
   };
   tableData.value.push(newRow);
   // 閫氱煡鐖剁粍浠舵洿鏂�
@@ -152,18 +149,19 @@
 }
 
 /** 澶勭悊浜у搧鍙樻洿 */
-async function handleProductChange(productId: any, row: any) {
-  const product = productOptions.value.find((p) => p.id === productId);
+function handleProductChange(product: any, row: any) {
   if (!product) {
     return;
   }
-  row.productId = productId;
-  row.productUnitId = product.unitId;
+  row.productId = product.id;
+  row.productUnitId = product.unitMeasureId;
   row.productBarCode = product.barCode;
-  row.productUnitName = product.unitName;
+  row.productUnitName = product.unitMeasureName;
+  row.productUnitName2 = product.unitMeasureName2;
+  row.productUnitName3 = product.unitMeasureName3;
+  row.productSpecification = product.specification;
   row.productName = product.name;
-  row.stockCount = (await getStockCount(productId)) || 0;
-  row.productPrice = product.salePrice || 0;
+  row.productPrice = product.salesPrice || 0;
   row.count = row.count || 1;
   handleRowChange(row);
 }
@@ -186,6 +184,10 @@
     row.taxPrice =
       erpPriceMultiply(row.totalProductPrice, (row.taxPercent || 0) / 100) ?? 0;
     row.totalPrice = row.totalProductPrice + row.taxPrice;
+  }
+  // 榛樿闇�瑕佺敓浜�
+  if (row.needProduction === undefined) {
+    row.needProduction = 1;
   }
 }
 
@@ -213,7 +215,6 @@
 
 /** 鍒濆鍖� */
 onMounted(async () => {
-  productOptions.value = await getProductSimpleList();
   // 鐩殑锛氭柊澧炴椂锛岄粯璁ゆ坊鍔犱竴琛�
   if (tableData.value.length === 0) {
     handleAdd();
@@ -224,15 +225,29 @@
 <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"
+        :model-value="row.productId"
         placeholder="璇烽�夋嫨浜у搧"
-        show-search
+        @update:model-value="row.productId = $event"
         @change="handleProductChange($event, row)"
       />
+      <span v-else>{{ row.productName || '-' }}</span>
+    </template>
+    <template #needProduction="{ row }">
+      <Select
+        v-if="!disabled"
+        v-model:value="row.needProduction"
+        :options="[
+          { label: '鏄�', value: 1 },
+          { label: '鍚�', value: 0 },
+        ]"
+        class="w-full"
+        placeholder="璇烽�夋嫨"
+        @change="handleRowChange(row)"
+      />
+      <Tag v-else-if="row.needProduction === 1" color="success">鏄�</Tag>
+      <Tag v-else color="default">鍚�</Tag>
     </template>
     <template #count="{ row }">
       <InputNumber

--
Gitblit v1.9.3