CreateAuctionOrder.vue 3.95 KB
<template>
    <a-alert class="mt-16" message="请从以下已出价的竞拍者中选择一位作为新的成交人。确认后,当前订单将被作废,
并为新的成交人生成新订单。" type="info" show-icon/>
    <a-table class="mt-16" :columns="columns" :data-source="bids" :bordered="false" @resizeColumn="this.$filters.tableResizeColumn"
             size="small" :pagination="false" :row-key="record => record.bidId" :scroll="{y: '500px)'}"
             :row-selection="{ selectedRowKeys: selectIds, onChange: onSelectChange, type: 'radio', preserveSelectedRowKeys:true }">
        <template #bodyCell="{column,record}">
            <template v-if="column.key === 'action'">

            </template>
        </template>
        <!--拍卖订单列表end-->
    </a-table>
</template>
<script lang="ts">
import {Component, Prop, Vue} from "vue-facing-decorator";
import AuctionOrderStateTag from "@/views/auction/order/AuctionOrderStateTag.vue";
import {message, Modal, TableColumnsType} from "ant-design-vue";
import {Bid} from "lib/src/entity/auction/entity/Bid";
import {BidController} from "@/api/BidController";
import {AuctionOrder} from "lib/src/entity/auction/entity/AuctionOrder";
import {AuctionOrderController} from "@/api/AuctionOrderController";
import {BidOrder} from "lib/src/entity/auction/domain/BidOrder";
import {ExclamationCircleOutlined} from "@ant-design/icons-vue";
import {createVNode} from "vue";

@Component({
    components: {AuctionOrderStateTag}
})
export default class CreateAuctionOrder extends Vue {

    @Prop({required: true, type: Object})
    auctionOrder: AuctionOrder;

    bids: Bid[] = [];

    selectIds: number[] = [];

    selectedItem: Bid;

    columns: TableColumnsType = [
        {title: '姓名', dataIndex: ['account', 'accountName'], key: 'accountName', resizable: true, ellipsis: true, sorter: true},
        {title: '账号', dataIndex: ['account', 'mobile'], key: 'mobile', resizable: true, ellipsis: true, sorter: true},
        {title: '出价金额', dataIndex: 'bidPrice', key: 'bidPrice', width: 180, resizable: true, ellipsis: true, sorter: true},
        {title: '出价时间', dataIndex: 'createTime', key: 'createTime', width: 170, align: 'center', resizable: true, ellipsis: true, sorter: true},
        {
            title: '是否成交', dataIndex: 'deal', key: 'deal', width: 100, resizable: true, ellipsis: true, sorter: true,
            customRender: ({text, record, index, column}) => {
                return text ? '成交' : '未成交';
            }
        },
    ];

    created(): void {
        BidController.getLastBidsByOrderId(this.axios, this.auctionOrder.orderId).then(response => {
            this.bids = response.data;
        });
    }

    onSelectChange(selectedRowKeys: number[], selectedRows: Bid[]): void {
        this.selectIds = selectedRowKeys;
        this.selectedItem = selectedRows[0];
    }

    submitForm(): void {
        if (this.selectIds.length === 0) {
            message.warning('请选择一个出价者');
            return;
        }
        const that = this;
        const accountName = that.selectedItem.account.accountName;
        const orderPrice = that.selectedItem.bidPrice;
        const bidOrder = new BidOrder();
        bidOrder.bidId = that.selectedItem.bidId;
        bidOrder.orderId = that.auctionOrder.orderId;
        Modal.confirm({
            title: '提示',
            icon: createVNode(ExclamationCircleOutlined),
            content: `您确定将成交人修改为「${accountName}」吗?原订单将被作废,新订单成交价为 ¥${orderPrice}。`,
            onOk() {
                AuctionOrderController.addAuctionOrder(that.axios, bidOrder).then(response => {
                    message.success('新合同创建成功');
                    that.$emit('handleOk', response.data);
                });
            },
            onCancel() {
                console.log('Cancel');
            },
        });

    }
}
</script>

<style lang="less" scoped>

</style>