import { BaseEventOrig, InputProps } from '@tarojs/components'; import { forwardRef, useCallback, useImperativeHandle, useState } from 'react'; import BlFormInput from '@/components/bl-form-input'; import BlFormItem from '@/components/bl-form-item'; import BlFormSelect from '@/components/bl-form-select'; import { EDUCATION_TYPE_OPTIONS, EducationType } from '@/constants/material'; import { MaterialProfile } from '@/types/material'; import { logWithPrefix, string2Number } from '@/utils/common'; import './index.less'; interface IProps { profile: Partial; } const PREFIX = 'fragment-profile-others'; const log = logWithPrefix(PREFIX); function ProfileOthersFragment(props: IProps, ref) { const { profile } = props; const [educationType, setEducationType] = useState(profile.educationType || ''); const [height, setHeight] = useState(profile.height || ''); const [weight, setWeight] = useState(profile.weight || ''); const [shoeSize, setShoeSize] = useState(profile.shoeSize || ''); const handleInputHeight = useCallback((e: BaseEventOrig) => { const value = e.detail.value || ''; if (Number.isNaN(Number(value))) { return; } setHeight(string2Number(value)); }, []); const handleInputWeight = useCallback((e: BaseEventOrig) => { const value = e.detail.value || ''; if (Number.isNaN(Number(value))) { return; } setWeight(string2Number(value)); }, []); const handleInputShoeSize = useCallback((e: BaseEventOrig) => { const value = e.detail.value || ''; if (Number.isNaN(Number(value))) { return; } setShoeSize(string2Number(value)); }, []); const handleSelectEducationType = useCallback((type: EducationType) => { setEducationType(type); }, []); useImperativeHandle( ref, () => ({ getData: () => ({ height, weight, shoeSize, educationType }), }), [height, weight, shoeSize, educationType] ); return (
服饰等穿版品类必填,其他品类选填
); } export default forwardRef(ProfileOthersFragment);