1. 实现前端删除饲喂计划
2. 修复后端delete接口bug
This commit is contained in:
@@ -130,12 +130,13 @@ export default {
|
||||
}
|
||||
|
||||
try {
|
||||
const response = await fetch(`/api/v1/feed/plan/delete/${planId}`, {
|
||||
method: 'DELETE',
|
||||
const response = await fetch('/api/v1/feed/plan/delete', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'Authorization': 'Bearer ' + localStorage.getItem('authToken')
|
||||
}
|
||||
},
|
||||
body: JSON.stringify({ id: planId })
|
||||
})
|
||||
|
||||
const data = await response.json()
|
||||
@@ -143,13 +144,13 @@ export default {
|
||||
if (response.ok && data.code === 0) {
|
||||
// 删除成功,重新加载列表
|
||||
await this.loadPlans()
|
||||
alert('删除成功')
|
||||
this.$message?.success('删除成功') || alert('删除成功')
|
||||
} else {
|
||||
alert('删除失败: ' + data.message)
|
||||
this.$message?.error('删除失败: ' + data.message) || alert('删除失败: ' + data.message)
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('删除饲喂计划失败:', error)
|
||||
alert('删除饲喂计划失败: ' + error.message)
|
||||
this.$message?.error('删除饲喂计划失败: ' + error.message) || alert('删除饲喂计划失败: ' + error.message)
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user