Browse Source

平均值

master
han\hanst 3 days ago
parent
commit
49ab1a592f
  1. 133
      src/views/modules/sampleTracking/projectProofTracking.vue

133
src/views/modules/sampleTracking/projectProofTracking.vue

@ -211,10 +211,15 @@
<el-table
ref="trackingTable"
:data="dataList"
border class="data-table proof-tracking-table"
border
class="data-table proof-tracking-table"
:class="{ 'is-tracking-lt-summary-hidden': !hasTrackingLtSummary }"
stripe highlight-current-row
:height="trackingTableHeight"
v-loading="dataListLoading"
show-summary
sum-text="平均值"
:summary-method="getTrackingLtSummaries"
@sort-change="handleTrackingTableSortChange"
@header-dragend="handleTrackingColumnResize"
@selection-change="selectionChange"
@ -1955,6 +1960,9 @@ export default {
: this.buildDefaultTrackingColumns()
return sourceColumns.filter(item => this.isTrackingColumnVisible(item))
},
hasTrackingLtSummary () {
return Array.isArray(this.selectionRows) && this.selectionRows.length > 0
},
visibleProcessColumns () {
const searchBuNo = this.getSelectedSearchBuNo()
// BUBU
@ -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;

Loading…
Cancel
Save