selectEmp.vue 4.44 KB
<template>
  <div class="select-emp-panel">
    <div class="scrm-p10 emp-tree-panel">
      <div class="popper-arrow"></div>
      <div
        class="emp-scroll-panel"
        :style="{
          height: treeHeight + 'px'
        }"
      >
        <div class="tree-title">所在门店/部门</div>
        <el-tree :data="listTree" :expand-on-click-node="false" highlight-current :props="defaultProps" @node-click="handleNodeClick"></el-tree>
      </div>
    </div>
    <el-col
      class="scrm-p10 emp-table-panel"
      :style="{
        height: treeHeight + 20 + 'px'
      }"
    >
      <GLTable ref="saleTable" :tableData="tableEmpData" :tableParams="tableParams" :hasNum="false" :hasPage="false" @selectionTable="selectionTable"></GLTable>
    </el-col>
  </div>
</template>

<script>
export default {
  name: 'selectEmp',

  data() {
    return {
      treeHeight: 0,
      staffName: '',
      listTree: [],
      defaultProps: {
        children: 'children',
        label: 'departmentName'
      },
      // 表格参数
      tableParams: {
        checkSelectKey: 'id',
        checkSelectVal: [],
        listName: 'list',
        // 行数据的key
        mutiSelectUniqueKey: 'id',
        // 多选ref的名称
        mutiSelectName: 'salelist',
        btnId: new Date().getTime() + parseInt(Math.random() * 1000),
        tableColumns: [
          {
            label: '姓名',
            prop: 'staffName'
          },
          {
            label: '职务',
            prop: 'staffTitle'
          }
        ]
      },
      tableEmpData: []
    }
  },

  methods: {
    selectionTable(val) {
      this.$emit('selectTable', val)
    },
    listDepartmentTree() {
      this.$apis.emp.listDepartmentTree({ id: 1 }).then(res => {
        this.listTree = res
        this.$nextTick(() => {
          document.getElementsByClassName('el-tree-node__expand-icon')[0].click()
          document.getElementsByClassName('el-tree-node__content')[0].click()
        })
      })
    },
    clearSelect(row) {
      this.tableEmpData.forEach(item => {
        if (item.id == row.id) {
          this.$refs.saleTable.$refs.salelistMutiTable.toggleRowSelection(item)
        }
      })
    },
    clearSelection() {
      this.$refs.saleTable.$refs.salelistMutiTable.clearSelection()
    },
    handleNodeClick(data) {
      this.departmentId = data.id
      this.listEntmicroStaff()
    },
    listEntmicroStaff(staffName) {
      let params = {
        departmentId: this.departmentId,
        staffName: staffName ? staffName : this.staffName,
        merchantid: this.$globalState.session.merchantId
      }
      this.$apis.emp.listEntmicroStaff(params).then(res => {
        this.tableEmpData = res
      })
    }
  },

  mounted() {
    let clientHeight = document.documentElement.clientHeight
    this.treeHeight = clientHeight - 480
    this.listDepartmentTree()
  }
}
</script>

<style scoped lang="scss">
.select-emp-panel {
  display: flex;
  .emp-tree-panel {
    margin-top: 10px;
    width: 200px;
    position: relative;
    background: #ffffff;
    // box-shadow: 0px 2px 12px 0px rgba(0, 0, 0, 0.06);
    border: 1px solid #e4e7ed;
    .emp-scroll-panel {
      min-height: 200px;
      overflow: auto;
      box-sizing: border-box;
    }
    .popper-arrow {
      border-top-width: 0;
      border-width: 6px;
      position: absolute;
      top: -12px;
      left: 30px;
      display: block;
      width: 0;
      height: 0;
      border-color: transparent;
      border-style: solid;
      border-bottom-color: #e4e7ed;
      &:after {
        content: ' ';
        border-width: 6px;
        top: 1px;
        margin-left: -6px;
        border-top-width: 0;
        position: absolute;
        display: block;
        width: 0;
        height: 0;
        border-color: transparent;
        border-style: solid;
        border-bottom-color: #fff;
      }
    }
  }
  .emp-table-panel {
    flex: 1;
    min-height: 200px;
    overflow: auto;
    margin-top: 10px;
    background: #ffffff;
    // box-shadow: 0px 2px 12px 0px rgba(0, 0, 0, 0.06);
    border: 1px solid #e4e7ed;
    /deep/ .el-checkbox__input.is-disabled .el-checkbox__inner {
      background-color: #999999;
    }
  }
  .emp-tree-panel {
    margin-right: 10px;
    font-size: 15px;
    /deep/ .el-tree-node:focus > .el-tree-node__content {
      color: #5850ff;
      background: #f2f5fa;
    }
  }
  .tree-title {
    font-size: 16px;
    font-weight: 500;
    color: #333333;
    line-height: 14px;
    padding: 10px;
  }
}
</style>