fix: 添加分类名称唯一约束,防止重复名称
This commit is contained in:
@@ -89,15 +89,20 @@ function editCat(row: any) {
|
||||
}
|
||||
|
||||
async function saveCat() {
|
||||
if (editing.value) {
|
||||
await adminApi.updateCategory(editing.value.id, form)
|
||||
} else {
|
||||
await adminApi.createCategory(form)
|
||||
try {
|
||||
if (editing.value) {
|
||||
await adminApi.updateCategory(editing.value.id, form)
|
||||
} else {
|
||||
await adminApi.createCategory(form)
|
||||
}
|
||||
ElMessage.success('保存成功')
|
||||
showAdd.value = false
|
||||
editing.value = null
|
||||
await fetchCategories()
|
||||
} catch (error: any) {
|
||||
const msg = error.response?.data?.error || '保存失败'
|
||||
ElMessage.error(msg)
|
||||
}
|
||||
ElMessage.success('保存成功')
|
||||
showAdd.value = false
|
||||
editing.value = null
|
||||
await fetchCategories()
|
||||
}
|
||||
|
||||
async function deleteCat(id: number) {
|
||||
|
||||
Reference in New Issue
Block a user