index.vue 9.74 KB
<template>
  <div className="scrm-main">
    <div class="follow-header">
      <div class="follow-title">跟进专员</div>
      <p>
        为不同的业务部门设置对应的跟进专员,方便后续业务部门创办相关的活动时能为其成员创建活动和发送企微消息,引导其跟进活动。跟进专员接收任务后可转发给客户/客户群,拥有“添加外部联系人权限”的员工才允许设置为跟进专员。
        <a class="follow-process-a" @click="jumpUrl('https://img01.glsx.com.cn/upload/temporary/process.html')">
          设置“外部联系人权限”教程
          <i class="el-icon-d-arrow-right"></i>
        </a>
      </p>
    </div>
    <div class="follow-form" :style="{ 'min-height': formHeight + 'px' }">
      <GLCombiForm ref="showSearch" :formObj="searchForm" :rowNumber="1" :searchSelectObj="searchSelectObj" :formData="searchFormData" :inline="true" @handleOk="handleSearch" @handleRest="handleReset"></GLCombiForm>
      <div class="table-header">
        <div class="header-text">跟进专员列表</div>
        <div class="table-btn">
          <GLButton fn="新增" size="small" type="primary" plain @click="openDrawer">
            <i class="el-icon-plus"></i>
            添加专员
          </GLButton>
          <!-- <el-button size="small" type="primary" plain @click="openDrawer">
            <i class="el-icon-plus"></i>
            添加专员
          </el-button> -->
        </div>
      </div>
      <GLTable ref="table" :layout="layout" :tableData="tableData" :tableTotal="tableTotal" :pageConf="pageConf" :tableParams="tableParams" @refreshTable="handleSearch">
        <template slot="auth-button" slot-scope="scope" :data="scope.scope">
          <GLTableButton :buttonList="buttonList" :buttonItem="scope.scope"></GLTableButton>
          <!-- <el-button fn="删除" type="text" @click="handleDele(scope.scope)">删除</el-button> -->
        </template>
      </GLTable>
    </div>
    <el-drawer class="drawer-panel" size="60%" title="添加跟进员工" :visible.sync="drawer" :direction="direction" :before-close="handleClose">
      <add-sale ref="drawerForm" @closeDrawer="closeDrawer" @handSelectdEmp="handSelectdEmp"></add-sale>
    </el-drawer>
  </div>
</template>

