longz
2026-06-29 9d4cbff7464ebfd7803c2ce53ded49d0f73fe011
frontend-admin/src/views/VisitReasonsSettingsView.vue
@@ -88,6 +88,7 @@
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;
@@ -182,18 +183,20 @@
  }
  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("已保存");
    }