From bc92c5b9f6c432667dcaf43fdca588f889d65f53 Mon Sep 17 00:00:00 2001
From: buhuazhen <hua100783@gmail.com>
Date: 星期六, 16 五月 2026 10:16:36 +0800
Subject: [PATCH] feat(salesQuotation): 将productModel 设置为specification 为后端接口参数对应

---
 src/views/salesManagement/salesQuotation/index.vue |   92 +++++++++++++++++++++++++---------------------
 1 files changed, 50 insertions(+), 42 deletions(-)

diff --git a/src/views/salesManagement/salesQuotation/index.vue b/src/views/salesManagement/salesQuotation/index.vue
index 39cf160..fce764f 100644
--- a/src/views/salesManagement/salesQuotation/index.vue
+++ b/src/views/salesManagement/salesQuotation/index.vue
@@ -187,9 +187,9 @@
             </el-table-column>
             <el-table-column prop="specification" label="瑙勬牸鍨嬪彿" width="200">
               <template #default="scope">
-                <el-form-item :prop="`products.${scope.$index}.specificationId`" class="product-table-form-item">
+                <el-form-item :prop="`products.${scope.$index}.productModelId`" class="product-table-form-item">
                   <el-select
-                    v-model="scope.row.specificationId"
+                    v-model="scope.row.productModelId"
                     placeholder="璇烽�夋嫨"
                     clearable
                     @change="getProductModel($event, scope.row)"
@@ -239,10 +239,10 @@
           </template>
           <div class="form-content">
             <el-form-item label="澶囨敞" prop="remark">
-              <el-input 
-                type="textarea" 
-                v-model="form.remark" 
-                placeholder="璇疯緭鍏ュ娉ㄤ俊鎭紙閫夊~锛�" 
+              <el-input
+                type="textarea"
+                v-model="form.remark"
+                placeholder="璇疯緭鍏ュ娉ㄤ俊鎭紙閫夊~锛�"
                 :rows="4"
                 maxlength="500"
                 show-word-limit
@@ -270,7 +270,7 @@
           <span style="font-size: 18px; color: #e6a23c; font-weight: bold;">楼{{ currentQuotation.totalAmount?.toFixed(2) }}</span>
         </el-descriptions-item>
       </el-descriptions>
-      
+
       <div style="margin: 20px 0;">
         <h4>浜у搧鏄庣粏</h4>
         <el-table :data="currentQuotation.products" border style="width: 100%">
@@ -300,7 +300,6 @@
 import Pagination from '@/components/PIMTable/Pagination.vue'
 import FormDialog from '@/components/Dialog/FormDialog.vue'
 import {getQuotationList,addQuotation,updateQuotation,deleteQuotation} from '@/api/salesManagement/salesQuotation.js'
-import {customerList} from "@/api/salesManagement/salesLedger.js";
 import {modelList, productTreeList} from "@/api/basicData/product.js";
 import {listCustomer} from "@/api/basicData/customer.js";
 import { userListNoPage } from "@/api/system/user.js";
@@ -316,7 +315,7 @@
 const quotationList = ref([])
 const userList = ref([])
 const productOptions = ref([]);
