From 49ab1a592f5dfadd96119fce98facb1da46a7195 Mon Sep 17 00:00:00 2001 From: "han\\hanst" Date: Sun, 20 Sep 2026 13:11:20 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B9=B3=E5=9D=87=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sampleTracking/projectProofTracking.vue | 133 +++++++++++++++++- 1 file changed, 132 insertions(+), 1 deletion(-) diff --git a/src/views/modules/sampleTracking/projectProofTracking.vue b/src/views/modules/sampleTracking/projectProofTracking.vue index cfc9a77..997b1d4 100644 --- a/src/views/modules/sampleTracking/projectProofTracking.vue +++ b/src/views/modules/sampleTracking/projectProofTracking.vue @@ -211,10 +211,15 @@ this.isTrackingColumnVisible(item)) }, + hasTrackingLtSummary () { + return Array.isArray(this.selectionRows) && this.selectionRows.length > 0 + }, visibleProcessColumns () { const searchBuNo = this.getSelectedSearchBuNo() // 指定了查询BU时,整表进度列按该BU配置展示。 @@ -4528,6 +4536,88 @@ export default { }, selectionChange (rows) { this.selectionRows = rows || [] + // 汇总行常驻 DOM,勾选变化后必须重算数值并补一次列宽/滚动同步。 + this.refreshTrackingLtSummary() + }, + refreshTrackingLtSummary () { + this.$nextTick(() => { + const tableRef = this.$refs.trackingTable + if (!tableRef) { + return + } + if (typeof tableRef.$forceUpdate === 'function') { + tableRef.$forceUpdate() + } + // forceUpdate 会重建 footer 的 col,必须等下一帧再同步宽度,否则数字要拖滚动条才出现。 + this.$nextTick(() => { + this.syncTrackingLtSummaryLayout() + }) + }) + }, + syncTrackingLtSummaryLayout () { + const tableRef = this.$refs.trackingTable + if (!tableRef) { + return + } + if (typeof tableRef.doLayout === 'function') { + tableRef.doLayout() + } + if (tableRef.layout && typeof tableRef.layout.notifyObservers === 'function') { + tableRef.layout.notifyObservers('columns') + tableRef.layout.notifyObservers('scrollable') + } + const bodyWrapper = tableRef.bodyWrapper || (tableRef.$refs && tableRef.$refs.bodyWrapper) + const footerWrapper = tableRef.$refs && tableRef.$refs.footerWrapper + if (bodyWrapper && footerWrapper) { + footerWrapper.scrollLeft = bodyWrapper.scrollLeft + } + }, + parseTrackingLtNumber (value) { + // 空值(含空白字符串)不参与平均,0 是有效天数需要保留。 + if (this.isBlankValue(value)) { + return null + } + const number = Number(value) + if (Number.isNaN(number)) { + return null + } + return number + }, + calcTrackingLtAverage (rows, columnProp) { + if (!Array.isArray(rows) || rows.length === 0 || !columnProp) { + return '' + } + let sum = 0 + let count = 0 + rows.forEach(row => { + const number = this.parseTrackingLtNumber(row && row[columnProp]) + if (number == null) { + return + } + sum += number + count += 1 + }) + if (count === 0) { + return '' + } + const rounded = Math.round(sum / count * 10) / 10 + return String(rounded) + }, + getTrackingLtSummaries ({ columns }) { + // 平均值行仅在勾选后展示,两列各自跳过空值,互不影响。 + const sourceRows = Array.isArray(this.selectionRows) ? this.selectionRows : [] + let averageLabelWritten = false + return (columns || []).map(column => { + const columnProp = column && column.property + if (columnProp === 'sampleLt' || columnProp === 'sampleLtInquery') { + return this.calcTrackingLtAverage(sourceRows, columnProp) + } + if (averageLabelWritten || !column || column.type === 'selection') { + return '' + } + averageLabelWritten = true + return '平均值' + }) }, isCommentsEditing (row) { return !!row && row.trackingId === this.commentsEditingTrackingId @@ -6694,6 +6784,47 @@ export default { .el-table.proof-tracking-table .el-table__fixed-right-patch { border-bottom: 1px solid #808080; } + +.el-table.proof-tracking-table.is-tracking-lt-summary-hidden .el-table__footer-wrapper, +.el-table.proof-tracking-table.is-tracking-lt-summary-hidden .el-table__fixed-footer-wrapper, +.el-table.proof-tracking-table.is-tracking-lt-summary-hidden .el-table__fixed-right-footer-wrapper { + display: none; +} + +.el-table.proof-tracking-table .el-table__footer-wrapper, +.el-table.proof-tracking-table .el-table__fixed-footer-wrapper, +.el-table.proof-tracking-table .el-table__fixed-right-footer-wrapper { + background: transparent; +} + +.el-table.proof-tracking-table .el-table__footer-wrapper tbody td, +.el-table.proof-tracking-table .el-table__footer-wrapper tbody td.el-table__cell, +.el-table.proof-tracking-table .el-table__fixed-footer-wrapper tbody td, +.el-table.proof-tracking-table .el-table__fixed-footer-wrapper tbody td.el-table__cell, +.el-table.proof-tracking-table .el-table__fixed-right-footer-wrapper tbody td, +.el-table.proof-tracking-table .el-table__fixed-right-footer-wrapper tbody td.el-table__cell, +.el-table.proof-tracking-table .el-table__footer-wrapper tbody td .cell, +.el-table.proof-tracking-table .el-table__fixed-footer-wrapper tbody td .cell, +.el-table.proof-tracking-table .el-table__fixed-right-footer-wrapper tbody td .cell { + background: transparent; + background-color: transparent; +} + +.el-table.proof-tracking-table .el-table__footer-wrapper td, +.el-table.proof-tracking-table .el-table__fixed-footer-wrapper td, +.el-table.proof-tracking-table .el-table__fixed-right-footer-wrapper td { + height: 23px; + padding-top: 3px; + padding-bottom: 3px; +} + +.el-table.proof-tracking-table .el-table__footer-wrapper td .cell, +.el-table.proof-tracking-table .el-table__fixed-footer-wrapper td .cell, +.el-table.proof-tracking-table .el-table__fixed-right-footer-wrapper td .cell { + height: 17px; + line-height: 17px; + font-weight: 700; +} .el-table.el-table--medium.data-table th, .el-table.data-table th { height: 26px;