mirror of
https://github.com/chillzhuang/SpringBlade.git
synced 2024-11-15 23:19:29 +08:00
74 lines
2.0 KiB
Plaintext
74 lines
2.0 KiB
Plaintext
#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="/$!{cfg.servicePackage}/$!{table.entityPath}" action={action}>
|
|
<Form hideRequiredMark style={{ marginTop: 8 }}>
|
|
<Card className={styles.card} bordered={false}>
|
|
#foreach($field in $!{table.fields})
|
|
<FormItem {...formItemLayout} label="$!{field.comment}">
|
|
{getFieldDecorator('$!{field.propertyName}', {
|
|
rules: [
|
|
{
|
|
required: true,
|
|
message: '请输入$!{field.comment}',
|
|
},
|
|
],
|
|
})(<Input placeholder="请输入$!{field.comment}" />)}
|
|
</FormItem>
|
|
#end
|
|
</Card>
|
|
</Form>
|
|
</Panel>
|
|
);
|
|
}
|
|
}
|
|
|
|
export default $!{entity}Add;
|