zoukankan      html  css  js  c++  java
  • table表格+ 分页 封装

    参数说明:

    pageSize:每页显示多少条
    pageCount:总共多少页
    pageIndex:当前是第几页(这里是从0开发)
    <template>
      <div>
        <el-table :data="traceTableList" class="border-all table-components-content" border style=" 100%;height:100%;">
          <el-table-column v-for="(headEle, index) in headerTraceTableList" :key="index" :prop="headEle.prop" :label="headEle.label" :width="headEle.width" :min-width="headEle.minWidth">
            <template slot-scope="scope">
              <!-- :class="{'text-warn': scope.row[headEle.prop]<0 }" -->
              <span :class="{'text-danger': (headEle.isWarning && scope.row[headEle.prop]) < 0}">{{ scope.row[headEle.prop] }}</span>
            </template>
          </el-table-column>
        </el-table>
        <div v-if="showPage" class="page-container margin-t-10">
          <el-button type="primary" size="mini" icon="el-icon-arrow-left" :disabled="pageIndex===0" @click="handleLeftPage" />
          <span class="text-color-3">{{ pageIndex + 1 }}</span>
          <el-button type="primary" size="mini" icon="el-icon-arrow-right" :disabled="pageIndex < pageInfo.pageCount" @click="handleRightPage" />
        </div>
      </div>
    </template>
    <script>
      export default {
        name: 'TraceTable',
        props: {
          headerTraceTableList: {
            type: Array,
            default: function () {
              return []
            }
          },
          traceTableList: {
            type: Array,
            default: function () {
              return []
            }
          },
          showPage: {
            type: Boolean,
            default: false
          },
          pageInfo: {
            type: Object,
            default: function () {
              return {
                pageCount: 0,
                pageSize: 20
              }
            }
          }
        },
        data () {
          return {
            pageIndex: 0
          }
        },
        methods: {
          handleLeftPage () {
            this.pageIndex--
            this.$emit('turnPage', { pageIndex: this.pageIndex, pageSize: this.pageInfo.pageSize })
          },
          // 右分页
          handleRightPage () {
            this.pageIndex++
            this.$emit('turnPage', { pageIndex: this.pageIndex, pageSize: this.pageInfo.pageSize })
          }
        }
      }
    </script>
    <style scoped>
      .page-container > span {
        width: 35px;
        height: 28px;
        display: inline-block;
        text-align: center;
      }
    </style>
    View Code
  • 相关阅读:
    2018-2019-2 实验三 敏捷开发与XP实践
    计算机网络课外实验一级 20175319江野
    2018-2019-2 《Java程序设计》第9周学习总结
    MyCP(课下作业,必做)
    [NOIP2012] 疫情控制
    [SPOJ2021] Moving Pebbles
    谁能赢呢?
    [HEOI2014] 人人尽说江南好
    [笔记] 巴什博弈
    [SCOI2008] 着色方案
  • 原文地址:https://www.cnblogs.com/phermis/p/11864313.html
Copyright © 2011-2022 走看看