import React, {Component} from 'react'
|
import PropTypes from 'prop-types'
|
import { Form, Row, Col, Input, Radio, Tooltip, InputNumber } from 'antd'
|
import { QuestionCircleOutlined } from '@ant-design/icons'
|
|
import './index.scss'
|
|
const { TextArea } = Input
|
|
class CustomMenuForm extends Component {
|
static propTpyes = {
|
config: PropTypes.object,
|
MenuId: PropTypes.string,
|
updateConfig: PropTypes.func
|
}
|
|
state = {}
|
|
// 一二级菜单切换
|
selectChange = (key, value) => {
|
const { config } = this.props
|
|
if (key === 'cacheUseful') {
|
this.props.updateConfig({...config, cacheUseful: value})
|
} else if (key === 'timeUnit') {
|
this.props.updateConfig({...config, timeUnit: value})
|
} else if (key === 'mask') {
|
this.props.updateConfig({...config, mask: value})
|
} else if (key === 'cacheLocal') {
|
this.props.updateConfig({...config, cacheLocal: value})
|
// } else if (key === 'permission') {
|
// this.props.updateConfig({...config, permission: value})
|
}
|
}
|
|
// 菜单名称
|
changeName = (e) => {
|
this.props.updateConfig({...this.props.config, MenuName: e.target.value})
|
}
|
|
// 菜单参数
|
changeNo = (e) => {
|
this.props.updateConfig({...this.props.config, MenuNo: e.target.value})
|
}
|
|
changeRemark = (e) => {
|
this.props.updateConfig({...this.props.config, Remark: e.target.value})
|
}
|
|
changeCacheDay = (val) => {
|
if (typeof(val) !== 'number') {
|
val = ''
|
}
|
this.props.updateConfig({...this.props.config, cacheTime: val})
|
}
|
|
render() {
|
const { config } = 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} className="custom-menu-form">
|
<Row>
|
<Col span={24}>
|
<Form.Item label="菜单名称">
|
{getFieldDecorator('MenuName', {
|
initialValue: config.MenuName,
|
rules: [
|
{
|
required: true,
|
message: '请输入菜单名称!'
|
}
|
]
|
})(<Input placeholder="" autoComplete="off" onChange={this.changeName}/>)}
|
</Form.Item>
|
</Col>
|
<Col span={24}>
|
<Form.Item label="菜单参数">
|
{getFieldDecorator('MenuNo', {
|
initialValue: config.MenuNo,
|
rules: [
|
{
|
required: true,
|
message: '请输入菜单参数!'
|
}
|
]
|
})(<Input placeholder="" autoComplete="off" onChange={this.changeNo}/>)}
|
</Form.Item>
|
</Col>
|
<Col span={24}>
|
<Form.Item label={
|
<Tooltip placement="topLeft" title="数据会缓存到用户本地,方便页面快速呈现。">
|
<QuestionCircleOutlined className="mk-form-tip" />
|
本地缓存
|
</Tooltip>
|
}>
|
{getFieldDecorator('cacheLocal', {
|
initialValue: config.cacheLocal || 'false'
|
})(
|
<Radio.Group onChange={(e) => {this.selectChange('cacheLocal', e.target.value)}}>
|
<Radio value="true">使用</Radio>
|
<Radio value="false">不使用</Radio>
|
</Radio.Group>
|
)}
|
</Form.Item>
|
</Col>
|
<Col span={24}>
|
<Form.Item label={
|
<Tooltip placement="topLeft" title="对于不经常性变动的信息,缓存数据有助于提高查询效率。">
|
<QuestionCircleOutlined className="mk-form-tip" />
|
后端缓存
|
</Tooltip>
|
}>
|
{getFieldDecorator('cacheUseful', {
|
initialValue: config.cacheUseful || 'false'
|
})(
|
<Radio.Group onChange={(e) => {this.selectChange('cacheUseful', e.target.value)}}>
|
<Radio value="true">使用</Radio>
|
<Radio value="false">不使用</Radio>
|
</Radio.Group>
|
)}
|
</Form.Item>
|
</Col>
|
{/* <Col span={24}>
|
<Form.Item label={
|
<Tooltip placement="topLeft" title="跳过权限验证时,页面中组件及按钮不在进行权限控制。">
|
<QuestionCircleOutlined className="mk-form-tip" />
|
权限验证
|
</Tooltip>
|
}>
|
{getFieldDecorator('permission', {
|
initialValue: config.permission || 'false'
|
})(
|
<Radio.Group onChange={(e) => {this.selectChange('permission', e.target.value)}}>
|
<Radio value="true">使用</Radio>
|
<Radio value="false">不使用</Radio>
|
</Radio.Group>
|
)}
|
</Form.Item>
|
</Col> */}
|
<Col span={24}>
|
<Form.Item label={
|
<Tooltip placement="topLeft" title="使用登录验证后,用户必须登录系统后才可以访问,注:含有登录组件的页面中无效。">
|
<QuestionCircleOutlined className="mk-form-tip" />
|
登录验证
|
</Tooltip>
|
}>
|
{getFieldDecorator('logincheck', {
|
initialValue: config.logincheck || 'false'
|
})(
|
<Radio.Group onChange={(e) => {this.selectChange('logincheck', e.target.value)}}>
|
<Radio value="true">使用</Radio>
|
<Radio value="false">不使用</Radio>
|
</Radio.Group>
|
)}
|
</Form.Item>
|
</Col>
|
<Col span={24}>
|
<Form.Item label={
|
<Tooltip placement="topLeft" title="数据加载时的遮罩和空数据图标是否显示。">
|
<QuestionCircleOutlined className="mk-form-tip" />
|
数据提示
|
</Tooltip>
|
}>
|
{getFieldDecorator('mask', {
|
initialValue: config.mask || 'true'
|
})(
|
<Radio.Group onChange={(e) => {this.selectChange('mask', e.target.value)}}>
|
<Radio value="true">显示</Radio>
|
<Radio value="false">隐藏</Radio>
|
</Radio.Group>
|
)}
|
</Form.Item>
|
</Col>
|
{config.cacheUseful === 'true' ? <Col span={24}>
|
<Form.Item label="单位">
|
{getFieldDecorator('timeUnit', {
|
initialValue: config.timeUnit || 'day'
|
})(
|
<Radio.Group onChange={(e) => {this.selectChange('timeUnit', e.target.value)}}>
|
<Radio value="day">天</Radio>
|
<Radio value="hour">小时</Radio>
|
</Radio.Group>
|
)}
|
</Form.Item>
|
</Col> : null}
|
{config.cacheUseful === 'true' ? <Col span={24}>
|
<Form.Item label="时长">
|
{getFieldDecorator('cacheTime', {
|
initialValue: config.cacheTime,
|
rules: [
|
{
|
required: true,
|
message: '请输入时长!'
|
}
|
]
|
})(
|
<InputNumber min={1} max={config.timeUnit !== 'hour' ? 7 : 23} precision={0} onChange={this.changeCacheDay}/>
|
)}
|
</Form.Item>
|
</Col> : null}
|
<Col span={24} className="red-font">
|
<Form.Item label="备注">
|
{getFieldDecorator('Remark', {
|
initialValue: config.Remark || '',
|
rules: [
|
{
|
max: 512,
|
message: '备注最多512个字符!'
|
}
|
]
|
})(<TextArea rows={2} placeholder={''} onChange={this.changeRemark} />)}
|
</Form.Item>
|
</Col>
|
</Row>
|
</Form>
|
)
|
}
|
}
|
|
export default Form.create()(CustomMenuForm)
|