diff --git a/pages/detail/detail.vue b/pages/detail/detail.vue index a5601e7..67f03fc 100644 --- a/pages/detail/detail.vue +++ b/pages/detail/detail.vue @@ -159,14 +159,14 @@ - 股票代码 + {{ transactionType === 'sell' ? '选择持仓' : '股票代码' }} - + - {{ result.ticker }} + {{ result.ticker || result.stockCode }} + {{ result.name || result.stockName }} {{ result.assetType }} - {{ result.exchange }} + {{ result.exchange || '' }} @@ -334,17 +335,18 @@ const searchStock = async (keyword) => { }; const selectStock = (result) => { - transactionForm.value.stockCode = result.ticker || result.Ticker; + transactionForm.value.stockCode = result.ticker || result.Ticker || result.stockCode; // 自动填充对应货币 - if (result.priceCurrency) { + const currency = result.priceCurrency || result.currency; + if (currency) { const currencyMap = { 'CNY': 0, 'USD': 1, 'HKD': 2 }; - if (currencyMap[result.priceCurrency] !== undefined) { - currencyIndex.value = currencyMap[result.priceCurrency]; - transactionForm.value.currency = result.priceCurrency; + if (currencyMap[currency] !== undefined) { + currencyIndex.value = currencyMap[currency]; + transactionForm.value.currency = currency; } } searchResults.value = []; @@ -413,6 +415,14 @@ const handleBuy = () => { const handleSell = () => { transactionType.value = 'sell'; resetTransactionForm(); + // 卖出时自动填充持仓列表作为可选 + searchResults.value = positions.value.map(pos => ({ + ticker: pos.stockCode, + name: pos.stockName, + assetType: pos.assetType || 'Stock', + priceCurrency: pos.currency, + exchange: '' + })); showTransactionForm.value = true; }; @@ -425,6 +435,8 @@ const resetTransactionForm = () => { transactionDate: getCurrentDate(), remark: '' }; + // 重置搜索结果 + searchResults.value = []; }; const submitTransaction = async () => {