import React, {Component} from 'react'
|
import PropTypes from 'prop-types'
|
import { Form, Row, Col, Tooltip, Icon, Select, Radio } from 'antd'
|
|
// import './index.scss'
|
|
class SettingForm extends Component {
|
static propTpyes = {
|
autoMatic: PropTypes.object,
|
actions: PropTypes.array
|
}
|
|
state = {}
|
|
handleConfirm = () => {
|
// 表单提交时检查输入值是否正确
|
return new Promise((resolve, reject) => {
|
this.props.form.validateFieldsAndScroll((err, values) => {
|
if (!err) {
|
resolve(values)
|
} else {
|
reject(err)
|
}
|
})
|
})
|
}
|
|
render() {
|
const { actions, autoMatic } = this.props
|
const { getFieldDecorator } = this.props.form
|
|
const formItemLayout = {
|
labelCol: {
|
xs: { span: 24 },
|
sm: { span: 8 }
|
},
|
wrapperCol: {
|
xs: { span: 24 },
|
sm: { span: 16 }
|
}
|
}
|
|
return (
|
<Form {...formItemLayout}>
|
<Row gutter={24}>
|
<Col span={20}>
|
<Form.Item label="是否启用">
|
{getFieldDecorator('enable', {
|
initialValue: autoMatic.enable,
|
})(
|
<Radio.Group>
|
<Radio value="true">是</Radio>
|
<Radio value="false">否</Radio>
|
</Radio.Group>
|
)}
|
</Form.Item>
|
</Col>
|
<Col span={20}>
|
<Form.Item label={
|
<Tooltip placement="topLeft" title="用于自动执行的按钮。">
|
<Icon type="question-circle" style={{color: '#c49f47', marginRight: '3px'}} />
|
按钮
|
</Tooltip>
|
}>
|
{getFieldDecorator('action', {
|
initialValue: autoMatic.action || '',
|
rules: [{
|
required: true,
|
message: '请选择执行按钮!'
|
}]
|
})(
|
<Select>
|
{actions.map((option, i) =>
|
<Select.Option key={i} value={option.uuid}>{option.label}</Select.Option>
|
)}
|
</Select>
|
)}
|
</Form.Item>
|
</Col>
|
</Row>
|
</Form>
|
)
|
}
|
}
|
|
export default Form.create()(SettingForm)
|