From f8c3c53f9e29541f8c0e3fcbf682c301fd17e06a Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期一, 23 十一月 2020 17:49:23 +0800 Subject: [PATCH] 2020-11-23 --- src/menu/actioncomponent/actionform/index.jsx | 225 ++++++++++++++++--------------------------------------- 1 files changed, 67 insertions(+), 158 deletions(-) diff --git a/src/menu/actioncomponent/actionform/index.jsx b/src/menu/actioncomponent/actionform/index.jsx index a3e887b..a9758c6 100644 --- a/src/menu/actioncomponent/actionform/index.jsx +++ b/src/menu/actioncomponent/actionform/index.jsx @@ -2,33 +2,30 @@ 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' +import { btnIcons, btnCustomClasses, formRule } from '@/utils/option.js' -import Api from '@/api' -import options from '@/store/options.js' -import Utils from '@/utils/utils.js' 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'] + pop: ['label', 'OpenType', 'intertype', 'Ot', 'show', 'icon', 'class', 'execSuccess', 'execError', 'syncComponent', 'width'], + prompt: ['label', 'OpenType', 'intertype', 'Ot', 'show', 'icon', 'class', 'execSuccess', 'execError', 'syncComponent', 'width'], + exec: ['label', 'OpenType', 'intertype', 'Ot', 'show', 'icon', 'class', 'execSuccess', 'execError', 'syncComponent', 'width'], + excelIn: ['label', 'Ot', 'OpenType', 'intertype', 'show', 'icon', 'class', 'sheet', 'execSuccess', 'execError', 'syncComponent', 'width'], + excelOut: ['label', 'OpenType', 'intertype', 'show', 'icon', 'class', 'execSuccess', 'execError', 'pagination', 'search', 'width'], + popview: ['label', 'Ot', 'OpenType', 'show', 'icon', 'class', 'popClose', 'width'], + tab: ['label', 'Ot', 'OpenType', 'show', 'icon', 'class', 'linkmenu', 'width'], + innerpage: ['label', 'Ot', 'OpenType', 'pageTemplate', 'show', 'icon', 'class', 'width'], + funcbutton: ['label', 'OpenType', 'funcType', 'show', 'icon', 'class', 'width'] } class MainSearch extends Component { static propTpyes = { dict: PropTypes.object, // 瀛楀吀椤� + type: PropTypes.any, // type涓�"card"鏃讹紝鍙彲閫夊崟琛屾垨涓嶉�夎 setting: PropTypes.object, // 椤甸潰璁剧疆 formlist: PropTypes.any, // 琛ㄥ崟淇℃伅 card: PropTypes.any, // 鎸夐挳淇℃伅 - tabs: PropTypes.array, // 鎵�鏈夋爣绛鹃〉 inputSubmit: PropTypes.any // 鍥炶溅鎻愪氦浜嬩欢 } @@ -37,7 +34,6 @@ openType: null, // 鎵撳紑鏂瑰紡 interType: null, // 鎺ュ彛绫诲瀷锛氬唴閮ㄣ�佸閮� funcType: null, // 鍔熻兘绫诲瀷 - position: null, // 鎸夐挳浣嶇疆 requireOptions: [{ value: 'notRequired', text: this.props.dict['header.form.notRequired'] @@ -81,7 +77,7 @@ UNSAFE_componentWillMount () { - const { card } = this.props + const { card, type } = this.props let _menulist = this.props.formlist.filter(form => form.key === 'linkmenu')[0] || '' let _opentype = card.OpenType // 鎵撳紑鏂瑰紡 @@ -98,15 +94,16 @@ openType: _opentype, menulist: _menulist.options || [], interType: _intertype, - position: card.position || 'toolbar', funcType: _funcType, formlist: this.props.formlist.map(item => { if (item.key === 'class') { - item.options = btnClasses + item.options = btnCustomClasses } else if (item.key === 'icon') { item.options = btnIcons } else if (item.key === 'Ot') { - if (card.position === 'grid' || card.pageTemplate === 'pay') { // 琛岀骇鎸夐挳銆佹敮浠樻寜閽紝鍙兘閫夊崟琛� + if (type === 'card') { + item.options = this.state.requireOptions.filter(op => ['notRequired', 'requiredSgl'].includes(op.value)) + } else if (card.pageTemplate === 'pay') { // 琛岀骇鎸夐挳銆佹敮浠樻寜閽紝鍙兘閫夊崟琛� item.options = this.state.requireOptions.filter(op => ['requiredSgl'].includes(op.value)) } else if (['innerpage', 'blank', 'tab', 'popview', 'excelIn'].includes(_opentype)) { item.options = this.state.requireOptions.filter(op => ['notRequired', 'requiredSgl'].includes(op.value)) @@ -121,14 +118,6 @@ } else { item.options = this.state.insertUpdateOptions } - } else if (item.key === 'linkTab') { - item.options = [ - { - value: '', - text: '鏂板缓' - }, - ...this.props.tabs - ] } else if (item.key === 'OpenType') { item.initVal = _opentype } @@ -166,7 +155,7 @@ _options.push('execMode', 'intertype', 'innerFunc', 'Ot', 'execSuccess', 'execError') } } - } else { + } else if (_opentype === 'popview' && _opentype === 'tab') { if (_intertype === 'outer') { _options.push('innerFunc', 'sysInterface', 'interface', 'outerFunc', 'callbackFunc') } else if (_intertype === 'inner') { @@ -199,7 +188,7 @@ * 3銆佸垏鎹㈡爣绛剧被鍨嬶紝閲嶇疆鍙�夋爣绛� */ openTypeChange = (key, value) => { - const { card } = this.props + const { card, type } = this.props if (key === 'OpenType') { let _options = this.getOptions(value, this.state.interType, this.state.funcType, card.pageTemplate) @@ -214,9 +203,8 @@ if (item.key === 'intertype') { _fieldval.intertype = this.state.interType } else if (item.key === 'Ot') { - if (this.state.position === 'grid') { - item.options = this.state.requireOptions.filter(op => ['requiredSgl'].includes(op.value)) - _fieldval.Ot = 'requiredSgl' + if (type === 'card') { + item.options = this.state.requireOptions.filter(op => ['notRequired', 'requiredSgl'].includes(op.value)) } else if (['innerpage', 'blank', 'tab', 'popview'].includes(value)) { item.options = this.state.requireOptions.filter(op => ['notRequired', 'requiredSgl'].includes(op.value)) _fieldval.Ot = 'requiredSgl' @@ -252,57 +240,8 @@ this.props.form.setFieldsValue(_fieldval) }) - } else if (key === 'position') { - let _fieldval = {} - - this.setState({ - position: value, - formlist: this.state.formlist.map(item => { - if (item.key === 'Ot') { - if (value === 'grid') { - item.options = this.state.requireOptions.filter(op => ['requiredSgl'].includes(op.value)) - _fieldval.Ot = 'requiredSgl' - } else if (['innerpage', 'blank', 'tab', 'popview'].includes(this.state.openType)) { - item.options = this.state.requireOptions.filter(op => ['notRequired', 'requiredSgl'].includes(op.value)) - _fieldval.Ot = 'requiredSgl' - } else { - item.options = this.state.requireOptions - } - } - return item - }) - }, () => { - this.props.form.setFieldsValue(_fieldval) - }) - } else if (key === 'tabType') { - let _tabs = this.props.tabs.filter(tab => tab.type === value) - let _fieldval = {} - - this.setState({ - formlist: this.state.formlist.map(item => { - if (item.key === 'linkTab') { - item.options = [ - { - value: '', - text: '鏂板缓' - }, - ..._tabs - ] - } - return item - }) - }, () => { - this.props.form.setFieldsValue(_fieldval) - }) } else if (key === 'funcType') { - 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 { - _options = ['label', 'OpenType', 'funcType', 'execMode', 'intertype', 'innerFunc', 'Ot', 'icon', 'class', 'execSuccess', 'execError'] - } - } + let _options = this.getOptions(this.state.openType, this.state.interType, value, card.pageTemplate) let _fieldval = {} this.setState({ @@ -314,7 +253,11 @@ if (item.key === 'intertype') { _fieldval.intertype = this.state.interType } else if (item.key === 'Ot' && value === 'print') { - item.options = this.state.requireOptions + if (type === 'card') { + item.options = this.state.requireOptions.filter(op => ['notRequired', 'requiredSgl'].includes(op.value)) + } else { + item.options = this.state.requireOptions + } } return item @@ -326,7 +269,9 @@ let _fieldval = {} this.setState({ formlist: this.state.formlist.map(item => { - if (item.key === 'Ot' && value === 'insert') { + if (item.key === 'Ot' && type === 'card') { + item.options = this.state.requireOptions.filter(op => ['notRequired', 'requiredSgl'].includes(op.value)) + } else if (item.key === 'Ot' && value === 'insert') { item.options = this.state.requireOptions.filter(op => ['notRequired', 'requiredSgl', 'required'].includes(op.value)) } else if (item.key === 'Ot') { item.options = this.state.requireOptions @@ -349,17 +294,14 @@ } else if (value === 'LogicDelete' || value === 'delete') { _fieldval.label = '鍒犻櫎' _fieldval.class = 'danger' - _fieldval.Ot = 'required' + _fieldval.Ot = 'requiredSgl' } this.props.form.setFieldsValue(_fieldval) }) } else if (key === 'pageTemplate') { - let _options = ['label', 'Ot', 'OpenType', 'pageTemplate', 'icon', 'class', 'position'] let _fieldval = {} - if (value === 'custom') { - _options.push('url', 'joint') - } + let _options = this.getOptions(this.state.openType, this.state.interType, this.state.funcType, value) this.setState({ openType: value, @@ -370,6 +312,8 @@ if (value === 'pay') { item.options = this.state.requireOptions.filter(op => ['requiredSgl'].includes(op.value)) _fieldval.Ot = 'requiredSgl' + } else if (type === 'card') { + item.options = this.state.requireOptions.filter(op => ['notRequired', 'requiredSgl'].includes(op.value)) } else { item.options = this.state.requireOptions.filter(op => ['notRequired', 'requiredSgl'].includes(op.value)) } @@ -384,6 +328,7 @@ } onChange = (e, key) => { + const { type } = this.props const { openType } = this.state let value = e.target.value @@ -400,7 +345,11 @@ } else if (item.key === 'sysInterface') { item.initVal = 'false' } else if (item.key === 'Ot') { - item.options = this.state.requireOptions + if (type === 'card') { + item.options = this.state.requireOptions.filter(op => ['notRequired', 'requiredSgl'].includes(op.value)) + } else { + item.options = this.state.requireOptions + } } return item }) @@ -442,7 +391,7 @@ const fields = [] this.state.formlist.forEach((item, index) => { - if (item.hidden) return + if (item.hidden || item.forbid) return if (item.type === 'text') { // 鏂囨湰鎼滅储 let _rules = [] @@ -597,9 +546,20 @@ })( <Cascader options={this.state.menulist} - loadData={this.loadData} placeholder="" /> + )} + </Form.Item> + </Col> + ) + } else if (item.type === 'mcascader') { + fields.push( + <Col span={12} key={index}> + <Form.Item label={item.label}> + {getFieldDecorator(item.key, { + initialValue: item.initVal + })( + <Cascader options={item.options} expandTrigger="hover" placeholder="" /> )} </Form.Item> </Col> @@ -607,57 +567,6 @@ } }) 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 = () => { @@ -670,27 +579,27 @@ values.uuid = this.props.card.uuid values.verify = this.props.card.verify || null - if (values.OpenType === 'excelIn') { - values.position = 'toolbar' + if (values.show === 'icon' && !values.icon) { + notification.warning({ + top: 92, + message: '璇烽�夋嫨鍥炬爣锛�', + duration: 5 + }) + return } else if (values.OpenType === 'excelOut') { - if (values.intertype === 'inner' && !values.innerFunc) { - if ((setting.interType === 'inner' && setting.innerFunc) || setting.interType === 'outer') { - notification.warning({ - top: 92, - message: '琛ㄦ牸鏁版嵁鏌ヨ鏈娇鐢ㄦ暟鎹簮锛屽鍑篍xcel浣跨敤鍐呴儴鎺ュ彛鏃讹紝闇�鑷畾涔夊唴閮ㄥ嚱鏁帮紒', - duration: 5 - }) - return - } + if (values.intertype === 'system' && setting.interType !== 'system') { + notification.warning({ + top: 92, + message: '琛ㄦ牸鏁版嵁鏌ヨ鏈娇鐢ㄦ暟鎹簮锛屽鍑篍xcel浣跨敤鍐呴儴鎺ュ彛鏃讹紝闇�鑷畾涔夊唴閮ㄥ嚱鏁帮紒', + duration: 5 + }) + return } - values.position = 'toolbar' values.Ot = 'notRequired' - } else if (values.OpenType === 'popview' && !values.linkTab) { // 娌℃湁鍏宠仈鏍囩锛堟柊寤烘椂锛夛紝鍒涘缓鏂版爣绛綢d - values.linkTab = Utils.getuuid() + } else if (values.OpenType === 'popview') { values.createTab = true // 鐢ㄤ簬鏍囪鎸夐挳澶嶅埗鏃讹紝鏄惁澶嶅埗鍘熸湁鏍囩 } else if (values.OpenType === 'funcbutton') { // 杞崲鎵撳嵃鏃舵墦寮�鏂瑰紡 - values.position = 'toolbar' if (values.funcType === 'print') { values.OpenType = values.execMode } -- Gitblit v1.8.0