金长 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条)

报告相同问题?

悬赏问题

  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!