refactor(cost views): 统一调整数值格式化精度为两位小数
修改了三个成本相关页面的数值格式化逻辑: 1. energy.vue和assised.vue的formatNum方法,将保留小数位数从4位改为2位 2. comprehensive.vue的多位置数值处理逻辑,统一将计算结果格式化为两位小数
This commit is contained in:
@@ -735,7 +735,7 @@ export default {
|
||||
if (!d.detailDate) return
|
||||
if (!map[d.detailDate]) map[d.detailDate] = { detailDate: d.detailDate }
|
||||
const sfx = d.shift && d.shift !== '0' ? '_' + d.shift : ''
|
||||
map[d.detailDate]['q' + d.itemId + sfx] = d.quantity
|
||||
map[d.detailDate]['q' + d.itemId + sfx] = d.quantity != null && d.quantity !== '' ? Number(d.quantity).toFixed(2) : d.quantity
|
||||
})
|
||||
this.gridRows = Object.values(map).sort((a,b) => a.detailDate.localeCompare(b.detailDate))
|
||||
},
|
||||
@@ -780,7 +780,7 @@ export default {
|
||||
})
|
||||
})
|
||||
},
|
||||
evalF(f) { const s = f.replace(/[^0-9+\-*/.()\s]/g,''); if(!s) return null; try { const r = new Function('return ('+s+')')(); return isFinite(r)?Math.round(r*10000)/10000:null } catch(e){ return null } },
|
||||
evalF(f) { const s = f.replace(/[^0-9+\-*/.()\s]/g,''); if(!s) return null; try { const r = new Function('return ('+s+')')(); return isFinite(r)?(Math.round(r*100)/100).toFixed(2):null } catch(e){ return null } },
|
||||
sortGrid() { this.gridRows.sort((a,b)=>{if(!a.detailDate)return 1;if(!b.detailDate)return -1;return a.detailDate.localeCompare(b.detailDate)}) },
|
||||
async saveGrid() {
|
||||
const rid = this.activeReport.reportId; if (!rid) return; this.saving = true
|
||||
@@ -860,7 +860,7 @@ export default {
|
||||
try {
|
||||
const val = await handler(col.queryCondition, row, col, this.activeReport, shift)
|
||||
if (val != null) {
|
||||
const round3 = n => Math.round(n * 1000) / 1000
|
||||
const round3 = n => (Math.round(n * 100) / 100).toFixed(2)
|
||||
if (Array.isArray(val)) {
|
||||
this.$set(row, 'q' + col.itemId + '_1', round3(val[0]))
|
||||
this.$set(row, 'q' + col.itemId + '_2', round3(val[1]))
|
||||
@@ -946,7 +946,7 @@ export default {
|
||||
if (!col.queryCondition) return
|
||||
const handler = queryHandlers[col.category] || queryHandlers['default']
|
||||
if (!handler) { this.$modal.msgWarning(`类别 "${col.category}" 未注册查询处理器`); return }
|
||||
const round3 = n => Math.round(n * 1000) / 1000
|
||||
const round3 = n => (Math.round(n * 100) / 100).toFixed(2)
|
||||
const tasks = []
|
||||
for (const row of this.gridRows) {
|
||||
if (!row.detailDate) continue
|
||||
|
||||
@@ -130,7 +130,7 @@ export default {
|
||||
else return row.lineType || '-'
|
||||
}
|
||||
},
|
||||
formatNum(val) { if (val === null || val === undefined || val === '') return ''; const n = Number(val); if (isNaN(n)) return val; return parseFloat(n.toFixed(4)) },
|
||||
formatNum(val) { if (val === null || val === undefined || val === '') return ''; const n = Number(val); if (isNaN(n)) return val; return parseFloat(n.toFixed(2)) },
|
||||
async loadItems() { if (!this.allItems.length) { const r = await listItem({ pageNum:1, pageSize:999 }); this.allItems = r.rows || [] } },
|
||||
async enter(row) { const r = await getProdReport(row.reportId); if (r.data) this.activeReport = r.data; else this.activeReport = row; this.loadGrid() }
|
||||
}
|
||||
|
||||
@@ -130,7 +130,7 @@ export default {
|
||||
else return row.lineType || '-'
|
||||
}
|
||||
},
|
||||
formatNum(val) { if (val === null || val === undefined || val === '') return ''; const n = Number(val); if (isNaN(n)) return val; return parseFloat(n.toFixed(4)) },
|
||||
formatNum(val) { if (val === null || val === undefined || val === '') return ''; const n = Number(val); if (isNaN(n)) return val; return parseFloat(n.toFixed(2)) },
|
||||
async loadItems() { if (!this.allItems.length) { const r = await listItem({ pageNum:1, pageSize:999 }); this.allItems = r.rows || [] } },
|
||||
async enter(row) { const r = await getProdReport(row.reportId); if (r.data) this.activeReport = r.data; else this.activeReport = row; this.loadGrid() }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user