From d59f518f466274b2caeb2e01c10c92deafe7c93b Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期三, 09 二月 2022 11:48:29 +0800 Subject: [PATCH] 2022-02-09 --- src/menu/datasource/verifycard/settingform/index.jsx | 234 +++++++++++++++++++++++++++++++-------------------------- 1 files changed, 127 insertions(+), 107 deletions(-) diff --git a/src/menu/datasource/verifycard/settingform/index.jsx b/src/menu/datasource/verifycard/settingform/index.jsx index de9225c..72fc91f 100644 --- a/src/menu/datasource/verifycard/settingform/index.jsx +++ b/src/menu/datasource/verifycard/settingform/index.jsx @@ -1,101 +1,72 @@ import React, {Component} from 'react' import PropTypes from 'prop-types' -import { Form, Row, Col, Input, Radio, Tooltip, Icon, notification, Select, InputNumber, Cascader } from 'antd' +import { Form, Row, Col, Input, Radio, Tooltip, notification, Select, InputNumber, Cascader } from 'antd' +import { QuestionCircleOutlined } from '@ant-design/icons' import { formRule } from '@/utils/option.js' import Utils from '@/utils/utils.js' +import MenuUtils from '@/utils/utils-custom.js' import CodeMirror from '@/templates/zshare/codemirror' import './index.scss' + +const { TextArea } = Input class SettingForm extends Component { static propTpyes = { dict: PropTypes.object, // 瀛楀吀椤� - menu: PropTypes.any, // 鑿滃崟閰嶇疆淇℃伅 config: PropTypes.object, // 缁勪欢閰嶇疆 setting: PropTypes.object, // 鏁版嵁婧愰厤缃� - modules: PropTypes.array, // 鍒楄缃� + modules: PropTypes.array, // 鍙粦瀹氱殑涓婄骇缁勪欢 columns: PropTypes.array, // 鍒楄缃� scripts: PropTypes.array, // 鑷畾涔夎剼鏈� } state = { interType: this.props.setting.interType || 'system', + laypage: this.props.setting.laypage || 'true', modules: [], - useMSearch: this.props.setting.useMSearch || 'false' + usefulFields: [], + useMSearch: this.props.setting.useMSearch || 'false', + supModule: this.props.setting.supModule || [], + appType: sessionStorage.getItem('appType') } UNSAFE_componentWillMount () { - const { menu, config } = this.props + const { config } = this.props - let modules = this.getModules(menu.components, config.uuid) - if (!modules) { - modules = [] - } + let modules = MenuUtils.getSupModules(window.GLOB.customMenu.components, config.uuid) || [] modules.unshift({ value: 'empty', label: '鏃�' }) - this.setState({modules}) - } - - getModules = (components, selfId) => { - let modules = components.map(item => { - if (item.uuid === selfId) { - return { - children: null - } - } else if (item.switchable) { - return { - value: item.uuid, - label: item.name - } - } else if (item.type === 'tabs') { - let _item = { - value: item.uuid, - label: item.name, - children: item.subtabs.map(f_tab => { - let subItem = { - value: f_tab.uuid, - label: f_tab.label, - children: this.getModules(f_tab.components, selfId) - } - - if (!subItem.children || subItem.children.length === 0) { - return {children: null} - } - return subItem - }) - } - - _item.children = _item.children.filter(t => t.children !== null) - - if (_item.children.length === 0) { - return {children: null} - } - - return _item - } else { - return { - children: null - } + let usefulFields = sessionStorage.getItem('permFuncField') + if (usefulFields) { + try { + usefulFields = JSON.parse(usefulFields) + } catch (e) { + usefulFields = [] } - }) - - modules = modules.filter(mod => mod.children !== null) - - if (modules.length === 0) { - return null + } else { + usefulFields = [] } - return modules + + this.setState({modules, usefulFields}) } handleConfirm = () => { + const { appType } = this.state // 琛ㄥ崟鎻愪氦鏃舵鏌ヨ緭鍏ュ�兼槸鍚︽纭� return new Promise((resolve, reject) => { this.props.form.validateFieldsAndScroll((err, values) => { if (!err) { + values.sync = values.sync || 'false' + + if (appType === 'mob' && values.useMSearch === 'true') { + values.syncRefresh = 'true' + } + // 鏁版嵁婧愬墠绔獙璇� if (values.interType === 'system' && values.execute !== 'false' && !values.dataresource) { notification.warning({ @@ -171,10 +142,22 @@ } } + onSysInter = (e) => { + let value = e.target.value + + if (value === 'true') { + this.props.form.setFieldsValue({interface: window.GLOB.mainSystemApi}) + } + } + + changeSupModule = (val) => { + this.setState({supModule: val}) + } + render() { - const { setting, menu, columns, config } = this.props + const { setting, columns, config } = this.props const { getFieldDecorator } = this.props.form - const { interType, modules, useMSearch } = this.state + const { interType, modules, useMSearch, laypage, supModule, usefulFields, appType } = this.state const formItemLayout = { labelCol: { @@ -190,9 +173,9 @@ let tooltip = null let rules = [] - if (menu.permFuncField && menu.permFuncField.length > 0) { - tooltip = '寮�澶村彲鐢ㄥ瓧绗︼細' + menu.permFuncField.join(', ') - let str = '^(' + menu.permFuncField.join('|') + ')' + if (usefulFields.length > 0) { + tooltip = '寮�澶村彲鐢ㄥ瓧绗︼細' + usefulFields.join(', ') + let str = '^(' + usefulFields.join('|') + ')' let _patten = new RegExp(str + formRule.func.innerPattern + '$', 'g') rules.push({ @@ -205,7 +188,6 @@ <div className="model-datasource-setting-form-box"> <Form {...formItemLayout} className="model-setting-form"> <Row gutter={24}> - <Col span={8}> <Form.Item label="琛ㄥ悕"> {getFieldDecorator('tableName', { @@ -215,6 +197,10 @@ required: true, message: this.props.dict['form.required.input'] + '琛ㄥ悕!' }, + { + max: 50, + message: '琛ㄥ悕鏈�闀夸负50涓瓧绗�!' + } ] })(<Input placeholder={''} autoComplete="off" />)} </Form.Item> @@ -237,10 +223,21 @@ </Radio.Group>)} </Form.Item> </Col> + {interType === 'outer' ? <Col span={8}> + <Form.Item label="绯荤粺鎺ュ彛"> + {getFieldDecorator('sysInterface', { + initialValue: setting.sysInterface || 'false' + })( + <Radio.Group onChange={this.onSysInter}> + <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}> - <Icon type="question-circle" /> + <QuestionCircleOutlined className="mk-form-tip" /> 鍐呴儴鍑芥暟 </Tooltip> : '鍐呴儴鍑芥暟' }> @@ -256,7 +253,7 @@ })(<Input placeholder={''} autoComplete="off" />)} </Form.Item> </Col> : null} - {interType === 'outer' ? <Col span={8}> + {interType === 'outer' ? <Col className="outer-interface" span={24}> <Form.Item label="鎺ュ彛鍦板潃"> {getFieldDecorator('interface', { initialValue: setting.interface || '', @@ -266,7 +263,18 @@ message: this.props.dict['form.required.input'] + '鎺ュ彛鍦板潃!' } ] - })(<Input placeholder={''} autoComplete="off" />)} + })(<TextArea rows={2}/>)} + </Form.Item> + </Col> : null} + {interType === 'outer' ? <Col className="outer-interface" span={24}> + <Form.Item label={<Tooltip placement="topLeft" title="姝e紡绯荤粺鎺ュ彛鍦板潃锛屼负绌烘椂浣跨敤鎺ュ彛鍦板潃"> + <QuestionCircleOutlined className="mk-form-tip" /> + 姝e紡鍦板潃 + </Tooltip> + }> + {getFieldDecorator('proInterface', { + initialValue: setting.proInterface || '' + })(<TextArea rows={2}/>)} </Form.Item> </Col> : null} {interType === 'outer' ? <Col span={8}> @@ -281,8 +289,8 @@ </Col> : null} {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={'浣跨敤绯荤粺鍑芥暟鏃讹紝闇�濉啓鏁版嵁婧愩�傛敞锛氭暟鎹潈闄愭浛鎹㈢ $@ -> /* 鎴� \'\'銆� @$ -> */ 鎴� \'\''}> - <Icon type="question-circle" /> + <Tooltip placement="topLeft" title={`浣跨敤绯荤粺鍑芥暟鏃讹紝闇�濉啓鏁版嵁婧愩�傛敞锛氭暟鎹潈闄愭浛鎹㈢ $@ -> /* 鎴� ''銆� @$ -> */ 鎴� ''锛涙煡璇㈡浛鎹㈢ $select@ -> /* 鎴� ''銆� @select$ -> */ 鎴� ''锛涚粺璁℃浛鎹㈢ $sum@ -> /* 鎴� ''銆� @sum$ -> */ 鎴� ''銆俙}> + <QuestionCircleOutlined className="mk-form-tip" /> 鏁版嵁婧� </Tooltip> }> @@ -294,7 +302,7 @@ {interType === 'system' ? <Col span={8}> <Form.Item label={ <Tooltip placement="topLeft" title={'鏌ヨ鏃讹紝鎼滅储鏉′欢浠here鏉′欢鎷兼帴杩涘叆sql锛岀粺璁℃椂锛屽皢鏁版嵁婧愪腑浠モ�淍+鎼滅储瀛楁+@鈥濈殑鍐呭锛屼互鎼滅储鏉′欢涓殑鍊艰繘琛屾浛鎹㈠悗锛屾彁浜ゆ煡璇紝娉細鏌ヨ绫诲瀷浠呭湪浣跨敤绯荤粺鍑芥暟鏃舵湁鏁堛��'}> - <Icon type="question-circle" /> + <QuestionCircleOutlined className="mk-form-tip" /> 鏌ヨ绫诲瀷 </Tooltip> }> @@ -326,7 +334,7 @@ {config.format === 'array' ? <Col span={8}> <Form.Item label="榛樿鎺掑簭"> {getFieldDecorator('order', { - initialValue: setting.order || '', + initialValue: setting.order || 'ID desc', rules: [ { required: true, @@ -347,59 +355,42 @@ </Radio.Group>)} </Form.Item> </Col> : null} - <Col span={8}> + {!['navbar', 'balcony', 'menubar'].includes(config.type) && (!config.wrap || config.wrap.supType !== 'multi') ? <Col span={8}> <Form.Item label={ <Tooltip placement="topLeft" title={'璇ョ粍浠跺鏋滃彈鍏朵粬缁勪欢鎺у埗锛岃閫夐」鐩稿簲鐨勭粍浠讹紝娌℃湁鏃堕�夆�滄棤鈥濄��'}> - <Icon type="question-circle" /> - 涓婄骇妯″潡 + <QuestionCircleOutlined className="mk-form-tip" /> + 涓婄骇缁勪欢 </Tooltip> }> {getFieldDecorator('supModule', { - initialValue: setting.supModule || [], + initialValue: supModule, rules: [ { required: true, - message: this.props.dict['form.required.select'] + '涓婄骇妯″潡!' + message: this.props.dict['form.required.select'] + '涓婄骇缁勪欢!' } ] })( - <Cascader options={modules} expandTrigger="hover" placeholder="" /> - )} - </Form.Item> - </Col> - {!config.pageable ? <Col span={8}> - <Form.Item label={ - <Tooltip placement="topLeft" title={'鍒濆鍖栧姞杞芥椂锛屾槸鍚︿笌鍏朵粬缁勪欢涓�鍚屽姞杞芥暟鎹紝娉細浠呭湪浣跨敤绯荤粺鍑芥暟锛屼笖鍒濆鍖栧姞杞芥暟鎹椂鏈夋晥锛屽垎椤佃姹傛椂鏃犳晥銆�'}> - <Icon type="question-circle" /> - 鍚屾鏌ヨ - </Tooltip> - }> - {getFieldDecorator('sync', { - initialValue: setting.sync || 'true' - })( - <Radio.Group> - <Radio value="true">鏄�</Radio> - <Radio value="false">鍚�</Radio> - </Radio.Group> + <Cascader options={modules} onChange={this.changeSupModule} expandTrigger="hover" placeholder="" /> )} </Form.Item> </Col> : null} {config.pageable ? <Col span={8}> <Form.Item label="鍒嗛〉"> {getFieldDecorator('laypage', { - initialValue: setting.laypage || 'false' + initialValue: setting.laypage || 'true' })( - <Radio.Group> + <Radio.Group onChange={(e) => this.setState({laypage: e.target.value})}> <Radio value="true">鏄�</Radio> <Radio value="false">鍚�</Radio> </Radio.Group> )} </Form.Item> </Col> : null} - {config.pageable ? <Col span={8}> + {config.pageable && laypage !== 'false' ? <Col span={8}> <Form.Item label={ <Tooltip placement="topLeft" title="閫夋嫨鍒嗛〉鏃舵湁鏁堛��"> - <Icon type="question-circle" /> + <QuestionCircleOutlined className="mk-form-tip" /> 姣忛〉鏁伴噺 </Tooltip> }> @@ -414,15 +405,33 @@ })(<InputNumber min={1} max={500} precision={0} />)} </Form.Item> </Col> : null} - <Col span={8}> + {/* 1銆佷笉鍒嗛〉涓斾笉瀛樺湪涓婄骇妯″潡 */} + {!['navbar'].includes(config.type) && (!config.pageable || (config.pageable && laypage === 'false')) && (!supModule || supModule.length === 0 || supModule[0] === 'empty') ? <Col span={8}> + <Form.Item label={ + <Tooltip placement="topLeft" title={'鍒濆鍖栧姞杞芥椂锛屾槸鍚︿笌鍏朵粬缁勪欢涓�鍚屽姞杞芥暟鎹紝娉細浠呭湪浣跨敤绯荤粺鍑芥暟锛屼笖鍒濆鍖栧姞杞芥暟鎹椂鏈夋晥锛屽垎椤佃姹傛椂鏃犳晥銆�'}> + <QuestionCircleOutlined className="mk-form-tip" /> + 鍚屾鏌ヨ + </Tooltip> + }> + {getFieldDecorator('sync', { + initialValue: setting.sync || 'true' + })( + <Radio.Group> + <Radio value="true">鏄�</Radio> + <Radio value="false">鍚�</Radio> + </Radio.Group> + )} + </Form.Item> + </Col> : null} + {!['navbar', 'balcony', 'menubar'].includes(config.type) ? <Col span={8}> <Form.Item label={ <Tooltip placement="topLeft" title={'浼樺厛浣跨敤鍚岀骇鐨勬悳绱㈡潯浠剁粍浠讹紝鍚岀骇鎼滅储涓嶅瓨鍦ㄦ椂锛屼緷娆″悜涓婇�夊彇锛屼笌褰撳墠缁勪欢鐨勬悳绱㈡潯浠朵竴鍚岀敤浣滄暟鎹繃婊わ紙褰撳墠缁勪欢鐨勬悳绱㈡潯浠朵紭鍏堬級銆�'}> - <Icon type="question-circle" /> - 澶栧眰鎼滅储 + <QuestionCircleOutlined className="mk-form-tip" /> + 澶栭儴鎼滅储 </Tooltip> }> {getFieldDecorator('useMSearch', { - initialValue: setting.useMSearch || 'false' + initialValue: setting.useMSearch || 'true' })( <Radio.Group onChange={(e) => this.setState({useMSearch: e.target.value})}> <Radio value="true">浣跨敤</Radio> @@ -430,11 +439,11 @@ </Radio.Group> )} </Form.Item> - </Col> - {useMSearch === 'true' ? <Col span={8}> + </Col> : null} + {!['navbar', 'balcony', 'menubar'].includes(config.type) && useMSearch === 'true' && appType !== 'mob' ? <Col span={8}> <Form.Item label={ <Tooltip placement="topLeft" title={'澶栧眰鎼滅储鏉′欢鏀瑰彉鏃讹紝鏄惁鍒锋柊褰撳墠缁勪欢鏁版嵁銆�'}> - <Icon type="question-circle" /> + <QuestionCircleOutlined className="mk-form-tip" /> 鍚屾鍒锋柊 </Tooltip> }> @@ -449,6 +458,17 @@ </Form.Item> </Col> : null} <Col span={8}> + <Form.Item label="浜嬪姟"> + {getFieldDecorator('transaction', { + initialValue: setting.transaction || 'false' + })( + <Radio.Group> + <Radio value="true">浣跨敤</Radio> + <Radio value="false">涓嶄娇鐢�</Radio> + </Radio.Group>)} + </Form.Item> + </Col> + {!['navbar', 'balcony', 'menubar'].includes(config.type) ? <Col span={8}> <Form.Item label="鍒濆鍖栨暟鎹�"> {getFieldDecorator('onload', { initialValue: setting.onload || 'true' @@ -459,7 +479,7 @@ </Radio.Group> )} </Form.Item> - </Col> + </Col> : null} </Row> </Form> </div> -- Gitblit v1.8.0