<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>
    <el-input style="width:270px" placeholder="请输入内容" v-model="param.content.where.condition" class="input-with-select normal-margin" size="small" clearable>
      <el-button slot="append" icon="el-icon-search"  @click="listData(param.content.departmentid)">查 询</el-button>
    </el-input>
    <!-- <tableLayout :layout="tablecols" :data="list" :opwidth="200" :custom="false" height="calc(100vh - 508px)">
      <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> -->
    <el-table
      :data="list"
      size="mini"
      border
      style="width: 100%">
      <el-table-column
        prop="hrcode"
        label="编号">
      </el-table-column>
      <el-table-column
        prop="name"
        label="姓名">
      </el-table-column>
      <el-table-column
        prop="phonenumber"
        label="手机号">
      </el-table-column>
      <el-table-column
        prop="depname"
        label="部门">
      </el-table-column>
      <el-table-column
        prop="position"
        label="职位">
      </el-table-column>
      <el-table-column
        label="操作">
        <template slot-scope="scope">
           <slot name="detail" :data="scope.row"></slot>
        </template>
      </el-table-column>
    </el-table>
    <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,
    }
  },
  methods:{
    async listData (id) {
      this.param.content.departmentids = [id]
      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('depManage')['staffTable'].tablecols
  }
}

</script>
<style>
</style>