From c6b4244831bc1d05599c430fd58b8ba281c8b176 Mon Sep 17 00:00:00 2001 From: tangjie <122778500@qq.com> Date: Thu, 13 Aug 2026 12:54:26 +0800 Subject: [PATCH] fix --- src/pages/Container/RegisterMore/index.js | 30 +++++++++++------------ 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/pages/Container/RegisterMore/index.js b/src/pages/Container/RegisterMore/index.js index c5eb9ac..ca7b34d 100644 --- a/src/pages/Container/RegisterMore/index.js +++ b/src/pages/Container/RegisterMore/index.js @@ -68,7 +68,7 @@ const INITIAL_FORM = { archiveRoomArea: "", fulltimeEvaluatorCount: "", registeredEngineerCount: "", - applyBusinessScope: [], // 多选,提交时 join(",") + safetyIndustryCategoryCode: [], // 多选,提交时传数组 orgIntro: "", id: undefined, }; @@ -201,11 +201,11 @@ const validate = (formData, registerUserId) => { else if (Number(formData.registeredEngineerCount) > MAX_INT32) errors.registeredEngineerCount = "数值过大"; // int 上限 // 2026-08-08 校验前先清洗为 code(兼容历史中文 label 混存),避免以 label 长度误判 - const normalizedScope = normalizeBusinessScope(formData.applyBusinessScope); + const normalizedScope = normalizeBusinessScope(formData.safetyIndustryCategoryCode); if (normalizedScope.length === 0) { - errors.applyBusinessScope = "请至少选择一项业务范围"; + errors.safetyIndustryCategoryCode = "请至少选择一项业务范围"; } else if (normalizedScope.join(",").length > 500) - errors.applyBusinessScope = "业务范围总字数不能超过500字"; // varchar(500) + errors.safetyIndustryCategoryCode = "业务范围总字数不能超过500字"; // varchar(500) if (required("orgIntro", "请输入单位基本情况介绍")) { } else if (formData.orgIntro.length > 2000) errors.orgIntro = "单位基本情况介绍不能超过2000字"; @@ -246,7 +246,7 @@ const RegisterMore = (props) => { data: resolvedAccount, }); if (res?.data) { - // 2026-08-08 回显:applyBusinessScope 拆为数组,attachmentUrls JSON.parse + // 2026-08-08 回显:safetyIndustryCategoryCode 拆为数组,attachmentUrls JSON.parse // 同时把后端主键 id 写回 formData,供"缓存/提交"更新时精确匹配记录(规避二次映射)。 setFormData({ ...INITIAL_FORM, @@ -255,9 +255,9 @@ const RegisterMore = (props) => { // 用 Number() 转换会丢失末位精度(如 ...87938 → ...88000),故保持字符串,由后端 Long 反序列化解析。 id: res.data.id != null ? String(res.data.id) : undefined, // 写回主键,使保存走更新分支更精确(后端仍按 registerUserId 兜底) // 2026-08-08 回显时清洗历史中文 label 为 code,保证 formData 中只存枚举值 - applyBusinessScope: normalizeBusinessScope( - res.data.applyBusinessScope - ? String(res.data.applyBusinessScope).split(",").filter(Boolean) + safetyIndustryCategoryCode: normalizeBusinessScope( + res.data.safetyIndustryCategoryCode + ? String(res.data.safetyIndustryCategoryCode).split(",").filter(Boolean) : [], ), attachmentUrls: res.data.attachmentUrls @@ -338,12 +338,12 @@ const RegisterMore = (props) => { const toggleScope = (val) => { setFormData((prev) => { - const set = new Set(prev.applyBusinessScope); + const set = new Set(prev.safetyIndustryCategoryCode); if (set.has(val)) set.delete(val); else set.add(val); - return { ...prev, applyBusinessScope: Array.from(set) }; + return { ...prev, safetyIndustryCategoryCode: Array.from(set) }; }); - setErrors((prev) => ({ ...prev, applyBusinessScope: undefined })); + setErrors((prev) => ({ ...prev, safetyIndustryCategoryCode: undefined })); }; // 2026-08-08 暂存(draft)与提交(submit)区分流转: @@ -382,8 +382,8 @@ const RegisterMore = (props) => { registerUserId: String(resolvedRegisterUserId), contactName, contactPhone, - // 2026-08-08 提交前清洗历史中文 label 为 code,确保只传枚举值拼接,不传 label - applyBusinessScope: normalizeBusinessScope(formData.applyBusinessScope).join(","), + // 2026-08-08 提交前清洗历史中文 label 为 code,以数组形式提交 + safetyIndustryCategoryCode: normalizeBusinessScope(formData.safetyIndustryCategoryCode), attachmentUrls: formData.attachmentUrls.length ? JSON.stringify(formData.attachmentUrls) : null, @@ -780,14 +780,14 @@ const RegisterMore = (props) => { required wide alignStart - error={errors.applyBusinessScope} + error={errors.safetyIndustryCategoryCode} >
{BUSINESS_SCOPE_OPTIONS.map((opt) => (