Merge remote-tracking branch 'origin/dev-tmp1' into dev-tmp1
commit
349ec7b3cc
|
|
@ -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}
|
||||
>
|
||||
<div className="register-more-scope">
|
||||
{BUSINESS_SCOPE_OPTIONS.map((opt) => (
|
||||
<label key={opt.value}>
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={formData.applyBusinessScope.includes(opt.value)}
|
||||
checked={formData.safetyIndustryCategoryCode.includes(opt.value)}
|
||||
disabled={!hasRegisterContext}
|
||||
onChange={() => toggleScope(opt.value)}
|
||||
/>
|
||||
|
|
|
|||
Loading…
Reference in New Issue