feat: 卖出功能优化,点击减少自动展示已有持仓列表供选择

This commit is contained in:
claw_bot 2026-03-10 02:33:35 +00:00
parent fa45406d8d
commit 97f2442581

View File

@ -159,14 +159,14 @@
<view class="form-content">
<view class="form-item relative">
<text class="form-label">股票代码</text>
<text class="form-label">{{ transactionType === 'sell' ? '选择持仓' : '股票代码' }}</text>
<input
v-model="transactionForm.stockCode"
class="form-input"
placeholder="请输入股票代码"
:placeholder="transactionType === 'sell' ? '请选择要卖出的持仓' : '请输入股票代码'"
@input="(e) => searchStock(e.detail.value)"
/>
<!-- 搜索下拉列表 -->
<!-- 搜索下拉列表/持仓列表 -->
<view class="search-dropdown" v-if="searchResults.length > 0">
<view
class="dropdown-item"
@ -175,10 +175,11 @@
@click="selectStock(result)"
>
<view class="item-left">
<text class="item-ticker">{{ result.ticker }}</text>
<text class="item-ticker">{{ result.ticker || result.stockCode }}</text>
<text class="item-name">{{ result.name || result.stockName }}</text>
<text class="item-type" v-if="result.assetType">{{ result.assetType }}</text>
</view>
<text class="item-exchange">{{ result.exchange }}</text>
<text class="item-exchange">{{ result.exchange || '' }}</text>
</view>
</view>
</view>
@ -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 () => {