<template>
  <div class="container normal-panel">
    <div class="flex-align-center flex-between">
      <p class="normal-title normal-margin">员工信息</p>
      <slot name="staff"></slot>
    </div>
    <div class="flex-align-center normal-margin search-panel">
      <p>搜索:&nbsp;</p>
      <el-input style="width:200px" size="small" placeholder="姓名,手机号,职位" @clear="search" @keyup.native.enter="search"  v-model="param.content.where.condition" prefix-icon="el-icon-search" clearable></el-input>
    </div>
    <tableLayout :layout="tablecols" :data="list" :custom="true" height="500px">
      <template v-slot:customcol="scope">
        <p>{{scope.column.data[scope.column.columnname]}}</p>
      </template>
      <template v-slot:opreation="scope">
        <slot name="detail" :data="scope.data"></slot>
        <slot name="edit" :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 {
  data () {
    return {
      param:{
        "classname": "webmanage.hr.hr",
        "method": "query_hrList",
        "content": {
            "nocahe":true,
            "pageNumber": 1,
            "pageSize": 20,
            "departmentids":null,
            "containssub":1,
            "where": {
              "condition": ""
            }
        }
      },
      tablecols:[],
      list:[],
      total:0,
      currentPage:0,
      depid:null
    }
  },
  methods:{
    search () {
      this.param.content.pageNumber = 1
      this.listData (this.depid)
    },
    async listData (id) {
      this.depid = id
      this.param.content.departmentids = [this.depid]
      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.listData()
    },
    handleCurrentChange(val) {
      // console.log(`当前页: ${val}`);
      this.param.content.pageNumber = val
      this.listData()
    }
  },
  mounted () {
    this.tablecols = this.tool.tabelCol(this.$route.name)['staffTable'].tablecols
  }
}

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