<template>
  <div class="container normal-panel">
    <tableLayout :layout="tablecols" :data="list" :opwidth="200" :custom="true" height="calc(100vh - 175px)">
      <template v-slot:customcol="scope">
        <div v-if="scope.column.columnname === 'status'">
          <span v-if="scope.column.data.isontop === 1" style="color:#FF3B30">置顶</span>
          <div v-else>
            <span v-if="scope.column.data[scope.column.columnname] === '发布'" style="color:#52C41A">{{scope.column.data[scope.column.columnname]}}</span>
            <span v-else>{{scope.column.data[scope.column.columnname]}}</span>
          </div>
        </div>
        <p v-else>{{scope.column.data[scope.column.columnname]}}</p>
      </template>
      <template v-slot:opreation="scope">
        <slot name="edit" :data="scope"></slot>
        <slot name="release" :data="scope"></slot>
        <slot name="topping" :data="scope"></slot>
        <slot name="message" :data="scope"></slot>
        <slot name="data_statistics" :data="scope"></slot>
        <slot name="del" :data="scope"></slot>
      </template>
    </tableLayout>
    <div style="margin-top:16px;text-align:right">
      <el-pagination
        background
        small
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page="currentPage"
        :page-size="param.content.pageSize"
        layout="total, prev, pager, next, jumper"
        :total="total">
      </el-pagination>
    </div>
  </div>
</template>

<script>
export default {
  data () {
    return {
      param:{
        "classname": "webmanage.coderule.coderule",
        "method": "query_coderuleList",
        "content": {
          "pageSize":10,
          "pageNumber":1
        }
      },
      tablecols:{},
      list:[],
      total:0,
      currentPage:0,
    }
  },
  methods:{
    async query_coderuleList () {
      const res = await this.$api.requested(this.param)
      this.list = res.data
      this.total = res.total
      this.currentPage = res.pageNumber
    },
    handleSizeChange(val) {
      // console.log(`每页 ${val} 条`);
      this.params.content.pageSize = val
      this.query_coderuleList()
    },
    handleCurrentChange(val) {
      // console.log(`当前页: ${val}`);
      this.params.content.pageNumber = val
      this.query_coderuleList()
    },
  },
  created () {
    this.tablecols = this.tool.tabelCol(this.$route.name)['coderuleTable'].tablecols
  },
  mounted () {
    this.query_coderuleList()
    
  }
}

</script>
<style>
</style>