From e642aa17872ac17f1ea8d8c3915a9f7c501f5ccb Mon Sep 17 00:00:00 2001 From: Xiaoming Liu <13118619+happier2@users.noreply.github.com> Date: Tue, 21 Nov 2017 13:11:07 +0800 Subject: [PATCH] fix user input information will lose (#255) In step1, user changes some inputs, then clicks next step to step2. Then, back to step1, user's inputs will lose. fix it. --- src/routes/Forms/StepForm/Step1.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/routes/Forms/StepForm/Step1.js b/src/routes/Forms/StepForm/Step1.js index 5acdd406..20379b96 100644 --- a/src/routes/Forms/StepForm/Step1.js +++ b/src/routes/Forms/StepForm/Step1.js @@ -5,7 +5,7 @@ import styles from './style.less'; const { Option } = Select; -export default ({ formItemLayout, form, dispatch }) => { +export default ({ formItemLayout, form, dispatch, data }) => { const { getFieldDecorator, validateFields } = form; const onValidateForm = () => { validateFields((err, values) => { @@ -26,7 +26,7 @@ export default ({ formItemLayout, form, dispatch }) => { label="付款账户" > {getFieldDecorator('payAccount', { - initialValue: 'ant-design@alipay.com', + initialValue: data.payAccount || 'ant-design@alipay.com', rules: [{ required: true, message: '请选择付款账户' }], })( {getFieldDecorator('receiverAccount', { - initialValue: 'test@example.com', + initialValue: data.receiverAccount || 'test@example.com', rules: [ { required: true, message: '请输入收款人账户' }, { type: 'email', message: '账户名应为邮箱格式' }, @@ -59,7 +59,7 @@ export default ({ formItemLayout, form, dispatch }) => { label="收款人姓名" > {getFieldDecorator('receiverName', { - initialValue: 'Alex', + initialValue: data.receiverName || 'Alex', rules: [{ required: true, message: '请输入收款人姓名' }], })( @@ -70,7 +70,7 @@ export default ({ formItemLayout, form, dispatch }) => { label="转账金额" > {getFieldDecorator('amount', { - initialValue: '500', + initialValue: data.amount || '500', rules: [ { required: true, message: '请输入转账金额' }, { pattern: /^(\d+)((?:\.\d+)?)$/, message: '请输入合法金额数字' }, -- GitLab