feat(contract): 启用产品内容组件并优化合同相关功能

- 在合同页面启用ProductContent组件替代注释代码
- 优化ProductContent组件数值计算和空值处理
- 修改ContractList组件从productContent字段获取数据
- 在OrderDetail组件添加"写入合同"功能
- 优化ReceiveTable组件未收款金额计算逻辑
This commit is contained in:
2026-04-23 11:47:30 +08:00
parent 8897a2ad9f
commit 84c26a2990
6 changed files with 186 additions and 89 deletions

View File

@@ -261,10 +261,10 @@ export default {
// 1. 创建excel
const workbook = new ExcelJS.Workbook();
const worksheet = workbook.addWorksheet('产品销售合同');
let orderItems = [];
// 2. 查询合同详情
const res = await listOrderItem({ orderId: row.orderId, pageNum: 1, pageSize: 1000 });
orderItems = res.rows || [];
// let orderItems = [];
// // 2. 查询合同详情
// const res = await listOrderItem({ orderId: row.orderId, pageNum: 1, pageSize: 1000 });
// orderItems = res.rows || [];
// 2. 设置列宽
worksheet.columns = [
@@ -408,38 +408,46 @@ export default {
totalAmountInWords: '零元整'
};
if (orderItems) {
if (row.productContent) {
try {
// 改为从orderItems中获取产品内容
const productName = orderItems[0].productType || '冷硬钢卷';
const remark = row.remark || '';
const products = orderItems.map(item => ({
spec: item.finishedProductSpec || '',
material: item.material || '',
quantity: parseFloat(item.weight || 0),
taxPrice: parseFloat(item.contractPrice || 0),
noTaxPrice: parseFloat(item.itemAmount || 0),
taxTotal: parseFloat(item.contractPrice) * parseFloat(item.weight || 0),
remark: item.remark || ''
}));
const totalQuantity = products.reduce((acc, product) => acc + parseFloat(product.quantity || 0), 0);
const totalTaxTotal = products.reduce((acc, product) => acc + parseFloat(product.taxTotal || 0), 0);
const totalAmountInWords = this.convertToChinese(totalTaxTotal);
productData = {
products,
productName,
remark,
totalQuantity,
totalTaxTotal,
totalAmountInWords
};
productData = JSON.parse(row.productContent);
} catch (error) {
console.error('解析产品内容失败:', error);
}
}
// if (orderItems) {
// try {
// // 改为从orderItems中获取产品内容
// const productName = orderItems[0].productType || '冷硬钢卷';
// const remark = row.remark || '';
// const products = orderItems.map(item => ({
// spec: item.finishedProductSpec || '',
// material: item.material || '',
// quantity: parseFloat(item.weight || 0),
// taxPrice: parseFloat(item.contractPrice || 0),
// noTaxPrice: parseFloat(item.itemAmount || 0),
// taxTotal: parseFloat(item.contractPrice) * parseFloat(item.weight || 0),
// remark: item.remark || ''
// }));
// const totalQuantity = products.reduce((acc, product) => acc + parseFloat(product.quantity || 0), 0);
// const totalTaxTotal = products.reduce((acc, product) => acc + parseFloat(product.taxTotal || 0), 0);
// const totalAmountInWords = this.convertToChinese(totalTaxTotal);
// productData = {
// products,
// productName,
// remark,
// totalQuantity,
// totalTaxTotal,
// totalAmountInWords
// };
// } catch (error) {
// console.error('解析产品内容失败:', error);
// }
// }
// 更新产品名称
worksheet.getCell('A6').value = `产品名称:${productData.productName}`;