mirror of
https://github.com/woodchen-ink/aimodels-prices.git
synced 2025-07-18 13:41:59 +08:00
新增批量删除价格功能
- 在 Prices.vue 中添加批量删除按钮,允许管理员选择多个价格记录进行删除。 - 实现批量删除逻辑,包含用户确认提示和删除成功/失败的反馈。 - 优化用户体验,确保在删除前提示用户操作不可恢复。
This commit is contained in:
parent
5384e515ac
commit
ca3d4a73ee
@ -10,6 +10,7 @@
|
|||||||
<template v-if="isAdmin && selectedPrices.length > 0">
|
<template v-if="isAdmin && selectedPrices.length > 0">
|
||||||
<el-button type="success" @click="batchUpdateStatus('approved')">批量通过</el-button>
|
<el-button type="success" @click="batchUpdateStatus('approved')">批量通过</el-button>
|
||||||
<el-button type="danger" @click="batchUpdateStatus('rejected')">批量拒绝</el-button>
|
<el-button type="danger" @click="batchUpdateStatus('rejected')">批量拒绝</el-button>
|
||||||
|
<el-button type="danger" @click="batchDelete">批量删除</el-button>
|
||||||
<el-divider direction="vertical" />
|
<el-divider direction="vertical" />
|
||||||
</template>
|
</template>
|
||||||
<template v-if="isAdmin">
|
<template v-if="isAdmin">
|
||||||
@ -1006,6 +1007,39 @@ const batchUpdateStatus = async (status) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 批量删除价格记录
|
||||||
|
const batchDelete = async () => {
|
||||||
|
if (!selectedPrices.value.length) {
|
||||||
|
ElMessage.warning('请先选择要删除的价格')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
// 确认操作
|
||||||
|
await ElMessageBox.confirm(
|
||||||
|
`确定要删除选中的 ${selectedPrices.value.length} 条价格吗?此操作不可恢复!`,
|
||||||
|
'警告',
|
||||||
|
{
|
||||||
|
confirmButtonText: '确定',
|
||||||
|
cancelButtonText: '取消',
|
||||||
|
type: 'warning'
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
// 批量删除
|
||||||
|
for (const price of selectedPrices.value) {
|
||||||
|
await axios.delete(`/api/prices/${price.id}`)
|
||||||
|
}
|
||||||
|
|
||||||
|
await loadPrices()
|
||||||
|
ElMessage.success('批量删除成功')
|
||||||
|
} catch (error) {
|
||||||
|
if (error === 'cancel') return
|
||||||
|
console.error('Failed to batch delete prices:', error)
|
||||||
|
ElMessage.error('批量删除失败')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 处理分页变化
|
// 处理分页变化
|
||||||
const handleSizeChange = (val) => {
|
const handleSizeChange = (val) => {
|
||||||
pageSize.value = val
|
pageSize.value = val
|
||||||
|
Loading…
x
Reference in New Issue
Block a user