Browse Source

删除自选股后刷新分组下的自选股;

dongqian/feature-20251022181325-deepmate简版
宋杰 3 weeks ago
parent
commit
bd950323de
  1. 89
      pages/customStockList/customStockList.vue

89
pages/customStockList/customStockList.vue

@ -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 {

Loading…
Cancel
Save