diff --git a/klp-ui/src/views/cost/comprehensive.vue b/klp-ui/src/views/cost/comprehensive.vue index 1c08f505e..5a7c79e2d 100644 --- a/klp-ui/src/views/cost/comprehensive.vue +++ b/klp-ui/src/views/cost/comprehensive.vue @@ -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 } }, diff --git a/klp-ui/src/views/cost/trend.vue b/klp-ui/src/views/cost/trend.vue index c5f8be51e..7fcb5482f 100644 --- a/klp-ui/src/views/cost/trend.vue +++ b/klp-ui/src/views/cost/trend.vue @@ -38,48 +38,54 @@ - -