¶Ô±ÈÐÂÎļþ |
| | |
| | | #set($upperEntityPath=$table.entityPath.toUpperCase()) |
| | | import React, { PureComponent } from 'react'; |
| | | import { Form, Input, Card, Button } from 'antd'; |
| | | import { connect } from 'dva'; |
| | | import Panel from '../../../components/Panel'; |
| | | import styles from '../../../layouts/Sword.less'; |
| | | import { $!{upperEntityPath}_SUBMIT } from '../../../actions/$!{table.entityPath}'; |
| | | |
| | | const FormItem = Form.Item; |
| | | |
| | | @connect(({ loading }) => ({ |
| | | submitting: loading.effects['$!{table.entityPath}/submit'], |
| | | })) |
| | | @Form.create() |
| | | class $!{entity}Add extends PureComponent { |
| | | handleSubmit = e => { |
| | | e.preventDefault(); |
| | | const { dispatch, form } = this.props; |
| | | form.validateFieldsAndScroll((err, values) => { |
| | | if (!err) { |
| | | dispatch($!{upperEntityPath}_SUBMIT(values)); |
| | | } |
| | | }); |
| | | }; |
| | | |
| | | render() { |
| | | const { |
| | | form: { getFieldDecorator }, |
| | | submitting, |
| | | } = this.props; |
| | | |
| | | const formItemLayout = { |
| | | labelCol: { |
| | | xs: { span: 24 }, |
| | | sm: { span: 7 }, |
| | | }, |
| | | wrapperCol: { |
| | | xs: { span: 24 }, |
| | | sm: { span: 12 }, |
| | | md: { span: 10 }, |
| | | }, |
| | | }; |
| | | |
| | | const action = ( |
| | | <Button type="primary" onClick={this.handleSubmit} loading={submitting}> |
| | | æäº¤ |
| | | </Button> |
| | | ); |
| | | |
| | | return ( |
| | | <Panel title="æ°å¢" back="/$!{servicePackage}/$!{table.entityPath}" action={action}> |
| | | <Form hideRequiredMark style={{ marginTop: 8 }}> |
| | | <Card className={styles.card} bordered={false}> |
| | | #foreach($field in $!{table.fields}) |
| | | #if($!{field.name}!=$!{tenantColumn}) |
| | | <FormItem {...formItemLayout} label="$!{field.comment}"> |
| | | {getFieldDecorator('$!{field.propertyName}', { |
| | | rules: [ |
| | | { |
| | | required: true, |
| | | message: '请è¾å
¥$!{field.comment}', |
| | | }, |
| | | ], |
| | | })(<Input placeholder="请è¾å
¥$!{field.comment}" />)} |
| | | </FormItem> |
| | | #end |
| | | #end |
| | | </Card> |
| | | </Form> |
| | | </Panel> |
| | | ); |
| | | } |
| | | } |
| | | |
| | | export default $!{entity}Add; |