AuctionControlPage.vue 15.8 KB
<template>
    <a-card class="tabs-card" :bordered="false" :tab-list="tabs" :active-tab-key="currentAuctionType" @tabChange="key => changeTab(key )">

        <!--查询栏-->
        <m-pagination-query-render :fields="pagination.filterFields" :form="pagination.queryForm" @onSearch="pageReload" @onReset="pageReset" :simpleFieldNum="4"/>
        <div class="table-operations">
            <a-radio-group class="state-radio-group mt-12" v-model:value="pagination.queryForm.auctionState" @change="pageReload">
                <a-radio-button :value="null">{{ $t('common.all') }}</a-radio-button>
                <a-radio-button v-for="item in auctionStates" :key="item" :value="item">
                    {{ $t('enum.auction.auctionState.' + item) }}({{ auctionStateCount[item] ?? 0 }})
                </a-radio-button>
            </a-radio-group>
        </div>
        <a-list :grid="{ gutter: 16, xs: 1, sm: 2, md: 2, lg: 3, xl: 3, xxl: 3   }" :loading="loading" :data-source="contents">
            <template #footer>
                <a-pagination style="float: right" v-model:current="pagination.pageIndex" :total="pagination.totalElements" @change="pageChange" v-model:page-size="pagination.pageSize"
                              :show-total="showTotal"/>
            </template>
            <template #renderItem="{ item }">
                <a-list-item style="padding-bottom: 0;margin-bottom:4px">
                    <a-card class="control-card" size="default" :bordered="false">
                        <template #title>
                            <a-typography-text type="secondary">ID {{ item.auctionId }}</a-typography-text>
                        </template>
                        <template #extra>
                            <auction-state-tag :auction-state="item.auctionState"></auction-state-tag>
                        </template>
                        <h4>{{ item.auctionName }}</h4>
                        <a-typography-text type="secondary">
                            <CalendarOutlined/>
                            {{ item.auctionStartTime }}至 {{ item.auctionEndTime }}
                        </a-typography-text>

                        <a-flex class="mt-12 mb-8">
                            <a-tooltip :title="updateTime">
                                <a-progress class="mt-8 mb-8" :percent="item.auctionedCount*100/item.vehicleCount" stroke-color="#1956FE" trail-color="#B1C8FD" :show-info="false"/>
                            </a-tooltip>
                            <a-space align="center" style="min-width: 50px">
                                {{ item.auctionedCount }}/ {{ item.vehicleCount + '辆' }}
                            </a-space>
                        </a-flex>


                        <a-row :gutter="[10,10]">
                            <!--                            <a-col :span="12">-->
                            <!--                                <a-card size="small" :bordered="false" style="background-color: #ECF4FE">-->
                            <!--                                    <a-statistic :value="item.auctionedCount+'/'+item.vehicleCount" :precision="0" suffix="辆">-->
                            <!--                                        <template #title>-->
                            <!--                                            <LineChartOutlined/>-->
                            <!--                                            拍卖进展-->
                            <!--                                        </template>-->
                            <!--                                    </a-statistic>-->
                            <!--                                </a-card>-->
                            <!--                            </a-col>-->
                            <a-col :span="8">
                                <a-card size="small" :bordered="false">
                                    <a-tooltip :title="updateTime">
                                        <a-statistic :value="item.accountCount" :precision="0" :value-style="statisticStyle">
                                            <template #title>
                                                <TeamOutlined/>
                                                参拍人数
                                            </template>
                                        </a-statistic>
                                    </a-tooltip>
                                </a-card>
                            </a-col>
                            <a-col :span="8">
                                <a-card size="small" :bordered="false">
                                    <a-tooltip :title="updateTime">
                                        <a-statistic :value="item.vehicleCount===0?0:(item.auctionedCount/ item.vehicleCount)*100" :precision="1" suffix="%" :value-style="statisticStyle">
                                            <template #title>
                                                <RiseOutlined/>
                                                成交率
                                            </template>
                                        </a-statistic>
                                    </a-tooltip>
                                </a-card>
                            </a-col>
                            <a-col :span="8">
                                <a-card size="small" :bordered="false">
                                    <a-tooltip :title="updateTime">
                                        <a-statistic :value="item.transactionVolume/10000" :precision="2" suffix="万" :value-style="statisticStyle">
                                            <template #title>
                                                <DollarOutlined/>
                                                成交额
                                            </template>
                                        </a-statistic>
                                    </a-tooltip>
                                </a-card>
                            </a-col>
                        </a-row>
                        <a-flex class="mt-16" justify="space-between">
                            <a-space>
                                <template v-if="item.auctionState==='WAIT_AUCTION'||item.auctionState==='PREVIEW'">
                                    <router-link :to="{path:'/auction/view/control',query:{auctionId: item.auctionId }}">
                                        <a-button type="link" size="small">
                                            <template #icon>
                                                <EyeOutlined class="mr-5"/>
                                            </template>
                                            详情
                                        </a-button>
                                    </router-link>
                                    <router-link v-sec="'control_10'" v-if="item.auctionState==='WAIT_AUCTION'" :to="{path:'/auction/form',query:{id: item.auctionId,action:'edit'}}">
                                        <a-button type="link" size="small">
                                            <template #icon>
                                                <EditOutlined class="mr-5"/>
                                            </template>
                                            编辑
                                        </a-button>
                                    </router-link>
                                </template>
                                <router-link v-sec="'control_1'" v-if="item.auctionState==='AUCTIONING'" :to="{ path:'/auction/view/control',query:{auctionId: item.auctionId}}">
                                    <a-button type="link" size="small">
                                        <template #icon>
                                            <ToolOutlined class="mr-5"/>
                                        </template>
                                        拍卖管控
                                    </a-button>
                                </router-link>
                                <template v-if="item.auctionState==='CLOSED'">
                                    <router-link v-sec="'control_13'" :to="{path:'/auction/order',query:{auctionId: item.auctionId }}">
                                        <a-button type="link" size="small">
                                            <template #icon>
                                                <AccountBookOutlined class="mr-5"/>
                                            </template>
                                            查看订单
                                        </a-button>
                                    </router-link>
                                    <!--                                    <a-button v-sec="'control_14'" type="link" size="small">-->
                                    <!--                                        <template #icon>-->
                                    <!--                                            <LineChartOutlined class="mr-5"/>-->
                                    <!--                                        </template>-->
                                    <!--                                        查看数据-->
                                    <!--                                    </a-button>-->
                                </template>
                            </a-space>
                            <a-space>
                                <template v-if="item.auctionState==='WAIT_AUCTION'||item.auctionState==='PREVIEW'">
                                    <a-button v-sec="'control_11'" type="link" danger size="small" @click="cancelAuction(item)">
                                        <template #icon>
                                            <StopOutlined class="mr-5"/>
                                        </template>
                                        取消
                                    </a-button>
                                </template>
                            </a-space>
                        </a-flex>
                    </a-card>
                </a-list-item>
            </template>
        </a-list>
    </a-card>
