From 3145a4847f8dbd378c932e9bacb0376fd3fe1e54 Mon Sep 17 00:00:00 2001
From: gaoluyang <2820782392@qq.com>
Date: 星期五, 03 四月 2026 11:10:06 +0800
Subject: [PATCH] 军泰伟业 1.部署修改

---
 src/views/salesManagement/salesQuotation/index.vue |  208 ++++++++++++++++++++++++---------------------------
 1 files changed, 99 insertions(+), 109 deletions(-)

diff --git a/src/views/salesManagement/salesQuotation/index.vue b/src/views/salesManagement/salesQuotation/index.vue
index d6f6c80..24147ae 100644
--- a/src/views/salesManagement/salesQuotation/index.vue
+++ b/src/views/salesManagement/salesQuotation/index.vue
@@ -229,45 +229,28 @@
           </template>
           <div class="form-content">
             <el-table :data="form.products" border style="width: 100%" class="product-table" v-if="form.products.length > 0">
-            <el-table-column prop="product" label="浜у搧鍚嶇О" width="200">
+            <el-table-column prop="product" label="浜у搧鍚嶇О" width="220">
               <template #default="scope">
-								<el-tree-select
-									v-model="scope.row.productId"
-									placeholder="璇烽�夋嫨"
-									clearable
-									check-strictly
-									@change="getModels($event, scope.row)"
-									:data="productOptions"
-									:render-after-expand="false"
-									style="width: 100%"
-								/>
+                <span>{{ scope.row.product || scope.row.productName || '--' }}</span>
               </template>
             </el-table-column>
-            <el-table-column prop="specification" label="瑙勬牸鍨嬪彿" width="150">
+            <el-table-column prop="specification" label="鍥剧焊缂栧彿" width="220">
               <template #default="scope">
-								<el-select
-									v-model="scope.row.specificationId"
-									placeholder="璇烽�夋嫨"
-									clearable
-									@change="getProductModel($event, scope.row)"
-								>
-									<el-option
-										v-for="item in scope.row.modelOptions || []"
-										:key="item.id"
-										:label="item.model"
-										:value="item.id"
-									/>
-								</el-select>
+                <span>{{ scope.row.specification || '--' }}</span>
               </template>
             </el-table-column>
             <el-table-column prop="unit" label="鍗曚綅">
               <template #default="scope">
-                <el-input v-model="scope.row.unit" placeholder="鍗曚綅" />
+                <el-form-item :prop="`products.${scope.$index}.unit`" class="product-table-form-item">
+                  <el-input v-model="scope.row.unit" placeholder="鍗曚綅" clearable/>
+                </el-form-item>
               </template>
             </el-table-column>
             <el-table-column prop="unitPrice" label="鍗曚环">
               <template #default="scope">
-                <el-input-number v-model="scope.row.unitPrice" :min="0" :precision="2" style="width: 100%" />
+                <el-form-item :prop="`products.${scope.$index}.unitPrice`" class="product-table-form-item">
+                  <el-input-number v-model="scope.row.unitPrice" :min="0.01" :precision="2" :step="0.01" style="width: 100%" />
+                </el-form-item>
               </template>
             </el-table-column>
             <el-table-column label="鎿嶄綔" width="80" align="center">
@@ -305,6 +288,12 @@
       </div>
     </FormDialog>
 
+    <ProductSelectDialog
+      v-model="productSelectVisible"
+      :single="true"
+      @confirm="handleProductSelectConfirm"
+    />
+
     <!-- 鏌ョ湅璇︽儏瀵硅瘽妗� -->
     <el-dialog v-model="viewDialogVisible" title="鎶ヤ环璇︽儏" width="800px">
       <el-descriptions :column="2" border>
@@ -326,7 +315,7 @@
         <h4>浜у搧鏄庣粏</h4>
         <el-table :data="currentQuotation.products" border style="width: 100%">
           <el-table-column prop="product" label="浜у搧鍚嶇О" />
-          <el-table-column prop="specification" label="瑙勬牸鍨嬪彿" />
+          <el-table-column prop="specification" label="鍥剧焊缂栧彿" />
           <el-table-column prop="unit" label="鍗曚綅" />
           <el-table-column prop="unitPrice" label="鍗曚环">
             <template #default="scope">
@@ -350,6 +339,7 @@
 import { Search, Document, UserFilled, Box, EditPen, Plus, ArrowRight, Delete } from '@element-plus/icons-vue'
 import Pagination from '@/components/PIMTable/Pagination.vue'
 import FormDialog from '@/components/Dialog/FormDialog.vue'
