diff --git a/src/hooks/useIndustryOptions.js b/src/hooks/useIndustryOptions.js new file mode 100644 index 0000000..5f12cc6 --- /dev/null +++ b/src/hooks/useIndustryOptions.js @@ -0,0 +1,18 @@ +import { useMemo } from "react"; +import { QUALIFICATION_INDUSTRY_OPTIONS } from "~/enumerate/enterpriseOptions"; + +/** 根据机构 orgInfo.safetyIndustryCategoryCode 过滤行业选项 */ +const useIndustryOptions = () => { + return useMemo(() => { + const orgInfo = JSON.parse(sessionStorage.getItem("orgInfo") || "{}"); + const codes = orgInfo?.safetyIndustryCategoryCode; + if (Array.isArray(codes) && codes.length > 0) { + return QUALIFICATION_INDUSTRY_OPTIONS.filter((item) => + codes.includes(item.value), + ); + } + return QUALIFICATION_INDUSTRY_OPTIONS; + }, []); +}; + +export default useIndustryOptions; diff --git a/src/pages/Container/EnterpriseInfo/PersonnelInfo/List/index.js b/src/pages/Container/EnterpriseInfo/PersonnelInfo/List/index.js index 51e9b72..05e6ccf 100644 --- a/src/pages/Container/EnterpriseInfo/PersonnelInfo/List/index.js +++ b/src/pages/Container/EnterpriseInfo/PersonnelInfo/List/index.js @@ -42,10 +42,9 @@ import { CERT_LEVEL_OPTIONS_BY_TYPE, CAPABILITY_OPTIONS, PROFESSIONAL_MAJOR_OPTIONS, - CAPABILITY_MAP, CERT_LEVEL_LABEL_BY_TYPE } from "~/enumerate/constant"; -import { getBirthDateFromIdCard } from "~/utils"; +import { getBirthDateFromIdCard, renderCapabilityList } from "~/utils"; import { idCardRule, mobileRule } from "~/utils/validators"; import AttachmentUpload from "~/components/AttachmentUpload"; import StaffViewModal from "~/components/StaffViewModal"; @@ -323,12 +322,7 @@ function PersonnelInfoPage(props) { { title: "专业能力", dataIndex: "capabilityAssessment", - render: (list) => { - if (!Array.isArray(list) || !list.length) return "-"; - return list - .map((item) => CAPABILITY_MAP[item.professionalCapabilityCode]) - .join("、"); - }, + render: renderCapabilityList, }, { title: "证照名称", diff --git a/src/pages/Container/QualApplication/FilingForm/components/BasicInfoStep.jsx b/src/pages/Container/QualApplication/FilingForm/components/BasicInfoStep.jsx index c954c0d..100b1d0 100644 --- a/src/pages/Container/QualApplication/FilingForm/components/BasicInfoStep.jsx +++ b/src/pages/Container/QualApplication/FilingForm/components/BasicInfoStep.jsx @@ -1,23 +1,11 @@ -import { useMemo } from "react"; import { Form, Input, InputNumber, Row, Col, Select, Checkbox } from "antd"; -import { - CHONGQING_DISTRICTS, - QUALIFICATION_INDUSTRY_OPTIONS, -} from "~/enumerate/enterpriseOptions"; +import { CHONGQING_DISTRICTS } from "~/enumerate/enterpriseOptions"; +import useIndustryOptions from "~/hooks/useIndustryOptions"; import { FILING_UNIT_TYPE_OPTIONS } from "~/enumerate/qualFilingOptions"; import AttachmentUpload from "~/components/AttachmentUpload"; export default function BasicInfoStep({ form, disabled, mode }) { - const industryOptions = useMemo(() => { - const orgInfo = JSON.parse(sessionStorage.getItem("orgInfo") || "{}"); - const codes = orgInfo?.safetyIndustryCategoryCode; - if (Array.isArray(codes) && codes.length > 0) { - return QUALIFICATION_INDUSTRY_OPTIONS.filter((item) => - codes.includes(item.value), - ); - } - return QUALIFICATION_INDUSTRY_OPTIONS; - }, []); + const industryOptions = useIndustryOptions(); return (