<!--
 * @Descripttion: 当前组件信息
 * @version: 1.0.0
 * @Author: 无尘
 * @Date: 2018-12-20 14:24:50
 * @LastEditors: 无尘
 * @LastEditTime: 2018-12-20 14:24:50
 -->
<template>
  <div class="employee-table">
    <el-table :data="employeeList" @selection-change="selectMember" @row-click="linkToDetail">
      <el-table-column type="selection" width="42"> </el-table-column>
      <el-table-column prop="name" label="姓名">
        <template slot-scope="scope">
          <span>{{ scope.row.name }}</span>
          <span v-if="scope.row.isManager == 1" class="is-manager">部门负责人</span>
        </template>
      </el-table-column>
      <el-table-column prop="phoneNumber" label="手机号">
        <template slot-scope="scope">
          {{ scope.row.nationcode == '86' ? scope.row.phoneNumber : '+' + scope.row.nationcode + '-' + scope.row.phoneNumber || '--' }}
        </template>
      </el-table-column>
      <el-table-column label="职位" prop="positionName">
        <template slot-scope="scope">
          {{ !!scope.row.positionName ? scope.row.positionName : '--' }}
        </template>
      </el-table-column>
      <el-table-column label="状态">
        <template slot-scope="scope">
          <div class="status-icon" :class="scope.row.activationStatus == 1 ? 'is-active' : ''">
            <i class="iconfont icon-shouji"></i>
          </div>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>
<script>
export default {
  name: 'employee-table',
  props: {
    employeeList: {
      type: Array,
      default() {
        return [];
      }
    },
    headList: {
      type: Array,
      default() {
        return ['selection', 'name', 'phoneNumber', 'positionName', 'activationStatus'];
      }
    }
  },
  data() {
    return {
      tableH: window.screen.availHeight - 180
    };
  },
  methods: {
    /**
     * table选择员工
     */
    selectMember(selection) {
      this.$emit('selectMember', selection);
    },
    /**
     * 跳转至员工详情
     */
    linkToDetail(row) {
      let path = '/employee?employeeClerkId=' + row.employeeClerkId;
      this.$router.push(path);
    }
  },
  mounted() {
    console.log(this.employeeList);
  }
};
</script>
<style lang="scss">
.el-table .cell .is-manager {
  display: inline-block;
  vertical-align: middle;
  font-size: 10px;
  color: #fff;
  width: auto;
  padding: 0 4px;
  height: 13px;
  text-align: center;
  line-height: 15px;
  background: rgba(247, 203, 39, 1);
  border-radius: 2px;
}

.el-table tr {
  cursor: pointer;
}
</style>
