potentialClient.vue 6.89 KB
<template>
  <div class="sub-container">
    <search-form class="searchTop border-shadow" :isHasSyncBtn="true" :isThreeRowShow="true" :showDefaultTime="false" :formModel="searchForm" :formList="clientGroupFormList" @setTableHeightEvent="setTableHeightEvent">
      <span class="inline-b" slot="form-slot">
        <el-button type="primary" @click="handleExport">导出</el-button>
        <el-button plain @click="resetTable">重置</el-button>
        <el-button type="primary" @click="searchTable">查询</el-button>
      </span>
    </search-form>
    <!-- :tableId="$route.query.id" 去掉,表格组件也应该去掉 -->
    <GLTable ref="clientGroupDetail" @setTableFinishFun="setTableFinishFun" :hasNum="true" :pageConf="pageConf" :getListApi="getListApi" :beforeSearchFn="beforeSearchFn" :searchForm="searchFormTable" :tableParams="tableParams" :headerStyle="{ height: '54px', background: '#F4F6FC', color: '#333333', fontSize: '14px' }" :noDataImg="url">
      <span slot="customerName" class="flex-center" slot-scope="scope">
        <el-tooltip effect="dark" :content="scope.scope.customerName" placement="top">
          <span class="ellipsis-1" style="display: inline-block; max-width: 70px; text-align: left">{{ scope.scope.customerName }}</span>
        </el-tooltip>

        <span class="pure-blue-text">{{ scope.scope.type == 1 ? '@微信' : scope.scope.type == 2 ? '@企微' : '' }}</span>
      </span>
      <span slot="customerSex" slot-scope="scope">
        <span>{{ scope.scope.customerSex == 2 ? '女' : scope.scope.customerSex == 1 ? '男' : '未知' }}</span>
      </span>
      <span slot="joinScene" slot-scope="scope">
        <span>{{ scope.scope.joinScene == 1 ? '直接邀请入群' : scope.scope.joinScene == 2 ? '通过邀请链接入群' : scope.scope.joinScene == 3 ? '通过扫描群二维码入群' : '' }}</span>
      </span>
      <template slot="auth-button" slot-scope="scope" :data="scope.scope">
        <span @click="goDetail(scope.scope.id)" class="blue-text">详情</span>
      </template>
    </GLTable>
  </div>
</template>

<script>
import { getDetailPotentialTableList,potentialClientExportApi } from '@/api/modules/clientGroupManage'
export default {
  props: {
    url: {
      type: String,
      default: ''
    }
  },
  data() {
    return {
      searchForm: {},
      searchFormTable: {},
      clientGroupFormList: [
        {
          type: 'daterange',
          prop: 'daterange',
          label: '入群时间',
          pickerOptions: {
            disabledDate(time) {
              return time.getTime() > Date.now() || time.getTime() < new Date('2017-12-31').getTime()
            }
          }
        },
        // {
        //   type: 'select',
        //   prop: 'customerSex',
        //   label: '性别',
        //   placeholder: '请选择性别',
        //   options: [
        //     {
        //       label: '全部',
        //       value: null
        //     },
        //     {
        //       label: '男',
        //       value: 1
        //     },
        //     {
        //       label: '女',
        //       value: 2
        //     },
        //     {
        //       label: '未知',
        //       value: 0
        //     }
        //   ]
        // },
        {
          type: 'input',
          inputType: 'text',
          prop: 'groupNickName',
          label: '本群昵称',
          placeholder: '请输入本群昵称'
        }
      ],
      pageConf: { pageSize: 'pageSize', pageNum: 'pageNum', totalCount: 'count' },
      tableParams: {
        // btnId: new Date().getTime() + parseInt(Math.random() * 1000),
        listName: 'data',
        tableColumns: [
          {
            label: '本群昵称',
            prop: 'groupNickName'
          },
          // {
          //   label: '手机号码',
          //   prop: 'customerPhone'
          // },
          // {
          //   label: '性别',
          //   prop: 'customerSex',
          //   addHtml: 'customerSex'
          // },
          {
            label: '入群方式',
            prop: 'joinScene',
            addHtml: 'joinScene'
          },
          {
            label: '邀请人',
            prop: 'invitorName'
          },
          {
            label: '入群时间',
            prop: 'joinTime',
            width: 98
          }
        ],
        // tableOption: {
        //   width: 80,
        //   btnList: [
        //     {
        //       name: '详情',
        //       pType: 'detail'
        //     }
        //   ]
        // }
      },
      getListApi: getDetailPotentialTableList,
      clientTableDataNum: 0
    }
  },
  created() {
    this.searchForm = {
      id: this.$route.query.id
    }
  },
  methods: {
     getParams(){
      var params = JSON.parse(JSON.stringify(this.searchForm))
      if (params.daterange) {
        params.beginTime = this.searchForm.daterange[0] 
        params.endTime = this.searchForm.daterange[1]
      } else {
        if (params.beginTime) delete params.beginTime && delete params.endTime
      }
      delete params.daterange
      return params
    },
    beforeSearchFn() {
      // return new Promise((resolve, reject) => {
      //   this.searchFormTable = JSON.parse(JSON.stringify(this.searchForm))
      //   if (this.searchFormTable.daterange) {
      //     this.searchFormTable.beginTime = this.searchForm.daterange[0]
      //     this.searchFormTable.endTime = this.searchForm.daterange[1]
      //     delete this.searchFormTable.daterange
      //   } else {
      //     if (this.searchFormTable.beginTime) delete this.searchFormTable.beginTime && delete this.searchFormTable.endTime
      //   }
      //   resolve()
      // })
       return new Promise((resolve, reject) => {
        this.searchFormTable = this.getParams()
        resolve()
      })
    },
    setTableHeightEvent() {
      this.$refs.clientGroupDetail.setTableHeightFun()
    },
    setTableFinishFun(content) {
      //content是第一页的数据
      console.log(content)
      this.clientTableDataNum = this.$refs.clientGroupDetail.total
      //接收到的数据为空
      // if (!this.$refs.clientGroupDetail.data.length) {
      //   this.$refs.clientGroupDetail.setTableHeightFun()
      // }
      this.$refs.clientGroupDetail.data.length ? (this.$refs.clientGroupDetail.tableHeightValues = '') : this.$refs.clientGroupDetail.setTableHeightFun()
    },
  //导出
    handleExport(){
      var params = this.getParams()
      potentialClientExportApi(params).then(res => {
        this.$Utils.exportFn(res)
      })
    },
    //搜索表格
    searchTable() {
      this.$refs.clientGroupDetail.refreshTable()
    },
    //重置表格
    resetTable() {
      this.searchForm = { id: this.$route.query.id }
      this.$refs.clientGroupDetail.refreshTable()
    },
    goDetail(msg) {
      this.$emit('goDetail', msg)
    }
  }
}
</script>

<style lang="scss" scope>
.sub-container {
  @import '@/styles/variables.scss';
  @import '@/styles/resetelement.scss';
}
</style>