leaveGroupClient.vue 7.34 KB
<template>
  <div class="sub-container">
    <GLCombiForm class="sub-form-style" :formObj="searchForm" :formData="clientGroupFormList" @handleOk="searchTable" @handleRest="resetTable"></GLCombiForm>
    <!-- <div class="leadList">
      <div>
        <span></span>
      </div>
      <el-button size="small" @click="handleExport">导出</el-button>
    </div> -->
    <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>
      <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 { getDetailQuitTableList, leaveGroupExportApi } from '@/api/modules/clientGroupManage'
export default {
  props: {
    url: {
      type: String,
      default: ''
    }
  },
  data() {
    return {
      searchForm: {},
      searchFormTable: {},
      clientGroupFormList: [
        {
          type: 'datePicker',
          name: 'daterange',
          label: '入群时间',
          valueFormat: 'yyyy-MM-dd',
          pickerOptions: {
            disabledDate(time) {
              return time.getTime() > Date.now() || time.getTime() < new Date('2017-12-31').getTime()
            }
          }
        },
        {
          type: 'select',
          name: 'customerSex',
          label: '性别',
          placeholder: '请选择性别',
          optionLabel: 'label',
          optionId: 'value',
          optionList: [
            {
              label: '全部',
              value: null
            },
            {
              label: '男',
              value: 1
            },
            {
              label: '女',
              value: 2
            },
            {
              label: '未知',
              value: 0
            }
          ]
        },
        {
          type: 'input',
          inputType: 'text',
          name: 'groupNickName',
          label: '本群昵称',
          placeholder: '请输入本群昵称'
        },
        {
          type: 'input',
          inputType: 'text',
          name: 'customerName',
          label: '客户名称',
          placeholder: '请输入客户名称'
        }
      ],
      pageConf: { pageSize: 'pageSize', pageNum: 'pageNum', totalCount: 'count' },
      tableParams: {
        listName: 'data',
        tableColumns: [
          {
            label: '本群昵称',
            prop: 'groupNickName',
            minWidth: 120
          },
          {
            label: '客户名称',
            prop: 'customerName',
            addHtml: 'customerName',
            minWidth: 150
          },
          {
            label: '手机号码',
            prop: 'customerPhone',
            minWidth: 120
          },
          {
            label: '性别',
            prop: 'customerSex',
            addHtml: 'customerSex'
          },
          {
            label: '入群方式',
            prop: 'joinScene',
            addHtml: 'joinScene',
            minWidth: 140
          },
          {
            label: '邀请人',
            prop: 'invitorName',
            minWidth: 120
          },
          {
            label: '入群时间',
            prop: 'joinTime',
            width: 170
          }
        ],
        tableOption: {
          width: 60,
          btnList: [
            {
              name: '详情',
              pType: 'detail'
            }
          ]
        }
      },
      getListApi: getDetailQuitTableList,
      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是第一页的数据
      
      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()
      leaveGroupExportApi(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" scoped>
.sub-container {
  @import '@/styles/variables.scss';
  @import '@/styles/resetelement.scss';
  .leadList {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    div {
      text-align: center;
      span:nth-child(1) {
        font-weight: 600;
        font-size: 16px;
      }
    }
    /deep/ .el-button {
      color: #5850ff;
      border: 1px solid #5850ff;
    }
  }
  //  /deep/ .sub-form-style {
  //   @media screen and (min-width: 1440px) and (max-width: 1720px) {
  //     .glsx-combi-form .el-form-item--small {
  //       width: 50%;
  //     }
  //   }
  // }
}
</style>