| | |
| | | import { onMounted, reactive, ref } from "vue"; |
| | | import { ElMessage, ElMessageBox } from "element-plus"; |
| | | import http from "../api/http"; |
| | | import { normalizeFormData } from "../utils/formHelper"; |
| | | |
| | | type Row = { |
| | | id: number; |
| | |
| | | } |
| | | saving.value = true; |
| | | try { |
| | | const payload = { |
| | | reasonName, |
| | | // 处理表单数据:字符串 null/undefined 转为空字符串 |
| | | const normalized = normalizeFormData({ |
| | | reasonName: form.reasonName, |
| | | sortOrder: Number(form.sortOrder) || 0, |
| | | }; |
| | | }); |
| | | |
| | | if (editingId.value == null) { |
| | | await http.post("/config/visit-reasons/manage", payload); |
| | | await http.post("/config/visit-reasons/manage", normalized); |
| | | ElMessage.success("已新增"); |
| | | page.value = 1; |
| | | } else { |
| | | await http.put(`/config/visit-reasons/manage/${editingId.value}`, { |
| | | ...payload, |
| | | uuid: form.uuid, |
| | | ...normalized, |
| | | }); |
| | | ElMessage.success("已保存"); |
| | | } |