|
@@ -7,10 +7,10 @@ import {
|
|
Select,
|
|
Select,
|
|
Radio,
|
|
Radio,
|
|
FormInstance,
|
|
FormInstance,
|
|
- Space,
|
|
|
|
} from 'antd';
|
|
} from 'antd';
|
|
import { useIntl, FormattedMessage } from 'react-intl';
|
|
import { useIntl, FormattedMessage } from 'react-intl';
|
|
import { registerFormFields } from '@/validation/patient/registerSchema';
|
|
import { registerFormFields } from '@/validation/patient/registerSchema';
|
|
|
|
+import NumberWithUnit from '@/components/NumberWithUnit';
|
|
|
|
|
|
const genderOptions = [
|
|
const genderOptions = [
|
|
{
|
|
{
|
|
@@ -68,6 +68,11 @@ interface BasicInfoFormProps {
|
|
form?: FormInstance;
|
|
form?: FormInstance;
|
|
}
|
|
}
|
|
const BasicInfoForm: React.FC<BasicInfoFormProps> = ({ style, form }) => {
|
|
const BasicInfoForm: React.FC<BasicInfoFormProps> = ({ style, form }) => {
|
|
|
|
+ const patient_age = Form.useWatch('patient_age', form);
|
|
|
|
+ React.useEffect(() => {
|
|
|
|
+ console.log('patient_age 变化了:', patient_age); // 每次 NumberWithUnit onChange 都会触发
|
|
|
|
+ }, [patient_age]);
|
|
|
|
+
|
|
const intl = useIntl();
|
|
const intl = useIntl();
|
|
return (
|
|
return (
|
|
<Form form={form} layout="vertical" style={style} className="px-2">
|
|
<Form form={form} layout="vertical" style={style} className="px-2">
|
|
@@ -161,25 +166,21 @@ const BasicInfoForm: React.FC<BasicInfoFormProps> = ({ style, form }) => {
|
|
required={registerFormFields.patient_age.required}
|
|
required={registerFormFields.patient_age.required}
|
|
validateTrigger={registerFormFields.patient_age.trigger}
|
|
validateTrigger={registerFormFields.patient_age.trigger}
|
|
rules={registerFormFields.patient_age.validation}
|
|
rules={registerFormFields.patient_age.validation}
|
|
|
|
+ initialValue={{ number: 0, unit: 'Y' }}
|
|
>
|
|
>
|
|
- <>
|
|
|
|
- <style>{`
|
|
|
|
- .my-space .ant-space-item:nth-child(1) {
|
|
|
|
- width: 70%;
|
|
|
|
- }
|
|
|
|
- .my-space .ant-space-item:nth-child(2) {
|
|
|
|
- width: 30%;
|
|
|
|
- }
|
|
|
|
- `}</style>
|
|
|
|
- <Space className="w-full my-space" align="baseline">
|
|
|
|
- <InputNumber min={0} className="w-full" />
|
|
|
|
- <Select>
|
|
|
|
- <Select.Option value="D">天</Select.Option>
|
|
|
|
- <Select.Option value="M">月</Select.Option>
|
|
|
|
- <Select.Option value="Y">年</Select.Option>
|
|
|
|
- </Select>
|
|
|
|
- </Space>
|
|
|
|
- </>
|
|
|
|
|
|
+ <NumberWithUnit
|
|
|
|
+ align="baseline"
|
|
|
|
+ defaultUnit="Y"
|
|
|
|
+ defaultNumber={0}
|
|
|
|
+ unitClassName="w-full"
|
|
|
|
+ numberClassName="w-full"
|
|
|
|
+ className="w-full"
|
|
|
|
+ options={[
|
|
|
|
+ { label: '天', value: 'D' },
|
|
|
|
+ { label: '月', value: 'M' },
|
|
|
|
+ { label: '年', value: 'Y' },
|
|
|
|
+ ]}
|
|
|
|
+ />
|
|
</Form.Item>
|
|
</Form.Item>
|
|
<Form.Item
|
|
<Form.Item
|
|
label={
|
|
label={
|