Unverified Commit b8e9fb75 authored by valleykid's avatar valleykid Committed by GitHub

Fix a warning (#762)

* Add *bak in gitignore

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

* Remove props parent

* Fix some warnings
parent 7008363a
...@@ -11,11 +11,11 @@ const { Option } = Select; ...@@ -11,11 +11,11 @@ const { Option } = Select;
const getValue = obj => Object.keys(obj).map(key => obj[key]).join(','); const getValue = obj => Object.keys(obj).map(key => obj[key]).join(',');
const CreateForm = Form.create()((props) => { const CreateForm = Form.create()((props) => {
const { modalVisible, addInputValue, parent, form } = props; const { modalVisible, form, handleAdd, handleModalVisible } = props;
const okHandle = () => { const okHandle = () => {
form.validateFields((err/* , fieldsValue */) => { form.validateFields((err, fieldsValue) => {
if (err) return; if (err) return;
parent.handleAdd(); handleAdd(fieldsValue);
}); });
}; };
return ( return (
...@@ -23,8 +23,7 @@ const CreateForm = Form.create()((props) => { ...@@ -23,8 +23,7 @@ const CreateForm = Form.create()((props) => {
title="新建规则" title="新建规则"
visible={modalVisible} visible={modalVisible}
onOk={okHandle} onOk={okHandle}
destroyOnClose onCancel={() => handleModalVisible()}
onCancel={() => parent.handleModalVisible()}
> >
<FormItem <FormItem
labelCol={{ span: 5 }} labelCol={{ span: 5 }}
...@@ -34,7 +33,7 @@ const CreateForm = Form.create()((props) => { ...@@ -34,7 +33,7 @@ const CreateForm = Form.create()((props) => {
{form.getFieldDecorator('desc', { {form.getFieldDecorator('desc', {
rules: [{ required: true, message: 'Please input some description...' }], rules: [{ required: true, message: 'Please input some description...' }],
})( })(
<Input placeholder="请输入" onChange={parent.handleAddInput} value={addInputValue} /> <Input placeholder="请输入" />
)} )}
</FormItem> </FormItem>
</Modal> </Modal>
...@@ -48,7 +47,6 @@ const CreateForm = Form.create()((props) => { ...@@ -48,7 +47,6 @@ const CreateForm = Form.create()((props) => {
@Form.create() @Form.create()
export default class TableList extends PureComponent { export default class TableList extends PureComponent {
state = { state = {
addInputValue: '',
modalVisible: false, modalVisible: false,
expandForm: false, expandForm: false,
selectedRows: [], selectedRows: [],
...@@ -167,17 +165,11 @@ export default class TableList extends PureComponent { ...@@ -167,17 +165,11 @@ export default class TableList extends PureComponent {
}); });
} }
handleAddInput = (e) => { handleAdd = (fields) => {
this.setState({
addInputValue: e.target.value,
});
}
handleAdd = () => {
this.props.dispatch({ this.props.dispatch({
type: 'rule/add', type: 'rule/add',
payload: { payload: {
description: this.state.addInputValue, description: fields.desc,
}, },
}); });
...@@ -301,7 +293,7 @@ export default class TableList extends PureComponent { ...@@ -301,7 +293,7 @@ export default class TableList extends PureComponent {
render() { render() {
const { rule: { data }, loading } = this.props; const { rule: { data }, loading } = this.props;
const { selectedRows, modalVisible, addInputValue } = this.state; const { selectedRows, modalVisible } = this.state;
const menu = ( const menu = (
<Menu onClick={this.handleMenuClick} selectedKeys={[]}> <Menu onClick={this.handleMenuClick} selectedKeys={[]}>
...@@ -313,7 +305,6 @@ export default class TableList extends PureComponent { ...@@ -313,7 +305,6 @@ export default class TableList extends PureComponent {
const parentMethods = { const parentMethods = {
handleAdd: this.handleAdd, handleAdd: this.handleAdd,
handleModalVisible: this.handleModalVisible, handleModalVisible: this.handleModalVisible,
handleAddInput: this.handleAddInput,
}; };
return ( return (
...@@ -350,9 +341,8 @@ export default class TableList extends PureComponent { ...@@ -350,9 +341,8 @@ export default class TableList extends PureComponent {
</div> </div>
</Card> </Card>
<CreateForm <CreateForm
parent={parentMethods} {...parentMethods}
modalVisible={modalVisible} modalVisible={modalVisible}
addInputValue={addInputValue}
/> />
</PageHeaderLayout> </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