index.vue 4.46 KB
<template>
  <div class="square-main" v-loading="loading">
    <GLDialog title="选择跟进专员" :visible.sync="dialogVisible">
      <el-form :inline="true" :model="tableSearchForm">
        <el-form-item size="small" label="员工">
          <el-input v-model="tableSearchForm.username" placeholder="请输入员工姓名"></el-input>
        </el-form-item>
        <el-form-item size="small">
          <el-button type="primary" @click="handleSearch">查询</el-button>
        </el-form-item>
      </el-form>
      <GLTable :hasNum="false" v-if="dialogVisible" @refreshTable="handleSearch" ref="table" :layout="layout" :tableData="tableData" :tableTotal="tableTotal" :pageConf="pageConf" :tableParams="tableParams">
        <div slot="options" slot-scope="scope">
          <!-- @click.prevent.native="checkRadio(scope.scope.userOneid)" -->
          <el-radio :label="scope.scope.userOneid" v-model="selectId"></el-radio>
        </div>
      </GLTable>
      <span slot="footer" class="dialog-footer">
        <a class="dialog-jump" @click="jumpUrl">新增专员</a>
        <el-button plain size="small" @click="handleCancel">取 消</el-button>
        <el-button size="small" type="primary" @click.native="handleSelect">确 定</el-button>
      </span>
    </GLDialog>
  </div>
</template>
<script>
import { utils } from 'glsx-common'
import util from '@/utils/util'
export default {
  name: 'selectEmp',
  data() {
    return {
      selectId: null,
      // loading: false,
      dialogVisible: false,
      tableSearchForm: {},
      pageConf: { pageSize: 'pageSize', pageNum: 'pageNum', totalCount: 'total' },
      tableParams: {
        listName: 'data',
        tableOption: false,
        // 行数据的key
        mutiSelectUniqueKey: 'id',
        tableColumns: [
          {
            label: '',
            prop: '',
            addHtml: 'options'
          },
          {
            label: '姓名',
            prop: 'staffName'
          },
          // {
          //   label: '部门',
          //   prop: 'departmentName'
          // },
          {
            label: '跟进专员类型',
            prop: 'followerName'
          }
        ]
      },
      layout: 'sizes, prev, pager, next, jumper, ->, total',
      tableData: [],
      tableTotal: 0,
      selectEmp: [],
      typeselect: '',
      selectUuid: ''
    }
  },
  methods: {
    // checkRadio(val) {
    //   val === this.selectId ? (this.selectId = '') : (this.selectId = val)
    // },
    jumpUrl() {
      util.openUrl(location.origin + '/settings/followUp/index')
    },
    selectableStaff(type) {
      this.typeselect = type
      let params = {
        ...JSON.parse(JSON.stringify(this.tableSearchForm)),
        pageSize: this.$refs.table.page.pageSize,
        pageNum: this.$refs.table.page.pageNum,
        type
      }
      this.$apis.leadManage.selectableStaff(params).then(res => {
        this.tableData = res.list ? res.list : []
        this.tableTotal = res.total
      })
    },
    init(type, uuid) {
      this.selectId = uuid
      this.tableSearchForm = {}
      this.dialogVisible = true
      this.$nextTick(() => {
        this.$refs.table.page.pageNum = 1
        this.selectableStaff(type)
      })
    },
    handleSearch() {
      let type = this.typeselect
      this.selectableStaff(type)
    },
    handleClose() {
      this.handleCancel()
    },
    handleCancel: utils.debounce(function() {
      this.dialogVisible = false
    }, 300),
    handleSelect: utils.debounce(function() {
      if (!this.selectId) {
        this.$message.error('请选择员工')
        return
      }
      let list = this.tableData.filter(item => {
        return item['userOneid'] == this.selectId
      })
      let selectEmp = {
        userId: list[0].userId,
        userName: list[0].staffName,
        userUuid: list[0].userOneid
      }
      this.dialogVisible = false
      this.$emit('selectTable', selectEmp)
    }, 300)
  }
}
</script>
<style lang="scss" scoped>
/deep/.glsx-table .emptyBg .noDataImg {
  margin-top: 150px !important;
}
/deep/ .el-radio:focus:not(.is-focus):not(:active):not(.is-disabled) .el-radio__inner {
  box-shadow: none;
}
/deep/ .el-radio__label {
  display: none;
}
.dialog-jump {
  color: #5850ff;
  float: left;
  line-height: 24px;
  text-decoration: underline;
  cursor: pointer;
}
.square-main {
  /deep/ {
    .el-table {
      height: 40vh;
      overflow-y: auto;
    }
    .el-table::before {
      left: 0;
      bottom: 0;
      width: 100%;
      height: 0px;
    }
  }
}
</style>