AuctionOrderFunnel.vue 9.58 KB
<template>
    <a-spin :spinning="loading">
        <a-card title="拍卖流程核心漏斗" size="default" class="mt-10">
            <template #extra>
                <a-segmented v-model:value="segment" :options="segments" @change="changeDateRange">
                </a-segmented>
                <a-range-picker v-if="segment==='custom'" v-model:value="dateRange" @change="changeDateRange" :allowClear="false" class="ml-8"></a-range-picker>
            </template>
            <a-row :gutter="16" class="ml-10">
                <a-col :span="8" style="text-align: center;">
                    <a-statistic class="stat" title="总车源数" :value="totalCount" :precision="0"></a-statistic>
                </a-col>
                <a-col :span="8" style="text-align: center;">
                    <a-statistic class="stat" title="最终成交" :value="orderCount" :precision="0"></a-statistic>
                </a-col>
                <a-col :span="8" style="text-align: center;">
                    <a-statistic class="stat" title="转化率" :value="totalCount!==0?(orderCount*100/totalCount):0" :precision="1" suffix="%"></a-statistic>
                </a-col>
            </a-row>
            <div class="step-card">
                <a-tooltip color="blue">
                    <template #title>
                        <a-space direction="vertical">
                            <p>环节名称:总车源数</p>
                            <p>绝对数值:{{ totalCount }}</p>
                        </a-space>
                    </template>
                    <div class="step step-1">
                        总车源数 {{ totalCount }}
                    </div>
                </a-tooltip>
                <p>
                    <ArrowDownOutlined class="mr-8"/>
                    {{ totalCount !== 0 ? (warehousingCount * 100 / totalCount).toFixed(1) : 0 }}%
                </p>
                <a-tooltip color="blue">
                    <template #title>
                        <a-space direction="vertical">
                            <p>环节名称:入库车辆</p>
                            <p>绝对数值:{{ warehousingCount }}</p>
                            <p>与上一环节转化率:{{ totalCount !== 0 ? (warehousingCount * 100 / totalCount).toFixed(1) : 0 }}%</p>
                            <p>与初始环节转化率:{{ totalCount !== 0 ? (warehousingCount * 100 / totalCount).toFixed(1) : 0 }}%</p>
                        </a-space>
                    </template>
                    <div class="step step-2">
                        入库车辆 {{ warehousingCount }}
                    </div>
                </a-tooltip>
                <p>
                    <ArrowDownOutlined class="mr-8"/>
                    {{ warehousingCount !== 0 ? (auctionCount * 100 / warehousingCount).toFixed(1) : 0 }}%
                </p>
                <a-tooltip color="blue">
                    <template #title>
                        <a-space direction="vertical">
                            <p>环节名称:参拍车辆</p>
                            <p>绝对数值:{{ auctionCount }}</p>
                            <p>与上一环节转化率:{{ warehousingCount !== 0 ? (auctionCount * 100 / warehousingCount).toFixed(1) : 0 }}%</p>
                            <p>与初始环节转化率:{{ totalCount !== 0 ? (auctionCount * 100 / totalCount).toFixed(1) : 0 }}%</p>
                        </a-space>
                    </template>
                    <div class="step step-3">
                        参拍车辆 {{ auctionCount }}
                    </div>
                </a-tooltip>
                <p>
                    <ArrowDownOutlined class="mr-8"/>
                    {{ auctionCount !== 0 ? (orderCount * 100 / auctionCount).toFixed(1) : 0 }}%
                </p>
                <a-tooltip color="blue">
                    <template #title>
                        <a-space direction="vertical">
                            <p>环节名称:成交车辆</p>
                            <p>绝对数值:{{ orderCount }}</p>
                            <p>与上一环节转化率:{{ auctionCount !== 0 ? (orderCount * 100 / auctionCount).toFixed(1) : 0 }}%</p>
                            <p>与初始环节转化率:{{ totalCount !== 0 ? (orderCount * 100 / totalCount).toFixed(1) : 0 }}%</p>
                        </a-space>
                    </template>
                    <div class="step step-4">
                        成交车辆 {{ orderCount }}
                    </div>
                </a-tooltip>
                <p>
                    <ArrowDownOutlined class="mr-8"/>
                    {{ orderCount !== 0 ? (completedCount * 100 / orderCount).toFixed(1) : 0 }}%
                </p>
                <a-tooltip color="blue">
                    <template #title>
                        <a-space direction="vertical">
                            <p>环节名称:过户成功</p>
                            <p>绝对数值:{{ completedCount }}</p>
                            <p>与上一环节转化率: {{ orderCount !== 0 ? (completedCount * 100 / orderCount).toFixed(1) : 0 }}%</p>
                            <p>与初始环节转化率:{{ totalCount !== 0 ? (completedCount * 100 / totalCount).toFixed(1) : 0 }}%</p>
                        </a-space>
                    </template>
                    <div class="step step-5">
                        过户成功 {{ completedCount }}
                    </div>
                </a-tooltip>
            </div>
        </a-card>
    </a-spin>


