This commit is contained in:
liushuai
2019-01-03 19:05:42 +08:00
parent 115de385bc
commit 63cca644bb
12 changed files with 96 additions and 70 deletions

View File

@@ -17,7 +17,7 @@
@click="total1=0;pageCurrent1=1;pageSize1=10;searchTable1()">查询</el-button>
</el-card>
<el-card>
<el-table v-loading="" :data="tableData2" show-summary border style="width: 100%;max-height: 500px;" height="300px" size="mini">
<el-table v-loading="" :data="tableData2" :summary-method="getSummaries1" show-summary border style="width: 100%;max-height: 500px;" height="300px" size="mini">
<el-table-column label="项目名称" align="center" min-width="100">
<template slot-scope="scope">
{{ scope.row.项目名称 }}
@@ -56,7 +56,7 @@
</el-table>
</el-card>
<el-card>
<el-table v-loading="" :data="tableData" show-summary border style="width: 100%;max-height: 500px;" height="300px" size="mini">
<el-table v-loading="" :data="tableData" :summary-method="getSummaries" show-summary border style="width: 100%;max-height: 500px;" height="300px" size="mini">
<el-table-column label="项目名称" align="center" min-width="100">
<template slot-scope="scope">
{{ scope.row.项目名称 }}
@@ -144,6 +144,62 @@ export default {
} else {
this.$message.error('请选择项目')
}
},
getSummaries(param) {
const { columns, data } = param
const sums = []
columns.forEach((column, index) => {
if (index === 4) {
sums[index] = '合计'
return
} else if (index === 5) {
const values = data.map(item => Number(item['金额']))
if (!values.every(value => isNaN(value))) {
sums[index] = values.reduce((prev, curr) => {
const value = Number(curr)
if (!isNaN(value)) {
return Number(prev) + Number(curr)
} else {
return Number(prev)
}
}, 0)
sums[index] += ' 元(未税)'
} else {
sums[index] = 'N/A'
}
} else if (index === 6) {
sums[index] = parseInt(parseInt(sums[5]) * 1.16 * 100) / 100 + ' 元(含税)'
}
})
return sums
},
getSummaries1(param) {
const { columns, data } = param
const sums = []
columns.forEach((column, index) => {
if (index === 4) {
sums[index] = '合计'
return
} else if (index === 5) {
const values = data.map(item => Number(item['金额']))
if (!values.every(value => isNaN(value))) {
sums[index] = values.reduce((prev, curr) => {
const value = Number(curr)
if (!isNaN(value)) {
return Number(prev) + Number(curr)
} else {
return Number(prev)
}
}, 0)
sums[index] += ' 元(未税)'
} else {
sums[index] = 'N/A'
}
} else if (index === 6) {
sums[index] = parseInt(parseInt(sums[5]) * 1.16 * 100) / 100 + ' 元(含税)'
}
})
return sums
}
}
}