index.vue 9.76 KB
<template>
  <div class="square-main" v-loading="loading">
    <el-dialog title="客户列表" :visible.sync="dialogVisible" width="70%" :before-close="handleClose">
      <el-form :inline="true" :model="tableSearchForm" class="emp-form">
        <el-form-item size="small" label="客户名称">
          <el-input v-model="tableSearchForm.customerName" placeholder="请输入客户名称"></el-input>
        </el-form-item>
        <el-form-item size="small" label="状态" v-if="!pStatus">
          <el-select v-model="tableSearchForm.status" placeholder="请选择">
            <el-option v-for="item in optionstatus" :key="item.value" :label="item.label" :value="item.value"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item size="small" label="跟进员工" v-if="!staffIds">
          <el-select v-model="staffId" placeholder="请选择">
            <el-option v-for="item in staffName" :key="item.staffId" :label="item.staffName" :value="item.staffId"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item size="small" label="添加时间" v-if="timeStatus">
          <el-date-picker :picker-options="pickerOptions" value-format="yyyy-MM-dd" v-model="createTime" type="daterange" range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期"></el-date-picker>
        </el-form-item>
        <el-form-item size="small">
          <el-button type="primary" @click="handleSearch">查询</el-button>
          <el-button type="primary" @click="handleReset">重置</el-button>
        </el-form-item>
      </el-form>
      <!-- <GLCombiForm ref="formSearch" :formObj="tableSearchForm" :formData="searchFormData" @handleOk="handleSearch" @handleRest="handleReset"></GLCombiForm> -->
      <GLTable v-loading="loading" ref="table" :layout="layout" :tableData="tableData" :tableTotal="tableTotal" :pageConf="pageConf" :tableParams="tableParams" @refreshTable="handleSearch" @selectionTable="selectionTable">
        <div class="table-btns" slot="optionBtns" slot-scope="scope">
          <el-button type="text" @click="handleDetail(scope.scope)">详情</el-button>
        </div>
        <template slot="status" slot-scope="scope">
          <div class="status-form" v-if="scope.scope.status" style="color: #eb4e4e">删除好友</div>
          <div class="status-form" v-else style="color: #00a854">正常</div>
        </template>
        <template slot="customerName" slot-scope="scope">
          <div class="form-row">
            <img :src="scope.scope.avatar" v-if="scope.scope.avatar" />
            {{ scope.scope.nickNameList[0].nickName }}
            <span style="color: #5850ff">{{ scope.scope.type == 1 ? '@微信' : '@企微' }}</span>
          </div>
        </template>
      </GLTable>
      <span slot="footer" class="dialog-footer">
        <el-button size="small" @click="handleCancel" type="primary">关闭</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
