Commit 8b01419b by liwk

表格增加合计

1 parent 94e7a239
......@@ -13,6 +13,7 @@
@selection-change="handleSelect"
size="medium"
:show-summary="tableParams.showSummary"
:summary-method="tableParams.summaryMethod"
>
<el-table-column
v-if="tableParams.mutiSelectUniqueKey && tableParams.mutiSelectName"
......
......@@ -158,7 +158,7 @@ export default {
cardNo: '123',
activationCode: '恒河猴22',
memberName: 'SS2W',
sn: '56456456',
sn: 1,
updatedDate: 'JKHSJKSH',
cardNoSSS: 'SHJJKHK',
AAA: '掉接口',
......@@ -170,7 +170,7 @@ export default {
cardNo: '123',
activationCode: '恒河猴22',
memberName: 'SS2W',
sn: '56456456',
sn: 2,
updatedDate: 'JKHSJKSH',
cardNoSSS: 'SHJJKHK',
AAA: '掉接口',
......@@ -182,7 +182,7 @@ export default {
cardNo: '123',
activationCode: '恒河猴22',
memberName: 'SS2W',
sn: '56456456',
sn: 3,
updatedDate: 'JKHSJKSH',
cardNoSSS: 'SHJJKHK',
AAA: '掉接口',
......@@ -194,7 +194,7 @@ export default {
cardNo: '123',
activationCode: '恒河猴22',
memberName: 'SS2W',
sn: '56456456',
sn: 4,
updatedDate: 'JKHSJKSH',
cardNoSSS: 'SHJJKHK',
AAA: '掉接口',
......@@ -206,6 +206,30 @@ export default {
tableParams: {
// listName: 'list',
showSummary: true,
summaryMethod ({ columns, data }) {
let 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] += ' 元'
} else {
sums[index] = ''
}
})
return sums
},
tableColumns: [
{
label: '订单编号',
......@@ -221,6 +245,7 @@ export default {
label: '商品形态',
prop: 'sn',
minWidth: '200',
},
{
label: '商品名称',
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!