| | |
| | | import React, {Component} from 'react' |
| | | import PropTypes from 'prop-types' |
| | | import { Form, Row, Col, Input, Select, Icon, Radio, notification, Tooltip, InputNumber } from 'antd' |
| | | import { Form, Row, Col, Input, Select, Icon, Radio, notification, Tooltip, InputNumber, Cascader } from 'antd' |
| | | import { btnIcons, btnClasses, formRule } from '@/utils/option.js' |
| | | |
| | | import Api from '@/api' |
| | | import options from '@/store/options.js' |
| | | import Utils from '@/utils/utils.js' |
| | | import './index.scss' |
| | | |
| | |
| | | UNSAFE_componentWillMount () { |
| | | const { card } = this.props |
| | | |
| | | let _menulist = this.props.formlist.filter(form => form.key === 'linkmenu')[0] || '' |
| | | let _opentype = card.OpenType // 打开方式 |
| | | let _tabType = card.tabType || 'SubTable' // 按钮为弹窗(标签)时,标签的类型 |
| | | let _options = null // 选项列表 |
| | |
| | | if (_opentype === 'innerpage') { // 新页面,可选模板(自定义时,可填入外部链接) |
| | | _options = ['label', 'Ot', 'OpenType', 'pageTemplate', 'icon', 'class', 'position'] |
| | | if (card.pageTemplate === 'custom') { |
| | | _options.push('url') |
| | | _options.push('url', 'joint') |
| | | } |
| | | } else if (_opentype === 'blank' || _opentype === 'tab') { // 新标签或当前页面替换 |
| | | _options = ['label', 'Ot', 'OpenType', 'icon', 'class', 'position', 'tabTemplate'] |
| | | if (card.tabTemplate === 'ThdMenu') { |
| | | _options.push('linkmenu') |
| | | } |
| | | } else if (_opentype === 'popview') { // 模态框标签页 |
| | | _options = ['label', 'Ot', 'OpenType', 'icon', 'class', 'position', 'tabType', 'linkTab', 'popClose'] |
| | | } else if (_opentype === 'excelOut') { // 导入导出 |
| | |
| | | } |
| | | this.setState({ |
| | | openType: _opentype, |
| | | menulist: _menulist.options || [], |
| | | interType: card.intertype || 'inner', |
| | | position: card.position || 'toolbar', |
| | | funcType: card.funcType, |
| | |
| | | if (value === 'innerpage') { |
| | | _options = ['label', 'Ot', 'OpenType', 'pageTemplate', 'icon', 'class', 'position'] |
| | | if (card.pageTemplate === 'custom') { |
| | | _options.push('url') |
| | | _options.push('url', 'joint') |
| | | } |
| | | } else if (value === 'blank' || value === 'tab') { |
| | | _options = ['label', 'Ot', 'OpenType', 'icon', 'class', 'position', 'tabTemplate'] |
| | | if (card.tabTemplate === 'ThdMenu') { |
| | | _options.push('linkmenu') |
| | | } |
| | | } else if (value === 'popview') { |
| | | _options = ['label', 'Ot', 'OpenType', 'icon', 'class', 'position', 'tabType', 'linkTab', 'popClose'] |
| | | } else if (value === 'excelOut') { |
| | |
| | | _options = ['label', 'Ot', 'OpenType', 'pageTemplate', 'url', 'icon', 'class', 'position'] |
| | | } else { |
| | | _options = ['label', 'Ot', 'OpenType', 'pageTemplate', 'icon', 'class', 'position'] |
| | | } |
| | | |
| | | this.setState({ |
| | | openType: value, |
| | | formlist: this.state.formlist.map(item => { |
| | | item.hidden = !_options.includes(item.key) |
| | | |
| | | return item |
| | | }) |
| | | }) |
| | | } else if (key === 'tabTemplate') { |
| | | let _options = ['label', 'Ot', 'OpenType', 'icon', 'class', 'position', 'tabTemplate'] |
| | | |
| | | if (value === 'ThdMenu') { |
| | | _options.push('linkmenu') |
| | | } |
| | | |
| | | this.setState({ |
| | |
| | | </Form.Item> |
| | | </Col> |
| | | ) |
| | | } else if (item.type === 'cascader') { // 多选 |
| | | fields.push( |
| | | <Col span={12} 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 + '!' |
| | | } |
| | | ] |
| | | })( |
| | | <Cascader |
| | | options={this.state.menulist} |
| | | loadData={this.loadData} |
| | | placeholder="" |
| | | /> |
| | | )} |
| | | </Form.Item> |
| | | </Col> |
| | | ) |
| | | } |
| | | }) |
| | | return fields |
| | | } |
| | | |
| | | loadData = selectedOptions => { |
| | | const { MenuID } = this.props |
| | | const targetOption = selectedOptions[selectedOptions.length - 1] |
| | | targetOption.loading = true |
| | | |
| | | let _param = { |
| | | func: 'sPC_Get_FunMenu', |
| | | ParentID: targetOption.value, |
| | | systemType: options.sysType, |
| | | debug: 'Y' |
| | | } |
| | | |
| | | Api.getSystemConfig(_param).then(result => { |
| | | if (result.status) { |
| | | targetOption.loading = false |
| | | targetOption.children = result.data.map(item => { |
| | | let submenu = { |
| | | value: item.ParentID, |
| | | label: item.MenuNameP, |
| | | children: item.FunMenu.map(cell => { |
| | | return { |
| | | value: cell.MenuID, |
| | | label: cell.MenuName, |
| | | MenuID: cell.MenuID, |
| | | MenuName: cell.MenuName, |
| | | MenuNo: cell.MenuNo, |
| | | Ot: cell.Ot, |
| | | PageParam: cell.PageParam, |
| | | LinkUrl: cell.LinkUrl, |
| | | disabled: cell.MenuID === MenuID |
| | | } |
| | | }) |
| | | } |
| | | |
| | | return submenu |
| | | }) |
| | | |
| | | this.setState({ |
| | | menulist: [...this.state.menulist] |
| | | }) |
| | | } else { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: result.message, |
| | | duration: 5 |
| | | }) |
| | | targetOption.loading = false |
| | | } |
| | | }) |
| | | } |
| | | |
| | | handleConfirm = () => { |
| | | const { setting } = this.props |
| | | const { menulist } = this.state |
| | | // 表单提交时检查输入值是否正确 |
| | | return new Promise((resolve, reject) => { |
| | | this.props.form.validateFieldsAndScroll((err, values) => { |
| | |
| | | } |
| | | } |
| | | |
| | | // 关联三级菜单 |
| | | if (values.OpenType === 'tab' && values.linkmenu && values.linkmenu.length > 0) { |
| | | let linkThdMenu = '' |
| | | menulist.forEach(menu => { |
| | | if (menu.value === values.linkmenu[0]) { |
| | | menu.children.forEach(item => { |
| | | if (item.value === values.linkmenu[1]) { |
| | | item.children.forEach(cell => { |
| | | if (cell.value === values.linkmenu[2]) { |
| | | linkThdMenu = cell |
| | | } |
| | | }) |
| | | } |
| | | }) |
| | | } |
| | | }) |
| | | values.linkThdMenu = linkThdMenu |
| | | } |
| | | |
| | | if (values.innerFunc === '' && values.sql === '') { |
| | | notification.warning({ |
| | | top: 92, |