import { utils } from 'glsx-common'
import util from '@/utils/util'
export default {
  name: 'selectEmp',
  data() {
    return {
      loading: false,
      dialogVisible: false,
      status: '',
      createTime: [],
      optionstatus: [
        {
          value: '',
          label: '全部'
        },
        {
          value: '0',
          label: '正常'
        },
        {
          value: '-1',
          label: '删除好友'
        }
      ],
      tableSearchForm: {},
      searchFormData: [
        {
          label: '客户名称',
          name: 'codeNameAndRemark',
          type: 'input',
          placeholder: '请输入客户名称'
        },
        {
          label: '状态',
          name: 'imStatus',
          type: 'select',
          placeholder: '请选择',
          optionId: 'value',
          optionLabel: 'label',
          optionList: [
            {
              value: '',
              label: '全部'
            },
            {
              value: '0',
              label: '正常'
            },
            {
              value: '-1',
              label: '删除好友'
            }
          ]
        },
        {
          label: '跟进员工',
          name: 'imStatus',
          type: 'select',
          placeholder: '请选择',
          optionId: 'value',
          optionLabel: 'label',
          optionList: [
            {
              value: '',
              label: '全部'
            },
            {
              value: '0',
              label: '正常'
            },
            {
              value: '-1',
              label: '删除好友'
            }
          ]
        },
        {
          label: '添加时间',
          name: 'createTime',
          type: 'datePicker',
          placeholder: '',
          isClear: true,
          pickerOptions: {
            disabledDate: time => {
              return time.getTime() > Date.now()
            }
          }
        }
      ],
      pageConf: { pageSize: 'pageSize', pageNum: 'pageNum', totalCount: 'total' },
      tableParams: {
        listName: 'data',
        tableOption: false,
        tableColumns: [
          {
            label: '客户名称',
            prop: 'customerName',
            addHtml: 'customerName',
            align: 'left'
          },
          {
            label: '客户性别',
            prop: 'customerSex',
            formatter: cellValue => {
              return cellValue.customerSex == 1 ? '男' : '女'
            },
            minWidth: 100
          },
          {
            label: '状态',
            prop: 'status',
            addHtml: 'status',
            minWidth: 100
          },
          {
            label: '跟进员工',
            prop: 'followStaff',
            minWidth: 100
          },
          {
            label: '添加时间',
            prop: 'addTime'
          },
          {
            label: '操作',
            prop: 'optionBtns',
            minWidth: '80px',
            addHtml: 'optionBtns'
          }
        ]
      },
      layout: 'sizes, prev, pager, next, jumper, ->, total',
      tableData: [],
      staffName: [],
      tableTotal: 0,
      selectItem: [],
      selectEmp: [],
      pStatus: null,
      staffIds: null,
      staffId: null
    }
  },
  methods: {
    jumpUrl() {
      this.$history.push('/home/followUp/index')
    },
    getFollower() {
      var params = {
        ...JSON.parse(JSON.stringify(this.tableSearchForm)),
        pageSize: this.$refs.table.page.pageSize,
        pageNum: this.$refs.table.page.pageNum,
        custState: this.selectRow.codeState ? this.selectRow.codeState : this.selectRow.state,
        staffIds: this.staffId ? [this.staffId] : null
      }
      if (this.createTime && this.createTime.length > 0) {
        params.beginTime = this.createTime[0]
        params.endTime = this.createTime[1]
      }
      if (this.pStatus) {
        params.status = 0
      }
      if (this.staffIds) {
        params.staffIds = this.staffIds
      }
      this.loading = true
      this.$apis.channel.getCustomer(params).then(res => {
        this.loading = false
        this.tableData = res.data
        this.tableTotal = res.count
      })
    },
    getChannelCodeStaffList() {
      var params = {
        pageSize: 1000,
        pageNum: 1,
        codeState: this.selectRow.codeState ? this.selectRow.codeState : this.selectRow.state
      }
      this.$apis.channel.getChannelCodeStaffList(params).then(res => {
        this.staffName = [{ staffName: '全部', staffId: null }].concat(res.data)
      })
    },
    init(item, value, day) {
      this.createTime = []
      this.pStatus = null
      this.staffIds = null
      this.timeStatus = true
      if (value == 'day' && !day) {
        this.createTime = [util.getDay(0), util.getDay(0)]
        this.timeStatus = false
      }
      if (value == 'day' && day) {
        if (day.indexOf('~') == -1) {
          this.createTime = [day, day]
        } else {
          this.createTime = [day.split('~')[0], day.split('~')[1]]
        }
        this.timeStatus = false
      }
      if (value == 'status' && !day) {
        this.pStatus = 'status'
      }
      if (value == 'status' && day) {
        this.pStatus = 'status'
        if (day.indexOf('~') == -1) {
          this.createTime = [day, day]
        } else {
          this.createTime = [day.split('~')[0], day.split('~')[1]]
        }
        this.timeStatus = false
      }
      if (value == 'staffIds') {
        this.staffIds = item.staffId
      }
      if (value == 'statusAndStaffIds') {
        this.pStatus = 'status'
        this.staffIds = item.staffId
      }
      this.selectRow = item
      this.tableSearchForm = {}
      this.dialogVisible = true
      this.getChannelCodeStaffList()
      this.$nextTick(() => {
        this.$refs.table.page.pageNum = 1
        this.getFollower()
      })
    },
    handleSearch() {
      this.getFollower()
    },
    handleReset() {
      this.tableSearchForm = {}
      this.getFollower()
    },
    selectionTable(val) {
      this.selectItem = val
    },
    handleClose() {
      this.handleCancel()
    },
    handleDetail(scope) {
      this.$history.push('/custom/clientManage/clientDetail?id=' + scope.oneId)
    },
    handleCancel: utils.debounce(function() {
      this.dialogVisible = false
    }, 300)
  }
}
</script>

<style lang="scss" scoped>
.dialog-jump {
  color: #5850ff;
  float: left;
  line-height: 24px;
  text-decoration: underline;
  cursor: pointer;
}
.emp-form {
  /deep/ {
    .el-date-editor,
    .el-input {
      width: 212px;
    }
  }
}
.square-main {
  /deep/ {
    .el-table {
      height: 35vh;
      overflow-y: auto;
    }
    .el-form-item {
      margin-right: 20px;
    }
    .el-table::before {
      left: 0;
      bottom: 0;
      width: 100%;
      height: 0px;
    }
  }
}
.form-row {
  img {
    width: 50px;
    height: 50px;
    vertical-align: middle;
  }
}
</style>