browseList.vue 8.23 KB
<!-- 明细 -->
<template>
  <div class="edit-share marketing edit-box">
    <div class="container edit-container">
      <p class="edit-title">{{ routeInfo.activityName }}</p>

      <div class="p-20">
        <GLCombiForm
          ref="showSearch"
          :rowNumber="1"
          :formObj="searchForm"
          :formData="searchFormData"
          @handleOk="handleSearch"
          @handleRest="handleReset"
        ></GLCombiForm>

        <div class="flex m-b-10 w-100-percent">
          <div class="table-title">
            已累计<template v-if="routeInfo.type != 2">{{decodeURI(routeInfo.name)}}</template>
            <span>{{routeInfo.count || 0}}</span>
            {{routeInfo.type == 2?'位访客':'次'}}
          </div>
          <el-button
            :size="size"
            class="default-blue-btn"
            type="default"
            @click="handleExport"
          >导出</el-button>
        </div>

        <!-- 表格区域 开始 -->
        <GLTable
          ref="browserRef"
          :getListApi="getListApi"
          :noDataImg="url"
          :searchForm="searchForm"
          :tableParams="tableParams"
          :pageConf="pageConf"
          :beforeSearchFn="beforeSearchFn"
          @setTableFinishFun="setTableFinishFun"
        >
          <div
            slot="customerName"
            class="flex-align"
            slot-scope="scope"
          >
            <template v-if="scope.scope.customerAvatar">
              <el-popover
                placement="top"
                width="160"
                trigger="hover"
                popper-class="table-popover-block"
              >
                <img
                  class="table-popover-img"
                  :src="scope.scope.customerAvatar"
                />
                <img
                  class="img-36 pointer"
                  slot="reference"
                  :src="scope.scope.customerAvatar"
                />
              </el-popover>
            </template>
            <span class="m-l-10">{{ scope.scope.customerName }}</span>
          </div>
          <div
            slot="shareName"
            class="flex-align"
            slot-scope="scope"
          >
            <template v-if="scope.scope.shareAvatar">
              <el-popover
                placement="top"
                width="160"
                trigger="hover"
                popper-class="table-popover-block"
              >
                <img
                  class="table-popover-img"
                  :src="scope.scope.shareAvatar"
                />
                <img
                  class="img-36 pointer"
                  slot="reference"
                  :src="scope.scope.shareAvatar"
                />
              </el-popover>
            </template>
            <span class="m-l-10">{{ scope.scope.shareName }}</span>
            <span class="m-l-10">{{ scope.scope.sharePhone }}</span>
          </div>
          <div
            slot="isBuy"
            slot-scope="scope"
          >
            <span :class="['table-circle', 'm-r-8', scope.scope.isBuy == 'Y' ?'back-green': 'back-grey']"></span>
            <span>{{{
                'Y':'已付款',
                'N':'未付款'
              }[scope.scope.isBuy] || '--'}}</span>
          </div>
        </GLTable>
        <!-- 表格区域 end -->
      </div>
    </div>
    <div
      class="footer"
      :style="{ left: footerLeft + 'px', width: footerWidth + 'px' }"
    >
      <el-button
        type="default"
        @click="handleJump"
      >返回</el-button>
    </div>
  </div>
</template>

