|
|
@@ -30,7 +30,7 @@ const fetchData = async () => {
|
|
|
loading.value = true
|
|
|
try {
|
|
|
const res = await api.list()
|
|
|
- if (res?.code === 200) {
|
|
|
+ if (res?.code === 0 || res?.code === 200) {
|
|
|
tableData.value = res.data || []
|
|
|
}
|
|
|
} catch {
|
|
|
@@ -66,7 +66,7 @@ const handleSave = async () => {
|
|
|
description: categoryForm.description || undefined
|
|
|
}
|
|
|
const res = isEdit.value ? await api.edit3(data) : await api.add3(data)
|
|
|
- if (res?.code === 200) {
|
|
|
+ if (res?.code === 0 || res?.code === 200) {
|
|
|
ElMessage.success(isEdit.value ? '修改成功' : '新增成功')
|
|
|
dialogVisible.value = false
|
|
|
fetchData()
|
|
|
@@ -81,7 +81,7 @@ const handleDelete = (row: CategoryVo) => {
|
|
|
.then(async () => {
|
|
|
try {
|
|
|
const res = await api._delete({ id: row.id! })
|
|
|
- if (res?.code === 200) {
|
|
|
+ if (res?.code === 0 || res?.code === 200) {
|
|
|
ElMessage.success('删除成功')
|
|
|
fetchData()
|
|
|
}
|
|
|
@@ -91,6 +91,10 @@ const handleDelete = (row: CategoryVo) => {
|
|
|
.catch(() => {})
|
|
|
}
|
|
|
|
|
|
+const handleDialogClosed = () => {
|
|
|
+ formRef.value?.resetFields()
|
|
|
+}
|
|
|
+
|
|
|
onMounted(fetchData)
|
|
|
</script>
|
|
|
|
|
|
@@ -123,7 +127,7 @@ onMounted(fetchData)
|
|
|
</el-table>
|
|
|
</el-card>
|
|
|
|
|
|
- <el-dialog v-model="dialogVisible" :title="dialogTitle" width="480px" draggable>
|
|
|
+ <el-dialog v-model="dialogVisible" :title="dialogTitle" width="480px" draggable @closed="handleDialogClosed">
|
|
|
<el-form ref="formRef" :model="categoryForm" :rules="formRules" label-position="top">
|
|
|
<el-form-item label="分类名称" prop="categoryName">
|
|
|
<el-input v-model="categoryForm.categoryName" placeholder="请输入分类名称" />
|