feat(金额显示): 统一金额单位为万元并优化产品内容处理
refactor(产品内容): 提取产品内容处理逻辑到独立工具类 style(合同表单): 调整技术附件和商务附件顺序
This commit is contained in:
@@ -127,6 +127,10 @@
|
||||
import { listOrder, updateOrder } from "@/api/crm/order";
|
||||
import * as ExcelJS from 'exceljs';
|
||||
import { saveAs } from 'file-saver';
|
||||
import {
|
||||
parseProductContent,
|
||||
convertToChinese
|
||||
} from '@/utils/productContent';
|
||||
|
||||
export default {
|
||||
name: "ContractList",
|
||||
@@ -213,62 +217,7 @@ export default {
|
||||
this.showMoreFilter = !this.showMoreFilter;
|
||||
},
|
||||
convertToChinese(amount) {
|
||||
if (amount === 0) return '零元整'
|
||||
|
||||
const digits = ['零', '壹', '贰', '叁', '肆', '伍', '陆', '柒', '捌', '玖']
|
||||
const units = ['', '拾', '佰', '仟']
|
||||
const bigUnits = ['', '万', '亿']
|
||||
|
||||
let integerPart = Math.floor(amount)
|
||||
let decimalPart = Math.round((amount - integerPart) * 100)
|
||||
|
||||
let result = ''
|
||||
let unitIndex = 0
|
||||
let bigUnitIndex = 0
|
||||
|
||||
if (integerPart === 0) {
|
||||
result = '零'
|
||||
} else {
|
||||
while (integerPart > 0) {
|
||||
let section = integerPart % 10000
|
||||
if (section > 0) {
|
||||
let sectionResult = ''
|
||||
let sectionUnitIndex = 0
|
||||
|
||||
while (section > 0) {
|
||||
let digit = section % 10
|
||||
if (digit > 0) {
|
||||
sectionResult = digits[digit] + units[sectionUnitIndex] + sectionResult
|
||||
} else if (sectionResult && !sectionResult.startsWith('零')) {
|
||||
sectionResult = '零' + sectionResult
|
||||
}
|
||||
section = Math.floor(section / 10)
|
||||
sectionUnitIndex++
|
||||
}
|
||||
|
||||
result = sectionResult + bigUnits[bigUnitIndex] + result
|
||||
}
|
||||
integerPart = Math.floor(integerPart / 10000)
|
||||
bigUnitIndex++
|
||||
}
|
||||
}
|
||||
|
||||
result += '元'
|
||||
|
||||
if (decimalPart === 0) {
|
||||
result += '整'
|
||||
} else {
|
||||
const jiao = Math.floor(decimalPart / 10)
|
||||
const fen = decimalPart % 10
|
||||
if (jiao > 0) {
|
||||
result += digits[jiao] + '角'
|
||||
}
|
||||
if (fen > 0) {
|
||||
result += digits[fen] + '分'
|
||||
}
|
||||
}
|
||||
|
||||
return result
|
||||
return convertToChinese(amount);
|
||||
},
|
||||
/** 导出合同 */
|
||||
async handleExport(row) {
|
||||
@@ -413,21 +362,9 @@ export default {
|
||||
|
||||
// 产品表格数据, 来源于一个json字符串(productContent,json结构参考ProductContent.vue)
|
||||
// 解析产品内容
|
||||
let productData = {
|
||||
products: [],
|
||||
productName: row.productName || '冷硬钢卷',
|
||||
remark: '',
|
||||
totalQuantity: 0,
|
||||
totalTaxTotal: 0,
|
||||
totalAmountInWords: '零元整'
|
||||
};
|
||||
|
||||
if (row.productContent) {
|
||||
try {
|
||||
productData = JSON.parse(row.productContent);
|
||||
} catch (error) {
|
||||
console.error('解析产品内容失败:', error);
|
||||
}
|
||||
let productData = parseProductContent(row.productContent);
|
||||
if (!productData.productName && row.productName) {
|
||||
productData.productName = row.productName;
|
||||
}
|
||||
|
||||
// if (orderItems) {
|
||||
|
||||
Reference in New Issue
Block a user