From 55a89127d14a20a96720d9050295743f2090f046 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期一, 09 九月 2024 22:29:37 +0800 Subject: [PATCH] 2024-09-09 --- src/components/tabview/index.jsx | 14 src/utils/utils-datamanage.js | 421 ++--- src/templates/sharecomponent/actioncomponent/verifyexcelout/customscript/index.jsx | 2 src/tabviews/zshare/actionList/funcbutton/index.jsx | 79 + src/tabviews/custom/components/editor/braft-editor/index.jsx | 40 src/tabviews/zshare/topSearch/index.jsx | 210 ++ src/utils/utils-custom.js | 754 +++++++++- src/templates/sharecomponent/actioncomponent/verifypay/customscript/index.jsx | 2 src/views/mkiframe/index.jsx | 8 src/tabviews/zshare/actionList/excelInbutton/index.jsx | 609 ++++++-- src/tabviews/zshare/actionList/exceloutbutton/index.jsx | 16 src/views/rolemanage/index.jsx | 7 src/tabviews/custom/popview/index.jsx | 31 src/views/design/sidemenu/index.scss | 9 src/views/tabledesign/index.jsx | 23 src/tabviews/basetable/index.jsx | 4 src/api/index.js | 93 + src/tabviews/custom/components/module/invoice/index.jsx | 13 src/tabviews/zshare/actionList/newpagebutton/index.jsx | 121 + src/views/billprint/index.jsx | 36 src/views/design/sidemenu/index.jsx | 4 src/menu/components/module/invoice/verifycard/callbackcustomscript/index.jsx | 2 src/tabviews/zshare/actionList/normalbutton/index.jsx | 629 ++++++++ src/views/mobdesign/index.jsx | 51 src/views/menudesign/index.jsx | 23 src/utils/utils.js | 17 src/index.js | 1 src/menu/components/module/invoice/verifycard/customscript/index.jsx | 2 src/tabviews/custom/components/share/tabtransfer/index.jsx | 42 src/views/pcdesign/index.jsx | 51 src/tabviews/custom/components/table/edit-table/normalTable/mkPopSelect/index.jsx | 166 + src/menu/datasource/verifycard/settingform/index.jsx | 14 src/templates/zshare/pasteform/index.jsx | 4 src/tabviews/custom/components/table/edit-table/normalTable/index.jsx | 212 ++ src/tabviews/zshare/actionList/printbutton/index.jsx | 62 src/tabviews/zshare/mutilform/mkPopSelect/index.jsx | 166 + src/components/breadview/index.jsx | 12 src/tabviews/zshare/mutilform/index.jsx | 104 + src/tabviews/custom/index.jsx | 52 src/menu/components/editor/braft-editor/index.jsx | 3 src/menu/components/table/edit-table/columns/tableIn/customscript/index.jsx | 2 src/templates/zshare/verifycard/baseform/index.jsx | 2 src/components/pasteboard/index.jsx | 4 43 files changed, 3,313 insertions(+), 804 deletions(-) diff --git a/src/api/index.js b/src/api/index.js index b24fd12..48de454 100644 --- a/src/api/index.js +++ b/src/api/index.js @@ -671,6 +671,59 @@ param.LoginUID = param.LoginUID || sessionStorage.getItem('LoginUID') || '' param.appkey = window.GLOB.appkey || '' + if (param.$backend) { + delete param.$backend + + let id = '' + if (cache) { + id = param.data[0].id + + if (window.GLOB.CacheMap.has(id)) { + return Promise.resolve(window.GLOB.CacheMap.get(id)) + } + } + + param.username = sessionStorage.getItem('User_Name') || '' + param.fullname = sessionStorage.getItem('Full_Name') || '' + param.s_debug = window.GLOB.debugger ? 'Y' : '' + param.data_md5 = param.data_md5 || '' + param.time_limit = param.time_limit || 0 + + let url = '/webapi/exstars' + if (param.rduri) { + param.rduri = param.rduri.replace(/dostars/ig, 'exstars') + if (!window.GLOB.transfer) { + url = param.rduri + delete param.rduri + } + } + + param = this.encryptParam(param) + + return new Promise((resolve) => { + axios({ + url: url, + method: 'post', + data: JSON.stringify(param) + }).then(res => { + if (res.mksqls) { + res.mksqls.forEach(n => { + n = n.replace(/(UNION ALL\s+)?SELECT obj_name='[\S\s]+sub_field=''\s+/ig, '') + window.mkInfo(n) + }) + } + if (res.ErrCode === 'version_error') { + res.ErrCode = '-2' + MKEmitter.emit('reloadTabs') + } + if (res.status) { + window.GLOB.CacheMap.set(id, res) + } + resolve(res) + }) + }) + } + let url = '/webapi/dostars' if (param.rduri && !window.GLOB.transfer) { url = param.rduri @@ -938,6 +991,46 @@ } }) }) + } else if (param.$backend) { + delete param.$backend + + let url = '/webapi/exstars' + if (param.rduri) { + param.rduri = param.rduri.replace(/dostars/ig, 'exstars') + if (!window.GLOB.transfer) { + url = param.rduri + delete param.rduri + } + } + + param.username = sessionStorage.getItem('User_Name') || '' + param.fullname = sessionStorage.getItem('Full_Name') || '' + param.s_debug = window.GLOB.debugger ? 'Y' : '' + param.data_md5 = param.data_md5 || '' + param.time_limit = param.time_limit || 0 + + param = this.encryptParam(param) + + return new Promise((resolve) => { + axios({ + url: url, + method: 'post', + data: JSON.stringify(param), + requestId + }).then(res => { + if (res.mksqls) { + res.mksqls.forEach(n => { + n = n.replace(/(UNION ALL\s+)?SELECT obj_name='[\S\s]+sub_field=''\s+/ig, '') + window.mkInfo(n) + }) + } + if (res.ErrCode === 'version_error') { + res.ErrCode = '-2' + MKEmitter.emit('reloadTabs') + } + resolve(res) + }) + }) } else { let url = '/webapi/dostars' if (param.rduri && (!window.GLOB.transfer || /https:\/\/sso.mk9h.cn/.test(param.rduri)) && /\/dostars/.test(param.rduri) && param.func !== 'webapi_ChangeUser') { diff --git a/src/components/breadview/index.jsx b/src/components/breadview/index.jsx index ac52d25..340b188 100644 --- a/src/components/breadview/index.jsx +++ b/src/components/breadview/index.jsx @@ -42,9 +42,7 @@ componentDidMount () { MKEmitter.addListener('modifyTabs', this.modifyTabs) - if (window.GLOB.forcedUpdate) { - MKEmitter.addListener('reloadTabs', this.reloadTabs) - } + MKEmitter.addListener('reloadTabs', this.reloadTabs) } /** @@ -160,9 +158,15 @@ reloadTabs = () => { if (this.reloading) return - this.reloading = true let time = new Date().getTime() + let oldTime = sessionStorage.getItem('mk_reloadTabs') + + if (oldTime && time - oldTime < 180000) return + + sessionStorage.setItem('mk_reloadTabs', time) + + this.reloading = true this.setState({visible: true}) Api.getAppVersion(true).then((list) => { diff --git a/src/components/pasteboard/index.jsx b/src/components/pasteboard/index.jsx index c7a79a1..66c00c4 100644 --- a/src/components/pasteboard/index.jsx +++ b/src/components/pasteboard/index.jsx @@ -61,14 +61,14 @@ } } catch (e) { // 閫氳繃sql璇彞娣诲姞瀛楁闆� - if (/[a-zA-Z0-9_]+\s+(nvarchar\(\d+\)|Decimal\(18,\d+\)|Int)/ig.test(config)) { + if (/[a-zA-Z0-9_]+\s+(nvarchar\(\d+\)|Decimal\(18,\d+\)|Int|datetime|date)/ig.test(config)) { _config = { key: 'datasourcefield', type: 'array', data: [] } - let list = config.match(/[a-zA-Z0-9_]+\s+(nvarchar\(\d+\)|Decimal\(18,\d+\)|Int)/ig) + let list = config.match(/[a-zA-Z0-9_]+\s+(nvarchar\(\d+\)|Decimal\(18,\d+\)|Int|datetime|date)/ig) list.forEach(item => { _config.data.unshift({ diff --git a/src/components/tabview/index.jsx b/src/components/tabview/index.jsx index 88e48b9..dc50560 100644 --- a/src/components/tabview/index.jsx +++ b/src/components/tabview/index.jsx @@ -48,10 +48,7 @@ componentDidMount () { MKEmitter.addListener('modifyTabs', this.modifyTabs) MKEmitter.addListener('closeTabView', this.closeTabView) - - if (window.GLOB.forcedUpdate) { - MKEmitter.addListener('reloadTabs', this.reloadTabs) - } + MKEmitter.addListener('reloadTabs', this.reloadTabs) } /** @@ -157,9 +154,16 @@ reloadTabs = () => { if (this.reloading) return - this.reloading = true let time = new Date().getTime() + let oldTime = sessionStorage.getItem('mk_reloadTabs') + + if (oldTime && time - oldTime < 180000) return + + sessionStorage.setItem('mk_reloadTabs', time) + + this.reloading = true + this.setState({visible: true}) Api.getAppVersion(true).then((list) => { diff --git a/src/index.js b/src/index.js index 36ff7ed..1fac703 100644 --- a/src/index.js +++ b/src/index.js @@ -159,6 +159,7 @@ } if (/#\/hs$/.test(window.location.href)) { // hs涓嬩笉鎵撳嵃鑴氭湰 + config.systemRun = '' // hs 涓嶄娇鐢ㄥ悗绔浛鎹� GLOB.debugger = false if (GLOB.mainSystemApi) { diff --git a/src/menu/components/editor/braft-editor/index.jsx b/src/menu/components/editor/braft-editor/index.jsx index ba933e2..1b2c190 100644 --- a/src/menu/components/editor/braft-editor/index.jsx +++ b/src/menu/components/editor/braft-editor/index.jsx @@ -38,7 +38,7 @@ let _card = { uuid: card.uuid, type: card.type, - format: 'object', // 缁勪欢灞炴�� - 鏁版嵁鏍煎紡 + format: 'array', // 缁勪欢灞炴�� - 鏁版嵁鏍煎紡 pageable: false, // 缁勪欢灞炴�� - 鏄惁鍙垎椤� switchable: false, // 缁勪欢灞炴�� - 鏁版嵁鏄惁鍙垏鎹� width: card.width || 24, @@ -57,6 +57,7 @@ } else { let _card = fromJS(card).toJS() + _card.format = 'array' if (_card.wrap.firstTr === 'light') { _card.wrap.tbStyle = 'th-light' delete _card.wrap.firstTr diff --git a/src/menu/components/module/invoice/verifycard/callbackcustomscript/index.jsx b/src/menu/components/module/invoice/verifycard/callbackcustomscript/index.jsx index a7834c9..786f5c5 100644 --- a/src/menu/components/module/invoice/verifycard/callbackcustomscript/index.jsx +++ b/src/menu/components/module/invoice/verifycard/callbackcustomscript/index.jsx @@ -219,7 +219,7 @@ </Col> : null} {!type ? <Col span={8}> <Form.Item label="鎶ラ敊瀛楁" style={{margin: 0, whiteSpace: 'nowrap'}}> - errorcode锛堝鍔犲悗缂�NT琛ㄧず鏁版嵁涓嶅洖婊氾紝濡侲NT銆丯NT銆丗NT銆丯MNT銆丆NT銆�-2NT锛�, retmsg + errorcode, retmsg </Form.Item> </Col> : null} {!type ? <Col span={24} className="sqlfield"> diff --git a/src/menu/components/module/invoice/verifycard/customscript/index.jsx b/src/menu/components/module/invoice/verifycard/customscript/index.jsx index c9a1299..8d848ce 100644 --- a/src/menu/components/module/invoice/verifycard/customscript/index.jsx +++ b/src/menu/components/module/invoice/verifycard/customscript/index.jsx @@ -201,7 +201,7 @@ <Row gutter={24}> {!type ? <Col span={8}> <Form.Item label={'鎶ラ敊瀛楁'} style={{margin: 0, whiteSpace: 'nowrap'}}> - errorcode锛堝鍔犲悗缂�NT琛ㄧず鏁版嵁涓嶅洖婊氾紝濡侲NT銆丯NT銆丗NT銆丯MNT銆丆NT銆�-2NT锛�, retmsg + errorcode, retmsg </Form.Item> </Col> : null} {!type ? <Col span={24} className="sqlfield"> diff --git a/src/menu/components/table/edit-table/columns/tableIn/customscript/index.jsx b/src/menu/components/table/edit-table/columns/tableIn/customscript/index.jsx index 5468010..274f82e 100644 --- a/src/menu/components/table/edit-table/columns/tableIn/customscript/index.jsx +++ b/src/menu/components/table/edit-table/columns/tableIn/customscript/index.jsx @@ -268,7 +268,7 @@ </Col> : null} {!type ? <Col span={10}> <Form.Item label="鎶ラ敊瀛楁" style={{margin: 0, whiteSpace: 'nowrap'}}> - errorcode锛堝鍔犲悗缂�NT琛ㄧず鏁版嵁涓嶅洖婊氾紝濡侲NT銆丯NT銆丗NT銆丯MNT锛�, retmsg + errorcode, retmsg </Form.Item> </Col> : null} {!type ? <Col span={24} className="sqlfield"> diff --git a/src/menu/datasource/verifycard/settingform/index.jsx b/src/menu/datasource/verifycard/settingform/index.jsx index 56093f1..7bacde9 100644 --- a/src/menu/datasource/verifycard/settingform/index.jsx +++ b/src/menu/datasource/verifycard/settingform/index.jsx @@ -532,7 +532,7 @@ {/* 1銆佷笉鍒嗛〉涓斾笉瀛樺湪涓婄骇妯″潡 */} {!['navbar', 'interface', 'calendar'].includes(config.type) && !['editable', 'basetable', 'dualdatacard', 'invoice', 'invTable'].includes(config.subtype) && (!config.pageable || (config.pageable && setting.laypage === 'false')) && (setting.supModule.length === 0 || setting.supModule[0] === 'empty') && setting.interType === 'system' && setting.onload !== 'false' ? <Col span={8}> <Form.Item label={ - <Tooltip placement="topLeft" title={'鍒濆鍖栧姞杞芥椂锛屾槸鍚︿笌鍏朵粬缁勪欢涓�鍚屽姞杞芥暟鎹紝娉細濡傝彍鍗曟湭浣跨敤鍚庣缂撳瓨锛屽垯鏌ヨ璇彞澶т簬8000瀛楃鏃舵棤鏁堛��'}> + <Tooltip placement="topLeft" title={'鍒濆鍖栧姞杞芥椂锛屾槸鍚︿笌鍏朵粬缁勪欢涓�鍚屽姞杞芥暟鎹��'}> <QuestionCircleOutlined className="mk-form-tip" /> 鍚屾鏌ヨ </Tooltip> @@ -593,6 +593,18 @@ )} </Form.Item> </Col> : null} + {window.backend && setting.interType === 'system' ? <Col span={8}> + <Form.Item label="浜嬪姟"> + {getFieldDecorator('transact', { + initialValue: setting.transact || 'false' + })( + <Radio.Group onChange={(e) => {this.onOptionChange(e.target.value, 'transact')}}> + <Radio value="true">鍚敤</Radio> + <Radio value="false">绂佺敤</Radio> + </Radio.Group> + )} + </Form.Item> + </Col> : null} {config.type === 'interface' && ((setting.supModule && setting.supModule[0] === 'empty') || MenuType === 'billPrint') ? <Col span={8}> <Form.Item label={ <Tooltip placement="topLeft" title="鍒濆鍖栧姞杞藉皢鍦ㄩ〉闈㈠姞杞藉墠鎵ц銆�"> diff --git a/src/tabviews/basetable/index.jsx b/src/tabviews/basetable/index.jsx index c613378..d066c57 100644 --- a/src/tabviews/basetable/index.jsx +++ b/src/tabviews/basetable/index.jsx @@ -2,6 +2,7 @@ import PropTypes from 'prop-types' import { is, fromJS } from 'immutable' import { notification, Spin, Row, Col } from 'antd' +import md5 from 'md5' import Api from '@/api' import Utils from '@/utils/utils.js' @@ -177,7 +178,8 @@ if (window.backend && config.allSqls) { let keys = Object.keys(urlparam) config.allSqls.forEach(item => { - if (item.type === 'datasource') { + item.id = md5(window.GLOB.appkey + item.v_id) + if (item.type === 'datasource' || item.type === 'excelOut') { item.urlkeys = keys item.urlparam = urlparam if (config.flow_code) { diff --git a/src/tabviews/custom/components/editor/braft-editor/index.jsx b/src/tabviews/custom/components/editor/braft-editor/index.jsx index bac965b..d5a8cea 100644 --- a/src/tabviews/custom/components/editor/braft-editor/index.jsx +++ b/src/tabviews/custom/components/editor/braft-editor/index.jsx @@ -21,14 +21,14 @@ BID: '', // 涓婄骇ID config: null, // 鍥捐〃閰嶇疆淇℃伅 loading: false, // 鏁版嵁鍔犺浇鐘舵�� - data: {} // 鏁版嵁 + data: [] // 鏁版嵁 } UNSAFE_componentWillMount () { const { config } = this.props let _config = fromJS(config).toJS() - let _data = { $$empty: true } + let _data = [] let BID = '' let BData = '' @@ -47,8 +47,6 @@ if (_config.setting.sync === 'true' && window.GLOB.SyncData.has(_config.dataName)) { _data = window.GLOB.SyncData.get(_config.dataName) || [] - _data = _data[0] || {$$empty: true} - _config.setting.sync = 'false' window.GLOB.SyncData.delete(_config.dataName) @@ -56,6 +54,11 @@ } else if (_config.wrap.datatype === 'public' && window.GLOB.CacheData.has(_config.wrap.publicId)) { _data = window.GLOB.CacheData.get(_config.wrap.publicId) _data = fromJS(_data).toJS() + if (_data.$$empty) { + _data = [] + } else { + _data = [_data] + } } if (_config.wrap.minHeight) { @@ -122,7 +125,6 @@ if (config.$syncId !== syncId) return let _data = window.GLOB.SyncData.get(config.dataName) || [] - _data = _data[0] || {$$empty: true} this.setState({data: _data}) @@ -146,6 +148,11 @@ if (config.wrap.datatype === 'public' && config.wrap.publicId === publicId) { let _data = fromJS(data).toJS() + if (_data.$$empty) { + _data = [] + } else { + _data = [_data] + } this.setState({data: _data}) } @@ -180,13 +187,13 @@ if (config.wrap.datatype === 'static') { this.setState({ - data: {$$empty: true}, + data: [], loading: false }) return } else if (config.setting.supModule && !BID) { // BID 涓嶅瓨鍦ㄦ椂锛屼笉鍋氭煡璇� this.setState({ - data: {$$empty: true}, + data: [], loading: false }) return @@ -210,11 +217,8 @@ let result = await Api.genericInterface(param) if (result.status) { - let _data = result.data || [] - _data = _data[0] || {$$empty: true} - this.setState({ - data: _data, + data: result.data || [], loading: false }) @@ -231,7 +235,7 @@ render() { const { config, loading, data } = this.state - if (config.wrap.empty === 'hidden' && (!data || data.$$empty)) return null + if (config.wrap.empty === 'hidden' && (!data || data.length === 0)) return null return ( <div className={'custom-braft-editor-box ' + (config.wrap.tbStyle || '')} id={'anchor' + config.uuid} style={config.style}> @@ -242,10 +246,14 @@ </div> : null } <NormalHeader config={config}/> - <BraftContent - value={config.wrap.datatype !== 'static' ? (data[config.wrap.field] || '') : config.html} - encryption={config.wrap.datatype !== 'static' ? config.wrap.encryption : 'false'} - /> + {config.wrap.datatype === 'static' ? <BraftContent + value={config.html} + encryption={'false'} + /> : data.map((item, index) => <BraftContent + key={index} + value={item[config.wrap.field] || ''} + encryption={config.wrap.encryption} + />)} </div> ) } diff --git a/src/tabviews/custom/components/module/invoice/index.jsx b/src/tabviews/custom/components/module/invoice/index.jsx index 06fe3f8..5dc2ec4 100644 --- a/src/tabviews/custom/components/module/invoice/index.jsx +++ b/src/tabviews/custom/components/module/invoice/index.jsx @@ -864,10 +864,15 @@ 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) - } + if (Object.keys(item).length === 0) return + + Object.keys(item).forEach(k => { + if (item[k] === null) { + item[k] = '' + } + }) + item.$$key = tb + '_' + key + subObjs.push(item) }) } else if (Object.keys(val).length > 0) { val.$$key = tb + '_' + key diff --git a/src/tabviews/custom/components/share/tabtransfer/index.jsx b/src/tabviews/custom/components/share/tabtransfer/index.jsx index 56a17af..fee500a 100644 --- a/src/tabviews/custom/components/share/tabtransfer/index.jsx +++ b/src/tabviews/custom/components/share/tabtransfer/index.jsx @@ -50,9 +50,16 @@ UNSAFE_componentWillMount () { let _config = fromJS(this.props.config).toJS() + let BID = '' + let BData = window.GLOB.CacheData.get(_config.$pageId) + + if (BData) { + BID = BData.$BID || '' + } + let params = [] if (_config.type !== 'group') { - _config.components = this.formatSetting(_config.components, params) + _config.components = this.formatSetting(_config.components, params, BID) } else { let delay = 110 _config.components.forEach(item => { @@ -68,17 +75,17 @@ config: _config }, () => { if (params.length > 0) { - this.loadmaindata(params) + this.loadmaindata(params, BID) } }) } - formatSetting = (components, params) => { + formatSetting = (components, params, BID) => { let delay = 110 return components.map(item => { if (item.type === 'tabs') return item if (item.type === 'group') { - item.components = this.formatSetting(item.components, params) + item.components = this.formatSetting(item.components, params, BID) return item } @@ -102,7 +109,18 @@ item.setting.sync = 'false' item.setting.onload = 'false' } else { - params.push(getStructDefaultParam(item, searchlist, params.length === 0)) + let backend = false + if (window.backend && params.length === 0 && window.GLOB.CacheData.has('sql_' + item.uuid)) { + backend = true + } else if (window.backend && params[0] && params[0].exps) { + backend = true + } + + if (backend && !window.GLOB.CacheData.has('sql_' + item.uuid)) { + item.setting.sync = 'false' + } else { + params.push(getStructDefaultParam(item, searchlist, params.length === 0, BID)) + } } } @@ -116,19 +134,13 @@ /** * @description 涓昏〃鏁版嵁鍔犺浇 */ - loadmaindata = (params) => { + loadmaindata = (params, BID) => { const { config } = this.state - let BID = '' - let BData = window.GLOB.CacheData.get(config.$pageId) - - if (BData) { - BID = BData.$BID || '' - } let param = getStructuredParams(params, config, BID) if (config.$cache && config.$time) { - Api.getLCacheConfig(params[0].uuid, config.$time, BID).then(res => { + Api.getLCacheConfig(params[0].uuid || params[0].id, config.$time, BID).then(res => { if (!res.valid) { this.getMainData(param, params, config.uuid) } @@ -156,11 +168,11 @@ } params.forEach((item) => { - let _data = result[item.name] || '' + let _data = result[item.dataName] || '' if (_data && !Array.isArray(_data)) { _data = [_data] } - window.GLOB.SyncData.set(item.name, _data) + window.GLOB.SyncData.set(item.dataName, _data) }) MKEmitter.emit('transferSyncData', tabId) diff --git a/src/tabviews/custom/components/table/edit-table/normalTable/index.jsx b/src/tabviews/custom/components/table/edit-table/normalTable/index.jsx index 40cc3e9..34edff4 100644 --- a/src/tabviews/custom/components/table/edit-table/normalTable/index.jsx +++ b/src/tabviews/custom/components/table/edit-table/normalTable/index.jsx @@ -1515,7 +1515,11 @@ deForms: hasBid ? deForms : null }, () => { if (deForms.length > 0 && (!hasBid || BID)) { - this.improveActionForm(deForms, BID) + if (window.backend && window.GLOB.CacheData.has('sql_' + deForms[0].uuid)) { + this.improveBackActionForm(deForms, BID) + } else { + this.improveActionForm(deForms, BID) + } } }) } @@ -1529,7 +1533,11 @@ const { deForms } = this.state if (deForms && nextProps.BID !== BID) { - this.improveActionForm(deForms, nextProps.BID) + if (window.backend && window.GLOB.CacheData.has('sql_' + deForms[0].uuid)) { + this.improveBackActionForm(deForms, nextProps.BID) + } else { + this.improveActionForm(deForms, nextProps.BID) + } } if (parCtrl && !is(fromJS(this.props.columns), fromJS(nextProps.columns))) { let getColumns = (cols, sk) => { @@ -2000,6 +2008,98 @@ }) } + improveBackActionForm = (deForms, BID) => { + let sysvals = { + mk_departmentcode: sessionStorage.getItem('departmentcode') || '', + mk_organization: sessionStorage.getItem('organization') || '', + mk_user_type: sessionStorage.getItem('mk_user_type') || '', + bid: BID || '', + datam: sessionStorage.getItem('dataM') === 'true' ? 'Y' : '', + datam_begin: sessionStorage.getItem('dataM') === 'true' ? 'Y' : '', + datam_end: sessionStorage.getItem('dataM') === 'true' ? 'Y' : '' + } + if (window.GLOB.externalDatabase !== null) { + sysvals.db = window.GLOB.externalDatabase + } + + let deffers = [] + let mainItems = [] // 浜戠鎴栧崟鐐规暟鎹� + let localItems = [] // 鏈湴鏁版嵁 + + deForms.forEach(item => { + let ex = window.GLOB.CacheData.get('sql_' + item.uuid) + + if (!ex) return + + let exps = [] + ex.reps.forEach(n => { + let key = n.toLowerCase() + if (sysvals.hasOwnProperty(key)) { + exps.push({ + key: n, + value: sysvals[key] + }) + } + }) + + let cell = { + id: ex.id, + exps: exps, + menuname: item.label + '锛堣〃鍗曪級', + md5_id: '' + } + + if (item.database === 'sso' && window.GLOB.mainSystemApi) { + mainItems.push(cell) + } else { + localItems.push(cell) + } + }) + + if (localItems.length) { + deffers.push({ + $backend: true, + data: localItems + }) + } + + if (mainItems.length) { + deffers.push({ + $backend: true, + data: mainItems, + rduri: window.GLOB.mainSystemApi + }) + } + + if (!deffers.length) return + + deffers = deffers.map(item => { + return new Promise(resolve => { + Api.getSystemCacheConfig(item, false).then(res => { + if (!res.status) { + notification.warning({ + top: 92, + message: res.message, + duration: 5 + }) + } + resolve(res) + }) + }) + }) + + Promise.all(deffers).then(response => { + let result = {...response[0], ...(response[1] || {})} + + delete result.ErrCode + delete result.ErrMesg + delete result.message + delete result.status + + this.resetFormList(result) + }) + } + resetFormList = (result) => { const { columns, edData } = this.state @@ -2377,22 +2477,32 @@ if (!data) return - let result = getEditTableSql(submit, data, forms) - - let param = { - excel_in: result.lines, - BID: BID || '' - } - this.setState({ loading: true }) - if (submit.intertype === 'system') { // 绯荤粺瀛樺偍杩囩▼ - param.func = 'sPC_TableData_InUpDe' - - delete param.excel_in + if (submit.intertype === 'system' && window.backend && window.GLOB.CacheData.has('sql_' + submit.$menuId)) { + let ex = window.GLOB.CacheData.get('sql_' + submit.$menuId) + let param = this.getExps(ex, submit, data, forms) + Api.genericInterface(param).then((res) => { + if (res.status) { + this.execSuccess(res, record) + } else { + this.execError(res, record) + } + }, (error) => { + if (error && error.ErrCode === 'LoginError') return + + this.execError({}) + }) + } else if (submit.intertype === 'system') { // 绯荤粺瀛樺偍杩囩▼ + let result = getEditTableSql(submit, data, forms) + let param = {} + + param.func = 'sPC_TableData_InUpDe' + param.BID = BID || '' + param.exec_type = window.GLOB.execType || 'y' param.LText = Utils.formatOptions(result.sql, param.exec_type) param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') @@ -2416,7 +2526,12 @@ this.execError({}) }) } else if (submit.intertype === 'inner' && submit.innerFunc) { // 鑷畾涔夊瓨鍌ㄨ繃绋� + let result = getEditTableSql(submit, data, forms) + let param = {} + param.func = submit.innerFunc + param.BID = BID || '' + param.excel_in = result.lines if (submit.recordUser === 'true') { param.username = sessionStorage.getItem('User_Name') || '' @@ -2437,6 +2552,77 @@ } } + getExps = (ex, btn, data, forms) => { + const { BID } = this.props + + let exps = [] + let values = { + time_id: Utils.getguid(), + roleid: sessionStorage.getItem('role_id') || '', + mk_departmentcode: sessionStorage.getItem('departmentcode') || '', + mk_organization: sessionStorage.getItem('organization') || '', + mk_user_type: sessionStorage.getItem('mk_user_type') || '', + mk_nation: sessionStorage.getItem('nation') || '', + mk_province: sessionStorage.getItem('province') || '', + mk_city: sessionStorage.getItem('city') || '', + mk_district: sessionStorage.getItem('district') || '', + mk_address: sessionStorage.getItem('address') || '', + bid: BID || '', + typename: 'admin', + datam: sessionStorage.getItem('dataM') === 'true' ? 'Y' : '', + datam_begin: sessionStorage.getItem('dataM') === 'true' ? 'Y' : '', + datam_end: sessionStorage.getItem('dataM') === 'true' ? 'Y' : '', + } + + if (window.GLOB.externalDatabase !== null) { + values.db = window.GLOB.externalDatabase + } + + let lines = data.map(item => { + let vals = [] + forms.forEach(col => { + vals.push(item[col.field]) + }) + + vals.push(item.$$uuid) + vals.push(item.$type || 'upt') + vals.push(BID) + + return vals + }) + + ex.reps.forEach(n => { + let key = n.toLowerCase() + if (values.hasOwnProperty(key)) { + exps.push({ + key: n, + value: values[key] + }) + } + }) + + exps.push({ + key: 'mk_excel_data', + value: lines + }) + + let md5_id = '' + if (window.GLOB.probation) { + md5_id = md5(ex.id + JSON.stringify(exps) + Math.floor(new Date().getTime() / 600000)) + md5_id = moment().format('YYYYMMDDHHmmss') + md5_id.slice(-18) + } + + return { + $backend: true, + data: [{ + id: ex.id, + exps: exps, + menuname: btn.logLabel || '', + md5_id: md5_id + }] + } + } + execSuccess = (res, record) => { const { submit } = this.props const { edData, dict } = this.state diff --git a/src/tabviews/custom/components/table/edit-table/normalTable/mkPopSelect/index.jsx b/src/tabviews/custom/components/table/edit-table/normalTable/mkPopSelect/index.jsx index 6493202..7c1cc56 100644 --- a/src/tabviews/custom/components/table/edit-table/normalTable/mkPopSelect/index.jsx +++ b/src/tabviews/custom/components/table/edit-table/normalTable/mkPopSelect/index.jsx @@ -41,61 +41,127 @@ loading: true }) - let param = { - func: 'sPC_Get_TableData', - obj_name: 'data', - exec_type: window.GLOB.execType || 'y', - arr_field: config.arr_field, - default_sql: 'true', - custom_script: '', - menuname: config.label - } + let param = null + if (window.backend && window.GLOB.CacheData.has('sql_' + config.uuid)) { + let ex = window.GLOB.CacheData.get('sql_' + config.uuid) + let sysvals = { + time_id: Utils.getguid(), + mk_departmentcode: sessionStorage.getItem('departmentcode') || '', + mk_organization: sessionStorage.getItem('organization') || '', + mk_user_type: sessionStorage.getItem('mk_user_type') || '', + id: ID || '', + bid: BID || '', + datam: sessionStorage.getItem('dataM') === 'true' ? 'Y' : '', + datam_begin: sessionStorage.getItem('dataM') === 'true' ? 'Y' : '', + datam_end: sessionStorage.getItem('dataM') === 'true' ? 'Y' : '', + orderby: orderBy || config.order || '', + pagesize: config.laypage === 'true' ? pageSize : '9999', + pageindex: pageIndex + } + if (window.GLOB.externalDatabase !== null) { + sysvals.db = window.GLOB.externalDatabase + } - let sql = '' - let DateCount = '' - let _search = '' - let _orderBy = orderBy || config.order || '' - let _datasource = config.dataSource + let exps = [] - if (config.searchKey && searchKey) { - let fields = config.searchKey.split(',').map(field => field + ` like '%${searchKey}%'`) - _search = 'where ' + fields.join(' OR ') - } + if (config.searchKey) { + if (!searchKey) { + exps.push({ + key: 'mk_search', + value: [] + }) + } else { + exps.push({ + key: 'mk_search', + value: [{ + key: config.searchKey, + match: '01', + type: /,/.test(config.searchKey) ? 'text_or' : 'text', + value: searchKey + }] + }) + } + config.searchKey.split(',').forEach(key => { + sysvals[key.toLowerCase()] = searchKey || '' + }) + } - _datasource = _datasource.replace(/@BID@/ig, `'${BID || ''}'`) - _datasource = _datasource.replace(/@ID@/ig, `'${ID || ''}'`) - - if (config.laypage === 'true') { - sql = `/*system_query*/select top ${pageSize} ${config.arr_field} from (select ${config.arr_field} ,ROW_NUMBER() over(order by ${_orderBy}) as rows from ${_datasource} ${_search}) tmptable where rows > ${pageSize * (pageIndex - 1)} order by tmptable.rows ` - DateCount = `/*system_query*/select count(1) as total from ${_datasource} ${_search}` - } else if (_orderBy) { - sql = `/*system_query*/select ${config.arr_field} from (select ${config.arr_field} ,ROW_NUMBER() over(order by ${_orderBy}) as rows from ${_datasource} ${_search}) tmptable order by tmptable.rows ` - } else { - sql = `/*system_query*/select ${config.arr_field} from ${_datasource} ${_search} ` - } - - let departmentcode = sessionStorage.getItem('departmentcode') || '' - let organization = sessionStorage.getItem('organization') || '' - let mk_user_type = sessionStorage.getItem('mk_user_type') || '' + ex.reps.forEach(n => { + let key = n.toLowerCase() + if (sysvals.hasOwnProperty(key)) { + exps.push({ + key: n, + value: sysvals[key] + }) + } + }) - sql = `declare @mk_departmentcode nvarchar(512),@mk_organization nvarchar(512),@mk_user_type nvarchar(20) - Select @mk_departmentcode='${departmentcode}', @mk_organization='${organization}', @mk_user_type='${mk_user_type}' - ${sql}` - - // 娴嬭瘯绯荤粺鎵撳嵃鏌ヨ璇彞 - if (window.GLOB.debugger === true) { - window.mkInfo(`/*${config.label} 鏁版嵁婧�*/\n` + sql.replace(/\n\s{6}/ig, '\n')) - DateCount && window.mkInfo(`/*${config.label} 鎬绘暟鏌ヨ*/\n` + DateCount.replace(/\n\s{6}/ig, '\n')) + param = { + $backend: true, + data: [{ + id: ex.id, + exps: exps, + menuname: '', + md5_id: '' + }] + } + } else { + param = { + func: 'sPC_Get_TableData', + obj_name: 'data', + exec_type: window.GLOB.execType || 'y', + arr_field: config.arr_field, + default_sql: 'true', + custom_script: '', + menuname: config.label + } + + let sql = '' + let DateCount = '' + let _search = '' + let _orderBy = orderBy || config.order || '' + let _datasource = config.dataSource + + if (config.searchKey && searchKey) { + let fields = config.searchKey.split(',').map(field => field + ` like '%${searchKey}%'`) + _search = 'where ' + fields.join(' OR ') + } + + _datasource = _datasource.replace(/@BID@/ig, `'${BID || ''}'`) + _datasource = _datasource.replace(/@ID@/ig, `'${ID || ''}'`) + + if (config.laypage === 'true') { + sql = `/*system_query*/select top ${pageSize} ${config.arr_field} from (select ${config.arr_field} ,ROW_NUMBER() over(order by ${_orderBy}) as rows from ${_datasource} ${_search}) tmptable where rows > ${pageSize * (pageIndex - 1)} order by tmptable.rows ` + DateCount = `/*system_query*/select count(1) as total from ${_datasource} ${_search}` + } else if (_orderBy) { + sql = `/*system_query*/select ${config.arr_field} from (select ${config.arr_field} ,ROW_NUMBER() over(order by ${_orderBy}) as rows from ${_datasource} ${_search}) tmptable order by tmptable.rows ` + } else { + sql = `/*system_query*/select ${config.arr_field} from ${_datasource} ${_search} ` + } + + let departmentcode = sessionStorage.getItem('departmentcode') || '' + let organization = sessionStorage.getItem('organization') || '' + let mk_user_type = sessionStorage.getItem('mk_user_type') || '' + + sql = `declare @mk_departmentcode nvarchar(512),@mk_organization nvarchar(512),@mk_user_type nvarchar(20) + Select @mk_departmentcode='${departmentcode}', @mk_organization='${organization}', @mk_user_type='${mk_user_type}' + ${sql}` + + // 娴嬭瘯绯荤粺鎵撳嵃鏌ヨ璇彞 + if (window.GLOB.debugger === true) { + window.mkInfo(`/*${config.label} 鏁版嵁婧�*/\n` + sql.replace(/\n\s{6}/ig, '\n')) + DateCount && window.mkInfo(`/*${config.label} 鎬绘暟鏌ヨ*/\n` + DateCount.replace(/\n\s{6}/ig, '\n')) + } + + param.LText = Utils.formatOptions(sql, param.exec_type) + param.DateCount = Utils.formatOptions(DateCount, param.exec_type) + + param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + param.secretkey = Utils.encrypt('', param.timestamp) + + param.username = sessionStorage.getItem('User_Name') || '' + param.fullname = sessionStorage.getItem('Full_Name') || '' } - - param.LText = Utils.formatOptions(sql, param.exec_type) - param.DateCount = Utils.formatOptions(DateCount, param.exec_type) - - param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') - param.secretkey = Utils.encrypt('', param.timestamp) - - param.username = sessionStorage.getItem('User_Name') || '' - param.fullname = sessionStorage.getItem('Full_Name') || '' Api.getSystemCacheConfig(param, config.cache === 'true').then(result => { if (result.status) { diff --git a/src/tabviews/custom/index.jsx b/src/tabviews/custom/index.jsx index 23526d4..88009a6 100644 --- a/src/tabviews/custom/index.jsx +++ b/src/tabviews/custom/index.jsx @@ -3,6 +3,7 @@ import { is, fromJS } from 'immutable' import { notification, Spin, Row, Col, Modal } from 'antd' import moment from 'moment' +import md5 from 'md5' import Api from '@/api' import Utils from '@/utils/utils.js' @@ -219,6 +220,21 @@ window.GLOB.CacheData.set(MenuID, urlparam) + if (window.backend && config.allSqls) { + let keys = Object.keys(urlparam) + config.allSqls.forEach(item => { + item.id = md5(window.GLOB.appkey + item.v_id) + if (item.type === 'datasource' || item.type === 'excelOut') { + item.urlkeys = keys + item.urlparam = urlparam + if (config.flow_code) { + item.works_flow_code = config.flow_code + } + } + window.GLOB.CacheData.set('sql_' + item.uuid, item) + }) + } + let userName = sessionStorage.getItem('User_Name') || '' let fullName = sessionStorage.getItem('Full_Name') || '' @@ -285,7 +301,7 @@ } }) - config.components = this.formatSetting(config.components, params, inherit, config.interfaces, balMap, tbMap) + config.components = this.formatSetting(config.components, params, inherit, config.interfaces, balMap, tbMap, BID) if (initInters.length > 0) { this.stepInter = { @@ -680,6 +696,7 @@ if (item.hasExtend) { item.setting.hasExtend = true + item.setting.sync = 'false' item.setting.tableMode = 'compatible' item.setting.extendTime = moment().format('YYYY-MM-DD HH:mm:ss') item.colsCtrls = null @@ -698,6 +715,9 @@ } } } else if (item.type === 'card' || item.type === 'carousel' || item.type === 'timeline') { + if (item.wrap.datatype === 'public') { + balMap.set(item.wrap.publicId + 'public', true) + } item.subcards && item.subcards.forEach(card => { if (card.style.boxShadow) { delete card.style.hShadow @@ -908,7 +928,7 @@ if (item.setting.sync === 'true') { // pageable 鏄惁鍒嗛〉锛岀粍浠跺睘鎬э紝涓嶅垎椤电殑缁勪欢鎵嶅彲浠ョ粺涓�鏌ヨ - if ((!item.pageable || (item.pageable && !item.setting.laypage)) && item.setting.onload === 'true') { + if ((!item.pageable || (item.pageable && !item.setting.laypage)) && item.setting.onload === 'true' && !_tailScript) { } else { item.setting.sync = 'false' @@ -1126,18 +1146,18 @@ } // 鏍煎紡鍖栭粯璁よ缃� - formatSetting = (components, params, inherit, interfaces, balMap, tbMap) => { + formatSetting = (components, params, inherit, interfaces, balMap, tbMap, BID) => { let delay = 20 return components.map(component => { if (component.type === 'tabs') { component.subtabs = component.subtabs.map(tab => { - tab.components = this.formatSetting(tab.components, null, inherit, interfaces, balMap, tbMap) + tab.components = this.formatSetting(tab.components, null, inherit, interfaces, balMap, tbMap, BID) tab = {...tab, ...inherit} return tab }) return component } else if (component.type === 'group') { - component.components = this.formatSetting(component.components, params, null, interfaces, balMap, tbMap) + component.components = this.formatSetting(component.components, params, null, interfaces, balMap, tbMap, BID) return component } @@ -1212,6 +1232,8 @@ if (component.setting.interType !== 'system') return component + component.setting.uuid = component.uuid + // dataName 绯荤粺鐢熸垚鐨勬暟鎹簮鍚嶇О if (component.setting.sync === 'true') { component.dataName = 'mk' + component.uuid.slice(-18) @@ -1233,7 +1255,17 @@ component.setting.sync = 'false' component.setting.onload = 'false' } else { - params.push(getStructDefaultParam(component, searchlist, params.length === 0)) + let backend = false + if (window.backend && params.length === 0 && window.GLOB.CacheData.has('sql_' + component.uuid)) { + backend = true + } else if (window.backend && params[0] && params[0].exps) { + backend = true + } + if (backend && !window.GLOB.CacheData.has('sql_' + component.uuid)) { + component.setting.sync = 'false' + } else { + params.push(getStructDefaultParam(component, searchlist, params.length === 0, BID)) + } } } } @@ -1287,6 +1319,8 @@ inter.setting.arr_field = inter.columns.map(col => col.field).join(',') if (inter.setting.interType !== 'system') return inter + + inter.setting.uuid = inter.uuid let _customScript = '' let _tailScript = '' @@ -1349,7 +1383,7 @@ this.setState({loading: true, loadingview: false}) if (config.$cache && config.$time) { - Api.getLCacheConfig(params[0].uuid, config.$time, BID).then(res => { + Api.getLCacheConfig(params[0].uuid || params[0].id, config.$time, BID).then(res => { if (!res.valid) { this.getMainData(param, params, config.MenuID) } else { @@ -1385,11 +1419,11 @@ } params.forEach((item) => { - let _data = result[item.name] || '' + let _data = result[item.dataName] || '' if (_data && !Array.isArray(_data)) { _data = [_data] } - window.GLOB.SyncData.set(item.name, _data) + window.GLOB.SyncData.set(item.dataName, _data) }) MKEmitter.emit('transferSyncData', MenuID) diff --git a/src/tabviews/custom/popview/index.jsx b/src/tabviews/custom/popview/index.jsx index 338eb38..9e557fc 100644 --- a/src/tabviews/custom/popview/index.jsx +++ b/src/tabviews/custom/popview/index.jsx @@ -156,7 +156,7 @@ let params = [] let BID = urlparam.$BID || '' - config.components = this.formatSetting(config.components, params, balMap, tbMap) + config.components = this.formatSetting(config.components, params, balMap, tbMap, BID) this.setState({ BID: BID, @@ -414,6 +414,7 @@ if (item.hasExtend) { item.setting.hasExtend = true + item.setting.sync = 'false' item.setting.tableMode = 'compatible' item.setting.extendTime = moment().format('YYYY-MM-DD HH:mm:ss') item.colsCtrls = null @@ -432,6 +433,9 @@ } } } else if (item.type === 'card' || item.type === 'carousel' || item.type === 'timeline') { + if (item.wrap.datatype === 'public') { + balMap.set(item.wrap.publicId + 'public', true) + } item.subcards && item.subcards.forEach(card => { if (card.style.boxShadow) { delete card.style.hShadow @@ -620,7 +624,7 @@ if (item.setting.sync === 'true') { // pageable 鏄惁鍒嗛〉锛岀粍浠跺睘鎬э紝涓嶅垎椤电殑缁勪欢鎵嶅彲浠ョ粺涓�鏌ヨ - if ((!item.pageable || (item.pageable && !item.setting.laypage)) && item.setting.onload === 'true') { + if ((!item.pageable || (item.pageable && !item.setting.laypage)) && item.setting.onload === 'true' && !_tailScript) { } else { item.setting.sync = 'false' @@ -814,17 +818,17 @@ } // 鏍煎紡鍖栭粯璁よ缃� - formatSetting = (components, params, balMap, tbMap) => { + formatSetting = (components, params, balMap, tbMap, BID) => { let delay = 20 return components.map(component => { if (component.type === 'tabs') { component.subtabs = component.subtabs.map(tab => { - tab.components = this.formatSetting(tab.components, null, balMap, tbMap) + tab.components = this.formatSetting(tab.components, null, balMap, tbMap, BID) return tab }) return component } else if (component.type === 'group') { - component.components = this.formatSetting(component.components, params, balMap, tbMap) + component.components = this.formatSetting(component.components, params, balMap, tbMap, BID) return component } @@ -912,7 +916,18 @@ component.setting.sync = 'false' component.setting.onload = 'false' } else { - params.push(getStructDefaultParam(component, searchlist, params.length === 0)) + let backend = false + if (window.backend && params.length === 0 && window.GLOB.CacheData.has('sql_' + component.uuid)) { + backend = true + } else if (window.backend && params[0] && params[0].exps) { + backend = true + } + + if (backend && !window.GLOB.CacheData.has('sql_' + component.uuid)) { + component.setting.sync = 'false' + } else { + params.push(getStructDefaultParam(component, searchlist, params.length === 0, BID)) + } } } } @@ -955,11 +970,11 @@ } params.forEach((item) => { - let _data = result[item.name] || '' + let _data = result[item.dataName] || '' if (_data && !Array.isArray(_data)) { _data = [_data] } - window.GLOB.SyncData.set(item.name, _data) + window.GLOB.SyncData.set(item.dataName, _data) }) MKEmitter.emit('transferSyncData', Tab.uuid) diff --git a/src/tabviews/zshare/actionList/excelInbutton/index.jsx b/src/tabviews/zshare/actionList/excelInbutton/index.jsx index dd39f39..a875b0a 100644 --- a/src/tabviews/zshare/actionList/excelInbutton/index.jsx +++ b/src/tabviews/zshare/actionList/excelInbutton/index.jsx @@ -3,6 +3,7 @@ import moment from 'moment' import { is, fromJS } from 'immutable' import { Button, Modal, notification, message } from 'antd' +import md5 from 'md5' import ExcelIn from './excelin' import Utils, { getExcelInSql } from '@/utils/utils.js' @@ -336,70 +337,42 @@ }) } - let result = getExcelInSql(btn, data, (BID || ''), this.state.primaryId) + if (btn.intertype === 'system' && window.backend && window.GLOB.CacheData.has('sql_' + btn.uuid)) { + let ex = window.GLOB.CacheData.get('sql_' + btn.uuid) + let param = this.getExps(ex, data) - if (result.errors) { - notification.warning({ - top: 92, - message: result.errors, - duration: 5 - }) - this.setState({ loading: false }) - return - } - - let param = { - ID: this.state.primaryId, - excel_in: result.lines - } - - if (BID) { - param.BID = BID - } - - if (btn.intertype === 'system') { // 绯荤粺瀛樺偍杩囩▼ - param.func = 'sPC_TableData_InUpDe' - - delete param.excel_in - - // param.excel_in_type = 'true' - param.exec_type = window.GLOB.execType || 'y' - param.LText = result.sql - param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + if (param.errors) { + notification.warning({ + top: 92, + message: param.errors, + duration: 5 + }) + this.setState({ loading: false }) + return + } let unCheckParam = null - if (/\$check@|@check\$/ig.test(param.LText)) { + if (ex.reps.includes('mk_check_begin')) { unCheckParam = fromJS(param).toJS() - param.LText = param.LText.replace(/\$check@|@check\$/ig, '') - } - param.LText = Utils.formatOptions(param.LText, param.exec_type) - param.secretkey = Utils.encrypt('', param.timestamp) - if (window.GLOB.mkHS) { // 浜戠楠岃瘉 - param.open_key = Utils.encryptOpenKey(param.secretkey, param.timestamp) - } - - if (btn.database === 'sso' && window.GLOB.mainSystemApi) { - param.rduri = window.GLOB.mainSystemApi - } - - param.menuname = btn.logLabel - - if (window.GLOB.probation) { - param.s_debug_type = 'Y' + param.data[0].exps.push({ + key: 'mk_check_begin', + value: '' + }, { + key: 'mk_check_end', + value: '' + }) + unCheckParam.data[0].exps.push({ + key: 'mk_check_begin', + value: 'Y' + }, { + key: 'mk_check_end', + value: 'Y' + }) } if (unCheckParam) { - unCheckParam.LText = unCheckParam.LText.replace(/\$check@/ig, '/*').replace(/@check\$/ig, '*/') - unCheckParam.LText = Utils.formatOptions(unCheckParam.LText, unCheckParam.exec_type) - unCheckParam.secretkey = Utils.encrypt('', unCheckParam.timestamp) - unCheckParam.menuname = btn.logLabel - - if (window.GLOB.probation) { - unCheckParam.s_debug_type = 'Y' - } - Api.genericInterface(param).then(res => { if (res.status) { this.execSuccess(res) @@ -445,132 +418,454 @@ this.execError({}) }) } - } else if (btn.intertype === 'inner' && btn.innerFunc) { // 鑷畾涔夊瓨鍌ㄨ繃绋� - param.func = btn.innerFunc - - if (btn.recordUser === 'true') { - param.username = sessionStorage.getItem('User_Name') || '' - param.fullname = sessionStorage.getItem('Full_Name') || '' + } else { + let result = getExcelInSql(btn, data, (BID || ''), this.state.primaryId) + + if (result.errors) { + notification.warning({ + top: 92, + message: result.errors, + duration: 5 + }) + this.setState({ loading: false }) + return } - if (btn.dataM === 'true') { - param.dataM = sessionStorage.getItem('dataM') === 'true' ? 'Y' : '' + + let param = { + ID: this.state.primaryId, + excel_in: result.lines } - - Api.genericInterface(param).then((res) => { - if (res.status) { - this.execSuccess(res) - } else { - this.execError(res) + + if (BID) { + param.BID = BID + } + + if (btn.intertype === 'system') { // 绯荤粺瀛樺偍杩囩▼ + param.func = 'sPC_TableData_InUpDe' + + delete param.excel_in + + // param.excel_in_type = 'true' + param.exec_type = window.GLOB.execType || 'y' + param.LText = result.sql + param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + + let unCheckParam = null + + if (/\$check@|@check\$/ig.test(param.LText)) { + unCheckParam = fromJS(param).toJS() + param.LText = param.LText.replace(/\$check@|@check\$/ig, '') } - }, (error) => { - if (error && error.ErrCode === 'LoginError') return - this.execError({}) - }) - } else if (btn.intertype === 'outer') { // 澶栭儴鎺ュ彛 - let _outParam = null - let ver_token = false - - new Promise(resolve => { - // 鍐呴儴璇锋眰 - if (btn.innerFunc) { - param.func = btn.innerFunc - // 瀛樺湪鍐呴儴鍑芥暟鏃讹紝鏁版嵁棰勫鐞� + + param.LText = Utils.formatOptions(param.LText, param.exec_type) + param.secretkey = Utils.encrypt('', param.timestamp) + if (window.GLOB.mkHS) { // 浜戠楠岃瘉 + param.open_key = Utils.encryptOpenKey(param.secretkey, param.timestamp) + } + + if (btn.database === 'sso' && window.GLOB.mainSystemApi) { + param.rduri = window.GLOB.mainSystemApi + } + + param.menuname = btn.logLabel + + if (window.GLOB.probation) { + param.s_debug_type = 'Y' + } + + if (unCheckParam) { + unCheckParam.LText = unCheckParam.LText.replace(/\$check@/ig, '/*').replace(/@check\$/ig, '*/') + unCheckParam.LText = Utils.formatOptions(unCheckParam.LText, unCheckParam.exec_type) + unCheckParam.secretkey = Utils.encrypt('', unCheckParam.timestamp) + unCheckParam.menuname = btn.logLabel + + if (window.GLOB.probation) { + unCheckParam.s_debug_type = 'Y' + } + Api.genericInterface(param).then(res => { if (res.status) { - delete res.ErrCode - delete res.ErrMesg - delete res.message - delete res.status - - // 浣跨敤澶勭悊鍚庣殑鏁版嵁璋冪敤澶栭儴鎺ュ彛 - let keys = Object.keys(res) // 鎻愪氦澶栭儴鎺ュ彛鍓嶏紝娣诲姞BID - if (this.props.BID && keys.filter(key => key.toLowerCase() === 'bid').length === 0) { - res.BID = this.props.BID - } - resolve(res) + this.execSuccess(res) + } else if (res.ErrCode === 'C') { + const that = this + confirm({ + title: window.GLOB.dict['exec_sure'] || '璇风‘璁�', + content: res.message, + okText: window.GLOB.dict['ok'] || '纭畾', + cancelText: window.GLOB.dict['cancel'] || '鍙栨秷', + onOk() { + return new Promise(resolve => { + Api.genericInterface(unCheckParam).then(result => { + if (result.status) { + that.execSuccess(result) + } else { + that.execError(result) + } + resolve() + }) + }) + }, + onCancel() { + that.execError(res) + } + }) } else { this.execError(res) - resolve(false) } }, (error) => { if (error && error.ErrCode === 'LoginError') return this.execError({}) }) } else { - resolve(param) + Api.genericInterface(param).then((res) => { + if (res.status) { + this.execSuccess(res) + } else { + this.execError(res) + } + }, (error) => { + if (error && error.ErrCode === 'LoginError') return + this.execError({}) + }) } - }).then(res => { - if (!res) return - // 澶栭儴璇锋眰 - _outParam = fromJS(res).toJS() - - if (btn.sysInterface === 'true') { - if (window.GLOB.mainSystemApi) { - param.rduri = window.GLOB.mainSystemApi - } - } else if (btn.sysInterface === 'external') { - if (window.GLOB.systemType === 'production') { - param.$token = btn.exProInterface || '' + } else if (btn.intertype === 'inner' && btn.innerFunc) { // 鑷畾涔夊瓨鍌ㄨ繃绋� + param.func = btn.innerFunc + + if (btn.recordUser === 'true') { + param.username = sessionStorage.getItem('User_Name') || '' + param.fullname = sessionStorage.getItem('Full_Name') || '' + } + if (btn.dataM === 'true') { + param.dataM = sessionStorage.getItem('dataM') === 'true' ? 'Y' : '' + } + + Api.genericInterface(param).then((res) => { + if (res.status) { + this.execSuccess(res) } else { - param.$token = btn.exInterface || '' + this.execError(res) } - ver_token = true - } else { - if (window.GLOB.systemType === 'production' && btn.proInterface) { - param.rduri = btn.proInterface + }, (error) => { + if (error && error.ErrCode === 'LoginError') return + this.execError({}) + }) + } else if (btn.intertype === 'outer') { // 澶栭儴鎺ュ彛 + let _outParam = null + let ver_token = false + + new Promise(resolve => { + // 鍐呴儴璇锋眰 + if (btn.innerFunc) { + param.func = btn.innerFunc + // 瀛樺湪鍐呴儴鍑芥暟鏃讹紝鏁版嵁棰勫鐞� + Api.genericInterface(param).then(res => { + if (res.status) { + delete res.ErrCode + delete res.ErrMesg + delete res.message + delete res.status + + // 浣跨敤澶勭悊鍚庣殑鏁版嵁璋冪敤澶栭儴鎺ュ彛 + let keys = Object.keys(res) // 鎻愪氦澶栭儴鎺ュ彛鍓嶏紝娣诲姞BID + if (this.props.BID && keys.filter(key => key.toLowerCase() === 'bid').length === 0) { + res.BID = this.props.BID + } + resolve(res) + } else { + this.execError(res) + resolve(false) + } + }, (error) => { + if (error && error.ErrCode === 'LoginError') return + this.execError({}) + }) } else { - param.rduri = btn.interface + resolve(param) } - let host = window.GLOB.baseurl.replace(/http(s):\/\//, '') - if (param.rduri.indexOf(host) === -1 && /\/dostars/.test(param.rduri)) { - param.$login = true - } - } - - if (btn.outerFunc) { - res.func = btn.outerFunc - } - - if (window.GLOB.mkHS && res.func === 's_sDataDictb_excelIn') { // s_sDataDictb_excelIn 浜戠楠岃瘉 - let sql = `Declare @UserName nvarchar(50),@FullName nvarchar(50),@RoleID nvarchar(512),@mk_departmentcode nvarchar(512),@mk_organization nvarchar(512),@mk_user_type nvarchar(20),@mk_nation nvarchar(50),@mk_province nvarchar(50),@mk_city nvarchar(50),@mk_district nvarchar(50),@mk_address nvarchar(100),@ErrorCode nvarchar(50),@retmsg nvarchar(4000),@tbid Nvarchar(512)` - param.LText = Utils.formatOptions(sql) - param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') - param.secretkey = Utils.encrypt(param.LText, param.timestamp) - param.open_key = Utils.encryptOpenKey(param.secretkey, param.timestamp) - } - - return Api.genericInterface(res) - }).then(response => { - if (!response || response.ErrCode === 'LoginError') return - // 鍥炶皟璇锋眰 - if (ver_token && response.ErrCode === 'token_error') { - response.ErrCode = 'E' - this.execError(response) - } else if (btn.callbackFunc ) { - // 瀛樺湪鍥炶皟鍑芥暟鏃讹紝璋冪敤 - delete response.message - delete response.status - - response.func = btn.callbackFunc - - let _callbackparam = {..._outParam, ...response} - return Api.genericInterface(_callbackparam) - } else { - if (response.status) { - this.execSuccess(response) + }).then(res => { + if (!res) return + // 澶栭儴璇锋眰 + _outParam = fromJS(res).toJS() + + if (btn.sysInterface === 'true') { + if (window.GLOB.mainSystemApi) { + param.rduri = window.GLOB.mainSystemApi + } + } else if (btn.sysInterface === 'external') { + if (window.GLOB.systemType === 'production') { + param.$token = btn.exProInterface || '' + } else { + param.$token = btn.exInterface || '' + } + ver_token = true } else { + if (window.GLOB.systemType === 'production' && btn.proInterface) { + param.rduri = btn.proInterface + } else { + param.rduri = btn.interface + } + let host = window.GLOB.baseurl.replace(/http(s):\/\//, '') + if (param.rduri.indexOf(host) === -1 && /\/dostars/.test(param.rduri)) { + param.$login = true + } + } + + if (btn.outerFunc) { + res.func = btn.outerFunc + } + + if (window.GLOB.mkHS && res.func === 's_sDataDictb_excelIn') { // s_sDataDictb_excelIn 浜戠楠岃瘉 + let sql = `Declare @UserName nvarchar(50),@FullName nvarchar(50),@RoleID nvarchar(512),@mk_departmentcode nvarchar(512),@mk_organization nvarchar(512),@mk_user_type nvarchar(20),@mk_nation nvarchar(50),@mk_province nvarchar(50),@mk_city nvarchar(50),@mk_district nvarchar(50),@mk_address nvarchar(100),@ErrorCode nvarchar(50),@retmsg nvarchar(4000),@tbid Nvarchar(512)` + param.LText = Utils.formatOptions(sql) + param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + param.secretkey = Utils.encrypt(param.LText, param.timestamp) + param.open_key = Utils.encryptOpenKey(param.secretkey, param.timestamp) + } + + return Api.genericInterface(res) + }).then(response => { + if (!response || response.ErrCode === 'LoginError') return + // 鍥炶皟璇锋眰 + if (ver_token && response.ErrCode === 'token_error') { + response.ErrCode = 'E' this.execError(response) + } else if (btn.callbackFunc ) { + // 瀛樺湪鍥炶皟鍑芥暟鏃讹紝璋冪敤 + delete response.message + delete response.status + + response.func = btn.callbackFunc + + let _callbackparam = {..._outParam, ...response} + return Api.genericInterface(_callbackparam) + } else { + if (response.status) { + this.execSuccess(response) + } else { + this.execError(response) + } + } + }).then(res => { + if (!res || res.ErrCode === 'LoginError') return + + if (res.status) { + this.execSuccess(res) + } else { + this.execError(res) + } + }) + } + } + } + + getExps = (ex, data) => { + const { BID, btn } = this.props + const { primaryId } = this.state + + let exps = [] + let values = { + time_id: Utils.getguid(), + roleid: sessionStorage.getItem('role_id') || '', + mk_departmentcode: sessionStorage.getItem('departmentcode') || '', + mk_organization: sessionStorage.getItem('organization') || '', + mk_user_type: sessionStorage.getItem('mk_user_type') || '', + mk_nation: sessionStorage.getItem('nation') || '', + mk_province: sessionStorage.getItem('province') || '', + mk_city: sessionStorage.getItem('city') || '', + mk_district: sessionStorage.getItem('district') || '', + mk_address: sessionStorage.getItem('address') || '', + id: primaryId || '', + bid: BID || '', + typename: 'admin', + datam: sessionStorage.getItem('dataM') === 'true' ? 'Y' : '', + datam_begin: sessionStorage.getItem('dataM') === 'true' ? 'Y' : '', + datam_end: sessionStorage.getItem('dataM') === 'true' ? 'Y' : '', + // mk_check_begin: '', + // mk_check_end: '' + } + + if (window.GLOB.externalDatabase !== null) { + values.db = window.GLOB.externalDatabase + } + + let keys = ['delete', 'drop', 'insert', 'truncate', 'update'] + let errors = [] + let _topline = btn.verify.range || 0 + let cols = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'] + for (let i = 0; i < 26; i++) { + cols.push('A' + cols[i]) + } + + let lines = data.map((item, lindex) => { + let vals = [] + btn.verify.columns.forEach((col, cindex) => { + if (col.import === 'false') return + + let val = item[col.Column] !== undefined ? item[col.Column] : '' + let _colindex = cols[cindex] || (cindex + 1) + let _position = (_topline + lindex + 1) + '琛� ' + _colindex + '鍒� ' + + if (col.import === 'init') { + if (/^Nvarchar/ig.test(col.type)) { + val = '' + } else if (/^Decimal/ig.test(col.type) || /^int/ig.test(col.type)) { + val = 0 + } else if (col.type === 'date') { + val = '1949-10-01' + } else if (col.type === 'datetime') { + val = '1949-10-01 00:00:00' + } + } else if (/^Nvarchar/ig.test(col.type)) { + val = val + '' + + if (/'/.test(val)) { + val = val.replace(/'/ig, '"') + } + + val = val.replace(/(^\s+$)|\t+|\v+/ig, '') + + if (!val && col.required === 'true') { // 蹇呭~鏍¢獙 + errors.push(_position + '鍐呭涓嶅彲涓虹┖') + } else if (col.limit && val.length > col.limit) { // 闀垮害鏍¢獙 + errors.push(_position + '鍐呭瓒呴暱') + } else { // 鍏抽敭瀛楁牎楠� + keys.forEach(key => { + let _patten = new RegExp('(^' + key + '\\s+)|(\\s+' + key + '\\s+)', 'ig') + if (_patten.test(val)) { + errors.push(_position + '鍚湁鍏抽敭瀛�' + key) + } + }) + } + } else if (/^Decimal/ig.test(col.type) || /^int/ig.test(col.type)) { + if (col.required === 'false') { + if (!val || isNaN(val)) { + val = 0 + } + } else if (!val && val !== 0) { + errors.push(_position + '鍐呭涓嶅彲涓虹┖') + } else if (isNaN(val)) { // 妫�楠屾槸鍚︿负鏁板�� + errors.push(_position + '鍐呭搴斾负鏁板��') + } else if ((col.min || col.min === 0) && val < col.min) { // 鏈�灏忓�兼楠� + errors.push(_position + '灏忎簬鏈�灏忓��') + } else if ((col.max || col.max === 0) && val > col.max) { // 鏈�澶у�兼楠� + errors.push(_position + '澶т簬鏈�澶у��') + } + } else if (col.type === 'date' || col.type === 'datetime') { + if (typeof(val) === 'number') { + if (val > 2958465 || val <= 0) { // 鏃堕棿杩囧ぇ鎴栧皬浜庣瓑浜�0 + errors.push(_position + '鏃堕棿涓鸿礋鍊兼垨澶ぇ') + } else { // 鏃堕棿鏍煎紡鍖� + if (val < 60) { // 1900-2-29锛宔xcel涓瓨鍦紝瀹為檯涓嶅瓨鍦� + val++ + } + if (col.type === 'datetime') { + val = val - 2 + let day = Math.floor(val) + let seconds = Math.round((val - day) * 24 * 60 * 60) + val = moment('19000101', 'YYYYMMDD').add(day, 'days').add(seconds, 'seconds').format('YYYY-MM-DD HH:mm:ss') + } else { + val = moment('19000101', 'YYYYMMDD').add(Math.floor(val - 2), 'days').format('YYYY-MM-DD') + } + } + } else if (typeof(val) === 'string') { + val = val.replace(/(^\s+$)|\t+|\v+/ig, '') + if (!val) { + if (col.required === 'true') { // 鏃堕棿蹇呭~鏍¢獙 + errors.push(_position + '鍐呭涓嶅彲涓虹┖') + } else if (col.type === 'date') { + val = '1949-10-01' + } else if (col.type === 'datetime') { + val = '1949-10-01 00:00:00' + } + } else if (!/^[1-9][0-9]{3}/.test(val)) { // 鏃堕棿姝e垯鏍¢獙 + errors.push(_position + '鏃堕棿鏍煎紡閿欒') + } + } else { // 鏃堕棿鏍煎紡閿欒 + errors.push(_position + '鏃堕棿鏍煎紡閿欒') } } - }).then(res => { - if (!res || res.ErrCode === 'LoginError') return - if (res.status) { - this.execSuccess(res) - } else { - this.execError(res) - } + vals.push(val) }) + + let _lineIndex = '0000' + (lindex + 1) + '0' + _lineIndex = _lineIndex.substring(_lineIndex.length - 6) + + vals.push(Utils.getguid() + _lineIndex) + vals.push(BID) + + return vals + }) + + if (errors.length) return {errors: errors.join('; ')} + + ex.reps.forEach(n => { + let key = n.toLowerCase() + if (values.hasOwnProperty(key)) { + exps.push({ + key: n, + value: values[key] + }) + } + }) + + exps.push({ + key: 'mk_excel_data', + value: lines + }) + + if (btn.$process && btn.verify.workFlow === 'true') { + let flow = window.GLOB.UserCacheMap.get(btn.$flowId) + let target = flow ? flow.cells.filter(cell => cell.mknode === 'start')[0] : '' + + let error = '' + let msg = '' + let status = 0 + let statusName = '' + let detailId = '' + + if (target) { + detailId = target.id + status = target.mkdata.status + statusName = target.mkdata.statusName + + let label = target.attrs && target.attrs.text && target.attrs.text.text ? target.attrs.text.text : '' + msg = {...target.mkdata, label: label, id: target.id, checkIds: [], checkUsers: []} + msg = window.btoa(window.encodeURIComponent(JSON.stringify(msg))) + } else { + status = 0 + statusName = '寮傚父' + error = '宸ヤ綔娴佹棤寮�濮嬭妭鐐�' + } + + exps.push( + { key: 'works_flow_error', value: error }, + { key: 'works_flow_code', value: flow ? flow.flow_code : '' }, + { key: 'works_flow_name', value: flow ? flow.flow_name : '' }, + { key: 'works_flow_param', value: msg }, + { key: 'works_flow_detail_id', value: detailId }, + { key: 'status', value: status }, + { key: 'statusname', value: statusName }, + { key: 'work_group', value: sessionStorage.getItem('work_group') || '' }, + { key: 'work_grade', value: sessionStorage.getItem('work_grade') || 0 }, + // { key: 'start_type', value: '寮�濮�' }, + ) + } + + let md5_id = '' + if (window.GLOB.probation) { + md5_id = md5(ex.id + JSON.stringify(exps) + Math.floor(new Date().getTime() / 600000)) + md5_id = moment().format('YYYYMMDDHHmmss') + md5_id.slice(-18) + } + + return { + $backend: true, + data: [{ + id: ex.id, + exps: exps, + menuname: btn.logLabel || '', + md5_id: md5_id + }] } } diff --git a/src/tabviews/zshare/actionList/exceloutbutton/index.jsx b/src/tabviews/zshare/actionList/exceloutbutton/index.jsx index 711ad21..6cc49b6 100644 --- a/src/tabviews/zshare/actionList/exceloutbutton/index.jsx +++ b/src/tabviews/zshare/actionList/exceloutbutton/index.jsx @@ -381,7 +381,6 @@ if (btn.dataM === 'true') { param.dataM = sessionStorage.getItem('dataM') === 'true' ? 'Y' : '' } - } else if (btn.intertype === 'outer' && !btn.innerFunc) { // 浣跨敤澶栭儴鍑芥暟 param = this.getExcelCustomParam(viewParam.orderBy, viewParam.search, true, pageIndex, pageSize) @@ -863,7 +862,10 @@ let _setting = {} let _orderBy = orderBy || '' + if (btn.verify.dataType === 'custom') { + _setting.uuid = btn.uuid + _setting.interType = 'system' _setting.arr_field = [] btn.verify.columns.forEach(col => { @@ -941,17 +943,9 @@ primaryId = primaryId ? 'excel:' + primaryId : '' } - let param = UtilsDM.getDefaultQueryParam(_setting, search, _orderBy, pageIndex, pageSize, primaryId, BID) + let param = UtilsDM.getQueryDataParams(_setting, search, _orderBy, pageIndex, pageSize, BID, primaryId) - param.DateCount = '' - - // 鏁版嵁绠$悊鏉冮檺 - if (sessionStorage.getItem('dataM') === 'true') { - param.dataM = 'Y' - } - if (BID) { - param.BID = BID - } + delete param.DateCount return param } diff --git a/src/tabviews/zshare/actionList/funcbutton/index.jsx b/src/tabviews/zshare/actionList/funcbutton/index.jsx index 251ecff..c83ac11 100644 --- a/src/tabviews/zshare/actionList/funcbutton/index.jsx +++ b/src/tabviews/zshare/actionList/funcbutton/index.jsx @@ -187,6 +187,8 @@ dataM: sessionStorage.getItem('dataM') === 'true' ? 'Y' : '', ID: orderId } + } else if (window.backend && window.GLOB.CacheData.has('sql_' + btn.uuid)) { + param = this.getbackParam(orderId, data) } else if (btn.payMode === 'system') { let sql = this.getSysDeclareSql(orderId, data) @@ -247,6 +249,83 @@ } } + getbackParam = (ID, data) => { + const { columns, btn, BID } = this.props + + let ex = window.GLOB.CacheData.get('sql_' + btn.uuid) + let exps = [] + let values = { + time_id: Utils.getguid(), + roleid: sessionStorage.getItem('role_id') || '', + mk_departmentcode: sessionStorage.getItem('departmentcode') || '', + mk_organization: sessionStorage.getItem('organization') || '', + mk_user_type: sessionStorage.getItem('mk_user_type') || '', + mk_nation: sessionStorage.getItem('nation') || '', + mk_province: sessionStorage.getItem('province') || '', + mk_city: sessionStorage.getItem('city') || '', + mk_district: sessionStorage.getItem('district') || '', + mk_address: sessionStorage.getItem('address') || '', + id: ID || '', + bid: BID || '', + typename: 'admin', + datam: sessionStorage.getItem('dataM') === 'true' ? 'Y' : '', + datam_begin: sessionStorage.getItem('dataM') === 'true' ? 'Y' : '', + datam_end: sessionStorage.getItem('dataM') === 'true' ? 'Y' : '', + } + + if (window.GLOB.externalDatabase !== null) { + values.db = window.GLOB.externalDatabase + } + + ex.reps.forEach(n => { + let key = n.toLowerCase() + if (values.hasOwnProperty(key)) { + exps.push({ + key: n, + value: values[key] + }) + } + }) + + let _data = {} + Object.keys(data).forEach(key => { + _data[key.toLowerCase()] = data[key] + }) + + columns.forEach(col => { + if (!ex.reps.includes(col.field)) return + if (!col.datatype) return + + let _key = col.field.toLowerCase() + let _val = _data.hasOwnProperty(_key) ? _data[_key] : '' + + if (/^date/ig.test(col.datatype) && !_val) { + _val = '1949-10-01' + } + + exps.push({ + key: 'mk_' + col.field + '_mk', + value: _val + }) + }) + + let md5_id = '' + if (window.GLOB.probation) { + md5_id = md5(ex.id + JSON.stringify(exps) + Math.floor(new Date().getTime() / 600000)) + md5_id = moment().format('YYYYMMDDHHmmss') + md5_id.slice(-18) + } + + return { + $backend: true, + data: [{ + id: ex.id, + exps: exps, + menuname: btn.logLabel || '', + md5_id: md5_id + }] + } + } + getSysDeclareSql = (ID, data) => { const { columns, btn, BID } = this.props diff --git a/src/tabviews/zshare/actionList/newpagebutton/index.jsx b/src/tabviews/zshare/actionList/newpagebutton/index.jsx index 50dcdbf..2a61fb0 100644 --- a/src/tabviews/zshare/actionList/newpagebutton/index.jsx +++ b/src/tabviews/zshare/actionList/newpagebutton/index.jsx @@ -3,6 +3,7 @@ import { is, fromJS } from 'immutable' import { Button, notification, Modal, message } from 'antd' import moment from 'moment' +import md5 from 'md5' import Api from '@/api' import Utils from '@/utils/utils.js' @@ -220,16 +221,49 @@ } else { if (btn.Ot === 'required') { data.forEach(item => { - let _id = item.$$uuid || '' - let url = '#/billprint/' + window.btoa(window.encodeURIComponent(JSON.stringify({ id: _id, tempId: btn.printTemp, pageId: btn.$MenuID || '', dataM: sessionStorage.getItem('dataM') }))) + let _param = { id: item.$$uuid || '', tempId: btn.printTemp, pageId: btn.$MenuID || '', dataM: sessionStorage.getItem('dataM')} + + Object.keys(item).forEach(key => { + if (/^\$/.test(key)) return + if (typeof(item[key]) !== 'string' && typeof(item[key]) !== 'number') return + if (typeof(item[key]) === 'string' && item[key].length > 50) return + if (['id', 'tempid', 'pageid', 'datam'].includes(key.toLowerCase())) return + + _param[key.toLowerCase()] = item[key] + }) + + let url = '#/billprint/' + window.btoa(window.encodeURIComponent(JSON.stringify(_param))) window.open(url) }) } else if (btn.Ot === 'requiredOnce') { Id = data.map(item => item.$$uuid).filter(Boolean).join(',') + let _param = { id: Id, tempId: btn.printTemp, pageId: btn.$MenuID || '', dataM: sessionStorage.getItem('dataM')} + let item = data[0] + + Object.keys(item).forEach(key => { + if (/^\$/.test(key)) return + if (typeof(item[key]) !== 'string' && typeof(item[key]) !== 'number') return + if (typeof(item[key]) === 'string' && item[key].length > 50) return + if (['id', 'tempid', 'pageid', 'datam'].includes(key.toLowerCase())) return + + _param[key.toLowerCase()] = item[key] + }) - window.open('#/billprint/' + window.btoa(window.encodeURIComponent(JSON.stringify({ id: Id, tempId: btn.printTemp, pageId: btn.$MenuID || '', dataM: sessionStorage.getItem('dataM') })))) + window.open('#/billprint/' + window.btoa(window.encodeURIComponent(JSON.stringify(_param)))) } else { - window.open('#/billprint/' + window.btoa(window.encodeURIComponent(JSON.stringify({ id: Id, tempId: btn.printTemp, pageId: btn.$MenuID || '', dataM: sessionStorage.getItem('dataM') })))) + let _param = { id: Id, tempId: btn.printTemp, pageId: btn.$MenuID || '', dataM: sessionStorage.getItem('dataM')} + let item = data[0] + + Object.keys(item).forEach(key => { + if (/^\$/.test(key)) return + if (typeof(item[key]) !== 'string' && typeof(item[key]) !== 'number') return + if (typeof(item[key]) === 'string' && item[key].length > 50) return + if (['id', 'tempid', 'pageid', 'datam'].includes(key.toLowerCase())) return + + _param[key.toLowerCase()] = item[key] + }) + + window.open('#/billprint/' + window.btoa(window.encodeURIComponent(JSON.stringify(_param)))) } } } else if (btn.pageTemplate === 'billprintTemp') { @@ -356,6 +390,8 @@ dataM: sessionStorage.getItem('dataM') === 'true' ? 'Y' : '', ID: ID } + } else if (window.backend && window.GLOB.CacheData.has('sql_' + btn.uuid)) { + param = this.getbackParam(ID, data) } else { let sql = this.getSysDeclareSql(ID, data) @@ -415,6 +451,83 @@ }) } + getbackParam = (ID, data) => { + const { columns, btn, BID } = this.props + + let ex = window.GLOB.CacheData.get('sql_' + btn.uuid) + let exps = [] + let values = { + time_id: Utils.getguid(), + roleid: sessionStorage.getItem('role_id') || '', + mk_departmentcode: sessionStorage.getItem('departmentcode') || '', + mk_organization: sessionStorage.getItem('organization') || '', + mk_user_type: sessionStorage.getItem('mk_user_type') || '', + mk_nation: sessionStorage.getItem('nation') || '', + mk_province: sessionStorage.getItem('province') || '', + mk_city: sessionStorage.getItem('city') || '', + mk_district: sessionStorage.getItem('district') || '', + mk_address: sessionStorage.getItem('address') || '', + id: ID || '', + bid: BID || '', + typename: 'admin', + datam: sessionStorage.getItem('dataM') === 'true' ? 'Y' : '', + datam_begin: sessionStorage.getItem('dataM') === 'true' ? 'Y' : '', + datam_end: sessionStorage.getItem('dataM') === 'true' ? 'Y' : '', + } + + if (window.GLOB.externalDatabase !== null) { + values.db = window.GLOB.externalDatabase + } + + ex.reps.forEach(n => { + let key = n.toLowerCase() + if (values.hasOwnProperty(key)) { + exps.push({ + key: n, + value: values[key] + }) + } + }) + + let _data = {} + Object.keys(data).forEach(key => { + _data[key.toLowerCase()] = data[key] + }) + + columns.forEach(col => { + if (!ex.reps.includes(col.field)) return + if (!col.datatype) return + + let _key = col.field.toLowerCase() + let _val = _data.hasOwnProperty(_key) ? _data[_key] : '' + + if (/^date/ig.test(col.datatype) && !_val) { + _val = '1949-10-01' + } + + exps.push({ + key: 'mk_' + col.field + '_mk', + value: _val + }) + }) + + let md5_id = '' + if (window.GLOB.probation) { + md5_id = md5(ex.id + JSON.stringify(exps) + Math.floor(new Date().getTime() / 600000)) + md5_id = moment().format('YYYYMMDDHHmmss') + md5_id.slice(-18) + } + + return { + $backend: true, + data: [{ + id: ex.id, + exps: exps, + menuname: btn.logLabel || '', + md5_id: md5_id + }] + } + } + getSysDeclareSql = (ID, data) => { const { columns, btn, BID } = this.props diff --git a/src/tabviews/zshare/actionList/normalbutton/index.jsx b/src/tabviews/zshare/actionList/normalbutton/index.jsx index daddf9d..7eb4679 100644 --- a/src/tabviews/zshare/actionList/normalbutton/index.jsx +++ b/src/tabviews/zshare/actionList/normalbutton/index.jsx @@ -458,8 +458,8 @@ let primaryId = '' - if ((btn.Ot === 'requiredSgl' || btn.Ot === 'requiredOnce') && setting.primaryKey) { - let ids = data.map(d => { return d[setting.primaryKey] || ''}) + if (btn.Ot === 'requiredSgl' || btn.Ot === 'requiredOnce') { + let ids = data.map(d => d.$$uuid) ids = ids.filter(Boolean) primaryId = ids.join(',') } @@ -492,16 +492,7 @@ param.LText = Utils.formatOptions(param.LText, param.exec_type) } else if (btn.OpenType === 'pop' || btn.OpenType === 'formSubmit' || btn.OpenType === 'form') { // 琛ㄥ崟 if (btn.sqlType === 'insert') { // 绯荤粺鍑芥暟娣诲姞鏃讹紝鐢熸垚uuid - primaryId = '' - - if (formdata && setting.primaryKey) { // 琛ㄥ崟涓瓨鍦ㄤ富閿瓧娈碉紝涓婚敭鍊间互琛ㄥ崟涓殑鍊间负鍑� - let _form = formdata.filter(_form => _form.key === setting.primaryKey)[0] - if (_form) { - primaryId = _form.value - } - } - - param.ID = primaryId || Utils.getguid() + param.ID = Utils.getguid() if (retmsg) { const { sql, callbacksql } = getSysDefaultSql(btn, setting, formdata, param, data[0], columns, retmsg) // 鏁版嵁婧� @@ -717,6 +708,463 @@ return _params } + getBackSystemParam = (data, formdata) => { + const { btn } = this.props + + let ex = window.GLOB.CacheData.get('sql_' + btn.uuid) + let _params = [] + + if (btn.Ot === 'notRequired' || btn.Ot === 'requiredSgl' || btn.Ot === 'requiredOnce') { + let primaryId = '' + let cell = null + + if (btn.Ot === 'requiredSgl' || btn.Ot === 'requiredOnce') { + primaryId = data.map(d => d.$$uuid).filter(Boolean).join(',') + cell = data[0] + } + + if (btn.OpenType === 'pop' || btn.OpenType === 'formSubmit' || btn.OpenType === 'form') { // 琛ㄥ崟 + if (btn.sqlType === 'insert') { // 绯荤粺鍑芥暟娣诲姞鏃讹紝鐢熸垚uuid + primaryId = Utils.getguid() + } + } + + let exp = this.getExps(ex, formdata, cell, primaryId, btn.$process) + + if (ex.reps.includes('mk_check_begin')) { + exp.$unCheckParam = fromJS(exp).toJS() + + exp.data[0].exps.push({ + key: 'mk_check_begin', + value: '' + }, { + key: 'mk_check_end', + value: '' + }) + exp.$unCheckParam.data[0].exps.push({ + key: 'mk_check_begin', + value: 'Y' + }, { + key: 'mk_check_end', + value: 'Y' + }) + } else if (btn.procMode === 'system' && btn.callbackType === 'script') { + let _backex = window.GLOB.CacheData.get('sql_back_' + btn.uuid) + exp.$backParam = this.getExps(_backex, formdata, cell, primaryId) + } + + _params.push(exp) + } else if (btn.Ot === 'required') { + _params = data.map((cell, index) => { + let primaryId = cell.$$uuid || '' + + if (btn.OpenType === 'pop') { // 琛ㄥ崟 + if (index !== 0) { + let _cell = {} + Object.keys(cell).forEach(key => { + _cell[key.toLowerCase()] = cell[key] + }) + formdata = formdata.map(_data => { + if (_data.readin && _cell.hasOwnProperty(_data.key.toLowerCase())) { + _data.value = _cell[_data.key.toLowerCase()] + } + return _data + }) + } + + if (btn.sqlType === 'insert') { // 绯荤粺鍑芥暟娣诲姞鏃讹紝鐢熸垚uuid + primaryId = Utils.getguid() + } + } + let exp = this.getExps(ex, formdata, cell, primaryId, btn.$process) + if (ex.reps.includes('mk_check_begin')) { + exp.$unCheckParam = fromJS(exp).toJS() + + exp.data[0].exps.push({ + key: 'mk_check_begin', + value: '' + }, { + key: 'mk_check_end', + value: '' + }) + exp.$unCheckParam.data[0].exps.push({ + key: 'mk_check_begin', + value: 'Y' + }, { + key: 'mk_check_end', + value: 'Y' + }) + } else if (btn.procMode === 'system' && btn.callbackType === 'script') { + let _backex = window.GLOB.CacheData.get('sql_back_' + btn.uuid) + exp.$backParam = this.getExps(_backex, formdata, cell, primaryId) + } + + return exp + }) + } + + return _params + } + + getExps = (ex, formdata, cell, id, process) => { + const { columns, BID, btn } = this.props + let exps = [] + let values = { + time_id: Utils.getguid(), + roleid: sessionStorage.getItem('role_id') || '', + mk_departmentcode: sessionStorage.getItem('departmentcode') || '', + mk_organization: sessionStorage.getItem('organization') || '', + mk_user_type: sessionStorage.getItem('mk_user_type') || '', + mk_nation: sessionStorage.getItem('nation') || '', + mk_province: sessionStorage.getItem('province') || '', + mk_city: sessionStorage.getItem('city') || '', + mk_district: sessionStorage.getItem('district') || '', + mk_address: sessionStorage.getItem('address') || '', + id: id || '', + bid: BID || '', + typename: 'admin', + datam: sessionStorage.getItem('dataM') === 'true' ? 'Y' : '', + datam_begin: sessionStorage.getItem('dataM') === 'true' ? 'Y' : '', + datam_end: sessionStorage.getItem('dataM') === 'true' ? 'Y' : '', + // mk_check_begin: '', + // mk_check_end: '' + } + + if (window.GLOB.externalDatabase !== null) { + values.db = window.GLOB.externalDatabase + } + + let formkeys = [] + formdata && formdata.forEach(form => { + if (!ex.reps.includes(form.key)) return + + formkeys.push(form.key) + + let val = form.value + if (form.type === 'number' || form.type === 'rate') { + if (isNaN(val)) { + val = 0 + } + } else if (['date', 'datemonth'].includes(form.type)) { + val = val || '1949-10-01' + } + + exps.push({ + key: 'mk_' + form.key + '_mk', + value: val + }) + }) + + if (cell && columns && columns.length > 0) { + let datavars = {} + + Object.keys(cell).forEach(key => { + datavars[key.toLowerCase()] = cell[key] + }) + + columns.forEach(col => { + if (!ex.reps.includes(col.field) || formkeys.includes(col.field)) return + if (!col.datatype) return + + let _key = col.field.toLowerCase() + let _val = datavars.hasOwnProperty(_key) ? datavars[_key] : '' + + if (/^date/ig.test(col.datatype) && !_val) { + _val = '1949-10-01' + } + + exps.push({ + key: 'mk_' + col.field + '_mk', + value: _val + }) + }) + } + + ex.reps.forEach(n => { + let key = n.toLowerCase() + if (values.hasOwnProperty(key)) { + exps.push({ + key: n, + value: values[key] + }) + } + }) + + if (process && btn.verify.workFlow === 'true') { + let flow = window.GLOB.UserCacheMap.get(btn.$flowId) + let node = null + let line = null + let target = null + let status = 0 + let statusName = '' + let detailId = '' + let sign = '' + let error = '' + let userid = sessionStorage.getItem('UserID') || '' + let checkIds = [] + let checkUsers = [] + let noticeIds = [] + let work_grade = sessionStorage.getItem('work_grade') || 0 + let departmentcode = sessionStorage.getItem('departmentcode') || '' + let _data = cell || {} + let msg = '' + + if (btn.verify.flowType === 'start') { + target = flow ? flow.cells.filter(cell => cell.mknode === 'start')[0] : '' + + if (target) { + detailId = target.id + status = target.mkdata.status + statusName = target.mkdata.statusName + } else { + error = '宸ヤ綔娴佹棤寮�濮嬭妭鐐�' + } + } else if (_data.works_flow_param) { + try { + node = JSON.parse(window.decodeURIComponent(window.atob(_data.works_flow_param))) + } catch (e) { + node = null + } + + if (node) { + let lines = flow ? flow.cells.filter(cell => cell.shape === 'edge' && cell.source.cell === node.id) : [] + if (btn.verify.flowType === 'reject') { + line = lines.filter(cell => cell.mkdata.flowType === 'reject' || cell.mknode === 'startEdge')[0] + } else { + lines = lines.filter(cell => cell.mkdata.flowType !== 'reject' && cell.mknode !== 'startEdge') + + if (lines.length === 0) { + error = '鏃犲彲鎵ц鐨勬祦绋嬪垎鏀�' + } else { + let branchKey = btn.verify.flowBranch ? btn.verify.flowBranch.toLowerCase() : '' + + formdata && formdata.forEach(form => { + let _key = form.key.toLowerCase() + _data[_key] = form.value + }) + + if (!branchKey) { + lines.forEach(line => { + if (line.mkdata.execCondition === 'open') { + error = '鎸夐挳鏈缃祦绋嬫帶鍒跺瓧娈点��' + } + }) + if (!error) { + lines = lines.filter(cell => { + if (cell.mkdata.seniorCondition === 'open' && !line) { + cell.mkdata.seniorbers && cell.mkdata.seniorbers.forEach(per => { + if (per.worker_id === userid) { + line = cell + } + }) + return false + } + return true + }) + + if (!line) { + line = lines[0] + } + } + } else if (!_data.hasOwnProperty(branchKey)) { + error = '淇℃伅涓棤娴佺▼鎺у埗瀛楁銆�' + } else { + let _def_lines = [] + let _equ_lines = [] + let _unequ_lines = [] + let _or_lines = [] + let branchVal = _data[branchKey] + + if (branchVal && typeof(branchVal) === 'string' && !isNaN(branchVal)) { + branchVal = +branchVal + } + + lines.forEach(item => { + if (item.mkdata.execCondition !== 'open') { + _def_lines.push(item) + } else { + if (item.mkdata.match === '=') { + if (item.mkdata.matchVal === branchVal + '') { + _equ_lines.push(item) + } + } else if (item.mkdata.match === '!=') { + if (item.mkdata.matchVal !== branchVal + '') { + _unequ_lines.push(item) + } + } else { + if (item.mkdata.match === '<') { + if (item.mkdata.matchVal < branchVal) { + _or_lines.push({...item, dist: Math.abs(item.mkdata.matchVal - branchVal)}) + } + } else if (item.mkdata.match === '>') { + if (item.mkdata.matchVal > branchVal) { + _or_lines.push({...item, dist: Math.abs(item.mkdata.matchVal - branchVal)}) + } + } else if (item.mkdata.match === '<=') { + if (item.mkdata.matchVal <= branchVal) { + _or_lines.push({...item, dist: Math.abs(item.mkdata.matchVal - branchVal)}) + } + } else if (item.mkdata.match === '>=') { + if (item.mkdata.matchVal >= branchVal) { + _or_lines.push({...item, dist: Math.abs(item.mkdata.matchVal - branchVal)}) + } + } + } + } + }) + + _or_lines.sort((a, b) => a.dist - b.dist) + + let _lines = [..._equ_lines, ..._or_lines, ..._unequ_lines, ..._def_lines] + + _lines = _lines.filter(cell => { + if (cell.mkdata.seniorCondition === 'open' && !line) { + cell.mkdata.seniorbers && cell.mkdata.seniorbers.forEach(per => { + if (per.worker_id === userid) { + line = cell + } + }) + return false + } + return true + }) + + if (!line) { + line = _lines[0] + } + } + } + } + } else { + error = '琛屼俊鎭腑宸ヤ綔娴佸弬鏁版棤娉曡В鏋�' + } + + if (line) { + detailId = line.id + status = line.mkdata.status + statusName = line.mkdata.statusName + sign = line.mkdata.seniorSign || '' + target = flow.cells.filter(cell => cell.id === line.target.cell)[0] + + line.mkdata.members && line.mkdata.members.forEach(item => { + if (line.mkdata.approver === 'departmentManager') { + if (item.job_type === 'manage' && departmentcode === item.parentIds[1]) { + checkIds.push(item.worker_id) + checkUsers.push(item) + } + } else if (line.mkdata.approver === 'directManager') { + if (departmentcode === item.parentIds[1] && item.work_grade > work_grade) { + checkIds.push(item.worker_id) + checkUsers.push(item) + } + } else { + checkIds.push(item.worker_id) + checkUsers.push(item) + } + }) + line.mkdata.copys && line.mkdata.copys.forEach(item => { + noticeIds.push(item.worker_id) + }) + + if (!target) { + error = '鏈煡璇㈠埌宸ヤ綔娴佺洰鏍囪妭鐐�' + } else if (checkIds.length === 0 && !['startEdge', 'endEdge', 'throughEdge'].includes(line.mknode)) { + error = '鏈幏鍙栧埌涓嬩竴姝ュ鎵逛汉' + } else if (line.approvalMethod === 'countersign' && (!node.checkIds || !node.checkIds.includes(userid))) { + error = '褰撳墠鐢ㄦ埛涓嶅湪瀹℃壒浜哄垪琛ㄤ腑' + } + } else if (!error) { + error = '宸ヤ綔娴佷腑鏃犲搴旀祦绋�' + } + } else { + error = '琛屼俊鎭腑鏃犲伐浣滄祦鍙傛暟' + } + + if (error) { + status = 0 + statusName = '寮傚父' + } else if (target) { + let label = target.attrs && target.attrs.text && target.attrs.text.text ? target.attrs.text.text : '' + msg = {...target.mkdata, label: label, id: target.id, checkIds: [], checkUsers: []} + msg = window.btoa(window.encodeURIComponent(JSON.stringify(msg))) + } + + if (btn.verify.flowType === 'start') { + exps.push( + { key: 'works_flow_error', value: error }, + { key: 'works_flow_code', value: flow ? flow.flow_code : '' }, + { key: 'works_flow_name', value: flow ? flow.flow_name : '' }, + { key: 'works_flow_param', value: msg }, + { key: 'works_flow_detail_id', value: detailId }, + { key: 'status', value: status }, + { key: 'statusname', value: statusName }, + { key: 'work_group', value: sessionStorage.getItem('work_group') || '' }, + { key: 'work_grade', value: sessionStorage.getItem('work_grade') || 0 }, + // { key: 'start_type', value: '寮�濮�' }, + ) + } else { + let works_flow_countersign = '' + let works_flow_sign_values = '' + let works_flow_sign_field = '' + let works_flow_sign_label = '' + let works_begin_branch = '' + if (line.approvalMethod === 'countersign' && node.checkIds.length > 1) { + works_flow_countersign = 'Y' + let mark = line.mark || '宸插鏍�' + let fields = ['statuscharone', 'statuschartwo', 'statuscharthree', 'statuscharfour', 'statuscharfive'] + node.checkUsers.forEach((user, index) => { + if (user.worker_id === userid) { + works_flow_sign_field = fields[index] + works_flow_sign_label = `${user.parentNames[2] || ''}${user.workername || ''}${mark}` + } else { + works_flow_sign_values += `${user.parentNames[2] || ''}${user.workername || ''}${mark}` + } + }) + } else { + works_begin_branch = line.mknode === 'startEdge' ? 'Y' : '' + } + + exps.push( + { key: 'works_flow_error', value: error }, + { key: 'works_flow_countersign', value: works_flow_countersign }, + { key: 'works_flow_sign_values', value: works_flow_sign_values }, + { key: 'works_begin_branch', value: works_begin_branch }, + { key: 'works_flow_sign_field', value: works_flow_sign_field }, + { key: 'works_flow_sign_label', value: works_flow_sign_label }, + { key: 'works_flow_code', value: flow ? flow.flow_code : '' }, + { key: 'works_flow_name', value: flow ? flow.flow_name : '' }, + { key: 'works_flow_param', value: msg }, + { key: 'works_flow_detail_id', value: detailId }, + { key: 'status', value: status }, + { key: 'statusname', value: statusName }, + { key: 'work_group', value: sessionStorage.getItem('work_group') || '' }, + { key: 'work_grade', value: sessionStorage.getItem('work_grade') || 0 }, + // { key: 'check_type', value: btn.verify.flowType === 'reject' ? '椹冲洖' : '瀹℃牳' }, + // { key: 'notice_type', value: '鎶勯��' }, + { key: 'check_userids', value: checkIds.join(',') }, + { key: 'notice_userids', value: noticeIds.join(',') }, + { key: 'works_flow_sign', value: sign }, + ) + } + } + + let md5_id = '' + if (window.GLOB.probation) { + md5_id = md5(ex.id + JSON.stringify(exps) + Math.floor(new Date().getTime() / 600000)) + md5_id = moment().format('YYYYMMDDHHmmss') + md5_id.slice(-18) + } + + return { + $backend: true, + data: [{ + id: ex.id, + exps: exps, + menuname: btn.logLabel || '', + md5_id: md5_id + }] + } + } + getInnerParam = (data, formdata, retmsg) => { const { setting, btn, columns } = this.props let _params = [] @@ -743,7 +1191,7 @@ let primaryId = '' if ((btn.Ot === 'requiredSgl' || btn.Ot === 'requiredOnce') && setting.primaryKey) { - let ids = data.map(d => { return d[setting.primaryKey] || ''}) + let ids = data.map(d => d.$$uuid) ids = ids.filter(Boolean) primaryId = ids.join(',') @@ -762,7 +1210,10 @@ param.open_key = Utils.encryptOpenKey(param.secretkey, param.timestamp) } - if (retmsg) { + if (btn.callbackType === 'script' && window.backend && window.GLOB.CacheData.has('sql_back_' + btn.uuid)) { + let _backex = window.GLOB.CacheData.get('sql_back_' + btn.uuid) + param.$backParam = this.getExps(_backex, formdata, data[0], primaryId) + } else if (retmsg) { param.$callbacksql = this.getSysDeclareSql(btn, formdata, data[0], columns, this.props.BID) } @@ -785,7 +1236,7 @@ param.dataM = sessionStorage.getItem('dataM') === 'true' ? 'Y' : '' } - let primaryId = setting.primaryKey ? cell[setting.primaryKey] || '' : '' + let primaryId = cell.$$uuid || '' if (btn.OpenType === 'pop') { // 琛ㄥ崟 if (index !== 0) { @@ -815,7 +1266,10 @@ param.open_key = Utils.encryptOpenKey(param.secretkey, param.timestamp) } - if (retmsg) { + if (btn.callbackType === 'script' && window.backend && window.GLOB.CacheData.has('sql_back_' + btn.uuid)) { + let _backex = window.GLOB.CacheData.get('sql_back_' + btn.uuid) + param.$backParam = this.getExps(_backex, formdata, cell, primaryId) + } else if (retmsg) { param.$callbacksql = this.getSysDeclareSql(btn, formdata, cell, columns, this.props.BID) } @@ -1066,7 +1520,9 @@ if (btn.intertype === 'system' || btn.intertype === 'inner') { // 绯荤粺鎺ュ彛 let params = [] - if (btn.intertype === 'system') { + if (btn.intertype === 'system' && window.backend && window.GLOB.CacheData.has('sql_' + btn.uuid)) { + params = this.getBackSystemParam(data, formdata) + } else if (btn.intertype === 'system') { params = this.getSystemParam(data, formdata) if (btn.returnValue === 'true') { params = params.map(item => { @@ -1173,7 +1629,9 @@ /** *********************璋冪敤澶栭儴鎺ュ彛************************* */ let _params = [] // 璇锋眰鍙傛暟鏁扮粍 - if (btn.procMode === 'system') { + if (btn.procMode === 'system' && window.backend && window.GLOB.CacheData.has('sql_' + btn.uuid)) { + _params = this.getBackSystemParam(data, formdata) + } else if (btn.procMode === 'system') { _params = this.getSystemParam(data, formdata, true) _params = _params.map(item => { item.script_type = 'Y' @@ -1194,7 +1652,9 @@ } else if (btn.intertype === 'custom') { // 绯荤粺鎺ュ彛 let params = [] - if (btn.procMode === 'system') { + if (btn.procMode === 'system' && window.backend && window.GLOB.CacheData.has('sql_' + btn.uuid)) { + params = this.getBackSystemParam(data, formdata) + } else if (btn.procMode === 'system') { params = this.getSystemParam(data, formdata, true) params = params.map(item => { item.script_type = 'Y' @@ -1230,13 +1690,15 @@ BID: param.BID || '', ID: param.ID || '', callbacksql: param.$callbacksql || '', - mk_api_key: '' + mk_api_key: '', + backParam: param.$backParam || '' } if (!record.ID && btn.Ot !== 'notRequired' && param[setting.primaryKey]) { record.ID = param[setting.primaryKey] } + delete param.$backParam delete param.$callbacksql if (param.$pice) { @@ -1246,7 +1708,7 @@ this.customOuterRequest(params, param, record, _resolve) return - } else if (!param.func) { + } else if (!param.func && !param.$backend) { this.customOuterRequest(params, param, record, _resolve) return } @@ -1457,6 +1919,8 @@ _resolve() } return + } else if (btn.callbackType === 'script' && record.backParam) { + param = this.getCallBackendParam(result, record) } else if (btn.callbackType === 'script' || btn.callbackType === 'default') { param = this.getCallBackSql(result, record) } else if (btn.callbackType === 'func') { @@ -1520,6 +1984,108 @@ }) } + getCallBackendParam = (result, record) => { + const { btn } = this.props + let lines = [] + let tables = [] + let param = fromJS(record.backParam).toJS() + + btn.verify.cbScripts.forEach(script => { + if (script.status === 'false') return + + if (/\s#[a-z0-9_]+(\s|\()/ig.test(script.sql)) { + tables.push(...script.sql.match(/\s#[a-z0-9_]+(\s|\()/ig)) + } + }) + + tables = tables.map(tb => tb.replace(/\s|\(/g, '')) + + if (result.$ErrCode) { + delete result.$ErrCode + delete result.$ErrMesg + } + + let getDefaultSql = (obj, tb, bid, level) => { + let vals = {} + let subObjs = [] + let id = Utils.getuuid() + + delete obj.$$key + + Object.keys(obj).forEach(key => { + let val = obj[key] + if (val === null || val === undefined) return + 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) return + + Object.keys(item).forEach(k => { + if (item[k] === null) { + item[k] = '' + } + }) + item.$$key = tb + '_' + key + subObjs.push(item) + }) + } else if (Object.keys(val).length > 0) { + val.$$key = tb + '_' + key + subObjs.push(val) + } + } else { + if (typeof(val) === 'string') { + val = val.replace(/'/ig, '"') + } else { + val = val + '' + } + vals[key] = val + } + }) + + vals.mk_level = level + vals.mk_id = id + vals.mk_bid = bid + + let isnew = true + lines.forEach(line => { + if (line.tb === tb) { + line.values.push(vals) + isnew = false + } + }) + if (isnew) { + lines.push({ + tb: tb, + type: tables.includes('#' + tb) ? '01' : '02', + values: [vals] + }) + } + + subObjs.forEach(item => { + getDefaultSql(item, item.$$key, id, level + 1) + }) + } + + getDefaultSql(result, btn.cbTable, '', 1) + + param.data[0].exps.push({ + key: 'mk_outer_params', // 鍥炶皟鑴氭湰鐨勬暟鎹浛鎹� + value: lines + }) + + let md5_id = '' + if (window.GLOB.probation) { + md5_id = md5('back_' + btn.uuid + JSON.stringify(param.data[0].exps) + Math.floor(new Date().getTime() / 600000)) + md5_id = moment().format('YYYYMMDDHHmmss') + md5_id.slice(-18) + } + + param.data[0].md5_id = md5_id + param.data[0].menuname = btn.logLabel + '(鍥炶皟)' + + return param + } + getCallBackSql = (result, record) => { const { btn } = this.props let lines = [] @@ -1570,10 +2136,15 @@ 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) - } + if (Object.keys(item).length === 0) return + + Object.keys(item).forEach(k => { + if (item[k] === null) { + item[k] = '' + } + }) + item.$$key = tb + '_' + key + subObjs.push(item) }) } else if (Object.keys(val).length > 0) { val.$$key = tb + '_' + key @@ -1846,16 +2417,18 @@ let record = { BID: param.BID || '', ID: param.ID || '', - callbacksql: param.$callbacksql || '' + callbacksql: param.$callbacksql || '', + backParam: param.$backParam || '' } if (!record.ID && btn.Ot !== 'notRequired' && param[setting.primaryKey]) { record.ID = param[setting.primaryKey] } + delete param.$backParam delete param.$callbacksql - if (!param.func) { + if (!param.func && !param.$backend) { this.outerOuterRequest(params, param, record, _resolve) return } @@ -2009,6 +2582,8 @@ _resolve() } return + } else if (btn.callbackType === 'script' && record.backParam) { + param = this.getCallBackendParam(result, record) } else if (btn.callbackType === 'script' || btn.callbackType === 'default') { param = this.getCallBackSql(result, record) } else if (btn.callbackType === 'func' || btn.callbackFunc) { diff --git a/src/tabviews/zshare/actionList/printbutton/index.jsx b/src/tabviews/zshare/actionList/printbutton/index.jsx index ba6fef3..768d2f9 100644 --- a/src/tabviews/zshare/actionList/printbutton/index.jsx +++ b/src/tabviews/zshare/actionList/printbutton/index.jsx @@ -8,6 +8,7 @@ import Utils from '@/utils/utils.js' import asyncSpinComponent from '@/utils/asyncSpinComponent' import { updateForm } from '@/utils/utils-update.js' +import UtilsDM from '@/utils/utils-datamanage.js' import MKEmitter from '@/utils/events.js' import MkIcon from '@/components/mk-icon' // import './index.scss' @@ -948,6 +949,65 @@ getDefaultSql = (formlist, data, ID) => { const { BID, btn, columns } = this.props + if (window.backend && window.GLOB.CacheData.has('sql_' + btn.uuid)) { + let setting = {...btn.verify.setting} + setting.interType = 'system' + setting.uuid = btn.uuid + + let _param = UtilsDM.getQueryDataParams(setting, [], setting.order, 1, 9999, BID, ID) + let item = window.GLOB.CacheData.get('sql_' + btn.uuid) + + _param.data[0].exps = _param.data[0].exps.filter(n => n.key !== 'mk_search') + let formkeys = [] + + formlist.forEach(form => { + if (!item.reps.includes(form.key)) return + + formkeys.push(form.key) + + let val = form.value + if (form.type === 'number' || form.type === 'rate') { + if (isNaN(val)) { + val = 0 + } + } else if (['date', 'datemonth'].includes(form.type)) { + val = val || '1949-10-01' + } + + _param.data[0].exps.push({ + key: 'mk_' + form.key + '_mk', + value: val + }) + }) + + if (data && columns && columns.length > 0) { + let datavars = {} + + Object.keys(data).forEach(key => { + datavars[key.toLowerCase()] = data[key] + }) + + columns.forEach(col => { + if (!item.reps.includes(col.field) || formkeys.includes(col.field)) return + if (!col.datatype) return + + let _key = col.field.toLowerCase() + let _val = datavars.hasOwnProperty(_key) ? datavars[_key] : '' + + if (/^date/ig.test(col.datatype) && !_val) { + _val = '1949-10-01' + } + + _param.data[0].exps.push({ + key: 'mk_' + col.field + '_mk', + value: _val + }) + }) + } + + return _param + } + let arrFields = btn.verify.columns.map(col => col.field).join(',') let param = { @@ -1036,8 +1096,6 @@ // 鑾峰彇瀛楁閿�煎 formlist.forEach(form => { let _key = form.key.toLowerCase() - - if (_vars.includes(_key)) return _vars.push(_key) diff --git a/src/tabviews/zshare/mutilform/index.jsx b/src/tabviews/zshare/mutilform/index.jsx index d92f54b7..57d140b 100644 --- a/src/tabviews/zshare/mutilform/index.jsx +++ b/src/tabviews/zshare/mutilform/index.jsx @@ -840,7 +840,9 @@ } getFormData = (deForms) => { - if (deForms.length === 1) { + if (window.backend && window.GLOB.CacheData.has('sql_' + deForms[0].uuid)) { + this.improveBackActionForm(deForms) + } else if (deForms.length === 1) { this.improveSimpleActionForm(deForms) } else if (!window.GLOB.mkHS && window.GLOB.sysType === 'local' && window.GLOB.systemType !== 'production') { this.improveSimpleActionForm(deForms) @@ -852,6 +854,106 @@ /** * @description 鑾峰彇涓嬫媺琛ㄥ崟閫夐」淇℃伅 */ + improveBackActionForm = (deForms) => { + const { BID, action } = this.props + + let sysvals = { + mk_departmentcode: sessionStorage.getItem('departmentcode') || '', + mk_organization: sessionStorage.getItem('organization') || '', + mk_user_type: sessionStorage.getItem('mk_user_type') || '', + id: this.state.ID || '', + bid: BID || '', + datam: sessionStorage.getItem('dataM') === 'true' ? 'Y' : '', + datam_begin: sessionStorage.getItem('dataM') === 'true' ? 'Y' : '', + datam_end: sessionStorage.getItem('dataM') === 'true' ? 'Y' : '' + } + if (window.GLOB.externalDatabase !== null) { + sysvals.db = window.GLOB.externalDatabase + } + + let deffers = [] + let mainItems = [] // 浜戠鎴栧崟鐐规暟鎹� + let localItems = [] // 鏈湴鏁版嵁 + let cache = action.setting.cache !== 'false' && !action.$cache + let skip = false + + deForms.forEach(item => { + let ex = window.GLOB.CacheData.get('sql_' + item.uuid) + + if (!ex) return + + let exps = [] + ex.reps.forEach(n => { + let key = n.toLowerCase() + if (sysvals.hasOwnProperty(key)) { + exps.push({ + key: n, + value: sysvals[key] + }) + } + }) + + let cell = { + id: ex.id, + exps: exps, + menuname: item.label + '锛堣〃鍗曪級', + md5_id: '' + } + + if (item.database === 'sso' && window.GLOB.mainSystemApi) { + mainItems.push(cell) + } else { + localItems.push(cell) + } + }) + + if (localItems.length) { + deffers.push({ + $backend: true, + data: localItems + }) + } + + if (mainItems.length) { + deffers.push({ + $backend: true, + data: mainItems, + rduri: window.GLOB.mainSystemApi + }) + } + + if (!deffers.length) return + + deffers = deffers.map(item => { + return new Promise(resolve => { + Api.getSystemCacheConfig(item, cache).then(res => { + if (!res.status) { + notification.warning({ + top: 92, + message: res.message, + duration: 5 + }) + skip = true + } + resolve(res) + }) + }) + }) + + Promise.all(deffers).then(response => { + let result = {...response[0], ...(response[1] || {})} + + delete result.ErrCode + delete result.ErrMesg + delete result.message + delete result.status + + this.resetFormList(result, skip) + }) + } + /** + * @description 鑾峰彇涓嬫媺琛ㄥ崟閫夐」淇℃伅 + */ improveActionForm = (deForms) => { const { BID, action } = this.props diff --git a/src/tabviews/zshare/mutilform/mkPopSelect/index.jsx b/src/tabviews/zshare/mutilform/mkPopSelect/index.jsx index 4099ef3..055a9b0 100644 --- a/src/tabviews/zshare/mutilform/mkPopSelect/index.jsx +++ b/src/tabviews/zshare/mutilform/mkPopSelect/index.jsx @@ -121,61 +121,127 @@ loading: true }) - let param = { - func: 'sPC_Get_TableData', - obj_name: 'data', - exec_type: window.GLOB.execType || 'y', - arr_field: arr_field, - default_sql: 'true', - custom_script: '', - menuname: config.label - } + let param = null + if (window.backend && window.GLOB.CacheData.has('sql_' + config.uuid)) { + let ex = window.GLOB.CacheData.get('sql_' + config.uuid) + let sysvals = { + time_id: Utils.getguid(), + mk_departmentcode: sessionStorage.getItem('departmentcode') || '', + mk_organization: sessionStorage.getItem('organization') || '', + mk_user_type: sessionStorage.getItem('mk_user_type') || '', + id: ID || '', + bid: BID || '', + datam: sessionStorage.getItem('dataM') === 'true' ? 'Y' : '', + datam_begin: sessionStorage.getItem('dataM') === 'true' ? 'Y' : '', + datam_end: sessionStorage.getItem('dataM') === 'true' ? 'Y' : '', + orderby: orderBy || config.order || '', + pagesize: config.laypage === 'true' ? pageSize : '9999', + pageindex: pageIndex + } + if (window.GLOB.externalDatabase !== null) { + sysvals.db = window.GLOB.externalDatabase + } - let sql = '' - let DateCount = '' - let _search = '' - let _orderBy = orderBy || config.order || '' - let _datasource = config.dataSource + let exps = [] - if (config.searchKey && searchKey) { - let fields = config.searchKey.split(',').map(field => field + ` like '%${searchKey}%'`) - _search = 'where ' + fields.join(' OR ') - } + if (config.searchKey) { + if (!searchKey) { + exps.push({ + key: 'mk_search', + value: [] + }) + } else { + exps.push({ + key: 'mk_search', + value: [{ + key: config.searchKey, + match: '01', + type: /,/.test(config.searchKey) ? 'text_or' : 'text', + value: searchKey + }] + }) + } + config.searchKey.split(',').forEach(key => { + sysvals[key.toLowerCase()] = searchKey || '' + }) + } - _datasource = _datasource.replace(/@BID@/ig, `'${BID || ''}'`) - _datasource = _datasource.replace(/@ID@/ig, `'${ID || ''}'`) - - if (config.laypage === 'true') { - sql = `/*system_query*/select top ${pageSize} ${arr_field} from (select ${arr_field} ,ROW_NUMBER() over(order by ${_orderBy}) as rows from ${_datasource} ${_search}) tmptable where rows > ${pageSize * (pageIndex - 1)} order by tmptable.rows ` - DateCount = `/*system_query*/select count(1) as total from ${_datasource} ${_search}` - } else if (_orderBy) { - sql = `/*system_query*/select ${arr_field} from (select ${arr_field} ,ROW_NUMBER() over(order by ${_orderBy}) as rows from ${_datasource} ${_search}) tmptable order by tmptable.rows ` - } else { - sql = `/*system_query*/select ${arr_field} from ${_datasource} ${_search} ` - } - - let departmentcode = sessionStorage.getItem('departmentcode') || '' - let organization = sessionStorage.getItem('organization') || '' - let mk_user_type = sessionStorage.getItem('mk_user_type') || '' + ex.reps.forEach(n => { + let key = n.toLowerCase() + if (sysvals.hasOwnProperty(key)) { + exps.push({ + key: n, + value: sysvals[key] + }) + } + }) - sql = `declare @mk_departmentcode nvarchar(512),@mk_organization nvarchar(512),@mk_user_type nvarchar(20) - Select @mk_departmentcode='${departmentcode}', @mk_organization='${organization}', @mk_user_type='${mk_user_type}' - ${sql}` - - // 娴嬭瘯绯荤粺鎵撳嵃鏌ヨ璇彞 - if (window.GLOB.debugger === true) { - window.mkInfo(`/*${config.label} 鏁版嵁婧�*/\n` + sql.replace(/\n\s{6}/ig, '\n')) - DateCount && window.mkInfo(`/*${config.label} 鎬绘暟鏌ヨ*/\n` + DateCount.replace(/\n\s{6}/ig, '\n')) + param = { + $backend: true, + data: [{ + id: ex.id, + exps: exps, + menuname: '', + md5_id: '' + }] + } + } else { + param = { + func: 'sPC_Get_TableData', + obj_name: 'data', + exec_type: window.GLOB.execType || 'y', + arr_field: arr_field, + default_sql: 'true', + custom_script: '', + menuname: config.label + } + + let sql = '' + let DateCount = '' + let _search = '' + let _orderBy = orderBy || config.order || '' + let _datasource = config.dataSource + + if (config.searchKey && searchKey) { + let fields = config.searchKey.split(',').map(field => field + ` like '%${searchKey}%'`) + _search = 'where ' + fields.join(' OR ') + } + + _datasource = _datasource.replace(/@BID@/ig, `'${BID || ''}'`) + _datasource = _datasource.replace(/@ID@/ig, `'${ID || ''}'`) + + if (config.laypage === 'true') { + sql = `/*system_query*/select top ${pageSize} ${arr_field} from (select ${arr_field} ,ROW_NUMBER() over(order by ${_orderBy}) as rows from ${_datasource} ${_search}) tmptable where rows > ${pageSize * (pageIndex - 1)} order by tmptable.rows ` + DateCount = `/*system_query*/select count(1) as total from ${_datasource} ${_search}` + } else if (_orderBy) { + sql = `/*system_query*/select ${arr_field} from (select ${arr_field} ,ROW_NUMBER() over(order by ${_orderBy}) as rows from ${_datasource} ${_search}) tmptable order by tmptable.rows ` + } else { + sql = `/*system_query*/select ${arr_field} from ${_datasource} ${_search} ` + } + + let departmentcode = sessionStorage.getItem('departmentcode') || '' + let organization = sessionStorage.getItem('organization') || '' + let mk_user_type = sessionStorage.getItem('mk_user_type') || '' + + sql = `declare @mk_departmentcode nvarchar(512),@mk_organization nvarchar(512),@mk_user_type nvarchar(20) + Select @mk_departmentcode='${departmentcode}', @mk_organization='${organization}', @mk_user_type='${mk_user_type}' + ${sql}` + + // 娴嬭瘯绯荤粺鎵撳嵃鏌ヨ璇彞 + if (window.GLOB.debugger === true) { + window.mkInfo(`/*${config.label} 鏁版嵁婧�*/\n` + sql.replace(/\n\s{6}/ig, '\n')) + DateCount && window.mkInfo(`/*${config.label} 鎬绘暟鏌ヨ*/\n` + DateCount.replace(/\n\s{6}/ig, '\n')) + } + + param.LText = Utils.formatOptions(sql, param.exec_type) + param.DateCount = Utils.formatOptions(DateCount, param.exec_type) + + param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + param.secretkey = Utils.encrypt('', param.timestamp) + + param.username = sessionStorage.getItem('User_Name') || '' + param.fullname = sessionStorage.getItem('Full_Name') || '' } - - param.LText = Utils.formatOptions(sql, param.exec_type) - param.DateCount = Utils.formatOptions(DateCount, param.exec_type) - - param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') - param.secretkey = Utils.encrypt('', param.timestamp) - - param.username = sessionStorage.getItem('User_Name') || '' - param.fullname = sessionStorage.getItem('Full_Name') || '' Api.genericInterface(param).then(result => { if (result.status) { diff --git a/src/tabviews/zshare/topSearch/index.jsx b/src/tabviews/zshare/topSearch/index.jsx index 032ca25..3f19a86 100644 --- a/src/tabviews/zshare/topSearch/index.jsx +++ b/src/tabviews/zshare/topSearch/index.jsx @@ -48,6 +48,8 @@ let fieldMap = new Map() let mainItems = [] // 浜戠鎴栧崟鐐规暟鎹� let localItems = [] // 鏈湴鏁版嵁 + let backMItems = [] // 浜戠鎴栧崟鐐规暟鎹� + let backLItems = [] // 鏈湴鏁版嵁 let deForms = [] // 娴嬭瘯绯荤粺锛屽崟涓姹� let advanceValues = [] let linkFields = {} @@ -55,6 +57,22 @@ let forbid = false // header涓笉璁剧疆楂樼骇鎼滅储 let _setting = {showAdv: false, show: false, style: null} let BID = this.props.BID + let sysvals = {} + + if (window.backend) { + sysvals = { + mk_departmentcode: sessionStorage.getItem('departmentcode') || '', + mk_organization: sessionStorage.getItem('organization') || '', + mk_user_type: sessionStorage.getItem('mk_user_type') || '', + bid: BID || '', + datam: sessionStorage.getItem('dataM') === 'true' ? 'Y' : '', + datam_begin: sessionStorage.getItem('dataM') === 'true' ? 'Y' : '', + datam_end: sessionStorage.getItem('dataM') === 'true' ? 'Y' : '', + } + if (window.GLOB.externalDatabase !== null) { + sysvals.db = window.GLOB.externalDatabase + } + } if (config.wrap) { _setting.show = config.wrap.show !== 'false' @@ -188,43 +206,77 @@ // 鏁版嵁婧愭煡璇㈣鍙� if (item.resourceType === '1' && item.dataSource) { - let _option = Utils.getSelectQueryOptions(item) - let _declare = `Declare @mk_departmentcode nvarchar(512),@mk_organization nvarchar(512),@mk_user_type nvarchar(20) select @mk_departmentcode='${sessionStorage.getItem('departmentcode') || ''}',@mk_organization='${sessionStorage.getItem('organization') || ''}',@mk_user_type='${sessionStorage.getItem('mk_user_type') || ''}'\n` + if (window.backend && window.GLOB.CacheData.has('sql_' + item.uuid)) { + let ex = window.GLOB.CacheData.get('sql_' + item.uuid) + let exps = [] - let exec = true - if (item.checkBid) { - item.sql = _declare + _option.sql - item.arr_field = _option.field + ex.reps.forEach(n => { + let key = n.toLowerCase() + if (sysvals.hasOwnProperty(key)) { + exps.push({ + key: n, + value: sysvals[key] + }) + } + }) - exec = !!BID - } + let cell = { + id: ex.id, + exps: exps, + menuname: item.label + '锛堟悳绱級', + md5_id: '' + } + if (item.checkBid) { + item.sqlId = ex.id + item.exps = exps + } - if (exec) { - let _sql = _option.sql.replace(/@BID@/ig, `'${BID || ''}'`) + if (item.checkBid && !BID) { + + } else if (item.database === 'sso' && window.GLOB.mainSystemApi) { + backMItems.push(cell) + } else { + backLItems.push(cell) + } + } else { + let _option = Utils.getSelectQueryOptions(item) + let _declare = `Declare @mk_departmentcode nvarchar(512),@mk_organization nvarchar(512),@mk_user_type nvarchar(20) select @mk_departmentcode='${sessionStorage.getItem('departmentcode') || ''}',@mk_organization='${sessionStorage.getItem('organization') || ''}',@mk_user_type='${sessionStorage.getItem('mk_user_type') || ''}'\n` - if (window.GLOB.debugger === true) { - window.mkInfo(_declare + _sql) + let exec = true + if (item.checkBid) { + item.sql = _declare + _option.sql + item.arr_field = _option.field + + exec = !!BID } - // 娴嬭瘯绯荤粺鍗曚釜璇锋眰 - if (!window.GLOB.mkHS && window.GLOB.sysType === 'local' && !window.GLOB.systemType) { - deForms.push({ - ...item, - arr_field: _option.field, - data_sql: Utils.formatOptions(_declare + _sql, window.GLOB.execType) - }) - } else { // 鍚堝苟璇锋眰锛屽尯鍒嗘湰鍦板強绯荤粺 - _sql = _sql.replace(/%/ig, ' mpercent ') - if (item.database === 'sso') { - if (mainItems.length === 0) { - _sql = _declare + _sql + if (exec) { + let _sql = _option.sql.replace(/@BID@/ig, `'${BID || ''}'`) + + if (window.GLOB.debugger === true) { + window.mkInfo(_declare + _sql) + } + + // 娴嬭瘯绯荤粺鍗曚釜璇锋眰 + if (!window.GLOB.mkHS && window.GLOB.sysType === 'local' && !window.GLOB.systemType) { + deForms.push({ + ...item, + arr_field: _option.field, + data_sql: Utils.formatOptions(_declare + _sql, window.GLOB.execType) + }) + } else { // 鍚堝苟璇锋眰锛屽尯鍒嗘湰鍦板強绯荤粺 + _sql = _sql.replace(/%/ig, ' mpercent ') + if (item.database === 'sso') { + if (mainItems.length === 0) { + _sql = _declare + _sql + } + mainItems.push(`select '${item.field}' as obj_name,'${_option.field}' as arr_field,'${window.btoa(window.encodeURIComponent(_sql))}' as LText`) + } else { + if (localItems.length === 0) { + _sql = _declare + _sql + } + localItems.push(`select '${item.field}' as obj_name,'${_option.field}' as arr_field,'${window.btoa(window.encodeURIComponent(_sql))}' as LText`) } - mainItems.push(`select '${item.field}' as obj_name,'${_option.field}' as arr_field,'${window.btoa(window.encodeURIComponent(_sql))}' as LText`) - } else { - if (localItems.length === 0) { - _sql = _declare + _sql - } - localItems.push(`select '${item.field}' as obj_name,'${_option.field}' as arr_field,'${window.btoa(window.encodeURIComponent(_sql))}' as LText`) } } } @@ -296,7 +348,9 @@ advanceValues, searchlist: _list }, () => { - if (!window.GLOB.mkHS && window.GLOB.sysType === 'local' && window.GLOB.systemType !== 'production') { + if (window.backend && (backMItems.length > 0 || backLItems.length > 0)) { + this.improveBackSearch(backMItems, backLItems, false) + } else if (!window.GLOB.mkHS && window.GLOB.sysType === 'local' && window.GLOB.systemType !== 'production') { this.improveSimpleSearch(deForms, false, null, BID) } else if (mainItems.length > 0 || localItems.length > 0) { this.improveSearch(mainItems, localItems, BID) @@ -337,19 +391,41 @@ resetOptions = (BID) => { let deForms = [] + let backMItems = [] // 浜戠鎴栧崟鐐规暟鎹� + let backLItems = [] // 鏈湴鏁版嵁 let searchlist = fromJS(this.state.searchlist).toJS().map(item => { if (item.checkBid) { - let sql = item.sql.replace(/@BID@/ig, `'${BID || ''}'`) - - if (window.GLOB.debugger === true) { - window.mkInfo(sql) - } + if (window.backend && item.sqlId) { + let cell = { + id: item.sqlId, + menuname: item.label + '锛堟悳绱級', + md5_id: '', + exps: item.exps.map(n => { + if (n.key === 'BID') { + n.value = BID + } + return n + }) + } - deForms.push({ - ...item, - arr_field: item.arr_field, - data_sql: Utils.formatOptions(sql, window.GLOB.execType) - }) + if (item.database === 'sso' && window.GLOB.mainSystemApi) { + backMItems.push(cell) + } else { + backLItems.push(cell) + } + } else { + let sql = item.sql.replace(/@BID@/ig, `'${BID || ''}'`) + + if (window.GLOB.debugger === true) { + window.mkInfo(sql) + } + + deForms.push({ + ...item, + arr_field: item.arr_field, + data_sql: Utils.formatOptions(sql, window.GLOB.execType) + }) + } } else if (item.checkShift) { let d = '' if (window.GLOB.CacheData.has(item.$supId)) { @@ -387,7 +463,9 @@ return item }) - if (deForms.length > 0) { + if (window.backend && (backMItems.length > 0 || backLItems.length > 0)) { + this.improveBackSearch(backMItems, backLItems, true, searchlist) + } else if (deForms.length > 0) { this.improveSimpleSearch(deForms, true, searchlist, BID) } else { this.setState({ @@ -532,6 +610,52 @@ delete result.status this.resetSearch(result, false) + }) + } + + // 鏌ヨ涓嬫媺鑿滃崟 + improveBackSearch = (mainItems, localItems, trigger, searchlist) => { + let deffers = [] + + if (localItems.length) { + deffers.push({ + $backend: true, + data: localItems + }) + } + + if (mainItems.length) { + deffers.push({ + $backend: true, + data: mainItems, + rduri: window.GLOB.mainSystemApi + }) + } + + deffers = deffers.map(item => { + return new Promise(resolve => { + Api.getSystemCacheConfig(item).then(res => { + if (!res.status) { + notification.warning({ + top: 92, + message: res.message, + duration: 5 + }) + } + resolve(res) + }) + }) + }) + + Promise.all(deffers).then(response => { + let result = {...response[0], ...(response[1] || {})} + + delete result.ErrCode + delete result.ErrMesg + delete result.message + delete result.status + + this.resetSearch(result, trigger, searchlist) }) } @@ -1049,7 +1173,7 @@ } if (typeof(val) === 'string') { - val = val.replace(/(^\s*|\s*$)/ig, '') + val = val.replace(/(^\s+|\s+$)/ig, '').replace(/\t+|\v+/g, '') } search.push({ diff --git a/src/templates/sharecomponent/actioncomponent/verifyexcelout/customscript/index.jsx b/src/templates/sharecomponent/actioncomponent/verifyexcelout/customscript/index.jsx index 3f2c50d..36f6164 100644 --- a/src/templates/sharecomponent/actioncomponent/verifyexcelout/customscript/index.jsx +++ b/src/templates/sharecomponent/actioncomponent/verifyexcelout/customscript/index.jsx @@ -210,7 +210,7 @@ </Col> <Col span={10}> <Form.Item label="鎶ラ敊瀛楁" style={{margin: 0, whiteSpace: 'nowrap'}}> - errorcode锛堝鍔犲悗缂�NT琛ㄧず鏁版嵁涓嶅洖婊氾紝濡侲NT銆丯NT銆丗NT銆丯MNT銆丆NT銆�-2NT锛�, retmsg + errorcode, retmsg </Form.Item> </Col> <Col span={24} className="sqlfield"> diff --git a/src/templates/sharecomponent/actioncomponent/verifypay/customscript/index.jsx b/src/templates/sharecomponent/actioncomponent/verifypay/customscript/index.jsx index 0ec027b..1704f52 100644 --- a/src/templates/sharecomponent/actioncomponent/verifypay/customscript/index.jsx +++ b/src/templates/sharecomponent/actioncomponent/verifypay/customscript/index.jsx @@ -167,7 +167,7 @@ <Row gutter={24}> {!type ? <Col span={8}> <Form.Item label="鎶ラ敊瀛楁" style={{margin: 0, whiteSpace: 'nowrap'}}> - errorcode锛堝鍔犲悗缂�NT琛ㄧず鏁版嵁涓嶅洖婊氾紝濡侲NT銆丯NT銆丗NT銆丯MNT銆丆NT銆�-2NT锛�, retmsg + errorcode, retmsg </Form.Item> </Col> : null} {!type ? <Col span={24} className="sqlfield"> diff --git a/src/templates/zshare/pasteform/index.jsx b/src/templates/zshare/pasteform/index.jsx index f3c3d6b..2a9a5b4 100644 --- a/src/templates/zshare/pasteform/index.jsx +++ b/src/templates/zshare/pasteform/index.jsx @@ -56,14 +56,14 @@ } } catch (e) { // 閫氳繃sql璇彞娣诲姞瀛楁闆� - if (/[a-zA-Z0-9_]+\s+(nvarchar\(\d+\)|Decimal\(18,\d+\)|Int)/ig.test(values.config)) { + if (/[a-zA-Z0-9_]+\s+(nvarchar\(\d+\)|Decimal\(18,\d+\)|Int|datetime|date)/ig.test(values.config)) { _config = { key: 'datasourcefield', type: 'array', data: [] } - let list = values.config.match(/[a-zA-Z0-9_]+\s+(nvarchar\(\d+\)|Decimal\(18,\d+\)|Int)/ig) + let list = values.config.match(/[a-zA-Z0-9_]+\s+(nvarchar\(\d+\)|Decimal\(18,\d+\)|Int|datetime|date)/ig) list.forEach(item => { _config.data.unshift({ diff --git a/src/templates/zshare/verifycard/baseform/index.jsx b/src/templates/zshare/verifycard/baseform/index.jsx index 8922bbe..8cc04fb 100644 --- a/src/templates/zshare/verifycard/baseform/index.jsx +++ b/src/templates/zshare/verifycard/baseform/index.jsx @@ -69,7 +69,7 @@ let temps = [] if (res.template_list) { temps = res.template_list.filter(item => { - if (!item.primary_industry || sysTempsIds.includes(item.template_id)) return false + if (!item.content || item.content.length < 25 || sysTempsIds.includes(item.template_id)) return false if (item.content) { item.content = item.content.replace('{{first.DATA}}\n', '').replace('\n{{remark.DATA}}', '') } diff --git a/src/utils/utils-custom.js b/src/utils/utils-custom.js index 2d86e2d..893d8aa 100644 --- a/src/utils/utils-custom.js +++ b/src/utils/utils-custom.js @@ -1745,6 +1745,115 @@ } /** + * @description 鑾峰彇鍙戦�佸閮ㄦ秷鎭� + */ +export function getOutMessage (config) { + let message = 'false' + + let filterBtn = (cell) => { + if (['pop', 'exec', 'form', 'prompt', 'formSubmit'].includes(cell.OpenType) && cell.verify) { + if (cell.verify.noteEnable === 'true' || cell.verify.wxNote === 'true' || cell.verify.emailEnable === 'true') { + message = 'true' + } + } + } + + let traversal = (components) => { + if (!components || message === 'true') return + + components.forEach(item => { + if (item.type === 'tabs') { + item.subtabs.forEach(tab => { + traversal(tab.components) + }) + } else if (item.type === 'group') { + traversal(item.components) + } else { + if (item.action) { + item.action.forEach(cell => { + if (cell.OpenType === 'popview') { + if (cell.config) { + traversal(cell.config.components) + } + } else { + filterBtn(cell) + } + }) + } + + if (item.type === 'card' || item.type === 'carousel' || item.type === 'timeline') { + item.subcards.forEach(card => { + card.elements && card.elements.forEach(cell => { + if (cell.eleType !== 'button') return + + if (cell.OpenType === 'popview') { + if (cell.config) { + traversal(cell.config.components) + } + } else { + filterBtn(cell) + } + }) + card.backElements && card.backElements.forEach(cell => { + if (cell.eleType !== 'button') return + + if (cell.OpenType === 'popview') { + if (cell.config) { + traversal(cell.config.components) + } + } else { + filterBtn(cell) + } + }) + }) + } else if (item.type === 'balcony') { + item.elements && item.elements.forEach(cell => { + if (cell.eleType !== 'button') return + + if (cell.OpenType === 'popview') { + if (cell.config) { + traversal(cell.config.components) + } + } else { + filterBtn(cell) + } + }) + } else if (item.type === 'table') { + let loopCol = (cols) => { + cols.forEach(col => { + if (col.type === 'colspan') { + loopCol(col.subcols) + } else if (col.type === 'custom') { + col.elements.forEach(cell => { + if (cell.eleType !== 'button') return + + if (cell.OpenType === 'popview') { + if (cell.config) { + traversal(cell.config.components) + } + } else { + filterBtn(cell) + } + }) + } + }) + } + loopCol(item.cols) + } else if (item.type === 'form') { + item.subcards.forEach(group => { + filterBtn(group.subButton) + }) + } + } + }) + } + + traversal(config.components) + + return message +} + +/** * @description 妫�娴嬬粍浠跺唴瀹� */ export function checkComponent (card) { @@ -2884,14 +2993,38 @@ let urlFields = config.urlFields let appType = sessionStorage.getItem('appType') let process = config.process === 'true' + let sysVars = ['loginuid', 'sessionuid', 'userid', 'appkey', 'lang', 'username', 'fullname', 'menuname'] if (urlFields) { urlFields = urlFields.map(n => n.toLowerCase()) } - let filterComponent = (components, mainSearch) => { +let callback = ` +COMMIT TRAN +set NOCOUNT ON +RETURN +END TRY +BEGIN CATCH + ROLLBACK TRAN + DECLARE @ErrorMessage NVARCHAR(4000); + DECLARE @ErrorSeverity INT; + DECLARE @ErrorState INT; + + set @ErrorCode=cast(ERROR_NUMBER() as nvarchar(50)) + set @retmsg=ERROR_MESSAGE(); + select @ErrorMessage=ERROR_MESSAGE(), @ErrorSeverity=ERROR_SEVERITY(), @ErrorState=ERROR_STATE(); + + RAISERROR(@ErrorMessage, @ErrorSeverity, @ErrorState); +END CATCH + +aaa: +select @ErrorCode as ErrorCode,@retmsg as retmsg +GOTO_RETURN: + ROLLBACK TRAN` + + let filterComponent = (components, mainSearch, label = '') => { components.forEach(item => { - item.$menuname = (config.MenuName || '') + '-' + (item.name || '') + item.$menuname = (config.MenuName || '') + label + '-' + (item.name || '') if (item.type === 'tabs') { item.subtabs.forEach(tab => { @@ -2904,10 +3037,10 @@ _mainSearch = com.search || [] }) } - filterComponent(tab.components, _mainSearch) + filterComponent(tab.components, _mainSearch, label) }) } else if (item.type === 'group') { - filterComponent(item.components, mainSearch) + filterComponent(item.components, mainSearch, label) } else { if (item.wrap && item.setting) { if (item.wrap.datatype === 'public' || item.wrap.datatype === 'static') { @@ -2921,7 +3054,7 @@ if (appType !== 'mob' && item.search && item.search.length > 0) { item.search.forEach(cell => { if (['select', 'link', 'multiselect', 'checkcard', 'radio'].includes(cell.type) && cell.resourceType === '1' && cell.dataSource) { - let msg = getFormSql(cell) + let msg = getFormSql(cell, '鎼滅储') sqls.push({uuid: cell.uuid, type: 'sForm', ...msg}) } @@ -2937,6 +3070,7 @@ item.setting.laypage = 'false' item.setting.$top = true } + item.setting.$name = item.$menuname || '' let msg = getDataSource(item, mainSearch) @@ -2971,7 +3105,7 @@ }) } else if (item.subtype === 'editable' && col.editable === 'true') { if (col.editType === 'select' && col.resourceType === '1') { - let msg = getFormSql(col) + let msg = getFormSql(col, '琛ㄥ崟') sqls.push({uuid: col.uuid, type: 'tbForm', ...msg}) } else if (col.editType === 'popSelect') { @@ -2994,6 +3128,7 @@ getCols(item.cols) if (item.subtype === 'editable' && item.submit.intertype === 'system') { + item.submit.logLabel = item.$menuname + '-鎻愪氦' let msg = getEditTableSql(item.submit, item.cols, item.columns) sqls.push({uuid: 'submit_' + item.uuid, type: 'editable', ...msg}) @@ -3039,8 +3174,13 @@ } let resetButton = (item, cell, isback) => { + cell.logLabel = item.$menuname + '-' + cell.label + if (['exec', 'prompt', 'pop', 'form', 'formSubmit'].includes(cell.OpenType)) { if (cell.intertype === 'system' || cell.procMode === 'system') { // 绯荤粺鎺ュ彛 + if (cell.verify && cell.verify.linkEnable === 'true' && /@/.test(cell.verify.linkUrl)) { + cell.returnValue = 'true' + } if (item.subtype === 'dualdatacard' && isback) { let _item = fromJS(item).toJS() _item.columns = _item.subColumns || [] @@ -3073,7 +3213,7 @@ cell.modal.fields.forEach(form => { // 鏁版嵁婧恠ql璇彞锛岄澶勭悊锛屾潈闄愰粦鍚嶅崟瀛楁璁剧疆涓洪殣钘忚〃鍗� if (['select', 'link', 'multiselect', 'radio', 'checkbox', 'checkcard'].includes(form.type) && form.resourceType === '1') { - let msg = getFormSql(form) + let msg = getFormSql(form, '琛ㄥ崟') sqls.push({uuid: form.uuid, type: 'form', ...msg}) } else if (form.type === 'popSelect') { @@ -3098,7 +3238,7 @@ } else if (cell.OpenType === 'funcbutton') { if (cell.funcType === 'print') { if (cell.intertype === 'system' && cell.verify && cell.verify.dataType === 'custom') { - let msg = getPrintSql(cell) + let msg = getPrintSql(cell, item) sqls.push({uuid: cell.uuid, type: 'print', ...msg}) } @@ -3106,7 +3246,7 @@ cell.modal.fields.forEach(form => { // 鏁版嵁婧恠ql璇彞锛岄澶勭悊锛屾潈闄愰粦鍚嶅崟瀛楁璁剧疆涓洪殣钘忚〃鍗� if (['select', 'link', 'multiselect', 'radio', 'checkbox', 'checkcard'].includes(form.type) && form.resourceType === '1') { - let msg = getFormSql(form) + let msg = getFormSql(form, '琛ㄥ崟') sqls.push({uuid: form.uuid, type: 'form', ...msg}) } else if (form.type === 'popSelect') { @@ -3152,7 +3292,7 @@ }) } - filterComponent(cell.config.components, _mainSearch) + filterComponent(cell.config.components, _mainSearch, '-' + cell.label) } } } @@ -3981,35 +4121,65 @@ if (verify.workFlow === 'true' && process) { if (verify.flowType === 'start') { + _sql = _sql.replace(/@start_type@/ig, `'寮�濮�'`) // works_flow_error 娴佺▼閿欒 - let worksReFields = ['works_flow_error', 'works_flow_code', 'works_flow_name', 'works_flow_param', 'works_flow_detail_id', 'status', 'statusname', 'work_group', 'work_grade', 'start_type'] + let worksReFields = ['works_flow_error', 'works_flow_code', 'works_flow_name', 'works_flow_param', 'works_flow_detail_id', 'status', 'statusname', 'work_group', 'work_grade'] worksReFields.forEach(n => { _sql = _sql.replace(new RegExp('@' + n + '@', 'ig'), `'@${n}@'`) }) } else { + _sql = _sql.replace(/@check_type@/ig, verify.flowType === 'reject' ? `'椹冲洖'` : `'瀹℃牳'`) + _sql = _sql.replace(/@notice_type@/ig, `'鎶勯��'`) // works_flow_error 娴佺▼閿欒 // works_flow_countersign 浼氱/鎴栫鏍囪 浼氱涓� Y // works_begin_branch 椹冲洖鑷冲紑濮嬪垎鏀紙line.mknode === 'startEdge'锛� // works_flow_sign_field 浼氱 鏍囪瀛楁 statuscharone/statuschartwo/statuscharthree/statuscharfour/statuscharfive // works_flow_sign_label 浼氱 鏍囪鍊� ***/***/宸插鏍� // works_flow_sign_values 浼氱鏍囪鎷兼帴鍊硷紙闄ゆ湰浜哄锛� - let worksReFields = ['works_flow_error', 'works_flow_countersign', 'works_flow_sign_values', 'works_begin_branch', 'works_flow_sign_label', 'works_flow_code', 'works_flow_name', 'works_flow_param', 'works_flow_detail_id', 'status', 'statusname', 'work_group', 'work_grade', 'check_type', 'notice_type', 'check_userids', 'notice_userids', 'works_flow_sign'] + let worksReFields = ['works_flow_error', 'works_flow_countersign', 'works_flow_sign_values', 'works_begin_branch', 'works_flow_sign_label', 'works_flow_code', 'works_flow_name', 'works_flow_param', 'works_flow_detail_id', 'status', 'statusname', 'work_group', 'work_grade', 'check_userids', 'notice_userids', 'works_flow_sign'] worksReFields.forEach(n => { _sql = _sql.replace(new RegExp('@' + n + '@', 'ig'), `'@${n}@'`) }) } } - if (btn.procMode === 'system') { + // if (btn.procMode === 'system' || btn.returnValue === 'true') { + // _sql += ` + // aaa: if @ErrorCode!='' + // insert into tmp_err_retmsg (ID, ErrorCode, retmsg, CreateUserID) select @time_id@,@ErrorCode, @retmsg,@UserID@` + // } else if (btn.output) { + // _sql += ` + // aaa: select @ErrorCode as ErrorCode,@retmsg as retmsg,${btn.output} as mk_b_id` + // } else { + // _sql += ` + // aaa: select @ErrorCode as ErrorCode,@retmsg as retmsg` + // } + + if (/@ErrorCode='(ENT|NNT|FNT|NMNT|CNT|-2NT)'/ig.test(_sql)) { + _sql = _sql.replace(/@ErrorCode='(ENT|NNT|FNT|NMNT|CNT|-2NT)'[\S\s]+\sgoto\s+aaa($|\s)/ig, (word) => { + return word.replace(/goto aaa/, 'goto mk_ent') + }) _sql += ` - aaa: if @ErrorCode!='' - insert into tmp_err_retmsg (ID, ErrorCode, retmsg, CreateUserID) select @time_id@,@ErrorCode, @retmsg,@UserID@` + if 1=2 + begin + mk_ent: + set @ErrorCode=left(@ErrorCode,1) + end + ` + } + + if (btn.procMode === 'system' || btn.returnValue === 'true') { + _sql += callback } else if (btn.output) { _sql += ` - aaa: select @ErrorCode as ErrorCode,@retmsg as retmsg,${btn.output} as mk_b_id` + select @ErrorCode as ErrorCode,@retmsg as retmsg,${btn.output} as mk_b_id + ${callback} + ` } else { _sql += ` - aaa: select @ErrorCode as ErrorCode,@retmsg as retmsg` + select @ErrorCode as ErrorCode,@retmsg as retmsg + ${callback} + ` } let syses = ['UserName', 'FullName', 'RoleID', 'mk_departmentcode', 'mk_organization', 'mk_user_type', 'mk_nation', 'mk_province', 'mk_city', 'mk_district', 'mk_address'] @@ -4049,7 +4219,7 @@ let reps = [] let decSql = [`@tbid nvarchar(50),@ErrorCode nvarchar(50),@retmsg nvarchar(4000),@BillCode nvarchar(50),@BVoucher nvarchar(50),@FIBVoucherDate nvarchar(50), @FiYear nvarchar(50),@ModularDetailCode nvarchar(50),@mk_deleted int,@bid nvarchar(50)`] - let secSql = [`@ErrorCode='',@retmsg='', @BillCode='',@BVoucher='',@FIBVoucherDate='',@FiYear='',@ModularDetailCode='', @mk_deleted=1, @bid=@BID@`] + let secSql = [`@ErrorCode='S',@retmsg='', @BillCode='',@BVoucher='',@FIBVoucherDate='',@FiYear='',@ModularDetailCode='', @mk_deleted=1, @bid=@BID@`] syses.forEach(s => { if (new RegExp('@' + s + '[^0-9a-z_]', 'ig').test(_sql)) { @@ -4067,20 +4237,36 @@ decSql = [...decSql, ..._declares] - _sql = `Declare ${decSql.join(',')} + // INSERT INTO s_paas_api_log (appkey,api_name,api_count,menuname,createuserid,createuser,createstaff,cdefine1,cdefine2) + // SELECT @appkey@,'sPC_TableData_InUpDe',1,@menuname@,@UserID@,@username@,@fullname@,@SessionUid@,@LoginUID@ + _sql = `/* ${btn.logLabel} */ + BEGIN TRY + begin TRAN + + Declare ${decSql.join(',')} /* 鍑瘉鍙婄敤鎴蜂俊鎭垵濮嬪寲璧嬪�� */ select ${secSql.join(',')} ${_sql} ` - _sql = _sql.replace(/\n\s{8,10}/g, '\n') - _sql = _sql.replace(/\n\s+\/\*/g, `\n/*`) - let regs = ['ID', 'BID', 'time_id', 'datam', 'LoginUID', 'SessionUid', 'UserID', 'Appkey', 'lang', 'typename'] + let regs = ['ID', 'BID', 'time_id', 'datam', 'typename'] regs.forEach(s => { if (new RegExp('@' + s + '@', 'ig').test(_sql)) { reps.push(s) } + }) + + let map = new Map() + reps.push(...sysVars) + reps = reps.filter(n => { + if (map.has(n.toLowerCase())) { + return false + } + + map.set(n.toLowerCase(), true) + + return true }) reps.forEach(n => { @@ -4091,18 +4277,33 @@ _sql = _sql.replace(/\$@/ig, '@datam_begin@').replace(/@\$/ig, '@datam_end@') reps.push('datam_begin', 'datam_end') } - - if (/\$check@|@check\$/ig.test(_sql)) { - _sql = _sql.replace(/\$check@/ig, '@mk_check_begin@').replace(/@check\$/ig, '@mk_check_end@') - reps.push('mk_check_begin', 'mk_check_end') + if (btn.procMode === 'system') { + if (/\$check@|@check\$/ig.test(_sql)) { + _sql = _sql.replace(/\$check@|@check\$/ig, '') + } + } else { + if (/\$check@|@check\$/ig.test(_sql)) { + _sql = _sql.replace(/\$check@/ig, '@mk_check_begin@').replace(/@check\$/ig, '@mk_check_end@') + reps.push('mk_check_begin', 'mk_check_end') + } } if (/@db@/ig.test(_sql)) { reps.push('db') } - reps = Array.from(new Set([...reps, ...colreps])) + _sql = _sql.replace(/\n\x20{8,10}/g, '\n').replace(/\n{3,}/g, '\n\n').replace(/^\s+|\s+$/g, '').replace(/\t+|\v+/g, '') + + reps = reps.filter(n => { + if (sysVars.includes(n.toLowerCase())) { + return false + } + + return true + }) + + reps = [...reps, ...colreps] - return { LText: _sql, reps } + return { LText: _sql, md5: md5(_sql), reps } } let getSysBackSql = (btn, component) => { @@ -4280,23 +4481,46 @@ } _sql += ` - ${_prev} - /* 澶栭儴鎺ュ彛鍏ュ弬 */ - @mk_outer_params@ - ${_back} - ` + ${_prev} + /* 澶栭儴鎺ュ彛鍏ュ弬 */ + @mk_outer_params@ + ${_back} + ` + // if (btn.output) { + // _sql += ` + // aaa: select @ErrorCode as ErrorCode,@retmsg as retmsg,${btn.output} as mk_b_id` + // } else { + // _sql += ` + // aaa: select @ErrorCode as ErrorCode,@retmsg as retmsg` + // } + if (/@ErrorCode='(ENT|NNT|FNT|NMNT|CNT|-2NT)'/ig.test(_sql)) { + _sql = _sql.replace(/@ErrorCode='(ENT|NNT|FNT|NMNT|CNT|-2NT)'[\S\s]+\sgoto\s+aaa($|\s)/ig, (word) => { + return word.replace(/goto aaa/, 'goto mk_ent') + }) + _sql += ` + if 1=2 + begin + mk_ent: + set @ErrorCode=left(@ErrorCode,1) + end + ` + } if (btn.output) { _sql += ` - aaa: select @ErrorCode as ErrorCode,@retmsg as retmsg,${btn.output} as mk_b_id` + select @ErrorCode as ErrorCode,@retmsg as retmsg,${btn.output} as mk_b_id + ${callback} + ` } else { _sql += ` - aaa: select @ErrorCode as ErrorCode,@retmsg as retmsg` + select @ErrorCode as ErrorCode,@retmsg as retmsg + ${callback} + ` } let syses = ['tbid', 'BillCode', 'BVoucher', 'FIBVoucherDate', 'FiYear', 'ModularDetailCode', 'mk_deleted', 'bid', 'UserName', 'FullName', 'RoleID', 'mk_departmentcode', 'mk_organization', 'mk_user_type', 'mk_nation', 'mk_province', 'mk_city', 'mk_district', 'mk_address'] let decSql = [`@ErrorCode nvarchar(50),@retmsg nvarchar(4000)`] - let secSql = [`@ErrorCode='',@retmsg=''`] + let secSql = [`@ErrorCode='S',@retmsg=''`] syses.forEach(s => { if (new RegExp('@' + s + '[^0-9a-z_]', 'ig').test(_sql)) { @@ -4324,21 +4548,34 @@ decSql = [...decSql, ..._declares] - _sql = `Declare ${decSql.join(',')} + _sql = `/* ${btn.logLabel}(鍥炶皟) */ + BEGIN TRY + begin TRAN + + Declare ${decSql.join(',')} /* 鍒濆鍖栬祴鍊� */ select ${secSql.join(',')} ${_sql} ` - _sql = _sql.replace(/\n\s{8,10}/g, '\n') - _sql = _sql.replace(/\n\s+\/\*/g, `\n/*`) - - let regs = ['ID', 'BID', 'time_id', 'datam', 'LoginUID', 'SessionUid', 'UserID', 'Appkey', 'lang', 'typename'] + let regs = ['ID', 'BID', 'time_id', 'datam', 'typename'] regs.forEach(s => { if (new RegExp('@' + s + '@', 'ig').test(_sql)) { reps.push(s) } + }) + + let map = new Map() + reps.push(...sysVars) + reps = reps.filter(n => { + if (map.has(n.toLowerCase())) { + return false + } + + map.set(n.toLowerCase(), true) + + return true }) reps.forEach(n => { @@ -4353,12 +4590,22 @@ reps.push('db') } - reps = Array.from(new Set([...reps, ...colreps])) + _sql = _sql.replace(/\n\x20{8,10}/g, '\n').replace(/\n{3,}/g, '\n\n').replace(/^\s+|\s+$/g, '').replace(/\t+|\v+/g, '') - return { LText: _sql, reps, tbs: tables } + reps = reps.filter(n => { + if (sysVars.includes(n.toLowerCase())) { + return false + } + + return true + }) + + reps = [...reps, ...colreps] + + return { LText: _sql, md5: md5(_sql), reps, tbs: tables } } - let getDataSource = (item, mainSearch = []) => { + let getDataSource = (item, mainSearch = [], type) => { if (!item.setting || item.setting.interType !== 'system') return let searches = item.search || [] @@ -4393,18 +4640,22 @@ } }) - if (_customScript || _tailScript) { - _tailScript += `${_tailScript} - aaa: - if @ErrorCode!='' - insert into tmp_err_retmsg (ID, ErrorCode, retmsg, CreateUserID) select @time_id@,@ErrorCode, @retmsg,@UserID@ - ` - } + // if (_customScript || _tailScript) { + // _tailScript += `${_tailScript} + // aaa: + // if @ErrorCode!='' + // insert into tmp_err_retmsg (ID, ErrorCode, retmsg, CreateUserID) select @time_id@,@ErrorCode, @retmsg,@UserID@ + // ` + // } let _search = '' if (item.setting.execute !== 'false') { _dataresource = item.setting.dataresource || '' _search = '@mk_search@' + } + + if (type === 'print') { + _search = '' } if (/\s/.test(_dataresource)) { @@ -4417,7 +4668,7 @@ let testSql = _dataresource + _customScript + _tailScript let decSql = [`@ErrorCode nvarchar(50),@retmsg nvarchar(4000)`] - let secSql = [`@ErrorCode='',@retmsg =''`] + let secSql = [`@ErrorCode='S',@retmsg =''`] let reps = [] @@ -4436,11 +4687,11 @@ } }) - decSql = `declare ${decSql.join(',')} - select ${secSql.join(',')}` + decSql = `declare ${decSql.join(',')}${type === 'print' ? '@mk_print_declare@' : ''} + select ${secSql.join(',')}${type === 'print' ? '@mk_print_select@' : ''}` // 涓嶉渶瑕佸崟寮曞彿锛歰rderBy銆乸ageSize銆乸ageIndex銆乨b - let regs = [...sFields, 'orderBy', 'pageSize', 'pageIndex', 'ID', 'BID', 'time_id', 'LoginUID', 'SessionUid', 'UserID', 'Appkey', 'lang', 'datam', 'typename'] + let regs = [...sFields, 'orderBy', 'pageSize', 'pageIndex', 'ID', 'BID', 'time_id', 'datam', 'typename'] if (item.hasExtend) { regs.push('mk_time') @@ -4485,6 +4736,8 @@ } else { LText = `select top 1 ${arr_field} from ${_dataresource} ${_search} ` } + } else if (item.setting.$fixOrder) { + LText = `select ${arr_field} from ${_dataresource} ${_search} order by ${item.setting.order} ` } else if (item.setting.order) { LText = `select ${arr_field} from ${_dataresource} ${_search} order by @orderBy@ ` reps.push('orderBy') @@ -4492,8 +4745,6 @@ LText = `select ${arr_field} from ${_dataresource} ${_search} ` } } - - reps = Array.from(new Set(reps)) let sub_name = '' let tabid = '' @@ -4508,9 +4759,33 @@ sub_field = item.subColumns.map(col => col.field).join(',') } - let sql = `SELECT obj_name='@mk_obj_name@',prm_field='',str_field='', - arr_field='${arr_field}',tabid='${tabid}',parid='${parid}',sub_name='${sub_name}',sub_field='${sub_field}' + // INSERT INTO s_paas_api_log (appkey,api_name,api_count,menuname,createuserid,createuser,createstaff,cdefine1,cdefine2) + // SELECT @appkey@,'sPC_Get_TableData',1,@menuname@,@UserID@,@username@,@fullname@,@SessionUid@,@LoginUID@ + let sql = '' + + if (item.setting.transact === 'true') { + sql = `/* ${item.setting.$name} */ + BEGIN TRY + begin TRAN + + SELECT obj_name='@mk_obj_name@',prm_field='',str_field='', + arr_field='${arr_field}',tabid='${tabid}',parid='${parid}',sub_name='${sub_name}',sub_field='${sub_field}' ` + + _tailScript += `${_tailScript} + select @ErrorCode as ErrorCode,@retmsg as retmsg + ${callback} + ` + } else { + sql = `/* ${item.setting.$name} */ + SELECT obj_name='@mk_obj_name@',prm_field='',str_field='', + arr_field='${arr_field}',tabid='${tabid}',parid='${parid}',sub_name='${sub_name}',sub_field='${sub_field}' + ` + + _tailScript += `${_tailScript} + select @ErrorCode as ErrorCode,@retmsg as retmsg + ` + } if (DateCount) { sql += `UNION ALL @@ -4518,7 +4793,10 @@ arr_field='',tabid='',parid='',sub_name='',sub_field='' ` } - + // sql += `UNION ALL + // SELECT obj_name='mk_error_code',prm_field='ErrorCode,retmsg',str_field='', + // arr_field='',tabid='',parid='',sub_name='',sub_field='' + // ` sql += ` ${decSql} ${_customScript} @@ -4527,6 +4805,18 @@ ${_tailScript} ` + let map = new Map() + reps.push(...sysVars) + reps = reps.filter(n => { + if (map.has(n.toLowerCase())) { + return false + } + + map.set(n.toLowerCase(), true) + + return true + }) + reps.forEach(n => { if (['orderBy', 'pageSize', 'pageIndex'].includes(n)) return @@ -4541,9 +4831,17 @@ } reps.push('mk_obj_name') - sql = sql.replace(/\n\x20{6,8}/g, '\n').replace(/\n{3,}/g, '\n\n').replace(/^\s+|\s+$/g, '') + sql = sql.replace(/\n\x20{6,8}/g, '\n').replace(/\n{3,}/g, '\n\n').replace(/^\s+|\s+$/g, '').replace(/\t+|\v+/g, '') - return {LText: sql, reps} + reps = reps.filter(n => { + if (sysVars.includes(n.toLowerCase())) { + return false + } + + return true + }) + + return {LText: sql, md5: md5(sql), reps, luser: /@userid@/ig.test(testSql)} } let getExcelInSql = (item) => { @@ -4691,10 +4989,14 @@ ` } - sql = `create table #${sheet} (${declarefields.join(',')},jskey nvarchar(50),BID nvarchar(50)) + sql = `/* ${item.logLabel} */ + BEGIN TRY + begin TRAN + + create table #${sheet} (${declarefields.join(',')},jskey nvarchar(50),BID nvarchar(50)) Declare @ErrorCode nvarchar(50),@retmsg nvarchar(4000),@tbid Nvarchar(512)@mk_init_declare@ - Select @ErrorCode='',@retmsg=''@mk_init_select@ + Select @ErrorCode='S',@retmsg=''@mk_init_select@ ${_initCustomScript} Insert into #${sheet} (${fields},jskey,BID) @@ -4705,6 +5007,17 @@ ${_uniquesql} ${_prevCustomScript} ${_insert}` + + let mk_ent = '' + if (/@ErrorCode='(ENT|NNT|FNT|NMNT|CNT|-2NT)'/ig.test(sql + _backCustomScript)) { + mk_ent = ` + if 1=2 + begin + mk_ent: + set @ErrorCode=left(@ErrorCode,1) + end + ` + } if (btn.workFlow === 'true' && process) { if (btn.flowSql === 'true') { @@ -4736,11 +5049,13 @@ ${_backCustomScript} drop table #${sheet} + ${mk_ent} + select @ErrorCode as ErrorCode,@retmsg as retmsg + ${callback}` - aaa: select @ErrorCode as ErrorCode,@retmsg as retmsg` - + sql = sql.replace(/@start_type@/ig, `'寮�濮�'`) // works_flow_error 娴佺▼閿欒 - let worksReFields = ['works_flow_error', 'works_flow_code', 'works_flow_name', 'works_flow_param', 'works_flow_detail_id', 'status', 'statusname', 'work_group', 'work_grade', 'start_type'] + let worksReFields = ['works_flow_error', 'works_flow_code', 'works_flow_name', 'works_flow_param', 'works_flow_detail_id', 'status', 'statusname', 'work_group', 'work_grade'] worksReFields.forEach(n => { sql = sql.replace(new RegExp('@' + n + '@', 'ig'), `'@${n}@'`) }) @@ -4749,8 +5064,15 @@ ${_backCustomScript} drop table #${sheet} + ${mk_ent} + select @ErrorCode as ErrorCode,@retmsg as retmsg + ${callback}` + } - aaa: select @ErrorCode as ErrorCode,@retmsg as retmsg` + if (/@ErrorCode='(ENT|NNT|FNT|NMNT|CNT|-2NT)'/ig.test(sql)) { + sql = sql.replace(/@ErrorCode='(ENT|NNT|FNT|NMNT|CNT|-2NT)'[\S\s]+\sgoto\s+aaa($|\s)/ig, (word) => { + return word.replace(/goto aaa/, 'goto mk_ent') + }) } let reps = [] @@ -4778,7 +5100,7 @@ sql = sql.replace(/@mk_init_declare@/ig, decSql) sql = sql.replace(/@mk_init_select@/ig, secSql) - let regs = ['ID', 'BID', 'time_id', 'datam', 'LoginUID', 'SessionUid', 'UserID', 'Appkey', 'lang', 'typename'] + let regs = ['ID', 'BID', 'time_id', 'datam', 'typename'] regs.forEach(s => { if (new RegExp('@' + s + '@', 'ig').test(sql)) { @@ -4786,22 +5108,45 @@ } }) + let map = new Map() + reps.push(...sysVars) + reps = reps.filter(n => { + if (map.has(n.toLowerCase())) { + return false + } + + map.set(n.toLowerCase(), true) + + return true + }) + reps.forEach(n => { sql = sql.replace(new RegExp('@' + n + '@', 'ig'), `'@${n}@'`) }) - - sql = sql.replace(/\n\s{6,10}/g, '\n') - sql = sql.replace(/\n\s+\/\*/g, `\n/*`) if (/\$@/ig.test(sql)) { sql = sql.replace(/\$@/ig, '@datam_begin@').replace(/@\$/ig, '@datam_end@') reps.push('datam_begin', 'datam_end') } + if (/\$check@|@check\$/ig.test(sql)) { + sql = sql.replace(/\$check@/ig, '@mk_check_begin@').replace(/@check\$/ig, '@mk_check_end@') + reps.push('mk_check_begin', 'mk_check_end') + } if (/@db@/ig.test(sql)) { reps.push('db') } - return {LText: sql, reps} + sql = sql.replace(/\n\x20{6,10}/g, '\n').replace(/\n{3,}/g, '\n\n').replace(/^\s+|\s+$/g, '').replace(/\t+|\v+/g, '') + + reps = reps.filter(n => { + if (sysVars.includes(n.toLowerCase())) { + return false + } + + return true + }) + + return {LText: sql, md5: md5(sql), reps} } let getEditTableSql = (btn, cols, columns) => { @@ -4968,9 +5313,13 @@ ` } - sql = `create table #${sheet} (${declarefields.join(',')},jskey nvarchar(50),data_type nvarchar(50),BID nvarchar(256)) + sql = `/* ${btn.logLabel} */ + BEGIN TRY + begin TRAN + + create table #${sheet} (${declarefields.join(',')},jskey nvarchar(50),data_type nvarchar(50),BID nvarchar(256)) Declare @ErrorCode nvarchar(50),@retmsg nvarchar(4000),@tbid Nvarchar(512)@mk_init_declare@ - Select @ErrorCode='',@retmsg=''@mk_init_select@ + Select @ErrorCode='S',@retmsg=''@mk_init_select@ ${_initCustomScript} Insert into #${sheet} (${fields},jskey,data_type,BID) @@ -4985,7 +5334,8 @@ drop table #${sheet} - aaa: select @ErrorCode as ErrorCode,@retmsg as retmsg` + select @ErrorCode as ErrorCode,@retmsg as retmsg + ${callback}` let reps = [] let decSql = [] @@ -5012,7 +5362,7 @@ sql = sql.replace(/@mk_init_declare@/ig, decSql) sql = sql.replace(/@mk_init_select@/ig, secSql) - let regs = ['BID', 'time_id', 'datam', 'LoginUID', 'SessionUid', 'UserID', 'Appkey', 'lang', 'typename'] + let regs = ['BID', 'time_id', 'datam', 'typename'] regs.forEach(s => { if (new RegExp('@' + s + '@', 'ig').test(sql)) { @@ -5020,12 +5370,21 @@ } }) + let map = new Map() + reps.push(...sysVars) + reps = reps.filter(n => { + if (map.has(n.toLowerCase())) { + return false + } + + map.set(n.toLowerCase(), true) + + return true + }) + reps.forEach(n => { sql = sql.replace(new RegExp('@' + n + '@', 'ig'), `'@${n}@'`) }) - - sql = sql.replace(/\n\s{6,10}/g, '\n') - sql = sql.replace(/\n\s+\/\*/g, `\n/*`) if (/\$@/ig.test(sql)) { sql = sql.replace(/\$@/ig, '@datam_begin@').replace(/@\$/ig, '@datam_end@') @@ -5035,7 +5394,17 @@ reps.push('db') } - return {LText: sql, reps} + sql = sql.replace(/\n\x20{6,10}/g, '\n').replace(/\n{3,}/g, '\n\n').replace(/^\s+|\s+$/g, '').replace(/\t+|\v+/g, '') + + reps = reps.filter(n => { + if (sysVars.includes(n.toLowerCase())) { + return false + } + + return true + }) + + return {LText: sql, md5: md5(sql), reps} } let getExcelOutSql = (btn, component) => { @@ -5058,6 +5427,7 @@ item.setting.queryType = btn.verify.queryType item.setting.laypage = btn.pagination item.setting.order = btn.verify.order || '' + item.setting.$name = btn.logLabel || '' if (btn.Ot === 'requiredOnce') { item.setting.primaryKey = btn.verify.primaryKey || component.setting.primaryKey || 'ID' @@ -5070,7 +5440,7 @@ return msg } - let getPrintSql = (btn) => { + let getPrintSql = (btn, component) => { let item = {setting: {}, columns: btn.verify.columns || [], search: [], useMSearch: 'false'} item.setting.interType = 'system' @@ -5079,18 +5449,121 @@ item.setting.queryType = btn.verify.setting.queryType item.setting.laypage = 'false' item.setting.order = btn.verify.setting.order || '' + item.setting.$name = btn.logLabel || '' + item.setting.transact = 'true' + item.setting.$fixOrder = true item.scripts = btn.verify.scripts || [] - let msg = getDataSource(item, []) + let msg = getDataSource(item, [], 'print') + + msg.LText = msg.LText.replace(/@mk_obj_name@/ig, 'data') + msg.reps = msg.reps.filter(n => n !== 'mk_obj_name') + + let formkeys = [] + let colreps = [] + let _declares = [] + let _init = [] + if (btn.execMode === 'pop' && btn.modal && btn.modal.fields) { + btn.modal.fields.forEach(item => { + if (!item.field) return + let _key = item.field.toLowerCase() + + if (!new RegExp('@' + _key + '[^0-9a-z_]', 'ig').test(msg.LText)) return + + formkeys.push(_key) + colreps.push(item.field) + + let _item = { + key: item.field, + fieldlen: item.fieldlength || 50, + writein: item.writein !== 'false', + type: item.type, + isconst: item.constant === 'true' + } + + if (_item.type === 'datemonth') { + _item.type = 'text' + } else if (_item.type === 'number' || _item.type === 'rate') { + _item.fieldlen = item.decimal || 0 + } else if (_item.type === 'date') { + _item.type = item.declareType === 'nvarchar(50)' ? 'text' : 'date' + } else if (_item.type === 'datetime') { + _item.type = 'date' + } else if (item.declare === 'decimal') { + _item.type = 'number' + _item.fieldlen = item.decimal || 0 + } + + if (_item.type === 'number' || _item.type === 'rate') { + _init.push(`@${_key}=@mk_${_key}_mk@`) + } else if (_item.type === 'date') { + _init.push(`@${_key}='@mk_${_key}_mk@'`) + } else if (_item.type === 'select' || _item.type === 'link' || _item.type === 'radio') { + _init.push(`@${_key}='@mk_${_key}_mk@'`) + } else if (_item.isconst) { + _init.push(`@${_key}=N'@mk_${_key}_mk@'`) + } else { + _init.push(`@${_key}='@mk_${_key}_mk@'`) + } + + if (_item.fieldlen && _item.fieldlen > 4000) { + _item.fieldlen = 'max' + } + + let _type = `nvarchar(${_item.fieldlen})` + + if (_item.type.match(/date/ig)) { + _type = 'datetime' + } else if (_item.type === 'number') { + _type = `decimal(18,${_item.fieldlen})` + } else if (_item.type === 'rate') { + _type = `decimal(18,2)` + } + + _declares.push(`@${_key} ${_type}`) + }) + } + + // 娣诲姞鏁版嵁涓瓧娈碉紝琛ㄥ崟鍊间紭鍏�(鎸夐挳涓嶉�夎鎴栧琛屾嫾鎺ユ椂璺宠繃) + if (btn.Ot !== 'notRequired' && component.columns.length > 0) { + component.columns.forEach(col => { + let _key = col.field.toLowerCase() + + if (formkeys.includes(_key) || !new RegExp('@' + _key + '[^0-9a-z_]', 'ig').test(msg.LText)) return + if (_key === 'id' && !/@id[^0-9a-z_@]/ig.test(msg.LText)) return + + colreps.push(col.field) + + if (col.type === 'number') { + _init.push(`@${_key}=@mk_${_key}_mk@`) + } else { + _init.push(`@${_key}='@mk_${_key}_mk@'`) + } + + _declares.push(`@${_key} ${col.datatype || 'nvarchar(50)'}`) + }) + } + + _declares = _declares.length ? ',' + _declares.join(',') : '' + _init = _init.length ? ',' + _init.join(',') : '' + + msg.LText = msg.LText.replace('@mk_print_declare@', _declares) + msg.LText = msg.LText.replace('@mk_print_select@', _init) + + msg.reps = [...msg.reps, ...colreps] return msg } let getPaySql = (btn, component) => { - let _sql = `Declare @ErrorCode nvarchar(50),@retmsg nvarchar(4000),@tbid nvarchar(50)@mk_init_declare@ - Select @ErrorCode='',@retmsg=''@mk_init_select@ - ` + let _sql = `/* ${btn.logLabel} */ + BEGIN TRY + begin TRAN + + Declare @ErrorCode nvarchar(50),@retmsg nvarchar(4000),@tbid nvarchar(50)@mk_init_declare@ + Select @ErrorCode='S',@retmsg=''@mk_init_select@ + ` btn.verify.scripts.forEach(item => { if (item.status === 'false') return @@ -5102,10 +5575,12 @@ if (btn.output) { _sql += ` - aaa: select @ErrorCode as ErrorCode,@retmsg as retmsg,${btn.output} as mk_b_id` + select @ErrorCode as ErrorCode,@retmsg as retmsg,${btn.output} as mk_b_id + ${callback}` } else { _sql += ` - aaa: select @ErrorCode as ErrorCode,@retmsg as retmsg` + select @ErrorCode as ErrorCode,@retmsg as retmsg + ${callback}` } let reps = [] @@ -5127,7 +5602,7 @@ } }) - let regs = ['ID', 'time_id', 'datam', 'LoginUID', 'SessionUid', 'UserID', 'Appkey', 'lang', 'typename'] + let regs = ['ID', 'time_id', 'datam', 'typename'] regs.forEach(s => { if (new RegExp('@' + s + '@', 'ig').test(_sql)) { @@ -5162,13 +5637,21 @@ _sql = _sql.replace(/@mk_init_declare@/ig, decSql) _sql = _sql.replace(/@mk_init_select@/ig, secSql) + let map = new Map() + reps.push(...sysVars) + reps = reps.filter(n => { + if (map.has(n.toLowerCase())) { + return false + } + + map.set(n.toLowerCase(), true) + + return true + }) + reps.forEach(n => { _sql = _sql.replace(new RegExp('@' + n + '@', 'ig'), `'@${n}@'`) }) - - reps = [...reps, ...colreps] - - _sql = _sql.replace(/\n\s{6,8}/g, '\n') if (/\$@/ig.test(_sql)) { _sql = _sql.replace(/\$@/ig, '@datam_begin@').replace(/@\$/ig, '@datam_end@') @@ -5178,10 +5661,22 @@ reps.push('db') } - return {LText: _sql, reps} + _sql = _sql.replace(/\n\x20{6,8}/g, '\n').replace(/\n{3,}/g, '\n\n').replace(/^\s+|\s+$/g, '').replace(/\t+|\v+/g, '') + + reps = reps.filter(n => { + if (sysVars.includes(n.toLowerCase())) { + return false + } + + return true + }) + + reps = [...reps, ...colreps] + + return {LText: _sql, md5: md5(_sql), reps} } - let getFormSql = (item) => { + let getFormSql = (item, tname) => { let arrfield = [item.valueField, item.valueText] if (item.type === 'checkcard') { @@ -5245,20 +5740,27 @@ decSql = decSql.join(',') secSql = secSql.join(',') + decSql = decSql ? `Declare ${decSql} select ${secSql}` : '' - if (decSql) { - sql = `Declare ${decSql} select ${secSql} - ${sql} - ` - } + sql = `/* ${item.label}锛�${tname}锛� */ + SELECT obj_name='${item.field}',prm_field='',str_field='', + arr_field='${arrfield}',tabid='',parid='',sub_name='',sub_field='' - let regs = ['ID', 'BID', 'datam', 'LoginUID', 'SessionUid', 'UserID', 'Appkey', 'lang'] + ${decSql} + ${sql} + + select 'S' as ErrorCode,'' as retmsg + ` + + let regs = ['ID', 'BID', 'datam'] regs.forEach(s => { if (new RegExp('@' + s + '@', 'ig').test(sql)) { reps.push(s) } }) + + reps.push(...sysVars) reps.forEach(n => { sql = sql.replace(new RegExp('@' + n + '@', 'ig'), `'@${n}@'`) @@ -5272,7 +5774,19 @@ reps.push('db') } - return {LText: sql, reps} + // reps.push('mk_obj_name') + + sql = sql.replace(/\n\x20{6,8}/g, '\n').replace(/\n{3,}/g, '\n\n').replace(/^\s+|\s+$/g, '').replace(/\t+|\v+/g, '') + + reps = reps.filter(n => { + if (sysVars.includes(n.toLowerCase())) { + return false + } + + return true + }) + + return {LText: sql, md5: md5(sql), reps} } let getPopSelectSql = (item) => { @@ -5303,7 +5817,7 @@ } // 涓嶉渶瑕佸崟寮曞彿锛歰rderBy銆乸ageSize銆乸ageIndex銆乨b - let regs = [...sFields, 'orderBy', 'pageSize', 'pageIndex', 'ID', 'BID', 'time_id', 'LoginUID', 'SessionUid', 'UserID', 'Appkey', 'lang', 'datam'] + let regs = [...sFields, 'orderBy', 'pageSize', 'pageIndex', 'ID', 'BID', 'time_id', 'datam'] regs.forEach(s => { if (new RegExp('@' + s + '@', 'ig').test(item.dataSource)) { @@ -5329,10 +5843,7 @@ decSql = decSql.join(',') secSql = secSql.join(',') - - if (decSql) { - decSql = `Declare ${decSql} select ${secSql}` - } + decSql = decSql ? `Declare ${decSql} select ${secSql}` : '' if (item.laypage === 'true') { /*system_query*/ @@ -5360,7 +5871,21 @@ ${decSql} ${LText} ${DateCount} + + select 'S' as ErrorCode,'' as retmsg ` + + let map = new Map() + reps.push(...sysVars) + reps = reps.filter(n => { + if (map.has(n.toLowerCase())) { + return false + } + + map.set(n.toLowerCase(), true) + + return true + }) reps.forEach(n => { if (['orderBy', 'pageSize', 'pageIndex'].includes(n)) return @@ -5375,9 +5900,17 @@ reps.push('db') } - sql = sql.replace(/\n\x20{6,8}/g, '\n').replace(/\n{3,}/g, '\n\n').replace(/^\s+|\s+$/g, '') + sql = sql.replace(/\n\x20{6,8}/g, '\n').replace(/\n{3,}/g, '\n\n').replace(/^\s+|\s+$/g, '').replace(/\t+|\v+/g, '') - return {LText: sql, reps} + reps = reps.filter(n => { + if (sysVars.includes(n.toLowerCase())) { + return false + } + + return true + }) + + return {LText: sql, md5: md5(sql), reps} } let _mainSearch = [] @@ -5418,7 +5951,7 @@ if (search.length > 0) { search.forEach(cell => { if (['select', 'link', 'multiselect', 'checkcard', 'radio'].includes(cell.type) && cell.resourceType === '1' && cell.dataSource) { - let msg = getFormSql(cell) + let msg = getFormSql(cell, '鎼滅储') sqls.push({uuid: cell.uuid, type: 'sForm', ...msg}) } @@ -5443,6 +5976,7 @@ m.setting.laypage = 'false' m.setting.$top = true + m.setting.$name = (config.MenuName || '') + '-' + (m.name || '') let msg = getDataSource(m, _mainSearch) diff --git a/src/utils/utils-datamanage.js b/src/utils/utils-datamanage.js index aff2f1e..84c388f 100644 --- a/src/utils/utils-datamanage.js +++ b/src/utils/utils-datamanage.js @@ -5,6 +5,133 @@ import MKEmitter from '@/utils/events.js' import Utils from './utils.js' +const getBackendQueryParam = (setting, search, orderBy, pageIndex, pageSize, id, BID, year, dataName) => { + let item = window.GLOB.CacheData.get('sql_' + setting.uuid) + + let searchKeys = null + if (setting.dataresource) { + searchKeys = [] + + if (search.length) { + searchKeys = Utils.getSearchkeys(search) + } + + if (id) { + if (/^excel:/.test(id)) { + id = id.replace(/^excel:/, '') + searchKeys.push({ + key: setting.primaryKey || 'ID', + match: '', + type: 'text_in', + value: id + }) + } else { + searchKeys.push({ + key: setting.primaryKey || 'ID', + match: '03', + type: 'text', + value: id + }) + } + } + } + + let values = { + time_id: Utils.getguid(), + roleid: sessionStorage.getItem('role_id') || '', + mk_departmentcode: sessionStorage.getItem('departmentcode') || '', + mk_organization: sessionStorage.getItem('organization') || '', + mk_user_type: sessionStorage.getItem('mk_user_type') || '', + mk_nation: sessionStorage.getItem('nation') || '', + mk_province: sessionStorage.getItem('province') || '', + mk_city: sessionStorage.getItem('city') || '', + mk_district: sessionStorage.getItem('district') || '', + mk_address: sessionStorage.getItem('address') || '', + orderby: orderBy || '', + pagesize: setting.laypage ? pageSize : '9999', + pageindex: pageIndex, + id: id || '', + bid: BID || '', + typename: 'admin', + datam: sessionStorage.getItem('dataM') === 'true' ? 'Y' : '', + datam_begin: sessionStorage.getItem('dataM') === 'true' ? 'Y' : '', + datam_end: sessionStorage.getItem('dataM') === 'true' ? 'Y' : '', + mk_obj_name: dataName || 'data' + } + + if (setting.hasExtend) { + values.mk_time = setting.extendTime + } + if (setting.$re_year) { + values.mk_year = year + } + if (window.GLOB.externalDatabase !== null) { + values.db = window.GLOB.externalDatabase + } + if (item.works_flow_code) { + values.works_flow_code = item.works_flow_code + } + + item.urlkeys && item.urlkeys.forEach(key => { + values[key] = item.urlparam[key] + }) + + let allSearch = Utils.getAllSearchOptions(search) + + allSearch.forEach(cell => { + values[cell.key.toLowerCase()] = cell.value + }) + + let exps = [] + + if (searchKeys) { + exps.push({ + key: 'mk_search', + value: searchKeys + }) + } + + item.reps.forEach(n => { + let key = n.toLowerCase() + if (values.hasOwnProperty(key)) { + exps.push({ + key: n, + value: values[key] + }) + } + }) + + let md5_id = '' + if (window.GLOB.probation) { + md5_id = md5(item.id + JSON.stringify(exps) + Math.floor(new Date().getTime() / 600000)) + md5_id = moment().format('YYYYMMDDHHmmss') + md5_id.slice(-18) + } + + let cell = { + id: item.id, + exps: exps, + menuname: setting.$name || '', + md5_id: md5_id + } + + if (dataName) { + cell.dataName = dataName + cell.luser = item.luser + return cell + } + + let param = { + $backend: true, + data: [cell] + } + + if (setting.database === 'sso' && window.GLOB.mainSystemApi) { + param.rduri = window.GLOB.mainSystemApi + } + + return param +} + export default class DataUtils { /** * @description 鏁版嵁婧愮粺涓�鏌ヨ @@ -13,22 +140,23 @@ let param = null if (setting.interType === 'system') { - if (window.backend && window.GLOB.CacheData.has('sql_' + setting.uuid) && !window.GLOB.mkHS) { - param = this.getDefaultQueryParam(setting, search, orderBy, pageIndex, pageSize, id, BID, year) - this.getBackendQueryParam(setting, search, orderBy, pageIndex, pageSize, id, BID, year) + if (window.backend && window.GLOB.CacheData.has('sql_' + setting.uuid)) { + param = getBackendQueryParam(setting, search, orderBy, pageIndex, pageSize, id, BID, year) } else { param = this.getDefaultQueryParam(setting, search, orderBy, pageIndex, pageSize, id, BID, year) + param.BID = BID || '' + param.dataM = sessionStorage.getItem('dataM') === 'true' ? 'Y' : '' } } else { param = this.getCustomQueryParam(setting, search, orderBy, pageIndex, pageSize, id, year) - } - if (BID) { - param.BID = BID - } - // 鏁版嵁绠$悊鏉冮檺 - if (sessionStorage.getItem('dataM') === 'true') { - param.dataM = 'Y' + if (BID) { + param.BID = BID + } + // 鏁版嵁绠$悊鏉冮檺 + if (sessionStorage.getItem('dataM') === 'true') { + param.dataM = 'Y' + } } return param @@ -336,235 +464,6 @@ } /** - * @description 鑾峰彇绯荤粺瀛樺偍杩囩▼鐨勫弬鏁� - */ - static getBackendQueryParam (setting, search, orderBy, pageIndex, pageSize, id, BID, year) { - let item = window.GLOB.CacheData.get('sql_' + setting.uuid) - - let param = {} - - let searchKeys = null - if (setting.dataresource) { - searchKeys = [] - - if (search.length) { - searchKeys = Utils.getSearchkeys(search) - } - - if (id) { - if (/^excel:/.test(id)) { - id = id.replace(/^excel:/, '') - searchKeys.push({ - key: setting.primaryKey || 'ID', - match: 'in', - type: 'text_in', - value: id - }) - } else { - searchKeys.push({ - key: setting.primaryKey || 'ID', - match: '=', - type: 'text', - value: id - }) - } - } - } - - let values = { - userid: sessionStorage.getItem('UserID') || '', - time_id: Utils.getguid(), - username: sessionStorage.getItem('User_Name') || '', - fullname: sessionStorage.getItem('Full_Name') || '', - roleid: sessionStorage.getItem('role_id') || '', - mk_departmentcode: sessionStorage.getItem('departmentcode') || '', - mk_organization: sessionStorage.getItem('organization') || '', - mk_user_type: sessionStorage.getItem('mk_user_type') || '', - mk_nation: sessionStorage.getItem('nation') || '', - mk_province: sessionStorage.getItem('province') || '', - mk_city: sessionStorage.getItem('city') || '', - mk_district: sessionStorage.getItem('district') || '', - mk_address: sessionStorage.getItem('address') || '', - orderby: orderBy, - pagesize: setting.laypage ? pageSize : '9999', - pageindex: pageIndex, - id: id || '', - bid: BID || '', - loginuid: sessionStorage.getItem('LoginUID') || '', - sessionuid: localStorage.getItem('SessionUid') || '', - appkey: window.GLOB.appkey || '', - lang: sessionStorage.getItem('lang'), - typename: 'admin', - datam: sessionStorage.getItem('dataM') === 'true' ? 'Y' : '', - datam_begin: sessionStorage.getItem('dataM') === 'true' ? 'Y' : '', - datam_end: sessionStorage.getItem('dataM') === 'true' ? 'Y' : '', - // datam_begin: sessionStorage.getItem('dataM') === 'true' ? '/*' : '', - // datam_end: sessionStorage.getItem('dataM') === 'true' ? '*/' : '', - mk_obj_name: 'data' - } - - if (setting.hasExtend) { - values.mk_time = setting.extendTime - } - if (setting.$re_year) { - values.mk_year = year - } - if (window.GLOB.externalDatabase !== null) { - values.db = window.GLOB.externalDatabase - } - if (item.works_flow_code) { - values.works_flow_code = item.works_flow_code - } - - item.urlkeys.forEach(key => { - values[key] = item.urlparam[key] - }) - - let allSearch = Utils.getAllSearchOptions(search) - - allSearch.forEach(cell => { - values[cell.key.toLowerCase()] = cell.value - }) - - let list = [] - - if (searchKeys) { - list.push({ - key: 'mk_search', - value: searchKeys - }) - } - - let sql = item.sql - - item.reps.forEach(n => { - let key = n.toLowerCase() - if (values.hasOwnProperty(key)) { - list.push({ - key: n, - value: values[key] - }) - } - }) - - // let list = [ - // { - // key: "mk_search", - // value: [ - // { key: "nvarchar1,nvarchar3", match: "like", type: "text_or", value: "www" }, - // { key: "int2", match: ">=", type: "number", value: "0" }, - // { key: "int2", match: "<=", type: "number", value: "50" } - // ] - // }, - // { key: "mk_obj_name", value: "data" }, - // { key: "pageSize", value: 10 }, - // { key: "orderBy", value: "ID desc" }, - // { key: "pageIndex", value: 1 }, - // { - // key: 'mk_excel_data', - // value: [[`'1'`, `'2'`, `'3'`, `'4'`, `'5'`], [`'6'`, `'7'`, `'8'`, `'9'`, `'10'`]] - // }, - // { - // key: 'mk_outer_params', - // value: [ - // { - // tb: '#tb1', - // keys: ['[nvarchar1]', '[nvarchar2]', '[nvarchar3]', '[mk_level]','[mk_id]','[mk_bid]'], - // values: [[`'1'`, `'2'`, `'3'`, `'4'`, `'5'`, `'6'`], [`'7'`, `'8'`, `'9'`, `'10'`, `'11'`, `'12'`]] - // }, - // { - // tb: '@tb2', - // keys: ['[field1]', '[field2]', '[field3]', '[mk_level]','[mk_id]','[mk_bid]'], - // values: [[`'1'`, `'2'`, `'3'`, `'4'`, `'5'`, `'6'`], [`'7'`, `'8'`, `'9'`, `'10'`, `'11'`, `'12'`]] - // } - // ] - // }, - // ] - - list.forEach(cell => { - if (cell.key === 'mk_outer_params') { - let mk_outer_params = [] - cell.value.forEach(n => { - mk_outer_params.push(` Insert into ${n.tb} (${n.keys.join(',')}) `) - let vals = [] - n.values.forEach(m => { - vals.push(` Select ${m.join(',')} `) - }) - mk_outer_params.push(vals.join(' Union all ')) - }) - mk_outer_params = mk_outer_params.join('') - sql = sql.replace(/@mk_outer_params@/ig, mk_outer_params) - } else if (cell.key === 'mk_excel_data') { - let mk_excel_data = [] - cell.value.forEach(n => { - mk_excel_data.push(`Select ${n.join(',')}`) - }) - mk_excel_data = mk_excel_data.join(' Union all ') - sql = sql.replace(/@mk_excel_data@/ig, mk_excel_data) - } else if (cell.key === 'datam_begin' || cell.key === 'mk_check_begin') { - if (cell.value === 'Y') { - sql = sql.replace(new RegExp('@' + cell.key + '@', 'ig'), '/*') - } else { - sql = sql.replace(new RegExp('@' + cell.key + '@', 'ig'), '') - } - } else if (cell.key === 'datam_end' || cell.key === 'mk_check_end') { - if (cell.value === 'Y') { - sql = sql.replace(new RegExp('@' + cell.key + '@', 'ig'), '*/') - } else { - sql = sql.replace(new RegExp('@' + cell.key + '@', 'ig'), '') - } - } else if (cell.key === 'mk_search') { - let mk_search = [] - - cell.value.forEach(n => { - let str = n.match === 'like' || n.match === 'not like' ? '%' : '' - if (n.type === 'text_or') { - let vals = n.key.split(',').map(key => { - return `${key} ${n.match} '${str}${n.value}${str}'` - }) - - mk_search.push(`(${vals.join(' OR ')})`) - } else if (n.type === 'text_multi') { - mk_search.push(`'${n.value}' ${n.match} '%'+${n.key}+'%'`) - } else if (n.type === 'number') { - mk_search.push(`${n.key} ${n.match} ${n.value}`) - } else if (n.type === 'text_in') { - mk_search.push(`${n.key} in (select ID from dbo.SplitComma('${n.value}'))`) - } else { - mk_search.push(`${n.key} ${n.match} '${str}${n.value}${str}'`) - } - }) - - if (mk_search.length === 0) { - mk_search = '' - } else { - mk_search = 'where ' + mk_search.join(' AND ') - } - - sql = sql.replace(/@mk_search@/ig, mk_search) - } else { - sql = sql.replace(new RegExp('@' + cell.key + '@', 'ig'), cell.value) - } - }) - - param.list = [ - { - id: item.v_id, - regExps: list, - menuname: setting.$name || '', - s_debug_type: window.GLOB.probation ? 'Y' : '', - // md5_id: window.GLOB.probation ? md5(JSON.stringify(list)) : '', - } - ] - - if (setting.database === 'sso' && window.GLOB.mainSystemApi) { - param.rduri = window.GLOB.mainSystemApi - } - - return param - } - - /** * @description 鑾峰彇绯荤粺瀛樺偍杩囩▼鍚堣鍊肩殑鍙傛暟 */ static getStatQueryDataParams (setting, statFields, search, orderBy, BID) { @@ -731,8 +630,12 @@ /** * @description 鐢熸垚鍗曚釜缁勪欢sPC_Get_structured_data璇锋眰鍙傛暟 */ -export function getStructDefaultParam (component, searchlist, first) { +export function getStructDefaultParam (component, searchlist, first, BID) { const { columns, setting, dataName, format, uuid } = component + + if (window.backend && window.GLOB.CacheData.has('sql_' + uuid)) { + return getBackendQueryParam(setting, searchlist, setting.order, 1, 1000, '', BID, '', dataName) + } let _dataresource = setting.dataresource let _customScript = setting.customScript @@ -789,7 +692,7 @@ return { uuid: uuid, - name: dataName, + dataName: dataName, $name: setting.$name, columns: columns, par_tablename: '', @@ -806,6 +709,38 @@ * @description 鐢熸垚sPC_Get_structured_data璇锋眰鍙傛暟 */ export function getStructuredParams (params, config, BID) { + if (window.backend && params[0].exps) { + let param = { + $backend: true, + data: params.map(item => { + let cell = {...item} + + delete cell.dataName + delete cell.luser + + return cell + }) + } + + if (config.cacheUseful === 'true') { + param.time_limit = config.cacheTime + + if (config.timeUnit === 'day') { + param.time_limit = param.time_limit * 1440 + } else if (config.timeUnit === 'hour') { + param.time_limit = param.time_limit * 60 + } + + if (params.findIndex(item => item.luser) > -1) { + param.data_md5 = md5(window.GLOB.appkey + params[0].id + sessionStorage.getItem('UserID')) + } else { + param.data_md5 = md5(window.GLOB.appkey + params[0].id) + } + } + + return param + } + let LText_field = [] let diffUser = false @@ -845,9 +780,9 @@ } item.columns.forEach(cell => { - LText_field.push(`Select '${item.name}' as tablename,'${cell.field}' as fieldname,'${cell.datatype}' as field_type`) + LText_field.push(`Select '${item.dataName}' as tablename,'${cell.field}' as fieldname,'${cell.datatype}' as field_type`) }) - return `Select '${item.name}' as tablename,'${window.btoa(window.encodeURIComponent(_sql))}' as LText,'${window.btoa(window.encodeURIComponent(_script))}' as Lcustomize,'${item.type}' as table_type,'${item.primaryKey}' as primary_key,'${item.par_tablename}' as par_tablename,'${item.foreign_key}' as foreign_key,'${index}' as Sort` + return `Select '${item.dataName}' as tablename,'${window.btoa(window.encodeURIComponent(_sql))}' as LText,'${window.btoa(window.encodeURIComponent(_script))}' as Lcustomize,'${item.type}' as table_type,'${item.primaryKey}' as primary_key,'${item.par_tablename}' as par_tablename,'${item.foreign_key}' as foreign_key,'${index}' as Sort` }) let param = { diff --git a/src/utils/utils.js b/src/utils/utils.js index d63640a..48c79b6 100644 --- a/src/utils/utils.js +++ b/src/utils/utils.js @@ -714,6 +714,15 @@ static getSearchkeys (searches) { let searchText = [] + let matchs = { + 'like': '01', + 'not like': '02', + '=': '03', + '>': '04', + '<': '05', + '>=': '06', + '<=': '07', + } searches.forEach(item => { if (item.forbid || !item.value) return @@ -834,12 +843,12 @@ searchText.push({ key: item.key, match: '>=', - type: 'number', + type: 'text', value: val[0] || -999999999 }, { key: item.key, match: '<=', - type: 'number', + type: 'text', value: val[1] || 999999999 }) } else { @@ -847,6 +856,10 @@ } }) + searchText.forEach(item => { + item.match = matchs[item.match] || '01' + }) + return searchText } diff --git a/src/views/billprint/index.jsx b/src/views/billprint/index.jsx index 112e0b5..f708040 100644 --- a/src/views/billprint/index.jsx +++ b/src/views/billprint/index.jsx @@ -2,6 +2,7 @@ import { is, fromJS } from 'immutable' import { Col, Row, Spin, notification, Button, Modal } from 'antd' import moment from 'moment' +import md5 from 'md5' import Api from '@/api' import Utils from '@/utils/utils.js' @@ -65,6 +66,7 @@ let param = JSON.parse(window.decodeURIComponent(window.atob(params.param))) sessionStorage.setItem('dataM', param.dataM || '') + this.setState({ BID: param.id || '', tempId: param.tempId, @@ -303,6 +305,22 @@ config.components = config.components.filter(item => !['tabs', 'search'].includes(item.type)) + if (window.backend && config.allSqls) { + let urlparam = urlParam || {} + let keys = Object.keys(urlparam) + config.allSqls.forEach(item => { + item.id = md5(window.GLOB.appkey + item.v_id) + if (item.type === 'datasource' || item.type === 'excelOut') { + item.urlkeys = keys + item.urlparam = urlparam + if (config.flow_code) { + item.works_flow_code = config.flow_code + } + } + window.GLOB.CacheData.set('sql_' + item.uuid, item) + }) + } + let userName = sessionStorage.getItem('User_Name') || '' let fullName = sessionStorage.getItem('Full_Name') || '' @@ -487,6 +505,8 @@ component.setting.sync = 'false' return component } + + component.setting.uuid = component.uuid let _customScript = '' let _tailScript = '' @@ -532,6 +552,12 @@ component.setting.customScript = _customScript // 鏁寸悊鍚庤嚜瀹氫箟鑴氭湰 component.setting.tailScript = _tailScript // 鍚庣疆鑷畾涔夎剼鏈� + + if (window.backend && config.allSqls) { + component.setting.sync = 'false' + } else if (_tailScript) { + component.setting.sync = 'false' + } // floor 缁勪欢鐨勫眰绾� // pageable 鏄惁鍒嗛〉锛岀粍浠跺睘鎬э紝涓嶅垎椤电殑缁勪欢鎵嶅彲浠ョ粺涓�鏌ヨ @@ -682,6 +708,8 @@ } return } + + inter.setting.uuid = inter.uuid let _customScript = '' let _tailScript = '' @@ -1091,6 +1119,14 @@ reloadTabs = () => { if (this.reloading) return + let time = new Date().getTime() + + let oldTime = sessionStorage.getItem('mk_reloadTabs') + + if (oldTime && time - oldTime < 180000) return + + sessionStorage.setItem('mk_reloadTabs', time) + this.reloading = true Api.getAppVersion(true).then(() => { diff --git a/src/views/design/sidemenu/index.jsx b/src/views/design/sidemenu/index.jsx index 7f9b43f..3bea583 100644 --- a/src/views/design/sidemenu/index.jsx +++ b/src/views/design/sidemenu/index.jsx @@ -1,7 +1,7 @@ import React, {Component} from 'react' import { is, fromJS } from 'immutable' import { Menu, Popover, Modal, notification } from 'antd' -import { EditOutlined, PlusOutlined, SettingOutlined, ApiOutlined } from '@ant-design/icons' +import { EditOutlined, PlusOutlined, SettingOutlined, ApiOutlined, SoundOutlined } from '@ant-design/icons' import moment from 'moment' import asyncComponent from '@/utils/asyncComponent' @@ -326,7 +326,7 @@ {item.children.map(cell => { return ( <Menu.Item key={cell.MenuID}> - <span className={'editable-menu-item ' + (cell.up_action ? 'unupdate' : '')} onDoubleClick={() => this.editmenu(cell)}>{cell.PageParam && cell.PageParam.interfaces === 'true' ? <ApiOutlined title="鑿滃崟涓娇鐢ㄤ簡澶栭儴鎺ュ彛" /> : null}{cell.MenuName}</span> + <span className={'editable-menu-item ' + (cell.up_action ? 'unupdate' : '')} onDoubleClick={() => this.editmenu(cell)}>{cell.PageParam && cell.PageParam.interfaces === 'true' ? <ApiOutlined title="鑿滃崟涓娇鐢ㄤ簡澶栭儴鎺ュ彛" /> : null}{cell.PageParam && cell.PageParam.msg === 'true' ? <SoundOutlined title="鑿滃崟涓彂閫佷簡娑堟伅" /> : null}{cell.MenuName}</span> </Menu.Item> ) })} diff --git a/src/views/design/sidemenu/index.scss b/src/views/design/sidemenu/index.scss index 3521e56..c12e612 100644 --- a/src/views/design/sidemenu/index.scss +++ b/src/views/design/sidemenu/index.scss @@ -23,6 +23,15 @@ top: 11px; color: orange; } + .anticon-sound { + position: absolute; + left: 25px; + top: 11px; + color: orange; + } + .anticon-api + .anticon-sound { + left: 5px; + } } .editable-menu-item.unupdate { diff --git a/src/views/menudesign/index.jsx b/src/views/menudesign/index.jsx index 36cb91f..bffacc8 100644 --- a/src/views/menudesign/index.jsx +++ b/src/views/menudesign/index.jsx @@ -13,7 +13,7 @@ import Utils from '@/utils/utils.js' import { langs } from '@/store/options' import MKEmitter from '@/utils/events.js' -import { getTables, getFuncsAndInters, getLangTrans, getAllSqls } from '@/utils/utils-custom.js' +import { getTables, getFuncsAndInters, getOutMessage, getLangTrans, getAllSqls } from '@/utils/utils-custom.js' import asyncComponent from '@/utils/asyncComponent' import '@/assets/css/design.scss' @@ -809,7 +809,6 @@ } let long_data = '' - delete config.allSqls if (window.backend && config.enabled) { let sqls = getAllSqls(config) let _t = moment().format('YYYYMMDDHHmmss') @@ -822,9 +821,21 @@ } long_data = [] + let oriIds = {} + if (config.allSqls) { + config.allSqls.forEach(item => { + if (!item.md5) return + oriIds[item.uuid + item.md5] = item.v_id + }) + } config.allSqls = sqls.map(item => { let v_id = _t + getguid() + + if (oriIds[item.uuid + item.md5]) { + v_id = oriIds[item.uuid + item.md5] + } + long_data.push(`${md5(window.GLOB.appkey + v_id)},${item.uuid},${v_id},${window.btoa(window.encodeURIComponent(item.LText))}`) return { @@ -832,11 +843,14 @@ v_id: v_id, type: item.type, reps: item.reps, - sql: item.LText + md5: item.md5 || '', + luser: item.luser === true } }) long_data = long_data.join(';') + } else { + delete config.allSqls } if (config.cacheUseful !== 'true') { @@ -885,6 +899,7 @@ } let interfaces = getFuncsAndInters(config) + let msg = getOutMessage(config) let urlFields = config.urlFields ? config.urlFields.join(',') : '' let langSql = getLangTrans(config) @@ -898,7 +913,7 @@ EasyCode: config.easyCode || '', Template: 'CustomPage', MenuName: config.MenuName || '', - PageParam: JSON.stringify({Template: 'CustomPage', OpenType: config.OpenType || 'newtab', hidden: config.hidden || 'false', menuColor: config.menuColor || '', interfaces, urlFields}), + PageParam: JSON.stringify({Template: 'CustomPage', OpenType: config.OpenType || 'newtab', hidden: config.hidden || 'false', menuColor: config.menuColor || '', interfaces, msg, urlFields}), open_edition: config.open_edition, long_data: long_data, debug_md5: key, diff --git a/src/views/mkiframe/index.jsx b/src/views/mkiframe/index.jsx index 00167e6..4730c77 100644 --- a/src/views/mkiframe/index.jsx +++ b/src/views/mkiframe/index.jsx @@ -166,6 +166,14 @@ reloadTabs = () => { if (this.reloading) return + let time = new Date().getTime() + + let oldTime = sessionStorage.getItem('mk_reloadTabs') + + if (oldTime && time - oldTime < 180000) return + + sessionStorage.setItem('mk_reloadTabs', time) + this.reloading = true Api.getAppVersion(true).then(() => { diff --git a/src/views/mobdesign/index.jsx b/src/views/mobdesign/index.jsx index 95a7773..19aa1c2 100644 --- a/src/views/mobdesign/index.jsx +++ b/src/views/mobdesign/index.jsx @@ -11,7 +11,7 @@ import Api from '@/api' import Utils from '@/utils/utils.js' import MKEmitter from '@/utils/events.js' -import MenuUtils, { getTables, getFuncsAndInters, getLangTrans } from '@/utils/utils-custom.js' +import MenuUtils, { getTables, getFuncsAndInters, getOutMessage, getLangTrans, getAllSqls } from '@/utils/utils-custom.js' import asyncComponent from '@/utils/asyncComponent' import '@/assets/css/design.scss' @@ -1481,6 +1481,51 @@ delete config.force } + let long_data = '' + if (window.backend && config.enabled) { + let sqls = getAllSqls(config) + let _t = moment().format('YYYYMMDDHHmmss') + let getguid = () => { + let uuid = '' + for (let i = 0; i < 18; i++) { + uuid += String.fromCharCode(Math.floor(Math.random() * 26) + 65) + } + return uuid + } + + long_data = [] + let oriIds = {} + if (config.allSqls) { + config.allSqls.forEach(item => { + if (!item.md5) return + oriIds[item.uuid + item.md5] = item.v_id + }) + } + + config.allSqls = sqls.map(item => { + let v_id = _t + getguid() + + if (oriIds[item.uuid + item.md5]) { + v_id = oriIds[item.uuid + item.md5] + } + + long_data.push(`${md5(window.GLOB.appkey + v_id)},${item.uuid},${v_id},${window.btoa(window.encodeURIComponent(item.LText))}`) + + return { + uuid: item.uuid, + v_id: v_id, + type: item.type, + reps: item.reps, + md5: item.md5 || '', + luser: item.luser === true + } + }) + + long_data = long_data.join(';') + } else { + delete config.allSqls + } + if (config.cacheUseful !== 'true') { config.components = this.resetSyncQuery(config.components) } @@ -1576,6 +1621,7 @@ menus_used_list = window.btoa(window.encodeURIComponent(menus_used_list || 'del')) let interfaces = getFuncsAndInters(config) + let msg = getOutMessage(config) roleParam.interfaces = interfaces let langSql = getLangTrans(config) @@ -1591,9 +1637,10 @@ TypeCharOne: sessionStorage.getItem('kei_no'), Typename: sessionStorage.getItem('typename'), MenuName: config.MenuName || '', - PageParam: JSON.stringify({Template: 'webPage', interfaces}), + PageParam: JSON.stringify({Template: 'webPage', interfaces, msg}), open_edition: config.open_edition, menus_rolelist: window.btoa(window.encodeURIComponent(JSON.stringify(roleParam))), + long_data: long_data, // LText: '', // LTexttb: '', menus_used_list, diff --git a/src/views/pcdesign/index.jsx b/src/views/pcdesign/index.jsx index db2af66..6162466 100644 --- a/src/views/pcdesign/index.jsx +++ b/src/views/pcdesign/index.jsx @@ -10,7 +10,7 @@ import Api from '@/api' import Utils from '@/utils/utils.js' -import { getTables, getFuncsAndInters, getLangTrans } from '@/utils/utils-custom.js' +import { getTables, getFuncsAndInters, getOutMessage, getLangTrans, getAllSqls } from '@/utils/utils-custom.js' import MKEmitter from '@/utils/events.js' import MenuUtils from '@/utils/utils-custom.js' import asyncComponent from '@/utils/asyncComponent' @@ -1207,6 +1207,51 @@ delete config.force } + let long_data = '' + if (window.backend && config.enabled) { + let sqls = getAllSqls(config) + let _t = moment().format('YYYYMMDDHHmmss') + let getguid = () => { + let uuid = '' + for (let i = 0; i < 18; i++) { + uuid += String.fromCharCode(Math.floor(Math.random() * 26) + 65) + } + return uuid + } + + long_data = [] + let oriIds = {} + if (config.allSqls) { + config.allSqls.forEach(item => { + if (!item.md5) return + oriIds[item.uuid + item.md5] = item.v_id + }) + } + + config.allSqls = sqls.map(item => { + let v_id = _t + getguid() + + if (oriIds[item.uuid + item.md5]) { + v_id = oriIds[item.uuid + item.md5] + } + + long_data.push(`${md5(window.GLOB.appkey + v_id)},${item.uuid},${v_id},${window.btoa(window.encodeURIComponent(item.LText))}`) + + return { + uuid: item.uuid, + v_id: v_id, + type: item.type, + reps: item.reps, + md5: item.md5 || '', + luser: item.luser === true + } + }) + + long_data = long_data.join(';') + } else { + delete config.allSqls + } + if (config.cacheUseful !== 'true') { config.components = this.resetSyncQuery(config.components) } @@ -1257,6 +1302,7 @@ } let interfaces = getFuncsAndInters(config) + let msg = getOutMessage(config) roleParam.interfaces = interfaces let langSql = getLangTrans(config) @@ -1272,9 +1318,10 @@ TypeCharOne: sessionStorage.getItem('kei_no'), Typename: 'pc', MenuName: config.MenuName || '', - PageParam: JSON.stringify({Template: 'webPage', interfaces}), + PageParam: JSON.stringify({Template: 'webPage', interfaces, msg}), menus_rolelist: window.btoa(window.encodeURIComponent(JSON.stringify(roleParam))), open_edition: config.open_edition, + long_data: long_data, // LText: '', // LTexttb: '', menus_used_list, diff --git a/src/views/rolemanage/index.jsx b/src/views/rolemanage/index.jsx index 3697b06..2fdc6e4 100644 --- a/src/views/rolemanage/index.jsx +++ b/src/views/rolemanage/index.jsx @@ -3,7 +3,7 @@ import { Spin, notification, Button, Table, Modal, Tree, Input, Empty } from 'antd' import moment from 'moment' import md5 from 'md5' -import { ApiOutlined } from '@ant-design/icons' +import { ApiOutlined, SoundOutlined } from '@ant-design/icons' import Api from '@/api' import Utils from '@/utils/utils.js' @@ -28,8 +28,8 @@ title: '鑿滃崟鍚嶇О', dataIndex: 'MenuName', key: 'MenuName', align: 'center', render: (text, record) => { if (record.extra || this.state.appKeys.includes(record.MenuID)) { return <span style={{color: '#1890ff'}}>{text}</span> - } else if (record.interfaces === 'true') { - return <span><ApiOutlined style={{color: 'orange', marginRight: '5px'}} title="鑿滃崟涓娇鐢ㄤ簡澶栭儴鎺ュ彛" />{text}</span> + } else if (record.interfaces === 'true' || record.msg === 'true') { + return <span>{record.interfaces === 'true' ? <ApiOutlined style={{color: 'orange', marginRight: '5px'}} title="鑿滃崟涓娇鐢ㄤ簡澶栭儴鎺ュ彛" /> : null}{record.msg === 'true' ? <SoundOutlined style={{color: 'orange', marginRight: '5px'}} title="鑿滃崟涓彂閫佷簡娑堟伅" /> : null}{text}</span> } return text } @@ -157,6 +157,7 @@ let pageParam = JSON.parse(window.decodeURIComponent(window.atob(item.menus_rolelist))) item.nodes = pageParam item.interfaces = pageParam.interfaces || 'false' + item.msg = pageParam.msg || 'false' if (pageParam.type) { item.type = pageParam.type diff --git a/src/views/tabledesign/index.jsx b/src/views/tabledesign/index.jsx index 26510b9..5e04a17 100644 --- a/src/views/tabledesign/index.jsx +++ b/src/views/tabledesign/index.jsx @@ -12,7 +12,7 @@ import Utils from '@/utils/utils.js' import { langs } from '@/store/options' import MKEmitter from '@/utils/events.js' -import { getTables, getFuncsAndInters, getLangTrans, getAllSqls } from '@/utils/utils-custom.js' +import { getTables, getFuncsAndInters, getOutMessage, getLangTrans, getAllSqls } from '@/utils/utils-custom.js' import SourceElement from '@/templates/zshare/dragsource' import asyncComponent from '@/utils/asyncComponent' import Source from './source' @@ -569,7 +569,6 @@ } let long_data = '' - delete config.allSqls if (window.backend && config.enabled) { let sqls = getAllSqls(config) let _t = moment().format('YYYYMMDDHHmmss') @@ -582,9 +581,21 @@ } long_data = [] + let oriIds = {} + if (config.allSqls) { + config.allSqls.forEach(item => { + if (!item.md5) return + oriIds[item.uuid + item.md5] = item.v_id + }) + } config.allSqls = sqls.map(item => { let v_id = _t + getguid() + + if (oriIds[item.uuid + item.md5]) { + v_id = oriIds[item.uuid + item.md5] + } + long_data.push(`${md5(window.GLOB.appkey + v_id)},${item.uuid},${v_id},${window.btoa(window.encodeURIComponent(item.LText))}`) return { @@ -592,11 +603,14 @@ v_id: v_id, type: item.type, reps: item.reps, - sql: item.LText + md5: item.md5 || '', + luser: item.luser === true } }) long_data = long_data.join(';') + } else { + delete config.allSqls } let tbs = [] @@ -633,6 +647,7 @@ } let interfaces = getFuncsAndInters(config) + let msg = getOutMessage(config) let urlFields = config.urlFields ? config.urlFields.join(',') : '' let langSql = getLangTrans(config) @@ -646,7 +661,7 @@ EasyCode: config.easyCode || '', Template: 'BaseTable', MenuName: config.MenuName || '', - PageParam: JSON.stringify({Template: 'BaseTable', OpenType: config.OpenType || 'newtab', hidden: config.hidden || 'false', menuColor: config.menuColor || '', interfaces, urlFields}), + PageParam: JSON.stringify({Template: 'BaseTable', OpenType: config.OpenType || 'newtab', hidden: config.hidden || 'false', menuColor: config.menuColor || '', interfaces, msg, urlFields}), open_edition: config.open_edition, long_data: long_data, debug_md5: key, -- Gitblit v1.8.0