|
@@ -49,7 +49,16 @@
|
|
|
sortable
|
|
|
resizable
|
|
|
:min-width="item.width ? item.width : 70"
|
|
|
- />
|
|
|
+ >
|
|
|
+ <template #default="scope" v-if="item.styleFn">
|
|
|
+ <span :style="item.styleFn(scope.row)">{{
|
|
|
+ scope.row[item.prop]
|
|
|
+ }}</span>
|
|
|
+ </template>
|
|
|
+ <template #default="scope" v-else>
|
|
|
+ <span>{{ scope.row[item.prop] }}</span>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
<template #empty>
|
|
|
<div class="nodata">
|
|
|
<img :src="nodata" alt="" />
|
|
@@ -150,58 +159,63 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
getSummaries(datas) {
|
|
|
- const {columns, data} = datas
|
|
|
+ const { columns, data } = datas;
|
|
|
const sums = [];
|
|
|
columns.forEach((column, index) => {
|
|
|
- const values = data.map(item => Number(item[column.property]));
|
|
|
+ const values = data.map((item) => Number(item[column.property]));
|
|
|
if (index === 0) {
|
|
|
- if (this.fromTableId === '2') {
|
|
|
- this.getSunOrAvg(1, sums, index, values)
|
|
|
+ if (this.fromTableId === "2") {
|
|
|
+ this.getSunOrAvg(1, sums, index, values);
|
|
|
} else {
|
|
|
// if (this.fromTableId === '1' || this.fromTableId === '3' || this.fromTableId === '4' || this.fromTableId === '5' || this.fromTableId === '6')
|
|
|
- sums[index] = '合计';
|
|
|
- return
|
|
|
- }
|
|
|
+ sums[index] = "合计";
|
|
|
+ return;
|
|
|
+ }
|
|
|
}
|
|
|
- if (!values.every(value => isNaN(value))) {
|
|
|
- if (this.fromTableId === '1') {
|
|
|
- if (index === 1 || index === 5 || index === 11 || index === 12 || index === 13) {
|
|
|
- this.getSunOrAvg(2, sums, index, values)
|
|
|
+ if (!values.every((value) => isNaN(value))) {
|
|
|
+ if (this.fromTableId === "1") {
|
|
|
+ if (
|
|
|
+ index === 1 ||
|
|
|
+ index === 5 ||
|
|
|
+ index === 11 ||
|
|
|
+ index === 12 ||
|
|
|
+ index === 13
|
|
|
+ ) {
|
|
|
+ this.getSunOrAvg(2, sums, index, values);
|
|
|
} else {
|
|
|
- this.getSunOrAvg(1, sums, index, values)
|
|
|
+ this.getSunOrAvg(1, sums, index, values);
|
|
|
}
|
|
|
- } else if (this.fromTableId === '2' || this.fromTableId === '5') {
|
|
|
+ } else if (this.fromTableId === "2" || this.fromTableId === "5") {
|
|
|
if (index !== 0) {
|
|
|
- this.getSunOrAvg(2, sums, index, values)
|
|
|
+ this.getSunOrAvg(2, sums, index, values);
|
|
|
}
|
|
|
- } else if (this.fromTableId === '3') {
|
|
|
+ } else if (this.fromTableId === "3") {
|
|
|
if (index === 2) {
|
|
|
- this.getSunOrAvg(2, sums, index, values)
|
|
|
+ this.getSunOrAvg(2, sums, index, values);
|
|
|
} else {
|
|
|
- this.getSunOrAvg(1, sums, index, values)
|
|
|
+ this.getSunOrAvg(1, sums, index, values);
|
|
|
}
|
|
|
- } else if (this.fromTableId === '4') {
|
|
|
+ } else if (this.fromTableId === "4") {
|
|
|
if (index === 1) {
|
|
|
- this.getSunOrAvg(2, sums, index, values)
|
|
|
+ this.getSunOrAvg(2, sums, index, values);
|
|
|
} else {
|
|
|
- this.getSunOrAvg(1, sums, index, values)
|
|
|
+ this.getSunOrAvg(1, sums, index, values);
|
|
|
}
|
|
|
- } else if (this.fromTableId === '6') {
|
|
|
+ } else if (this.fromTableId === "6") {
|
|
|
if (index === 3 || index === 9) {
|
|
|
- this.getSunOrAvg(1, sums, index, values)
|
|
|
+ this.getSunOrAvg(1, sums, index, values);
|
|
|
} else {
|
|
|
- this.getSunOrAvg(2, sums, index, values)
|
|
|
+ this.getSunOrAvg(2, sums, index, values);
|
|
|
}
|
|
|
- } else if (this.fromTableId === '7') {
|
|
|
+ } else if (this.fromTableId === "7") {
|
|
|
if (index === 2 || index === 3) {
|
|
|
- this.getSunOrAvg(2, sums, index, values)
|
|
|
+ this.getSunOrAvg(2, sums, index, values);
|
|
|
} else {
|
|
|
- this.getSunOrAvg(1, sums, index, values)
|
|
|
+ this.getSunOrAvg(1, sums, index, values);
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
} else {
|
|
|
- sums[index] = '-';
|
|
|
+ sums[index] = "-";
|
|
|
}
|
|
|
});
|
|
|
|
|
@@ -209,25 +223,26 @@ export default {
|
|
|
},
|
|
|
getSunOrAvg(type, sums, index, values) {
|
|
|
if (type === 1) {
|
|
|
- sums[index] = values.reduce((prev, curr) => {
|
|
|
+ sums[index] =
|
|
|
+ values.reduce((prev, curr) => {
|
|
|
const value = Number(curr);
|
|
|
if (!isNaN(value)) {
|
|
|
- return prev + curr;
|
|
|
+ return prev + curr;
|
|
|
} else {
|
|
|
- return prev;
|
|
|
+ return prev;
|
|
|
}
|
|
|
- }, 0) / values.length;
|
|
|
- return sums[index] = sums[index].toFixed(2) + ' (avg)';
|
|
|
+ }, 0) / values.length;
|
|
|
+ return (sums[index] = sums[index].toFixed(2) + " (avg)");
|
|
|
} else {
|
|
|
sums[index] = values.reduce((prev, curr) => {
|
|
|
- const value = Number(curr);
|
|
|
- if (!isNaN(value)) {
|
|
|
- return prev + curr;
|
|
|
- } else {
|
|
|
- return prev;
|
|
|
- }
|
|
|
+ const value = Number(curr);
|
|
|
+ if (!isNaN(value)) {
|
|
|
+ return prev + curr;
|
|
|
+ } else {
|
|
|
+ return prev;
|
|
|
+ }
|
|
|
}, 0);
|
|
|
- return sums[index] = sums[index].toFixed(2)
|
|
|
+ return (sums[index] = sums[index].toFixed(2));
|
|
|
}
|
|
|
},
|
|
|
handleExport() {
|