From 377c0a70c094d024aeb0bb94f4b791c6d5530c1e Mon Sep 17 00:00:00 2001
From: gaoluyang <2820782392@qq.com>
Date: 星期四, 06 八月 2026 10:21:55 +0800
Subject: [PATCH] 新疆_马铃薯 1.不合格管理添加拒收逻辑
---
src/views/salesManagement/salesQuotation/index.vue | 200 ++++++++++++++++++++++++++++++++-----------------
1 files changed, 130 insertions(+), 70 deletions(-)
diff --git a/src/views/salesManagement/salesQuotation/index.vue b/src/views/salesManagement/salesQuotation/index.vue
index 687b6d1..9dece6c 100644
--- a/src/views/salesManagement/salesQuotation/index.vue
+++ b/src/views/salesManagement/salesQuotation/index.vue
@@ -16,8 +16,8 @@
</el-input>
</el-col>
<el-col :span="8">
- <el-select v-model="searchForm.customer" placeholder="璇烽�夋嫨瀹㈡埛" clearable>
- <el-option v-for="item in customerOption" :key="item.id" :label="item.customerName" :value="item.customerName">
+ <el-select v-model="searchForm.customerId" placeholder="璇烽�夋嫨瀹㈡埛" clearable>
+ <el-option v-for="item in customerOption" :key="item.id" :label="item.customerName" :value="item.id">
{{
item.customerName + "鈥斺��" + item.taxpayerIdentificationNumber
}}
@@ -52,6 +52,7 @@
>
<el-table-column align="center" label="搴忓彿" type="index" width="60" />
<el-table-column prop="quotationNo" label="鎶ヤ环鍗曞彿" />
+ <el-table-column prop="masterContractNo" label="鎬诲悎鍚屽彿" width="150" show-overflow-tooltip />
<el-table-column prop="customer" label="瀹㈡埛鍚嶇О" />
<el-table-column prop="salesperson" label="涓氬姟鍛�" width="100" />
<el-table-column prop="quotationDate" label="鎶ヤ环鏃ユ湡" width="120" />
@@ -70,9 +71,9 @@
</el-table-column>
<el-table-column label="鎿嶄綔" width="200" fixed="right" align="center">
<template #default="scope">
- <el-button link type="primary" @click="handleEdit(scope.row)" :disabled="!['寰呭鎵�','鎷掔粷'].includes(scope.row.status)">缂栬緫</el-button>
+ <el-button link type="primary" @click="handleEdit(scope.row)">缂栬緫</el-button>
<el-button link type="primary" @click="handleView(scope.row)" style="color: #67C23A">鏌ョ湅</el-button>
- <el-button link type="danger" @click="handleDelete(scope.row)">鍒犻櫎</el-button>
+ <el-button link type="danger" @click="handleDelete(scope.row)" v-hasPermi="['salesManagement:salesQuotation:remove']">鍒犻櫎</el-button>
</template>
</el-table-column>
</el-table>
@@ -102,12 +103,21 @@
<div class="form-content">
<el-row :gutter="24">
<el-col :span="12">
- <el-form-item label="瀹㈡埛鍚嶇О" prop="customer">
- <el-select v-model="form.customer" placeholder="璇烽�夋嫨瀹㈡埛" style="width: 100%" clearable filterable>
+ <el-form-item label="瀹㈡埛鍚嶇О" prop="customerId">
+ <el-select v-model="form.customerId" placeholder="璇烽�夋嫨瀹㈡埛" style="width: 100%" clearable filterable @change="handleCustomerChange">
<el-option v-for="item in customerOption" :key="item.id" :label="item.customerName" :value="item.id"></el-option>
</el-select>
</el-form-item>
</el-col>
+ <el-col :span="12">
+ <el-form-item label="鎬诲悎鍚屽彿">
+ <el-select v-model="form.masterContractNo" placeholder="璇峰厛閫夋嫨瀹㈡埛" style="width: 100%" clearable filterable :disabled="!form.customerId">
+ <el-option v-for="item in contractList" :key="item.id" :label="item.masterContractNo" :value="item.masterContractNo"></el-option>
+ </el-select>
+ </el-form-item>
+ </el-col>
+ </el-row>
+ <el-row :gutter="24">
<el-col :span="12">
<el-form-item label="涓氬姟鍛�" prop="salesperson">
<el-select v-model="form.salesperson" placeholder="璇烽�夋嫨涓氬姟鍛�" style="width: 100%" clearable filterable>
@@ -148,7 +158,13 @@
<el-row :gutter="24">
<el-col :span="12">
<el-form-item label="浠樻鏂瑰紡" prop="paymentMethod">
- <el-input v-model="form.paymentMethod" placeholder="璇疯緭鍏ヤ粯娆炬柟寮�" clearable />
+ <el-select v-model="form.paymentMethod" placeholder="璇烽�夋嫨浠樻鏂瑰紡" clearable style="width: 100%">
+ <el-option label="鐜伴噾" value="鐜伴噾" />
+ <el-option label="鐢垫眹" value="鐢垫眹" />
+ <el-option label="寰俊" value="寰俊" />
+ <el-option label="鏀粯瀹�" value="鏀粯瀹�" />
+ <el-option label="鏀エ" value="鏀エ" />
+ </el-select>
</el-form-item>
</el-col>
</el-row>
@@ -187,9 +203,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 +255,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
@@ -258,6 +274,7 @@
<el-dialog v-model="viewDialogVisible" title="鎶ヤ环璇︽儏" width="800px">
<el-descriptions :column="2" border>
<el-descriptions-item label="鎶ヤ环鍗曞彿">{{ currentQuotation.quotationNo }}</el-descriptions-item>
+ <el-descriptions-item label="鎬诲悎鍚屽彿">{{ currentQuotation.masterContractNo || '--' }}</el-descriptions-item>
<el-descriptions-item label="瀹㈡埛鍚嶇О">{{ currentQuotation.customer }}</el-descriptions-item>
<el-descriptions-item label="涓氬姟鍛�">{{ currentQuotation.salesperson }}</el-descriptions-item>
<el-descriptions-item label="鎶ヤ环鏃ユ湡">{{ currentQuotation.quotationDate }}</el-descriptions-item>
@@ -270,7 +287,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%">
@@ -301,14 +318,15 @@
import FormDialog from '@/components/Dialog/FormDialog.vue'
import {getQuotationList,addQuotation,updateQuotation,deleteQuotation} from '@/api/salesManagement/salesQuotation.js'
import {modelList, productTreeList} from "@/api/basicData/product.js";
-import {listCustomerPrivatePool} from "@/api/basicData/customerFile.js";
+import {listCustomer} from "@/api/basicData/customer.js";
import { userListNoPage } from "@/api/system/user.js";
+import { getCustomerContractList } from "@/api/basicData/customerContract.js";
// 鍝嶅簲寮忔暟鎹�
const loading = ref(false)
const searchForm = reactive({
quotationNo: '',
- customer: '',
+ customerId: '',
status: ''
})
@@ -316,6 +334,7 @@
const userList = ref([])
const productOptions = ref([]);
const modelOptions = ref([]);
+const contractList = ref([]);
const pagination = reactive({
total: 3,
currentPage: 1,
@@ -327,6 +346,7 @@
const dialogTitle = ref('鏂板鎶ヤ环')
const form = reactive({
quotationNo: '',
+ customerId: undefined,
customer: '',
salesperson: '',
quotationDate: '',
@@ -334,12 +354,10 @@
paymentMethod: '',
status: '鑽夌',
remark: '',
+ masterContractNo: '',
products: [],
subtotal: 0,
freight: 0,
- otherFee: 0,
- discountRate: 0,
- discountAmount: 0,
totalAmount: 0
})
@@ -348,12 +366,12 @@
salesperson: [{ required: true, message: '璇烽�夋嫨涓氬姟鍛�', trigger: 'change' }],
quotationDate: [{ required: true, message: '璇烽�夋嫨鎶ヤ环鏃ユ湡', trigger: 'change' }],
validDate: [{ required: true, message: '璇烽�夋嫨鏈夋晥鏈�', trigger: 'change' }],
- paymentMethod: [{ required: true, message: '璇疯緭鍏ヤ粯娆炬柟寮�', trigger: 'blur' }]
+ paymentMethod: [{ required: true, message: '璇烽�夋嫨浠樻鏂瑰紡', trigger: 'change' }]
}
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' }]
}
@@ -361,7 +379,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
})
@@ -377,6 +395,7 @@
// 璁$畻灞炴��
const filteredList = computed(() => {
let list = quotationList.value
+ console.log(list)
return list
})
@@ -400,19 +419,38 @@
handleSearch()
}
-const loadCustomerOptions = async () => {
- const res = await listCustomerPrivatePool({ current: -1, size: -1 });
- customerOption.value = res?.data?.records || [];
-}
-
const handleAdd = async () => {
dialogTitle.value = '鏂板鎶ヤ环'
isEdit.value = false
resetForm()
dialogVisible.value = true
getProductOptions();
- loadCustomerOptions();
+ fetchCustomerOptions()
}
+
+const fetchCustomerOptions = () => {
+ if (customerOption.value.length > 0) return
+ listCustomer({current: -1,size:-1, type: 0}).then((res) => {
+ customerOption.value = res.data.records;
+ });
+}
+
+// 瀹㈡埛閫夋嫨鍙樺寲鏃讹紝鍔犺浇璇ュ鎴风殑鍚堝悓鍒楄〃
+const handleCustomerChange = async (customerId) => {
+ form.masterContractNo = '';
+ contractList.value = [];
+ if (!customerId) return;
+
+ try {
+ const res = await getCustomerContractList(customerId);
+ if (res.code === 200) {
+ contractList.value = res.data || [];
+ }
+ } catch (error) {
+ console.error('鑾峰彇瀹㈡埛鍚堝悓鍒楄〃澶辫触:', error);
+ }
+};
+
const getProductOptions = () => {
// 杩斿洖 Promise锛屼究浜庣紪杈戞椂 await 纭繚鑳藉弽鏄�
return productTreeList().then((res) => {
@@ -430,7 +468,7 @@
if (children && children.length > 0) {
newItem.children = convertIdToValue(children);
}
-
+
return newItem;
});
}
@@ -454,7 +492,7 @@
row.productId = '';
row.product = '';
row.modelOptions = [];
- row.specificationId = '';
+ row.productModelId = '';
row.specification = '';
row.unit = '';
return;
@@ -475,13 +513,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) {
@@ -515,12 +553,13 @@
quotationDate: row.quotationDate || '',
validDate: row.validDate || '',
paymentMethod: row.paymentMethod || '',
+ masterContractNo: row.masterContractNo || '',
status: row.status || '',
remark: row.remark || '',
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 || '',
@@ -539,48 +578,66 @@
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 || ''
form.paymentMethod = row.paymentMethod || ''
form.status = row.status || '鑽夌'
form.remark = row.remark || ''
+
+ // 缂栬緫鏃跺姞杞藉鎴风殑鍚堝悓鍒楄〃浠ヤ究鍥炴樉鎬诲悎鍚屽彿
+ if (row.customerId) {
+ try {
+ const contractRes = await getCustomerContractList(row.customerId);
+ if (contractRes.code === 200) {
+ contractList.value = contractRes.data || [];
+ }
+ } catch (error) {
+ console.error('鑾峰彇瀹㈡埛鍚堝悓鍒楄〃澶辫触:', error);
+ }
+ }
+
+ // 鍏煎鍚庣杩斿洖鐨� masterContractNo 鎴� master_contract_no锛屾斁鍦ㄥ悎鍚屽垪琛ㄥ姞杞藉悗璁剧疆
+ form.masterContractNo = row.masterContractNo || row.master_contract_no || ''
+
form.products = row.products ? await Promise.all(row.products.map(async (product) => {
const productName = product.product || product.productName || ''
// 浼樺厛鐢� productId锛涘鏋滃彧鏈夊悕绉帮紝灏濊瘯鍙嶆煡 id 浠ヤ究鏍戦�夋嫨鍣ㄥ弽鏄�
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 || '',
@@ -590,10 +647,6 @@
}
})) : []
form.subtotal = row.subtotal || 0
- form.freight = row.freight || 0
- form.otherFee = row.otherFee || 0
- form.discountRate = row.discountRate || 0
- form.discountAmount = row.discountAmount || 0
form.totalAmount = row.totalAmount || 0
dialogVisible.value = true
@@ -630,13 +683,13 @@
form.paymentMethod = ''
form.status = '鑽夌'
form.remark = ''
+ form.masterContractNo = ''
form.products = []
form.subtotal = 0
form.freight = 0
form.otherFee = 0
- form.discountRate = 0
- form.discountAmount = 0
form.totalAmount = 0
+ contractList.value = []
}
const addProduct = () => {
@@ -644,8 +697,7 @@
productId: '',
product: '',
productName: '',
- specificationId: '',
- specification: '',
+ productModelId: '',
quantity: 1,
unit: '',
unitPrice: 0,
@@ -688,11 +740,20 @@
return sum + price
}, 0)
+ form.customer = customerOption.value.find(item => item.id === form.customerId)?.customerName || ''
+
+ // 鍓旈櫎 products 涓殑 modelOptions 瀛楁锛屼互鍙� form 涓殑 subtotal銆乫reight 瀛楁
+ const { subtotal, freight, ...formWithoutSubtotal } = form
+ const submitData = {
+ ...formWithoutSubtotal,
+ products: form.products.map(({ modelOptions, ...rest }) => rest)
+ }
+
if (isEdit.value) {
// 缂栬緫
const index = quotationList.value.findIndex(item => item.id === editId.value)
if (index > -1) {
- updateQuotation(form).then(res=>{
+ updateQuotation(submitData).then(res=>{
// console.log(res)
if(res.code===200){
ElMessage.success('缂栬緫鎴愬姛')
@@ -703,7 +764,7 @@
}
} else {
// 鏂板
- addQuotation(form).then(res=>{
+ addQuotation(submitData).then(res=>{
if(res.code===200){
ElMessage.success('鏂板鎴愬姛')
dialogVisible.value = false
@@ -737,7 +798,9 @@
id: item.id,
quotationNo: item.quotationNo || '',
customer: item.customer || '',
+ customerId: item.customerId || undefined,
salesperson: item.salesperson || '',
+ masterContractNo: item.masterContractNo || '',
quotationDate: item.quotationDate || '',
validDate: item.validDate || '',
paymentMethod: item.paymentMethod || '',
@@ -748,7 +811,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 || '',
@@ -757,9 +820,6 @@
})) : [],
subtotal: item.subtotal || 0,
freight: item.freight || 0,
- otherFee: item.otherFee || 0,
- discountRate: item.discountRate || 0,
- discountAmount: item.discountAmount || 0,
totalAmount: item.totalAmount || 0
}))
pagination.total = res.data.total
@@ -782,8 +842,8 @@
onMounted(()=>{
getUserList()
- loadCustomerOptions()
handleSearch()
+ fetchCustomerOptions()
})
</script>
@@ -796,16 +856,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;
}
@@ -822,17 +882,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;
}
@@ -842,19 +902,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;
}
@@ -878,20 +938,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