<mu-data-table selectable select-all :selects.sync="selects" :loading="tableLoading"
:columns="columns" :sort.sync="sort" @sort-change="handleSortChange" :data="list" >
<template slot-scope="scope">
<td>{{scope.row.title}}</td>
<td class="is-right" style="padding-right: 20px;padding-left: 0px">{{scope.row.createdUserName}}</td>
<td class="is-right" style="padding-right: 65px;padding-left: 0px">{{scope.row.averageScore|filteringDigital}}</td>
<td class="is-right" style="padding-right: 0px;padding-left: 0px">{{scope.row.createdTime|dateFmt('YYYY-MM-DD HH:mm:ss')}}</td>
<td class="is-right" style="padding-right: 150px;">
<mu-menu >
<mu-button color="primary" small flat>操作<mu-icon right value="arrow_drop_down"></mu-icon></mu-button>
<mu-list slot="content">
<mu-list-item button @click="details(scope.row.id)">
<mu-list-item-title>详情</mu-list-item-title>
</mu-list-item>
</mu-list>
</mu-menu>
</td>
<td class="is-right">{{scope.row.iron}}</td>
</template>
</mu-data-table>
<mu-flex justify-content="end" style="margin-top:24px;">
<mu-pagination :sort="sort" :total="current.totalSize" :current.sync="current.page" :page-size="current.pageSize" @change="changePage()"></mu-pagination>
</mu-flex>
</mu-paper>
script
handleSortChange ({name, order}) {
if(name === 'score'){
this.list = this.list.sort((a, b) =>
order === 'asc' ? a[name] - b[name] : b[name] - a[name]
);
}else{
this.list =this.list.sort((a,b) => {
let aTimeString = a[name];
let bTimeString = b[name];
let aTime = Number(new Date(aTimeString).getTime());
let bTime = Number(new Date(bTimeString).getTime());
if(order === 'asc'){
return aTime-bTime
}else {
return bTime-aTime
}
})
}
console.log(this.list)
},
loadRethinkList(title){
this.tableLoading = true;
testpage({
currentPage:this.current.page,
pageSize:this.current.pageSize,
start:0,
data:{status:1,title:title}
}).then(res =>{
if (res.code == 200) {
this.list = res.data.list;
this.current.totalSize = res.data.total;
this.current.page = res.data.currentPage;
console.log(res.data.list)
} else {
this.$toast.warning("量表列表获取失败: " + res.message)
}
this.tableLoading = false;
})
},
changePage(){
this.loadRethinkList()
},
details(id){
this.$router.push({path: '/rethink/info',name: "RethinkInfo", params:{ rethinkId: id }});
}
},