|
|
|
@ -103,6 +103,13 @@ |
|
|
|
</view> |
|
|
|
<view class="toolbar-right"> |
|
|
|
<button |
|
|
|
class="delete-btn" |
|
|
|
:disabled="selectedStockIds.length === 0" |
|
|
|
@click="deleteSelectedStocks" |
|
|
|
> |
|
|
|
删除 |
|
|
|
</button> |
|
|
|
<button |
|
|
|
class="add-to-group-btn" |
|
|
|
:disabled="selectedStockIds.length === 0" |
|
|
|
@click="showGroupSelectModal = true" |
|
|
|
@ -143,7 +150,7 @@ |
|
|
|
</template> |
|
|
|
|
|
|
|
<script> |
|
|
|
import { getUserStockGroupList, addUserStockGroup, getUserStockList, updateUserStockGroup } from '@/api/home/mySelections.js' |
|
|
|
import { getUserStockGroupList, addUserStockGroup, getUserStockList, updateUserStockGroup, deleteUserStock } from '@/api/home/mySelections.js' |
|
|
|
|
|
|
|
export default { |
|
|
|
data() { |
|
|
|
@ -484,7 +491,7 @@ |
|
|
|
this.selectedStockIds = [] |
|
|
|
|
|
|
|
// 重新加载当前分组的股票列表 |
|
|
|
this.loadStockList() |
|
|
|
this.loadStocksByGroup(this.currentGroupId) |
|
|
|
|
|
|
|
} catch (error) { |
|
|
|
console.error('移动股票失败:', error) |
|
|
|
@ -495,6 +502,69 @@ |
|
|
|
} finally { |
|
|
|
uni.hideLoading() |
|
|
|
} |
|
|
|
}, |
|
|
|
|
|
|
|
// 删除选中的股票 |
|
|
|
async deleteSelectedStocks() { |
|
|
|
// 检查是否有选中的股票 |
|
|
|
if (this.selectedStockIds.length === 0) { |
|
|
|
uni.showToast({ |
|
|
|
title: '请先选择要删除的股票', |
|
|
|
icon: 'none' |
|
|
|
}) |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
// 显示确认删除弹窗 |
|
|
|
uni.showModal({ |
|
|
|
title: '确认删除', |
|
|
|
content: `确定要删除选中的 ${this.selectedStockIds.length} 只股票吗?`, |
|
|
|
success: async (res) => { |
|
|
|
if (res.confirm) { |
|
|
|
await this.performDeleteStocks() |
|
|
|
} |
|
|
|
} |
|
|
|
}) |
|
|
|
}, |
|
|
|
|
|
|
|
// 执行删除股票操作 |
|
|
|
async performDeleteStocks() { |
|
|
|
try { |
|
|
|
uni.showLoading({ |
|
|
|
title: '删除中...' |
|
|
|
}) |
|
|
|
|
|
|
|
// 调用API删除每只选中的股票 |
|
|
|
const deletePromises = this.selectedStockIds.map(stockId => { |
|
|
|
return deleteUserStock(null, null, { |
|
|
|
groupId: this.currentGroupId, |
|
|
|
id: stockId |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
await Promise.all(deletePromises) |
|
|
|
|
|
|
|
uni.showToast({ |
|
|
|
title: '删除成功', |
|
|
|
icon: 'success' |
|
|
|
}) |
|
|
|
|
|
|
|
// 退出多选模式 |
|
|
|
this.isMultiSelectMode = false |
|
|
|
this.selectedStockIds = [] |
|
|
|
|
|
|
|
// 重新加载当前分组的股票列表 |
|
|
|
this.loadStocksByGroup(this.currentGroupId) |
|
|
|
|
|
|
|
} catch (error) { |
|
|
|
console.error('删除股票失败:', error) |
|
|
|
uni.showToast({ |
|
|
|
title: '删除失败,请重试', |
|
|
|
icon: 'none' |
|
|
|
}) |
|
|
|
} finally { |
|
|
|
uni.hideLoading() |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
@ -782,6 +852,21 @@ |
|
|
|
.toolbar-right { |
|
|
|
display: flex; |
|
|
|
align-items: center; |
|
|
|
gap: 12px; |
|
|
|
} |
|
|
|
|
|
|
|
.delete-btn { |
|
|
|
background-color: #ff6b6b; |
|
|
|
color: #fff; |
|
|
|
border: none; |
|
|
|
border-radius: 6px; |
|
|
|
padding: 8px 16px; |
|
|
|
font-size: 14px; |
|
|
|
} |
|
|
|
|
|
|
|
.delete-btn:disabled { |
|
|
|
background-color: #ccc; |
|
|
|
color: #999; |
|
|
|
} |
|
|
|
|
|
|
|
.add-to-group-btn { |
|
|
|
|