IStreamTableDocpan.vue 2.74 KB
Newer Older
1 2
<template>
  <div class="eContainer-table-block">
1377875331@qq.com committed
3 4 5
    <el-table 
      :data="tableData.slice((currentPage - 1) * pageSize, currentPage * pageSize)" 
      style="width: 100%"
liushikai committed
6
      class="eContainer-table"
1377875331@qq.com committed
7
      :row-class-name="tableRowClassName"
liushikai committed
8
      :header-cell-style="{background: 'rgb(235, 235, 235)', color: 'rgb(51, 51, 51)'}"
liushikai committed
9
      :border="true">
10 11 12 13 14 15 16 17 18
      <el-table-column
        v-for="(item, key) in tableColumns"
        :key="key"
				:prop="item.prop"
        :label="item.label"
        :width="item.width"
      ></el-table-column>
      <slot></slot>
    </el-table>
liushikai committed
19
    <c-col :span="16">
20 21 22 23 24 25 26 27 28 29
		<el-pagination
      class="eContainer-pagination"
      layout="prev, pager, next, jumper"
      :page-sizes="pageSizes"
      :page-size="pageSize"
      :current-page="currentPage"
      :total="tableData.length"
			@size-change="sizeChange"
			@current-change="currentChange"
    ></el-pagination>
liushikai committed
30 31
    </c-col>
    <c-col :span="8">
32
    <div class="paginationLable">当前显示第 {{(currentPage - 1) * pageSize + 1}}-{{currentPage * pageSize > tableData.length ? tableData.length : currentPage * pageSize}} 条,共 {{tableData.length}}</div>
liushikai committed
33
     </c-col>
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
  </div>
</template>

<script>
export default {
  props: {
    columns: {
      type: Array,
      default: () => {
        return [];
      },
    },
    list: {
      type: Array,
      default: () => {
        return [];
      },
    },
    column: {
      default: () => {
        return [];
      },
    }
  },
  computed: {
    tableColumns() {
      const arr = [];
      for (let i = 0; i < this.columns.length; i++) {
				const vals = this.columns[i].split(" ")
        arr.push({
          prop: vals[0],
          label: vals[1],
潘际乾 committed
66
          width: vals[2] ? vals[2] : "auto",
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96
        });
        this.column.push(vals[0]);
      }
			return arr;
    },
    tableData() {
      const temp = this.column;
      const res = [];
      return this.list.map((row) => {
				const res = {}
				for (let i = 0; i < temp.length; i++) {
					res[temp[i]] = row[temp[i]];
				}
				return res;
      });
    },
  },
  data() {
    return {
			currentPage: 1,
			pageSizes: [5, 10, 20, 30, 40, 50, 100],
			pageSize: 5
		};
  },
  methods: {
		sizeChange(size) {
			this.pageSize = size;
		},
		currentChange(currentPage) {
			this.currentPage = currentPage;
1377875331@qq.com committed
97 98 99 100
		},
    tableRowClassName(row) {
        row.row.index = row.rowIndex + (this.currentPage - 1) * this.pageSize;
    }
101 102 103 104 105 106 107 108 109 110 111
	}
};
</script>

<style>
.eContainer-table-block .paginationLable{
 font-size: 12px;
 color: #808080;
 height: 26px;
 line-height: 26px;
 float:right;
liushikai committed
112
 /* margin-top:20px; */
113 114 115 116 117 118 119 120 121 122
}
.eContainer-table-block .el-table__body-wrapper {
  overflow: auto;
}
.el-table .warning-row {
  background: oldlace;
}
.el-table .success-row {
  background: #f0f9eb;
}
liushikai committed
123

124
</style>