From 352fbcfaa09e261918f5a7b50bcd9ba15583b1aa Mon Sep 17 00:00:00 2001
From: gaoluyang <2820782392@qq.com>
Date: 星期五, 13 三月 2026 13:55:16 +0800
Subject: [PATCH] 军泰伟业 1.销售退货逻辑完善与联调
---
src/views/salesManagement/returnOrder/components/formDia.vue | 125 +++++++++++++++++++++++++++++++----------
1 files changed, 94 insertions(+), 31 deletions(-)
diff --git a/src/views/salesManagement/returnOrder/components/formDia.vue b/src/views/salesManagement/returnOrder/components/formDia.vue
index 82b3766..9f1bb9a 100644
--- a/src/views/salesManagement/returnOrder/components/formDia.vue
+++ b/src/views/salesManagement/returnOrder/components/formDia.vue
@@ -44,11 +44,6 @@
</el-form-item>
</el-col>
<el-col :span="4">
- <el-form-item label="椤圭洰闃舵锛�" prop="projectStage">
- <el-input v-model="form.projectStage" placeholder="椤圭洰闃舵" />
- </el-form-item>
- </el-col>
- <el-col :span="4">
<el-form-item label="鍒跺崟浜猴細" prop="maker">
<el-select v-model="form.maker" filterable placeholder="璇烽�夋嫨鍒跺崟浜�">
<el-option v-for="u in userOptions" :key="u.value" :label="u.label" :value="u.value" />
@@ -61,19 +56,21 @@
</el-form-item>
</el-col>
<el-col :span="4">
- <el-form-item label="缁撶畻浜猴細" prop="settler">
- <el-select v-model="form.settler" filterable placeholder="璇烽�夋嫨缁撶畻浜�">
- <el-option v-for="u in userOptions" :key="u.value" :label="u.label" :value="u.value" />
+ <el-form-item label="鐘舵�侊細" prop="status">
+ <el-select v-model="form.status" placeholder="璇烽�夋嫨鐘舵��">
+ <el-option label="寰呭鐞�" :value="0" />
+ <el-option label="宸插鐞�" :value="1" />
</el-select>
</el-form-item>
</el-col>
<el-col :span="4">
- <el-form-item label="鐘舵�侊細" prop="status">
- <el-select v-model="form.status" placeholder="璇烽�夋嫨鐘舵��">
- <el-option label="寰呭鏍�" :value="0" />
- <el-option label="瀹℃牳涓�" :value="1" />
- <el-option label="宸插鏍�" :value="2" />
- </el-select>
+ <el-form-item label="閫�璐у師鍥狅細" prop="returnReason">
+ <el-input v-model="form.returnReason" placeholder="璇疯緭鍏ラ��璐у師鍥�" />
+ </el-form-item>
+ </el-col>
+ <el-col :span="4">
+ <el-form-item label="閫�娆炬�婚锛�" prop="refundAmount">
+ <el-input v-model="form.refundAmount" disabled placeholder="鑷姩璁$畻" />
</el-form-item>
</el-col>
</el-row>
@@ -92,6 +89,37 @@
placeholder="璇疯緭鍏�"
type="number"
@input="(val) => handleReturnQuantityChange(val, row)"
+ />
+ </template>
+ <template #price="{ row }">
+ <el-input
+ v-model="row.price"
+ style="width:100px"
+ placeholder="璇疯緭鍏�"
+ type="number"
+ @input="(val) => handlePriceChange(val, row)"
+ />
+ </template>
+ <template #amount="{ row }">
+ <el-input
+ v-model="row.amount"
+ style="width:100px"
+ placeholder="鑷姩璁$畻"
+ type="number"
+ disabled
+ />
+ </template>
+ <template #isQuality="{ row }">
+ <el-select v-model="row.isQuality" placeholder="璇烽�夋嫨" style="width:120px">
+ <el-option label="鏄�" :value="1" />
+ <el-option label="鍚�" :value="2" />
+ </el-select>
+ </template>
+ <template #remark="{ row }">
+ <el-input
+ v-model="row.remark"
+ style="width:130px"
+ placeholder="璇疯緭鍏�"
/>
</template>
<template #action="{ row, index }">
@@ -159,11 +187,11 @@
customerId: "",
shippingId: "",
projectId: "",
- projectStage: "",
maker: "",
makeTime: "",
- settler: "",
status: 0,
+ returnReason: "",
+ refundAmount: "",
},
rules: {
returnNo: [{
@@ -194,6 +222,10 @@
{align: "center", label: "宸查��璐ф暟閲�", prop: "totalReturnNum", width: 120 },
{align: "center", label: "鏈��璐ф暟閲�", prop: "unQuantity", width: 120 },
{align: "center", label: "閫�璐ф暟閲�", prop: "returnQuantity", dataType: "slot", slot: "returnQuantity", width: 120 },
+ {align: "center", label: "閫�璐т骇鍝佸崟浠�", prop: "price", dataType: "slot", slot: "price", width: 120 },
+ {align: "center", label: "閫�璐т骇鍝侀噾棰�", prop: "amount", dataType: "slot", slot: "amount", width: 120 },
+ {align: "center", label: "鏄惁鏈夎川閲忛棶棰�", prop: "isQuality", dataType: "slot", slot: "isQuality", width: 140 },
+ {align: "center", label: "澶囨敞", prop: "remark", dataType: "slot", slot: "remark", width: 150 },
{align: "center", label: "鎿嶄綔" , prop: "action", dataType: "slot", slot: "action", width: 120 },
]);
const tableData = ref([]);
@@ -215,8 +247,13 @@
id: productId,
returnSaleProductId,
returnSaleLedgerProductId: productId,
+ productModelId: raw?.productModelId,
num,
returnQuantity: Number.isFinite(num) ? num : 0,
+ price: Number(raw?.taxInclusiveUnitPrice ?? raw?.price ?? 0),
+ amount: Number(raw?.amount ?? 0).toFixed(2),
+ isQuality: raw?.isQuality ?? 2,
+ remark: raw?.remark ?? "",
};
};
@@ -248,6 +285,8 @@
return product ? { ...product, ...normalized } : normalized;
})
: [];
+
+ calculateTotalRefund();
};
const openDialog = async (type, row) => {
@@ -265,11 +304,11 @@
customerId: "",
shippingId: "",
projectId: "",
- projectStage: "",
maker: "",
makeTime: "",
- settler: "",
status: 0,
+ returnReason: "",
+ refundAmount: "",
});
form.value.maker = userStore.nickName || userStore.name || "";
form.value.makeTime = new Date().toISOString().replace('T', ' ').split('.')[0]; // Default to now
@@ -282,7 +321,13 @@
if (!valid) return;
const returnSaleProducts = (tableData.value || []).map(el => ({
returnSaleLedgerProductId: el.returnSaleLedgerProductId ?? el.id,
+ productModelId: el.productModelId,
+ unit: el.unit,
num: Number(el.num ?? el.returnQuantity ?? 0),
+ price: Number(el.price ?? 0),
+ amount: Number(el.amount ?? 0),
+ isQuality: el.isQuality ?? 2,
+ remark: el.remark ?? "",
id: operationType.value === "edit" ? (el.returnSaleProductId ?? "") : ""
}));
const payload = { ...form.value, returnSaleProducts };
@@ -374,7 +419,6 @@
if(res.code === 200){
// If backend returns project info, set it
if (res.data.projectId) form.value.projectId = res.data.projectId;
- if (res.data.projectStage) form.value.projectStage = res.data.projectStage;
// Store available products for selection
availableProducts.value = res.data.productDtoData || [];
@@ -388,7 +432,6 @@
const current = Number(val);
if (current > max) {
- // Need nextTick to ensure update if user typed too fast or pasted
proxy.$nextTick(() => {
row.returnQuantity = max;
row.num = max;
@@ -402,6 +445,29 @@
} else {
row.num = current;
}
+ calculateRowAmount(row);
+ calculateTotalRefund();
+};
+
+const handlePriceChange = (val, row) => {
+ if (val === "" || val === null) {
+ row.price = 0;
+ }
+ calculateRowAmount(row);
+ calculateTotalRefund();
+};
+
+const calculateRowAmount = (row) => {
+ const quantity = Number(row.returnQuantity || 0);
+ const price = Number(row.price || 0);
+ row.amount = (quantity * price).toFixed(2);
+};
+
+const calculateTotalRefund = () => {
+ const total = tableData.value.reduce((sum, row) => {
+ return sum + Number(row.amount || 0);
+ }, 0);
+ form.value.refundAmount = total.toFixed(2);
};
const availableProducts = ref([]);
@@ -429,26 +495,23 @@
// Removed checkSelectable to allow toggling existing items
const confirmProductSelection = () => {
- // Rebuild tableData based on selection, preserving existing data (returnQuantity)
const newTableData = [];
selectedProducts.value.forEach(product => {
- // Check if product was already in tableData to preserve user input
const existing = tableData.value.find(item => item.id === product.id);
if (existing) {
newTableData.push(existing);
} else {
- // Create new entry
newTableData.push({
- ...product, // Keep all product display fields (productName, model, unit, etc.)
-
- // Map to backend entity structure for submission
+ ...product,
returnSaleLedgerProductId: product.id,
- returnQuantity: 0, // Default input
- num: 0, // Backend quantity field
-
- // Ensure display fields are available if they come from 'product'
- // If product has different field names than tableColumn expects, map them here
+ productModelId: product.productModelId,
+ returnQuantity: 0,
+ num: 0,
+ price: Number(product.taxInclusiveUnitPrice ?? 0),
+ amount: "0.00",
+ isQuality: 2,
+ remark: "",
productName: product.productName,
specificationModel: product.specificationModel,
unit: product.unit,
--
Gitblit v1.9.3