From 137fb8ea6af2789b3238b22bac31d80bced41dfe Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期三, 28 七月 2021 11:39:39 +0800 Subject: [PATCH] 2021-07-28 --- src/menu/components/share/actioncomponent/actionform/index.jsx | 90 ++++++++++++++++++++++++++++++++++----------- 1 files changed, 68 insertions(+), 22 deletions(-) diff --git a/src/menu/components/share/actioncomponent/actionform/index.jsx b/src/menu/components/share/actioncomponent/actionform/index.jsx index f7494bf..26122e5 100644 --- a/src/menu/components/share/actioncomponent/actionform/index.jsx +++ b/src/menu/components/share/actioncomponent/actionform/index.jsx @@ -2,15 +2,17 @@ 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, btnCustomClasses, formRule } from '@/utils/option.js' +import { btnCustomClasses, formRule } from '@/utils/option.js' +import asyncComponent from '@/utils/asyncComponent' import './index.scss' const { TextArea } = Input +const MkIcon = asyncComponent(() => import('@/components/mkIcon')) const actionTypeOptions = { - pop: ['label', 'OpenType', 'intertype', 'Ot', 'show', 'icon', 'class', 'execSuccess', 'execError', 'resetPageIndex', 'syncComponent', 'width'], - prompt: ['label', 'OpenType', 'intertype', 'Ot', 'show', 'icon', 'class', 'execSuccess', 'execError', 'resetPageIndex', 'syncComponent', 'width'], - exec: ['label', 'OpenType', 'intertype', 'Ot', 'show', 'icon', 'class', 'execSuccess', 'execError', 'resetPageIndex', 'syncComponent', 'width'], + pop: ['label', 'OpenType', 'intertype', 'Ot', 'show', 'icon', 'class', 'execSuccess', 'execError', 'resetPageIndex', 'syncComponent', 'width', 'openmenu', 'open'], + prompt: ['label', 'OpenType', 'intertype', 'Ot', 'show', 'icon', 'class', 'execSuccess', 'execError', 'resetPageIndex', 'syncComponent', 'width', 'openmenu', 'open'], + exec: ['label', 'OpenType', 'intertype', 'Ot', 'show', 'icon', 'class', 'execSuccess', 'execError', 'resetPageIndex', 'syncComponent', 'width', 'openmenu', 'open'], excelIn: ['label', 'Ot', 'OpenType', 'intertype', 'show', 'icon', 'class', 'sheet', 'execSuccess', 'execError', 'resetPageIndex', 'syncComponent', 'width'], excelOut: ['label', 'OpenType', 'intertype', 'show', 'icon', 'class', 'execSuccess', 'execError', 'syncComponent', 'resetPageIndex', 'pagination', 'search', 'width'], popview: ['label', 'Ot', 'OpenType', 'show', 'icon', 'class', 'popClose', 'resetPageIndex', 'width'], @@ -35,6 +37,8 @@ interType: null, // 鎺ュ彛绫诲瀷锛氬唴閮ㄣ�佸閮� funcType: null, // 鍔熻兘绫诲瀷 procMode: null, // 鍙傛暟鏂瑰紡 + pageTemplate: null, + Ot: null, requireOptions: [{ value: 'notRequired', text: this.props.dict['header.form.notRequired'] @@ -90,15 +94,19 @@ let _opentype = card.OpenType // 鎵撳紑鏂瑰紡 let _intertype = card.intertype || 'system' // 鎺ュ彛绫诲瀷 let _funcType = card.funcType || '' // 鍔熻兘鎸夐挳榛樿绫诲瀷 - let _procMode = card.procMode || 'system' // 鍙傛暟璇锋眰鏂瑰紡 + let _procMode = card.procMode || 'system' + let _Ot = card.Ot || 'requiredSgl' + let _pageTemplate = card.pageTemplate || '' - let _options = this.getOptions(_opentype, _intertype, _funcType, card.pageTemplate, _procMode) + let _options = this.getOptions(_opentype, _intertype, _funcType, _pageTemplate, _procMode, _Ot) this.setState({ + Ot: _Ot, openType: _opentype, interType: _intertype, procMode: _procMode, funcType: _funcType, + pageTemplate: _pageTemplate, formlist: this.props.formlist.map(item => { if (item.key === 'class') { item.options = btnCustomClasses @@ -107,12 +115,10 @@ } else if (item.key === 'intertype') { let iscustom = ['pop', 'prompt', 'exec'].includes(_opentype) item.options = this.state.interTypeOptions.filter(op => (iscustom || op.value !== 'custom')) - } else if (item.key === 'icon') { - item.options = btnIcons } else if (item.key === 'Ot') { if (type === 'card') { item.options = this.state.requireOptions.filter(op => ['notRequired', 'requiredSgl'].includes(op.value)) - } else if (card.pageTemplate === 'pay') { // 琛岀骇鎸夐挳銆佹敮浠樻寜閽紝鍙兘閫夊崟琛� + } else if (_pageTemplate === 'pay') { // 琛岀骇鎸夐挳銆佹敮浠樻寜閽紝鍙兘閫夊崟琛� item.options = this.state.requireOptions.filter(op => ['requiredSgl'].includes(op.value)) } else if (['innerpage', 'tab', 'popview', 'excelIn'].includes(_opentype)) { item.options = this.state.requireOptions.filter(op => ['notRequired', 'requiredSgl'].includes(op.value)) @@ -137,8 +143,8 @@ }) } - getOptions = (_opentype, _intertype, _funcType, _pageTemplate, _procMode) => { - let _options = fromJS(actionTypeOptions[_opentype]).toJS() // 閫夐」鍒楄〃 + getOptions = (_opentype, _intertype, _funcType, _pageTemplate, _procMode, _Ot) => { + let _options = actionTypeOptions[_opentype] ? fromJS(actionTypeOptions[_opentype]).toJS() : [] // 閫夐」鍒楄〃 if (_opentype === 'innerpage') { // 鏂伴〉闈紝鍙�夋ā鏉�(鑷畾涔夋椂锛屽彲濉叆澶栭儴閾炬帴) if (_pageTemplate === 'custom') { @@ -186,6 +192,13 @@ } } + if (_Ot !== 'notRequired' && _opentype !== 'excelOut') { + _options.push('controlField', 'controlVal') + } + if (_Ot === 'requiredSgl' && ['pop', 'prompt', 'exec'].includes(_opentype)) { + _options.push('swipe') + } + return _options } @@ -210,13 +223,12 @@ */ optionChange = (key, value) => { const { card, type } = this.props - const { openType, procMode } = this.state + const { openType, procMode, Ot, pageTemplate } = this.state if (key === 'OpenType') { - let _options = this.getOptions(value, 'system', this.state.funcType, card.pageTemplate, 'system') + let _options = this.getOptions(value, 'system', this.state.funcType, '', 'system', Ot) let _fieldval = {} - let _formlist = this.state.formlist.map(item => { item.hidden = !_options.includes(item.key) @@ -248,6 +260,8 @@ item.options = this.state.insertUpdateOptions } _fieldval.sqlType = '' + } else if (item.key === 'pageTemplate') { + item.initVal = '' } return item @@ -257,6 +271,7 @@ openType: value, intertype: 'system', procMode: 'system', + pageTemplate: '', formlist: _formlist }, () => { if (value === 'excelIn') { @@ -270,7 +285,7 @@ this.props.form.setFieldsValue(_fieldval) }) } else if (key === 'funcType') { - let _options = this.getOptions(openType, this.state.interType, value, card.pageTemplate, procMode) + let _options = this.getOptions(openType, this.state.interType, value, pageTemplate, procMode, Ot) let _fieldval = {} this.setState({ @@ -334,9 +349,10 @@ }) } else if (key === 'pageTemplate') { let _fieldval = {} - let _options = this.getOptions(openType, this.state.interType, this.state.funcType, value, procMode) + let _options = this.getOptions(openType, this.state.interType, this.state.funcType, value, procMode, Ot) this.setState({ + pageTemplate: value, formlist: this.state.formlist.map(item => { item.hidden = !_options.includes(item.key) @@ -357,7 +373,7 @@ this.props.form.setFieldsValue(_fieldval) }) } else if (key === 'intertype') { - let _options = this.getOptions(openType, value, this.state.funcType, '', procMode) + let _options = this.getOptions(openType, value, this.state.funcType, pageTemplate, procMode, Ot) this.setState({ interType: value, @@ -379,7 +395,7 @@ }) }) } else if (key === 'procMode') { - let _options = this.getOptions(openType, this.state.interType, this.state.funcType, '', value) + let _options = this.getOptions(openType, this.state.interType, this.state.funcType, pageTemplate, value, Ot) this.setState({ procMode: value, @@ -389,6 +405,16 @@ if (item.key === 'innerFunc') { item.required = true } + return item + }) + }) + } else if (key === 'Ot') { + let _options = this.getOptions(openType, this.state.interType, this.state.funcType, pageTemplate, procMode, value) + + this.setState({ + Ot: value, + formlist: this.state.formlist.map(item => { + item.hidden = !_options.includes(item.key) return item }) }) @@ -503,7 +529,7 @@ </Form.Item> </Col> ) - } else if (item.type === 'select') { // 涓嬫媺鎼滅储 + } else if (item.type === 'select') { fields.push( <Col span={12} key={index}> <Form.Item label={item.tooltip ? @@ -523,13 +549,14 @@ })( <Select showSearch - filterOption={(input, option) => option.props.children[2].toLowerCase().indexOf(input.toLowerCase()) >= 0} + allowClear={item.allowClear === true} + filterOption={(input, option) => option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0} onChange={(value) => {this.optionChange(item.key, value)}} getPopupContainer={() => document.getElementById('winter')} > {item.options.map((option, index) => - <Select.Option id={`${index}`} title={option.text} key={`${index}`} value={option.value}> - {item.key === 'icon' && option.value && <Icon type={option.value} />} {option.text} + <Select.Option key={index} value={(option.value || option.field)}> + {(option.text || option.label)} </Select.Option> )} </Select> @@ -602,6 +629,24 @@ </Form.Item> </Col> ) + } else if (item.type === 'icon') { + 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 + '!' + } + ] + })( + <MkIcon allowClear/> + )} + </Form.Item> + </Col> + ) } else if (item.type === 'mcascader') { fields.push( <Col span={12} key={index}> @@ -627,6 +672,7 @@ if (!err) { values.uuid = card.uuid values.verify = card.verify || null + values.modal = card.modal || null if (values.show === 'icon' && !values.icon) { notification.warning({ -- Gitblit v1.8.0