Skip to content

Commit 08e85da

Browse files
committed
报表支持统计汇总
1 parent 165e9c5 commit 08e85da

File tree

1 file changed

+30
-1
lines changed

1 file changed

+30
-1
lines changed

src/components/page/operation/OperatingAccountManage.vue

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
</el-form>
1616
</el-col>
1717
<!--列表-->
18-
<el-table :data="records" border highlight-current-row v-loading="listLoading"
18+
<el-table :data="records" :summary-method="getSummaries" show-summary border highlight-current-row v-loading="listLoading"
1919
style="width: 100%;">
2020
<!--<el-table-column type="selection" width="55">-->
2121
<!--</el-table-column>-->
@@ -136,6 +136,35 @@
136136
this.listLoading = false;
137137
});
138138
},
139+
getSummaries(param) {
140+
const {columns, data} = param;
141+
const sums = [];
142+
columns.forEach((column, index) => {
143+
if (index === 0) {
144+
sums[index] = '合计';
145+
return;
146+
}
147+
if (index === 1) {
148+
sums[index] = 'N/A';
149+
return;
150+
}
151+
const values = data.map(item => Number(item[column.property]));
152+
if (!values.every(value => isNaN(value))) {
153+
sums[index] = values.reduce((prev, curr) => {
154+
const value = Number(curr);
155+
if (!isNaN(value)) {
156+
return prev + curr;
157+
} else {
158+
return prev;
159+
}
160+
}, 0);
161+
sums[index] += '';
162+
} else {
163+
sums[index] = 'N/A';
164+
}
165+
});
166+
return sums;
167+
},
139168
},
140169
mounted() {
141170
this.initOSSAuth();

0 commit comments

Comments
 (0)