From 606b0b991748740179fa37448f645e6e9c7f1c41 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期日, 24 一月 2021 19:17:38 +0800 Subject: [PATCH] 2021-01-24 --- src/mob/datasource/verifycard/index.jsx | 1 src/tabviews/scriptmanage/index.jsx | 71 ++++++++++ src/templates/sharecomponent/settingcomponent/settingform/simplescript/index.jsx | 104 +++++++++----- src/templates/sharecomponent/settingcomponent/settingform/index.jsx | 84 +++++++++-- src/templates/sharecomponent/settingcomponent/settingform/datasource/index.jsx | 29 +++ src/templates/zshare/customscript/index.jsx | 3 src/templates/zshare/verifycard/index.jsx | 1 src/templates/sharecomponent/settingcomponent/index.scss | 1 src/templates/sharecomponent/actioncomponent/verifyexcelin/index.jsx | 1 src/templates/sharecomponent/settingcomponent/settingform/utils.jsx | 56 ++++++++ src/menu/datasource/verifycard/index.jsx | 1 src/utils/utils.js | 39 ----- 12 files changed, 280 insertions(+), 111 deletions(-) diff --git a/src/menu/datasource/verifycard/index.jsx b/src/menu/datasource/verifycard/index.jsx index d3d310f..1febad6 100644 --- a/src/menu/datasource/verifycard/index.jsx +++ b/src/menu/datasource/verifycard/index.jsx @@ -230,7 +230,6 @@ let _item = { name: item.funcname, 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 18e9efb..d02dff0 100644 --- a/src/mob/datasource/verifycard/index.jsx +++ b/src/mob/datasource/verifycard/index.jsx @@ -151,7 +151,6 @@ let _item = { name: item.funcname, value: window.decodeURIComponent(window.atob(item.longparam)) - // value: Utils.UnformatOptions(item.longparam) } _scripts.push(_item) diff --git a/src/tabviews/scriptmanage/index.jsx b/src/tabviews/scriptmanage/index.jsx index ab95a32..ed0910c 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 = this.UnformatOptions(item.LongParam) item.key = index return item }), @@ -153,6 +153,75 @@ } } + // UnformatOptions = (value) => { + // if (!value) return '' + // let salt = 'minKe' // 鐩愬�� + // let _value = '' + // const formatKeys = [ + // { key: 'select', value: ' msltk ' }, + // { key: 'from', value: ' mfrmk ' }, + // { key: 'where', value: ' mwhrk ' }, + // { key: 'order by', value: ' modbk ' }, + // { key: 'asc', value: ' modack ' }, + // { key: 'desc', value: ' moddesk ' }, + // { key: 'top', value: ' mtpk ' }, + // { key: 'like', value: ' mlkk ' }, + // { key: 'not like', value: ' mnlkk ' }, + // { key: 'between', value: ' mbtnk ' }, + // { key: 'and', value: ' madk ' }, + // { key: 'insert', value: ' mistk ' }, + // { key: 'into', value: ' mitk ' }, + // { key: 'update', value: ' muptk ' }, + // { key: 'delete', value: ' mdelk ' }, + // { key: 'begin', value: ' mbgink ' }, + // { key: 'end', value: ' medk ' }, + // { key: 'if', value: ' mefk ' }, + // { key: 'while', value: ' mwilk ' }, + // { key: 'create', value: ' mcrtk ' }, + // { key: 'alter', value: ' matek ' }, + // { key: 'len', value: ' mlnk ' }, + // { key: 'left', value: ' mlftk ' }, + // { key: 'right', value: ' mritk ' }, + // { key: 'union', value: ' munok ' }, + // { key: 'varchar', value: ' mvcrk ' }, + // { key: 'getdate', value: ' mgtdtk ' }, + // { key: 'TRY', value: ' mtryonek ' }, + // { key: 'TRAN', value: ' mtrnk ' }, + // { key: 'goto', value: ' mgtk ' }, + // { key: 'set', value: ' mstk ' }, + // { key: 'ROLLBACK', value: ' mrlbkk ' } + // ] + + // try { + // try { + // _value = JSON.parse(window.decodeURIComponent(window.atob(value))) + // } catch { + // _value = '' + // } + + // if (!_value) { + // _value = window.atob(value) + // _value = _value.replace(salt, '') + // _value = window.decodeURIComponent(window.atob(_value)) + + // _value = _value.replace(/\smpercent\s/g, '%') + + // formatKeys.forEach(item => { + // let reg = new RegExp(item.value, 'g') + // _value = _value.replace(reg, ' ' + item.key + ' ') + // }) + + // _value = _value.replace(/\s\n\s/ig, '\n') + // _value = _value.replace(/(^\s+|\s+$)/ig, '') + // } + // } catch { + // console.warn('UnFormat Failure') + // _value = '' + // } + + // return _value + // } + /** * @description 鑾峰彇绯荤粺瀛樺偍杩囩▼ sPC_Get_TableData 鐨勫弬鏁� */ diff --git a/src/templates/sharecomponent/actioncomponent/verifyexcelin/index.jsx b/src/templates/sharecomponent/actioncomponent/verifyexcelin/index.jsx index a645ca3..adca1a9 100644 --- a/src/templates/sharecomponent/actioncomponent/verifyexcelin/index.jsx +++ b/src/templates/sharecomponent/actioncomponent/verifyexcelin/index.jsx @@ -300,7 +300,6 @@ return { name: item.funcname, value: window.decodeURIComponent(window.atob(item.longparam)) - // value: Utils.UnformatOptions(item.longparam) } }) }) diff --git a/src/templates/sharecomponent/settingcomponent/index.scss b/src/templates/sharecomponent/settingcomponent/index.scss index 135e66c..41b2501 100644 --- a/src/templates/sharecomponent/settingcomponent/index.scss +++ b/src/templates/sharecomponent/settingcomponent/index.scss @@ -15,6 +15,7 @@ padding-bottom: 5px; .ant-modal-body { max-height: calc(100vh - 190px); + min-height: 250px; overflow-y: auto; padding-top: 10px; } diff --git a/src/templates/sharecomponent/settingcomponent/settingform/datasource/index.jsx b/src/templates/sharecomponent/settingcomponent/settingform/datasource/index.jsx index 53ea2eb..dd2f8e1 100644 --- a/src/templates/sharecomponent/settingcomponent/settingform/datasource/index.jsx +++ b/src/templates/sharecomponent/settingcomponent/settingform/datasource/index.jsx @@ -19,11 +19,12 @@ setting: PropTypes.object, // 鏁版嵁婧愰厤缃� columns: PropTypes.array, // 鍒楄缃� scripts: PropTypes.array, // 鑷畾涔夎剼鏈� + updateStatus: PropTypes.func, // 鐘舵�佹洿鏂� } state = { interType: 'system', - procMode: 'system', + procMode: 'script', requestMode: 'system', funcTooltip: '', funcRules: [] @@ -59,7 +60,7 @@ this.setState({ interType: setting.interType || 'system', - procMode: setting.procMode || 'system', + procMode: setting.procMode || 'script', requestMode: setting.requestMode || 'system', funcTooltip: tooltip, funcRules: rules @@ -175,6 +176,7 @@ interface: window.GLOB.mainSystemApi || '' }) } + this.props.updateStatus({[key]: value}) } primaryKeyChange = (val) => { @@ -279,7 +281,7 @@ ] })( <Radio.Group style={{whiteSpace: 'nowrap'}} onChange={(e) => {this.onRadioChange(e, 'procMode')}}> - <Radio value="system">鍓嶇疆鑴氭湰</Radio> + <Radio value="script">鍓嶇疆鑴氭湰</Radio> <Radio value="inner">鍓嶇疆鍑芥暟</Radio> </Radio.Group>)} </Form.Item> @@ -463,15 +465,32 @@ {interType === 'custom' ? <Col span={12}> <Form.Item label="鍥炶皟鏂瑰紡"> {getFieldDecorator('callbackType', { - initialValue: setting.callbackType || 'default' + initialValue: setting.callbackType || 'script' })( - <Radio.Group> + <Radio.Group onChange={(e) => {this.onRadioChange(e, 'callbackType')}}> <Radio value="default">榛樿鑴氭湰</Radio> <Radio value="script">鑷畾涔夎剼鏈�</Radio> </Radio.Group>)} </Form.Item> </Col> : null} {interType === 'custom' ? <Col span={12}> + <Form.Item label="鍥炶皟琛ㄥ悕"> + {getFieldDecorator('cbTable', { + initialValue: setting.cbTable || '', + rules: [ + { + required: true, + message: dict['form.required.input'] + '鍥炶皟琛ㄥ悕!' + }, + { + max: formRule.input.max, + message: formRule.input.message + } + ] + })(<Input placeholder={''} autoComplete="off" />)} + </Form.Item> + </Col> : null} + {interType === 'custom' ? <Col span={12}> <Form.Item label={ <Tooltip placement="topLeft" title={'鍚屾鎵ц锛氬閮ㄦ帴鍙h皟鐢ㄦ垚鍔熷悗鍐嶈姹傛暟鎹紱寮傛鎵ц锛氬閮ㄦ帴鍙h皟鐢ㄤ笌璇锋眰鏁版嵁鍚屾椂杩涜銆�'}> <Icon type="question-circle" /> diff --git a/src/templates/sharecomponent/settingcomponent/settingform/index.jsx b/src/templates/sharecomponent/settingcomponent/settingform/index.jsx index b5c4ffe..0ee9ff9 100644 --- a/src/templates/sharecomponent/settingcomponent/settingform/index.jsx +++ b/src/templates/sharecomponent/settingcomponent/settingform/index.jsx @@ -31,7 +31,8 @@ arr_field: '', regoptions: [], setting: null, - defaultSql: '' + defaultSql: '', + status: {} } UNSAFE_componentWillMount() { @@ -80,6 +81,11 @@ _search = _search.replace(/@\$@/ig, '') _search = _search ? 'where ' + _search : '' + let status = fromJS(_setting).toJS() + status.requestMode = status.requestMode || 'system' + status.procMode = status.procMode || 'script' + status.callbackType = status.callbackType || 'script' + this.setState({ setting: _setting, search: _search, @@ -88,7 +94,8 @@ columns: columns, scripts: _scripts, preScripts: _preScripts, - cbScripts: _cbScripts + cbScripts: _cbScripts, + status }) } @@ -147,7 +154,7 @@ } handleConfirm = (trigger) => { - const { activeKey, setting, scripts } = this.state + const { activeKey, setting, scripts, preScripts, cbScripts } = this.state let _loading = false if (this.scriptsForm && this.scriptsForm.props.form.getFieldValue('sql')) { @@ -195,7 +202,7 @@ this.setState({loading: false}) reject() return - } else if (res.interType === 'system' && res.default === 'false' && _scripts.length === 0) { + } else if ((res.interType === 'system' || res.requestMode === 'system') && res.default === 'false' && _scripts.length === 0) { notification.warning({ top: 92, message: '涓嶆墽琛岄粯璁ql鏃讹紝璇锋坊鍔犺嚜瀹氫箟鑴氭湰锛�', @@ -210,7 +217,7 @@ }, () => { this.sqlverify(() => { this.setState({loading: false}) - resolve({...res, scripts}) + resolve({...res, scripts, preScripts, cbScripts}) }, () => { this.setState({loading: false}) reject() @@ -221,7 +228,7 @@ reject() }) }) - } else { + } else if (activeKey === 'scripts') { return new Promise((resolve, reject) => { if (trigger === 'func' && setting.interType !== 'inner') { notification.warning({ @@ -231,7 +238,7 @@ }) this.setState({loading: false}) reject() - } else if (setting.interType === 'system' && setting.default === 'false' && _scripts.length === 0) { + } else if ((setting.interType === 'system' || setting.requestMode === 'system') && setting.default === 'false' && _scripts.length === 0) { notification.warning({ top: 92, message: '涓嶆墽琛岄粯璁ql鏃讹紝璇锋坊鍔犺嚜瀹氫箟鑴氭湰锛�', @@ -242,12 +249,17 @@ } else { this.sqlverify(() => { this.setState({loading: false}) - resolve({...setting, scripts}) + resolve({...setting, scripts, preScripts, cbScripts}) }, () => { this.setState({loading: false}) reject() }, 'submit') } + }) + } else { + this.setState({loading: false}) + return new Promise((resolve) => { + resolve({...setting, scripts, preScripts, cbScripts}) }) } } @@ -255,7 +267,7 @@ sqlverify = (_resolve, _reject, type, uscripts) => { const { setting, scripts, arr_field, regoptions, search } = this.state - if (setting.interType !== 'system') { // 涓嶄娇鐢ㄧ郴缁熸帴鍙f椂锛屼笉闇�瑕乻ql楠岃瘉 + if (setting.interType !== 'system' && setting.requestMode !== 'system') { // 涓嶄娇鐢ㄧ郴缁熸帴鍙f椂锛屼笉闇�瑕乻ql楠岃瘉 _resolve() return } @@ -296,7 +308,7 @@ // 鏍囩鍒囨崲 changeTab = (val) => { - const { activeKey, search, arr_field } = this.state + const { activeKey, search, arr_field, setting } = this.state let _loading = false if (this.scriptsForm && this.scriptsForm.props.form.getFieldValue('sql')) { @@ -316,13 +328,38 @@ return } + if (activeKey !== 'setting') { + if (setting.interType !== 'system' && setting.requestMode !== 'system' && val === 'scripts') { + notification.warning({ + top: 92, + message: '浣跨敤绯荤粺鎺ュ彛鏃讹紝鎵嶅彲浠ヨ缃嚜瀹氫箟鑴氭湰锛�', + duration: 5 + }) + return + } else if (setting.interType !== 'custom' && (val === 'prescripts' || val === 'cbscripts')) { + notification.warning({ + top: 92, + message: '浣跨敤鑷畾涔夋帴鍙f椂锛屾墠鍙互璁剧疆鍓嶇疆鎴栧洖璋冭剼鏈紒', + duration: 5 + }) + return + } + } + if (activeKey === 'setting') { let _defaultSql = '' this.settingForm.handleConfirm().then(res => { - if (res.interType !== 'system') { + if (res.interType !== 'system' && res.requestMode !== 'system' && val === 'scripts') { notification.warning({ top: 92, message: '浣跨敤绯荤粺鎺ュ彛鏃讹紝鎵嶅彲浠ヨ缃嚜瀹氫箟鑴氭湰锛�', + duration: 5 + }) + return + } else if (res.interType !== 'custom' && (val === 'prescripts' || val === 'cbscripts')) { + notification.warning({ + top: 92, + message: '浣跨敤鑷畾涔夋帴鍙f椂锛屾墠鍙互璁剧疆鍓嶇疆鎴栧洖璋冭剼鏈紒', duration: 5 }) return @@ -369,6 +406,10 @@ loading: false }) }, activeKey) + } else { + this.setState({ + activeKey: val + }) } } @@ -394,9 +435,13 @@ this.setState({cbScripts}) } + updateStatus = (status) => { + this.setState({status: {...this.state.status, ...status}}) + } + render() { const { config, menu, dict } = this.props - const { loading, activeKey, setting, defaultSql, columns, scripts, preScripts, cbScripts } = this.state + const { loading, activeKey, setting, defaultSql, columns, scripts, preScripts, cbScripts, status, regoptions } = this.state return ( <div className="model-table-setting-form-box" id="model-setting-form-body"> @@ -410,6 +455,7 @@ columns={columns} setting={setting} scripts={scripts} + updateStatus={this.updateStatus} wrappedComponentRef={(inst) => this.settingForm = inst} /> </TabPane> @@ -418,13 +464,14 @@ 鑷畾涔夎剼鏈� {scripts.length ? <span className="count-tip">{scripts.length}</span> : null} </span> - } key="scripts"> + } disabled={!(status.interType === 'system' || (status.interType === 'custom' && status.requestMode === 'system'))} key="scripts"> <CustomScript dict={dict} setting={setting} scripts={scripts} defaultSql={defaultSql} searches={this.props.search} + scriptsChange={this.scriptsChange} scriptsUpdate={this.scriptsUpdate} wrappedComponentRef={(inst) => this.scriptsForm = inst} /> @@ -434,14 +481,13 @@ 鍓嶇疆鑴氭湰 {preScripts.length ? <span className="count-tip">{preScripts.length}</span> : null} </span> - } key="prescripts"> + } disabled={status.interType !== 'custom' || status.procMode !== 'script'} key="prescripts"> <SimpleScript dict={dict} setting={setting} scripts={preScripts} - defaultSql={defaultSql} + regoptions={regoptions} searches={this.props.search} - scriptsChange={this.scriptsChange} scriptsUpdate={this.preScriptsUpdate} wrappedComponentRef={(inst) => this.preScriptsForm = inst} /> @@ -451,14 +497,12 @@ 鍥炶皟鑴氭湰 {cbScripts.length ? <span className="count-tip">{cbScripts.length}</span> : null} </span> - } key="cbscripts"> + } disabled={status.interType !== 'custom' || status.callbackType !== 'script'} key="cbscripts"> <SimpleScript dict={dict} setting={setting} scripts={cbScripts} - searches={this.props.search} - scriptsChange={this.scriptsChange} - scriptsUpdate={this.scriptsUpdate} + scriptsUpdate={this.cbScriptsUpdate} wrappedComponentRef={(inst) => this.cbScriptsForm = inst} /> </TabPane> diff --git a/src/templates/sharecomponent/settingcomponent/settingform/simplescript/index.jsx b/src/templates/sharecomponent/settingcomponent/settingform/simplescript/index.jsx index a559a1f..391053d 100644 --- a/src/templates/sharecomponent/settingcomponent/settingform/simplescript/index.jsx +++ b/src/templates/sharecomponent/settingcomponent/settingform/simplescript/index.jsx @@ -1,11 +1,12 @@ 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 { Form, Row, Col, Icon, Button, notification, Select, Popconfirm, Typography, Modal } from 'antd' import moment from 'moment' import Utils from '@/utils/utils.js' import Api from '@/api' +import SettingUtils from '../utils' import CodeMirror from '@/templates/zshare/codemirror' import asyncComponent from '@/utils/asyncComponent' import './index.scss' @@ -19,7 +20,7 @@ setting: PropTypes.object, // 璁剧疆 scripts: PropTypes.array, // 鑷畾涔夎剼鏈垪琛� searches: PropTypes.array, // 鎼滅储鏉′欢 - defaultSql: PropTypes.string, // 榛樿sql + regoptions: PropTypes.any, // 姝e垯鏇挎崲 scriptsChange: PropTypes.func, // 鑷畾涔夎剼鏈垏鎹㈡椂楠岃瘉 scriptsUpdate: PropTypes.func // 琛ㄥ崟 } @@ -90,26 +91,32 @@ const { searches, scripts } = this.props let _usefulFields = [] - searches.forEach(item => { - if (!item.field) return - if (item.type === 'group') { - if (item.transfer === 'true') { + + if (searches) { + 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) } - _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) - } - }) + }) + _usefulFields = _usefulFields.join(', ') + } else { + _usefulFields = null + } this.setState({ - usefulFields: _usefulFields.join(', '), + usefulFields: _usefulFields, scripts: fromJS(scripts).toJS() }) } @@ -140,7 +147,6 @@ let _item = { name: item.funcname, value: window.decodeURIComponent(window.atob(item.longparam)) - // value: Utils.UnformatOptions(item.longparam) } return _item }) @@ -249,24 +255,39 @@ _scripts.push(values) } + let param = { + func: 's_debug_sql', + exec_type: 'y', + LText: SettingUtils.getCustomDebugSql(_scripts, this.props.regoptions) + } + param.LText = Utils.formatOptions(param.LText) + param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + param.secretkey = Utils.encrypt('', param.timestamp) + 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}) + Api.getLocalConfig(param).then(result => { + if (result.status) { + this.setState({ + loading: false, + scripts: _scripts, + editItem: null + }) + + this.props.scriptsUpdate(_scripts) + this.props.form.setFieldsValue({ + sql: '' + }) + } else { + this.setState({loading: false}) + Modal.error({ + title: result.message + }) + } }) } selectScript = (value, option) => { + if (!value || !option) return let _sql = this.props.form.getFieldValue('sql') if (_sql) { _sql = _sql + ` @@ -344,7 +365,7 @@ } render() { - const { setting, defaultSql, scripts } = this.props + const { setting, scripts } = this.props const { getFieldDecorator } = this.props.form const { usefulFields, scriptsColumns, systemScripts } = this.state const formItemLayout = { @@ -362,29 +383,30 @@ <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} + <Col span={8}> + <Form.Item label={'鍥炶皟琛ㄥ悕'} style={{whiteSpace: 'nowrap', margin: 0}}> + {setting.cbTable} </Form.Item> - </Col> : null} + </Col> <Col span={16}> <Form.Item label={'鎶ラ敊瀛楁'} style={{margin: 0}}> ErrorCode, retmsg </Form.Item> </Col> - <Col span={24} className="sqlfield"> + {usefulFields ? <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 : ''} + id, bid, loginuid, sessionuid, userid, username, fullname, appkey, time_id{usefulFields ? ', ' + usefulFields : ''} </Form.Item> - </Col> + </Col> : null} <Col span={10} className="quick-add"> <Form.Item label={'蹇嵎娣诲姞'} style={{marginBottom: 0}}> <Select + allowClear showSearch filterOption={(input, option) => option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0} onChange={this.selectScript} > - <Select.Option key="default" value={defaultSql}>榛樿sql</Select.Option> + {!usefulFields ? <Select.Option key="default" value={`declare @${setting.cbTable} table (mk_api_key nvarchar(100))`}>榛樿sql</Select.Option> : null} {systemScripts.map((option, i) => <Select.Option style={{whiteSpace: 'normal'}} key={i} value={option.value}>{option.name}</Select.Option> )} diff --git a/src/templates/sharecomponent/settingcomponent/settingform/utils.jsx b/src/templates/sharecomponent/settingcomponent/settingform/utils.jsx index 9bde95a..4298827 100644 --- a/src/templates/sharecomponent/settingcomponent/settingform/utils.jsx +++ b/src/templates/sharecomponent/settingcomponent/settingform/utils.jsx @@ -99,4 +99,60 @@ return sql } + + /** + * @description 鐢熸垚鍓嶇疆鎴栧悗缃鍙� + * @return {String} scripts 鑴氭湰 + * @return {Array} regoptions 鎼滅储鏉′欢姝e垯鏇挎崲 + */ + static getCustomDebugSql (scripts, regoptions) { + let sql = '' + let _customScript = '' + + scripts.forEach(script => { + if (script.status === 'false') return + + _customScript += ` + ${script.sql} + ` + }) + + if (_customScript) { + _customScript = `declare @ErrorCode nvarchar(50),@retmsg nvarchar(4000),@UserName nvarchar(50),@FullName nvarchar(50) select @ErrorCode='',@retmsg ='' + ${_customScript} + ` + } + + _customScript = _customScript.replace(/@\$|\$@/ig, '') + // 澶栬仈鏁版嵁搴撴浛鎹� + if (window.GLOB.externalDatabase !== null) { + _customScript = _customScript.replace(/@db@/ig, window.GLOB.externalDatabase) + } + + // 姝e垯鏇挎崲 + if (regoptions) { + let _regoptions = regoptions.map(item => { + return { + reg: new RegExp('@' + item.key + '@', 'ig'), + value: `'0'` + } + }) + _regoptions.forEach(item => { + _customScript = _customScript.replace(item.reg, item.value) + }) + } + + if (_customScript) { + sql = `/* sql 楠岃瘉 */ + ${_customScript} + aaa: + if @ErrorCode!='' + insert into tmp_err_retmsg (ID, ErrorCode, retmsg, CreateUserID) select @time_id@,@ErrorCode, @retmsg,@UserID@ + ` + } + sql = sql.replace(/\n\s{8}/ig, '\n') + console.info(sql) + + return sql + } } \ No newline at end of file diff --git a/src/templates/zshare/customscript/index.jsx b/src/templates/zshare/customscript/index.jsx index a559a1f..b7c3ecb 100644 --- a/src/templates/zshare/customscript/index.jsx +++ b/src/templates/zshare/customscript/index.jsx @@ -140,7 +140,6 @@ let _item = { name: item.funcname, value: window.decodeURIComponent(window.atob(item.longparam)) - // value: Utils.UnformatOptions(item.longparam) } return _item }) @@ -267,6 +266,7 @@ } selectScript = (value, option) => { + if (!value || !option) return let _sql = this.props.form.getFieldValue('sql') if (_sql) { _sql = _sql + ` @@ -380,6 +380,7 @@ <Col span={10} className="quick-add"> <Form.Item label={'蹇嵎娣诲姞'} style={{marginBottom: 0}}> <Select + allowClear showSearch filterOption={(input, option) => option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0} onChange={this.selectScript} diff --git a/src/templates/zshare/verifycard/index.jsx b/src/templates/zshare/verifycard/index.jsx index dbd3a0d..b5dd64b 100644 --- a/src/templates/zshare/verifycard/index.jsx +++ b/src/templates/zshare/verifycard/index.jsx @@ -978,7 +978,6 @@ return { name: item.funcname, value: window.decodeURIComponent(window.atob(item.longparam)) - // value: Utils.UnformatOptions(item.longparam) } }) }) diff --git a/src/utils/utils.js b/src/utils/utils.js index f98e18e..373792a 100644 --- a/src/utils/utils.js +++ b/src/utils/utils.js @@ -183,45 +183,6 @@ } /** - * @description 瑙e瘑 - * @return {String} value - */ - static UnformatOptions (value) { - if (!value) return '' - let salt = 'minKe' // 鐩愬�� - let _value = '' - - try { - try { - _value = JSON.parse(window.decodeURIComponent(window.atob(value))) - } catch { - _value = '' - } - - if (!_value) { - _value = window.atob(value) - _value = _value.replace(salt, '') - _value = window.decodeURIComponent(window.atob(_value)) - - _value = _value.replace(/\smpercent\s/g, '%') - - formatKeys.forEach(item => { - let reg = new RegExp(item.value, 'g') - _value = _value.replace(reg, ' ' + item.key + ' ') - }) - - _value = _value.replace(/\s\n\s/ig, '\n') - _value = _value.replace(/(^\s+|\s+$)/ig, '') - } - } catch { - console.warn('UnFormat Failure') - _value = '' - } - - return _value - } - - /** * @description sPC_TableData_InUpDe sql鍔犲瘑 * @return {String} value */ -- Gitblit v1.8.0