import { Connect } from "@cqsjjb/jjb-dva-runtime"; import { Button, Col, DatePicker, Form, Input, InputNumber, message, Row, Select, Space, Flex, } from "antd"; import AttachmentUpload from "~/components/AttachmentUpload"; import BaiduMapPicker from "~/components/BaiduMapPicker"; import dayjs from "dayjs"; import { useEffect, useState } from "react"; import PageLayout from "@cqsjjb/jjb-react-admin-component/PageLayout"; import { NATIONAL_COUNTIES } from "~/enumerate/constant"; import { ENTERPRISE_SCALE_OPTIONS, ENTERPRISE_STATUS_OPTIONS, REGISTERED_ORG_FILING_RECORD_STATUS_OPTIONS, REGISTERED_ORG_FILING_TYPE_SEARCH_OPTIONS, QUALIFICATION_INDUSTRY_OPTIONS, ECONOMY_INDUSTRY_OPTIONS, } from "~/enumerate/enterpriseOptions"; import { NS_ORG_INFO } from "~/enumerate/namespace"; import { coordinatePairRule, creditCodeRule, latitudeRule, longitudeRule, nonNegativeIntegerRule, normalizeUrl, phoneRule, positiveNumberRule, urlRule, } from "~/utils/validators"; function OrgInfoPage(props) { const [form] = Form.useForm(); const { orgInfoLoading } = props.orgInfo; const [editing, setEditing] = useState(true); const [submitting, setSubmitting] = useState(false); const [detail, setDetail] = useState({}); const [mapPickerVisible, setMapPickerVisible] = useState(false); /** 是否已存在机构数据(有 id 视为已入库,只能修改) */ const [hasExistingData, setHasExistingData] = useState(false); const loadDetail = async () => { try { const res = await props.orgInfoGet(); if (res?.data?.id) { setDetail(res.data); form.setFieldsValue({ ...res.data, productionDate: res.data.productionDate ? dayjs(res.data.productionDate) : undefined, attachmentUrls: res.data.attachmentUrls ? JSON.parse(res.data.attachmentUrls) : null, }); setHasExistingData(true); setEditing(false); } else { setDetail({}); setHasExistingData(false); setEditing(true); } } catch (err) { console.warn("[OrgInfo] loadDetail failed:", err); setDetail({}); setHasExistingData(false); setEditing(true); } }; useEffect(() => { loadDetail(); }, []); const handleCancelEdit = () => { setEditing(false); }; const handleSave = async (submitType) => { try { const formValues = await form.validateFields(); const values = { ...formValues, productionDate: formValues.productionDate ? dayjs(formValues.productionDate).format("YYYY-MM-DD") : undefined, attachmentUrls: formValues.attachmentUrls ? JSON.stringify(formValues.attachmentUrls) : null, infoDisclosureUrl: formValues.infoDisclosureUrl ? normalizeUrl(formValues.infoDisclosureUrl) : undefined, authStatusCode: submitType === "draft" ? 0 : 1, authStatusName: submitType === "draft" ? "草稿" : "已提交", }; setSubmitting(true); let request; if (hasExistingData) { request = props.orgInfoModify; values.id = detail.id; } else { request = submitType === "draft" ? props.orgInfoDraft : props.orgInfoSave; } const res = await request(values); if (res?.success !== false) { message.success( hasExistingData ? "修改成功" : submitType === "draft" ? "暂存成功" : "提交成功", ); setEditing(false); loadDetail(); } } finally { setSubmitting(false); } }; const handleMapConfirm = ({ lng, lat }) => { form.setFieldsValue({ longitude: lng, latitude: lat }); setMapPickerVisible(false); }; return ( 基础信息管理
新成立或首次使用系统的安全评价机构,可通过系统提供的引导页面,详细填写机构的基本信息。
} extra={ hasExistingData && !editing && ( ) } >
{ form.setFieldValue("districtName", option?.label || ""); }} /> typeof value === "string" ? value.trim() : value } > typeof value === "string" ? value.trim() : value } > typeof value === "string" ? value.trim() : value } > typeof value === "string" ? value.trim() : value } > typeof value === "string" ? value.trim() : value } > { form.setFieldValue( "enterpriseScaleName", option?.label || "", ); }} /> { form.setFieldValue( "filingRecordStatusName", option?.label || "", ); }} />
setMapPickerVisible(false)} onConfirm={handleMapConfirm} /> {editing && (
{!hasExistingData && ( )}
)}
); } export default Connect([NS_ORG_INFO], true)(OrgInfoPage);