import { intl } from '@/utils/intl'; import { useEffect, useState } from 'react'; import { Space, Input, Select } from 'antd'; import { getLocale } from 'umi'; import EnStyles from './indexEn.less'; import ZhStyles from './indexZh.less'; const locale = getLocale(); const styles = locale === 'zh-CN' ? ZhStyles : EnStyles; interface Props { value?: API.ParameterValue; onChange?: (value?: API.ParameterValue) => void; onBlur?: () => void; } const optionConfig = [ { label: intl.formatMessage({ id: 'OBD.pages.components.Parameter.AutomaticAllocation', defaultMessage: '自动分配', }), value: true, }, { label: intl.formatMessage({ id: 'OBD.pages.components.Parameter.Custom', defaultMessage: '自定义', }), value: false, }, ]; export default function Parameter({ value: itemValue, onChange, onBlur, }: Props) { const [parameterValue, setParameterValue] = useState(itemValue); useEffect(() => { if (onChange) { if ( itemValue?.adaptive !== parameterValue?.adaptive || itemValue?.value !== parameterValue?.value ) { onChange(parameterValue); } } }, [parameterValue]); return ( setParameterValue({ ...parameterValue, value: e.target.value }) } /> ); }