From c391bf92060a370c1f22e5e3b7d17c2ebfd048c7 Mon Sep 17 00:00:00 2001
From: spring <2396852758@qq.com>
Date: 星期三, 08 四月 2026 14:25:36 +0800
Subject: [PATCH] fix: 销售台账新增修改
---
src/views/salesManagement/salesLedger/index.vue | 153 +++++++++++++++++---------------------------------
1 files changed, 52 insertions(+), 101 deletions(-)
diff --git a/src/views/salesManagement/salesLedger/index.vue b/src/views/salesManagement/salesLedger/index.vue
index b80007c..49450cf 100644
--- a/src/views/salesManagement/salesLedger/index.vue
+++ b/src/views/salesManagement/salesLedger/index.vue
@@ -179,12 +179,6 @@
<el-table-column label="鎬讳环"
prop="totalPrice"
:formatter="formattedNumber" />
- <el-table-column label="杩愯垂"
- prop="freight"
- :formatter="formattedNumber" />
- <el-table-column label="鍚繍璐瑰崟浠�"
- prop="priceWithFreight"
- :formatter="formattedNumber" />
</template>
<!--鎿嶄綔-->
<!-- <el-table-column Width="60px"
@@ -298,6 +292,7 @@
style="text-align: right;">
<el-button type="primary"
plain
+ :disabled="!form.customerId"
@click="openQuotationDialog">
浠庨攢鍞姤浠峰鍏�
</el-button>
@@ -481,12 +476,6 @@
:formatter="formattedNumber" />
<el-table-column label="鎬讳环"
prop="totalPrice"
- :formatter="formattedNumber" />
- <el-table-column label="杩愯垂"
- prop="freight"
- :formatter="formattedNumber" />
- <el-table-column label="鍚繍璐瑰崟浠�"
- prop="priceWithFreight"
:formatter="formattedNumber" />
</template>
<el-table-column fixed="right"
@@ -691,22 +680,6 @@
style="width: 100%" />
</el-form-item>
</el-col>
- <!-- <el-col :span="12">
- <el-form-item label="绋庣巼(%)锛�"
- prop="taxRate">
- <el-select v-model="productForm.taxRate"
- placeholder="璇烽�夋嫨"
- clearable
- @change="calculateFromTaxRate">
- <el-option label="1"
- value="1" />
- <el-option label="6"
- value="6" />
- <el-option label="13"
- value="13" />
- </el-select>
- </el-form-item>
- </el-col> -->
</el-row>
<el-row :gutter="30">
</el-row>
@@ -719,6 +692,10 @@
<el-select v-model="productForm.taxRate"
placeholder="璇烽�夋嫨"
clearable
+ filterable
+ allow-create
+ default-first-option
+ style="width: 100%"
@change="calculateFromTaxRate">
<el-option label="1"
value="1" />
@@ -805,34 +782,6 @@
:precision="2"
placeholder="璇疯緭鍏�"
clearable />
- </el-form-item>
- </el-col>
- </el-row>
- <el-row :gutter="30">
- <el-col :span="12">
- <el-form-item label="杩愯垂锛�"
- prop="freight">
- <el-input-number :step="0.01"
- :min="0"
- v-model="productForm.freight"
- style="width: 100%"
- :precision="2"
- placeholder="璇疯緭鍏�"
- clearable
- @change="calculatePrivatePrice" />
- </el-form-item>
- </el-col>
- <el-col :span="12">
- <el-form-item label="鍚繍璐瑰崟浠凤細"
- prop="priceWithFreight">
- <el-input-number :step="0.01"
- :min="0"
- v-model="productForm.priceWithFreight"
- style="width: 100%"
- :precision="2"
- placeholder="璇疯緭鍏�"
- clearable
- @change="calculatePrivateTotal" />
</el-form-item>
</el-col>
</el-row>
@@ -1154,6 +1103,18 @@
const productFormVisible = ref(false);
const productOperationType = ref("");
const currentId = ref("");
+ const validateTaxRate = (_rule, value, callback) => {
+ if (value === null || value === undefined || value === "") {
+ callback(new Error("璇烽�夋嫨绋庣巼"));
+ return;
+ }
+ const taxRateStr = String(value).trim();
+ if (!/^\d+(\.\d+)?$/.test(taxRateStr)) {
+ callback(new Error("绋庣巼鍙兘杈撳叆鏁板瓧"));
+ return;
+ }
+ callback();
+ };
const productFormData = reactive({
productForm: {
productCategory: "",
@@ -1162,15 +1123,14 @@
quantity: "",
// 瀵瑰叕瀛楁
taxInclusiveUnitPrice: "",
- taxRate: "",
+ taxRate: null,
taxInclusiveTotalPrice: "",
taxExclusiveTotalPrice: "",
invoiceType: "",
// 瀵圭瀛楁
unitPrice: "",
totalPrice: "",
- freight: 0,
- priceWithFreight: "",
+
},
productRules: {
productCategory: [{ required: true, message: "璇烽�夋嫨", trigger: "change" }],
@@ -1184,7 +1144,7 @@
taxInclusiveUnitPrice: [
{ required: true, message: "璇疯緭鍏�", trigger: "blur" },
],
- taxRate: [{ required: true, message: "璇烽�夋嫨", trigger: "change" }],
+ taxRate: [{ validator: validateTaxRate, trigger: "change" }],
taxInclusiveTotalPrice: [
{ required: true, message: "璇疯緭鍏�", trigger: "blur" },
],
@@ -1195,8 +1155,6 @@
// 瀵圭瀛楁楠岃瘉
unitPrice: [{ required: true, message: "璇疯緭鍏�", trigger: "blur" }],
totalPrice: [{ required: true, message: "璇疯緭鍏�", trigger: "blur" }],
- freight: [{ required: true, message: "璇疯緭鍏�", trigger: "blur" }],
- priceWithFreight: [{ required: true, message: "璇疯緭鍏�", trigger: "blur" }],
},
});
const { productForm, productRules } = toRefs(productFormData);
@@ -1553,6 +1511,10 @@
// 鎵撳紑鎶ヤ环鍗曢�夋嫨寮圭獥锛堜粎瀹℃壒閫氳繃锛�
const openQuotationDialog = async () => {
if (operationType.value === "view") return;
+ if (!form.value.customerId) {
+ proxy.$modal.msgWarning("璇峰厛閫夋嫨瀹㈡埛鍚嶇О");
+ return;
+ }
quotationDialogVisible.value = true;
// 鎵撳紑寮圭獥鏃堕噸缃垎椤靛埌绗竴椤�
quotationPage.current = 1;
@@ -1609,20 +1571,21 @@
form.value.salesman = (row.salesperson || "").trim();
// 瀹㈡埛鍚嶇О -> customerId
- const qCustomerName = String(row.customer || "").trim();
- const customer = (customerOption.value || []).find(c => {
- const name = String(c.customerName || "").trim();
- return (
- name === qCustomerName ||
- name.includes(qCustomerName) ||
- qCustomerName.includes(name)
- );
- });
- if (customer?.id) {
- form.value.customerId = customer.id;
- } else {
- // 濡傛灉鎵句笉鍒帮紝淇濈暀鍘熷�硷紙鍏佽鐢ㄦ埛鎵嬪姩閫夋嫨/涓嶆墦鏂凡鏈夎緭鍏ワ級
- form.value.customerId = form.value.customerId || "";
+ // 濡傛灉琛ㄥ崟閲岃繕娌℃湁閫夊鎴凤紝鍒欏皾璇曢�氳繃鎶ヤ环鍗曞鎴峰悕绉板尮閰嶏紱
+ // 濡傛灉宸茬粡閫変簡瀹㈡埛锛屽垯淇濇寔鐢ㄦ埛褰撳墠閫夋嫨锛屼笉琚姤浠峰崟瑕嗙洊銆�
+ if (!form.value.customerId) {
+ const qCustomerName = String(row.customer || "").trim();
+ const customer = (customerOption.value || []).find(c => {
+ const name = String(c.customerName || "").trim();
+ return (
+ name === qCustomerName ||
+ name.includes(qCustomerName) ||
+ qCustomerName.includes(name)
+ );
+ });
+ if (customer?.id) {
+ form.value.customerId = customer.id;
+ }
}
// 浜у搧淇℃伅鏄犲皠锛氭姤浠� products -> 鍙拌处 productData
@@ -1737,6 +1700,9 @@
proxy.resetForm("productFormRef");
if (type === "edit") {
productForm.value = { ...row };
+ if (productForm.value.taxRate !== undefined && productForm.value.taxRate !== null && productForm.value.taxRate !== "") {
+ productForm.value.taxRate = String(productForm.value.taxRate);
+ }
productIndex.value = index;
// 缂栬緫鏃舵牴鎹骇鍝佸ぇ绫诲悕绉板弽鏌� tree 鑺傜偣 id锛屽苟鍔犺浇瑙勬牸鍨嬪彿鍒楄〃
try {
@@ -1778,8 +1744,6 @@
// 瀵圭瀛楁涓嶉渶瑕侀獙璇�
delete dynamicRules.unitPrice;
delete dynamicRules.totalPrice;
- delete dynamicRules.freight;
- delete dynamicRules.priceWithFreight;
} else if (currentCustomerType.value == 2) {
// 瀵瑰叕瀛楁涓嶉渶瑕侀獙璇�
delete dynamicRules.taxInclusiveUnitPrice;
@@ -1822,8 +1786,6 @@
// 瀵圭瀛楁涓嶉渶瑕佹彁浜�
delete productDataToSubmit.unitPrice;
delete productDataToSubmit.totalPrice;
- delete productDataToSubmit.freight;
- delete productDataToSubmit.priceWithFreight;
} else if (currentCustomerType.value == 2) {
// 瀵瑰叕瀛楁涓嶉渶瑕佹彁浜�
delete productDataToSubmit.taxInclusiveUnitPrice;
@@ -2470,32 +2432,14 @@
isCalculating.value = false;
};
- // 瀵圭瀹㈡埛浠锋牸璁$畻锛氬崟浠峰拰杩愯垂鍙樺寲鏃惰绠楀惈杩愯垂鍗曚环鍜屾�讳环
+ // 瀵圭瀹㈡埛浠锋牸璁$畻锛氬崟浠峰彉鍖栨椂璁$畻鎬讳环
const calculatePrivatePrice = () => {
if (currentCustomerType.value == 2) {
const unitPrice = parseFloat(productForm.value.unitPrice) || 0;
- const freight = parseFloat(productForm.value.freight) || 0;
- const quantity = parseFloat(productForm.value.quantity) || 0;
-
- // 璁$畻鍚繍璐瑰崟浠�
- productForm.value.priceWithFreight = (unitPrice + freight).toFixed(2);
-
- // 璁$畻鎬讳环
- productForm.value.totalPrice = (
- parseFloat(productForm.value.priceWithFreight) * quantity
- ).toFixed(2);
- }
- };
-
- // 瀵圭瀹㈡埛浠锋牸璁$畻锛氬惈杩愯垂鍗曚环鍙樺寲鏃惰绠楁�讳环
- const calculatePrivateTotal = () => {
- if (currentCustomerType.value == 2) {
- const priceWithFreight =
- parseFloat(productForm.value.priceWithFreight) || 0;
const quantity = parseFloat(productForm.value.quantity) || 0;
// 璁$畻鎬讳环
- productForm.value.totalPrice = (priceWithFreight * quantity).toFixed(2);
+ productForm.value.totalPrice = (unitPrice * quantity).toFixed(2);
}
};
@@ -2585,8 +2529,13 @@
}
// 瀵瑰叕瀹㈡埛浣跨敤鍘熸湁鐨勮绠楅�昏緫
- if (!productForm.value.taxRate) {
+ if (productForm.value.taxRate === null || productForm.value.taxRate === undefined || productForm.value.taxRate === "") {
proxy.$modal.msgWarning("璇峰厛閫夋嫨绋庣巼");
+ return;
+ }
+ const taxRateStr = String(productForm.value.taxRate).trim();
+ if (!/^\d+(\.\d+)?$/.test(taxRateStr)) {
+ proxy.$modal.msgWarning("绋庣巼鍙兘杈撳叆鏁板瓧");
return;
}
if (isCalculating.value) return;
@@ -2608,6 +2557,7 @@
isCalculating.value = false;
};
+
/**
* 鑾峰彇鍙戣揣鐘舵�佹枃鏈�
* @param row 琛屾暟鎹�
@@ -2831,6 +2781,7 @@
justify-content: space-between;
margin-bottom: 10px;
}
+
.print-preview-dialog {
.el-dialog__body {
padding: 0;
--
Gitblit v1.9.3