import React, {Component} from 'react'
|
import PropTypes from 'prop-types'
|
import { is, fromJS } from 'immutable'
|
import { Form, Row, Col, Input } from 'antd'
|
import { formRule } from '@/utils/option.js'
|
import './index.scss'
|
|
const { TextArea } = Input
|
|
class MainSearch extends Component {
|
static propTpyes = {
|
config: PropTypes.object,
|
updatemenu: PropTypes.func
|
}
|
|
changeName = (e) => {
|
let value = e.target.value || ''
|
if (value.length > 100) return
|
|
this.setState({}, () => {
|
this.props.updatemenu({...this.props.config, tabName: value})
|
})
|
}
|
|
changeNo = (e) => {
|
let value = e.target.value || ''
|
if (value.length > 100) return
|
this.setState({}, () => {
|
this.props.updatemenu({...this.props.config, tabNo: value})
|
})
|
}
|
|
changeRemark = (e) => {
|
let value = e.target.value || ''
|
if (value.length > 100) return
|
this.setState({}, () => {
|
this.props.updatemenu({...this.props.config, Remark: value})
|
})
|
}
|
|
shouldComponentUpdate (nextProps, nextState) {
|
return is(fromJS(this.props), fromJS(nextProps))
|
}
|
|
render() {
|
const { config } = this.props
|
const { getFieldDecorator } = this.props.form
|
const formItemLayout = {
|
labelCol: {
|
xs: { span: 24 },
|
sm: { span: 24 }
|
},
|
wrapperCol: {
|
xs: { span: 24 },
|
sm: { span: 24 }
|
}
|
}
|
|
return (
|
<Form {...formItemLayout} className="ant-advanced-search-form" id="subqazxcvbn">
|
<Row gutter={24}>
|
<Col span={24}>
|
<Form.Item label="页面名称">
|
{getFieldDecorator('tabName', {
|
initialValue: config.tabName,
|
rules: [
|
{
|
required: true,
|
message: '请输入页面名称!'
|
},
|
{
|
max: formRule.input.max,
|
message: formRule.input.message
|
}
|
]
|
})(<Input placeholder="" autoComplete="off" onChange={this.changeName}/>)}
|
</Form.Item>
|
</Col>
|
<Col span={24}>
|
<Form.Item label="菜单参数">
|
{getFieldDecorator('tabNo', {
|
initialValue: config.tabNo,
|
rules: [
|
{
|
required: true,
|
message: '请输入菜单参数!'
|
},
|
{
|
max: formRule.input.max,
|
message: formRule.input.message
|
}
|
]
|
})(<Input placeholder="" autoComplete="off" onChange={this.changeNo}/>)}
|
</Form.Item>
|
</Col>
|
<Col span={24}>
|
<Form.Item label="备注">
|
{getFieldDecorator('Remark', {
|
initialValue: config.Remark,
|
rules: [
|
{
|
max: formRule.input.max,
|
message: formRule.input.message
|
}
|
]
|
})(<TextArea rows={2} placeholder="" autoComplete="off" onChange={this.changeRemark}/>)}
|
</Form.Item>
|
</Col>
|
</Row>
|
</Form>
|
)
|
}
|
}
|
|
export default Form.create()(MainSearch)
|