index.vue 8.16 KB
<!-- 秒杀活动 -->
<template>
    <div class="ctnr">
        <GLCombiForm class="search-wrap" rowNumber="1" ref="orderRef" @handleOk="handleSearch" @handleRest="handleReset" :formObj="orderFormObj" :formData="orderFormData">
        </GLCombiForm>
        <div class="main-wrap">
            <div class="global-title-wrap">
                <span v-for="item in titleList" :key="item.id" :class="['title', {'curTitleCla': orderFormObj.requestType==item.id}]" @click="changeTable(item.id)">{{item.name}}</span>
            </div>
            <div class="table-wrap">
                <GLTable @setTableFinishFun="setTableFinishFun" ref="tableRef" :pageConf="pageConf" :searchForm="searchForm" :tableParams="tableParams" :getListApi="getListApi" :beforeSearchFn="beforeSearchFn">
                    <div slot="goodsNameSlot" class="goodsNameSlot" slot-scope="scope">
                        <img :src="scope.scope.goodsImageUrl" alt="">
                        <el-tooltip class="item" effect="dark" :content="(scope.scope.brandName || '') + (scope.scope.goodsSkuName || '')" placement="top">
                            <span class="name">{{ scope.scope.brandName }}{{ scope.scope.goodsSkuName }}</span>
                        </el-tooltip>
                    </div>
                    <div slot="userInfoSlot" class="userInfoSlot" slot-scope="scope">
                        <p class="name">{{ scope.scope.accountName || '--' }}</p>
                        <p class="phone">{{ scope.scope.customerPhone}}</p>
                    </div>
                    <div slot="orderStatusSlot" slot-scope="scope">
                        <span class="circle" :style="{backgroundColor: transfStatus(scope.scope.payStatus,scope.scope.orderStatus).color}"></span>
                        <span>{{ transfStatus(scope.scope.payStatus,scope.scope.orderStatus).name }}</span>
                    </div>
                    <div slot="orderNoSlot" class="userInfoSlot" slot-scope="scope">
                        <p class="name">第三方:{{ scope.scope.thirdSubOrderCode || '--' }}</p>
                        <p class="name">平台:{{ scope.scope.subOrderCode || '--'}}</p>
                    </div>
                    <div slot="auth-button" slot-scope="scope">
                        <GLTableButton :buttonList="buttonList" :buttonItem="scope" :buttonNum="3"></GLTableButton>
                    </div>
                </GLTable>
            </div>
        </div>
    </div>
</template>
  
<script>
import { utils } from 'glsx-common'
import util from '@/util/util'
const titleList = [
        {
            id: 0,
            name: '全部'
        },
        {
            id: 2,
            name: '待支付'
        },
        {
            id: 1,
            name: '待收货'
        },
        {
            id: 4,
            name: '已完成'
        },
        {
            id: 3,
            name: '退款/售后'
        },
        {
            id: 5,
            name: '已关闭'
        },
    ]
export default {
    name: 'goodsOrderIndex',
    data() {
      return {
        size: 'small',
        titleList,
        buttonList: [
          {
            type: 'el-button',
            name: '详情',
            attrs: {
              type: 'text',
              fn: '商品订单详情'
            },
            listeners: {
              click: row => this.goOrderDetaillPage(row.scope)
            }
          }
        ],
        searchForm: {},
        orderFormObj: {
            customerInfo: '',
            searchOrderCode: '',
            goodsInfo: '',
            requestType: '0',
            time: ''
        },
        orderFormData: [
            {
                label: '用户信息',
                name: 'customerInfo',
                placeholder: '请输入姓名或手机号',
                type: 'input',
                isClear: true
            },
            {
                label: '商品信息',
                name: 'goodsInfo',
                type: 'input',
                isClear: true
            },
            {
                label: '订单编号',
                name: 'searchOrderCode',
                type: 'input',
                isClear: true
            },
            {
                label: '下单时间',
                name: 'time',
                type: 'datePicker',
                isClear: true,
                pickerOptions: 'beforeRangePickerOptions'
            }
        ],
        getListApi:  this.$apis.platformGoods.getOrderList,
        pageConf: { pageSize: 'pageSize', pageNum: 'currentPage', totalCount: 'total' },
        tableParams: {
            listName: 'list',
            tableOption: true,
            tableColumns: [
                {
                    label: '商品名称',
                    width: 300,
                    addHtml: 'goodsNameSlot'
                },
                {
                    label: '单价 (元)',
                    width: 100,
                    prop: 'salePrice'
                },
                {
                    label: '数量',
                    prop: 'sellQty'
                },
                {
                    label: '实收金额 (元)',
                    width: 130,
                    formatter: cell => {
                      return (cell.salePrice * cell.sellQty).toFixed(2)
                    }
                },
                {
                    label: '用户信息',
                    width: 150,
                    addHtml: 'userInfoSlot'
                },
                {
                    label: '订单状态',
                    width: 110,
                    addHtml: 'orderStatusSlot'
                },
                {
                    label: '订单编号',
                    width: 300,
                    addHtml: 'orderNoSlot'
                },
                {
                    label: '下单时间',
                    width: 200,
                    formatter: cellValue => {
                        return cellValue.orderCreatedDate ? util.dateFormat(cellValue.orderCreatedDate, 'YYYY-MM-DD HH:mm:ss') : '--'
                    }
                }
            ]
        }
      }
    },
  
    components: {
    },
  
    mounted() {
    },
  
    methods: {
        transfStatus: util.transfStatus,
        setTableFinishFun () {
            //接收到的数据为空
            this.$refs.tableRef.data.length ? (this.$refs.tableRef.tableHeightValues = '') : this.$refs.tableRef.setTableHeightFun()
        },
        changeTable(id){
            this.orderFormObj.requestType = id
            this.handleSearch()
        },
        handleReset(){
            this.orderFormObj = {
                customerInfo: '',
                searchOrderCode: '',
                goodsInfo: '',
                requestType: this.orderFormObj.requestType,
                time: ''
            }
            this.handleSearch()
        },
        handleSearch(){
            this.$refs.tableRef.refreshTable()
        },
        getParams(){
            let params = utils.deepClone(this.orderFormObj)
            if(params?.time?.length){
                params.createdStartTime = new Date(params.time[0]).toLocaleDateString().replace(/\//g, '-') + ' 00:00:00'
                params.createdEndTime = new Date(params.time[1]).toLocaleDateString().replace(/\//g, '-') + ' 23:59:59'
            }
            delete params.time
            return params
        },
        beforeSearchFn(){
            return new Promise((resolve, reject)=>{
                this.searchForm = this.getParams()
                resolve()
            }) 
        },
        goOrderDetaillPage(item){
            this.$router.push({ path: `/goodsOrder/detail/${item.subOrderCode}`})
        }
    }
  }
</script>
  
<style scoped lang="scss">
.ctnr{
    .search-wrap{
        background-color: #fff;
        padding: 20px;
    }
    .main-wrap{
        background-color: #fff;
        margin-top: 16px;
        .table-wrap{
            padding: 20px;
            .userInfoSlot{
                .name{
                    font-size: 14px;
                    color: #666666;
                }
                .phone{
                    font-size: 10px;
                    color: #999999;
                }
            }
        }
    }
}
</style>