From 452e5c5e9a340367c8fdb14b0bdecc96dcb29491 Mon Sep 17 00:00:00 2001
From: 云 <2163098428@qq.com>
Date: 星期三, 19 八月 2026 11:01:28 +0800
Subject: [PATCH] fix(router): 更新一袋一码首页路由标题

---
 src/views/crm/product/components/edit-table.vue |   88 ++++++++++++++++++++++----------------------
 1 files changed, 44 insertions(+), 44 deletions(-)

diff --git a/src/views/crm/product/components/edit-table.vue b/src/views/crm/product/components/edit-table.vue
index 0c335c0..f7cb97a 100644
--- a/src/views/crm/product/components/edit-table.vue
+++ b/src/views/crm/product/components/edit-table.vue
@@ -1,17 +1,17 @@
 <script lang="ts" setup>
 import type { CrmBusinessApi } from '#/api/crm/business';
 import type { CrmContractApi } from '#/api/crm/contract';
-import type { CrmProductApi } from '#/api/crm/product';
+import type { MdmItemApi } from '#/api/mdm/item';
 
-import { nextTick, onMounted, ref, watch } from 'vue';
+import { computed, nextTick, ref, watch } from 'vue';
 
-import { erpPriceMultiply } from '..\..\..\..\packages\utils\src';
+import { erpPriceMultiply } from '@vben/utils';
 
-import { InputNumber, Select } from 'ant-design-vue';
+import { InputNumber } from 'ant-design-vue';
 
 import { TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
 import { BizTypeEnum } from '#/api/crm/permission';
-import { getProductSimpleList } from '#/api/crm/product';
+import { MdmItemSelect } from '#/views/basicData/mdm/components';
 import { $t } from '#/locales';
 
 import { useProductEditTableColumns } from './data';
@@ -24,6 +24,12 @@
 }>();
 
 const emit = defineEmits(['update:products']);
+
+/** 鏄惁涓哄晢鏈虹被鍨� */
+const isBusiness = computed(() => props.bizType === BizTypeEnum.CRM_BUSINESS);
+
+/** 褰撳墠涓氬姟绫诲瀷瀵瑰簲鐨勪环鏍煎瓧娈靛悕 */
+const priceField = computed(() => isBusiness.value ? 'businessPrice' : 'contractPrice');
 
 /** 琛ㄦ牸鍐呴儴鏁版嵁 */
 const tableData = ref<any[]>([]);
@@ -39,34 +45,36 @@
 }
 
 /** 鍒囨崲浜у搧鏃跺悓姝ュ熀纭�淇℃伅 */
-function handleProductChange(productId: any, row: any) {
-  const product = productOptions.value.find((p) => p.id === productId);
+function handleProductChange(product: MdmItemApi.Item | undefined, row: any) {
   if (!product) {
     return;
   }
-  row.productUnit = product.unit;
-  row.productNo = product.no;
-  row.productPrice = product.price;
-  row.sellingPrice = product.price;
-  row.count = 0;
-  row.totalPrice = 0;
+  row.itemId = product.id;
+  row.itemName = product.name;
+  row.itemCode = product.code;
+  row.barCode = product.barCode;
+  row.itemUnitId = product.unitMeasureId;
+  row.itemUnitName = product.unitMeasureName;
+  row.itemUnitName2 = product.unitMeasureName2;
+  row.itemUnitName3 = product.unitMeasureName3;
+  row.itemSpecification = product.specification;
+  row.itemPrice = product.salesPrice;
+  row[priceField.value] = product.salesPrice;
+  row.count = row.count || 1;
+  row.totalPrice = erpPriceMultiply(row[priceField.value], row.count) ?? 0;
   handleUpdateValue(row);
 }
 
 /** 閲戦鍙樺姩鏃堕噸鏂拌绠楀悎璁� */
 function handlePriceChange(row: any) {
-  row.totalPrice = erpPriceMultiply(row.sellingPrice, row.count) ?? 0;
+  row.totalPrice = erpPriceMultiply(row[priceField.value], row.count) ?? 0;
   handleUpdateValue(row);
 }
 
 /** 灏嗘渶鏂版暟鎹啓鍥炲苟閫氱煡鐖剁粍浠� */
 function handleUpdateValue(row: any) {
   const index = tableData.value.findIndex((item) => item.id === row.id);
-  if (props.bizType === BizTypeEnum.CRM_BUSINESS) {
-    row.businessPrice = row.sellingPrice;
-  } else if (props.bizType === BizTypeEnum.CRM_CONTRACT) {
-    row.contractPrice = row.sellingPrice;
-  }
+  row.totalPrice = erpPriceMultiply(row[priceField.value], row.count) ?? 0;
   if (index === -1) {
     row.id = tableData.value.length + 1;
     tableData.value.push(row);
@@ -82,7 +90,7 @@
       trigger: 'click',
       mode: 'cell',
     },
-    columns: useProductEditTableColumns(),
+    columns: useProductEditTableColumns(isBusiness.value),
     data: tableData.value,
     border: true,
     showOverflow: true,
@@ -110,43 +118,35 @@
     }
     await nextTick();
     tableData.value = products;
-    if (props.bizType === BizTypeEnum.CRM_BUSINESS) {
-      tableData.value.forEach((item) => {
-        item.sellingPrice = item.businessPrice;
-      });
-    } else if (props.bizType === BizTypeEnum.CRM_CONTRACT) {
-      tableData.value.forEach((item) => {
-        item.sellingPrice = item.contractPrice;
-      });
-    }
     await gridApi.grid.reloadData(tableData.value);
   },
   {
     immediate: true,
   },
 );
-
-/** 鍒濆鍖� */
-const productOptions = ref<CrmProductApi.Product[]>([]); // 浜у搧涓嬫媺閫夐」
-onMounted(async () => {
-  productOptions.value = await getProductSimpleList();
-});
 </script>
 
 <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"
+    <template #itemId="{ row }">
+      <MdmItemSelect
+        :model-value="row.itemId"
+        placeholder="璇烽�夋嫨浜у搧"
+        @update:model-value="row.itemId = $event"
         @change="handleProductChange($event, row)"
       />
     </template>
-    <template #sellingPrice="{ row }">
+    <template #contractPrice="{ row }">
       <InputNumber
-        v-model:value="row.sellingPrice"
+        v-model:value="row.contractPrice"
+        :min="0.001"
+        :precision="2"
+        @change="handlePriceChange(row)"
+      />
+    </template>
+    <template #businessPrice="{ row }">
+      <InputNumber
+        v-model:value="row.businessPrice"
         :min="0.001"
         :precision="2"
         @change="handlePriceChange(row)"
@@ -180,7 +180,7 @@
             type: 'link',
             danger: true,
             popConfirm: {
-              title: $t('ui.actionMessage.deleteConfirm', [row.name]),
+              title: $t('ui.actionMessage.deleteConfirm', [row.itemName]),
               confirm: handleDelete.bind(null, row),
             },
           },

--
Gitblit v1.9.3