From 656df92fa586abc9ae7e840079526ac40b6a8e6e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A0=82=E7=B3=96?= Date: Sat, 11 Jul 2026 15:43:28 +0800 Subject: [PATCH] =?UTF-8?q?feat(cost):=20=E6=96=B0=E5=A2=9E=E6=88=90?= =?UTF-8?q?=E6=9C=AC=E8=B6=8B=E5=8A=BF=E5=9B=BE=E8=A1=A8=E7=AE=A1=E7=90=86?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=E4=B8=8E=E6=B1=87=E6=80=BB=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E4=BF=9D=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. 为comprehensive.vue新增保存汇总数据到报表配置的逻辑 2. 重构trend.vue的筛选交互为图表管理面板,支持显示隐藏、排序系列,配置持久化到localStorage 3. 替换原有的明细数据拉取逻辑为读取报表配置获取汇总数据 --- klp-ui/src/views/cost/comprehensive.vue | 35 +++ klp-ui/src/views/cost/trend.vue | 388 ++++++++++++++++++------ 2 files changed, 325 insertions(+), 98 deletions(-) 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 @@ - -
- 图表筛选: - - - - - - - - - - - - - + +
+ 图表: +
+ + + {{ sk.name }} + + + + + +
+
+ + + + + + + + + + + + + +
+ 关 闭 +
+
+