From 3df2d3624c6b768d29670b537f8d6a71d3ef122c Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期日, 12 四月 2020 22:04:53 +0800 Subject: [PATCH] 2020-04-12 --- src/templates/comtableconfig/index.jsx | 136 ++++++++++++++++++++++++++++++++++++++++---- 1 files changed, 122 insertions(+), 14 deletions(-) diff --git a/src/templates/comtableconfig/index.jsx b/src/templates/comtableconfig/index.jsx index e328ef9..832bea2 100644 --- a/src/templates/comtableconfig/index.jsx +++ b/src/templates/comtableconfig/index.jsx @@ -80,7 +80,8 @@ thawBtnVisible: false, // 瑙e喕鎸夐挳寮圭獥 thawbtnlist: null, // 瑙e喕鎸夐挳鍒楄〃 thawButtons: [], // 宸查�夋嫨瑕佽В鍐荤殑鎸夐挳 - activeKey: '0' // 榛樿灞曞紑鍩烘湰淇℃伅 + activeKey: '0', // 榛樿灞曞紑鍩烘湰淇℃伅 + sqlVerifing: false // sql楠岃瘉 } /** @@ -124,6 +125,7 @@ _config.tabgroups = _config.tabgroups || ['tabs'] _config.setting.subtabs = _config.setting.subtabs || [] _config.Template = 'CommonTable' + _config.easyCode = _config.easyCode || '' let _oriActions = [] if (_config.type === 'user') { @@ -224,6 +226,14 @@ MenuID: 'currenttab', text: this.state.dict['header.form.currenttab'] }] + }, + { + type: 'text', + key: 'easyCode', + label: this.state.dict['header.form.easyCode'], + initVal: _config.easyCode, + required: false, + readonly: false } ] }) @@ -733,11 +743,46 @@ _search = _search.filter(item => !item.origin) - this.setState({ - config: {...config, search: _search}, - optionLibs: optionLibs, - modaltype: '' - }) + if ((res.type === 'select' || res.type === 'multiselect' || res.type === 'link') && res.resourceType === '1' && /\s/.test(res.dataSource)) { + this.setState({ + sqlVerifing: true + }) + + let param = { + func: 's_debug_sql', + LText: res.dataSource + } + 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) + + if (window.GLOB.mainSystemApi && res.database === 'sso') { + param.rduri = window.GLOB.mainSystemApi + } + + Api.getLocalConfig(param).then(result => { + if (result.status) { + this.setState({ + sqlVerifing: false, + config: {...config, search: _search}, + optionLibs: optionLibs, + modaltype: '' + }) + } else { + this.setState({sqlVerifing: false}) + + Modal.error({ + title: result.message + }) + } + }) + } else { + this.setState({ + config: {...config, search: _search}, + optionLibs: optionLibs, + modaltype: '' + }) + } }) } else if (modaltype === 'actionEdit' || modaltype === 'actionCopy') { this.actionFormRef.handleConfirm().then(res => { @@ -1512,7 +1557,7 @@ } let _LongParam = '' - let _config = {...config, tables: this.state.selectedTables} + let _config = {...config, tables: this.state.selectedTables, easyCode: res.easyCode} let _pageParam = {...menu.PageParam, OpenType: res.opentype} // 鏈缃暟鎹簮鎴栨爣绛句笉鍚堟硶鏃讹紝鍚敤鐘舵�佷负false @@ -1731,6 +1776,7 @@ ParentID: res.parentId, MenuID: menu.MenuID, MenuNo: res.menuNo, + EasyCode: res.easyCode, Template: menu.PageParam.Template || '', MenuName: res.menuName, PageParam: JSON.stringify(_pageParam), @@ -2098,7 +2144,7 @@ }) } else { this.menuformRef.handleConfirm().then(res => { - let _config = {...config, tables: this.state.selectedTables} + let _config = {...config, tables: this.state.selectedTables, easyCode: res.easyCode} let _pageParam = {...menu.PageParam, OpenType: res.opentype} let _originMenu = { ...originMenu, @@ -2436,10 +2482,71 @@ Api.getLocalConfig(param) } - this.setState({ - config: {...config, setting: res}, - settingVisible: false, - }) + + + if (res.interType === 'inner' && !res.innerFunc && /\s/.test(res.dataresource)) { + this.setState({ + sqlVerifing: true + }) + + let _dataresource = res.dataresource + + if (res.queryType === 'statistics') { + let fieldmap = new Map() + let options = config.search.map(item => { + let _field = item.key + let _val = '' + + if (fieldmap.has(_field)) { + _field = _field + '1' + } + + fieldmap.set(item.key, true) + + if (/date/.test(item.type)) { + _val = '1900-01-01' + } + + return { + reg: new RegExp('@' + _field + '@', 'ig'), + value: _val + } + }) + + options.forEach(item => { + _dataresource = _dataresource.replace(item.reg, `'${item.value}'`) + }) + } + + let param = { + func: 's_debug_sql', + LText: _dataresource + } + 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) + + Api.getLocalConfig(param).then(result => { + if (result.status) { + this.setState({ + sqlVerifing: false, + config: {...config, setting: res}, + settingVisible: false + }) + } else { + this.setState({sqlVerifing: false}) + + Modal.error({ + title: result.message + }) + } + }) + } else { + this.setState({ + config: {...config, setting: res}, + settingVisible: false + }) + } }) } @@ -2458,7 +2565,7 @@ }) } else { this.menuformRef.handleConfirm().then(res => { - let _config = {...config, tables: this.state.selectedTables} + let _config = {...config, tables: this.state.selectedTables, easyCode: res.easyCode} let _pageParam = {...menu.PageParam, OpenType: res.opentype} let _originMenu = { ...originMenu, @@ -3115,6 +3222,7 @@ width={700} maskClosable={false} onOk={this.handleSubmit} + confirmLoading={this.state.sqlVerifing} onCancel={this.editModalCancel} destroyOnClose > @@ -3310,7 +3418,7 @@ <CreateInterface key="interface" dict={this.state.dict} ref="tableCreatInterface" trigger={this.tableCreatInterface}/>, <CreateFunc key="create" dict={this.state.dict} ref="tableCreatFunc" trigger={this.tableCreatFunc}/>, <Button key="cancel" onClick={() => { this.setState({ settingVisible: false }) }}>{this.state.dict['header.cancel']}</Button>, - <Button key="confirm" type="primary" onClick={this.settingSave}>{this.state.dict['header.confirm']}</Button> + <Button key="confirm" type="primary" loading={this.state.sqlVerifing} onClick={this.settingSave}>{this.state.dict['header.confirm']}</Button> ]} destroyOnClose > -- Gitblit v1.8.0