<script>
import addSale from './components/addSale'
export default {
  name: 'index',
  components: {
    addSale
  },
  data() {
    return {
      alertStatus: true,
      formHeight: 300,
      drawer: false,
      direction: 'rtl',
      searchForm: {
        followerTypeId: '',
        staffName: ''
      },
      searchFormData: [
        {
          label: '类型',
          name: 'followerTypeId',
          type: 'select',
          placeholder: '全部',
          optionsType: [],
          optionList: [],
          optionId: 'id',
          optionLabel: 'followName',
          optionsName: 'followName'
        },
        {
          label: '员工姓名',
          name: 'staffName',
          type: 'input',
          placeholder: '输入关键字搜索'
        }
      ],
      scope: {
        scope: ''
      },
      pageConf: { pageSize: 'pageSize', pageNum: 'pageNum', totalCount: 'total' },
      // 表格参数
      tableParams: {
        tableOption: {
          width: 80
        },
        mutiSelectName: 'user',
        btnId: new Date().getTime() + parseInt(Math.random() * 1000),
        tableColumns: [
          {
            label: '姓名',
            prop: 'staffName'
          },
          {
            label: '部门',
            prop: 'departmentName'
          },
          {
            label: '跟进专员类型',
            prop: 'followerTypeName'
          },
          {
            label: '手机号',
            prop: 'staffPhone'
          },
          {
            label: '首次开通时间',
            prop: 'followerCreatedTime'
          },
          {
            label: '是否有外部联系人权限',
            prop: 'isAddOutsider',
            width: '200',
            formatter: cellValue => {
              return {
                0: '是',
                1: '否'
              }[cellValue.isAddOutsider]
            }
          }
        ]
      },
      buttonList: [
        {
          type: 'GLButton',
          name: row => {
            return '删除'
          },
          attrs: {
            type: 'text',
            fn: '删除'
          },
          condition: row => {
            return true
          },
          listeners: {
            click: this.handleDele
          }
        }
      ],
      layout: 'sizes, prev, pager, next, jumper, ->, total',
      tableData: [],
      tableTotal: 0
    }
  },
  watch: {
    drawer(val) {
      if (!val) {
        this.listEntFollowerType()
      }
    }
  },
  methods: {
    jumpUrl(url) {
      const link = document.createElement('a')
      link.href = url
      link.target = '_blank'
      link.click()
    },
    openDrawer() {
      this.drawer = true
      this.$nextTick(() => {
        this.$refs.drawerForm.init()
      })
    },
    beforeSearchFn() {
      return new Promise(resolve => {
        // 调接口前,操作
        resolve()
      })
    },
    handleClose() {
      this.drawer = false
    },
    closeDrawer() {
      this.handleClose()
    },
    handSelectdEmp(followerTypeId, userIds, businessTypeId) {
      var params = {
        followerTypeId,
        userIds,
        businessTypeId
      }
      console.log(params, '1253715427')
      this.$apis.emp.saveFollowerStaff(params).then(res => {
        if (res) {
          this.handleClose()
          this.handleSearch()
        }
      })
    },
    handleReset() {
      this.searchForm = {
        followerTypeId: '',
        staffName: ''
      }
      this.handleSearch()
    },
    handleSearch() {
      var params = {
        ...JSON.parse(JSON.stringify(this.searchForm)),
        pageSize: this.$refs.table.page.pageSize,
        pageNum: this.$refs.table.page.pageNum
      }
      this.$apis.emp.listFollowerStaffByPage(params).then(res => {
        this.tableData = res.data
        this.tableTotal = res.count
        if (res.data && res.data.length == []) {
          this.$refs.table.setTableHeightFun()
        }
      })
    },
    listEntFollowerType() {
      this.$apis.emp.listEntFollowerType({ merchantId: this.$globalState.session.merchantId }).then(res => {
        this.optionsType = [{ followName: '全部', id: '' }].concat(res)
        let idx = this.searchFormData.findIndex(item => item.name == 'followerTypeId')
        this.searchFormData[idx].optionList = this.optionsType
      })
    },
    handleDele(scope) {
      this.$confirm('是否删除该员工?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        customClass: 'gl-message-box',
        type: 'warning'
      })
        .then(() => {
          this.$apis.emp.deleteFollowerStaff({ userId: scope.userId, userOneId: scope.userOneId }).then(res => {
            if (res) {
              this.$message({
                type: 'success',
                message: '删除成功!'
              })
            }
            this.handleSearch()
          })
        })
        .catch(() => {})
    },
    jumpWx() {
      this.$router.push('/enterpriseWechat/index')
    },
    wxTips() {
      const menu = JSON.parse(sessionStorage['SCRM_BASE_MENULIST'])
      menu.forEach(item => {
        if (!item.children) {
          return
        }
        item.children.forEach(itm => {
          if (itm.path == '/enterpriseWechat/index') {
            this.$apis.ww.getStatus({}).then(res => {
              if (res.status != 'SUCCESS') {
                const h = this.$createElement
                this.$message({
                  showClose: true,
                  duration: 0,
                  message: h('p', null, [h('span', null, '此功能需完成【企业微信授权】后方可使用! '), h('span', { on: { click: this.jumpWx }, style: { margin: '0px 60px 0px 20px', cursor: 'pointer', color: '#5850ff' } }, ['企业微信授权 ', h('i', { class: 'el-icon-d-arrow-right' }, '')])])
                })
              }
            })
          }
        })
      })
    }
  },
  beforeDestroy() {
    this.$message.closeAll()
  },
  mounted() {
    this.wxTips()
    this.listEntFollowerType()
    this.handleSearch()
    this.formHeight = document.documentElement.clientHeight - 230
  }
}
</script>

<style scoped lang="scss">
.slide-fade-enter-active {
  transition: all 0.3s ease;
}
.slide-fade-leave-active {
  transition: all 0.8s cubic-bezier(1, 0.5, 0.8, 1);
}
.slide-fade-enter, .slide-fade-leave-to
/* .slide-fade-leave-active 用于 2.1.8 以下版本 */ {
  transform: translateX(10px);
  opacity: 0;
}
.message-tips {
  padding: 10px;
  box-sizing: border-box;
  border-width: 1px;
  border-style: solid;
  border-color: #ebeef5;
  position: fixed;
  left: 50%;
  top: 0px;
  transform: translate(-50%, 20px);
  display: flex;
  align-items: center;
  transition: all 0.3s ease-in;
  background: forestgreen;
}
.follow-header {
  background: #ffffff;
  line-height: 20px;
  padding: 20px;
  font-size: 15px;
  color: rgba(0, 0, 0, 0.65);
  position: relative;
  .follow-title {
    font-size: 20px;
    font-family: PingFangSC-Medium, PingFang SC;
    color: #333333;
    margin-bottom: 20px;
  }
  p {
    color: #666666;
  }
  .follow-process-a {
    line-height: 24px;
    color: #5850ff;
    cursor: pointer;
  }
}
.follow-form {
  min-height: calc(100% - 200px);
  margin-top: 10px;
  background: #ffffff;
  // box-shadow: 0 10px 20px 0 rgba(88, 80, 255, 0.1);
  padding: 20px;
  &-item {
    position: relative;
    .follow-form-jump {
      position: absolute;
      right: 0px;
      margin-right: 0px;
    }
  }
}
.drawer-panel {
  /deep/ .el-drawer__body {
    overflow-y: auto;
  }
}
.follow-btn {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 20px;
}
</style>