From d36c27e80e668b3bc1dcd687a18a2f2d125b32db Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期日, 24 一月 2021 02:15:12 +0800 Subject: [PATCH] 2021-01-24 --- src/templates/sharecomponent/settingcomponent/settingform/simplescript/index.jsx | 417 +++++++++++++++++ src/components/header/index.jsx | 4 src/templates/formtabconfig/index.jsx | 1 src/templates/zshare/verifycard/callbackcustomscript/index.jsx | 11 src/tabviews/scriptmanage/config.jsx | 4 src/templates/comtableconfig/index.jsx | 7 src/templates/zshare/verifycard/customscript/index.jsx | 3 src/locales/zh-CN/model.js | 3 src/templates/sharecomponent/settingcomponent/settingform/simplescript/index.scss | 45 + src/api/index.js | 1 src/locales/en-US/model.js | 3 src/templates/sharecomponent/settingcalcomponent/verifycard/index.jsx | 2 src/templates/sharecomponent/settingcomponent/settingform/index.jsx | 123 +++- src/templates/sharecomponent/actioncomponent/index.scss | 6 src/tabviews/zshare/actionList/normalbutton/index.jsx | 178 +++++++ src/templates/sharecomponent/actioncomponent/verifyexcelin/index.jsx | 3 src/menu/datasource/verifycard/index.jsx | 3 src/tabviews/scriptmanage/actionList/index.jsx | 2 src/mob/datasource/verifycard/index.jsx | 3 src/menu/components/card/cardcellcomponent/index.jsx | 1 src/templates/zshare/formconfig.jsx | 56 + src/menu/components/share/actioncomponent/actionform/index.scss | 6 src/menu/components/share/actioncomponent/formconfig.jsx | 89 ++ src/templates/sharecomponent/actioncomponent/actionform/index.jsx | 47 + src/templates/sharecomponent/settingcomponent/settingform/datasource/index.jsx | 170 ++++++- src/templates/zshare/verifycard/index.jsx | 124 ---- src/menu/components/share/actioncomponent/index.jsx | 3 src/templates/sharecomponent/treesettingcomponent/settingform/index.jsx | 3 src/menu/components/share/actioncomponent/actionform/index.jsx | 88 ++- src/templates/sharecomponent/actioncomponent/index.jsx | 2 src/tabviews/scriptmanage/index.jsx | 2 src/templates/zshare/customscript/index.jsx | 3 32 files changed, 1,135 insertions(+), 278 deletions(-) diff --git a/src/api/index.js b/src/api/index.js index 8e671f6..a906a36 100644 --- a/src/api/index.js +++ b/src/api/index.js @@ -134,7 +134,6 @@ } _url = window.btoa(_url) - params.url = '/trans/redirect?rd=' + _url + '&method=' + method return axios(params) diff --git a/src/components/header/index.jsx b/src/components/header/index.jsx index 5a25fd9..5d9c7b7 100644 --- a/src/components/header/index.jsx +++ b/src/components/header/index.jsx @@ -673,10 +673,6 @@ console.warn('websql 鍒濆鍖栭敊璇紒') }) }, 1000) - - // Api.directRequest('https://www.sogou.com/suggnew/ajajjson', 'get', {type: 'web', key: '#content#'}).then(res => { - // }, (e) => { - // }) } shouldComponentUpdate (nextProps, nextState) { diff --git a/src/locales/en-US/model.js b/src/locales/en-US/model.js index a806926..799732f 100644 --- a/src/locales/en-US/model.js +++ b/src/locales/en-US/model.js @@ -247,6 +247,5 @@ 'model.tooltip.action.guide': '鍦ㄥ乏渚у伐鍏锋爮銆婃寜閽�嬩腑锛岄�夋嫨瀵瑰簲绫诲瀷鐨勬寜閽嫋鑷虫澶勬坊鍔狅紝濡傞�夋嫨鎸夐挳绫诲瀷涓鸿〃鍗曘�佹柊鏍囩椤电瓑鍚湁閰嶇疆椤甸潰鐨勬寜閽紝鍙湪宸︿晶宸ュ叿鏍�-鎸夐挳-鍙厤缃寜閽锛岀偣鍑绘寜閽畬鎴愮浉鍏抽厤缃�傛敞锛氬綋璁剧疆鎸夐挳鏄剧ず浣嶇疆涓鸿〃鏍兼椂锛屾樉绀哄垪浼氬鍔犳搷浣滃垪銆�', 'model.tooltip.column.guide': '鍦ㄥ乏渚у伐鍏锋爮銆婃樉绀哄垪銆嬩腑锛岄�夋嫨瀵瑰簲绫诲瀷鐨勬樉绀哄垪鎷栬嚦姝ゅ娣诲姞锛涙垨鐐瑰嚮銆婃坊鍔犳樉绀哄垪銆嬫寜閽壒閲忔坊鍔狅紝閫夋嫨鎵归噺娣诲姞鏃讹紝闇�鎻愬墠閫夋嫨浣跨敤琛ㄣ�傛敞锛氭坊鍔犲悎骞跺垪鏃讹紝闇�璁剧疆鍙�夊垪銆�', 'model.tooltip.tabs.guide': '鍦ㄥ乏渚у伐鍏锋爮銆婃爣绛鹃〉銆嬩腑锛岄�夋嫨瀵瑰簲绫诲瀷鐨勬爣绛鹃〉鎷栬嚦姝ゅ娣诲姞銆�', - 'model.tooltip.func.innerface': '鍐呴儴鎺ュ彛: 鍙嚜瀹氫箟鏁版嵁澶勭悊鍑芥暟锛屽嚱鏁板悕绉伴渶浠ableField绛夊瓧绗﹀紑濮�;', - 'model.tooltip.func.outface': '澶栭儴鎺ュ彛: 鍙嚜瀹氫箟鏁版嵁澶勭悊鍑芥暟锛屾彁浜ゆ暟鎹粡杩囧唴閮ㄥ嚱鏁板鐞嗗悗锛屼紶鍏ュ閮ㄦ帴鍙o紝鏈缃椂锛屾暟鎹細鐩存帴浼犲叆澶栭儴鎺ュ彛銆�', + 'model.tooltip.func.innerface': '鍐呴儴鍑芥暟鍚嶇О闇�浠ableField绛夊瓧绗﹀紑濮�;', } \ No newline at end of file diff --git a/src/locales/zh-CN/model.js b/src/locales/zh-CN/model.js index bbdcebd..0367a1b 100644 --- a/src/locales/zh-CN/model.js +++ b/src/locales/zh-CN/model.js @@ -247,6 +247,5 @@ 'model.tooltip.action.guide': '鍦ㄥ乏渚у伐鍏锋爮銆婃寜閽�嬩腑锛岄�夋嫨瀵瑰簲绫诲瀷鐨勬寜閽嫋鑷虫澶勬坊鍔狅紝濡傞�夋嫨鎸夐挳绫诲瀷涓鸿〃鍗曘�佹柊鏍囩椤电瓑鍚湁閰嶇疆椤甸潰鐨勬寜閽紝鍙湪宸︿晶宸ュ叿鏍�-鎸夐挳-鍙厤缃寜閽锛岀偣鍑绘寜閽畬鎴愮浉鍏抽厤缃�傛敞锛氬綋璁剧疆鎸夐挳鏄剧ず浣嶇疆涓鸿〃鏍兼椂锛屾樉绀哄垪浼氬鍔犳搷浣滃垪銆�', 'model.tooltip.column.guide': '鍦ㄥ乏渚у伐鍏锋爮銆婃樉绀哄垪銆嬩腑锛岄�夋嫨瀵瑰簲绫诲瀷鐨勬樉绀哄垪鎷栬嚦姝ゅ娣诲姞锛涙垨鐐瑰嚮銆婃坊鍔犳樉绀哄垪銆嬫寜閽壒閲忔坊鍔狅紝閫夋嫨鎵归噺娣诲姞鏃讹紝闇�鎻愬墠閫夋嫨浣跨敤琛ㄣ�傛敞锛氭坊鍔犲悎骞跺垪鏃讹紝闇�璁剧疆鍙�夊垪銆�', 'model.tooltip.tabs.guide': '鍦ㄥ乏渚у伐鍏锋爮銆婃爣绛鹃〉銆嬩腑锛岄�夋嫨瀵瑰簲绫诲瀷鐨勬爣绛鹃〉鎷栬嚦姝ゅ娣诲姞銆�', - 'model.tooltip.func.innerface': '鍐呴儴鎺ュ彛: 鍙嚜瀹氫箟鏁版嵁澶勭悊鍑芥暟锛屽嚱鏁板悕绉伴渶浠ableField绛夊瓧绗﹀紑濮�;', - 'model.tooltip.func.outface': '澶栭儴鎺ュ彛: 鍙嚜瀹氫箟鏁版嵁澶勭悊鍑芥暟锛屾彁浜ゆ暟鎹粡杩囧唴閮ㄥ嚱鏁板鐞嗗悗锛屼紶鍏ュ閮ㄦ帴鍙o紝鏈缃椂锛屾暟鎹細鐩存帴浼犲叆澶栭儴鎺ュ彛銆�', + 'model.tooltip.func.innerface': '鍐呴儴鍑芥暟鍚嶇О闇�浠ableField绛夊瓧绗﹀紑濮�;', } \ No newline at end of file diff --git a/src/menu/components/card/cardcellcomponent/index.jsx b/src/menu/components/card/cardcellcomponent/index.jsx index 1eb0989..24433e0 100644 --- a/src/menu/components/card/cardcellcomponent/index.jsx +++ b/src/menu/components/card/cardcellcomponent/index.jsx @@ -292,7 +292,6 @@ let ableField = usefulFields.join(', ') let functip = <div> <p style={{marginBottom: '5px'}}>{this.state.dict['model.tooltip.func.innerface'].replace('@ableField', ableField)}</p> - <p>{this.state.dict['model.tooltip.func.outface']}</p> </div> let menulist = sessionStorage.getItem('fstMenuList') diff --git a/src/menu/components/share/actioncomponent/actionform/index.jsx b/src/menu/components/share/actioncomponent/actionform/index.jsx index 1240c61..29f3493 100644 --- a/src/menu/components/share/actioncomponent/actionform/index.jsx +++ b/src/menu/components/share/actioncomponent/actionform/index.jsx @@ -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: '鑷畾涔�' }] } @@ -76,16 +90,23 @@ let _opentype = card.OpenType // 鎵撳紑鏂瑰紡 let _intertype = card.intertype || 'system' // 鎺ュ彛绫诲瀷 let _funcType = card.funcType || 'print' // 鍔熻兘鎸夐挳榛樿绫诲瀷 + 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') { @@ -116,7 +137,7 @@ }) } - getOptions = (_opentype, _intertype, _funcType, _pageTemplate) => { + getOptions = (_opentype, _intertype, _funcType, _pageTemplate, _procMode) => { let _options = fromJS(actionTypeOptions[_opentype]).toJS() // 閫夐」鍒楄〃 if (_opentype === 'innerpage') { // 鏂伴〉闈紝鍙�夋ā鏉�(鑷畾涔夋椂锛屽彲濉叆澶栭儴閾炬帴) @@ -145,7 +166,14 @@ } } } else if (_opentype !== 'popview' && _opentype !== 'tab') { - if (_intertype === 'outer') { + if (_intertype === 'custom') { + _options.push('procMode', 'interface', 'callbackType', 'cbTable', 'proInterface', 'method') + if (_procMode === 'system') { + _options.push('sql', 'sqlType') + } else { + _options.push('innerFunc') + } + } else if (_intertype === 'outer') { _options.push('innerFunc', 'sysInterface', 'interface', 'outerFunc', 'callbackFunc') } else if (_intertype === 'inner') { _options.push('innerFunc') @@ -176,21 +204,27 @@ * 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)) @@ -217,6 +251,8 @@ this.setState({ openType: value, + intertype: 'system', + procMode: 'system', formlist: _formlist }, () => { if (value === 'excelIn') { @@ -230,7 +266,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(this.state.openType, this.state.interType, value, card.pageTemplate, procMode) let _fieldval = {} this.setState({ @@ -294,7 +330,7 @@ }) } else if (key === 'pageTemplate') { let _fieldval = {} - let _options = this.getOptions(this.state.openType, this.state.interType, this.state.funcType, value) + let _options = this.getOptions(this.state.openType, this.state.interType, this.state.funcType, value, procMode) this.setState({ openType: value, @@ -317,16 +353,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 +374,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') { @@ -475,7 +513,7 @@ <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) => @@ -501,7 +539,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 ( @@ -520,7 +558,7 @@ <Form.Item label={item.label} className="textarea"> {getFieldDecorator(item.key, { initialValue: item.initVal - })(<TextArea rows={4} />)} + })(<TextArea rows={2} />)} </Form.Item> </Col> ) diff --git a/src/menu/components/share/actioncomponent/actionform/index.scss b/src/menu/components/share/actioncomponent/actionform/index.scss index c25cef2..75b421d 100644 --- a/src/menu/components/share/actioncomponent/actionform/index.scss +++ b/src/menu/components/share/actioncomponent/actionform/index.scss @@ -12,6 +12,12 @@ width: 86%; } } + .ant-radio-group { + white-space: nowrap; + .ant-radio-wrapper { + margin-right: 4px; + } + } .ant-input-number { width: 100%; } diff --git a/src/menu/components/share/actioncomponent/formconfig.jsx b/src/menu/components/share/actioncomponent/formconfig.jsx index 0444ac7..3413aee 100644 --- a/src/menu/components/share/actioncomponent/formconfig.jsx +++ b/src/menu/components/share/actioncomponent/formconfig.jsx @@ -66,7 +66,7 @@ options: opentypes }, { - type: 'select', + type: 'radio', key: 'funcType', label: Formdict['header.form.funcType'], initVal: card.funcType || 'print', @@ -102,23 +102,6 @@ label: Formdict['header.form.intertype'], initVal: card.intertype || 'system', required: true, - options: [{ - value: 'system', - text: '绯荤粺' - }, { - value: 'inner', - text: Formdict['model.interface.inner'] - }, { - value: 'outer', - text: Formdict['model.interface.outer'] - }] - }, - { - type: 'select', - key: 'sqlType', - label: Formdict['header.form.action.type'], - initVal: card.sqlType || '', - required: true, options: [] }, { @@ -128,6 +111,28 @@ initVal: card.label, required: true, readonly: false + }, + { + type: 'radio', + key: 'procMode', + label: '鍙傛暟澶勭悊', + initVal: card.procMode || 'system', + required: true, + options: [{ + value: 'system', + text: '绯荤粺鍑芥暟' + }, { + value: 'inner', + text: '鍐呴儴鍑芥暟' + }] + }, + { + type: 'radio', + key: 'sqlType', + label: Formdict['header.form.action.type'], + initVal: card.sqlType || '', + required: true, + options: [] }, { type: 'text', @@ -194,12 +199,56 @@ readonly: false }, { - type: 'text', + type: 'textarea', key: 'interface', label: Formdict['header.form.interface'], initVal: card.sysInterface === 'true' ? (window.GLOB.mainSystemApi || '') : (card.interface || ''), required: true, readonly: card.sysInterface === 'true' + }, + { + type: 'textarea', + key: 'proInterface', + label: '姝e紡鍦板潃', + initVal: card.proInterface || '', + tooltip: '姝e紡绯荤粺鎵�浣跨敤鐨勬帴鍙e湴鍧�銆�', + required: false + }, + { + type: 'radio', + key: 'method', + label: '璇锋眰鏂瑰紡', + initVal: card.method || 'post', + required: true, + options: [{ + value: 'get', + text: 'GET' + }, { + value: 'post', + text: 'POST' + }] + }, + { + type: 'radio', + key: 'callbackType', + label: '鍥炶皟鏂瑰紡', + initVal: card.callbackType || 'script', + tooltip: '浣跨敤榛樿鏂瑰紡鎵ц鏃讹紝闇�瑕侀厤鍚堣鍒掍换鍔°��', + required: true, + options: [{ + value: 'default', + text: '榛樿鑴氭湰' + }, { + value: 'script', + text: '鑷畾涔夎剼鏈�' + }] + }, + { + type: 'text', + key: 'cbTable', + label: '鍥炶皟琛ㄥ悕', + initVal: card.cbTable || '', + required: true }, { type: 'text', @@ -308,7 +357,7 @@ required: true }, { - type: 'select', + type: 'radio', key: 'show', label: "鏄剧ず涓�", initVal: card.show || 'icon', diff --git a/src/menu/components/share/actioncomponent/index.jsx b/src/menu/components/share/actioncomponent/index.jsx index 3c62910..36e5f09 100644 --- a/src/menu/components/share/actioncomponent/index.jsx +++ b/src/menu/components/share/actioncomponent/index.jsx @@ -159,7 +159,6 @@ let ableField = usefulFields.join(', ') let functip = <div> <p style={{marginBottom: '5px'}}>{this.state.dict['model.tooltip.func.innerface'].replace('@ableField', ableField)}</p> - <p>{this.state.dict['model.tooltip.func.outface']}</p> </div> let menulist = sessionStorage.getItem('fstMenuList') @@ -466,7 +465,7 @@ <Modal title={dict['model.action'] + '-' + (card && card.copyType === 'action' ? dict['model.copy'] : dict['model.edit'])} visible={visible} - width={800} + width={850} maskClosable={false} onCancel={this.editModalCancel} footer={[ diff --git a/src/menu/datasource/verifycard/index.jsx b/src/menu/datasource/verifycard/index.jsx index 2d9c900..d3d310f 100644 --- a/src/menu/datasource/verifycard/index.jsx +++ b/src/menu/datasource/verifycard/index.jsx @@ -229,7 +229,8 @@ res.data.forEach(item => { let _item = { name: item.funcname, - value: Utils.UnformatOptions(item.longparam) + value: window.decodeURIComponent(window.atob(item.longparam)) + // value: Utils.UnformatOptions(item.longparam) } _scripts.push(_item) diff --git a/src/mob/datasource/verifycard/index.jsx b/src/mob/datasource/verifycard/index.jsx index 1150f4a..18e9efb 100644 --- a/src/mob/datasource/verifycard/index.jsx +++ b/src/mob/datasource/verifycard/index.jsx @@ -150,7 +150,8 @@ res.data.forEach(item => { let _item = { name: item.funcname, - value: Utils.UnformatOptions(item.longparam) + value: window.decodeURIComponent(window.atob(item.longparam)) + // value: Utils.UnformatOptions(item.longparam) } _scripts.push(_item) diff --git a/src/tabviews/scriptmanage/actionList/index.jsx b/src/tabviews/scriptmanage/actionList/index.jsx index 29eb5df..a17cc72 100644 --- a/src/tabviews/scriptmanage/actionList/index.jsx +++ b/src/tabviews/scriptmanage/actionList/index.jsx @@ -120,8 +120,6 @@ LText: values.LongParam } - param.LText = window.btoa(window.encodeURIComponent(JSON.stringify(param.LText))) - if (btn.sqlType === 'delete') { param.LText = window.GLOB.appkey || '' param.Remark = '' diff --git a/src/tabviews/scriptmanage/config.jsx b/src/tabviews/scriptmanage/config.jsx index 08305a9..5402b14 100644 --- a/src/tabviews/scriptmanage/config.jsx +++ b/src/tabviews/scriptmanage/config.jsx @@ -63,7 +63,7 @@ {"label":"鍑芥暟","field":"func","type":"text","initval":"","readonly":"false","required":"true","hidden":"false","readin":"true","fieldlength":50,"regular":"funcname","supField":"","blacklist":[],"uuid":"1587006164634l397q15t49u2pfq02f5"}, {"label":"鎺掑簭","field":"Sort","type":"number","initval":0,"decimal":0,"min":"","max":"","readonly":"false","hidden":"false","readin":"true","supField":"","blacklist":[],"uuid":"15870101796149403f2pqfpviuo415m2"}, {"label":"鎻忚堪","field":"Remark","type":"textarea","initval":"","readonly":"false","required":"false","hidden":"false","readin":"true","fieldlength":512,"maxRows":6,"supField":"","blacklist":[],"uuid":"1587006199263k8hm45cmtomgu6hd881"}, - {"label":"鑴氭湰","field":"LongParam","type":"textarea","initval":"","readonly":"false","required":"true","encryption":"true","hidden":"false","readin":"true","fieldlength":8000,"maxRows":20,"supField":"","blacklist":[],"uuid":"1587006209935qbkle15h4d9i9lg9tcu"} + {"label":"鑴氭湰","field":"LongParam","type":"textarea","initval":"","readonly":"false","required":"true","encryption":"true","hidden":"false","readin":"true","fieldlength":12000,"maxRows":20,"supField":"","blacklist":[],"uuid":"1587006209935qbkle15h4d9i9lg9tcu"} ] }, '1587007258155ut4nbggg4r66t9uhut2': { @@ -84,7 +84,7 @@ {"label":"鍑芥暟","field":"func","type":"text","initval":"","readonly":"false","required":"true","hidden":"false","readin":"true","fieldlength":50,"regular":"funcname","supField":"","blacklist":[],"uuid":"1587006164634l397q15t49u2pfq02f5"}, {"label":"鎺掑簭","field":"Sort","type":"number","initval":0,"decimal":0,"min":"","max":"","readonly":"false","hidden":"false","readin":"true","supField":"","blacklist":[],"uuid":"1587010196675i9m6ie3tv9kg2rhgfi0"}, {"label":"鎻忚堪","field":"Remark","type":"textarea","initval":"","readonly":"false","required":"false","hidden":"false","readin":"true","fieldlength":512,"maxRows":6,"supField":"","blacklist":[],"uuid":"1587006199263k8hm45cmtomgu6hd881"}, - {"label":"鑴氭湰","field":"LongParam","type":"textarea","initval":"","readonly":"false","required":"true","encryption":"true","hidden":"false","readin":"true","fieldlength":8000,"maxRows":20,"supField":"","blacklist":[],"uuid":"1587006209935qbkle15h4d9i9lg9tcu"} + {"label":"鑴氭湰","field":"LongParam","type":"textarea","initval":"","readonly":"false","required":"true","encryption":"true","hidden":"false","readin":"true","fieldlength":12000,"maxRows":20,"supField":"","blacklist":[],"uuid":"1587006209935qbkle15h4d9i9lg9tcu"} ] } } diff --git a/src/tabviews/scriptmanage/index.jsx b/src/tabviews/scriptmanage/index.jsx index fef9e73..ab95a32 100644 --- a/src/tabviews/scriptmanage/index.jsx +++ b/src/tabviews/scriptmanage/index.jsx @@ -134,7 +134,7 @@ if (result.status) { this.setState({ data: result.data.map((item, index) => { - item.LongParam = Utils.UnformatOptions(item.LongParam) + // item.LongParam = Utils.UnformatOptions(item.LongParam) item.key = index return item }), diff --git a/src/tabviews/zshare/actionList/normalbutton/index.jsx b/src/tabviews/zshare/actionList/normalbutton/index.jsx index 3bcf302..c9e83ba 100644 --- a/src/tabviews/zshare/actionList/normalbutton/index.jsx +++ b/src/tabviews/zshare/actionList/normalbutton/index.jsx @@ -148,13 +148,20 @@ return } } else if (btn.intertype === 'custom') { - if (!btn.innerFunc && (!btn.sql || !btn.sqlType)) { + if (btn.callbackType === 'script' && (!btn.verify || !btn.verify.cbScripts || !btn.verify.cbScripts.filter(item => item.status !== 'false').length === 0)) { this.actionSettingError() return - } else if (!btn.innerFunc && data.length === 0 && btn.verify && btn.verify.voucher && btn.verify.voucher.enabled) { + } else if (btn.procMode === 'system' && data.length === 0 && btn.verify && btn.verify.voucher && btn.verify.voucher.enabled) { notification.warning({ top: 92, message: '浣跨敤鍒涘缓鍑瘉鍑芥暟锛岄渶瑕侀�夋嫨琛岋紒', + duration: 5 + }) + return + } else if (window.GLOB.systemType === 'production' && !btn.proInterface) { + notification.warning({ + top: 92, + message: '灏氭湭璁剧疆姝e紡绯荤粺鎺ュ彛鍦板潃锛�', duration: 5 }) return @@ -607,7 +614,7 @@ } else if (btn.intertype === 'custom') { // 绯荤粺鎺ュ彛 let params = [] - if (!btn.innerFunc) { + if (btn.procMode === 'system') { params = this.getSystemParam(data, formdata, true) params = params.map(item => { item.script_type = 'Y' @@ -699,11 +706,14 @@ url = btn.interface } + let mkey = result.mk_api_key || '' + delete result.mk_ex_invoke delete result.status delete result.message delete result.ErrCode delete result.ErrMesg + delete result.mk_api_key let param = {} @@ -713,12 +723,172 @@ }) Api.directRequest(url, btn.method, param).then(res => { + if (typeof(res) !== 'object' || Array.isArray(res)) { + this.execError({ErrCode: 'E', message: '鏈煡鐨勮繑鍥炵粨鏋滐紒'}) + _resolve() + } else { + res.mk_api_key = mkey + this.customCallbackRequest(params, res, _resolve) + } + }, () => { + this.updateStatus('over') + _resolve() + }) + } + + /** + * @description 鍥炶皟璇锋眰寰幆鎵ц + */ + customCallbackRequest = (params, result, _resolve) => { + const { btn } = this.props + let lines = [] + let pre = btn.callbackType === 'script' ? '@' : '' + + let getDefaultSql = (obj, tb, bid, level) => { + let keys = [] + let vals = [] + let subObjs = [] + let id = Utils.getuuid() + + delete obj.$$key + + Object.keys(obj).forEach(key => { + let val = obj[key] + if (typeof(val) === 'object') { + if (Array.isArray(val)) { + val.forEach(item => { + if (typeof(item) !== 'object' || Array.isArray(item)) return + if (Object.keys(item).length > 0) { + item.$$key = tb + '_' + key + subObjs.push(item) + } + }) + } else if (Object.keys(val).length > 0) { + val.$$key = tb + '_' + key + subObjs.push(val) + } + } else if (val !== null && val !== undefined) { + keys.push(key) + vals.push(`'${val}'`) + } + }) + + lines.push({ + table: tb, + insert: `Insert into ${pre}${tb} (${keys.join(',')},mk_level,mk_id,mk_bid)`, + select: `Select ${vals.join(',')},'${level}','${id}','${bid}'` + }) + + subObjs.forEach(item => { + getDefaultSql(item, item.$$key, id, level + 1) + }) + } + + getDefaultSql(result, btn.cbTable, '', 1) + + let lineMap = new Map() + lines.forEach(line => { + if (lineMap.has(line.table)) { + let _line = lineMap.get(line.table) + _line.selects.push(line.select) + lineMap.set(line.table, _line) + } else { + lineMap.set(line.table, { + table: line.table, + insert: line.insert, + selects: [line.select] + }) + } + }) + + let param = {} + + if (btn.callbackType === 'script') { // 浣跨敤鑷畾涔夎剼鏈� + param.func = 'sPC_TableData_InUpDe' + + if (this.props.BID) { + param.BID = this.props.BID + } + + let _prevCustomScript = '' // 榛樿sql鍓嶆墽琛岃剼鏈� + let _backCustomScript = '' // 榛樿sql鍚庢墽琛岃剼鏈� + + btn.verify.cbScripts.forEach(script => { + if (script.status === 'false') return + + if (script.position === 'front') { + _prevCustomScript += ` + /* 鑷畾涔夎剼鏈� */ + ${script.sql} + ` + } else { + _backCustomScript += ` + /* 鑷畾涔夎剼鏈� */ + ${script.sql} + ` + } + }) + + let sql = [...lineMap.values()].map(item => (` + ${item.insert} + ${item.selects.join(` union all + `)} + `)) + sql = sql.join('') + sql = _prevCustomScript + sql + sql = sql + _backCustomScript + + if ((window.GLOB.systemType !== 'production' && options.sysType !== 'cloud') || window.debugger === true) { + console.info(sql.replace(/\n\s{8}/ig, '\n')) + } + + param.LText = sql + + if (sessionStorage.getItem('dataM') === 'true') { // 鏁版嵁鏉冮檺 + param.LText = param.LText.replace(/\$@/ig, '/*') + param.LText = param.LText.replace(/@\$/ig, '*/') + } else { + param.LText = param.LText.replace(/@\$|\$@/ig, '') + } + param.LText = param.LText.replace(/\$check@|@check\$/ig, '') + + param.exec_type = 'y' // 鍚庡彴瑙g爜 + param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + param.secretkey = Utils.encrypt('', param.timestamp) + param.LText = Utils.formatOptions(param.LText) + param.menuname = btn.logLabel + + if (this.props.menuType === 'HS') { // 鍑芥暟 sPC_TableData_InUpDe 浜戠楠岃瘉 + param.open_key = Utils.encryptOpenKey(param.secretkey, param.timestamp) + } + } else { + param.func = 's_ex_result_back' + param.s_ex_result = [...lineMap.values()].map((item, index) => ({ + MenuID: btn.uuid, + MenuName: btn.logLabel, + TableName: item.table, + LongText: window.btoa(window.encodeURIComponent(`${item.insert} ${item.selects.join(` union all `)}`)), + Sort: index + 1 + })) + + if ((window.GLOB.systemType !== 'production' && options.sysType !== 'cloud') || window.debugger === true) { + let sql = [...lineMap.values()].map(item => (` + ${item.insert} + ${item.selects.join(` union all + `)} + `)) + sql = sql.join('') + console.info(sql.replace(/\n\s{10}/ig, '\n')) + } + } + + Api.genericInterface(param).then(res => { if (res.status) { if (params.length === 0) { this.execSuccess(res) _resolve() } else { - this.customLoopRequest(params, btn, _resolve) + this.customLoopRequest(params, _resolve) } } else { this.execError(res) diff --git a/src/templates/comtableconfig/index.jsx b/src/templates/comtableconfig/index.jsx index 5fdc681..a6fefe4 100644 --- a/src/templates/comtableconfig/index.jsx +++ b/src/templates/comtableconfig/index.jsx @@ -991,6 +991,13 @@ }) } } + if (btn.intertype === 'custom' && btn.callbackType === 'script' && (!btn.verify || !btn.verify.cbScripts || !btn.verify.cbScripts.filter(item => item.status !== 'false').length === 0)) { + notification.warning({ + top: 92, + message: `鎸夐挳銆�${btn.label}銆嬫湭璁剧疆鍥炶皟鑴氭湰锛� 灏嗕笉浼氱敓鏁堬紒`, + duration: 5 + }) + } }) if (config.setting.interType === 'system' && config.setting.default !== 'false' && !config.setting.dataresource) { diff --git a/src/templates/formtabconfig/index.jsx b/src/templates/formtabconfig/index.jsx index eab6c34..abd4a79 100644 --- a/src/templates/formtabconfig/index.jsx +++ b/src/templates/formtabconfig/index.jsx @@ -507,7 +507,6 @@ let ableField = usefulFields.join(', ') let functip = <div> <p style={{marginBottom: '5px'}}>{this.state.dict['model.tooltip.func.innerface'].replace('@ableField', ableField)}</p> - <p>{this.state.dict['model.tooltip.func.outface']}</p> </div> this.setState({ diff --git a/src/templates/sharecomponent/actioncomponent/actionform/index.jsx b/src/templates/sharecomponent/actioncomponent/actionform/index.jsx index 315b7a3..9f45bd7 100644 --- a/src/templates/sharecomponent/actioncomponent/actionform/index.jsx +++ b/src/templates/sharecomponent/actioncomponent/actionform/index.jsx @@ -36,6 +36,7 @@ interType: null, // 鎺ュ彛绫诲瀷锛氬唴閮ㄣ�佸閮� funcType: null, // 鍔熻兘绫诲瀷 position: null, // 鎸夐挳浣嶇疆 + procMode: null, // 澶栭儴鎺ュ彛鍙傛暟澶勭悊鏂瑰紡 pageTemplate: null, requireOptions: [{ value: 'notRequired', @@ -92,6 +93,7 @@ let _opentype = card.OpenType // 鎵撳紑鏂瑰紡 // let _tabType = card.tabType || 'SubTable' // 鎸夐挳涓哄脊绐楋紙鏍囩锛夋椂锛屾爣绛剧殑绫诲瀷 let _intertype = card.intertype || 'system' // 鎺ュ彛绫诲瀷 + let _procMode = card.procMode || 'system' // 鍙傛暟澶勭悊鏂瑰紡 let _funcType = card.funcType || '' // 鍔熻兘鎸夐挳榛樿绫诲瀷 let _tabTemplate = card.tabTemplate // 鎸夐挳涓烘爣绛鹃〉鏃讹紝鏍囩绫诲瀷锛氫笁绾ц彍鍗曟垨琛ㄥ崟鏍囩椤� let _pageTemplate = card.pageTemplate // 鏂伴〉闈㈢被鍨� @@ -104,17 +106,20 @@ } let _tabs = this.props.tabs.filter(tab => tab.type === 'SubTable') - let _options = this.getOptions(_opentype, _intertype, _funcType, _pageTemplate, _tabTemplate) + let _options = this.getOptions(_opentype, _intertype, _funcType, _pageTemplate, _tabTemplate, _procMode) this.setState({ openType: _opentype, pageTemplate: _pageTemplate, interType: _intertype, + procMode: _procMode, position: card.position || 'toolbar', funcType: _funcType, formlist: this.props.formlist.map(item => { if (item.key === 'class') { item.options = btnClasses + } else if (item.key === 'innerFunc' && _procMode === 'inner') { + item.required = true } else if (item.key === 'icon') { item.options = btnIcons } else if (item.key === 'intertype') { @@ -169,7 +174,7 @@ } } - getOptions = (_opentype, _intertype, _funcType, _pageTemplate, _tabTemplate) => { + getOptions = (_opentype, _intertype, _funcType, _pageTemplate, _tabTemplate, _procMode) => { let _options = fromJS(actionTypeOptions[_opentype]).toJS() // 閫夐」鍒楄〃 if (_opentype === 'innerpage') { // 鏂伴〉闈紝鍙�夋ā鏉�(鑷畾涔夋椂锛屽彲濉叆澶栭儴閾炬帴) @@ -205,7 +210,12 @@ } } else if (_opentype !== 'popview') { // 鎵撳紑鏂瑰紡涓嶆槸寮圭獥椤甸潰鏃� if (_intertype === 'custom') { - _options.push('sql', 'sqlType', 'innerFunc', 'interface', 'callbackType', 'cbTable', 'proInterface', 'method') + _options.push('procMode', 'interface', 'callbackType', 'cbTable', 'proInterface', 'method') + if (_procMode === 'system') { + _options.push('sql', 'sqlType') + } else { + _options.push('innerFunc') + } } else if (_intertype === 'outer') { _options.push('innerFunc', 'sysInterface', 'interface', 'outerFunc', 'callbackFunc') } else if (_intertype === 'inner') { @@ -226,11 +236,11 @@ * @description 鍒囨崲 */ optionChange = (key, value) => { - const { openType, funcType } = this.state + const { openType, funcType, procMode } = this.state const { card } = this.props if (key === 'OpenType') { - let _options = this.getOptions(value, 'system', '', this.state.pageTemplate, card.tabTemplate) + let _options = this.getOptions(value, 'system', '', this.state.pageTemplate, card.tabTemplate, 'system') let _fieldval = {} let _formlist = this.state.formlist.map(item => { item.hidden = !_options.includes(item.key) @@ -276,6 +286,7 @@ openType: value, funcType: '', intertype: 'system', + procMode: 'system', formlist: _formlist }, () => { if (value === 'excelIn') { @@ -334,7 +345,7 @@ // this.props.form.setFieldsValue(_fieldval) // }) } else if (key === 'funcType') { - let _options = this.getOptions('funcbutton', this.state.interType, value, card.pageTemplate, card.tabTemplate) + let _options = this.getOptions('funcbutton', this.state.interType, value, card.pageTemplate, card.tabTemplate, procMode) let _fieldval = {} this.setState({ @@ -388,7 +399,7 @@ this.props.form.setFieldsValue(_fieldval) }) } else if (key === 'pageTemplate') { - let _options = this.getOptions('innerpage', this.state.interType, this.state.funcType, value, card.tabTemplate) + let _options = this.getOptions('innerpage', this.state.interType, this.state.funcType, value, card.tabTemplate, procMode) let _fieldval = {} this.setState({ @@ -429,7 +440,7 @@ }) }) } else if (key === 'intertype') { - let _options = this.getOptions(openType, value, funcType, '', '') + let _options = this.getOptions(openType, value, funcType, '', '', procMode) this.setState({ interType: value, @@ -447,10 +458,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, 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') { @@ -621,7 +642,7 @@ <Form.Item label={item.label} className="textarea"> {getFieldDecorator(item.key, { initialValue: item.initVal - })(<TextArea rows={4} />)} + })(<TextArea rows={2} />)} </Form.Item> </Col> ) diff --git a/src/templates/sharecomponent/actioncomponent/index.jsx b/src/templates/sharecomponent/actioncomponent/index.jsx index a42075a..4392c36 100644 --- a/src/templates/sharecomponent/actioncomponent/index.jsx +++ b/src/templates/sharecomponent/actioncomponent/index.jsx @@ -154,7 +154,6 @@ let ableField = usefulFields.join(', ') let functip = <div> <p style={{marginBottom: '5px'}}>{this.state.dict['model.tooltip.func.innerface'].replace('@ableField', ableField)}</p> - <p>{this.state.dict['model.tooltip.func.outface']}</p> </div> let menulist = [] @@ -886,6 +885,7 @@ {/* 缂栬緫鎸夐挳锛氬鍒躲�佺紪杈� */} <Modal title={dict['model.action'] + '-' + (card && card.copyType === 'action' ? dict['model.copy'] : dict['model.edit'])} + wrapClassName="model-table-action-edit-modal" visible={visible} width={850} maskClosable={false} diff --git a/src/templates/sharecomponent/actioncomponent/index.scss b/src/templates/sharecomponent/actioncomponent/index.scss index 7a01fd3..2226cde 100644 --- a/src/templates/sharecomponent/actioncomponent/index.scss +++ b/src/templates/sharecomponent/actioncomponent/index.scss @@ -34,6 +34,12 @@ } } +.model-table-action-edit-modal { + .ant-modal { + top: 60px; + padding-bottom: 5px; + } +} .model-table-action-verify-modal { .ant-modal { top: 50px; diff --git a/src/templates/sharecomponent/actioncomponent/verifyexcelin/index.jsx b/src/templates/sharecomponent/actioncomponent/verifyexcelin/index.jsx index 398024f..a645ca3 100644 --- a/src/templates/sharecomponent/actioncomponent/verifyexcelin/index.jsx +++ b/src/templates/sharecomponent/actioncomponent/verifyexcelin/index.jsx @@ -299,7 +299,8 @@ systemScripts: res.data.map(item => { return { name: item.funcname, - value: Utils.UnformatOptions(item.longparam) + value: window.decodeURIComponent(window.atob(item.longparam)) + // value: Utils.UnformatOptions(item.longparam) } }) }) diff --git a/src/templates/sharecomponent/settingcalcomponent/verifycard/index.jsx b/src/templates/sharecomponent/settingcalcomponent/verifycard/index.jsx index 0ec28a2..38a6001 100644 --- a/src/templates/sharecomponent/settingcalcomponent/verifycard/index.jsx +++ b/src/templates/sharecomponent/settingcalcomponent/verifycard/index.jsx @@ -9,13 +9,13 @@ import asyncComponent from '@/utils/asyncComponent' import ColForm from './columnform' -import CustomScript from '@/templates/zshare/customscript' import SettingForm from './settingform' import SettingUtils from './utils' import './index.scss' const { TabPane } = Tabs +const CustomScript = asyncComponent(() => import('@/templates/zshare/customscript')) const FieldsComponent = asyncComponent(() => import('@/templates/sharecomponent/fieldscomponent')) class VerifyCard extends Component { diff --git a/src/templates/sharecomponent/settingcomponent/settingform/datasource/index.jsx b/src/templates/sharecomponent/settingcomponent/settingform/datasource/index.jsx index c1c0e77..53ea2eb 100644 --- a/src/templates/sharecomponent/settingcomponent/settingform/datasource/index.jsx +++ b/src/templates/sharecomponent/settingcomponent/settingform/datasource/index.jsx @@ -9,6 +9,8 @@ import CodeMirror from '@/templates/zshare/codemirror' import './index.scss' +const { TextArea } = Input + class SettingForm extends Component { static propTpyes = { config: PropTypes.object, // 椤甸潰閰嶇疆 @@ -21,6 +23,8 @@ state = { interType: 'system', + procMode: 'system', + requestMode: 'system', funcTooltip: '', funcRules: [] } @@ -55,6 +59,8 @@ this.setState({ interType: setting.interType || 'system', + procMode: setting.procMode || 'system', + requestMode: setting.requestMode || 'system', funcTooltip: tooltip, funcRules: rules }) @@ -156,12 +162,18 @@ this.setState({ interType: value }) - } else if (key === 'sysInterface') { - if (value === 'true') { - this.props.form.setFieldsValue({ - interface: window.GLOB.mainSystemApi || '' - }) - } + } else if (key === 'procMode') { + this.setState({ + procMode: value + }) + } else if (key === 'requestMode') { + this.setState({ + requestMode: value + }) + } else if (key === 'sysInterface' && value === 'true') { + this.props.form.setFieldsValue({ + interface: window.GLOB.mainSystemApi || '' + }) } } @@ -176,7 +188,7 @@ render() { const { setting, dict, menu, config, columns } = this.props const { getFieldDecorator } = this.props.form - const { interType, funcRules, funcTooltip } = this.state + const { interType, funcRules, funcTooltip, procMode, requestMode } = this.state const formItemLayout = { labelCol: { @@ -230,10 +242,11 @@ }, ] })( - <Radio.Group onChange={(e) => {this.onRadioChange(e, 'interType')}}> + <Radio.Group style={{whiteSpace: 'nowrap'}} onChange={(e) => {this.onRadioChange(e, 'interType')}}> <Radio value="system">绯荤粺</Radio> <Radio value="inner">鍐呴儴</Radio> <Radio value="outer">澶栭儴</Radio> + <Radio value="custom">鑷畾涔�</Radio> </Radio.Group>)} </Form.Item> </Col> @@ -254,7 +267,89 @@ </Radio.Group>)} </Form.Item> </Col> : null} - {interType === 'inner' ? <Col span={12}> + {interType === 'custom' ? <Col span={12}> + <Form.Item label="鍙傛暟澶勭悊"> + {getFieldDecorator('procMode', { + initialValue: procMode, + rules: [ + { + required: true, + message: dict['form.required.select'] + '鍙傛暟澶勭悊鏂瑰紡!' + }, + ] + })( + <Radio.Group style={{whiteSpace: 'nowrap'}} onChange={(e) => {this.onRadioChange(e, 'procMode')}}> + <Radio value="system">鍓嶇疆鑴氭湰</Radio> + <Radio value="inner">鍓嶇疆鍑芥暟</Radio> + </Radio.Group>)} + </Form.Item> + </Col> : null} + {interType === 'custom' && procMode === 'inner' ? <Col span={12}> + <Form.Item label={ + <Tooltip placement="topLeft" title={funcTooltip}> + <Icon type="question-circle" /> + 鍓嶇疆鍑芥暟 + </Tooltip> + }> + {getFieldDecorator('innerFunc', { + initialValue: setting.innerFunc || '', + rules: [ + { + required: true, + message: dict['form.required.input'] + '鍓嶇疆鍑芥暟!' + }, + { + max: formRule.func.max, + message: formRule.func.maxMessage + }, + ...funcRules + ] + })(<Input placeholder={''} autoComplete="off" />)} + </Form.Item> + </Col> : null} + {interType === 'outer' || interType === 'custom' ? <Col className="data-source" span={24}> + <Form.Item label="鎺ュ彛鍦板潃"> + {getFieldDecorator('interface', { + initialValue: setting.interface || '', + rules: [ + { + required: true, + message: dict['form.required.input'] + '鎺ュ彛鍦板潃!' + }, + ] + })(<TextArea rows={2} />)} + </Form.Item> + </Col> : null} + {interType === 'custom' ? <Col className="data-source" span={24}> + <Form.Item label={ + <Tooltip placement="topLeft" title="姝e紡绯荤粺鎵�浣跨敤鐨勭殑鎺ュ彛鍦板潃銆�"> + <Icon type="question-circle" /> + 姝e紡鍦板潃 + </Tooltip> + }> + {getFieldDecorator('proInterface', { + initialValue: setting.proInterface || '' + })(<TextArea rows={2} />)} + </Form.Item> + </Col> : null} + {interType === 'custom' ? <Col span={12}> + <Form.Item label="鏁版嵁璇锋眰"> + {getFieldDecorator('requestMode', { + initialValue: requestMode, + rules: [ + { + required: true, + message: dict['form.required.select'] + '鏁版嵁璇锋眰鏂瑰紡!' + }, + ] + })( + <Radio.Group style={{whiteSpace: 'nowrap'}} onChange={(e) => {this.onRadioChange(e, 'requestMode')}}> + <Radio value="system">绯荤粺鍑芥暟</Radio> + <Radio value="inner">鍐呴儴鍑芥暟</Radio> + </Radio.Group>)} + </Form.Item> + </Col> : null} + {interType === 'inner' || (interType === 'custom' && requestMode === 'inner') ? <Col span={12}> <Form.Item label={ <Tooltip placement="topLeft" title={funcTooltip}> <Icon type="question-circle" /> @@ -278,19 +373,6 @@ </Form.Item> </Col> : null} {interType === 'outer' ? <Col span={12}> - <Form.Item label="鎺ュ彛鍦板潃"> - {getFieldDecorator('interface', { - initialValue: setting.interface || '', - rules: [ - { - required: true, - message: dict['form.required.input'] + '鎺ュ彛鍦板潃!' - }, - ] - })(<Input placeholder={''} autoComplete="off" />)} - </Form.Item> - </Col> : null} - {interType === 'outer' ? <Col span={12}> <Form.Item label="澶栭儴鍑芥暟"> {getFieldDecorator('outerFunc', { initialValue: setting.outerFunc || '', @@ -306,7 +388,7 @@ })(<Input placeholder={''} autoComplete="off" />)} </Form.Item> </Col> : null} - {interType === 'system' ? <Col span={24} className="data-source" style={{paddingLeft: '7px'}}> + {interType === 'system' || (interType === 'custom' && requestMode === 'system') ? <Col span={24} className="data-source" style={{paddingLeft: '7px'}}> <Form.Item help={'鏁版嵁ID锛�' + menu.MenuID} labelCol={{xs: { span: 24 }, sm: { span: 4 }}} wrapperCol={ {xs: { span: 24 }, sm: { span: 20 }} } label={ <Tooltip placement="topLeft" title={'浣跨敤绯荤粺鍑芥暟鏃讹紝闇�濉啓鏁版嵁婧愩�傛敞锛氭暟鎹潈闄愭浛鎹㈢ $@ -> /* 鎴� \'\'銆� @$ -> */ 鎴� \'\''}> <Icon type="question-circle" /> @@ -318,7 +400,7 @@ })(<CodeMirror />)} </Form.Item> </Col> : null} - {interType === 'system' ? <Col span={12}> + {interType === 'system' || (interType === 'custom' && requestMode === 'system') ? <Col span={12}> <Form.Item label={ <Tooltip placement="topLeft" title={'鏌ヨ鏃讹紝鎼滅储鏉′欢浠here鏉′欢鎷兼帴杩涘叆sql锛岀粺璁℃椂锛屽皢鏁版嵁婧愪腑浠モ�淍+鎼滅储瀛楁+@鈥濈殑鍐呭锛屼互鎼滅储鏉′欢涓殑鍊艰繘琛屾浛鎹㈠悗锛屾彁浜ゆ煡璇紝娉細鏌ヨ绫诲瀷浠呭湪浣跨敤绯荤粺鍑芥暟鏃舵湁鏁堛��'}> <Icon type="question-circle" /> @@ -334,7 +416,7 @@ </Radio.Group>)} </Form.Item> </Col> : null} - {interType === 'system' ? <Col span={12}> + {interType === 'system' || (interType === 'custom' && requestMode === 'system') ? <Col span={12}> <Form.Item label="榛樿sql"> {getFieldDecorator('default', { initialValue: setting.default || 'true' @@ -378,6 +460,44 @@ })(<Input placeholder={'ID asc, UID desc'} autoComplete="off" />)} </Form.Item> </Col> + {interType === 'custom' ? <Col span={12}> + <Form.Item label="鍥炶皟鏂瑰紡"> + {getFieldDecorator('callbackType', { + initialValue: setting.callbackType || 'default' + })( + <Radio.Group> + <Radio value="default">榛樿鑴氭湰</Radio> + <Radio value="script">鑷畾涔夎剼鏈�</Radio> + </Radio.Group>)} + </Form.Item> + </Col> : null} + {interType === 'custom' ? <Col span={12}> + <Form.Item label={ + <Tooltip placement="topLeft" title={'鍚屾鎵ц锛氬閮ㄦ帴鍙h皟鐢ㄦ垚鍔熷悗鍐嶈姹傛暟鎹紱寮傛鎵ц锛氬閮ㄦ帴鍙h皟鐢ㄤ笌璇锋眰鏁版嵁鍚屾椂杩涜銆�'}> + <Icon type="question-circle" /> + 鎵ц鏂瑰紡 + </Tooltip> + }> + {getFieldDecorator('execType', { + initialValue: setting.execType || 'sync' + })( + <Radio.Group> + <Radio value="sync">鍚屾</Radio> + <Radio value="async">寮傛</Radio> + </Radio.Group>)} + </Form.Item> + </Col> : null} + {interType === 'custom' ? <Col span={12}> + <Form.Item label="鎵ц娆℃暟"> + {getFieldDecorator('execTime', { + initialValue: setting.execTime || 'once' + })( + <Radio.Group> + <Radio value="always">濮嬬粓</Radio> + <Radio value="once">涓�娆�</Radio> + </Radio.Group>)} + </Form.Item> + </Col> : null} <Col span={12}> <Form.Item label="鏄惁鍒嗛〉"> {getFieldDecorator('laypage', { diff --git a/src/templates/sharecomponent/settingcomponent/settingform/index.jsx b/src/templates/sharecomponent/settingcomponent/settingform/index.jsx index f7a193e..b5c4ffe 100644 --- a/src/templates/sharecomponent/settingcomponent/settingform/index.jsx +++ b/src/templates/sharecomponent/settingcomponent/settingform/index.jsx @@ -7,11 +7,13 @@ import Api from '@/api' import Utils from '@/utils/utils.js' import SettingUtils from './utils.jsx' -import CustomScript from '@/templates/zshare/customscript' +import asyncComponent from '@/utils/asyncComponent' import DataSource from './datasource' import './index.scss' const { TabPane } = Tabs +const CustomScript = asyncComponent(() => import('@/templates/zshare/customscript')) +const SimpleScript = asyncComponent(() => import('./simplescript')) class SettingForm extends Component { static propTpyes = { @@ -37,6 +39,8 @@ let _setting = fromJS(config.setting).toJS() let _scripts = _setting.scripts || [] + let _preScripts = _setting.preScripts || [] + let _cbScripts = _setting.cbScripts || [] _setting.default = _setting.default || 'true' // 榛樿sql _setting.sysInterface = _setting.sysInterface || 'false' // 鏄惁涓虹郴缁熸帴鍙� @@ -82,7 +86,9 @@ arr_field: arr_field.join(','), regoptions: Utils.getRegOptions(search), // 鎼滅储鏉′欢锛屾鍒欐浛鎹� columns: columns, - scripts: _scripts + scripts: _scripts, + preScripts: _preScripts, + cbScripts: _cbScripts }) } @@ -143,6 +149,24 @@ handleConfirm = (trigger) => { const { activeKey, setting, scripts } = this.state + let _loading = false + if (this.scriptsForm && this.scriptsForm.props.form.getFieldValue('sql')) { + _loading = true + } else if (this.preScriptsForm && this.preScriptsForm.props.form.getFieldValue('sql')) { + _loading = true + } else if (this.cbScriptsForm && this.cbScriptsForm.props.form.getFieldValue('sql')) { + _loading = true + } + + if (_loading) { + notification.warning({ + top: 92, + message: '瀛樺湪鏈繚瀛樿剼鏈紝璇风偣鍑荤‘瀹氫繚瀛橈紝鎴栫偣鍑诲彇娑堟斁寮冧慨鏀癸紒', + duration: 5 + }) + return + } + if (trigger) { this.setState({loading: true}) } @@ -199,25 +223,10 @@ }) } else { return new Promise((resolve, reject) => { - let _loading = false - if (this.scriptsForm && this.scriptsForm.state.editItem) { - _loading = true - } else if (this.scriptsForm && this.scriptsForm.props.form.getFieldValue('sql')) { - _loading = true - } - if (trigger === 'func' && setting.interType !== 'inner') { notification.warning({ top: 92, message: '浣跨敤鍐呴儴鎺ュ彛锛屾墠鍙互鍒涘缓瀛樺偍杩囩▼锛�', - duration: 5 - }) - this.setState({loading: false}) - reject() - } else if (_loading) { - notification.warning({ - top: 92, - message: '瀛樺湪鏈繚瀛樿剼鏈紝璇风偣鍑荤‘瀹氫繚瀛橈紝鎴栫偣鍑诲彇娑堟斁寮冧慨鏀癸紒', duration: 5 }) this.setState({loading: false}) @@ -289,6 +298,24 @@ changeTab = (val) => { const { activeKey, search, arr_field } = this.state + let _loading = false + if (this.scriptsForm && this.scriptsForm.props.form.getFieldValue('sql')) { + _loading = true + } else if (this.preScriptsForm && this.preScriptsForm.props.form.getFieldValue('sql')) { + _loading = true + } else if (this.cbScriptsForm && this.cbScriptsForm.props.form.getFieldValue('sql')) { + _loading = true + } + + if (_loading) { + notification.warning({ + top: 92, + message: '瀛樺湪鏈繚瀛樿剼鏈紝璇风偣鍑荤‘瀹氫繚瀛橈紝鎴栫偣鍑诲彇娑堟斁寮冧慨鏀癸紒', + duration: 5 + }) + return + } + if (activeKey === 'setting') { let _defaultSql = '' this.settingForm.handleConfirm().then(res => { @@ -330,22 +357,6 @@ }) }) } else if (activeKey === 'scripts') { - let _loading = false - if (this.scriptsForm && this.scriptsForm.state.editItem) { - _loading = true - } else if (this.scriptsForm && this.scriptsForm.props.form.getFieldValue('sql')) { - _loading = true - } - - if (_loading) { - notification.warning({ - top: 92, - message: '瀛樺湪鏈繚瀛樿剼鏈紝璇风偣鍑荤‘瀹氫繚瀛橈紝鎴栫偣鍑诲彇娑堟斁寮冧慨鏀癸紒', - duration: 5 - }) - return - } - this.setState({loading: true}) this.sqlverify(() => { // 楠岃瘉鎴愬姛 this.setState({ @@ -372,10 +383,20 @@ scriptsUpdate = (scripts) => { this.setState({scripts}) } + + // 鍓嶇疆鑴氭湰鏇存柊 + preScriptsUpdate = (preScripts) => { + this.setState({preScripts}) + } + + // 鍚庣疆鑴氭湰鏇存柊 + cbScriptsUpdate = (cbScripts) => { + this.setState({cbScripts}) + } render() { const { config, menu, dict } = this.props - const { loading, activeKey, setting, defaultSql, columns, scripts } = this.state + const { loading, activeKey, setting, defaultSql, columns, scripts, preScripts, cbScripts } = this.state return ( <div className="model-table-setting-form-box" id="model-setting-form-body"> @@ -404,11 +425,43 @@ scripts={scripts} defaultSql={defaultSql} searches={this.props.search} - scriptsChange={this.scriptsChange} scriptsUpdate={this.scriptsUpdate} wrappedComponentRef={(inst) => this.scriptsForm = inst} /> </TabPane> + <TabPane tab={ + <span> + 鍓嶇疆鑴氭湰 + {preScripts.length ? <span className="count-tip">{preScripts.length}</span> : null} + </span> + } key="prescripts"> + <SimpleScript + dict={dict} + setting={setting} + scripts={preScripts} + defaultSql={defaultSql} + searches={this.props.search} + scriptsChange={this.scriptsChange} + scriptsUpdate={this.preScriptsUpdate} + wrappedComponentRef={(inst) => this.preScriptsForm = inst} + /> + </TabPane> + <TabPane tab={ + <span> + 鍥炶皟鑴氭湰 + {cbScripts.length ? <span className="count-tip">{cbScripts.length}</span> : null} + </span> + } key="cbscripts"> + <SimpleScript + dict={dict} + setting={setting} + scripts={cbScripts} + searches={this.props.search} + scriptsChange={this.scriptsChange} + scriptsUpdate={this.scriptsUpdate} + wrappedComponentRef={(inst) => this.cbScriptsForm = inst} + /> + </TabPane> </Tabs> </div> ) diff --git a/src/templates/sharecomponent/settingcomponent/settingform/simplescript/index.jsx b/src/templates/sharecomponent/settingcomponent/settingform/simplescript/index.jsx new file mode 100644 index 0000000..a559a1f --- /dev/null +++ b/src/templates/sharecomponent/settingcomponent/settingform/simplescript/index.jsx @@ -0,0 +1,417 @@ +import React, {Component} from 'react' +import PropTypes from 'prop-types' +import { fromJS } from 'immutable' +import { Form, Row, Col, Icon, Button, notification, Select, Popconfirm, Typography } from 'antd' +import moment from 'moment' + +import Utils from '@/utils/utils.js' +import Api from '@/api' +import CodeMirror from '@/templates/zshare/codemirror' +import asyncComponent from '@/utils/asyncComponent' +import './index.scss' + +const { Paragraph } = Typography +const EditTable = asyncComponent(() => import('@/templates/zshare/editTable')) + +class CustomForm extends Component { + static propTpyes = { + dict: PropTypes.object, // 瀛楀吀椤� + setting: PropTypes.object, // 璁剧疆 + scripts: PropTypes.array, // 鑷畾涔夎剼鏈垪琛� + searches: PropTypes.array, // 鎼滅储鏉′欢 + defaultSql: PropTypes.string, // 榛樿sql + scriptsChange: PropTypes.func, // 鑷畾涔夎剼鏈垏鎹㈡椂楠岃瘉 + scriptsUpdate: PropTypes.func // 琛ㄥ崟 + } + + state = { + editItem: null, + loading: false, + usefulFields: '', + systemScripts: [], + scriptsColumns: [ + { + title: 'SQL', + dataIndex: 'sql', + width: '73%', + render: (text) => { + let title = text.match(/^\s*\/\*.+\*\//) + title = title && title[0] ? title[0] : '' + text = title ? text.replace(title, '') : text + + return ( + <div> + {title ? <span style={{color: '#a50'}}>{title}</span> : null} + <Paragraph copyable ellipsis={{ rows: 4, expandable: true }}>{text}</Paragraph> + </div> + ) + } + }, + { + title: '鐘舵��', + dataIndex: 'status', + width: '12%', + render: (text, record) => record.status === 'false' ? + ( + <div> + {this.props.dict['model.status.forbidden']} + <Icon style={{marginLeft: '5px'}} type="stop" theme="twoTone" twoToneColor="#ff4d4f" /> + </div> + ) : + ( + <div> + {this.props.dict['model.status.open']} + <Icon style={{marginLeft: '5px'}} type="check-circle" theme="twoTone" twoToneColor="#52c41a" /> + </div> + ) + }, + { + title: '鎿嶄綔', + align: 'center', + width: '15%', + dataIndex: 'operation', + render: (text, record) => + (<div style={{textAlign: 'center'}}> + <span className="operation-btn" title={this.props.dict['model.edit']} onClick={() => this.handleEdit(record)} style={{color: '#1890ff'}}><Icon type="edit" /></span> + <span className="operation-btn" title={this.props.dict['header.form.status.change']} onClick={() => this.handleStatus(record)} style={{color: '#8E44AD'}}><Icon type="swap" /></span> + <Popconfirm + overlayClassName="popover-confirm" + title={this.props.dict['model.query.delete']} + onConfirm={() => this.handleDelete(record) + }> + <span className="operation-btn" style={{color: '#ff4d4f'}}><Icon type="delete" /></span> + </Popconfirm> + </div>) + } + ] + } + + UNSAFE_componentWillMount() { + const { searches, scripts } = this.props + + let _usefulFields = [] + searches.forEach(item => { + if (!item.field) return + if (item.type === 'group') { + if (item.transfer === 'true') { + _usefulFields.push(item.field) + } + _usefulFields.push(item.datefield) + _usefulFields.push(item.datefield + '1') + } else if (['dateweek', 'datemonth', 'daterange'].includes(item.type)) { + _usefulFields.push(item.field) + _usefulFields.push(item.field + '1') + } else if (_usefulFields.includes(item.field)) { + _usefulFields.push(item.field + '1') + } else { + _usefulFields.push(item.field) + } + }) + + this.setState({ + usefulFields: _usefulFields.join(', '), + scripts: fromJS(scripts).toJS() + }) + } + + componentDidMount () { + this.getsysScript() + } + + getsysScript = () => { + let _scriptSql = `Select distinct func+Remark as funcname,longparam, s.Sort from聽 s_custom_script s inner join (select OpenID from sapp where ID=@Appkey@) p on s.openid = case when s.appkey='' then s.openid else p.OpenID end order by s.Sort` + + _scriptSql = Utils.formatOptions(_scriptSql) + + let _sParam = { + func: 'sPC_Get_SelectedList', + LText: _scriptSql, + obj_name: 'data', + arr_field: 'funcname,longparam' + } + + _sParam.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + _sParam.secretkey = Utils.encrypt(_sParam.LText, _sParam.timestamp) + _sParam.open_key = Utils.encryptOpenKey(_sParam.secretkey, _sParam.timestamp) // 浜戠鏁版嵁楠岃瘉 + + Api.getSystemConfig(_sParam).then(res => { + if (res.status) { + let _scripts = res.data.map(item => { + let _item = { + name: item.funcname, + value: window.decodeURIComponent(window.atob(item.longparam)) + // value: Utils.UnformatOptions(item.longparam) + } + return _item + }) + + this.setState({ + systemScripts: _scripts + }) + } else { + notification.warning({ + top: 92, + message: res.message, + duration: 5 + }) + } + }) + } + + handleCancel = () => { + this.setState({ + editItem: null + }) + this.props.form.setFieldsValue({ + sql: '' + }) + } + + handleConfirm = () => { + const { scripts, editItem } = this.state + + let _sql = this.props.form.getFieldValue('sql') + + if (!_sql) { + notification.warning({ + top: 92, + message: '璇峰~鍐欒嚜瀹氫箟鑴氭湰锛�', + duration: 5 + }) + return + } else if (/^\s+$/.test(_sql)) { + notification.warning({ + top: 92, + message: '鑷畾涔夎剼鏈笉鍙负绌猴紒', + duration: 5 + }) + return + } + + let values = { + uuid: editItem && editItem.uuid ? editItem.uuid : Utils.getuuid(), + sql: _sql + } + + let _quot = values.sql.match(/'{1}/g) + let _lparen = values.sql.match(/\({1}/g) + let _rparen = values.sql.match(/\){1}/g) + + _quot = _quot ? _quot.length : 0 + _lparen = _lparen ? _lparen.length : 0 + _rparen = _rparen ? _rparen.length : 0 + + if (_quot % 2 !== 0) { + notification.warning({ + top: 92, + message: 'sql涓璡'蹇呴』鎴愬鍑虹幇', + duration: 5 + }) + return + } else if (_lparen !== _rparen) { + notification.warning({ + top: 92, + message: 'sql涓�()蹇呴』鎴愬鍑虹幇', + duration: 5 + }) + return + } else if (/--/ig.test(values.sql)) { + notification.warning({ + top: 92, + message: '鑷畾涔塻ql璇彞涓紝涓嶅彲鍑虹幇瀛楃 -- 锛屾敞閲婅鐢� /*鍐呭*/', + duration: 5 + }) + return + } + + let error = Utils.verifySql(values.sql, 'customscript') + + if (error) { + notification.warning({ + top: 92, + message: 'sql涓笉鍙娇鐢�' + error, + duration: 5 + }) + return + } + + let _scripts = fromJS(scripts).toJS() + + if (editItem && editItem.uuid) { + _scripts = _scripts.map(item => { + if (item.uuid === values.uuid) { + return values + } else { + return item + } + }) + } else { + _scripts.push(values) + } + + this.setState({loading: true}) + this.props.scriptsChange(_scripts).then(res => { + this.setState({ + loading: false, + scripts: _scripts, + editItem: null + }) + + this.props.scriptsUpdate(_scripts) + this.props.form.setFieldsValue({ + sql: '' + }) + }, () => { + this.setState({loading: false}) + }) + } + + selectScript = (value, option) => { + let _sql = this.props.form.getFieldValue('sql') + if (_sql) { + _sql = _sql + ` + + ` + } + + _sql = _sql.replace(/\s{6}$/, '') + _sql = _sql + `/*${option.props.children}*/ + ` + _sql = _sql.replace(/\s{4}$/, '') + _sql = _sql + value + + this.props.form.setFieldsValue({ + sql: _sql + }) + } + + handleEdit = (record) => { + this.setState({ + editItem: record + }) + + this.props.form.setFieldsValue({ + sql: record.sql + }) + + this.scrolltop() + } + + scrolltop = () => { + let node = document.getElementById('model-setting-form-body').parentNode + + if (node && node.scrollTop) { + let inter = Math.ceil(node.scrollTop / 10) + + let timer = setInterval(() => { + if (node.scrollTop - inter > 0) { + node.scrollTop = node.scrollTop - inter + } else { + node.scrollTop = 0 + clearInterval(timer) + } + }, 10) + } + } + + changeScripts = (scripts) => { + this.setState({scripts}) + this.props.scriptsUpdate(scripts) + } + + handleStatus = (record) => { + let scripts = fromJS(this.state.scripts).toJS() + record.status = record.status === 'false' ? 'true' : 'false' + + scripts = scripts.map(item => { + if (item.uuid === record.uuid) { + return record + } else { + return item + } + }) + + this.setState({scripts}) + this.props.scriptsUpdate(scripts) + } + + handleDelete = (record) => { + let scripts = fromJS(this.state.scripts).toJS() + scripts = scripts.filter(item => item.uuid !== record.uuid) + + this.setState({ scripts }) + this.props.scriptsUpdate(scripts) + } + + render() { + const { setting, defaultSql, scripts } = this.props + const { getFieldDecorator } = this.props.form + const { usefulFields, scriptsColumns, systemScripts } = this.state + const formItemLayout = { + labelCol: { + xs: { span: 24 }, + sm: { span: 8 } + }, + wrapperCol: { + xs: { span: 24 }, + sm: { span: 16 } + } + } + + return ( + <div className="modal-menu-setting-script"> + <Form {...formItemLayout}> + <Row gutter={24}> + {setting.tableName ? <Col span={8}> + <Form.Item label={'琛ㄥ悕'} style={{whiteSpace: 'nowrap', margin: 0}}> + {setting.tableName} + </Form.Item> + </Col> : null} + <Col span={16}> + <Form.Item label={'鎶ラ敊瀛楁'} style={{margin: 0}}> + ErrorCode, retmsg + </Form.Item> + </Col> + <Col span={24} className="sqlfield"> + <Form.Item label={'鍙敤瀛楁'}> + id, bid, loginuid, sessionuid, userid, username, fullname, appkey, time_id, orderBy{setting.laypage === 'true' ? ', pageSize, pageIndex': ''}{usefulFields ? ', ' + usefulFields : ''} + </Form.Item> + </Col> + <Col span={10} className="quick-add"> + <Form.Item label={'蹇嵎娣诲姞'} style={{marginBottom: 0}}> + <Select + showSearch + filterOption={(input, option) => option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0} + onChange={this.selectScript} + > + <Select.Option key="default" value={defaultSql}>榛樿sql</Select.Option> + {systemScripts.map((option, i) => + <Select.Option style={{whiteSpace: 'normal'}} key={i} value={option.value}>{option.name}</Select.Option> + )} + </Select> + </Form.Item> + </Col> + <Col span={6} className="add"> + <Button onClick={this.handleConfirm} loading={this.state.loading} className="mk-green" style={{marginTop: 5, marginBottom: 15, marginLeft: 30}}> + 淇濆瓨 + </Button> + <Button onClick={this.handleCancel} style={{marginTop: 5, marginBottom: 15, marginLeft: 10}}> + 鍙栨秷 + </Button> + </Col> + <Col span={24} className="sql"> + <Form.Item label={'sql'}> + {getFieldDecorator('sql', { + initialValue: '' + })(<CodeMirror />)} + </Form.Item> + </Col> + </Row> + </Form> + <EditTable data={scripts} actions={['move']} columns={scriptsColumns} onChange={this.changeScripts}/> + </div> + ) + } +} + +export default Form.create()(CustomForm) \ No newline at end of file diff --git a/src/templates/sharecomponent/settingcomponent/settingform/simplescript/index.scss b/src/templates/sharecomponent/settingcomponent/settingform/simplescript/index.scss new file mode 100644 index 0000000..945809b --- /dev/null +++ b/src/templates/sharecomponent/settingcomponent/settingform/simplescript/index.scss @@ -0,0 +1,45 @@ +.modal-menu-setting-script { + .sqlfield { + .ant-form-item { + margin-bottom: 5px; + } + .ant-form-item-control { + line-height: 24px; + } + .ant-form-item-label { + line-height: 25px; + } + .ant-form-item-children { + line-height: 22px; + } + .ant-col-sm-8 { + width: 10.5%; + } + .ant-col-sm-16 { + width: 89.5%; + } + } + .quick-add { + .ant-col-sm-8 { + width: 26%; + } + .ant-col-sm-16 { + width: 74%; + } + } + .sql { + .ant-col-sm-8 { + width: 10.5%; + } + .ant-col-sm-16 { + width: 89.5%; + padding-top: 4px; + } + .CodeMirror { + height: 350px; + } + } + div.ant-typography { + margin-bottom: 0; + } +} \ No newline at end of file diff --git a/src/templates/sharecomponent/treesettingcomponent/settingform/index.jsx b/src/templates/sharecomponent/treesettingcomponent/settingform/index.jsx index 285aff8..38552f7 100644 --- a/src/templates/sharecomponent/treesettingcomponent/settingform/index.jsx +++ b/src/templates/sharecomponent/treesettingcomponent/settingform/index.jsx @@ -8,10 +8,11 @@ import Utils from '@/utils/utils.js' import SettingUtils from './utils.jsx' import DataSource from './datasource' -import CustomScript from '@/templates/zshare/customscript' +import asyncComponent from '@/utils/asyncComponent' import './index.scss' const { TabPane } = Tabs +const CustomScript = asyncComponent(() => import('@/templates/zshare/customscript')) class SettingForm extends Component { static propTpyes = { diff --git a/src/templates/zshare/customscript/index.jsx b/src/templates/zshare/customscript/index.jsx index 0a3834e..a559a1f 100644 --- a/src/templates/zshare/customscript/index.jsx +++ b/src/templates/zshare/customscript/index.jsx @@ -139,7 +139,8 @@ let _scripts = res.data.map(item => { let _item = { name: item.funcname, - value: Utils.UnformatOptions(item.longparam) + value: window.decodeURIComponent(window.atob(item.longparam)) + // value: Utils.UnformatOptions(item.longparam) } return _item }) diff --git a/src/templates/zshare/formconfig.jsx b/src/templates/zshare/formconfig.jsx index fd7dfe4..bc9eab3 100644 --- a/src/templates/zshare/formconfig.jsx +++ b/src/templates/zshare/formconfig.jsx @@ -687,7 +687,7 @@ options: opentypes }, { - type: 'select', + type: 'radio', key: 'funcType', label: Formdict['header.form.funcType'], initVal: card.funcType || '', @@ -727,10 +727,25 @@ }, { type: 'text', - key: 'sql', - label: Formdict['model.form.tablename'], - initVal: card.sql || config.setting.tableName || '', - required: true + key: 'label', + label: '鎸夐挳鍚嶇О', + initVal: card.label, + required: true, + readonly: false + }, + { + type: 'radio', + key: 'procMode', + label: '鍙傛暟澶勭悊', + initVal: card.procMode || 'system', + required: true, + options: [{ + value: 'system', + text: '绯荤粺鍑芥暟' + }, { + value: 'inner', + text: '鍐呴儴鍑芥暟' + }] }, { type: 'radio', @@ -742,11 +757,10 @@ }, { type: 'text', - key: 'label', - label: '鎸夐挳鍚嶇О', - initVal: card.label, - required: true, - readonly: false + key: 'sql', + label: Formdict['model.form.tablename'], + initVal: card.sql || config.setting.tableName || '', + required: true }, { type: 'text', @@ -839,12 +853,20 @@ readonly: false }, { - type: 'text', + type: 'textarea', key: 'interface', label: Formdict['header.form.interface'], initVal: card.sysInterface === 'true' ? (window.GLOB.mainSystemApi || '') : (card.interface || ''), required: true, readonly: card.sysInterface === 'true' + }, + { + type: 'textarea', + key: 'proInterface', + label: '姝e紡鍦板潃', + initVal: card.proInterface || '', + tooltip: '姝e紡绯荤粺鎵�浣跨敤鐨勬帴鍙e湴鍧�銆�', + required: false }, { type: 'radio', @@ -861,23 +883,15 @@ }] }, { - type: 'text', - key: 'proInterface', - label: '姝e紡鍦板潃', - initVal: card.proInterface || '', - tooltip: '姝e紡绯荤粺鎵�浣跨敤鐨勬帴鍙e湴鍧�銆�', - required: false - }, - { type: 'radio', key: 'callbackType', label: '鍥炶皟鏂瑰紡', - initVal: card.callbackType || 'default', + initVal: card.callbackType || 'script', tooltip: '浣跨敤榛樿鏂瑰紡鎵ц鏃讹紝闇�瑕侀厤鍚堣鍒掍换鍔°��', required: true, options: [{ value: 'default', - text: '榛樿鎵ц' + text: '榛樿鑴氭湰' }, { value: 'script', text: '鑷畾涔夎剼鏈�' diff --git a/src/templates/zshare/verifycard/callbackcustomscript/index.jsx b/src/templates/zshare/verifycard/callbackcustomscript/index.jsx index b53a5fd..86d96e5 100644 --- a/src/templates/zshare/verifycard/callbackcustomscript/index.jsx +++ b/src/templates/zshare/verifycard/callbackcustomscript/index.jsx @@ -162,6 +162,7 @@ } selectScript = (value, option) => { + if (!value || !option) return let _sql = this.props.form.getFieldValue('sql') if (_sql) { _sql = _sql + ` @@ -195,13 +196,13 @@ } return ( - <Form {...formItemLayout} className="verify-form" id="verify-custom-scripts"> + <Form {...formItemLayout} className="verify-form" id="verify-custom-callback-scripts"> <Row gutter={24}> - {btn.cbTable ? <Col span={8}> + <Col span={8}> <Form.Item label={'琛ㄥ悕'} style={{whiteSpace: 'nowrap', margin: 0}}> {btn.cbTable} </Form.Item> - </Col> : null} + </Col> <Col span={16}> <Form.Item label={'鎶ラ敊瀛楁'} style={{margin: 0}}> ErrorCode, retmsg @@ -227,11 +228,13 @@ <Col span={10}> <Form.Item label={'蹇嵎娣诲姞'} style={{marginBottom: 0}}> <Select + allowClear showSearch filterOption={(input, option) => option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0} onChange={this.selectScript} - getPopupContainer={() => document.getElementById('verify-custom-scripts')} + getPopupContainer={() => document.getElementById('verify-custom-callback-scripts')} > + <Select.Option key="default" value={`declare @${btn.cbTable} table (mk_api_key nvarchar(100))`}>榛樿sql</Select.Option> {systemScripts.map((option, i) => <Select.Option key={i} value={option.value}>{option.name}</Select.Option> )} diff --git a/src/templates/zshare/verifycard/customscript/index.jsx b/src/templates/zshare/verifycard/customscript/index.jsx index 1914af3..6a10c5d 100644 --- a/src/templates/zshare/verifycard/customscript/index.jsx +++ b/src/templates/zshare/verifycard/customscript/index.jsx @@ -171,6 +171,8 @@ } selectScript = (value, option) => { + if (!value || !option) return + let _sql = this.props.form.getFieldValue('sql') if (_sql) { _sql = _sql + ` @@ -243,6 +245,7 @@ <Form.Item label={'蹇嵎娣诲姞'} style={{marginBottom: 0}}> <Select showSearch + allowClear filterOption={(input, option) => option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0} onChange={this.selectScript} getPopupContainer={() => document.getElementById('verify-custom-scripts')} diff --git a/src/templates/zshare/verifycard/index.jsx b/src/templates/zshare/verifycard/index.jsx index d93f37e..dbd3a0d 100644 --- a/src/templates/zshare/verifycard/index.jsx +++ b/src/templates/zshare/verifycard/index.jsx @@ -977,7 +977,8 @@ systemScripts: res.scripts.map(item => { return { name: item.funcname, - value: Utils.UnformatOptions(item.longparam) + value: window.decodeURIComponent(window.atob(item.longparam)) + // value: Utils.UnformatOptions(item.longparam) } }) }) @@ -1381,8 +1382,8 @@ return ( <div id="verify-card-box-tab"> - {card.intertype === 'system' || card.intertype === 'custom' ? <Tabs defaultActiveKey="1" className="verify-card-box"> - <TabPane tab="鍩虹楠岃瘉" key="1"> + <Tabs defaultActiveKey="1" className="verify-card-box"> + {card.intertype === 'system' || (card.intertype === 'custom' && card.procMode === 'system') ? <TabPane tab="鍩虹楠岃瘉" key="1"> <Form {...formItemLayout}> <Row gutter={24}> {this.props.card.sqlType !== 'custom' ? <Col span={8}> @@ -1488,8 +1489,8 @@ </Col> : null} </Row> </Form> - </TabPane> - <TabPane tab={ + </TabPane> : null} + {card.intertype === 'system' || (card.intertype === 'custom' && card.procMode === 'system') ? <TabPane tab={ <span> 姣旇緝楠岃瘉 {verify.contrasts.length ? <span className="count-tip">{verify.contrasts.length}</span> : null} @@ -1497,8 +1498,8 @@ } key="2x"> <ContrastForm dict={this.props.dict} contrastChange={this.contrastChange}/> <EditTable actions={['edit', 'move', 'copy', 'del']} type="contrastverify" data={verify.contrasts} columns={contrastColumns} onChange={(contrasts) => this.setState({verify: {...verify, contrasts}})}/> - </TabPane> - <TabPane tab={ + </TabPane> : null} + {card.intertype === 'system' || (card.intertype === 'custom' && card.procMode === 'system') ? <TabPane tab={ <span> 鑷畾涔夐獙璇� {verify.customverifys.length ? <span className="count-tip">{verify.customverifys.length}</span> : null} @@ -1513,8 +1514,8 @@ wrappedComponentRef={(inst) => this.customForm = inst} /> <EditTable actions={['move']} data={verify.customverifys} columns={customColumns} onChange={(customverifys) => {this.setState({verify: {...verify, customverifys}})}}/> - </TabPane> - <TabPane tab={ + </TabPane> : null} + {card.intertype === 'system' || (card.intertype === 'custom' && card.procMode === 'system') ? <TabPane tab={ <span> 鍗曞彿鐢熸垚 {verify.billcodes.length ? <span className="count-tip">{verify.billcodes.length}</span> : null} @@ -1532,8 +1533,8 @@ wrappedComponentRef={(inst) => this.orderForm = inst} /> <EditTable actions={['move']} data={verify.billcodes} columns={orderColumns} onChange={(billcodes) => {this.setState({verify: {...verify, billcodes}})}}/> - </TabPane> - <TabPane tab={ + </TabPane> : null} + {card.intertype === 'system' || (card.intertype === 'custom' && card.procMode === 'system') ? <TabPane tab={ <span> {card.Ot !== 'requiredOnce' ? '鍞竴鎬ч獙璇�' : '鍚岀被鏁版嵁楠岃瘉'} {verify.uniques.length ? <span className="count-tip">{verify.uniques.length}</span> : null} @@ -1546,8 +1547,8 @@ uniqueChange={this.uniqueChange} /> <EditTable actions={['edit', 'move', 'del']} data={verify.uniques} columns={card.Ot !== 'requiredOnce' ? uniqueColumns : onceUniqueColumns} onChange={this.changeUniques}/> - </TabPane> - <TabPane tab={ + </TabPane> : null} + {card.intertype === 'system' || (card.intertype === 'custom' && card.procMode === 'system') ? <TabPane tab={ <span> 鍒涘缓鍑瘉 {verify.voucher && verify.voucher.enabled ? <span className="count-tip">1</span> : null} @@ -1562,8 +1563,8 @@ voucherChange={this.voucherChange} wrappedComponentRef={(inst) => this.voucherForm = inst} /> - </TabPane> - <TabPane tab={ + </TabPane> : null} + {card.intertype === 'system' || (card.intertype === 'custom' && card.procMode === 'system') ? <TabPane tab={ <span> 鑷畾涔夎剼鏈� {verify.scripts.length ? <span className="count-tip">{verify.scripts.length}</span> : null} @@ -1581,7 +1582,7 @@ wrappedComponentRef={(inst) => this.scriptsForm = inst} /> <EditTable actions={['move']} data={verify.scripts} columns={scriptsColumns} onChange={(scripts) => {this.setState({verify: {...verify, scripts}})}}/> - </TabPane> + </TabPane> : null} {card.callbackType === 'script' && card.intertype === 'custom' ? <TabPane tab={ <span> 鍥炶皟鑴氭湰 @@ -1685,96 +1686,7 @@ </Row> </Form> </TabPane> - </Tabs> : null} - {card.intertype !== 'system' && card.intertype !== 'custom' ? <Tabs defaultActiveKey="7" className="verify-card-box"> - <TabPane tab="淇℃伅鎻愮ず" key="7"> - <Form {...formItemLayout}> - <Row gutter={24}> - <Col offset={6} span={6}> - <Form.Item label={'鎻愮ず缂栫爜'}> - <span className="errorval"> S </span> - <Button onClick={() => {this.showError('S')}} type="primary" size="small"> - 鏌ョ湅 - </Button> - </Form.Item> - </Col> - <Col span={8}> - <Form.Item label={'鍋滅暀鏃堕棿'}> - <InputNumber defaultValue={verify.stime || 2} min={1} max={10000} precision={0} onChange={(val) => {this.timeChange(val, 'stime')}} /> - </Form.Item> - </Col> - </Row> - <Row gutter={24}> - <Col offset={6} span={6}> - <Form.Item label={'鎻愮ず缂栫爜'}> - <span className="errorval"> Y </span> - <Button onClick={() => {this.showError('Y')}} type="primary" size="small"> - 鏌ョ湅 - </Button> - </Form.Item> - </Col> - </Row> - <Row gutter={24}> - <Col offset={6} span={6}> - <Form.Item label={'鎻愮ず缂栫爜'}> - <span className="errorval"> N </span> - <Button onClick={() => {this.showError('N')}} type="primary" size="small"> - 鏌ョ湅 - </Button> - </Form.Item> - </Col> - <Col span={8}> - <Form.Item label={'鍋滅暀鏃堕棿'}> - <InputNumber defaultValue={verify.ntime || 10} min={1} max={10000} precision={0} onChange={(val) => {this.timeChange(val, 'ntime')}} /> - </Form.Item> - </Col> - </Row> - <Row gutter={24}> - <Col offset={6} span={6}> - <Form.Item label={'鎻愮ず缂栫爜'}> - <span className="errorval"> F </span> - <Button onClick={() => {this.showError('F')}} type="primary" size="small"> - 鏌ョ湅 - </Button> - </Form.Item> - </Col> - <Col span={8}> - <Form.Item label={'鍋滅暀鏃堕棿'}> - <InputNumber defaultValue={verify.ftime || 10} min={1} max={10000} precision={0} onChange={(val) => {this.timeChange(val, 'ftime')}} /> - </Form.Item> - </Col> - </Row> - <Row gutter={24}> - <Col offset={6} span={6}> - <Form.Item label={'鎻愮ず缂栫爜'}> - <span className="errorval"> E </span> - <Button onClick={() => {this.showError('E')}} type="primary" size="small"> - 鏌ョ湅 - </Button> - </Form.Item> - </Col> - </Row> - <Row gutter={24}> - <Col offset={6} span={6}> - <Form.Item label={'鎻愮ず缂栫爜'}> - <span className="errorval"> NM </span> - <Button onClick={() => {this.showError('NM')}} type="primary" size="small"> - 鏌ョ湅 - </Button> - </Form.Item> - </Col> - </Row> - <Row gutter={24}> - <Col offset={6} span={6}> - <Form.Item label={'鎻愮ず缂栫爜'}> - <span className="errorval"> -1 </span> - 涓嶆彁绀� - </Form.Item> - </Col> - </Row> - </Form> - </TabPane> - </Tabs> : null} + </Tabs> </div> ) } -- Gitblit v1.8.0