<template>
  <div>
    <el-table v-loading='tableLoading' :data='tableData' border max-height="500px">
      <el-table-column align="center" prop="frameName" label="密集架名称"></el-table-column>
      <el-table-column align="center" prop="layerWidth" label="密集架宽度"></el-table-column>
      <el-table-column align="center" label="操作" width="250px">
        <template slot-scope="scope">
          <el-button @click="edit('修改',scope.row)" v-if="showButtons.edit" type="text">修改</el-button>
          <el-button @click="del(scope.row.id)" v-if="showButtons.del" type="text" style="color:#FF4949">删除</el-button>
        </template>
      </el-table-column>
    </el-table>
    <el-pagination @current-change="handleCurrentChange" @size-change="handleSizeChange"
      layout="total, prev, pager, next, sizes" :page-size="pagination.pageSize" :page-sizes="[10, 20, 30, 50]"
      :current-page="pagination.pageNum" :total="pagination.total">
    </el-pagination>
  </div>
</template>
<script>
  export default {
    props: {
      tableLoading: {
        type: Boolean,
        default: () => false,
      },
      tableData: {
        type: Array,
        default: () => [],
      },
      pagination: {
        type: Object,
        default: () => {},
      },
      showButtons: {
        type: Object,
        default: () => {},
      },
    },
    data() {
      return {

      }
    },
    methods: {
      handleCurrentChange(val) {
        this.pagination.pageNum = val;
        this.$emit("getData");
      },
      handleSizeChange(val) {
        this.pagination.pageSize = val;
        this.pagination.pageNum = 1;
        this.$emit("getData");
      },
      edit(str, val) {
        this.$emit('edit', str, val)
      },
      del(id) {
        this.$confirm('此操作将永久删除该文件, 是否继续?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          this.$store.dispatch('denseFrameParameters/deleteData', {
            id
          }).then(res => {
            this.$emit('getData')
          })
        }).catch(() => {});
      }
    }
  }

</script>
<style lang='scss' scoped>

</style>
