feat(cost): 新增成本趋势图表管理功能与汇总数据保存

1.  为comprehensive.vue新增保存汇总数据到报表配置的逻辑
2.  重构trend.vue的筛选交互为图表管理面板,支持显示隐藏、排序系列,配置持久化到localStorage
3.  替换原有的明细数据拉取逻辑为读取报表配置获取汇总数据
This commit is contained in:
砂糖
2026-07-11 15:43:28 +08:00
parent 534fd20342
commit 656df92fa5
2 changed files with 325 additions and 98 deletions

View File

@@ -938,6 +938,41 @@ export default {
await batchSaveProdMetricResult({ resultIds, prodMetricResultList: metricResultList })
}
// 保存汇总数据到报表config
const summaryRows = this.summaryRows
const sumRow = summaryRows.find(r => r.$summaryType === 'sum')
const avgRow = summaryRows.find(r => r.$summaryType === 'avg')
const buildSummaryMap = (row) => {
const map = {}
if (!row) return map
this.allCols.forEach(col => {
const hdr = col.$type === 'detail'
? (col.itemName || col.itemCode) + (col.unit ? '(' + col.unit + ')' : '')
: col.metricName + (col.unit ? '(' + col.unit + ')' : '')
if (col.isShift) {
if (col.$type === 'detail') {
const v1 = row['q' + col.itemId + '_1']
const v2 = row['q' + col.itemId + '_2']
if (v1 != null) map[hdr + '(甲)'] = v1
if (v2 != null) map[hdr + '(乙)'] = v2
} else {
const v1 = row['mv' + col.mIdx + '_1']
const v2 = row['mv' + col.mIdx + '_2']
if (v1 != null) map[hdr + '(甲)'] = v1
if (v2 != null) map[hdr + '(乙)'] = v2
}
} else {
const v = col.$type === 'detail' ? row['q' + col.itemId] : row['mv' + col.mIdx]
if (v != null) map[hdr] = v
}
})
return map
}
const cfg = JSON.parse(this.activeReport.colConfig || '{}')
cfg.avg = buildSummaryMap(avgRow)
cfg.sum = buildSummaryMap(sumRow)
await updateProdReport({ reportId: rid, colConfig: JSON.stringify(cfg) })
this.$modal.msgSuccess("保存成功"); await this.loadGrid()
} catch(e) { this.$modal.msgError("保存失败") } finally { this.saving = false }
},