record.vue 4.02 KB
<template>
  <div class="container">
    <GLCombiForm ref="showSearch" :rowNumber="1" :formObj="searchForm" :formData="searchFormData" @handleOk="handleSearch" @handleRest="handleReset"></GLCombiForm>
    <!-- 表格区域 开始 -->
    <div class="live-table-header">
      <h2>
        已累计
        <label>{{ peopleNum }}</label>
        人观看&nbsp;&nbsp;
        <label>{{ roomNum }}</label>
        次观看
      </h2>
      <el-button :size="size" type="primary" plain @click="detailexport">导出</el-button>
    </div>
    <GLTable ref="classifyRef" :getListApi="getListApi" :noDataImg="url" :searchForm="tableSearchForm" :tableParams="tableParams" :pageConf="pageConf" :beforeSearchFn="beforeSearchFn" @setTableFinishFun="setTableFinishFun">
      <div slot="nickname" slot-scope="scope">
        <div class="nickname-border">
          <img :src="scope.scope.avatar" />
          <span>{{ scope.scope.nickname }}</span>
        </div>
      </div>
    </GLTable>
  </div>
</template>

<script>
import url from '@/assets/empty.png'
import { downloadUrl } from '@/utils'
export default {
  name: 'LiveIndex',
  props: {
    roomNum: Number,
    peopleNum: {
      type: Number,
      default: 0
    }
  },
  data() {
    return {
      size: 'small',
      url: url,
      searchForm: {
        nickname: '',
        phone: '',
        sourceShopName: ''
      },
      tableSearchForm: {},
      // 搜索
      searchFormData: [
        {
          label: '微信昵称',
          name: 'nickname',
          type: 'input',
          maxlength: 20
        },
        {
          label: '手机号',
          name: 'phone',
          type: 'input',
          maxlength: 20
        },
        {
          label: '来源门店',
          name: 'sourceShopName',
          type: 'input',
          maxlength: 20
        }
      ],
      // 表格
      getListApi: this.$apis.console.detailpage,
      tableParams: {
        listName: 'list',
        tableColumns: [
          {
            label: '微信昵称',
            prop: 'nickname',
            addHtml: 'nickname'
          },
          {
            label: '手机号',
            prop: 'phone'
          },
          {
            label: '访问来源',
            prop: 'visitSource'
          },
          {
            label: '来源门店',
            prop: 'sourceShopName'
          },
          {
            label: '观看时长',
            prop: 'visitDuration'
          },
          {
            label: '最后浏览',
            prop: 'lastVisitTime',
            width: 200
          }
        ]
      },
      pageConf: { pageSize: 'pageSize', pageNum: 'currentPage', totalCount: 'total' }
    }
  },
  inject: ['elFormItem'],
  methods: {
    detailexport() {
      const getParams = Object.assign(this.getParams(), {
        pageSize: 1000000,
        currentPage: 1
      })
      this.$apis.console.detailexport(getParams).then(res => {
        res && downloadUrl(res)
      })
    },
    getParams() {
      var params = JSON.parse(JSON.stringify(this.searchForm))
      params.id = this.$route.query.id
      return params
    },
    beforeSearchFn() {
      return new Promise(resolve => {
        this.tableSearchForm = this.getParams()
        resolve()
      })
    },
    setTableFinishFun() {
      //接收到的数据为空
      this.$refs.classifyRef.data.length ? (this.$refs.classifyRef.tableHeightValues = '') : this.$refs.classifyRef.setTableHeightFun()
    },

    handleSearch() {
      this.$refs.classifyRef.refreshTable()
    },

    handleReset() {
      this.searchForm = {}
      this.handleSearch()
    }
  }
}
</script>

<style lang="scss" scoped>
.container {
  ::v-deep {
    .el-form-item--small {
      width: 25%;
    }
  }
  .live-table-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    color: #333333;
    font-size: 16px;
    label {
      color: #5850ff;
    }
  }
}
.nickname-border {
  display: flex;
  align-items: center;
  img {
    width: 36px;
    height: 36px;
    margin-right: 10px;
  }
}
</style>