fix:产品管理折扣值浮点精度问题处理

dev_1.0.2
UNISINSIGHT\rdpnr_jiangpeng 2026-03-26 16:40:13 +08:00
parent 4b7021b45e
commit c66bdbcc74
1 changed files with 7 additions and 2 deletions

View File

@ -353,13 +353,15 @@ export default {
if (this.form.guidanceDiscount === null || this.form.guidanceDiscount === undefined) { if (this.form.guidanceDiscount === null || this.form.guidanceDiscount === undefined) {
return ''; return '';
} }
return (this.form.guidanceDiscount * 100).toString(); const percentValue = this.normalizeDecimalNumber(this.form.guidanceDiscount * 100);
return percentValue.toString();
}, },
set(val) { set(val) {
if (val === '' || val === null) { if (val === '' || val === null) {
this.form.guidanceDiscount = null; this.form.guidanceDiscount = null;
} else { } else {
this.form.guidanceDiscount = parseFloat(val) / 100; const discountValue = this.normalizeDecimalNumber(parseFloat(val) / 100);
this.form.guidanceDiscount = discountValue;
} }
} }
} }
@ -372,6 +374,9 @@ export default {
this.getVendorList(); this.getVendorList();
}, },
methods: { methods: {
normalizeDecimalNumber(value, digits = 12) {
return parseFloat(Number(value).toFixed(digits));
},
/** 加载字典数据 */ /** 加载字典数据 */
getDicts() { getDicts() {
return getDicts('product_type').then(response => { return getDicts('product_type').then(response => {