<template>
  <div class="container normal-panel">
    <p class="normal-title normal-margin">业务员信息</p>
    <div class="flex-align-center flex-between normal-margin">
      <div class="flex-align-center  search-panel">
        <p>搜索:</p>
        <el-input style="width:200px" size="small" placeholder="业务员名称,编号,手机号" @keyup.native.enter="query_saler(param.content.sa_saleareaid)" @clear="(param.content.where.condition = '',query_saler(param.content.sa_saleareaid))" v-model="param.content.where.condition" prefix-icon="el-icon-search" clearable></el-input>
      </div>
      <div>
        <slot name="agent_type"></slot>
        <slot name="add"></slot>
      </div>
    </div>
    <tableLayout :layout="tablecols" :data="list" :custom="false" height="calc(100vh - 495px)">
      <template v-slot:opreation="scope">
        <slot name="detail" :data="scope.data"></slot>
        <slot name="del" :data="scope.data"></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>
import { log } from '@antv/g2plot/lib/utils'
export default {
  props:['data'],
  data () {
    return {
      tablecols:[],
      list:[],
      total:0,
      currentPage:1,
      param:{
        "classname": "webmanage.sale.salearea.salearea",
        "method": "query_saler",
        "content": {
          "pageSize":20,
          "pageNumber":1,
          "sa_saleareaid":'',
          "where":{}
        }
      }
    }
  },
  methods:{
    async query_saler (sa_saleareaid) {
      this.param.content.sa_saleareaid = sa_saleareaid
      const res = await this.$api.requested(this.param)
      this.list = res.data
      this.total = res.total
      this.currentPage = res.pageNumber
      console.log(this.list);
      
    },
    handleSizeChange(val) {
      // console.log(`每页 ${val} 条`);
      this.param.content.pageSize = val
      this.query_saler(this.param.content.sa_saleareaid)
    },
    handleCurrentChange(val) {
      // console.log(`当前页: ${val}`);
      this.param.content.pageNumber = val
      this.query_saler(this.param.content.sa_saleareaid)
    }
  },
  mounted () {
    // this.query_saler()
  },
  created () {
    // 获取角色表结构
    this.tablecols = this.tool.tabelCol(this.$route.name)['salerTable'].tablecols
  }
}

</script>
<style>
</style>
<style scoped>
.search-panel p{
  width:40px;
  font-size:14px
}
</style>