</template>
<script lang="ts">
import {Component, Vue} from 'vue-facing-decorator';
import {ArrowDownOutlined} from "@ant-design/icons-vue";
import {VehicleController} from "@/api/VehicleController";
import dayjs from "dayjs";

@Component({components: {ArrowDownOutlined}})
export default class AuctionOrderFunnel extends Vue {
    segments = [{label: '今日', value: 'today'}, {label: '昨日', value: 'yesterday'}, {label: '近7天', value: 'day7'}, {label: '近30天', value: 'day30'}
        , {label: '自定义', value: 'custom'}];

    dateRange = [];
    segment = 'day30';

    vehicleCount: any = {};
    /**
     * 总车源数
     */
    totalCount = 0;

    warehousingCount = 0;

    auctionCount = 0;
    /**
     * 成交车辆
     */
    orderCount = 0;
    completedCount = 0;

    loading = false;

    created(): void {
        this.changeDateRange();
    }

    changeDateRange(): void {
        switch (this.segment) {
            case 'today':
                this.dateRange = [dayjs(), dayjs()];
                break;
            case 'yesterday':
                this.dateRange = [dayjs().add(-1, 'days'), dayjs().add(-1, 'days')];
                break;
            case 'day7':
                this.dateRange = [dayjs().add(-7, 'days'), dayjs()];
                break;
            case 'day30':
                this.dateRange = [dayjs().add(-30, 'days'), dayjs()];
                break;
            case 'custom':
                break;
        }
        this.loadData();
    }

    loadData(): void {
        this.loading = true;
        VehicleController.getVehicleCountByStateAndDateRange(this.axios, this.dateRange[0], this.dateRange[1]).then(res => {
            this.vehicleCount = res.data;
            this.calVehicleCount();
        }).finally(() => this.loading = false);
    }

    calVehicleCount(): void {
        let total = 0;
        let warehousingCount = 0;
        let auctionCount = 0;
        let orderCount = 0;
        let completedCount = 0;
        for (const key in this.vehicleCount) {
            total = total + this.vc(key);
            if (key !== 'INVENTORY') {
                warehousingCount = warehousingCount + this.vc(key);
                if (key !== 'VENUE' && key !== 'TO_BE_PRICED' && key !== 'PRICED') {
                    auctionCount = auctionCount + this.vc(key);
                    if (key !== 'PENDING_AUCTION' && key !== 'WAIT_AUCTION' && key !== 'PREVIEW' && key !== 'AUCTIONING') {
                        orderCount = orderCount + this.vc(key);
                        if (key !== 'CONTRACT_UNSIGNED' && key !== 'UNPAID' && key !== 'WAIT_PICKUP' && key !== 'TRANSFERRING') {
                            completedCount = completedCount + this.vc(key);
                        }
                    }
                }
            }
        }
        this.totalCount = total;
        this.warehousingCount = warehousingCount;
        this.auctionCount = auctionCount;
        this.orderCount = orderCount;
        this.completedCount = completedCount;
    }

    vc(state: string): number {
        const num = this.vehicleCount[state];
        if (num) {
            return num;
        } else {
            return 0;
        }
    }

}
</script>


<style scoped lang="less">
.stat {
    border-radius: 8px;
    //background: linear-gradient(129.4deg, #F7FAFF 0%, #EBF3FF 36.53%, #F7FAFF 100%);
    background: linear-gradient(129.4deg, #F7FAFFFF 0%, #F7FAFFFF 36.53%, #F7FAFFFF 100%);
    padding: 12px 16px 12px 16px;
}

.step-card {
    padding: 30px 48px 0 48px;
    text-align: center;

    p {
        line-height: 36px;
    }
}

.step {
    height: 32px;
    opacity: 1;
    border-radius: 6px;
    text-align: center;
    align-items: center;
    padding: 5px 0 5px 0;
    display: inline-block;
}

.step-1 {
    background: #EBF3FF;
    width: 100%;
    color: #777C85;
}

.step-2 {
    background: #C2D8FF;
    width: 80%;
    color: #777C85;
}

.step-3 {
    background: #78A8FB;
    width: 60%;
    color: #ffffff;
}

.step-4 {
    background: #3D84FF;
    width: 40%;
    color: #ffffff;
}

.step-5 {
    background: #1956FE;
    width: 20%;
    color: #ffffff;
}
</style>