From f66e19dd13af07ee466306632ad43c72f1f16ae7 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期三, 26 五月 2021 14:49:55 +0800 Subject: [PATCH] 2021-05-26 --- src/menu/components/share/actioncomponent/actionform/index.jsx | 176 ++++++++++++++++++++++++++++++++++++++++------------------ 1 files changed, 122 insertions(+), 54 deletions(-) diff --git a/src/menu/components/share/actioncomponent/actionform/index.jsx b/src/menu/components/share/actioncomponent/actionform/index.jsx index 83d1aab..ba4c550 100644 --- a/src/menu/components/share/actioncomponent/actionform/index.jsx +++ b/src/menu/components/share/actioncomponent/actionform/index.jsx @@ -8,18 +8,18 @@ const { TextArea } = Input 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'], - excelIn: ['label', 'Ot', 'OpenType', 'intertype', 'show', 'icon', 'class', 'sheet', 'execSuccess', 'execError', 'resetPageIndex', 'syncComponent', 'width'], - excelOut: ['label', 'OpenType', 'intertype', 'show', 'icon', 'class', 'execSuccess', 'execError', 'resetPageIndex', 'pagination', 'search', 'width'], - popview: ['label', 'Ot', 'OpenType', 'show', 'icon', 'class', 'popClose', 'resetPageIndex', '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'] + pop: ['label', 'OpenType', 'intertype', 'Ot', 'show', 'icon', 'class', 'execSuccess', 'execError', 'resetPageIndex', 'syncComponent', 'width', 'controlField', 'controlVal'], + prompt: ['label', 'OpenType', 'intertype', 'Ot', 'show', 'icon', 'class', 'execSuccess', 'execError', 'resetPageIndex', 'syncComponent', 'width', 'controlField', 'controlVal'], + exec: ['label', 'OpenType', 'intertype', 'Ot', 'show', 'icon', 'class', 'execSuccess', 'execError', 'resetPageIndex', 'syncComponent', 'width', 'controlField', 'controlVal'], + excelIn: ['label', 'Ot', 'OpenType', 'intertype', 'show', 'icon', 'class', 'sheet', 'execSuccess', 'execError', 'resetPageIndex', 'syncComponent', 'width', 'controlField', 'controlVal'], + excelOut: ['label', 'OpenType', 'intertype', 'show', 'icon', 'class', 'execSuccess', 'execError', 'syncComponent', 'resetPageIndex', 'pagination', 'search', 'width', 'controlField', 'controlVal'], + popview: ['label', 'Ot', 'OpenType', 'show', 'icon', 'class', 'popClose', 'resetPageIndex', 'width', 'controlField', 'controlVal'], + tab: ['label', 'Ot', 'OpenType', 'show', 'icon', 'class', 'linkmenu', 'width', 'controlField', 'controlVal'], + innerpage: ['label', 'Ot', 'OpenType', 'pageTemplate', 'show', 'icon', 'class', 'width', 'open', 'controlField', 'controlVal'], + funcbutton: ['label', 'OpenType', 'funcType', 'show', 'icon', 'class', 'width', 'controlField', 'controlVal'] } -class MainSearch extends Component { +class ActionForm extends Component { static propTpyes = { dict: PropTypes.object, // 瀛楀吀椤� type: PropTypes.any, // type涓�"card"鏃讹紝鍙彲閫夊崟琛屾垨涓嶉�夎 @@ -34,6 +34,7 @@ openType: null, // 鎵撳紑鏂瑰紡 interType: null, // 鎺ュ彛绫诲瀷锛氬唴閮ㄣ�佸閮� funcType: null, // 鍔熻兘绫诲瀷 + procMode: null, // 鍙傛暟鏂瑰紡 requireOptions: [{ value: 'notRequired', text: this.props.dict['header.form.notRequired'] @@ -66,6 +67,19 @@ }, { value: 'custom', text: this.props.dict['header.form.custom'] + }], + interTypeOptions: [{ + value: 'system', + text: this.props.dict['model.interface.system'] + }, { + value: 'inner', + text: this.props.dict['model.interface.inner'] + }, { + value: 'outer', + text: this.props.dict['model.interface.outer'] + }, { + value: 'custom', + text: '鑷畾涔�' }] } @@ -75,17 +89,24 @@ let _opentype = card.OpenType // 鎵撳紑鏂瑰紡 let _intertype = card.intertype || 'system' // 鎺ュ彛绫诲瀷 - let _funcType = card.funcType || 'print' // 鍔熻兘鎸夐挳榛樿绫诲瀷 + let _funcType = card.funcType || '' // 鍔熻兘鎸夐挳榛樿绫诲瀷 + let _procMode = card.procMode || 'system' // 鍙傛暟璇锋眰鏂瑰紡 - let _options = this.getOptions(_opentype, _intertype, _funcType, card.pageTemplate) + let _options = this.getOptions(_opentype, _intertype, _funcType, card.pageTemplate, _procMode) this.setState({ openType: _opentype, interType: _intertype, + procMode: _procMode, funcType: _funcType, formlist: this.props.formlist.map(item => { if (item.key === 'class') { item.options = btnCustomClasses + } else if (item.key === 'innerFunc' && _procMode === 'inner') { + item.required = true + } 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') { @@ -93,7 +114,7 @@ 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)) { + } else if (['innerpage', 'tab', 'popview', 'excelIn'].includes(_opentype)) { item.options = this.state.requireOptions.filter(op => ['notRequired', 'requiredSgl'].includes(op.value)) } else if (card.sqlType === 'insert') { item.options = this.state.requireOptions.filter(op => ['notRequired', 'requiredSgl', 'required'].includes(op.value)) @@ -116,22 +137,26 @@ }) } - getOptions = (_opentype, _intertype, _funcType, _pageTemplate) => { - let _options = fromJS(actionTypeOptions[_opentype]).toJS() // 閫夐」鍒楄〃 + getOptions = (_opentype, _intertype, _funcType, _pageTemplate, _procMode) => { + let _options = actionTypeOptions[_opentype] ? fromJS(actionTypeOptions[_opentype]).toJS() : [] // 閫夐」鍒楄〃 if (_opentype === 'innerpage') { // 鏂伴〉闈紝鍙�夋ā鏉�(鑷畾涔夋椂锛屽彲濉叆澶栭儴閾炬帴) if (_pageTemplate === 'custom') { _options.push('url', 'joint') + } else if (_pageTemplate === 'page') { + _options.push('copyMenuId', 'joint') + } else if (_pageTemplate === 'linkpage') { + _options.push('linkmenu', 'joint') } } else if (_opentype === 'excelOut') { // 瀵煎叆瀵煎嚭 if (_intertype === 'outer') { - _options.push('innerFunc', 'sysInterface', 'interface', 'outerFunc') + _options.push('innerFunc', 'sysInterface', 'interface', 'proInterface', 'outerFunc') } else if (_intertype === 'inner') { _options.push('innerFunc') } } else if (_opentype === 'excelIn') { // 瀵煎叆瀵煎嚭 if (_intertype === 'outer') { - _options.push('innerFunc', 'sysInterface', 'interface', 'outerFunc', 'callbackFunc') + _options.push('innerFunc', 'sysInterface', 'interface', 'proInterface', 'outerFunc', 'callbackFunc') } else if (_intertype === 'inner') { _options.push('innerFunc') } @@ -139,14 +164,21 @@ if (_funcType === 'print') { _options.push('execMode', 'intertype', 'Ot', 'execSuccess', 'execError', 'resetPageIndex') if (_intertype === 'outer') { - _options.push('innerFunc', 'sysInterface', 'interface', 'outerFunc', 'callbackFunc') + _options.push('innerFunc', 'sysInterface', 'interface', 'proInterface', 'outerFunc', 'callbackFunc') } else if (_intertype === 'inner') { _options.push('innerFunc') } } } else if (_opentype !== 'popview' && _opentype !== 'tab') { - if (_intertype === 'outer') { - _options.push('innerFunc', 'sysInterface', 'interface', 'outerFunc', 'callbackFunc') + if (_intertype === 'custom') { + _options.push('procMode', 'interface', 'callbackType', 'cbTable', 'proInterface', 'method', 'cross') + if (_procMode === 'system') { + _options.push('sql', 'sqlType') + } else { + _options.push('innerFunc') + } + } else if (_intertype === 'outer') { + _options.push('innerFunc', 'sysInterface', 'interface', 'proInterface', 'outerFunc', 'callbackFunc') } else if (_intertype === 'inner') { _options.push('innerFunc') } else { @@ -176,25 +208,31 @@ * 2銆佹樉绀轰綅缃垏鎹紝閲嶇疆閫夋嫨琛� * 3銆佸垏鎹㈡爣绛剧被鍨嬶紝閲嶇疆鍙�夋爣绛� */ - openTypeChange = (key, value) => { + optionChange = (key, value) => { const { card, type } = this.props + const { openType, procMode } = this.state if (key === 'OpenType') { - let _options = this.getOptions(value, this.state.interType, this.state.funcType, card.pageTemplate) + let _options = this.getOptions(value, 'system', this.state.funcType, card.pageTemplate, 'system') let _fieldval = {} let _formlist = this.state.formlist.map(item => { item.hidden = !_options.includes(item.key) + if (item.key === 'intertype') { + let iscustom = ['pop', 'prompt', 'exec'].includes(value) + item.options = this.state.interTypeOptions.filter(op => (iscustom || op.value !== 'custom')) + } + if (item.hidden) return item if (item.key === 'intertype') { - _fieldval.intertype = this.state.interType + _fieldval.intertype = 'system' } else if (item.key === 'Ot') { if (type === 'card') { item.options = this.state.requireOptions.filter(op => ['notRequired', 'requiredSgl'].includes(op.value)) - } else if (['innerpage', 'blank', 'tab', 'popview'].includes(value)) { + } else if (['innerpage', 'tab', 'popview'].includes(value)) { item.options = this.state.requireOptions.filter(op => ['notRequired', 'requiredSgl'].includes(op.value)) _fieldval.Ot = 'requiredSgl' } else if (value === 'excelIn') { @@ -217,6 +255,8 @@ this.setState({ openType: value, + intertype: 'system', + procMode: 'system', formlist: _formlist }, () => { if (value === 'excelIn') { @@ -230,7 +270,7 @@ this.props.form.setFieldsValue(_fieldval) }) } else if (key === 'funcType') { - let _options = this.getOptions(this.state.openType, this.state.interType, value, card.pageTemplate) + let _options = this.getOptions(openType, this.state.interType, value, card.pageTemplate, procMode) let _fieldval = {} this.setState({ @@ -294,10 +334,9 @@ }) } else if (key === 'pageTemplate') { let _fieldval = {} - let _options = this.getOptions(this.state.openType, this.state.interType, this.state.funcType, value) + let _options = this.getOptions(openType, this.state.interType, this.state.funcType, value, procMode) this.setState({ - openType: value, formlist: this.state.formlist.map(item => { item.hidden = !_options.includes(item.key) @@ -317,16 +356,8 @@ }, () => { this.props.form.setFieldsValue(_fieldval) }) - } - } - - onChange = (e, key) => { - const { type } = this.props - const { openType } = this.state - let value = e.target.value - - if (key === 'intertype') { - let _options = this.getOptions(openType, value, this.state.funcType) + } else if (key === 'intertype') { + let _options = this.getOptions(openType, value, this.state.funcType, '', procMode) this.setState({ interType: value, @@ -346,10 +377,20 @@ } return item }) - }, () => { - if (this.props.form.getFieldValue('sqlType') !== undefined) { - this.props.form.setFieldsValue({sqlType: ''}) - } + }) + } else if (key === 'procMode') { + let _options = this.getOptions(openType, this.state.interType, this.state.funcType, '', value) + + this.setState({ + procMode: value, + formlist: this.state.formlist.map(item => { + item.hidden = !_options.includes(item.key) + + if (item.key === 'innerFunc') { + item.required = true + } + return item + }) }) } else if (key === 'sysInterface') { if (value === 'true') { @@ -433,6 +474,14 @@ </Form.Item> </Col> ) + } else if (item.type === 'tip') { + fields.push( + <Col span={12} key={index}> + <Form.Item label={item.label}> + {item} + </Form.Item> + </Col> + ) } else if (item.type === 'number') { fields.push( <Col span={12} key={index}> @@ -475,12 +524,12 @@ <Select showSearch filterOption={(input, option) => option.props.children[2].toLowerCase().indexOf(input.toLowerCase()) >= 0} - onChange={(value) => {this.openTypeChange(item.key, value)}} + 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 id={index} key={option.value || option.field} value={option.value || option.field}> + {item.key === 'icon' && option.value ? <Icon type={option.value} /> : ''} {option.text || option.label} </Select.Option> )} </Select> @@ -491,7 +540,12 @@ } else if (item.type === 'radio') { fields.push( <Col span={12} key={index}> - <Form.Item label={item.label}> + <Form.Item label={item.tooltip ? + <Tooltip placement="topLeft" overlayClassName={item.tooltipClass} title={item.tooltip}> + <Icon type="question-circle" /> + {item.label} + </Tooltip> : item.label + }> {getFieldDecorator(item.key, { initialValue: item.initVal, rules: [ @@ -501,7 +555,7 @@ } ] })( - <Radio.Group onChange={(e) => {this.onChange(e, item.key)}} disabled={item.readonly}> + <Radio.Group onChange={(e) => {this.optionChange(item.key, e.target.value)}} disabled={item.readonly}> { item.options.map(option => { return ( @@ -519,8 +573,14 @@ <Col span={24} key={index}> <Form.Item label={item.label} className="textarea"> {getFieldDecorator(item.key, { - initialValue: item.initVal - })(<TextArea rows={4} />)} + initialValue: item.initVal, + rules: [ + { + required: item.readonly ? false : !!item.required, + message: this.props.dict['form.required.input'] + item.label + '!' + } + ] + })(<TextArea rows={2} readOnly={item.readonly}/>)} </Form.Item> </Col> ) @@ -560,13 +620,14 @@ } handleConfirm = () => { - const { setting } = this.props + const { setting, card } = this.props // 琛ㄥ崟鎻愪氦鏃舵鏌ヨ緭鍏ュ�兼槸鍚︽纭� return new Promise((resolve, reject) => { this.props.form.validateFieldsAndScroll((err, values) => { if (!err) { - values.uuid = this.props.card.uuid - values.verify = this.props.card.verify || null + values.uuid = card.uuid + values.verify = card.verify || null + values.modal = card.modal || null if (values.show === 'icon' && !values.icon) { notification.warning({ @@ -587,8 +648,15 @@ values.Ot = 'notRequired' } else if (['pop', 'prompt', 'exec'].includes(values.OpenType) && values.verify) { - if ((values.Ot === 'requiredOnce' || this.props.card.Ot === 'requiredOnce') && this.props.card.Ot !== values.Ot) { + if ((values.Ot === 'requiredOnce' || card.Ot === 'requiredOnce') && card.Ot !== values.Ot) { values.verify.uniques = [] + } + if (card.Ot !== values.Ot) { + if (values.Ot === 'notRequired') { + values.verify.invalid = 'false' + } else if (card.Ot === 'notRequired' && values.Ot !== 'notRequired') { + values.verify.invalid = 'true' + } } } @@ -612,11 +680,11 @@ } } return ( - <Form {...formItemLayout} className="ant-advanced-search-form commontable-action-form" id="winter"> + <Form {...formItemLayout} className="menu-action-list-form" id="winter"> <Row gutter={24}>{this.getFields()}</Row> </Form> ) } } -export default Form.create()(MainSearch) \ No newline at end of file +export default Form.create()(ActionForm) \ No newline at end of file -- Gitblit v1.8.0