</template>
<script lang="ts">
import {Component} from 'vue-facing-decorator';
import {PaginationComponent} from "@/components/PaginationComponent";
import {Auction} from "lib/src/entity/auction/entity/Auction";
import {Operator, Order} from "lib/src/core/page/Pagination";
import {AuctionController} from "@/api/AuctionController";
import {AuctionControl} from "lib/src/entity/auction/domain/AuctionControl";
import {convertToTree} from "@/common/chinaarea";
import {
    AccountBookOutlined,
    CalendarOutlined,
    DollarOutlined,
    EditOutlined,
    EyeOutlined,
    LineChartOutlined,
    PlusSquareOutlined,
    RiseOutlined,
    SearchOutlined,
    StopOutlined,
    TeamOutlined,
    ToolOutlined
} from "@ant-design/icons-vue";
import AuctionStateTag from "@/views/auction/auction/tag/AuctionStateTag.vue";
import {ModalService} from "@/components/ModalService";
import AuctionChangeCancel from "@/views/auction/control/change/AuctionChangeCancel.vue";
import dayjs from "dayjs";

@Component({
    methods: {},
    components: {
        AuctionStateTag,
        PlusSquareOutlined,
        SearchOutlined,
        LineChartOutlined,
        RiseOutlined,
        StopOutlined,
        AccountBookOutlined,
        ToolOutlined,
        EyeOutlined,
        EditOutlined,
        TeamOutlined,
        DollarOutlined,
        CalendarOutlined
    }
})
export default class AuctionControlPage extends PaginationComponent<AuctionControl> {

    areaData = [];

    currentAuctionType = 'LIGHT';

