1.html部分
<el-table @sort-change="sortChangeJF" v-show="tableData.tableBody.length> 0" :data="tablePageData" :pagination="pagination" border style="width: 100%" max-height="440">
<el-table-column prop="fanId" type="selection" align="center" width="55"></el-table-column>
<el-table-column sortable='custom' fixed style="bottom:7px;" prop="产品型号" align="left" label="产品型号" width="150"></el-table-column>
<el-table-column prop="功率曲线及推力系数" label="功率曲线及推力系数" align="center" width="180" v-if="showEcharts">
<template slot-scope="scope">
<el-button size="mini" type="primary" plain @click="btnChartDown(scope.row)">查看图表</el-button>
</template>
</el-table-column>
<el-table-column v-if="showPT" sortable='custom' prop="平台" align="center" label="平台"></el-table-column>
<el-table-column v-if="showDWSFMJ" width="180"
sortable='custom' prop="单位扫风面积成本指数" align="center" label="单位扫风面积成本指数"></el-table-column>
</el-table>
2.js部分
//分页
pagination: {
currentPage: 1,
pageSize: 8
},
sortChangeJF(val){
this.sortChange(val, this.tableData,this.pagination)
},
sortChange(val,table,pagination){
let {column, prop, order} = val
if(!order){
table.tableBody = this.copyArr(table.allData)
pagination.currentPage = 1
return
}
let flag = order == "ascending" ? 1 : -1
if("平台" == prop || "单位扫风面积成本指数" == prop || "轮毂高度" == prop){
table.tableBody.sort(function(a,b){
return flag * (a[prop] - b[prop])
})
}else if("单机容量" == prop){
table.tableBody.sort(function(a,b){
return flag * (parseFloat(a[prop]) - parseFloat(b[prop]))
})
}else{
table.tableBody.sort(function(a,b){
return flag * (a[prop] > b[prop])
})
}
pagination.currentPage = 1
},