Commit 9e051436 authored by afc163's avatar afc163

update BasicForm

parent 44173606
import React, { PureComponent } from 'react'; import React, { PureComponent } from 'react';
import { connect } from 'dva'; import { connect } from 'dva';
import { Form, Input, DatePicker, Select, Button, Card } from 'antd'; import {
Form, Input, DatePicker, Select, Button, Card, InputNumber, Radio, Icon, Tooltip,
} from 'antd';
import PageHeaderLayout from '../../layouts/PageHeaderLayout'; import PageHeaderLayout from '../../layouts/PageHeaderLayout';
import styles from './style.less';
const FormItem = Form.Item; const FormItem = Form.Item;
const { Option } = Select; const { Option } = Select;
const { RangePicker } = DatePicker; const { RangePicker } = DatePicker;
const { TextArea } = Input;
@connect(state => ({ @connect(state => ({
submitting: state.form.regularFormSubmitting, submitting: state.form.regularFormSubmitting,
...@@ -25,12 +29,12 @@ export default class BasicForms extends PureComponent { ...@@ -25,12 +29,12 @@ export default class BasicForms extends PureComponent {
} }
render() { render() {
const { submitting } = this.props; const { submitting } = this.props;
const { getFieldDecorator } = this.props.form; const { getFieldDecorator, getFieldValue } = this.props.form;
const formItemLayout = { const formItemLayout = {
labelCol: { labelCol: {
xs: { span: 24 }, xs: { span: 24 },
sm: { span: 3 }, sm: { span: 7 },
}, },
wrapperCol: { wrapperCol: {
xs: { span: 24 }, xs: { span: 24 },
...@@ -42,100 +46,139 @@ export default class BasicForms extends PureComponent { ...@@ -42,100 +46,139 @@ export default class BasicForms extends PureComponent {
const submitFormLayout = { const submitFormLayout = {
wrapperCol: { wrapperCol: {
xs: { span: 24, offset: 0 }, xs: { span: 24, offset: 0 },
sm: { span: 10, offset: 3 }, sm: { span: 10, offset: 7 },
}, },
}; };
return ( return (
<PageHeaderLayout title="基础表单" content="表单页是向后台提交数据的标准场景。"> <PageHeaderLayout title="基础表单" content="表单页是向后台提交数据的标准场景。">
<Card bordered={false}> <Card bordered={false}>
<Form onSubmit={this.handleSubmit} hideRequiredMark style={{ marginTop: 24 }}> <Form
onSubmit={this.handleSubmit}
hideRequiredMark
style={{ marginTop: 8 }}
>
<FormItem <FormItem
{...formItemLayout} {...formItemLayout}
label="应用类型" label="标题"
hasFeedback
> >
{getFieldDecorator('appType', { {getFieldDecorator('title', {
rules: [{ rules: [{
required: true, message: '应用类型', required: true, message: '请输入标题',
}], }],
})( })(
<Select placeholder="请选择应用类型"> <Input placeholder="给目标起个名字" />
<Option value="type1">类型一</Option>
<Option value="type2">类型二</Option>
<Option value="type3">类型三</Option>
</Select>
)} )}
</FormItem> </FormItem>
<FormItem <FormItem
{...formItemLayout} {...formItemLayout}
label="产品名" label="起止日期"
hasFeedback
> >
{getFieldDecorator('productName', { {getFieldDecorator('date', {
rules: [{ rules: [{
required: true, message: '输入产品名', required: true, message: '选择起止日期',
}], }],
})( })(
<Input placeholder="产品名" /> <RangePicker style={{ width: '100%' }} placeholder={['开始日期', '结束日期']} />
)} )}
</FormItem> </FormItem>
<FormItem <FormItem
{...formItemLayout} {...formItemLayout}
label="应用名" label="目标描述"
hasFeedback
> >
{getFieldDecorator('appName', { {getFieldDecorator('goal', {
rules: [ rules: [{
{ required: true, message: '请输入应用名' }, required: true, message: '请输入目标描述',
{ pattern: /^[a-zA-Z0-9-]+$/, message: '只能输入英文、数字、中划线' }, }],
],
})( })(
<Input placeholder="只能输入英文、数字、中划线" /> <TextArea placeholder="请输入你的阶段性工作目标" rows={4} />
)} )}
</FormItem> </FormItem>
<FormItem <FormItem
{...formItemLayout} {...formItemLayout}
label="中文名" label="衡量标准"
hasFeedback
> >
{getFieldDecorator('appChineseName', { {getFieldDecorator('standard', {
rules: [ rules: [{
{ required: true, message: '请输入应用中文名' }, required: true, message: '请输入衡量标准',
{ pattern: /^[\u4e00-\u9fa5]+$/, message: '请输入中文' }, }],
],
})( })(
<Input placeholder="应用中文名" /> <TextArea placeholder="请输入衡量标准" rows={4} />
)} )}
</FormItem> </FormItem>
<FormItem <FormItem
{...formItemLayout} {...formItemLayout}
label="生效日期" label={
<span>
客户
<em className={styles.optional}>
选填
<Tooltip title="目标的服务对象">
<Icon type="info-circle-o" style={{ marginRight: 4 }} />
</Tooltip>
</em>
</span>
}
> >
{getFieldDecorator('dateRange', { {getFieldDecorator('client')(
rules: [{ type: 'array', required: true, message: '请选择生效日期' }], <Input placeholder="请描述你服务的客户,内部客户直接 @姓名/工号" />
})( )}
<RangePicker </FormItem>
format="YYYY-MM-DD" <FormItem
placeholder={['开始日期', '结束日期']} {...formItemLayout}
style={{ width: '100%' }} label={<span>邀评人<em className={styles.optional}>选填</em></span>}
/> >
{getFieldDecorator('invites')(
<Input placeholder="请直接 @姓名/工号,最多可邀请 5 人" />
)} )}
</FormItem> </FormItem>
<FormItem <FormItem
{...formItemLayout} {...formItemLayout}
label="域名" label={<span>权重<em className={styles.optional}>选填</em></span>}
> >
{getFieldDecorator('domain', { {getFieldDecorator('weight')(
rules: [{ required: true, message: '请输入域名' }], <InputNumber placeholder="请输入" min={0} max={100} />
)}
<span>%</span>
</FormItem>
<FormItem
{...formItemLayout}
label="目标公开"
help="客户、邀评人默认被分享"
>
<div>
{getFieldDecorator('public', {
initialValue: '1',
})(
<Radio.Group>
<Radio value="1">公开</Radio>
<Radio value="2">部分公开</Radio>
<Radio value="3">不公开</Radio>
</Radio.Group>
)}
{getFieldDecorator('publicUsers', {
})( })(
<Input addonBefore="http://" addonAfter=".com" placeholder="facebook" style={{ width: '100%' }} /> <Select
mode="multiple"
placeholder="公开给"
style={{
margin: '12px 0',
display: getFieldValue('public') === '2' ? 'block' : 'none',
}}
>
<Option value="1">同事甲</Option>
<Option value="2">同事乙</Option>
<Option value="3">同事丙</Option>
</Select>
)} )}
</div>
</FormItem> </FormItem>
<FormItem {...submitFormLayout} style={{ marginTop: 40 }}> <FormItem {...submitFormLayout} style={{ marginTop: 40 }}>
<Button type="primary" htmlType="submit" loading={submitting}> <Button type="primary" htmlType="submit" loading={submitting}>
新建应用 提交
</Button> </Button>
<Button style={{ marginLeft: 8 }}>保存</Button>
<Button style={{ marginLeft: 8 }}>删除</Button>
</FormItem> </FormItem>
</Form> </Form>
</Card> </Card>
......
...@@ -84,3 +84,8 @@ ...@@ -84,3 +84,8 @@
.withFooterToolbar + div { .withFooterToolbar + div {
padding-bottom: 64px; padding-bottom: 64px;
} }
.optional {
color: @text-color-secondary;
font-style: normal;
}
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