金长 2019-11-05 15:25 采纳率: 0%
浏览 614
已采纳

分页排序只排当页数据,有没有什么办法可以让把所有的数据都排上?下面放代码,求大佬指导参考


              <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 }});
           }
         },
  • 写回答

4条回答 默认 最新

  • 浅析丶 2019-11-05 15:34
    关注

    先给数据排了序再分页

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥60 爬虫登录易班工作站后台失败(相关搜索:登录页面)
  • ¥15 机器人关节变量求解问题
  • ¥15 ros小车启动launch文件报错
  • ¥15 vs2015到期想登陆但是登陆不上
  • ¥20 Intellij实现web登录界面
  • ¥15 IPQ5018制作烧录固件,boot运行失败(操作系统-linux)(相关搜索:操作系统)(相关搜索:操作系统)
  • ¥20 icefall在librispeech基础上加入个人数据集
  • ¥30 keepalive高可用故障运维配置询问
  • ¥15 求帮助!国家电网内网u盘突然识别不出来了。
  • ¥15 matlab语音变速变调同时实现