From af02b8f3c3ec9e5684be1084904d673429421d2b Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期四, 03 九月 2020 16:40:47 +0800 Subject: [PATCH] 2020-09-03 --- src/menu/actioncomponent/actionform/index.jsx | 204 ++++++++++++++++---------------------------------- 1 files changed, 67 insertions(+), 137 deletions(-) diff --git a/src/menu/actioncomponent/actionform/index.jsx b/src/menu/actioncomponent/actionform/index.jsx index 25d206c..921703d 100644 --- a/src/menu/actioncomponent/actionform/index.jsx +++ b/src/menu/actioncomponent/actionform/index.jsx @@ -1,5 +1,6 @@ import React, {Component} from 'react' import PropTypes from 'prop-types' +import { fromJS } from 'immutable' import { Form, Row, Col, Input, Select, Icon, Radio, notification, Tooltip, InputNumber, Cascader } from 'antd' import { btnIcons, btnClasses, formRule } from '@/utils/option.js' @@ -9,6 +10,17 @@ import './index.scss' const { TextArea } = Input +const actionTypeOptions = { + pop: ['label', 'position', 'OpenType', 'intertype', 'Ot', 'icon', 'class', 'execSuccess', 'execError'], + prompt: ['label', 'position', 'OpenType', 'intertype', 'Ot', 'icon', 'class', 'execSuccess', 'execError'], + exec: ['label', 'position', 'OpenType', 'intertype', 'Ot', 'icon', 'class', 'execSuccess', 'execError'], + excelIn: ['label', 'Ot', 'OpenType', 'intertype', 'icon', 'class', 'sheet', 'execSuccess', 'execError'], + excelOut: ['label', 'OpenType', 'intertype', 'icon', 'class', 'execSuccess', 'execError', 'pagination', 'search'], + popview: ['label', 'Ot', 'OpenType', 'icon', 'class', 'position', 'tabType', 'linkTab', 'popClose'], + tab: ['label', 'Ot', 'OpenType', 'icon', 'class', 'position', 'linkmenu'], + innerpage: ['label', 'Ot', 'OpenType', 'pageTemplate', 'icon', 'class', 'position'], + funcbutton: ['label', 'OpenType', 'funcType', 'icon', 'class'] +} class MainSearch extends Component { static propTpyes = { @@ -72,62 +84,22 @@ const { card } = this.props let _menulist = this.props.formlist.filter(form => form.key === 'linkmenu')[0] || '' - let _opentype = card.OpenType // 鎵撳紑鏂瑰紡 - let _options = null // 閫夐」鍒楄〃 - - if (card.execMode) { // 杞崲鎵撳嵃鏃舵墦寮�鏂瑰紡 + let _opentype = card.OpenType // 鎵撳紑鏂瑰紡 + let _intertype = card.intertype || 'system' // 鎺ュ彛绫诲瀷 + let _funcType = card.funcType || 'print' // 鍔熻兘鎸夐挳榛樿绫诲瀷 + + if (card.execMode) { // 杞崲鎵撳嵃鏃舵墦寮�鏂瑰紡 _opentype = 'funcbutton' - } else if (_opentype === 'outerpage') { - card.pageTemplate = 'custom' - _opentype = 'innerpage' } - if (_opentype === 'innerpage') { // 鏂伴〉闈紝鍙�夋ā鏉�(鑷畾涔夋椂锛屽彲濉叆澶栭儴閾炬帴) - _options = ['label', 'Ot', 'OpenType', 'pageTemplate', 'icon', 'class', 'position'] - if (card.pageTemplate === 'custom') { - _options.push('url', 'joint') - } - } else if (_opentype === 'blank' || _opentype === 'tab') { // 鏂版爣绛炬垨褰撳墠椤甸潰鏇挎崲 - _options = ['label', 'Ot', 'OpenType', 'icon', 'class', 'position', 'tabTemplate', 'linkmenu'] - } else if (_opentype === 'popview') { // 妯℃�佹鏍囩椤� - _options = ['label', 'Ot', 'OpenType', 'icon', 'class', 'position', 'tabType', 'linkTab', 'popClose'] - } else if (_opentype === 'excelOut') { // 瀵煎叆瀵煎嚭 - if (card.intertype === 'outer') { - _options = ['label', 'OpenType', 'intertype', 'innerFunc', 'sysInterface', 'interface', 'outerFunc', 'icon', 'class', 'execSuccess', 'execError', 'pagination', 'search'] - } else { - _options = ['label', 'OpenType', 'intertype', 'innerFunc', 'icon', 'class', 'execSuccess', 'execError', 'pagination', 'search'] - } - } else if (_opentype === 'excelIn') { // 瀵煎叆瀵煎嚭 - if (card.intertype === 'outer') { - _options = ['label', 'Ot', 'OpenType', 'intertype', 'innerFunc', 'sysInterface', 'interface', 'outerFunc', 'callbackFunc', 'icon', 'class', 'sheet', 'execSuccess', 'execError'] - } else { - _options = ['label', 'Ot', 'OpenType', 'intertype', 'innerFunc', 'icon', 'class', 'sheet', 'execSuccess', 'execError'] - } - } else if (_opentype === 'funcbutton') { - if (!card.funcType) { - _options = ['label', 'OpenType', 'funcType', 'icon', 'class'] - } else if (card.funcType === 'changeuser') { - _options = ['label', 'OpenType', 'funcType', 'icon', 'class'] - } else if (card.funcType === 'print') { - if (card.intertype === 'outer') { - _options = ['label', 'OpenType', 'funcType', 'execMode', 'intertype', 'innerFunc', 'sysInterface', 'interface', 'outerFunc', 'callbackFunc', 'Ot', 'icon', 'class', 'execSuccess', 'execError'] - } else { - _options = ['label', 'OpenType', 'funcType', 'execMode', 'intertype', 'innerFunc', 'Ot', 'icon', 'class', 'execSuccess', 'execError'] - } - } - } else { - if (card.intertype === 'outer') { - _options = ['label', 'position', 'OpenType', 'intertype', 'innerFunc', 'sysInterface', 'interface', 'outerFunc', 'callbackFunc', 'Ot', 'icon', 'class', 'execSuccess', 'execError'] - } else { - _options = ['label', 'position', 'OpenType', 'intertype', 'innerFunc', 'Ot', 'icon', 'class', 'execSuccess', 'execError', 'sql', 'sqlType'] - } - } + let _options = this.getOptions(_opentype, _intertype, _funcType, card.pageTemplate) + this.setState({ openType: _opentype, menulist: _menulist.options || [], - interType: card.intertype || 'inner', + interType: _intertype, position: card.position || 'toolbar', - funcType: card.funcType, + funcType: _funcType, formlist: this.props.formlist.map(item => { if (item.key === 'class') { item.options = btnClasses @@ -167,6 +139,46 @@ }) } + getOptions = (_opentype, _intertype, _funcType, _pageTemplate) => { + let _options = fromJS(actionTypeOptions[_opentype]).toJS() // 閫夐」鍒楄〃 + + if (_opentype === 'innerpage') { // 鏂伴〉闈紝鍙�夋ā鏉�(鑷畾涔夋椂锛屽彲濉叆澶栭儴閾炬帴) + if (_pageTemplate === 'custom') { + _options.push('url', 'joint') + } + } else if (_opentype === 'excelOut') { // 瀵煎叆瀵煎嚭 + if (_intertype === 'outer') { + _options.push('innerFunc', 'sysInterface', 'interface', 'outerFunc') + } else if (_intertype === 'inner') { + _options.push('innerFunc') + } + } else if (_opentype === 'excelIn') { // 瀵煎叆瀵煎嚭 + if (_intertype === 'outer') { + _options.push('innerFunc', 'sysInterface', 'interface', 'outerFunc', 'callbackFunc') + } else if (_intertype === 'inner') { + _options.push('innerFunc') + } + } else if (_opentype === 'funcbutton') { + if (_funcType === 'print') { + if (_intertype === 'outer') { + _options.push('execMode', 'intertype', 'innerFunc', 'sysInterface', 'interface', 'outerFunc', 'callbackFunc', 'Ot', 'execSuccess', 'execError') + } else if (_intertype === 'inner') { + _options.push('execMode', 'intertype', 'innerFunc', 'Ot', 'execSuccess', 'execError') + } + } + } else { + if (_intertype === 'outer') { + _options.push('innerFunc', 'sysInterface', 'interface', 'outerFunc', 'callbackFunc') + } else if (_intertype === 'inner') { + _options.push('innerFunc') + } else { + _options.push('sql', 'sqlType') + } + } + + return _options + } + componentDidMount () { const { card } = this.props @@ -190,47 +202,7 @@ const { card } = this.props if (key === 'OpenType') { - let _options = null - if (value === 'innerpage') { - _options = ['label', 'Ot', 'OpenType', 'pageTemplate', 'icon', 'class', 'position'] - if (card.pageTemplate === 'custom') { - _options.push('url', 'joint') - } - } else if (value === 'blank' || value === 'tab') { - _options = ['label', 'Ot', 'OpenType', 'icon', 'class', 'position', 'tabTemplate', 'linkmenu'] - } else if (value === 'popview') { - _options = ['label', 'Ot', 'OpenType', 'icon', 'class', 'position', 'tabType', 'linkTab', 'popClose'] - } else if (value === 'excelOut') { - if (this.state.interType === 'outer') { - _options = ['label', 'OpenType', 'intertype', 'innerFunc', 'sysInterface', 'interface', 'outerFunc', 'icon', 'class', 'execSuccess', 'execError', 'pagination', 'search'] - } else { - _options = ['label', 'OpenType', 'intertype', 'innerFunc', 'icon', 'class', 'execSuccess', 'execError', 'pagination', 'search'] - } - } else if (value === 'excelIn') { - if (this.state.interType === 'outer') { - _options = ['label', 'Ot', 'OpenType', 'intertype', 'innerFunc', 'sysInterface', 'interface', 'outerFunc', 'callbackFunc', 'icon', 'class', 'sheet', 'execSuccess', 'execError'] - } else { - _options = ['label', 'Ot', 'OpenType', 'intertype', 'innerFunc', 'icon', 'class', 'sheet', 'execSuccess', 'execError'] - } - } else if (value === 'funcbutton') { - if (!this.state.funcType) { - _options = ['label', 'OpenType', 'funcType', 'icon', 'class'] - } else if (this.state.funcType === 'changeuser') { - _options = ['label', 'OpenType', 'funcType', 'icon', 'class'] - } else if (this.state.funcType === 'print') { - if (this.state.interType === 'outer') { - _options = ['label', 'OpenType', 'funcType', 'execMode', 'intertype', 'innerFunc', 'sysInterface', 'interface', 'outerFunc', 'callbackFunc', 'Ot', 'icon', 'class', 'execSuccess', 'execError'] - } else { - _options = ['label', 'OpenType', 'funcType', 'execMode', 'intertype', 'innerFunc', 'Ot', 'icon', 'class', 'execSuccess', 'execError'] - } - } - } else { - if (this.state.interType === 'inner') { - _options = ['label', 'position', 'OpenType', 'intertype', 'innerFunc', 'Ot', 'icon', 'class', 'execSuccess', 'execError', 'sql', 'sqlType'] - } else { - _options = ['label', 'position', 'OpenType', 'intertype', 'innerFunc', 'Ot', 'icon', 'class', 'execSuccess', 'execError', 'sysInterface', 'interface', 'outerFunc', 'callbackFunc'] - } - } + let _options = this.getOptions(value, this.state.interType, this.state.funcType, card.pageTemplate) let _fieldval = {} @@ -323,12 +295,8 @@ this.props.form.setFieldsValue(_fieldval) }) } else if (key === 'funcType') { - let _options = null - if (!value) { - _options = ['label', 'OpenType', 'funcType', 'icon', 'class'] - } else if (value === 'changeuser') { - _options = ['label', 'OpenType', 'funcType', 'icon', 'class'] - } else if (value === 'print') { + let _options = ['label', 'OpenType', 'funcType', 'icon', 'class'] + if (value === 'print') { if (this.state.interType === 'outer') { _options = ['label', 'OpenType', 'funcType', 'execMode', 'intertype', 'innerFunc', 'sysInterface', 'interface', 'outerFunc', 'callbackFunc', 'Ot', 'icon', 'class', 'execSuccess', 'execError'] } else { @@ -387,12 +355,10 @@ this.props.form.setFieldsValue(_fieldval) }) } else if (key === 'pageTemplate') { - let _options = null + let _options = ['label', 'Ot', 'OpenType', 'pageTemplate', 'icon', 'class', 'position'] let _fieldval = {} if (value === 'custom') { - _options = ['label', 'Ot', 'OpenType', 'pageTemplate', 'url', 'joint', 'icon', 'class', 'position'] - } else { - _options = ['label', 'Ot', 'OpenType', 'pageTemplate', 'icon', 'class', 'position'] + _options.push('url', 'joint') } this.setState({ @@ -414,17 +380,6 @@ }, () => { this.props.form.setFieldsValue(_fieldval) }) - } else if (key === 'tabTemplate') { - let _options = ['label', 'Ot', 'OpenType', 'icon', 'class', 'position', 'tabTemplate', 'linkmenu'] - - this.setState({ - openType: value, - formlist: this.state.formlist.map(item => { - item.hidden = !_options.includes(item.key) - - return item - }) - }) } } @@ -433,32 +388,7 @@ let value = e.target.value if (key === 'intertype') { - let _options = null - if (openType === 'excelOut') { - if (value === 'outer') { - _options = ['label', 'OpenType', 'intertype', 'innerFunc', 'sysInterface', 'interface', 'outerFunc', 'icon', 'class', 'execSuccess', 'execError', 'pagination', 'search'] - } else { - _options = ['label', 'OpenType', 'intertype', 'innerFunc', 'icon', 'class', 'execSuccess', 'execError', 'pagination', 'search'] - } - } else if (openType === 'excelIn') { - if (value === 'outer') { - _options = ['label', 'Ot', 'OpenType', 'intertype', 'innerFunc', 'sysInterface', 'interface', 'outerFunc', 'callbackFunc', 'icon', 'class', 'sheet', 'execSuccess', 'execError'] - } else { - _options = ['label', 'Ot', 'OpenType', 'intertype', 'innerFunc', 'icon', 'class', 'sheet', 'execSuccess', 'execError'] - } - } else if (openType === 'funcbutton') { - if (value === 'outer') { - _options = ['label', 'OpenType', 'funcType', 'execMode', 'intertype', 'innerFunc', 'sysInterface', 'interface', 'outerFunc', 'callbackFunc', 'Ot', 'icon', 'class', 'execSuccess', 'execError'] - } else { - _options = ['label', 'OpenType', 'funcType', 'execMode', 'intertype', 'innerFunc', 'Ot', 'icon', 'class', 'execSuccess', 'execError'] - } - } else { - if (value === 'inner') { - _options = ['label', 'position', 'OpenType', 'intertype', 'innerFunc', 'Ot', 'icon', 'class', 'execSuccess', 'execError', 'sql', 'sqlType'] - } else { - _options = ['label', 'position', 'OpenType', 'intertype', 'innerFunc', 'Ot', 'icon', 'class', 'execSuccess', 'execError', 'sysInterface', 'interface', 'outerFunc', 'callbackFunc'] - } - } + let _options = this.getOptions(openType, value, this.state.funcType) this.setState({ interType: value, -- Gitblit v1.8.0