-const modelOptions = ref([]);
+const modelOptions  = ref([]);
 const pagination = reactive({
   total: 3,
   currentPage: 1,
@@ -328,7 +327,8 @@
 const dialogTitle = ref('鏂板鎶ヤ环')
 const form = reactive({
   quotationNo: '',
-  customerId: '',
+  customerId: undefined,
+  customer: '',
   salesperson: '',
   quotationDate: '',
   validDate: '',
@@ -354,7 +354,7 @@
 
 const productRowRules = {
   productId: [{ required: true, message: '璇烽�夋嫨浜у搧鍚嶇О', trigger: 'change' }],
-  specificationId: [{ required: true, message: '璇烽�夋嫨瑙勬牸鍨嬪彿', trigger: 'change' }],
+  productModelId: [{ required: true, message: '璇烽�夋嫨瑙勬牸鍨嬪彿', trigger: 'change' }],
   unit: [{ required: true, message: '璇峰~鍐欏崟浣�', trigger: 'blur' }],
   unitPrice: [{ required: true, message: '璇峰~鍐欏崟浠�', trigger: 'change' }]
 }
@@ -362,7 +362,7 @@
   const r = { ...baseRules }
   ;(form.products || []).forEach((_, i) => {
     r[`products.${i}.productId`] = productRowRules.productId
-    r[`products.${i}.specificationId`] = productRowRules.specificationId
+    r[`products.${i}.productModelId`] = productRowRules.productModelId
     r[`products.${i}.unit`] = productRowRules.unit
     r[`products.${i}.unitPrice`] = productRowRules.unitPrice
   })
@@ -407,6 +407,11 @@
   resetForm()
   dialogVisible.value = true
   getProductOptions();
+  fetchCustomerOptions()
+}
+
+const fetchCustomerOptions = () => {
+  if (customerOption.value.length > 0) return
   listCustomer({current: -1,size:-1, type: 0}).then((res) => {
     customerOption.value = res.data.records;
   });
@@ -428,7 +433,7 @@
 		if (children && children.length > 0) {
 			newItem.children = convertIdToValue(children);
 		}
-		
+
 		return newItem;
 	});
 }
@@ -452,7 +457,7 @@
 		row.productId = '';
 		row.product = '';
 		row.modelOptions = [];
-		row.specificationId = '';
+		row.productModelId = '';
 		row.specification = '';
 		row.unit = '';
 		return;
@@ -473,13 +478,13 @@
 	if (!row) return;
 	// 濡傛灉娓呯┖閫夋嫨锛屽垯娓呯┖鐩稿叧瀛楁
 	if (!value) {
-		row.specificationId = '';
+		row.productModelId = '';
 		row.specification = '';
 		row.unit = '';
 		return;
 	}
-	// 鏇存柊 specificationId锛坴-model 宸茬粡鑷姩鏇存柊锛岃繖閲岀‘淇濅竴鑷存�э級
-	row.specificationId = value;
+	// 鏇存柊 productModelId锛坴-model 宸茬粡鑷姩鏇存柊锛岃繖閲岀‘淇濅竴鑷存�э級
+	row.productModelId = value;
 	const modelOptions = row.modelOptions || [];
 	const index = modelOptions.findIndex((item) => item.id === value);
 	if (index !== -1) {
@@ -518,7 +523,7 @@
     products: row.products ? row.products.map(product => ({
       productId: product.productId || '',
       product: product.product || product.productName || '',
-      specificationId: product.specificationId || '',
+      productModelId: product.productModelId || '',
       specification: product.specification || '',
       quantity: product.quantity || 0,
       unit: product.unit || '',
@@ -537,10 +542,12 @@
   form.id = row.id || form.id || null
   // 鍏堝姞杞戒骇鍝佹爲鏁版嵁锛屽惁鍒� el-tree-select 鏃犳硶鍙嶆樉浜у搧鍚嶇О
   await getProductOptions()
+  await fetchCustomerOptions()
 
   // 鍙鍒堕渶瑕佺殑瀛楁锛岄伩鍏嶅皢缁勪欢寮曠敤鏀惧叆鍝嶅簲寮忓璞�
   form.quotationNo = row.quotationNo || ''
   form.customer = row.customer || ''
+  form.customerId = row.customerId || undefined
   form.salesperson = row.salesperson || ''
   form.quotationDate = row.quotationDate || ''
   form.validDate = row.validDate || ''
@@ -553,32 +560,32 @@
     const resolvedProductId = product.productId
       ? Number(product.productId)
       : findNodeIdByLabel(productOptions.value, productName) || ''
-    
+
     // 濡傛灉鏈変骇鍝両D锛屽姞杞藉搴旂殑瑙勬牸鍨嬪彿鍒楄〃
     let modelOptions = [];
-    let resolvedSpecificationId = product.specificationId || '';
-    
+    let resolvedProductModelId = product.productModelId || '';
+
     if (resolvedProductId) {
       try {
         const res = await modelList({ id: resolvedProductId });
         modelOptions = res || [];
-        
-        // 濡傛灉杩斿洖鐨勬暟鎹病鏈� specificationId锛屼絾鏈� specification 鍚嶇О锛屾牴鎹悕绉版煡鎵� ID
-        if (!resolvedSpecificationId && product.specification) {
+
+        // 濡傛灉杩斿洖鐨勬暟鎹病鏈� productModelId锛屼絾鏈� specification 鍚嶇О锛屾牴鎹悕绉版煡鎵� ID
+        if (!resolvedProductModelId && product.specification) {
           const foundModel = modelOptions.find(item => item.model === product.specification);
           if (foundModel) {
-            resolvedSpecificationId = foundModel.id;
+            resolvedProductModelId = foundModel.id;
           }
         }
       } catch (error) {
         console.error('鍔犺浇瑙勬牸鍨嬪彿澶辫触:', error);
       }
     }
-    
+
     return {
       productId: resolvedProductId,
       product: productName,
-      specificationId: resolvedSpecificationId,
+      productModelId: resolvedProductModelId,
       specification: product.specification || '',
       quantity: product.quantity || 0,
       unit: product.unit || '',
@@ -642,8 +649,7 @@
     productId: '',
     product: '',
     productName: '',
-    specificationId: '',
-    specification: '',
+    productModelId: '',
     quantity: 1,
     unit: '',
     unitPrice: 0,
@@ -736,6 +742,7 @@
         id: item.id,
         quotationNo: item.quotationNo || '',
         customer: item.customer || '',
+        customerId: item.customerId || undefined,
         salesperson: item.salesperson || '',
         quotationDate: item.quotationDate || '',
         validDate: item.validDate || '',
@@ -747,7 +754,7 @@
         products: item.products ? item.products.map(product => ({
           productId: product.productId || '',
           product: product.product || product.productName || '',
-          specificationId: product.specificationId || '',
+          productModelId: product.productModelId || '',
           specification: product.specification || '',
           quantity: product.quantity || 0,
           unit: product.unit || '',
@@ -782,6 +789,7 @@
 onMounted(()=>{
   getUserList()
   handleSearch()
+  fetchCustomerOptions()
 })
 </script>
 
@@ -794,16 +802,16 @@
   padding: 10px 0;
   max-height: calc(100vh - 200px);
   overflow-y: auto;
-  
+
   &::-webkit-scrollbar {
     width: 6px;
     height: 6px;
   }
-  
+
   &::-webkit-scrollbar-thumb {
     background: #c1c1c1;
     border-radius: 3px;
-    
+
     &:hover {
       background: #a8a8a8;
     }
@@ -820,17 +828,17 @@
   margin-bottom: 24px;
   border-radius: 8px;
   transition: all 0.3s ease;
-  
+
   &:hover {
     box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08) !important;
   }
-  
+
   :deep(.el-card__header) {
     padding: 16px 20px;
     background: linear-gradient(135deg, #f5f7fa 0%, #ffffff 100%);
     border-bottom: 1px solid #ebeef5;
   }
-  
+
   :deep(.el-card__body) {
     padding: 20px;
   }
@@ -840,19 +848,19 @@
   display: flex;
   align-items: center;
   gap: 8px;
-  
+
   .card-icon {
     font-size: 18px;
     color: #409eff;
   }
-  
+
   .card-title {
     font-weight: 600;
     font-size: 16px;
     color: #303133;
     flex: 1;
   }
-  
+
   .header-btn {
     margin-left: auto;
   }
@@ -876,20 +884,20 @@
 .product-table {
   :deep(.el-table__header) {
     background-color: #f5f7fa;
-    
+
     th {
       background-color: #f5f7fa !important;
       color: #606266;
       font-weight: 600;
     }
   }
-  
+
   :deep(.el-table__row) {
     &:hover {
       background-color: #f5f7fa;
     }
   }
-  
+
   :deep(.el-table__cell) {
     padding: 12px 0;
   }

--
Gitblit v1.9.3