File was renamed from src/templates/headerconfig/menuform/index.jsx |
| | |
| | | import React, {Component} from 'react' |
| | | import PropTypes from 'prop-types' |
| | | import { Form, Row, Col, Input, Select } from 'antd' |
| | | import { Form, Row, Col, Input, Select, Radio } from 'antd' |
| | | import Utils from '@/utils/utils.js' |
| | | import './index.scss' |
| | | |
| | |
| | | readonly: false |
| | | }, |
| | | { |
| | | type: 'select', |
| | | type: 'radio', |
| | | key: 'openType', |
| | | label: this.props.dict['model.openway'], |
| | | initVal: 'menu', |
| | |
| | | options: [{ |
| | | id: 'menu', |
| | | text: this.props.dict['model.menu'] |
| | | // }, { |
| | | // id: 'newpage', |
| | | // text: this.props.dict['model.new'] + this.props.dict['model.window'] |
| | | }, { |
| | | id: 'outpage', |
| | | text: '外部页面' |
| | | }] |
| | | }, |
| | | { |
| | | type: 'select', |
| | | type: 'text', |
| | | key: 'linkUrl', |
| | | label: '页面地址', |
| | | initVal: '', |
| | | hidden: true, |
| | | label: this.props.dict['model.new'] + this.props.dict['model.window'], |
| | | initVal: 'service', |
| | | required: true, |
| | | options: [] |
| | | required: true |
| | | } |
| | | ] |
| | | } |
| | | |
| | | UNSAFE_componentWillMount () { |
| | | const { menu } = this.props |
| | | |
| | | if (this.props.type === 'add') { |
| | | this.setState({ |
| | | formlist: this.state.defaultMenu |
| | | }) |
| | | } else { |
| | | this.setState({ |
| | | formlist: this.state.defaultMenu.map(menu => { |
| | | if (menu.key === 'menuName') { |
| | | menu.initVal = this.props.menu.MenuName |
| | | } else if (menu.key === 'openType') { |
| | | menu.initVal = this.props.menu.PageParam.OpenType |
| | | } else if (menu.key === 'linkUrl') { |
| | | menu.initVal = this.props.menu.PageParam.linkUrl |
| | | if (this.props.menu.PageParam.OpenType === 'menu') { |
| | | menu.hidden = true |
| | | } else if (this.props.menu.PageParam.OpenType === 'newpage') { |
| | | menu.hidden = false |
| | | formlist: this.state.defaultMenu.map(item => { |
| | | if (item.key === 'menuName') { |
| | | item.initVal = menu.MenuName |
| | | } else if (item.key === 'openType') { |
| | | item.initVal = menu.PageParam.OpenType |
| | | } else if (item.key === 'linkUrl') { |
| | | item.initVal = menu.PageParam.linkUrl |
| | | if (menu.PageParam.OpenType === 'menu') { |
| | | item.hidden = true |
| | | } else if (menu.PageParam.OpenType === 'outpage') { |
| | | item.hidden = false |
| | | } |
| | | } |
| | | return menu |
| | | return item |
| | | }) |
| | | }) |
| | | } |
| | |
| | | openTypeChange = (key, value) => { |
| | | if (key === 'openType') { |
| | | let formlist = this.state.formlist |
| | | if (value === 'newpage') { |
| | | if (value === 'outpage') { |
| | | formlist.forEach(item => { |
| | | if (item.key === 'linkUrl') { |
| | | item.hidden = false |
| | | item.initVal = 'service' |
| | | item.initVal = '' |
| | | } |
| | | }) |
| | | } else { |
| | |
| | | } |
| | | }) |
| | | } |
| | | |
| | | this.setState({formlist}) |
| | | } |
| | | } |
| | |
| | | getPopupContainer={() => document.getElementById('form-box')} |
| | | > |
| | | {item.options.map(option => |
| | | <Select.Option id={option.id} title={option.text} key={option.id} value={option.id}>{option.text}</Select.Option> |
| | | <Select.Option key={option.id} value={option.id}>{option.text}</Select.Option> |
| | | )} |
| | | </Select> |
| | | )} |
| | | </Form.Item> |
| | | </Col> |
| | | ) |
| | | } else if (item.type === 'radio') { // 下拉搜索 |
| | | fields.push( |
| | | <Col span={24} key={index}> |
| | | <Form.Item label={item.label}> |
| | | {getFieldDecorator(item.key, { |
| | | initialValue: item.initVal || '', |
| | | rules: [ |
| | | { |
| | | required: !!item.required, |
| | | message: this.props.dict['form.required.select'] + item.label + '!' |
| | | } |
| | | ] |
| | | })( |
| | | <Radio.Group onChange={(e) => {this.openTypeChange(item.key, e.target.value)}}> |
| | | { |
| | | item.options.map(option => { |
| | | return ( |
| | | <Radio key={option.id} value={option.id}>{option.text}</Radio> |
| | | ) |
| | | }) |
| | | } |
| | | </Radio.Group> |
| | | )} |
| | | </Form.Item> |
| | | </Col> |
| | | ) |
| | | } |
| | | }) |
| | | |