+import ProductSelectDialog from '@/views/basicData/product/ProductSelectDialog.vue'
 import {getQuotationList,addQuotation,updateQuotation,deleteQuotation} from '@/api/salesManagement/salesQuotation.js'
 import {userListNoPage} from "@/api/system/user.js";
 import {customerList} from "@/api/salesManagement/salesLedger.js";
@@ -365,7 +355,6 @@
 
 const quotationList = ref([])
 const productOptions = ref([]);
-const modelOptions = ref([]);
 const pagination = reactive({
   total: 3,
   currentPage: 1,
@@ -374,6 +363,8 @@
 
 const dialogVisible = ref(false)
 const viewDialogVisible = ref(false)
+const productSelectVisible = ref(false)
+const activeProductIndex = ref(-1)
 const dialogTitle = ref('鏂板鎶ヤ环')
 const form = reactive({
   quotationNo: '',
@@ -393,13 +384,30 @@
   totalAmount: 0
 })
 
-const rules = {
+const baseRules = {
   customer: [{ required: true, message: '璇烽�夋嫨瀹㈡埛', trigger: 'change' }],
   salesperson: [{ required: true, message: '璇烽�夋嫨涓氬姟鍛�', trigger: 'change' }],
   quotationDate: [{ required: true, message: '璇烽�夋嫨鎶ヤ环鏃ユ湡', trigger: 'change' }],
   validDate: [{ required: true, message: '璇烽�夋嫨鏈夋晥鏈�', trigger: 'change' }],
   paymentMethod: [{ required: true, message: '璇疯緭鍏ヤ粯娆炬柟寮�', trigger: 'blur' }]
 }
+
+const productRowRules = {
+  productId: [{ required: true, message: '璇烽�夋嫨浜у搧鍚嶇О', trigger: 'change' }],
+  specificationId: [{ required: true, message: '璇烽�夋嫨瑙勬牸鍨嬪彿', trigger: 'change' }],
+  unit: [{ required: true, message: '璇峰~鍐欏崟浣�', trigger: 'blur' }],
+  unitPrice: [{ required: true, message: '璇峰~鍐欏崟浠�', trigger: 'change' }]
+}
+const rules = computed(() => {
+  const r = { ...baseRules }
+  ;(form.products || []).forEach((_, i) => {
+    r[`products.${i}.productId`] = productRowRules.productId
+    r[`products.${i}.specificationId`] = productRowRules.specificationId
+    r[`products.${i}.unit`] = productRowRules.unit
+    r[`products.${i}.unitPrice`] = productRowRules.unitPrice
+  })
+  return r
+})
 const userList = ref([]);
 const customerOption = ref([]);
 
@@ -515,65 +523,6 @@
 	}
 	return null;
 }
-const getModels = (value, row) => {
-	if (!row) return;
-	// 濡傛灉娓呯┖閫夋嫨锛屽垯娓呯┖鐩稿叧瀛楁
-	if (!value) {
-		row.productId = '';
-		row.product = '';
-		row.modelOptions = [];
-		row.specificationId = '';
-		row.specification = '';
-		row.unit = '';
-		return;
-	}
-	// 鏇存柊 productId锛坴-model 宸茬粡鑷姩鏇存柊锛岃繖閲岀‘淇濅竴鑷存�э級
-	row.productId = value;
-	// 鎵惧埌瀵瑰簲鐨� label 骞惰祴鍊肩粰 row.product
-	const label = findNodeById(productOptions.value, value);
-	if (label) {
-		row.product = label;
-	}
-	// 鑾峰彇瑙勬牸鍨嬪彿鍒楄〃锛岃缃埌褰撳墠琛岀殑 modelOptions
-	modelList({ id: value }).then((res) => {
-		row.modelOptions = res || [];
-	});
-};
-const getProductModel = (value, row) => {
-	if (!row) return;
-	// 濡傛灉娓呯┖閫夋嫨锛屽垯娓呯┖鐩稿叧瀛楁
-	if (!value) {
-		row.specificationId = '';
-		row.specification = '';
-		row.unit = '';
-		return;
-	}
-	// 鏇存柊 specificationId锛坴-model 宸茬粡鑷姩鏇存柊锛岃繖閲岀‘淇濅竴鑷存�э級
-	row.specificationId = value;
-	const modelOptions = row.modelOptions || [];
-	const index = modelOptions.findIndex((item) => item.id === value);
-	if (index !== -1) {
-		row.specification = modelOptions[index].model;
-		row.unit = modelOptions[index].unit;
-	} else {
-		row.specification = '';
-		row.unit = '';
-	}
-};
-const findNodeById = (nodes, productId) => {
-	for (let i = 0; i < nodes.length; i++) {
-		if (nodes[i].value === productId) {
-			return nodes[i].label; // 鎵惧埌鑺傜偣锛岃繑鍥� label
-		}
-		if (nodes[i].children && nodes[i].children.length > 0) {
-			const foundLabel = findNodeById(nodes[i].children, productId);
-			if (foundLabel) {
-				return foundLabel; // 鍦ㄥ瓙鑺傜偣涓壘鍒帮紝杩斿洖 label
-			}
-		}
-	}
-	return null; // 娌℃湁鎵惧埌鑺傜偣锛岃繑鍥瀗ull
-};
 const handleView = (row) => {
   // 鍙鍒堕渶瑕佺殑瀛楁锛岄伩鍏嶅皢缁勪欢寮曠敤鏀惧叆鍝嶅簲寮忓璞�
   currentQuotation.value = {
@@ -729,23 +678,51 @@
 }
 
 const addProduct = () => {
-  form.products.push({
-    productId: '',
-    product: '',
-    productName: '',
-    specificationId: '',
-    specification: '',
-    quantity: 1,
-    unit: '',
-    unitPrice: 0,
-    amount: 0,
-    modelOptions: [] // 涓烘瘡琛屾坊鍔犵嫭绔嬬殑瑙勬牸鍨嬪彿鍒楄〃
-  })
+  activeProductIndex.value = -1
+  productSelectVisible.value = true
 }
 
 const removeProduct = (index) => {
   form.products.splice(index, 1)
   calculateSubtotal()
+}
+
+const handleProductSelectConfirm = (rows) => {
+  if (!rows || rows.length === 0 || activeProductIndex.value < 0) {
+    if (!rows || rows.length === 0) {
+      return
+    }
+    const selected = rows[0]
+    form.products.push({
+      productId: selected.id,
+      product: selected.productName || '',
+      productName: selected.productName || '',
+      specificationId: selected.id,
+      specification: selected.model || '',
+      quantity: 1,
+      unit: selected.unit || '',
+    unitPrice: 0.01,
+      amount: 0,
+      modelOptions: [],
+    })
+    calculateSubtotal()
+    activeProductIndex.value = -1
+    return
+  }
+
+  const row = form.products[activeProductIndex.value]
+  if (!row) {
+    return
+  }
+
+  const selected = rows[0]
+  row.productId = selected.id
+  row.product = selected.productName || ''
+  row.productName = selected.productName || ''
+  row.specificationId = selected.id
+  row.specification = selected.model || ''
+  row.unit = selected.unit || row.unit || ''
+  calculateAmount(row)
 }
 
 const calculateAmount = (product) => {
@@ -774,16 +751,18 @@
         ElMessage.warning('璇疯嚦灏戞坊鍔犱竴涓骇鍝�')
         return
       }
-      
-      // 瀹℃壒浜哄繀濉牎楠�
-      const hasEmptyApprover = approverNodes.value.some(node => !node.userId)
-      if (hasEmptyApprover) {
-        ElMessage.error('璇蜂负鎵�鏈夊鎵硅妭鐐归�夋嫨瀹℃壒浜猴紒')
+
+      const hasInvalidPrice = form.products.some(product => Number(product.unitPrice) <= 0)
+      if (hasInvalidPrice) {
+        ElMessage.error('鍗曚环蹇呴』澶т簬0')
         return
       }
-      
-      // 鏀堕泦鎵�鏈夎妭鐐圭殑瀹℃壒浜篿d
-      form.approveUserIds = approverNodes.value.map(node => node.userId).join(',')
+
+      // 鏀堕泦鎵�鏈夎妭鐐圭殑瀹℃壒浜篿d锛屽厑璁镐负绌�
+      form.approveUserIds = approverNodes.value
+        .map(node => node.userId)
+        .filter(userId => userId !== null && userId !== undefined && userId !== '')
+        .join(',')
       
       // 璁$畻鎵�鏈変骇鍝佺殑鍗曚环鎬诲拰
       form.totalAmount = form.products.reduce((sum, product) => {
@@ -956,6 +935,17 @@
   padding: 8px 0;
 }
 
+.product-table-form-item {
+  margin-bottom: 0;
+  :deep(.el-form-item__content) {
+    margin-left: 0 !important;
+  }
+  :deep(.el-form-item__label) {
+    width: auto;
+    min-width: auto;
+  }
+}
+
 .approver-nodes-container {
   display: flex;
   flex-wrap: wrap;

--
Gitblit v1.9.3