<script>
import * as dayjs from 'dayjs'
import url from '@/assets/empty.png'
import { exportFn } from '@/common/constant'
export default {
  name: 'browseList',
  data () {
    return {
      size: 'small',
      url: url,
      footerLeft: '0',
      footerWidth: '0',
      routeInfo: {
        id: '',
        activityName: ''
      },
      searchForm: {
        customerName: '',
        mobile: ''
      },
      pageConf: { pageSize: 'pageSize', pageNum: 'pageNum', totalCount: 'total' },
      // 搜索
      searchFormData: [
        {
          label: '微信昵称',
          name: 'customerName',
          type: 'input',
          maxlength: 50
        },
        {
          label: '手机号',
          name: 'mobile',
          type: 'input',
          maxlength: 11
        },
        {
          label: '分享人',
          name: 'shareName',
          type: 'input',
          maxlength: 50
        }
      ],
      // 表格
      getListApi: null,
      tableParams: {
        listName: 'list',
        tableColumns: [
          {
            label: '微信昵称',
            prop: 'customerName',
            addHtml: 'customerName'
          },
          {
            label: '手机号',
            prop: 'mobile'
          },
          {
            label: '分享人',
            prop: 'shareName',
            addHtml: 'shareName',
            width: 230
          },
        ]
      }
    }
  },

  created () {
    const lastTableColumns = [
      {
        label: '浏览时长',
        prop: 'browserTime',
      },
      {
        label: '进入页面时间',
        prop: 'operationDate',
        width: '180'
      },
      {
        label: '离开页面时间',
        prop: 'leaveDate',
        width: '180'
      },
      {
        label: '订单状态',
        prop: 'isBuy',
        addHtml: 'isBuy'
      }
    ], {
      query
    } = this.$route,
      name = {
        1: '浏览',
        2: '访客',
        3: '分享',
      }[query.type],
      [url] = window.location.href.split('%24title')
    query.name = name
    this.routeInfo = query
    this.getListApi = this.$apis.seckillActivity[{
      1: 'getBrowseListApi',
      2: 'getVisitorListApi',
      3: 'getSharedListApi'
    }[query.type]]

    history.replaceState(null, null, `${url}&$title=${name}明细`)
    // listName: 
    //1 浏览 2 访客 3 分享
    if (query.type != 2) {
      this.searchFormData.push({
        label: '订单状态',
        name: 'isBuy',
        type: 'select',
        width: '215px',
        optionList: [
          {
            confId: '',
            confName: '全部'
          },
          {
            confId: 'Y',
            confName: '已付款'
          },
          {
            confId: 'N',
            confName: '未付款'
          }
        ],
        optionId: 'confId',
        optionLabel: 'confName',
      })
      if (query.type == 3) this.tableParams.tableColumns.push({
        label: '分享时间',
        prop: 'sharedTime',
      })
      this.tableParams.tableColumns = [...this.tableParams.tableColumns, ...lastTableColumns]
    } else this.tableParams.tableColumns = [...this.tableParams.tableColumns, {
      label: '浏览次数',
      prop: 'browseCount',
    }, {
      label: '最后浏览时间',
      prop: 'lastBrowseDate',
    }]

  },

  mounted () {
    this.footerLeft = document.querySelector('.base-container-right').offsetLeft
    this.footerWidth = document.documentElement.clientWidth - this.footerLeft
  },

  methods: {
    beforeSearchFn () {
      return new Promise(resolve => {
        this.searchForm.activityId = this.routeInfo.id
        resolve()
      })
    },
    handleExport () {
      var params = this.$common.utils.deepClone(this.searchForm)
      let { type } = this.routeInfo
      params.pageNum = 1
      params.pageSize = 999999
      this.$apis.seckillActivity.exportBrowseApi(params, type).then(res => {
        exportFn(res)
      })
    },

    handleJump (path, row = {}) {
      this.$router.push({
        path: '/seckillActivity/crowdFundList'
      })
    },

    setTableFinishFun () {
      //接收到的数据为空
      this.$refs.browserRef.data.length ? (this.$refs.browserRef.tableHeightValues = '') : this.$refs.browserRef.setTableHeightFun()
    },

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

    handleReset () {
      this.searchForm = {
        activityId: this.routeInfo.id,
        customerName: '',
        mobile: ''
      }
      this.handleSearch()
    }
  }
}
</script>

<style scoped  lang="scss">
.edit-container {
  .table-title {
    font-weight: 400;
    font-size: 14px;
    color: #333333;
    line-height: 20px;
    display: flex;
    align-items: center;
    span {
      color: #5850ff;
    }
  }
}
</style>