diff --git a/src/api/order.ts b/src/api/order.ts index 0b6f453..7e50bb3 100644 --- a/src/api/order.ts +++ b/src/api/order.ts @@ -191,6 +191,8 @@ export interface OpenOrderDisplayItem { filledDisplay?: string orderID?: number tokenID?: string + /** 已成交数量达到原始总数量,不可撤单 */ + fullyFilled?: boolean } /** OrderType GTC=0 表示 Until Cancelled */ @@ -219,6 +221,7 @@ export function mapOrderToOpenOrderItem(order: ClobOrderItem): OpenOrderDisplayI const expiration = order.orderType === OrderType.GTC ? 'Until Cancelled' : order.expiration?.toString() ?? '' const actionLabel = sideNum === Side.Buy ? `Buy ${outcome}` : `Sell ${outcome}` + const fullyFilled = originalSize <= 0 || sizeMatched >= originalSize return { id, market, @@ -232,5 +235,6 @@ export function mapOrderToOpenOrderItem(order: ClobOrderItem): OpenOrderDisplayI filledDisplay: filled, orderID: order.ID, tokenID: order.assetID, + fullyFilled, } } diff --git a/src/components/OrderBook.vue b/src/components/OrderBook.vue index ff7680b..7bad62e 100644 --- a/src/components/OrderBook.vue +++ b/src/components/OrderBook.vue @@ -250,7 +250,8 @@ const bidsWithCumulativeTotal = computed(() => { return sortedBids.map((bid) => { // Calculate current bid's value - const bidValue = (bid.price * bid.shares) / 100 // Convert cents to dollars + console.log('bid.price', bid.price) + const bidValue = (bid.price * bid.shares) / 100.0 // Convert cents to dollars cumulativeTotal += bidValue return { ...bid, diff --git a/src/views/TradeDetail.vue b/src/views/TradeDetail.vue index 34e2692..4bb36be 100644 --- a/src/views/TradeDetail.vue +++ b/src/views/TradeDetail.vue @@ -108,7 +108,7 @@ variant="text" size="small" color="error" - :disabled="cancelOrderLoading" + :disabled="cancelOrderLoading || ord.fullyFilled" @click="cancelMarketOrder(ord)" > {{ t('activity.cancelOrder') }} @@ -993,6 +993,7 @@ async function loadMarketOpenOrders() { const cancelOrderLoading = ref(false) async function cancelMarketOrder(ord: OpenOrderDisplayItem) { + if (ord.fullyFilled) return const orderID = ord.orderID ?? 0 const tokenID = ord.tokenID ?? '' const uid = userStore.user?.id ?? userStore.user?.ID diff --git a/src/views/Wallet.vue b/src/views/Wallet.vue index bb5b620..a31be82 100644 --- a/src/views/Wallet.vue +++ b/src/views/Wallet.vue @@ -358,7 +358,7 @@ size="small" class="order-cancel-icon" color="error" - :disabled="cancelOrderLoading" + :disabled="cancelOrderLoading || ord.fullyFilled" @click.stop="cancelOrder(ord)" > mdi-close @@ -404,7 +404,7 @@ variant="text" size="small" color="error" - :disabled="cancelOrderLoading" + :disabled="cancelOrderLoading || ord.fullyFilled" @click="cancelOrder(ord)" >Cancel @@ -718,6 +718,8 @@ interface OpenOrder { /** 取消订单 API 用 */ orderID?: number tokenID?: string + /** 已成交数量达到原始总数量,不可撤单 */ + fullyFilled?: boolean } interface HistoryItem { id: string @@ -977,6 +979,7 @@ const cancelOrderLoading = ref(false) const cancelOrderError = ref('') const showCancelError = ref(false) async function cancelOrder(ord: OpenOrder) { + if (ord.fullyFilled) return const orderID = ord.orderID ?? 5 const tokenID = ord.tokenID ?? MOCK_TOKEN_ID const uid = userStore.user?.id ?? userStore.user?.ID