From cb52ff0fd9fdf3ebfbde2314539998f3fedd9854 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期二, 10 九月 2024 10:16:46 +0800 Subject: [PATCH] Merge branch 'develop' --- src/utils/utils-datamanage.js | 259 ++- src/tabviews/zshare/actionList/funcbutton/index.jsx | 79 + src/tabviews/custom/components/editor/braft-editor/index.jsx | 40 src/tabviews/zshare/actionList/popupbutton/index.jsx | 6 src/utils/utils-custom.js | 950 +++++++++-- src/views/main/index.jsx | 4 src/templates/sharecomponent/actioncomponent/verifypay/customscript/index.jsx | 2 src/views/mkiframe/index.jsx | 8 src/tabviews/zshare/actionList/excelInbutton/index.jsx | 615 ++++++-- src/tabviews/custom/popview/index.jsx | 31 src/tabviews/basetable/index.jsx | 28 src/tabviews/custom/components/module/invoice/index.jsx | 13 src/tabviews/zshare/actionList/newpagebutton/index.jsx | 133 + src/views/billprint/index.jsx | 36 src/views/design/sidemenu/index.jsx | 4 src/tabviews/zshare/actionList/normalbutton/index.jsx | 649 ++++++++ src/views/mobdesign/index.jsx | 51 src/views/menudesign/index.jsx | 59 src/menu/components/module/invoice/verifycard/customscript/index.jsx | 2 src/templates/zshare/pasteform/index.jsx | 4 src/tabviews/custom/components/table/edit-table/normalTable/index.jsx | 212 ++ 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/templates/sharecomponent/searchcomponent/searchform/index.jsx | 2 src/components/tabview/index.jsx | 14 src/templates/sharecomponent/actioncomponent/verifyexcelout/customscript/index.jsx | 2 src/components/header/index.jsx | 6 src/tabviews/zshare/topSearch/index.jsx | 210 ++ src/tabviews/zshare/actionList/exceloutbutton/index.jsx | 22 src/views/rolemanage/index.jsx | 7 src/views/design/sidemenu/index.scss | 9 src/views/tabledesign/index.jsx | 59 src/api/index.js | 93 + src/menu/components/module/invoice/verifycard/callbackcustomscript/index.jsx | 2 src/utils/utils.js | 151 ++ src/index.js | 2 src/tabviews/zshare/actionList/tabbutton/index.jsx | 12 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/tabviews/zshare/actionList/printbutton/index.jsx | 68 src/menu/components/editor/braft-editor/index.jsx | 3 src/menu/components/table/edit-table/columns/tableIn/customscript/index.jsx | 2 src/components/sidemenu/index.jsx | 6 src/templates/zshare/verifycard/baseform/index.jsx | 2 src/components/pasteboard/index.jsx | 4 49 files changed, 3,657 insertions(+), 811 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/header/index.jsx b/src/components/header/index.jsx index c8b66d5..eea9bda 100644 --- a/src/components/header/index.jsx +++ b/src/components/header/index.jsx @@ -559,9 +559,9 @@ MKEmitter.emit('modifyTabs', menu) } - if (window.GLOB.systemType === 'production') { - MKEmitter.emit('queryTrigger', {menuId: menu.MenuID, name: '鑿滃崟'}) - } + // if (window.GLOB.systemType === 'production') { + // MKEmitter.emit('queryTrigger', {menuId: menu.MenuID, name: '鑿滃崟'}) + // } } } 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/sidemenu/index.jsx b/src/components/sidemenu/index.jsx index 263d66f..1889c7f 100644 --- a/src/components/sidemenu/index.jsx +++ b/src/components/sidemenu/index.jsx @@ -79,9 +79,9 @@ MKEmitter.emit('modifyTabs', menu) } - if (window.GLOB.systemType === 'production') { - MKEmitter.emit('queryTrigger', {menuId: menu.MenuID, name: '鑿滃崟'}) - } + // if (window.GLOB.systemType === 'production') { + // MKEmitter.emit('queryTrigger', {menuId: menu.MenuID, name: '鑿滃崟'}) + // } } onOpenChange = openKeys => { 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 8c25e14..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) { @@ -346,6 +347,7 @@ } if (config.systemRun === 'backend') { + GLOB.debugger = false Object.defineProperty(window, 'backend', { writable: false, value: true 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 3ef6c7c..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' @@ -174,19 +175,20 @@ window.GLOB.CacheData.set(MenuID, urlparam) - // if (window.backend && config.allSqls) { - // let keys = Object.keys(urlparam) - // config.allSqls.forEach(item => { - // if (item.type === 'datasource') { - // 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) - // }) - // } + 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') || '' 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 c8d24bc..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' @@ -143,9 +144,9 @@ this.refs.excelIn.exceltrigger() }) - if (window.GLOB.systemType === 'production') { - MKEmitter.emit('queryTrigger', {menuId: btn.uuid, name: '瀵煎叆Excel'}) - } + // if (window.GLOB.systemType === 'production') { + // MKEmitter.emit('queryTrigger', {menuId: btn.uuid, name: '瀵煎叆Excel'}) + // } } } @@ -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 2a87051..6cc49b6 100644 --- a/src/tabviews/zshare/actionList/exceloutbutton/index.jsx +++ b/src/tabviews/zshare/actionList/exceloutbutton/index.jsx @@ -107,9 +107,9 @@ }) } else { MKEmitter.emit('queryModuleParam', btn.$menuId, this.triggerExcelout) - if (window.GLOB.systemType === 'production') { - MKEmitter.emit('queryTrigger', {menuId: btn.uuid, name: '瀵煎嚭Excel'}) - } + // if (window.GLOB.systemType === 'production') { + // MKEmitter.emit('queryTrigger', {menuId: btn.uuid, name: '瀵煎嚭Excel'}) + // } } } @@ -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 943d8a9..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' @@ -158,10 +159,10 @@ lang = data[0].lang_s || '' } - let _name = '鏂伴〉闈�' + // let _name = '鏂伴〉闈�' if (btn.pageTemplate === 'billprint') { - _name = '鍗曟嵁鎵撳嵃' + // _name = '鍗曟嵁鎵撳嵃' if (btn.preHandle === 'true' && btn.pre_func) { MKEmitter.emit('queryModuleParam', btn.$menuId, (res) => { let searches = {} @@ -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') { @@ -239,7 +273,7 @@ let src = '#/print/' + window.btoa(window.encodeURIComponent(JSON.stringify({ ID: Id, lang }))) window.open(src) } else if (btn.pageTemplate === 'pay') { - _name = '鏀粯' + // _name = '鏀粯' let appId = '' let merchId = '' @@ -338,9 +372,9 @@ window.open(url) } - if (window.GLOB.systemType === 'production') { - MKEmitter.emit('queryTrigger', {menuId: btn.uuid, name: _name}) - } + // if (window.GLOB.systemType === 'production') { + // MKEmitter.emit('queryTrigger', {menuId: btn.uuid, name: _name}) + // } } prequest = (ID, data, appId, merchId) => { @@ -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 47e76c9..7eb4679 100644 --- a/src/tabviews/zshare/actionList/normalbutton/index.jsx +++ b/src/tabviews/zshare/actionList/normalbutton/index.jsx @@ -307,16 +307,16 @@ } } - if (window.GLOB.systemType === 'production') { - let _change = { - prompt: '鎻愮ず妗�', - exec: '鐩存帴鎵ц', - pop: '寮圭獥锛堣〃鍗曪級', - formSubmit: '琛ㄥ崟', - form: '琛ㄥ崟', - } - MKEmitter.emit('queryTrigger', {menuId: btn.uuid, name: _change[btn.OpenType]}) - } + // if (window.GLOB.systemType === 'production') { + // let _change = { + // prompt: '鎻愮ず妗�', + // exec: '鐩存帴鎵ц', + // pop: '寮圭獥锛堣〃鍗曪級', + // formSubmit: '琛ㄥ崟', + // form: '琛ㄥ崟', + // } + // MKEmitter.emit('queryTrigger', {menuId: btn.uuid, name: _change[btn.OpenType]}) + // } } preTrigger = (callback) => { @@ -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/popupbutton/index.jsx b/src/tabviews/zshare/actionList/popupbutton/index.jsx index c6a9e99..68f3828 100644 --- a/src/tabviews/zshare/actionList/popupbutton/index.jsx +++ b/src/tabviews/zshare/actionList/popupbutton/index.jsx @@ -184,9 +184,9 @@ visible: true }) - if (window.GLOB.systemType === 'production') { - MKEmitter.emit('queryTrigger', {menuId: btn.uuid, name: '寮圭獥锛堟爣绛撅級'}) - } + // if (window.GLOB.systemType === 'production') { + // MKEmitter.emit('queryTrigger', {menuId: btn.uuid, name: '寮圭獥锛堟爣绛撅級'}) + // } } syspopclose = () => { diff --git a/src/tabviews/zshare/actionList/printbutton/index.jsx b/src/tabviews/zshare/actionList/printbutton/index.jsx index e106de1..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' @@ -204,9 +205,9 @@ this.triggerPrint(data) } - if (window.GLOB.systemType === 'production') { - MKEmitter.emit('queryTrigger', {menuId: btn.uuid, name: '鏍囩鎵撳嵃'}) - } + // if (window.GLOB.systemType === 'production') { + // MKEmitter.emit('queryTrigger', {menuId: btn.uuid, name: '鏍囩鎵撳嵃'}) + // } } triggerPrint = (data, formlist = []) => { @@ -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/actionList/tabbutton/index.jsx b/src/tabviews/zshare/actionList/tabbutton/index.jsx index 94322e0..0dbb778 100644 --- a/src/tabviews/zshare/actionList/tabbutton/index.jsx +++ b/src/tabviews/zshare/actionList/tabbutton/index.jsx @@ -213,9 +213,9 @@ MKEmitter.emit('openNewTab') } - if (window.GLOB.systemType === 'production') { - MKEmitter.emit('queryTrigger', {menuId: btn.uuid, name: '鏍囩椤�'}) - } + // if (window.GLOB.systemType === 'production') { + // MKEmitter.emit('queryTrigger', {menuId: btn.uuid, name: '鏍囩椤�'}) + // } } triggerMenu = (tab) => { @@ -300,9 +300,9 @@ MKEmitter.emit('openNewTab') } - if (window.GLOB.systemType === 'production') { - MKEmitter.emit('queryTrigger', {menuId: btn.uuid, name: '鏍囩椤�'}) - } + // if (window.GLOB.systemType === 'production') { + // MKEmitter.emit('queryTrigger', {menuId: btn.uuid, name: '鏍囩椤�'}) + // } } render() { 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/sharecomponent/searchcomponent/searchform/index.jsx b/src/templates/sharecomponent/searchcomponent/searchform/index.jsx index f093777..c2871bb 100644 --- a/src/templates/sharecomponent/searchcomponent/searchform/index.jsx +++ b/src/templates/sharecomponent/searchcomponent/searchform/index.jsx @@ -283,7 +283,7 @@ } else if (type === 'dateweek' || type === 'daterange' || type === 'range') { reOptions.match = matchReg.class5 } else if (type === 'checkcard') { - if (this.record.multiple === 'false') { + if (this.record.multiple === 'false' || this.record.multiple === 'dropdown') { reOptions.match = matchReg.class1 } else if (this.record.multiple === 'true') { reOptions.match = matchReg.class3 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 6556d9f..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) { @@ -1985,10 +2094,18 @@ let _quot = sql.match(/'{1}/g) let _lparen = sql.match(/\({1}/g) let _rparen = sql.match(/\){1}/g) + let _ch_b = sql.match(/\$check@/ig) + let _ch_d = sql.match(/@check\$/ig) + let _m_b = sql.match(/\$@/ig) + let _m_d = sql.match(/@\$/ig) _quot = _quot ? _quot.length : 0 _lparen = _lparen ? _lparen.length : 0 _rparen = _rparen ? _rparen.length : 0 + _ch_b = _ch_b ? _ch_b.length : 0 + _ch_d = _ch_d ? _ch_d.length : 0 + _m_b = _m_b ? _m_b.length : 0 + _m_d = _m_d ? _m_d.length : 0 if (_quot % 2 !== 0) { notification.warning({ @@ -2001,6 +2118,20 @@ notification.warning({ top: 92, message: 'sql涓�()蹇呴』鎴愬鍑虹幇', + duration: 5 + }) + return false + } else if (_ch_b !== _ch_d) { + notification.warning({ + top: 92, + message: 'sql涓� $check@ 涓� @check$ 蹇呴』鎴愬鍑虹幇', + duration: 5 + }) + return false + } else if (_m_b !== _m_d) { + notification.warning({ + top: 92, + message: 'sql涓� $@ 涓� @$ 蹇呴』鎴愬鍑虹幇', duration: 5 }) return false @@ -2862,13 +2993,39 @@ 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 || '') + label + '-' + (item.name || '') + if (item.type === 'tabs') { item.subtabs.forEach(tab => { let _mainSearch = mainSearch || [] @@ -2880,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') { @@ -2897,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}) } @@ -2913,6 +3070,7 @@ item.setting.laypage = 'false' item.setting.$top = true } + item.setting.$name = item.$menuname || '' let msg = getDataSource(item, mainSearch) @@ -2947,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') { @@ -2970,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}) @@ -3015,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 || [] @@ -3049,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') { @@ -3074,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}) } @@ -3082,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') { @@ -3128,14 +3292,13 @@ }) } - filterComponent(cell.config.components, _mainSearch) + filterComponent(cell.config.components, _mainSearch, '-' + cell.label) } } } let getSearches = (searches) => { let sFields = [] - let query = false searches.forEach(item => { if (!item.field) return @@ -3177,13 +3340,9 @@ } else { sFields.push(item.field) } - - if (query) return - - query = item.query !== 'false' }) - return { sFields, query } + return sFields } let getSysDefaultSql = (btn, component) => { @@ -3962,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'] @@ -4030,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)) { @@ -4048,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 => { @@ -4072,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) => { @@ -4261,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)) { @@ -4305,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 => { @@ -4334,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 || [] @@ -4347,7 +4613,7 @@ searches = [...searches, ...mainSearch] } item.$searches = fromJS(searches).toJS() - let { sFields, query } = getSearches(searches) + let sFields = getSearches(searches) let _columns = [] if (item.subtype === 'dualdatacard') { @@ -4374,8 +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@ + // ` + // } + + let _search = '' if (item.setting.execute !== 'false') { _dataresource = item.setting.dataresource || '' + _search = '@mk_search@' + } + + if (type === 'print') { + _search = '' } if (/\s/.test(_dataresource)) { @@ -4384,21 +4664,13 @@ item.setting.dataresource = _dataresource item.setting.customScript = _customScript - - let _search = '@search@' - if (item.setting.queryType === 'statistics' || !query) { - _search = '' - } let testSql = _dataresource + _customScript + _tailScript let decSql = [`@ErrorCode nvarchar(50),@retmsg nvarchar(4000)`] - let secSql = [`@ErrorCode='',@retmsg =''`] + let secSql = [`@ErrorCode='S',@retmsg =''`] let reps = [] - if (_customScript || _tailScript) { - reps.push('UserID', 'time_id') - } let syses = ['UserName', 'FullName', 'RoleID', 'mk_departmentcode', 'mk_organization', 'mk_user_type', 'mk_nation', 'mk_province', 'mk_city', 'mk_district', 'mk_address'] syses.forEach(s => { @@ -4415,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') @@ -4446,134 +4718,130 @@ let LText = '' let DateCount = '' if (_dataresource) { + /*system_query*/ if (/@pageSize@|@orderBy@|@mk_total/i.test(testSql)) { - LText = `/*system_query*/select ${arr_field} from ${_dataresource} ${_search} ` + LText = `select ${arr_field} from ${_dataresource} ${_search} ` } else if (item.setting.laypage === 'true' && item.setting.order) { - LText = `/*system_query*/select top @pageSize@ ${arr_field} from (select ${arr_field} ,ROW_NUMBER() over(order by @orderBy@) as rows from ${_dataresource} ${_search}) tmptable where rows > @pageSize@ * (@pageIndex@ - 1) order by tmptable.rows ` + LText = `select top @pageSize@ ${arr_field} from (select ${arr_field} ,ROW_NUMBER() over(order by @orderBy@) as rows from ${_dataresource} ${_search}) tmptable where rows > @pageSize@ * (@pageIndex@ - 1) order by tmptable.rows ` reps.push('pageSize', 'orderBy', 'pageIndex') if (item.subtype === 'dualdatacard') { - DateCount = `/*system_query*/select count(1) as total from (select distinct ${item.setting.primaryKey || 'ID'} from ${_dataresource} ${_search})a` + DateCount = `select count(1) as total from (select distinct ${item.setting.primaryKey || 'ID'} from ${_dataresource} ${_search})a` } else { - DateCount = `/*system_query*/select count(1) as total from ${_dataresource} ${_search}` + DateCount = `select count(1) as total from ${_dataresource} ${_search}` } } else if (item.setting.$top) { if (item.setting.order) { - LText = `/*system_query*/select top 1 ${arr_field} from ${_dataresource} ${_search} order by @orderBy@ ` + LText = `select top 1 ${arr_field} from ${_dataresource} ${_search} order by @orderBy@ ` reps.push('orderBy') } else { - LText = `/*system_query*/select top 1 ${arr_field} from ${_dataresource} ${_search} ` + 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 = `/*system_query*/select ${arr_field} from ${_dataresource} ${_search} order by @orderBy@ ` + LText = `select ${arr_field} from ${_dataresource} ${_search} order by @orderBy@ ` reps.push('orderBy') } else { - LText = `/*system_query*/select ${arr_field} from ${_dataresource} ${_search} ` + LText = `select ${arr_field} from ${_dataresource} ${_search} ` } } - if (_customScript) { - _customScript = `${decSql} - ${_customScript} + let sub_name = '' + let tabid = '' + let parid = '' + let sub_field = '' + + if (item.subtype === 'dualdatacard') { + arr_field = item.columns.map(col => col.field).join(',') + sub_name = item.setting.subdata + tabid = item.setting.primaryKey || '' + parid = item.setting.subBID || '' + sub_field = item.subColumns.map(col => col.field).join(',') + } + + // 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}' ` - if (DateCount) { - DateCount = `${DateCount} - ${_tailScript} - aaa: - if @ErrorCode!='' - insert into tmp_err_retmsg (ID, ErrorCode, retmsg, CreateUserID) select @time_id@,@ErrorCode,@retmsg,@UserID@ - ` - } else if (LText) { - LText = `${LText} - ${_tailScript} - aaa: - if @ErrorCode!='' - insert into tmp_err_retmsg (ID, ErrorCode, retmsg, CreateUserID) select @time_id@,@ErrorCode,@retmsg,@UserID@ - ` - } else { - _customScript = `${_customScript} - ${_tailScript} - aaa: - if @ErrorCode!='' - insert into tmp_err_retmsg (ID, ErrorCode, retmsg, CreateUserID) select @time_id@,@ErrorCode, @retmsg,@UserID@ - ` - } - } else if (_tailScript && DateCount) { - LText = `${decSql} - ${LText} - ` - DateCount = `${DateCount} - ${_tailScript} - aaa: - if @ErrorCode!='' - insert into tmp_err_retmsg (ID, ErrorCode, retmsg, CreateUserID) select @time_id@,@ErrorCode, @retmsg,@UserID@ - ` - } else if (_tailScript) { - LText = `${decSql} - ${LText} - ${_tailScript} - aaa: - if @ErrorCode!='' - insert into tmp_err_retmsg (ID, ErrorCode, retmsg, CreateUserID) select @time_id@,@ErrorCode, @retmsg,@UserID@ + + _tailScript += `${_tailScript} + select @ErrorCode as ErrorCode,@retmsg as retmsg + ${callback} ` } else { - LText = `${decSql} - ${LText} + 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 ` } - reps = Array.from(new Set(reps)) + if (DateCount) { + sql += `UNION ALL + SELECT obj_name='DateCount',prm_field='total',str_field='', + 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} + ${LText} + ${DateCount} + ${_tailScript} + ` - // LText = LText.replace(/\n\s{6,8}/g, '\n') - // DateCount = DateCount.replace(/\n\s{6,8}/g, '\n') - // _customScript = _customScript.replace(/\n\s{6,8}/g, '\n') - // LText = LText.replace(/\n\s+\/\*/g, `\n/*`) - // DateCount = DateCount.replace(/\n\s+\/\*/g, `\n/*`) - // _customScript = _customScript.replace(/\n\s+\/\*/g, `\n/*`) + 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 - LText = LText.replace(new RegExp('@' + n + '@', 'ig'), `'@${n}@'`) - DateCount = DateCount.replace(new RegExp('@' + n + '@', 'ig'), `'@${n}@'`) - _customScript = _customScript.replace(new RegExp('@' + n + '@', 'ig'), `'@${n}@'`) + sql = sql.replace(new RegExp('@' + n + '@', 'ig'), `'@${n}@'`) }) - if (/\$@/ig.test(testSql)) { - LText = LText.replace(/\$@/ig, '@datam_begin@').replace(/@\$/ig, '@datam_end@') - DateCount = DateCount.replace(/\$@/ig, '@datam_begin@').replace(/@\$/ig, '@datam_end@') - _customScript = _customScript.replace(/\$@/ig, '@datam_begin@').replace(/@\$/ig, '@datam_end@') + if (/\$@/ig.test(sql)) { + sql = sql.replace(/\$@/ig, '@datam_begin@').replace(/@\$/ig, '@datam_end@') reps.push('datam_begin', 'datam_end') } - if (/@db@/ig.test(testSql)) { + if (/@db@/ig.test(sql)) { reps.push('db') } + reps.push('mk_obj_name') - // let sql = '' - // let sub_name = '' - // let tabid = '' - // let parid = '' - // let sub_field = '' + sql = sql.replace(/\n\x20{6,8}/g, '\n').replace(/\n{3,}/g, '\n\n').replace(/^\s+|\s+$/g, '').replace(/\t+|\v+/g, '') - // if (item.subtype === 'dualdatacard') { - // arr_field = item.columns.map(col => col.field).join(',') - // sub_name = item.setting.subdata - // tabid = item.setting.primaryKey || '' - // parid = item.setting.subBID || '' - // sub_field = item.subColumns.map(col => col.field).join(',') - // } + reps = reps.filter(n => { + if (sysVars.includes(n.toLowerCase())) { + return false + } - // sql += ` - // SELECT obj_name='data',prm_field='',str_field='', - // arr_field='${arr_field}',tabid='${tabid}',parid='${parid}',sub_name='${sub_name}',sub_field='${sub_field}' - // ` + return true + }) - // if (DateCount) { - // sql += `UNION ALL - // SELECT obj_name='DateCount',prm_field='total',str_field='', - // arr_field='',tabid='',parid='',sub_name='',sub_field='' - // ` - // } - - return {LText, DateCount, customScript: _customScript, reps} + return {LText: sql, md5: md5(sql), reps, luser: /@userid@/ig.test(testSql)} } let getExcelInSql = (item) => { @@ -4721,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) @@ -4735,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') { @@ -4766,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}@'`) }) @@ -4779,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 = [] @@ -4808,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)) { @@ -4816,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) => { @@ -4998,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) @@ -5015,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 = [] @@ -5042,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)) { @@ -5050,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@') @@ -5065,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) => { @@ -5088,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' @@ -5100,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' @@ -5109,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 @@ -5132,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 = [] @@ -5157,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)) { @@ -5192,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@') @@ -5208,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') { @@ -5275,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}@'`) @@ -5302,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) => { @@ -5321,19 +5805,19 @@ item.dataSource = '(' + item.dataSource + ') tb' } - let sql = '' + let LText = '' let DateCount = '' let _search = '' let reps = [] let sFields = [] if (item.searchKey) { - _search = '@search@' + _search = '@mk_search@' sFields = item.searchKey.split(',') } // 涓嶉渶瑕佸崟寮曞彿锛歰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)) { @@ -5341,22 +5825,12 @@ } }) - if (item.laypage === 'true') { - sql = `/*system_query*/select top @pageSize@ ${arrfield} from (select ${arrfield} ,ROW_NUMBER() over(order by @orderBy@) as rows from ${item.dataSource} ${_search}) tmptable where rows > @pageSize@ * (@pageIndex@ - 1) order by tmptable.rows ` - DateCount = `/*system_query*/select count(1) as total from ${item.dataSource} ${_search}` - - reps.push('pageSize', 'orderBy', 'pageIndex') - } else { - sql = `/*system_query*/select ${arrfield} from ${item.dataSource} ${_search} order by @orderBy@ ` - reps.push('orderBy') - } - let decSql = [] let secSql = [] let syses = ['mk_departmentcode', 'mk_organization', 'mk_user_type'] syses.forEach(s => { - if (new RegExp('@' + s + '[^0-9a-z_]', 'ig').test(sql)) { + if (new RegExp('@' + s + '[^0-9a-z_]', 'ig').test(item.dataSource)) { if (['mk_departmentcode', 'mk_organization'].includes(s)) { decSql.push(`@${s} nvarchar(512)`) } else { @@ -5369,29 +5843,74 @@ decSql = decSql.join(',') secSql = secSql.join(',') + decSql = decSql ? `Declare ${decSql} select ${secSql}` : '' - if (decSql) { - sql = `Declare ${decSql} select ${secSql} - ${sql} + if (item.laypage === 'true') { + /*system_query*/ + LText = `select top @pageSize@ ${arrfield} from (select ${arrfield} ,ROW_NUMBER() over(order by @orderBy@) as rows from ${item.dataSource} ${_search}) tmptable where rows > @pageSize@ * (@pageIndex@ - 1) order by tmptable.rows ` + DateCount = `select count(1) as total from ${item.dataSource} ${_search}` + + reps.push('pageSize', 'orderBy', 'pageIndex') + } else { + LText = `select ${arrfield} from ${item.dataSource} ${_search} order by @orderBy@ ` + reps.push('orderBy') + } + + let sql = `SELECT obj_name='data',prm_field='',str_field='', + arr_field='${arrfield}',tabid='',parid='',sub_name='',sub_field='' + ` + + if (DateCount) { + sql += `UNION ALL + SELECT obj_name='DateCount',prm_field='total',str_field='', + arr_field='',tabid='',parid='',sub_name='',sub_field='' ` } + + sql += ` + ${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 sql = sql.replace(new RegExp('@' + n + '@', 'ig'), `'@${n}@'`) - DateCount = DateCount.replace(new RegExp('@' + n + '@', 'ig'), `'@${n}@'`) }) if (/\$@/ig.test(sql)) { sql = sql.replace(/\$@/ig, '@datam_begin@').replace(/@\$/ig, '@datam_end@') - DateCount = DateCount.replace(/\$@/ig, '@datam_begin@').replace(/@\$/ig, '@datam_end@') reps.push('datam_begin', 'datam_end') } if (/@db@/ig.test(sql)) { reps.push('db') } - - return {LText: sql, DateCount, 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 + }) + + return {LText: sql, md5: md5(sql), reps} } let _mainSearch = [] @@ -5432,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}) } @@ -5457,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 4e96051..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,17 +140,23 @@ let param = null if (setting.interType === 'system') { - param = this.getDefaultQueryParam(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 @@ -289,72 +422,6 @@ param.menuname = setting.$name } - // if (window.backend && window.GLOB.CacheData.has('sql_' + setting.uuid)) { - // let item = window.GLOB.CacheData.get('sql_' + setting.uuid) - - // let values = { - // userid: sessionStorage.getItem('UserID') || '', - // time_id: Utils.getguid(), - // username: userName, - // fullname: fullName, - // roleid: RoleID, - // mk_departmentcode: departmentcode, - // mk_organization: organization, - // mk_user_type: mk_user_type, - // mk_nation: nation, - // mk_province: province, - // mk_city: city, - // mk_district: district, - // mk_address: 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' ? '/*' : '', - // datam_end: sessionStorage.getItem('dataM') === 'true' ? '*/' : '', - // } - - // 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 Ltext = item.LText - // let DateCount = item.DateCount - // let customScript = item.customScript - - // item.reps.forEach(n => { - // let key = n.toLowerCase() - // if (values.hasOwnProperty(key)) { - // Ltext = Ltext.replace(new RegExp('@' + key + '@', 'ig'), values[key]) - // DateCount = DateCount.replace(new RegExp('@' + key + '@', 'ig'), values[key]) - // customScript = customScript.replace(new RegExp('@' + key + '@', 'ig'), values[key]) - // } - // }) - - // if (search.length) { - - // } - // } - param.custom_script = Utils.formatOptions(_customScript, param.exec_type) param.LText = Utils.formatOptions(LText, param.exec_type) param.DateCount = Utils.formatOptions(DateCount, param.exec_type) @@ -563,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 @@ -621,7 +692,7 @@ return { uuid: uuid, - name: dataName, + dataName: dataName, $name: setting.$name, columns: columns, par_tablename: '', @@ -638,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 @@ -677,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 ac418a1..48c79b6 100644 --- a/src/utils/utils.js +++ b/src/utils/utils.js @@ -712,6 +712,157 @@ return searchText.join(' AND ') } + 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 + + let cell = { + key: item.key, + match: item.match, + type: 'text', + value: item.value + } + + if (item.type === 'text' || item.type === 'select') { // 缁煎悎鎼滅储锛屾枃鏈垨涓嬫媺锛屾墍鏈夊瓧娈垫嫾鎺� + if (/,/.test(item.key)) { + cell.type = 'text_or' + } + } else if (item.type === 'multi') { + cell.type = 'text_multi' + } else if (item.type === 'date') { + let _val = item.value + let timetail = '' + + if (item.match === '<' || item.match === '<=') { // 鏃堕棿涓�<=鏃讹紝鍖归厤鍚庝竴澶╃殑0鐐癸紝鍖归厤鏂瑰紡涓�< + cell.match = '<' + if (item.precision === 'day') { + _val = moment(_val, 'YYYY-MM-DD').add(1, 'days').format('YYYY-MM-DD') + } + } + if (item.match === '=') { + timetail = '' + } else if (item.precision === 'day') { + timetail = ' 00:00:00.000' + } else if (item.precision === 'hour') { + timetail = ':00:00.000' + } else if (item.precision === 'minute') { + timetail = ':00.000' + } else if (item.precision === 'second') { + timetail = '.000' + } + + cell.value = _val + timetail + } + + if (item.type === 'datemonth') { // 鏈�-杩囨护鏉′欢锛屼粠鏈堝紑濮嬭嚦缁撴潫锛岀粨鏉熸椂闂翠负鏈堟湯鍔犱竴澶╃殑0鐐癸紝鏂瑰紡涓�< + if (item.match === '=') { + searchText.push(cell) + } else { + let _startval = moment(item.value, 'YYYY-MM').startOf('month').format('YYYY-MM-DD') + ' 00:00:00.000' + let _endval = moment(item.value, 'YYYY-MM').endOf('month').add(1, 'days').format('YYYY-MM-DD') + ' 00:00:00.000' + + searchText.push({ + key: item.key, + match: '>=', + type: 'text', + value: _startval + }, { + key: item.key, + match: '<', + type: 'text', + value: _endval + }) + } + } else if (item.type === 'dateweek') { // 鍛�-杩囨护鏉′欢 + let _startval = moment(item.value, 'YYYY-MM-DD' ).startOf('week').format('YYYY-MM-DD') + ' 00:00:00.000' + let _endval = moment(item.value, 'YYYY-MM-DD').endOf('week').add(1, 'days').format('YYYY-MM-DD') + ' 00:00:00.000' + + searchText.push({ + key: item.key, + match: '>=', + type: 'text', + value: _startval + }, { + key: item.key, + match: '<', + type: 'text', + value: _endval + }) + } else if (item.type === 'daterange') { + let val = item.value.split(',') + let _startval = '' + let _endval = '' + + if (item.precision === 'day') { + _startval = val[0] + ' 00:00:00.000' + _endval = moment(val[1], 'YYYY-MM-DD').add(1, 'days').format('YYYY-MM-DD') + ' 00:00:00.000' + } else if (item.precision === 'hour') { + _startval = val[0] + ':00:00.000' + _endval = val[1] + ':00:00.000' + } else if (item.precision === 'minute') { + _startval = val[0] + ':00.000' + _endval = val[1] + ':00.000' + } else if (item.precision === 'second') { + _startval = val[0] + '.000' + _endval = val[1] + '.000' + } + + let _skey = item.key + let _ekey = item.key + + if (/,/.test(item.key)) { + _skey = item.key.split(',')[0] + _ekey = item.key.split(',')[1] + } + + searchText.push({ + key: _skey, + match: '>=', + type: 'text', + value: _startval + }, { + key: _ekey, + match: '<', + type: 'text', + value: _endval + }) + } else if (item.type === 'range') { + let val = item.value.split(',') + + searchText.push({ + key: item.key, + match: '>=', + type: 'text', + value: val[0] || -999999999 + }, { + key: item.key, + match: '<=', + type: 'text', + value: val[1] || 999999999 + }) + } else { + searchText.push(cell) + } + }) + + searchText.forEach(item => { + item.match = matchs[item.match] || '01' + }) + + return searchText + } + /** * @description 鑾峰彇鎼滅储鐢ㄤ簬姝e垯鏇挎崲 * @param {Array} searches 鎼滅储鏉′欢 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/main/index.jsx b/src/views/main/index.jsx index 8723ebc..cf36bd0 100644 --- a/src/views/main/index.jsx +++ b/src/views/main/index.jsx @@ -4,7 +4,7 @@ import Header from '@/components/header' import MKEmitter from '@/utils/events.js' import Sidemenu from '@/components/sidemenu' -import QueryLog from '@/components/querylog' +// import QueryLog from '@/components/querylog' import ImgScale from '@/components/imgScale' // import './index.scss' @@ -78,7 +78,7 @@ {navBar === 'shutter' || navBar === 'menu_board_navigation' ? <Tabview key="tabview"/> : <Breadview key="breadview"/>} - {window.GLOB.systemType === 'production' ? <QueryLog /> : null} + {/* {window.GLOB.systemType === 'production' ? <QueryLog /> : null} */} <ImgScale /> </div> ) diff --git a/src/views/menudesign/index.jsx b/src/views/menudesign/index.jsx index 494b40e..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 } 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' @@ -780,7 +780,7 @@ } else if (this.checklog()) { if (sessionStorage.getItem('langList') && !config.trans) { - // } else if (window.backend && config.enabled && !config.allSqls) { + } else if (window.backend && config.enabled && !config.allSqls) { } else { notification.success({ @@ -808,13 +808,50 @@ delete config.force } - // let sqls = [] - // delete config.allSqls - // if (window.backend && config.enabled) { - // sqls = getAllSqls(config) + 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 + } - // config.allSqls = sqls - // } + 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) @@ -862,6 +899,7 @@ } let interfaces = getFuncsAndInters(config) + let msg = getOutMessage(config) let urlFields = config.urlFields ? config.urlFields.join(',') : '' let langSql = getLangTrans(config) @@ -875,10 +913,9 @@ 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, - // LText: '', - // LTexttb: '', + long_data: long_data, debug_md5: key, debug_url: url, debug_list: window.btoa(tbs), 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 8b998c2..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 } 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' @@ -540,7 +540,7 @@ } else if (this.checklog()) { if (sessionStorage.getItem('langList') && !config.trans) { - // } else if (window.backend && config.enabled && !config.allSqls) { + } else if (window.backend && config.enabled && !config.allSqls) { } else { notification.success({ @@ -568,13 +568,50 @@ delete config.force } - // let sqls = [] - // delete config.allSqls - // if (window.backend && config.enabled) { - // sqls = getAllSqls(config) + 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 + } - // config.allSqls = sqls - // } + 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 + } let tbs = [] let btns = this.getMenuMessage(tbs) @@ -610,6 +647,7 @@ } let interfaces = getFuncsAndInters(config) + let msg = getOutMessage(config) let urlFields = config.urlFields ? config.urlFields.join(',') : '' let langSql = getLangTrans(config) @@ -623,10 +661,9 @@ 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, - // LText: '', - // LTexttb: '', + long_data: long_data, debug_md5: key, debug_url: url, debug_list: window.btoa(tbs), -- Gitblit v1.8.0