PagingTable.vue 2.48 KB
Newer Older
fukai committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 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 66 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 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123
<template>
  <div class="eContainer-table-block">
    <el-table
      ref="table"
      :data="data"
      style="width: 100%"
      class="eContainer-table"
      :header-cell-style="{
        background: 'rgb(235, 235, 235)',
        color: 'rgb(51, 51, 51)',
      }"
      :highlight-current-row="true"
      :border="true"
      max-height="540"
			v-bind="$attrs"
			v-on="$listeners"
      @selection-change="handleSelectionChange"
    >
			<el-table-column
				type="selection"
				v-if="showSelection"
				:reserve-selection="true"
			></el-table-column>
      <c-table-column
        v-for="(item, key) in columns"
        :key="key"
        :prop="item.prop"
        :label="item.label"
        :min-width="item.width"
        sortable
				:show-overflow-tooltip="showTooltip || item.showTooltip"
      >
        <template v-slot="{ scope }">
          <span>{{ scope.row[item.prop] }}</span>
        </template>
      </c-table-column>
      <slot></slot>
    </el-table>
    <c-col :span="24">
      <el-pagination
        class="eContainer-pagination"
        layout="prev, pager, next, jumper, ->, sizes, total"
        :page-sizes="pageSizes"
        :page-size="pageSize"
        :current-page="pageNumber"
        :total="total"
        @size-change="sizeChange"
        @current-change="currentChange"
      ></el-pagination>
    </c-col>
  </div>
</template>


<script>
import CodeTable from "~/config/CodeTable";

/**
 * 后端分页的 Table 组件
 */
export default {
  props: {
    columns: {
      type: Array,
      default: () => {
        return [];
      },
    },
    data: {
      type: Array,
      default: () => {
        return [];
      },
    },
    pageNumber: {
      type: Number,
      default: 1,
    },
    pageSize: {
      type: Number,
      default: 1,
    },
    total: {
      type: Number,
      default: 0,
    },
    showSelection: {
      type: Boolean,
      default: false,
    },
    showTooltip: {
      type: Boolean,
      default: true,
    },
  },
  data() {
    return {
      pageSizes: [5, 10, 20, 30, 40, 50, 100],
      codes: {
        ...CodeTable,
      },
      multipleSelection: []
    };
  },
  mounted() {
		console.log("columns",this.columns)
	},
  methods: {
    sizeChange(size) {
      this.$emit("queryFunc", this.pageNumber, size);
    },
    currentChange(currentPage) {
      this.$emit("queryFunc", currentPage, this.pageSize);
    },
    handleSelectionChange(val){
      this.multipleSelection = val;
    },
  },
};
</script>

<style scoped>
</style>