From d59f518f466274b2caeb2e01c10c92deafe7c93b Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期三, 09 二月 2022 11:48:29 +0800 Subject: [PATCH] 2022-02-09 --- src/templates/sharecomponent/treesettingcomponent/settingform/index.jsx | 35 +++++++++++++++++++++++++++-------- 1 files changed, 27 insertions(+), 8 deletions(-) diff --git a/src/templates/sharecomponent/treesettingcomponent/settingform/index.jsx b/src/templates/sharecomponent/treesettingcomponent/settingform/index.jsx index e71602e..3f3d3a4 100644 --- a/src/templates/sharecomponent/treesettingcomponent/settingform/index.jsx +++ b/src/templates/sharecomponent/treesettingcomponent/settingform/index.jsx @@ -8,17 +8,17 @@ 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 = { dict: PropTypes.object, // 瀛楀吀椤� menu: PropTypes.object, // 鑿滃崟淇℃伅 config: PropTypes.object, // 椤甸潰閰嶇疆淇℃伅 - permFuncField: PropTypes.array, // 瀛樺偍杩囩▼鍙敤瀛楁 inputSubmit: PropTypes.any // 鍥炶溅鎻愪氦浜嬩欢 } @@ -34,6 +34,18 @@ let _setting = fromJS(config.setting).toJS() let _scripts = _setting.scripts || [] + + if (window.GLOB.funcs && window.GLOB.funcs.length > 0) { + window.GLOB.funcs.forEach(m => { + let reg = new RegExp(`\\/\\*\\$ex@${m.func_code}-begin\\*\\/[\\s\\S]+\\/\\*@ex\\$-end\\*\\/`, 'ig') + _scripts.forEach(item => { + item.sql = item.sql.replace(reg, `$ex@${m.func_code}@ex$`) + }) + if (_setting.dataresource) { + _setting.dataresource = _setting.dataresource.replace(reg, `$ex@${m.func_code}@ex$`) + } + }) + } this.setState({ setting: _setting, @@ -74,7 +86,7 @@ let _loading = false if (this.scriptsForm && this.scriptsForm.state.editItem) { _loading = true - } else if (this.scriptsForm && this.scriptsForm.props.form.getFieldValue('sql')) { + } else if (this.scriptsForm && this.scriptsForm.props.form.getFieldValue('sql') && !/^\s+$/.test(this.scriptsForm.props.form.getFieldValue('sql'))) { _loading = true } @@ -125,11 +137,12 @@ } else { // type 涓� submit 銆� verify 锛屼互鍙婂叾浠栭渶瑕侀獙璇佺殑鍦烘櫙 let param = { func: 's_debug_sql', + exec_type: 'y', LText: SettingUtils.getDebugSql(setting, _scripts) } param.LText = Utils.formatOptions(param.LText) - param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000' - param.secretkey = Utils.encrypt(param.LText, param.timestamp) + param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + param.secretkey = Utils.encrypt('', param.timestamp) Api.getLocalConfig(param).then(result => { if (result.status) { @@ -181,6 +194,7 @@ }) }, () => { // 楠岃瘉澶辫触 this.setState({ + activeKey: val, loading: false }) }, activeKey) @@ -190,7 +204,7 @@ let _loading = false if (this.scriptsForm && this.scriptsForm.state.editItem) { _loading = true - } else if (this.scriptsForm && this.scriptsForm.props.form.getFieldValue('sql')) { + } else if (this.scriptsForm && this.scriptsForm.props.form.getFieldValue('sql') && !/^\s+$/.test(this.scriptsForm.props.form.getFieldValue('sql'))) { _loading = true } @@ -210,6 +224,7 @@ }) }, () => { // 楠岃瘉澶辫触 this.setState({ + activeKey: val, loading: false }) }, activeKey) @@ -241,12 +256,16 @@ menu={menu} dict={this.props.dict} setting={setting} - permFuncField={this.props.permFuncField} inputSubmit={this.props.inputSubmit} wrappedComponentRef={(inst) => this.settingForm = inst} /> </TabPane> - <TabPane tab="鑷畾涔夎剼鏈�" key="scripts"> + <TabPane tab={ + <span> + 鑷畾涔夎剼鏈� + {scripts.length ? <span className="count-tip">{scripts.length}</span> : null} + </span> + } key="scripts"> <CustomScript dict={this.props.dict} setting={setting} -- Gitblit v1.8.0