burialPointList.vue 7.46 KB
<!-- 秒杀活动 -->
<template>
    <div>
        <div class="big-title">
            攻略名称:{{strategyName || '--'}}
        </div>
        <div class="ctnr">
            <GLCombiForm ref="goodsRef" @handleOk="handleSearch" @handleRest="handleReset" :formObj="searchFormObj" :formData="searchFormData">
            </GLCombiForm>
            <div class="operate-wrap">
                <span class="table-title">已累计{{searchFormObj.recordType==1 ? '浏览' : searchFormObj.recordType==2 ? '分享' : ''}}<span style="color: #5850FF;">{{total}}</span>{{searchFormObj.recordType==3 ? '位访客' : '次'}}</span>
                <div class="operate-btn">
                    <el-button :size="size" type="primary" plain  @click="handleExport">导出</el-button>
                </div>           
            </div>
            <GLTable ref="tableRef" :pageConf="pageConf" :searchForm="searchFormObj" :tableParams="tableParams" :getListApi="getListApi" :beforeSearchFn="beforeSearchFn" @setTableFinishFun="setTableFinishFun">
                <div slot="customerSlot" class="goodsNameSlot" slot-scope="scope">
                    <img v-if="scope.scope.customerAvatar" :src="scope.scope.customerAvatar" alt="">{{ scope.scope.customerName }}
                </div>
                <div slot="shareSlot" class="goodsNameSlot" slot-scope="scope">
                    <img v-if="scope.scope.shareAvatar" :src="scope.scope.shareAvatar" alt="">{{ scope.scope.shareName }}
                </div>
                <div slot="goodsNameSlot" class="goodsNameSlot" slot-scope="scope">
                    <img :src="scope.scope.goodsImgUrl" alt="">{{ scope.scope.goodsSkuName }}
                </div>
                <div class="setPriceSlot" slot="setPriceSlot" slot-scope="scope">
                    <el-input  v-if="curEditId==scope.scope.id" :value="scope.scope.salePrice"  type="text" clearable @blur="setPriceFn(scope.scope)"></el-input>
                    <span class="unedited" v-else>
                        {{scope.scope.salePrice}}
                        <img :src="require('@/assets/images/edit.png')" alt="" @click="editPrice(scope.scope)">
                    </span>
                </div>
            </GLTable>
        </div>
    </div>
</template>
  
<script>
const baseColumn = [
    {
        label: '微信昵称',
        addHtml: 'customerSlot'
    },
    {
        label: '手机号',
        prop: 'mobile'
    },
    {
        label: '分享人',
        addHtml: 'shareSlot'
    }
]

const otherColumn = {
    1: [
        {
            label: '浏览时长',
            prop: 'browserTime'
        },
        {
            label: '进入页面时间',
            prop: 'operationDate'
        },
        {
            label: '离开页面时间',
            prop: 'leaveDate'
        },
    ],
    2: [
        {
            label: '分享时间',
            prop: 'operationDate'
        },
        {
            label: '浏览时长',
            prop: 'browserTime',
            formatter: cell =>{
                return '--'
            }
        },
        {
            label: '进入页面时间',
            prop: 'operationDate',
            formatter: cell =>{
                return '--'
            }
        },
        {
            label: '离开页面时间',
            prop: 'leaveDate',
            formatter: cell =>{
                return '--'
            }
        },
    ],
    3: [
        {
            label: '浏览次数',
            prop: 'browseCount'
        },
        {
            label: '最后浏览时间',
            prop: 'lastBrowseDate'
        },
    ]
}
import { utils } from 'glsx-common'
export default {
    name: 'browse',
    data() {
      return {
        size: 'small',
        searchFormObj: {
            recordType: 1,
            strategyId: '',
            customerName: '',
            mobile: '',
            shareName: ''
        },
        strategyName: '',
        total: 0,
        searchFormData: [
            {
                label: '微信昵称',
                name: 'customerName',
                type: 'input',
                isClear: true
            },
            {
                label: '手机号',
                name: 'mobile',
                type: 'input',
                isClear: true
            },
            {
                label: '分享人',
                name: 'shareName',
                type: 'input',
                isClear: true
            }
        ],
        getListApi: this.$apis.strategy.getburialPointListApi,
        pageConf: { pageSize: 'pageSize', pageNum: 'pageNum', totalCount: 'total' },
        tableParams: {
            listName: 'list',
            tableOption: null,
            tableColumns: []
        },
      }
    },
  
    components: {
    },

    created() {
        const urlParam = this.$route.params
        this.routeInfo = JSON.parse(decodeURIComponent(urlParam.id))
        console.log(this.routeInfo)
        const {id, recordType, strategyName} = this.routeInfo
        this.strategyName = strategyName
        this.searchFormObj.strategyId = id
        this.searchFormObj.recordType = recordType
        this.tableParams.tableColumns = [...baseColumn,...otherColumn[recordType]]
    },
  
    mounted() {
    },
  
    methods: {
        handleReset(){
            this.searchFormObj = {
                strategyId: this.routeInfo.id,
                recordType: 1,
                customerName: '',
                mobile: '',
                shareName: ''
            }
            this.handleSearch()
        },
        setTableFinishFun(){
            this.total = this.$refs.tableRef.total
        },
        handleExport() {
            const parmas = { ...this.searchFormObj }
            this.$apis.strategy.exportListApi(parmas).then(({ code, data, message }) => {
                if (code == '0') {
                var a = document.createElement('a')
                a.setAttribute('id', 'exportToExport')
                a.setAttribute('href', data)
                a.setAttribute('target', '_blank')
                document.body.appendChild(a)
                a.click()
                } else {
                this.$message.error(message)
                }
            })
            },
        handleSearch(){
            this.$refs.tableRef.refreshTable()
        },
        beforeSearchFn(){
            return new Promise((resolve, reject)=>{
                this.searchForm = utils.deepClone(this.searchFormObj)
                const { categoryCode  } = this.searchForm
                this.searchForm.categoryCode = categoryCode && categoryCode.length ? categoryCode.pop() : ''
                resolve()
            }) 
        },
        goDetaillPage(item){
            this.$router.push({ path: `/goodsWarehouse/detail/${item.id}`})
        }
    }
  }
</script>
  
<style scoped lang="scss">
.big-title{
    height: 52px;
    background: #FFFFFF;
    margin-bottom: 16px;
    padding: 0 20px;
    line-height: 52px;
    font-weight: 600;
    font-size: 14px;
    color: #333333;
    font-family: PingFangSC-Medium;
}
.ctnr{
    background-color: #fff;
    padding: 20px;
    .goodsNameSlot{
        img{
            width: 36px;
            height: 36px;
            vertical-align: middle;
            margin-right: 8px;
        }
    }
    .setPriceSlot{
        .unedited{
            display: flex;
            align-items: center;
        }
        img{
            width: 16px;
            height: 16px;
            vertical-align: middle;
            margin-left: 8px;
            cursor: pointer;
        }
    }
}
</style>