| @@ -52,11 +52,10 @@ | |||||
| <!-- 表格 --> | <!-- 表格 --> | ||||
| <div class="cen-tab"> | <div class="cen-tab"> | ||||
| <el-table :data="tableData" stripe style="width: 100%"> | |||||
| <el-table :data="tableData" stripe style="width: 100%" show-summary :summary-method="getSummaries"> | |||||
| <el-table-column prop="batchId" label="序号" align="center"> | <el-table-column prop="batchId" label="序号" align="center"> | ||||
| <template slot-scope="scope"> | <template slot-scope="scope"> | ||||
| <span v-if="scope.$index + 1 == tableData.length"> 合计/平均</span> | |||||
| <span v-else> {{ scope.$index + 1 }}</span> | |||||
| <span> {{ scope.$index + 1 }}</span> | |||||
| </template> | </template> | ||||
| </el-table-column> | </el-table-column> | ||||
| <el-table-column prop="houseName" label="项目" align="center"> | <el-table-column prop="houseName" label="项目" align="center"> | ||||
| @@ -329,6 +328,39 @@ export default { | |||||
| this.gethouseData(); | this.gethouseData(); | ||||
| }, | }, | ||||
| methods: { | methods: { | ||||
| getSummaries(param) { | |||||
| const { columns, data } = param; | |||||
| const sums = []; | |||||
| columns.forEach((column, index) => { | |||||
| if (index === 0) { | |||||
| sums[index] = '总价'; | |||||
| return; | |||||
| } | |||||
| const values = data.map(item => Number(item[column.property])); | |||||
| if (!values.every(value => isNaN(value))) { | |||||
| sums[index] = values.reduce((prev, curr) => { | |||||
| const value = Number(curr); | |||||
| if (!isNaN(value)) { | |||||
| return prev + curr; | |||||
| } else { | |||||
| return prev; | |||||
| } | |||||
| }, 0); | |||||
| // sums[index] += ' 元'; | |||||
| if (index === 7) { | |||||
| sums[index] += '%'; | |||||
| return; | |||||
| } | |||||
| if (index === 8) { | |||||
| sums[index] += '%'; | |||||
| return; | |||||
| } | |||||
| } | |||||
| }); | |||||
| sums[1] = 'N/A'; | |||||
| return sums; | |||||
| }, | |||||
| downLoad() { | downLoad() { | ||||
| let pamaet = { | let pamaet = { | ||||
| orgType: this.role, | orgType: this.role, | ||||