<template>
  <div>
    <select_proGro  @searchActive="searchActive" ></select_proGro>
    <table1 :layout="tablecols" :data="list" :opwidth="200" :custom="true" :height="tableHieght" :checkbox="true" v-on="$listeners">
      <template v-slot:customcol="scope">
        <div v-if="scope.column.columnname === 'isonsale'">
          <span v-if="scope.column.data[scope.column.columnname] === 0"
            >下架
          </span>
          <span v-if="scope.column.data[scope.column.columnname] === 1"
            >上架
          </span>
        </div>
        <p v-else>{{scope.column.data[scope.column.columnname]}}</p>
      </template>
      <template v-slot:opreation="scope">
        <div>
          <slot name="detail" :data="scope.data"></slot>
          <slot name="edit" :data="scope.data"></slot>
          <slot name="up" :data="scope.data"></slot>
          <slot name="down" :data="scope.data"></slot>
          <slot name="del" :data="scope.data"></slot>
        </div>
      </template>
      </table1>
    <!-- </tableLayout> -->
    <div style="margin-top:16px;text-align:right">
      <el-pagination
          background
          small
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
          :current-page="currentPage"
          :page-size="params.content.pageSize"
          layout="total, prev, pager, next, jumper"
          :total="total">
      </el-pagination>
    </div>
  </div>
</template>

<script>
import select_proGro from './search'
import table1 from './table'
export default {
  name: "list",
  data() {
    return {
      tableHieght:400,
      tablecols:[],
      list:[],
      total:0,
      currentPage:0,
      isonsale:true,
      isonsales:false,
      params:{
        "id": "20220922164403",
        "version":1,
        "content": {
          pageNumber:1,
          pageSize:10,
          "nocache":true,
          "where":{
            "condition":""
          }
        }
      }
    }
  },
  components:{
    select_proGro,
    table1
  },
  mounted() {
    this.listData();
  },
  methods:{
    async listData(){
      const res=await this.$api.requested(this.params)
      this.list = res.data
      this.total = res.total
      this.currentPage = res.pageNumber
    },
    searchActive(data) {
      this.params.content.where.condition = data
      this.listData()
    },
    handleSizeChange(val) {
      // console.log(`每页 ${val} 条`);
      this.params.content.pageSize = val
      this.listData()
    },
    handleCurrentChange(val) {
      // console.log(`当前页: ${val}`);
      this.params.content.pageNumber = val
      this.listData()
    },
  },
  created() {
    this.tablecols = this.tool.tabelCol(this.$route.name).productGroupTable.tablecols
  }
}

</script>
<style>

</style>