优化:限价单已经完成的不可以撤消

This commit is contained in:
ivan 2026-03-01 00:46:06 +08:00
parent fffd7461df
commit 0069ae8357
4 changed files with 13 additions and 4 deletions

View File

@ -191,6 +191,8 @@ export interface OpenOrderDisplayItem {
filledDisplay?: string filledDisplay?: string
orderID?: number orderID?: number
tokenID?: string tokenID?: string
/** 已成交数量达到原始总数量,不可撤单 */
fullyFilled?: boolean
} }
/** OrderType GTC=0 表示 Until Cancelled */ /** OrderType GTC=0 表示 Until Cancelled */
@ -219,6 +221,7 @@ export function mapOrderToOpenOrderItem(order: ClobOrderItem): OpenOrderDisplayI
const expiration = const expiration =
order.orderType === OrderType.GTC ? 'Until Cancelled' : order.expiration?.toString() ?? '' order.orderType === OrderType.GTC ? 'Until Cancelled' : order.expiration?.toString() ?? ''
const actionLabel = sideNum === Side.Buy ? `Buy ${outcome}` : `Sell ${outcome}` const actionLabel = sideNum === Side.Buy ? `Buy ${outcome}` : `Sell ${outcome}`
const fullyFilled = originalSize <= 0 || sizeMatched >= originalSize
return { return {
id, id,
market, market,
@ -232,5 +235,6 @@ export function mapOrderToOpenOrderItem(order: ClobOrderItem): OpenOrderDisplayI
filledDisplay: filled, filledDisplay: filled,
orderID: order.ID, orderID: order.ID,
tokenID: order.assetID, tokenID: order.assetID,
fullyFilled,
} }
} }

View File

@ -250,7 +250,8 @@ const bidsWithCumulativeTotal = computed(() => {
return sortedBids.map((bid) => { return sortedBids.map((bid) => {
// Calculate current bid's value // 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 cumulativeTotal += bidValue
return { return {
...bid, ...bid,

View File

@ -108,7 +108,7 @@
variant="text" variant="text"
size="small" size="small"
color="error" color="error"
:disabled="cancelOrderLoading" :disabled="cancelOrderLoading || ord.fullyFilled"
@click="cancelMarketOrder(ord)" @click="cancelMarketOrder(ord)"
> >
{{ t('activity.cancelOrder') }} {{ t('activity.cancelOrder') }}
@ -993,6 +993,7 @@ async function loadMarketOpenOrders() {
const cancelOrderLoading = ref(false) const cancelOrderLoading = ref(false)
async function cancelMarketOrder(ord: OpenOrderDisplayItem) { async function cancelMarketOrder(ord: OpenOrderDisplayItem) {
if (ord.fullyFilled) return
const orderID = ord.orderID ?? 0 const orderID = ord.orderID ?? 0
const tokenID = ord.tokenID ?? '' const tokenID = ord.tokenID ?? ''
const uid = userStore.user?.id ?? userStore.user?.ID const uid = userStore.user?.id ?? userStore.user?.ID

View File

@ -358,7 +358,7 @@
size="small" size="small"
class="order-cancel-icon" class="order-cancel-icon"
color="error" color="error"
:disabled="cancelOrderLoading" :disabled="cancelOrderLoading || ord.fullyFilled"
@click.stop="cancelOrder(ord)" @click.stop="cancelOrder(ord)"
> >
<v-icon size="20">mdi-close</v-icon> <v-icon size="20">mdi-close</v-icon>
@ -404,7 +404,7 @@
variant="text" variant="text"
size="small" size="small"
color="error" color="error"
:disabled="cancelOrderLoading" :disabled="cancelOrderLoading || ord.fullyFilled"
@click="cancelOrder(ord)" @click="cancelOrder(ord)"
>Cancel</v-btn >Cancel</v-btn
> >
@ -718,6 +718,8 @@ interface OpenOrder {
/** 取消订单 API 用 */ /** 取消订单 API 用 */
orderID?: number orderID?: number
tokenID?: string tokenID?: string
/** 已成交数量达到原始总数量,不可撤单 */
fullyFilled?: boolean
} }
interface HistoryItem { interface HistoryItem {
id: string id: string
@ -977,6 +979,7 @@ const cancelOrderLoading = ref(false)
const cancelOrderError = ref('') const cancelOrderError = ref('')
const showCancelError = ref(false) const showCancelError = ref(false)
async function cancelOrder(ord: OpenOrder) { async function cancelOrder(ord: OpenOrder) {
if (ord.fullyFilled) return
const orderID = ord.orderID ?? 5 const orderID = ord.orderID ?? 5
const tokenID = ord.tokenID ?? MOCK_TOKEN_ID const tokenID = ord.tokenID ?? MOCK_TOKEN_ID
const uid = userStore.user?.id ?? userStore.user?.ID const uid = userStore.user?.id ?? userStore.user?.ID