Commit c29f22fe authored by valleykid's avatar valleykid Committed by 陈帅

修复TableList验证误触发 (#756)

* Add *bak in gitignore

* 修复TableList表单验证误触发问题

fix #755 
parent 3f2263d4
......@@ -18,4 +18,5 @@ yarn-error.log
.idea
yarn.lock
package-lock.json
*bak
jsconfig.json
......@@ -10,6 +10,36 @@ const FormItem = Form.Item;
const { Option } = Select;
const getValue = obj => Object.keys(obj).map(key => obj[key]).join(',');
const CreateForm = Form.create()((props) => {
const { modalVisible, addInputValue, parent, form } = props;
const okHandle = () => {
form.validateFields((err/* , fieldsValue */) => {
if (err) return;
parent.handleAdd();
});
};
return (
<Modal
title="新建规则"
visible={modalVisible}
onOk={okHandle}
onCancel={() => parent.handleModalVisible()}
>
<FormItem
labelCol={{ span: 5 }}
wrapperCol={{ span: 15 }}
label="描述"
>
{form.getFieldDecorator('desc', {
rules: [{ required: true, message: 'Please input some description...' }],
})(
<Input placeholder="请输入" onChange={parent.handleAddInput} value={addInputValue} />
)}
</FormItem>
</Modal>
);
});
@connect(({ rule, loading }) => ({
rule,
loading: loading.models.rule,
......@@ -279,6 +309,12 @@ export default class TableList extends PureComponent {
</Menu>
);
const parentMethods = {
handleAdd: this.handleAdd,
handleModalVisible: this.handleModalVisible,
handleAddInput: this.handleAddInput,
};
return (
<PageHeaderLayout title="查询表格">
<Card bordered={false}>
......@@ -312,20 +348,11 @@ export default class TableList extends PureComponent {
/>
</div>
</Card>
<Modal
title="新建规则"
visible={modalVisible}
onOk={this.handleAdd}
onCancel={() => this.handleModalVisible()}
>
<FormItem
labelCol={{ span: 5 }}
wrapperCol={{ span: 15 }}
label="描述"
>
<Input placeholder="请输入" onChange={this.handleAddInput} value={addInputValue} />
</FormItem>
</Modal>
<CreateForm
parent={parentMethods}
modalVisible={modalVisible}
addInputValue={addInputValue}
/>
</PageHeaderLayout>
);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment