Files
vxe-table/examples/views/table/scroll/ScrollFullCols.vue
xuliangzhan ceda1077db update
2019-05-08 19:20:07 +08:00

89 lines
2.6 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<template>
<div>
<p>加载 10 万行 1 万列左右固定列表尾合计</p>
<p>实际渲染速度受以下影响固定列底部合计数据运算量任何双向的数据或函数都会影响加载速度</p>
<vxe-table
ref="xTable"
border
resizable
show-footer
height="600"
:footer-method="footerMethod"
:footer-cell-class-name="footerCellClassName"
:loading="loading">
<vxe-table-column type="index" width="100" fixed="left"></vxe-table-column>
<vxe-table-column v-for="(item, index) in tableColumn" :key="index" prop="name" :label="`column_${index}`" width="200"></vxe-table-column>
<vxe-table-column prop="rate" label="Rate" width="200" fixed="right"></vxe-table-column>
</vxe-table>
</div>
</template>
<script>
import XEUtils from 'xe-utils'
export default {
data () {
return {
loading: false,
tableColumn: []
}
},
created () {
this.loading = true
this.$nextTick(() => {
this.$refs.xTable.reload([])
setTimeout(() => {
let list = window.MOCK_DATA_LIST.slice(0, 100000)
this.tableColumn = window.MOCK_DATA_LIST.slice(0, 10000)
this.$nextTick(() => this.$refs.xTable.reload(list))
this.loading = false
}, 500)
})
},
methods: {
footerCellClassName ({ rowIndex, column, columnIndex }) {
if (columnIndex === 0) {
if (rowIndex === 0) {
return 'col-blue'
} else {
return 'col-red'
}
}
},
footerMethod ({ columns, data }) {
return [
columns.map((column, columnIndex) => {
if (columnIndex === 0) {
return '平均'
} else if (column.property === 'age') {
return `${parseInt(XEUtils.mean(data, column.property))}`
} else if (column.property === 'rate') {
return `${parseInt(XEUtils.mean(data, column.property))}`
}
return '-'
}),
columns.map((column, columnIndex) => {
if (columnIndex === 0) {
return '和值'
} else if (column.property === 'rate') {
return `总分 ${XEUtils.sum(data, column.property)}`
}
return '-'
}),
columns.map((column, columnIndex) => {
if (columnIndex === 0) {
return '统计'
}
if (column.property === 'sex') {
let rest = XEUtils.groupBy(data, column.property)
return `${rest[1] ? rest[1].length : 0} 人,女 ${rest[0] ? rest[0].length : 0}`
}
return '-'
})
]
}
}
}
</script>