From be65feb64970908c7f0a287faa7a53612686dd43 Mon Sep 17 00:00:00 2001
From: zouyu <2723363702@qq.com>
Date: 星期五, 14 十一月 2025 15:01:32 +0800
Subject: [PATCH] 销售台账、采购台账添加产品表单调整
---
src/views/salesManagement/salesLedger/index.vue | 227 +++++++++++++++++++++++++++++++-------------------------
1 files changed, 124 insertions(+), 103 deletions(-)
diff --git a/src/views/salesManagement/salesLedger/index.vue b/src/views/salesManagement/salesLedger/index.vue
index 8c7c448..e60be67 100644
--- a/src/views/salesManagement/salesLedger/index.vue
+++ b/src/views/salesManagement/salesLedger/index.vue
@@ -250,7 +250,7 @@
</el-row>
<el-row :gutter="30">
<el-col :span="12">
- <el-form-item label="鍚◣鍗曚环(鍏�)锛�" prop="taxInclusiveUnitPrice">
+ <el-form-item label="鍚◣/涓嶅惈绋庡崟浠�(鍏�)锛�" prop="taxInclusiveUnitPrice">
<el-input-number :step="0.01" :min="0" v-model="productForm.taxInclusiveUnitPrice" style="width: 100%"
:precision="2"
placeholder="璇疯緭鍏�" clearable @change="calculateFromUnitPrice" />
@@ -320,7 +320,7 @@
<div class="company-name">榧庤瘹鐟炲疄涓氭湁闄愯矗浠诲叕鍙�</div>
<div class="document-title">闆跺敭鍙戣揣鍗�</div>
</div>
-
+
<div class="info-section">
<div class="info-row">
<div>
@@ -328,7 +328,7 @@
<span class="value">{{ formatDate(item.createTime) }}</span>
</div>
<div>
-
+
<span class="label">瀹㈡埛鍚嶇О锛�</span>
<span class="value">{{ item.customerName || '寮犵埍鏈�' }}</span>
</div>
@@ -338,7 +338,7 @@
<span class="value">{{ item.salesContractNo }}</span>
</div>
</div>
-
+
<div class="table-section">
<table class="product-table">
<thead>
@@ -376,7 +376,7 @@
</tfoot>
</table>
</div>
-
+
<div class="footer-section">
<div class="footer-row">
<div class="footer-item">
@@ -563,14 +563,14 @@
taxInclusiveUnitPrice: [
{ required: true, message: "璇疯緭鍏�", trigger: "blur" },
],
- taxRate: [{ required: true, message: "璇烽�夋嫨", trigger: "change" }],
+ // taxRate: [{ required: true, message: "璇烽�夋嫨", trigger: "change" }],
taxInclusiveTotalPrice: [
{ required: true, message: "璇疯緭鍏�", trigger: "blur" },
],
taxExclusiveTotalPrice: [
{ required: true, message: "璇疯緭鍏�", trigger: "blur" },
],
- invoiceType: [{ required: true, message: "璇烽�夋嫨", trigger: "change" }],
+ // invoiceType: [{ required: true, message: "璇烽�夋嫨", trigger: "change" }],
},
});
const { productForm, productRules } = toRefs(productFormData);
@@ -975,25 +975,25 @@
proxy.$modal.msgWarning("璇烽�夋嫨瑕佹墦鍗扮殑鏁版嵁");
return;
}
-
+
// 鏄剧ず鍔犺浇鐘舵��
proxy.$modal.loading("姝e湪鑾峰彇浜у搧鏁版嵁锛岃绋嶅��...");
-
+
try {
// 涓烘瘡涓�変腑鐨勯攢鍞彴璐﹁褰曟煡璇㈠搴旂殑浜у搧鏁版嵁
const printDataWithProducts = [];
-
+
for (const row of selectedRows.value) {
try {
// 璋冪敤productList鎺ュ彛鏌ヨ浜у搧鏁版嵁
const productRes = await productList({ salesLedgerId: row.id, type: 1 });
-
+
// 灏嗕骇鍝佹暟鎹暣鍚堝埌閿�鍞彴璐﹁褰曚腑
const rowWithProducts = {
...row,
products: productRes.data || []
};
-
+
printDataWithProducts.push(rowWithProducts);
} catch (error) {
console.error(`鑾峰彇閿�鍞彴璐� ${row.id} 鐨勪骇鍝佹暟鎹け璐�:`, error);
@@ -1004,11 +1004,11 @@
});
}
}
-
+
printData.value = printDataWithProducts;
console.log('鎵撳嵃鏁版嵁锛堝寘鍚骇鍝侊級:', printData.value);
printPreviewVisible.value = true;
-
+
} catch (error) {
console.error('鑾峰彇浜у搧鏁版嵁澶辫触:', error);
proxy.$modal.msgError("鑾峰彇浜у搧鏁版嵁澶辫触锛岃閲嶈瘯");
@@ -1020,10 +1020,10 @@
const executePrint = () => {
console.log('寮�濮嬫墽琛屾墦鍗帮紝鏁版嵁鏉℃暟:', printData.value.length);
console.log('鎵撳嵃鏁版嵁:', printData.value);
-
+
// 鍒涘缓涓�涓柊鐨勬墦鍗扮獥鍙�
const printWindow = window.open('', '_blank', 'width=800,height=600');
-
+
// 鏋勫缓鎵撳嵃鍐呭
let printContent = `
<!DOCTYPE html>
@@ -1159,7 +1159,7 @@
</head>
<body>
`;
-
+
// 涓烘瘡鏉℃暟鎹敓鎴愭墦鍗伴〉闈�
printData.value.forEach((item, index) => {
printContent += `
@@ -1169,7 +1169,7 @@
<div class="company-name">榧庤瘹鐟炲疄涓氭湁闄愯矗浠诲叕鍙�</div>
<div class="document-title">闆跺敭鍙戣揣鍗�</div>
</div>
-
+
<div class="info-section">
<div class="info-row">
<div>
@@ -1200,7 +1200,7 @@
</tr>
</thead>
<tbody>
- ${item.products && item.products.length > 0 ?
+ ${item.products && item.products.length > 0 ?
item.products.map(product => `
<tr>
<td>${product.productCategory || ''}</td>
@@ -1210,7 +1210,7 @@
<td>${product.quantity || '0'}</td>
<td>${product.taxInclusiveTotalPrice || '0'}</td>
</tr>
- `).join('') :
+ `).join('') :
'<tr><td colspan="6" style="text-align: center; color: #999;">鏆傛棤浜у搧鏁版嵁</td></tr>'
}
</tbody>
@@ -1257,16 +1257,16 @@
</div>
`;
});
-
+
printContent += `
</body>
</html>
`;
-
+
// 鍐欏叆鍐呭鍒版柊绐楀彛
printWindow.document.write(printContent);
printWindow.document.close();
-
+
// 绛夊緟鍐呭鍔犺浇瀹屾垚鍚庢墦鍗�
printWindow.onload = () => {
setTimeout(() => {
@@ -1366,148 +1366,169 @@
// 鏍规嵁鍚◣鎬讳环璁$畻鍚◣鍗曚环鍜屾暟閲�
const calculateFromTotalPrice = () => {
if (isCalculating.value) return;
-
+
const totalPrice = parseFloat(productForm.value.taxInclusiveTotalPrice);
const quantity = parseFloat(productForm.value.quantity);
-
+
if (!totalPrice || !quantity || quantity <= 0) {
return;
}
-
+
isCalculating.value = true;
-
+
// 璁$畻鍚◣鍗曚环 = 鍚◣鎬讳环 / 鏁伴噺
productForm.value.taxInclusiveUnitPrice = (totalPrice / quantity).toFixed(2);
-
+
// 濡傛灉鏈夌◣鐜囷紝璁$畻涓嶅惈绋庢�讳环
- if (productForm.value.taxRate) {
- productForm.value.taxExclusiveTotalPrice =
+ // if (productForm.value.taxRate) {
+ // productForm.value.taxExclusiveTotalPrice =
+ // proxy.calculateTaxExclusiveTotalPrice(
+ // totalPrice,
+ // productForm.value.taxRate
+ // );
+ // }
+ productForm.value.taxExclusiveTotalPrice =
proxy.calculateTaxExclusiveTotalPrice(
- totalPrice,
- productForm.value.taxRate
+ totalPrice,
+ productForm.value.taxRate
);
- }
-
+
isCalculating.value = false;
};
// 鏍规嵁涓嶅惈绋庢�讳环璁$畻鍚◣鍗曚环鍜屾暟閲�
const calculateFromExclusiveTotalPrice = () => {
- if (!productForm.value.taxRate) {
- proxy.$modal.msgWarning("璇峰厛閫夋嫨绋庣巼");
- return;
- }
+ // if (!productForm.value.taxRate) {
+ // proxy.$modal.msgWarning("璇峰厛閫夋嫨绋庣巼");
+ // return;
+ // }
if (isCalculating.value) return;
-
+
const exclusiveTotalPrice = parseFloat(productForm.value.taxExclusiveTotalPrice);
const quantity = parseFloat(productForm.value.quantity);
- const taxRate = parseFloat(productForm.value.taxRate);
-
- if (!exclusiveTotalPrice || !quantity || quantity <= 0 || !taxRate) {
+ const taxRate = productForm.value.taxRate?parseFloat(productForm.value.taxRate):0;
+
+ // if (!exclusiveTotalPrice || !quantity || quantity <= 0 || !taxRate) {
+ // return;
+ // }
+ if (!exclusiveTotalPrice || !quantity || quantity <= 0) {
return;
}
-
+
isCalculating.value = true;
-
+
// 鍏堣绠楀惈绋庢�讳环 = 涓嶅惈绋庢�讳环 / (1 - 绋庣巼/100)
const taxRateDecimal = taxRate / 100;
const inclusiveTotalPrice = exclusiveTotalPrice / (1 - taxRateDecimal);
productForm.value.taxInclusiveTotalPrice = inclusiveTotalPrice.toFixed(2);
-
+
// 璁$畻鍚◣鍗曚环 = 鍚◣鎬讳环 / 鏁伴噺
productForm.value.taxInclusiveUnitPrice = (inclusiveTotalPrice / quantity).toFixed(2);
-
+
isCalculating.value = false;
};
// 鏍规嵁鏁伴噺鍙樺寲璁$畻鎬讳环
const calculateFromQuantity = () => {
- if (!productForm.value.taxRate) {
- proxy.$modal.msgWarning("璇峰厛閫夋嫨绋庣巼");
- return;
- }
+ // if (!productForm.value.taxRate) {
+ // proxy.$modal.msgWarning("璇峰厛閫夋嫨绋庣巼");
+ // return;
+ // }
if (isCalculating.value) return;
-
+
const quantity = parseFloat(productForm.value.quantity);
const unitPrice = parseFloat(productForm.value.taxInclusiveUnitPrice);
-
+
if (!quantity || quantity <= 0 || !unitPrice) {
return;
}
-
+
isCalculating.value = true;
-
+
// 璁$畻鍚◣鎬讳环
productForm.value.taxInclusiveTotalPrice = (unitPrice * quantity).toFixed(2);
-
+
// 濡傛灉鏈夌◣鐜囷紝璁$畻涓嶅惈绋庢�讳环
- if (productForm.value.taxRate) {
- productForm.value.taxExclusiveTotalPrice =
+ // if (productForm.value.taxRate) {
+ // productForm.value.taxExclusiveTotalPrice =
+ // proxy.calculateTaxExclusiveTotalPrice(
+ // productForm.value.taxInclusiveTotalPrice,
+ // productForm.value.taxRate
+ // );
+ // }
+ productForm.value.taxExclusiveTotalPrice =
proxy.calculateTaxExclusiveTotalPrice(
- productForm.value.taxInclusiveTotalPrice,
- productForm.value.taxRate
+ productForm.value.taxInclusiveTotalPrice,
+ productForm.value.taxRate
);
- }
-
+
isCalculating.value = false;
};
// 鏍规嵁鍚◣鍗曚环鍙樺寲璁$畻鎬讳环
const calculateFromUnitPrice = () => {
- if (!productForm.value.taxRate) {
- proxy.$modal.msgWarning("璇峰厛閫夋嫨绋庣巼");
- return;
- }
+ // if (!productForm.value.taxRate) {
+ // proxy.$modal.msgWarning("璇峰厛閫夋嫨绋庣巼");
+ // return;
+ // }
if (isCalculating.value) return;
-
+
const quantity = parseFloat(productForm.value.quantity);
const unitPrice = parseFloat(productForm.value.taxInclusiveUnitPrice);
-
+
if (!quantity || quantity <= 0 || !unitPrice) {
return;
}
-
+
isCalculating.value = true;
-
+
// 璁$畻鍚◣鎬讳环
productForm.value.taxInclusiveTotalPrice = (unitPrice * quantity).toFixed(2);
-
+
// 濡傛灉鏈夌◣鐜囷紝璁$畻涓嶅惈绋庢�讳环
- if (productForm.value.taxRate) {
- productForm.value.taxExclusiveTotalPrice =
+ // if (productForm.value.taxRate) {
+ // productForm.value.taxExclusiveTotalPrice =
+ // proxy.calculateTaxExclusiveTotalPrice(
+ // productForm.value.taxInclusiveTotalPrice,
+ // productForm.value.taxRate
+ // );
+ // }
+ productForm.value.taxExclusiveTotalPrice =
proxy.calculateTaxExclusiveTotalPrice(
- productForm.value.taxInclusiveTotalPrice,
- productForm.value.taxRate
+ productForm.value.taxInclusiveTotalPrice,
+ productForm.value.taxRate
);
- }
-
+
isCalculating.value = false;
};
// 鏍规嵁绋庣巼鍙樺寲璁$畻涓嶅惈绋庢�讳环
const calculateFromTaxRate = () => {
- if (!productForm.value.taxRate) {
- proxy.$modal.msgWarning("璇峰厛閫夋嫨绋庣巼");
- return;
- }
+ // if (!productForm.value.taxRate) {
+ // proxy.$modal.msgWarning("璇峰厛閫夋嫨绋庣巼");
+ // return;
+ // }
if (isCalculating.value) return;
-
+
const inclusiveTotalPrice = parseFloat(productForm.value.taxInclusiveTotalPrice);
const taxRate = parseFloat(productForm.value.taxRate);
-
- if (!inclusiveTotalPrice || !taxRate) {
+
+ // if (!inclusiveTotalPrice || !taxRate) {
+ // return;
+ // }
+ if (!inclusiveTotalPrice) {
return;
}
-
+
isCalculating.value = true;
-
+
// 璁$畻涓嶅惈绋庢�讳环
productForm.value.taxExclusiveTotalPrice =
proxy.calculateTaxExclusiveTotalPrice(
inclusiveTotalPrice,
taxRate
);
-
+
isCalculating.value = false;
};
/**
@@ -1592,12 +1613,12 @@
padding: 15px;
border-bottom: 1px solid #e4e7ed;
text-align: center;
-
+
.el-button {
margin: 0 10px;
}
}
-
+
.print-preview-content {
padding: 20px;
background-color: #f5f5f5;
@@ -1629,13 +1650,13 @@
.header {
text-align: center;
margin-bottom: 8px;
-
+
.company-name {
font-size: 18px;
font-weight: bold;
margin-bottom: 4px;
}
-
+
.document-title {
font-size: 16px;
font-weight: bold;
@@ -1647,16 +1668,16 @@
display: flex;
justify-content: space-between;
align-items: center;
-
+
.info-row {
line-height: 20px;
-
+
.label {
font-weight: bold;
width: 60px;
font-size: 14px;
}
-
+
.value {
margin-right: 20px;
min-width: 80px;
@@ -1668,12 +1689,12 @@
.table-section {
margin-bottom: 4px;
flex: 1;
-
+
.product-table {
width: 100%;
border-collapse: collapse;
border: 1px solid #000;
-
+
th, td {
border: 1px solid #000;
padding: 6px;
@@ -1681,16 +1702,16 @@
font-size: 14px;
line-height: 1.4;
}
-
+
th {
font-weight: bold;
}
-
+
.total-label {
text-align: right;
font-weight: bold;
}
-
+
.total-value {
font-weight: bold;
}
@@ -1703,22 +1724,22 @@
margin-bottom: 3px;
line-height: 20px;
justify-content: space-between;
-
+
.footer-item {
display: flex;
margin-right: 20px;
-
+
.label {
font-weight: bold;
width: 80px;
font-size: 14px;
}
-
+
.value {
min-width: 80px;
font-size: 14px;
}
-
+
&.address-item {
.address-value {
min-width: 200px;
@@ -1732,7 +1753,7 @@
.app-container {
display: none;
}
-
+
.print-page {
box-shadow: none;
margin: 0;
--
Gitblit v1.9.3