    tabs = [{key: "LIGHT", tab: '明拍管理'}, {key: "DARK", tab: '暗拍管理'}];

    auctionStates = ['WAIT_AUCTION', 'PREVIEW', 'AUCTIONING', 'CLOSED'];

    auctionStateCount = {};

    statisticStyle = {fontSize: '16px', fontWeight: 500};
    intervalId: number;

    updateTime = "";

    /**
     * 初始化配置
     */
    created(): void {
        this.areaData = convertToTree(false);
        this.init(this.axios, AuctionController.PAGE_AUCTION_CONTROL);
        this.buildQueryForm({
            auctionName: [null, {label: '场次名称', field: 'auctionName', operator: Operator.like}],
            auctionState: [this.$route.query.auctionState ?? null, {label: '拍场状态', field: 'auctionState', operator: Operator.eq, hidden: true}],
            auctionDate: [null, {label: '拍卖日期', field: 'auctionDate', operator: Operator.dateBetween, type: 'date-range'}],
            accountCount: [null, {label: '当前参拍人数', field: 'accountCount', fieldName2: 'accountCount1', type: 'number-range', operator: Operator.numberBetween}],
            auctionedCount: [null, {label: '成交数量', field: 'auctionedCount', fieldName2: "auctionedCount1", type: 'number-range', min: 0, max: 100, step: 1, operator: Operator.numberBetween}],
            transactionVolume: [null, {label: '实时成交额(元)', field: 'transactionVolume', fieldName2: "transactionVolume1", type: 'number-range', operator: Operator.numberBetween}],
        });
        this.pagination.setDefaultSort('createTime', Order.desc);
        this.pagination.addDefaultFilter('auctionType', this.currentAuctionType);
        this.pageLoad().then(() => {
            this.updateTime = '数据更新于' + dayjs().format('YYYY-MM-DD HH:mm:ss');
        });
        this.loadAuctionStateCount();
        this.intervalId = setInterval(() => {
            this.pageRefresh().then(res => {
                this.updateTime = '数据更新于' + dayjs().format('YYYY-MM-DD HH:mm:ss');
            });
        }, 60000);
    }


    get contents(): AuctionControl[] {
        return this.pagination.content;
    }

    unmounted(): void {
        clearInterval(this.intervalId);
    }

    cancelAuction(auction: Auction): void {
        const modal = ModalService.confirm({
            title: '申请中止拍卖', component: AuctionChangeCancel, closable: true, appContext: this.$.appContext,
            props: {
                auction: auction
            },
            onOk: (component): void => {
                component.submitForm();
            },
            emits: {
                handleOk: (e) => {
                    modal.destroy();
                    this.pagination.refresh();
                    this.loadAuctionStateCount();
                }
            },
        });
    }

    changeTab(key: string): void {
        this.currentAuctionType = key;
        this.pagination.addDefaultFilter('auctionType', this.currentAuctionType);
        this.loadAuctionStateCount();
        this.loading = true;
        this.pagination.reload().then(res => {
            this.loadAuctionStateCount();
        }).finally(() => this.loading = false);
    }

    loadAuctionStateCount(): void {
        AuctionController.getAuctionStateCountByType(this.axios, this.currentAuctionType).then(res => {
            this.auctionStateCount = res.data;
        });
    }

    percentFormat(item, percent, successPercent) {
        return `${percent.toFixed(2)}%(${successPercent.toFixed(2)}%)`
    }

    showTotal(total, range) {
        return this.$t('common.page_state', {start: range[0], end: range[1], total: total});
    }

    /**
     * 当前分页状态
     */
    // get listPageState(): unknown {
    //     return {
    //         current: this.pagination.pageIndex,
    //         pageSize: this.pagination.pageSize,
    //         total: this.pagination.totalElements,
    //         showSizeChanger: true,
    //         pageSizeOptions: ['10', '20', '30', '50', '100'],
    //         showQuickJumper: true,
    //         // @ts-ignore
    //         showTotal: (total, range) => this.$t('common.page_state', {start: range[0], end: range[1], total: total}),
    //         // change: (page: number, pageSize: number) => this.pageChange(page, pageSize),
    //         change: this.pageChange
    //     };
    // }
}
</script>


<style scoped lang="less">
::v-deep(.ant-list .ant-list-item) {
    padding: 12px 0;
}


</style>