From 78eed586f6a0d15162c89878c53a301e7b142a8a Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期一, 10 十月 2022 00:07:06 +0800 Subject: [PATCH] Merge branch 'master' into positec --- src/menu/datasource/verifycard/settingform/index.jsx | 216 +++++++++++++++++++++++++++++++---------------------- 1 files changed, 125 insertions(+), 91 deletions(-) diff --git a/src/menu/datasource/verifycard/settingform/index.jsx b/src/menu/datasource/verifycard/settingform/index.jsx index cc9c58e..f0ff0c4 100644 --- a/src/menu/datasource/verifycard/settingform/index.jsx +++ b/src/menu/datasource/verifycard/settingform/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, Radio, Tooltip, notification, Select, InputNumber, Cascader } from 'antd' import { QuestionCircleOutlined } from '@ant-design/icons' @@ -22,18 +23,15 @@ } state = { - interType: this.props.setting.interType || 'system', - laypage: this.props.setting.laypage || 'true', + setting: null, modules: [], - usefulFields: [], - useMSearch: this.props.setting.useMSearch || 'false', - sysInterface: this.props.setting.sysInterface || 'false', - supModule: this.props.setting.supModule || [], + innerRules: [], + innertip: '', appType: sessionStorage.getItem('appType') } UNSAFE_componentWillMount () { - const { config } = this.props + const { config, setting } = this.props let modules = MenuUtils.getSupModules(window.GLOB.customMenu.components, config.uuid) || [] @@ -43,17 +41,36 @@ }) let usefulFields = sessionStorage.getItem('permFuncField') + let innerRules = [] + let innertip = '' if (usefulFields) { try { usefulFields = JSON.parse(usefulFields) + + if (usefulFields.length > 0) { + innertip = '寮�澶村彲鐢ㄥ瓧绗︼細' + usefulFields.join(', ') + let str = '^(' + usefulFields.join('|') + ')' + let _patten = new RegExp(str + formRule.func.innerPattern + '$', 'g') + + innerRules.push({ + pattern: _patten, + message: formRule.func.innerMessage + }) + } } catch (e) { - usefulFields = [] + innerRules = [] } - } else { - usefulFields = [] } - this.setState({modules, usefulFields}) + let _setting = fromJS(setting).toJS() + _setting.interType = setting.interType || 'system' + _setting.laypage = setting.laypage || 'true' + _setting.useMSearch = setting.useMSearch || 'false' + _setting.sysInterface = setting.sysInterface || 'false' + _setting.supModule = setting.supModule || [] + _setting.execute = setting.execute || 'true' + + this.setState({modules, innerRules, innertip, setting: _setting}) } handleConfirm = () => { @@ -69,15 +86,7 @@ } // 鏁版嵁婧愬墠绔獙璇� - if (values.interType === 'system' && values.execute !== 'false' && !values.dataresource) { - notification.warning({ - top: 92, - message: '璇峰~鍐欏唴閮ㄥ嚱鏁版垨鏁版嵁婧愶紒', - duration: 5 - }) - reject() - return - } else if (values.interType === 'system' && values.execute !== 'false' && values.dataresource) { + if (values.interType === 'system' && values.execute !== 'false' && values.dataresource) { let _quot = values.dataresource.match(/'{1}/g) let _lparen = values.dataresource.match(/\({1}/g) let _rparen = values.dataresource.match(/\){1}/g) @@ -133,35 +142,21 @@ }) } - onRadioChange = (e, key) => { - let value = e.target.value + onOptionChange = (value, key) => { + let setting = fromJS(this.state.setting).toJS() + setting[key] = value - if (key === 'interType') { - this.setState({ - interType: value - }) - } - } - - onSysInter = (e) => { - let value = e.target.value - - this.setState({ - sysInterface: value - }) - if (value === 'true') { + this.setState({setting}) + + if (key === 'sysInterface' && value === 'true') { this.props.form.setFieldsValue({interface: window.GLOB.mainSystemApi}) } } - changeSupModule = (val) => { - this.setState({supModule: val}) - } - render() { - const { setting, columns, config } = this.props + const { columns, config } = this.props const { getFieldDecorator } = this.props.form - const { interType, modules, useMSearch, laypage, supModule, usefulFields, appType, sysInterface } = this.state + const { setting, modules, innerRules, appType, innertip } = this.state const formItemLayout = { labelCol: { @@ -174,24 +169,23 @@ } } - let tooltip = null - let rules = [] - - if (usefulFields.length > 0) { - tooltip = '寮�澶村彲鐢ㄥ瓧绗︼細' + usefulFields.join(', ') - let str = '^(' + usefulFields.join('|') + ')' - let _patten = new RegExp(str + formRule.func.innerPattern + '$', 'g') - - rules.push({ - pattern: _patten, - message: formRule.func.innerMessage - }) - } - return ( <div className="model-datasource-setting-form-box"> <Form {...formItemLayout} className="model-setting-form"> <Row gutter={24}> + {config.type === 'interface' ? <Col span={8}> + <Form.Item label="鏁版嵁婧愬悕绉�"> + {getFieldDecorator('name', { + initialValue: setting.name, + rules: [ + { + required: true, + message: this.props.dict['form.required.input'] + '鏁版嵁婧愬悕绉�!' + } + ] + })(<Input placeholder={''} autoComplete="off" />)} + </Form.Item> + </Col> : null} <Col span={8}> <Form.Item label="琛ㄥ悕"> {getFieldDecorator('tableName', { @@ -204,6 +198,10 @@ { max: 50, message: '琛ㄥ悕鏈�闀夸负50涓瓧绗�!' + }, + { + pattern: /^[a-zA-Z_]+$/, + message: '琛ㄥ悕鍙彲浣跨敤瀛楁瘝浠ュ強_' } ] })(<Input placeholder={''} autoComplete="off" />)} @@ -212,7 +210,7 @@ <Col span={8}> <Form.Item label="鎺ュ彛绫诲瀷"> {getFieldDecorator('interType', { - initialValue: interType, + initialValue: setting.interType, rules: [ { required: true, @@ -220,17 +218,17 @@ }, ] })( - <Radio.Group onChange={(e) => {this.onRadioChange(e, 'interType')}}> + <Radio.Group onChange={(e) => {this.onOptionChange(e.target.value, 'interType')}}> <Radio value="system">绯荤粺</Radio> <Radio value="inner">鍐呴儴</Radio> <Radio value="outer">澶栭儴</Radio> </Radio.Group>)} </Form.Item> </Col> - {interType === 'outer' ? <Col span={8}> + {setting.interType === 'outer' ? <Col span={8}> <Form.Item label="绯荤粺鎺ュ彛"> {getFieldDecorator('sysInterface', { - initialValue: sysInterface, + initialValue: setting.sysInterface, rules: [ { required: true, @@ -238,15 +236,15 @@ } ] })( - <Radio.Group onChange={this.onSysInter}> + <Radio.Group onChange={(e) => {this.onOptionChange(e.target.value, 'sysInterface')}}> <Radio value="true">鏄�</Radio> <Radio value="false">鍚�</Radio> </Radio.Group>)} </Form.Item> </Col> : null} - {interType === 'inner' ? <Col span={8}> - <Form.Item label={tooltip ? - <Tooltip placement="topLeft" title={tooltip}> + {setting.interType === 'inner' ? <Col span={8}> + <Form.Item label={innertip ? + <Tooltip placement="topLeft" title={innertip}> <QuestionCircleOutlined className="mk-form-tip" /> 鍐呴儴鍑芥暟 </Tooltip> : '鍐呴儴鍑芥暟' @@ -258,25 +256,25 @@ required: true, message: this.props.dict['form.required.input'] + '鍐呴儴鍑芥暟!' }, - ...rules + ...innerRules ] })(<Input placeholder={''} autoComplete="off" />)} </Form.Item> </Col> : null} - {interType === 'outer' ? <Col className="outer-interface" span={24}> + {setting.interType === 'outer' ? <Col className="outer-interface" span={24}> <Form.Item label="鎺ュ彛鍦板潃"> {getFieldDecorator('interface', { - initialValue: setting.interface || (sysInterface === 'true' ? window.GLOB.mainSystemApi : ''), + initialValue: setting.interface || (setting.sysInterface === 'true' ? window.GLOB.mainSystemApi : ''), rules: [ { - required: sysInterface !== 'true' ? true : false, + required: setting.sysInterface !== 'true' ? true : false, message: this.props.dict['form.required.input'] + '鎺ュ彛鍦板潃!' } ] - })(<TextArea rows={2} readOnly={sysInterface === 'true'}/>)} + })(<TextArea rows={2} readOnly={setting.sysInterface === 'true'}/>)} </Form.Item> </Col> : null} - {interType === 'outer' && sysInterface !== 'true' ? <Col className="outer-interface" span={24}> + {setting.interType === 'outer' && setting.sysInterface !== 'true' ? <Col className="outer-interface" span={24}> <Form.Item label={<Tooltip placement="topLeft" title="姝e紡绯荤粺鎺ュ彛鍦板潃锛屼负绌烘椂浣跨敤鎺ュ彛鍦板潃"> <QuestionCircleOutlined className="mk-form-tip" /> 姝e紡鍦板潃 @@ -287,17 +285,14 @@ })(<TextArea rows={2}/>)} </Form.Item> </Col> : null} - {interType === 'outer' ? <Col span={8}> + {setting.interType === 'outer' ? <Col span={8}> <Form.Item label="澶栭儴鍑芥暟"> {getFieldDecorator('outerFunc', { - initialValue: setting.outerFunc || '', - rules: [ - - ] + initialValue: setting.outerFunc || '' })(<Input placeholder={''} autoComplete="off" />)} </Form.Item> </Col> : null} - {interType === 'system' ? <Col span={24} className="data-source" style={{paddingLeft: '7px'}}> + {setting.interType === 'system' ? <Col span={24} className="data-source" style={{paddingLeft: '7px'}}> <Form.Item labelCol={{xs: { span: 24 }, sm: { span: 2 }}} wrapperCol={ {xs: { span: 24 }, sm: { span: 22 }} } label={ <Tooltip placement="topLeft" title={`浣跨敤绯荤粺鍑芥暟鏃讹紝闇�濉啓鏁版嵁婧愩�傛敞锛氭暟鎹潈闄愭浛鎹㈢ $@ -> /* 鎴� ''銆� @$ -> */ 鎴� ''锛涙煡璇㈡浛鎹㈢ $select@ -> /* 鎴� ''銆� @select$ -> */ 鎴� ''锛涚粺璁℃浛鎹㈢ $sum@ -> /* 鎴� ''銆� @sum$ -> */ 鎴� ''銆俙}> <QuestionCircleOutlined className="mk-form-tip" /> @@ -305,11 +300,17 @@ </Tooltip> }> {getFieldDecorator('dataresource', { - initialValue: setting.dataresource || '' + initialValue: setting.dataresource || '', + rules: [ + { + required: setting.execute !== 'false' ? true : false, + message: this.props.dict['form.required.input'] + '鏁版嵁婧�!' + } + ] })(<CodeMirror />)} </Form.Item> </Col> : null} - {interType === 'system' ? <Col span={8}> + {setting.interType === 'system' ? <Col span={8}> <Form.Item label={ <Tooltip placement="topLeft" title={'鏌ヨ鏃讹紝鎼滅储鏉′欢浠here鏉′欢鎷兼帴杩涘叆sql锛岀粺璁℃椂锛屽皢鏁版嵁婧愪腑浠モ�淍+鎼滅储瀛楁+@鈥濈殑鍐呭锛屼互鎼滅储鏉′欢涓殑鍊艰繘琛屾浛鎹㈠悗锛屾彁浜ゆ煡璇紝娉細鏌ヨ绫诲瀷浠呭湪浣跨敤绯荤粺鍑芥暟鏃舵湁鏁堛��'}> <QuestionCircleOutlined className="mk-form-tip" /> @@ -354,18 +355,18 @@ })(<Input placeholder={'ID asc, UID desc'} autoComplete="off" />)} </Form.Item> </Col> : null} - {interType === 'system' ? <Col span={8}> + {setting.interType === 'system' ? <Col span={8}> <Form.Item label="榛樿sql"> {getFieldDecorator('execute', { - initialValue: setting.execute || 'true' + initialValue: setting.execute })( - <Radio.Group> + <Radio.Group onChange={(e) => {this.onOptionChange(e.target.value, 'execute')}}> <Radio value="true">鎵ц</Radio> <Radio value="false">涓嶆墽琛�</Radio> </Radio.Group>)} </Form.Item> </Col> : null} - {!['navbar', 'balcony', 'menubar'].includes(config.type) && (!config.wrap || config.wrap.supType !== 'multi') ? <Col span={8}> + {!['navbar', 'balcony', 'menubar', 'interface'].includes(config.type) && (!config.wrap || config.wrap.supType !== 'multi') ? <Col span={8}> <Form.Item label={ <Tooltip placement="topLeft" title={'璇ョ粍浠跺鏋滃彈鍏朵粬缁勪欢鎺у埗锛岃閫夐」鐩稿簲鐨勭粍浠讹紝娌℃湁鏃堕�夆�滄棤鈥濄��'}> <QuestionCircleOutlined className="mk-form-tip" /> @@ -373,7 +374,7 @@ </Tooltip> }> {getFieldDecorator('supModule', { - initialValue: supModule, + initialValue: setting.supModule, rules: [ { required: true, @@ -381,7 +382,7 @@ } ] })( - <Cascader options={modules} onChange={this.changeSupModule} expandTrigger="hover" placeholder="" /> + <Cascader options={modules} onChange={(val) => {this.onOptionChange(val, 'supModule')}} expandTrigger="hover" placeholder="" /> )} </Form.Item> </Col> : null} @@ -390,14 +391,14 @@ {getFieldDecorator('laypage', { initialValue: setting.laypage || 'true' })( - <Radio.Group onChange={(e) => this.setState({laypage: e.target.value})}> + <Radio.Group onChange={(e) => {this.onOptionChange(e.target.value, 'laypage')}}> <Radio value="true">鏄�</Radio> <Radio value="false">鍚�</Radio> </Radio.Group> )} </Form.Item> </Col> : null} - {config.pageable && laypage !== 'false' ? <Col span={8}> + {config.pageable && setting.laypage !== 'false' ? <Col span={8}> <Form.Item label={ <Tooltip placement="topLeft" title="閫夋嫨鍒嗛〉鏃舵湁鏁堛��"> <QuestionCircleOutlined className="mk-form-tip" /> @@ -416,7 +417,7 @@ </Form.Item> </Col> : null} {/* 1銆佷笉鍒嗛〉涓斾笉瀛樺湪涓婄骇妯″潡 */} - {!['navbar'].includes(config.type) && !['editable'].includes(config.subtype) && (!config.pageable || (config.pageable && laypage === 'false')) && (!supModule || supModule.length === 0 || supModule[0] === 'empty') ? <Col span={8}> + {!['navbar', 'interface'].includes(config.type) && !['editable'].includes(config.subtype) && (!config.pageable || (config.pageable && setting.laypage === 'false')) && (setting.supModule.length === 0 || setting.supModule[0] === 'empty') ? <Col span={8}> <Form.Item label={ <Tooltip placement="topLeft" title={'鍒濆鍖栧姞杞芥椂锛屾槸鍚︿笌鍏朵粬缁勪欢涓�鍚屽姞杞芥暟鎹紝娉細浠呭湪浣跨敤绯荤粺鍑芥暟锛屼笖鍒濆鍖栧姞杞芥暟鎹椂鏈夋晥锛屽垎椤佃姹傛椂鏃犳晥銆�'}> <QuestionCircleOutlined className="mk-form-tip" /> @@ -433,7 +434,7 @@ )} </Form.Item> </Col> : null} - {!['navbar', 'balcony', 'menubar'].includes(config.type) ? <Col span={8}> + {!['navbar', 'balcony', 'menubar', 'interface'].includes(config.type) ? <Col span={8}> <Form.Item label={ <Tooltip placement="topLeft" title={'浼樺厛浣跨敤鍚岀骇鐨勬悳绱㈡潯浠剁粍浠讹紝鍚岀骇鎼滅储涓嶅瓨鍦ㄦ椂锛屼緷娆″悜涓婇�夊彇锛屼笌褰撳墠缁勪欢鐨勬悳绱㈡潯浠朵竴鍚岀敤浣滄暟鎹繃婊わ紙褰撳墠缁勪欢鐨勬悳绱㈡潯浠朵紭鍏堬級銆�'}> <QuestionCircleOutlined className="mk-form-tip" /> @@ -443,14 +444,14 @@ {getFieldDecorator('useMSearch', { initialValue: setting.useMSearch || 'true' })( - <Radio.Group onChange={(e) => this.setState({useMSearch: e.target.value})}> + <Radio.Group onChange={(e) => {this.onOptionChange(e.target.value, 'useMSearch')}}> <Radio value="true">浣跨敤</Radio> <Radio value="false">涓嶄娇鐢�</Radio> </Radio.Group> )} </Form.Item> </Col> : null} - {!['navbar', 'balcony', 'menubar'].includes(config.type) && useMSearch === 'true' && appType !== 'mob' ? <Col span={8}> + {!['navbar', 'balcony', 'menubar', 'interface'].includes(config.type) && setting.useMSearch === 'true' && appType !== 'mob' ? <Col span={8}> <Form.Item label={ <Tooltip placement="topLeft" title={'澶栧眰鎼滅储鏉′欢鏀瑰彉鏃讹紝鏄惁鍒锋柊褰撳墠缁勪欢鏁版嵁銆�'}> <QuestionCircleOutlined className="mk-form-tip" /> @@ -478,7 +479,7 @@ </Radio.Group>)} </Form.Item> </Col> - {!['navbar', 'balcony', 'menubar'].includes(config.type) ? <Col span={8}> + {!['navbar', 'balcony', 'menubar', 'interface'].includes(config.type) ? <Col span={8}> <Form.Item label="鍒濆鍖栨暟鎹�"> {getFieldDecorator('onload', { initialValue: setting.onload || 'true' @@ -490,6 +491,39 @@ )} </Form.Item> </Col> : null} + {config.type === 'interface' ? <Col span={8}> + <Form.Item label="瀹氭椂鍣�"> + {getFieldDecorator('timer', { + initialValue: setting.timer || '' + })( + <Select onChange={(value) => {this.onOptionChange(value, 'timer')}}> + <Select.Option value=""> 鏃� </Select.Option> + <Select.Option value="2s"> 2绉� </Select.Option> + <Select.Option value="5s"> 5绉� </Select.Option> + <Select.Option value="15s"> 15绉� </Select.Option> + <Select.Option value="30s"> 30绉� </Select.Option> + <Select.Option value="1min"> 1鍒嗛挓 </Select.Option> + <Select.Option value="5min"> 5鍒嗛挓 </Select.Option> + <Select.Option value="10min"> 10鍒嗛挓 </Select.Option> + <Select.Option value="15min"> 15鍒嗛挓 </Select.Option> + <Select.Option value="30min"> 30鍒嗛挓 </Select.Option> + <Select.Option value="1hour"> 1灏忔椂 </Select.Option> + </Select> + )} + </Form.Item> + </Col> : null} + {config.type === 'interface' && setting.timer ? <Col span={8}> + <Form.Item label={ + <Tooltip placement="topLeft" title="瀹氭椂鍣ㄦ墽琛屾鏁般�傛敞锛�0琛ㄧず娌℃湁闄愬埗銆�"> + <QuestionCircleOutlined className="mk-form-tip" /> + 鎵ц娆℃暟 + </Tooltip> + }> + {getFieldDecorator('timerRepeats', { + initialValue: setting.timerRepeats || 0 + })(<InputNumber min={0} max={500} precision={0} />)} + </Form.Item> + </Col> : null} </Row> </Form> </div> -- Gitblit v1.8.0