File tree 1 file changed +30
-1
lines changed
src/components/page/operation 1 file changed +30
-1
lines changed Original file line number Diff line number Diff line change 15
15
</el-form >
16
16
</el-col >
17
17
<!-- 列表-->
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"
19
19
style =" width : 100% ;" >
20
20
<!-- <el-table-column type="selection" width="55">-->
21
21
<!-- </el-table-column>-->
136
136
this .listLoading = false ;
137
137
});
138
138
},
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
+ },
139
168
},
140
169
mounted () {
141
170
this .initOSSAuth ();
You can’t perform that action at this time.
0 commit comments