fix(notice): 修复通知发布表单提交逻辑

- 修复了分子公司选择为空时的返回逻辑
- 移除了调试用的 console.log 语句
- 调整了防止重复提交的逻辑位置
- 修正了表单验证失败后的处理流程
- 修复了条件判断语句的格式问题
- 清理了文件末尾的多余空行
master
wangyan 2026-02-28 18:12:02 +08:00
parent 2d89f175f5
commit 6207d77479
1 changed files with 9 additions and 8 deletions

View File

@ -29,7 +29,8 @@ function Add(props) {
// 监听分子公司选择变化,处理"全部"选项逻辑 // 监听分子公司选择变化,处理"全部"选项逻辑
const publishCorpinfoIdsValue = Form.useWatch("publishCorpinfoIds", form); const publishCorpinfoIdsValue = Form.useWatch("publishCorpinfoIds", form);
useEffect(() => { useEffect(() => {
if (!publishCorpinfoIdsValue || publishCorpinfoIdsValue.length === 0) return; if (!publishCorpinfoIdsValue || publishCorpinfoIdsValue.length === 0)
return;
const hasAll = publishCorpinfoIdsValue.includes("ALL"); const hasAll = publishCorpinfoIdsValue.includes("ALL");
const hasOther = publishCorpinfoIdsValue.some(id => id !== "ALL"); const hasOther = publishCorpinfoIdsValue.some(id => id !== "ALL");
@ -60,7 +61,6 @@ function Add(props) {
}, []); }, []);
useEffect(() => { useEffect(() => {
console.log(props);
props["corpInfoListAll"]({ inType: "0,1,6", eqUseFlag: 1 }).then((res) => { props["corpInfoListAll"]({ inType: "0,1,6", eqUseFlag: 1 }).then((res) => {
if (res.data) { if (res.data) {
console.log(res.data); console.log(res.data);
@ -77,13 +77,12 @@ function Add(props) {
const onSubmit = async () => { const onSubmit = async () => {
// 防止重复提交 // 防止重复提交
if (submitting) return;
setSubmitting(true); setSubmitting(true);
try { try {
await form.validateFields(); // 触发表单校验 await form.validateFields(); // 触发表单校验
} catch { }
setSubmitting(false); catch {
return; // 阻止后续逻辑 return; // 阻止后续逻辑
} }
const values = await form.validateFields(); const values = await form.validateFields();
@ -100,7 +99,8 @@ function Add(props) {
.filter(item => item.bianma !== "ALL") .filter(item => item.bianma !== "ALL")
.map(item => item.bianma); .map(item => item.bianma);
values.publishCorpinfoIds = allIds.join(","); values.publishCorpinfoIds = allIds.join(",");
} else { }
else {
values.publishCorpinfoIds = values.publishCorpinfoIds.join(","); values.publishCorpinfoIds = values.publishCorpinfoIds.join(",");
} }
} }
@ -115,7 +115,8 @@ function Add(props) {
}).finally(() => { }).finally(() => {
setSubmitting(false); setSubmitting(false);
}); });
} else { }
else {
props["noticeAdd"](values).then((res) => { props["noticeAdd"](values).then((res) => {
if (res.success) { if (res.success) {
message.success("新增成功!"); message.success("新增成功!");
@ -205,4 +206,4 @@ function Add(props) {
); );
} }
export default Connect([NS_NOTICE, NS_CORPINFO], true)(Add); export default Connect([NS_NOTICE, NS_CORPINFO], true)(Add);