diff --git a/src/enumerate/enterpriseOptions.js b/src/enumerate/enterpriseOptions.js index f0a2d37..e67df41 100644 --- a/src/enumerate/enterpriseOptions.js +++ b/src/enumerate/enterpriseOptions.js @@ -49,6 +49,11 @@ export const ENTERPRISE_STATUS_OPTIONS = [ { label: "注销", value: 3 }, ]; +export const ENTERPRISE_STATUS_OPTIONS_MAP = ENTERPRISE_STATUS_OPTIONS.reduce( + (acc, cur) => ({ ...acc, [cur.value]: cur.label }), + {}, +); + /** 企业规模 */ export const ENTERPRISE_SCALE_OPTIONS = [ { label: "大", value: "大" }, diff --git a/src/pages/Container/Supervision/BasicInfo/OrgAccount/index.js b/src/pages/Container/Supervision/BasicInfo/OrgAccount/index.js index c6f6855..2666fa2 100644 --- a/src/pages/Container/Supervision/BasicInfo/OrgAccount/index.js +++ b/src/pages/Container/Supervision/BasicInfo/OrgAccount/index.js @@ -22,18 +22,37 @@ import PageLayout from "@cqsjjb/jjb-react-admin-component/PageLayout"; import SearchForm from "~/components/SearchForm"; import ControlWrapper from "@cqsjjb/jjb-react-admin-component/ControlWrapper"; import { AntdTableFuncControl } from "@cqsjjb/jjb-common-decorator/antd"; +import { QUALIFICATION_INDUSTRY_OPTIONS } from "~/enumerate/enterpriseOptions"; import { isOrgAccountEnabled } from "~/utils/enterpriseInfo/adapter"; import { CHONGQING_DISTRICTS, ENTERPRISE_SCALE_OPTIONS, ORG_ACCOUNT_STATE_OPTIONS, ENTERPRISE_STATUS_OPTIONS, + ENTERPRISE_STATUS_OPTIONS_MAP, } from "~/enumerate/enterpriseOptions"; import { NS_ORG_INFO } from "~/enumerate/namespace"; import { safeListRequest, safeRequest } from "~/utils"; const { router } = tools; +const CONTACT_SEP = "/"; +const mergeContactNamePhone = (name, phone) => { + if (!name && !phone) return undefined; + return [name, phone].filter(Boolean).join(CONTACT_SEP); +}; +const splitContactNamePhone = (value) => { + if (!value) return { contactName: undefined, contactPhone: undefined }; + const idx = String(value).indexOf(CONTACT_SEP); + if (idx >= 0) { + return { + contactName: String(value).slice(0, idx).trim(), + contactPhone: String(value).slice(idx + 1).trim(), + }; + } + return { contactName: String(value).trim(), contactPhone: undefined }; +}; + function OrgAccountPage(props) { const [searchForm] = Form.useForm(); const [editForm] = Form.useForm(); @@ -47,8 +66,6 @@ function OrgAccountPage(props) { const [total, setTotal] = useState(0); const [loading, setLoading] = useState(false); - - const getData = async () => { setLoading(true); try { @@ -105,7 +122,13 @@ function OrgAccountPage(props) { setEditOpen(true); const res = await loadDetail(id); if (res?.data) { - editForm.setFieldsValue(res.data); + editForm.setFieldsValue({ + ...res.data, + contactNamePhone: mergeContactNamePhone( + res.data.contactName, + res.data.contactPhone, + ), + }); } }; @@ -188,12 +211,17 @@ function OrgAccountPage(props) { }; const onEditSubmit = async () => { - const values = await editForm.validateFields(); - setEditLoading(true); - const res = await props.orgAccountModify({ - ...values, + const formValues = await editForm.validateFields(); + const split = splitContactNamePhone(formValues.contactNamePhone); + const values = { + ...formValues, + contactName: split.contactName, + contactPhone: split.contactPhone, + contactNamePhone: undefined, id: currentId, - }); + }; + setEditLoading(true); + const res = await props.orgAccountModify(values); setEditLoading(false); if (res?.success !== false) { message.success("保存成功"); @@ -326,7 +354,7 @@ function OrgAccountPage(props) { current: 1, pageSize: 10, }; - getData() + getData(); }} /> {detail.districtName} - + {detail.safetyIndustryCategoryName} {detail.businessAddress} - {detail.enterpriseStatusName} + {ENTERPRISE_STATUS_OPTIONS_MAP[detail.enterpriseStatusCode]} - - {detail.longitude}, {detail.latitude} - - - {detail.principalName} - - - {detail.principalPhone} + + + {mergeContactNamePhone(detail.contactName, detail.contactPhone) || "-"} {detail.legalRepresentative} @@ -448,56 +471,119 @@ function OrgAccountPage(props) { - - + + + - + + + + + + - - - - - - - - - - - - - - - - - - - - + { + const { contactName, contactPhone } = + splitContactNamePhone(value); + if (!contactName) { + return Promise.reject(new Error("联系人不能为空")); + } + if (contactName.length > 50) { + return Promise.reject(new Error("联系人不能超过50字")); + } + if (!contactPhone) { + return Promise.reject( + new Error("请使用/分隔联系人和电话,并填写电话"), + ); + } + if ( + !/^(1[3-9]\d{9}|\d{10,12})$/.test( + String(contactPhone).replace(/\s+/g, ""), + ) + ) { + return Promise.reject( + new Error("电话格式不正确(手机11位或固话区号+号码)"), + ); + } + if (contactPhone.length > 20) { + return Promise.reject(new Error("电话不能超过20字")); + } + return Promise.resolve(); + }, + }, + ]} + extra="请使用/分隔联系人和电话,如:张三/13800138000" + > + - + - - + +