fix: 添加分类名称唯一约束,防止重复名称

This commit is contained in:
2026-05-25 17:38:11 +08:00
parent 4b03e593bc
commit 2cb86d1b38
6 changed files with 249 additions and 47 deletions
+13 -8
View File
@@ -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) {