<template>
  <div v-loading="loading">
    <el-drawer title="选择员工" size="240" :visible.sync="drawer" direction="rtl">     
      <div class="search-box">
        <el-input placeholder="输入关键字进行过滤" size="small" v-model="searchModel.keyWord">
          <el-button slot="append" icon="el-icon-search" @click="getManager"></el-button>        
        </el-input>
      </div>
    <el-table :data="retData.Data"  row-key="Id" border size="medium" @row-click="select">
      <el-table-column prop="LoginCode" label="账号" width="120"></el-table-column>
      <el-table-column prop="RealName" label="名称" width="120"></el-table-column>    
    </el-table>
        <div class="block">
      <el-pagination
        v-if="retData.Data.length>0"
        @current-change="getManager"
        :page-size="20"
        :current-page.sync="searchModel.PageIndex"
        layout="total,prev, pager, next"
        :total="retData.TotalCount"
      ></el-pagination>
    </div>
    </el-drawer>
  </div>
</template>
<script> 
export default {
  props: [],
  data() {
    return {
      loading:false,
      drawer: false,
      retData: { TotalCount: 0, Data: [] },
      searchModel: {
        PageIndex: 1,
        keyWord: ""
      }
    }
  },
  watch: {
    keyWord(val) {
        this.$refs.tree.filter(val);
    }
  },
  created() {
    this.getManager();
  },
  methods: {
    getManager() {
      this.$api.get("manage/v1/Manager/Get",this.searchModel).then(res => {
        this.retData=res;
      })
    },
    select(item,node,_this) {
      console.log(item)     
      this.drawer = false;
      var item=JSON.parse( JSON.stringify(item))
      this.$emit("select", item);
    },
    close() {
      this.drawer = false;
      this.$emit("close");
    },
    show() {
      this.drawer = true;
    }
  }
};
</script>

<style scoped>
.search-box{
  padding: 0 20px;
}
</style>
