dev-tmp1
tangjie 2026-08-13 12:54:26 +08:00
parent c55b856c34
commit c6b4244831
1 changed files with 15 additions and 15 deletions

View File

@ -68,7 +68,7 @@ const INITIAL_FORM = {
archiveRoomArea: "", archiveRoomArea: "",
fulltimeEvaluatorCount: "", fulltimeEvaluatorCount: "",
registeredEngineerCount: "", registeredEngineerCount: "",
applyBusinessScope: [], // 多选,提交时 join(",") safetyIndustryCategoryCode: [], // 多选,提交时传数组
orgIntro: "", orgIntro: "",
id: undefined, id: undefined,
}; };
@ -201,11 +201,11 @@ const validate = (formData, registerUserId) => {
else if (Number(formData.registeredEngineerCount) > MAX_INT32) else if (Number(formData.registeredEngineerCount) > MAX_INT32)
errors.registeredEngineerCount = "数值过大"; // int 上限 errors.registeredEngineerCount = "数值过大"; // int 上限
// 2026-08-08 校验前先清洗为 code兼容历史中文 label 混存),避免以 label 长度误判 // 2026-08-08 校验前先清洗为 code兼容历史中文 label 混存),避免以 label 长度误判
const normalizedScope = normalizeBusinessScope(formData.applyBusinessScope); const normalizedScope = normalizeBusinessScope(formData.safetyIndustryCategoryCode);
if (normalizedScope.length === 0) { if (normalizedScope.length === 0) {
errors.applyBusinessScope = "请至少选择一项业务范围"; errors.safetyIndustryCategoryCode = "请至少选择一项业务范围";
} else if (normalizedScope.join(",").length > 500) } else if (normalizedScope.join(",").length > 500)
errors.applyBusinessScope = "业务范围总字数不能超过500字"; // varchar(500) errors.safetyIndustryCategoryCode = "业务范围总字数不能超过500字"; // varchar(500)
if (required("orgIntro", "请输入单位基本情况介绍")) { if (required("orgIntro", "请输入单位基本情况介绍")) {
} else if (formData.orgIntro.length > 2000) } else if (formData.orgIntro.length > 2000)
errors.orgIntro = "单位基本情况介绍不能超过2000字"; errors.orgIntro = "单位基本情况介绍不能超过2000字";
@ -246,7 +246,7 @@ const RegisterMore = (props) => {
data: resolvedAccount, data: resolvedAccount,
}); });
if (res?.data) { if (res?.data) {
// 2026-08-08 回显:applyBusinessScope 拆为数组attachmentUrls JSON.parse // 2026-08-08 回显:safetyIndustryCategoryCode 拆为数组attachmentUrls JSON.parse
// 同时把后端主键 id 写回 formData供"缓存/提交"更新时精确匹配记录(规避二次映射)。 // 同时把后端主键 id 写回 formData供"缓存/提交"更新时精确匹配记录(规避二次映射)。
setFormData({ setFormData({
...INITIAL_FORM, ...INITIAL_FORM,
@ -255,9 +255,9 @@ const RegisterMore = (props) => {
// 用 Number() 转换会丢失末位精度(如 ...87938 → ...88000),故保持字符串,由后端 Long 反序列化解析。 // 用 Number() 转换会丢失末位精度(如 ...87938 → ...88000),故保持字符串,由后端 Long 反序列化解析。
id: res.data.id != null ? String(res.data.id) : undefined, // 写回主键,使保存走更新分支更精确(后端仍按 registerUserId 兜底) id: res.data.id != null ? String(res.data.id) : undefined, // 写回主键,使保存走更新分支更精确(后端仍按 registerUserId 兜底)
// 2026-08-08 回显时清洗历史中文 label 为 code保证 formData 中只存枚举值 // 2026-08-08 回显时清洗历史中文 label 为 code保证 formData 中只存枚举值
applyBusinessScope: normalizeBusinessScope( safetyIndustryCategoryCode: normalizeBusinessScope(
res.data.applyBusinessScope res.data.safetyIndustryCategoryCode
? String(res.data.applyBusinessScope).split(",").filter(Boolean) ? String(res.data.safetyIndustryCategoryCode).split(",").filter(Boolean)
: [], : [],
), ),
attachmentUrls: res.data.attachmentUrls attachmentUrls: res.data.attachmentUrls
@ -338,12 +338,12 @@ const RegisterMore = (props) => {
const toggleScope = (val) => { const toggleScope = (val) => {
setFormData((prev) => { setFormData((prev) => {
const set = new Set(prev.applyBusinessScope); const set = new Set(prev.safetyIndustryCategoryCode);
if (set.has(val)) set.delete(val); if (set.has(val)) set.delete(val);
else set.add(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)区分流转: // 2026-08-08 暂存(draft)与提交(submit)区分流转:
@ -382,8 +382,8 @@ const RegisterMore = (props) => {
registerUserId: String(resolvedRegisterUserId), registerUserId: String(resolvedRegisterUserId),
contactName, contactName,
contactPhone, contactPhone,
// 2026-08-08 提交前清洗历史中文 label 为 code确保只传枚举值拼接,不传 label // 2026-08-08 提交前清洗历史中文 label 为 code以数组形式提交
applyBusinessScope: normalizeBusinessScope(formData.applyBusinessScope).join(","), safetyIndustryCategoryCode: normalizeBusinessScope(formData.safetyIndustryCategoryCode),
attachmentUrls: formData.attachmentUrls.length attachmentUrls: formData.attachmentUrls.length
? JSON.stringify(formData.attachmentUrls) ? JSON.stringify(formData.attachmentUrls)
: null, : null,
@ -780,14 +780,14 @@ const RegisterMore = (props) => {
required required
wide wide
alignStart alignStart
error={errors.applyBusinessScope} error={errors.safetyIndustryCategoryCode}
> >
<div className="register-more-scope"> <div className="register-more-scope">
{BUSINESS_SCOPE_OPTIONS.map((opt) => ( {BUSINESS_SCOPE_OPTIONS.map((opt) => (
<label key={opt.value}> <label key={opt.value}>
<input <input
type="checkbox" type="checkbox"
checked={formData.applyBusinessScope.includes(opt.value)} checked={formData.safetyIndustryCategoryCode.includes(opt.value)}
disabled={!hasRegisterContext} disabled={!hasRegisterContext}
onChange={() => toggleScope(opt.value)} onChange={() => toggleScope(opt.value)}
/> />