<template>
  <div class="container normal-panel">
    <p class="normal-title normal-margin">业务员信息</p>
    <div class="flex-align-center flex-between normal-margin">
      <el-input style="width:270px" placeholder="请输入内容" v-model="param.content.where.condition" class="input-with-select" size="small" clearable>
        <el-button slot="append" icon="el-icon-search"  @click="query_saler(param.content.sa_saleareaid)">查 询</el-button>
      </el-input>
      <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>
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
    },
    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>