|
@@ -56,9 +56,9 @@ export default {
|
|
|
storageKey: {
|
|
|
type: String,
|
|
|
},
|
|
|
- showSummary:{
|
|
|
- type:Boolean,
|
|
|
- default:false,
|
|
|
+ showSummary: {
|
|
|
+ type: Boolean,
|
|
|
+ default: false,
|
|
|
},
|
|
|
},
|
|
|
components: {
|
|
@@ -98,7 +98,6 @@ export default {
|
|
|
// 过滤
|
|
|
filterData: [],
|
|
|
filterState: false,
|
|
|
-
|
|
|
};
|
|
|
},
|
|
|
computed: {
|
|
@@ -152,15 +151,15 @@ export default {
|
|
|
this.filterData = multiFilter(this.$props.value, newValue);
|
|
|
},
|
|
|
},
|
|
|
- value:{
|
|
|
+ value: {
|
|
|
handler: function (newValue) {
|
|
|
- if(this.value.length > 0){
|
|
|
- this.$refs.superTable&& this.$refs.superTable.clearSelection();
|
|
|
+ if (this.value.length > 0) {
|
|
|
+ this.$refs.superTable && this.$refs.superTable.clearSelection();
|
|
|
}
|
|
|
},
|
|
|
immediate: true,
|
|
|
- deep:true
|
|
|
- }
|
|
|
+ deep: true,
|
|
|
+ },
|
|
|
},
|
|
|
methods: {
|
|
|
//
|
|
@@ -274,47 +273,47 @@ export default {
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
- getSummaries(param){
|
|
|
- if(this.showSummary){
|
|
|
+ getSummaries(param) {
|
|
|
+ if (this.showSummary) {
|
|
|
const { columns, data } = param;
|
|
|
- const sums = [];
|
|
|
- columns.forEach((column, index) => {
|
|
|
+ const sums = [];
|
|
|
+ columns.forEach((column, index) => {
|
|
|
+ if (index === 0 && !column.property) {
|
|
|
+ sums[index] = "合计";
|
|
|
+ return;
|
|
|
+ }
|
|
|
|
|
|
- if (index === 0 && !column.property) {
|
|
|
- sums[index] = '合计';
|
|
|
- return;
|
|
|
- }
|
|
|
+ const values = data.map((item) => Number(item[column.property]));
|
|
|
+ // if (column.property == 'businessProportion' ||column.property =='rankMagnitude' ) {
|
|
|
|
|
|
- const values = data.map(item => Number(item[column.property]));
|
|
|
- // if (column.property == 'businessProportion' ||column.property =='rankMagnitude' ) {
|
|
|
+ let sumColumn = this.showColumns.filter(
|
|
|
+ ({ item, attr }) => attr.isSummary && item.key === column.property
|
|
|
+ );
|
|
|
|
|
|
- let sumColumn = this.showColumns.filter(({item,attr}) => attr.isSummary && item.key === column.property);
|
|
|
-
|
|
|
- if (sumColumn.length) {
|
|
|
- sums[index] = values.reduce((prev, curr) => {
|
|
|
- const value = Number(curr);
|
|
|
- if (!isNaN(value)) {
|
|
|
- return prev + curr;
|
|
|
- } else {
|
|
|
- return prev + 0;
|
|
|
- }
|
|
|
- }, 0);
|
|
|
- sums[index] = sums[index] && sums[index].toFixed(2) // 保留2位小数,解决小数合计列;
|
|
|
+ if (sumColumn.length) {
|
|
|
+ sums[index] = values.reduce((prev, curr) => {
|
|
|
+ const value = Number(curr);
|
|
|
+ if (!isNaN(value)) {
|
|
|
+ return prev + curr;
|
|
|
+ } else {
|
|
|
+ return prev + 0;
|
|
|
+ }
|
|
|
+ }, 0);
|
|
|
+ sums[index] = sums[index] && sums[index].toFixed(2); // 保留2位小数,解决小数合计列;
|
|
|
}
|
|
|
- });
|
|
|
- return sums;
|
|
|
-
|
|
|
+ });
|
|
|
+ return sums;
|
|
|
}
|
|
|
- }
|
|
|
+ },
|
|
|
},
|
|
|
created() {},
|
|
|
mounted() {
|
|
|
this.extendMethod();
|
|
|
},
|
|
|
updated() {
|
|
|
- this.$nextTick(()=>{
|
|
|
+ this.$nextTick(() => {
|
|
|
this.$refs.superTable.doLayout();
|
|
|
- })
|
|
|
+ });
|
|
|
},
|
|
|
destroyed() {},
|
|
|
};
|
|
@@ -470,9 +469,7 @@ export default {
|
|
|
<component v-if="attr.formatter" is="span">{{
|
|
|
attr.formatter(scope.row)
|
|
|
}}</component>
|
|
|
- <component v-else is="span">{{
|
|
|
- scope.row[item.key] || "--"
|
|
|
- }}</component>
|
|
|
+ <component v-else is="span">{{ scope.row[item.key] }}</component>
|
|
|
</template>
|
|
|
</slot>
|
|
|
</template>
|