From 145c4b6ec2ea4f1dd7986b3179ca505a79bc0598 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期二, 18 八月 2020 17:47:44 +0800 Subject: [PATCH] 2020-08-18 --- src/tabviews/treepage/index.jsx | 11 src/tabviews/zshare/mutilform/index.jsx | 296 +++++++++++++++++----- src/tabviews/formtab/index.jsx | 13 src/api/index.js | 16 - src/tabviews/zshare/topSearch/index.jsx | 353 ++++++++++++++++++-------- src/tabviews/zshare/actionList/normalbutton/index.jsx | 2 src/utils/option.js | 4 src/utils/utils.js | 2 src/tabviews/calendar/index.jsx | 42 +-- src/tabviews/zshare/actionList/printbutton/index.jsx | 2 10 files changed, 508 insertions(+), 233 deletions(-) diff --git a/src/api/index.js b/src/api/index.js index e87c871..d3ebe24 100644 --- a/src/api/index.js +++ b/src/api/index.js @@ -631,22 +631,12 @@ * @param {Object} param 璇锋眰鍙傛暟 * @param {Boolean} SSO 鏄惁涓哄崟鐐圭櫥褰曞湴鍧� */ - getSystemCacheConfig (param, SSO = true) { - param.userid = sessionStorage.getItem('UserID') || '' + getSystemCacheConfig (param) { + param.userid = param.userid || sessionStorage.getItem('UserID') || '' param.lang = localStorage.getItem('lang') || '' param.SessionUid = localStorage.getItem('SessionUid') || '' - param.LoginUID = sessionStorage.getItem('LoginUID') || '' + param.LoginUID = param.LoginUID || sessionStorage.getItem('LoginUID') || '' param.appkey = window.GLOB.appkey || '' - - if (sessionStorage.getItem('isEditState') === 'true' && SSO) { // 缂栬緫鐘舵�侊紝鍗曠偣鐧诲綍鏈嶅姟鍣ㄤ负浜戠 - if (options.cloudServiceApi) { // 瀛樺湪浜戠鍦板潃鏃讹紝浣跨敤浜戠绯荤粺鍙傛暟 - param.rduri = options.cloudServiceApi - param.userid = sessionStorage.getItem('CloudUserID') || '' - param.LoginUID = sessionStorage.getItem('CloudLoginUID') || '' - } - } else if (window.GLOB.mainSystemApi && SSO) { - param.rduri = window.GLOB.mainSystemApi - } let _param = JSON.parse(JSON.stringify(param)) // 缂撳瓨鏍¢獙锛屽幓闄ゆ椂闂村拰鍔犲瘑瀛楃 delete _param.timestamp diff --git a/src/tabviews/calendar/index.jsx b/src/tabviews/calendar/index.jsx index 6c7a7d7..f16d051 100644 --- a/src/tabviews/calendar/index.jsx +++ b/src/tabviews/calendar/index.jsx @@ -26,7 +26,7 @@ class NormalTable extends Component { static propTpyes = { - param: PropTypes.any, // 鍏朵粬椤甸潰浼犻�掔殑鎼滅储鏉′欢绛夊弬鏁� + param: PropTypes.any, // 鍏朵粬椤甸潰浼犻�掔殑鍙傛暟 MenuID: PropTypes.string, // 鑿滃崟Id MenuNo: PropTypes.string, // 鑿滃崟鍙傛暟 MenuName: PropTypes.string // 鑿滃崟鍚嶇О @@ -114,15 +114,27 @@ } } - // 瀛楁鏉冮檺榛戝悕鍗� + if (_curUserConfig) { + config.setting = {...config.setting, ..._curUserConfig.setting} + config.easyCode = _curUserConfig.easyCode || config.easyCode || '' + } + + // 瀛楁鏉冮檺榛戝悕鍗曘�佸繀濉�佸瓧娈甸�忚 + let valid = true config.search = config.search.map(item => { item.oriInitval = item.initval if (['text', 'select', 'link'].includes(item.type) && param) { if (param.searchkey === item.field) { item.initval = param.searchval - } else if (param.BID && item.field === 'BID') { + } else if (param.BID && item.field.toLowerCase() === 'bid') { item.initval = param.BID + } else if (param.data && param.data[item.field]) { + item.initval = param.data[item.field] } + } + + if (item.required === 'true' && !item.initval) { + valid = false } if (!item.blacklist || item.blacklist.length === 0) return item @@ -133,30 +145,6 @@ if (_black.length > 0) { item.Hide = 'true' - } - - return item - }) - - if (_curUserConfig) { - config.setting = {...config.setting, ..._curUserConfig.setting} - config.easyCode = _curUserConfig.easyCode || config.easyCode || '' - } - - // 閫忚瀛楁澶勭悊锛屽垵濮嬪寲澶勭悊 - let valid = true - config.search = config.search.map(item => { - item.oriInitval = item.initval - if (['text', 'select', 'link'].includes(item.type) && param) { - if (param.searchkey === item.field) { - item.initval = param.searchval - } else if (param.BID && item.field === 'BID') { - item.initval = param.BID - } - } - - if (item.required === 'true' && !item.initval) { - valid = false } return item diff --git a/src/tabviews/formtab/index.jsx b/src/tabviews/formtab/index.jsx index 02bba3c..f9daef9 100644 --- a/src/tabviews/formtab/index.jsx +++ b/src/tabviews/formtab/index.jsx @@ -197,7 +197,6 @@ if (item.resourceType === '1' && item.dataSource) { let _option = Utils.getSelectQueryOptions(item) let _sql = Utils.formatOptions(_option.sql) - let isSSO = item.database === 'sso' let param = { func: 'sPC_Get_SelectedList', @@ -218,12 +217,18 @@ if (this.props.menuType === 'HS') { // 浜戠鏁版嵁楠岃瘉 param.open_key = Utils.encrypt(param.secretkey, param.timestamp, true) - } else if (window.GLOB.systemType !== 'production') { - isSSO = false + + if (item.database === 'sso' && options.cloudServiceApi) { // 瀛樺湪浜戠鍦板潃鏃讹紝浣跨敤浜戠绯荤粺鍙傛暟 + param.rduri = options.cloudServiceApi + param.userid = sessionStorage.getItem('CloudUserID') || '' + param.LoginUID = sessionStorage.getItem('CloudLoginUID') || '' + } + } else if (item.database === 'sso' && window.GLOB.mainSystemApi && window.GLOB.systemType === 'production') { + param.rduri = window.GLOB.mainSystemApi } let defer = new Promise(resolve => { - Api.getSystemCacheConfig(param, isSSO).then(res => { + Api.getSystemCacheConfig(param).then(res => { res.search = item resolve(res) }) diff --git a/src/tabviews/treepage/index.jsx b/src/tabviews/treepage/index.jsx index 952f1cd..26e2454 100644 --- a/src/tabviews/treepage/index.jsx +++ b/src/tabviews/treepage/index.jsx @@ -27,6 +27,7 @@ class TreePage extends Component { static propTpyes = { + param: PropTypes.string, // 鍏朵粬椤甸潰浼犻�掔殑鍙傛暟 MenuID: PropTypes.string, // 鑿滃崟Id MenuNo: PropTypes.string, // 鑿滃崟鍙傛暟 MenuName: PropTypes.string // 鑿滃崟鍚嶇О @@ -36,6 +37,7 @@ dict: sessionStorage.getItem('lang') !== 'en-US' ? zhCN : enUS, ContainerId: Utils.getuuid(), // 鑿滃崟澶栧眰html Id loadingview: true, // 椤甸潰鍔犺浇涓� + BID: null, // 椤甸潰璺宠浆鏃舵惡甯D viewlost: false, // 椤甸潰涓㈠け锛�1銆佹湭鑾峰彇鍒伴厤缃�-椤甸潰涓㈠け锛�2銆侀〉闈㈡湭鍚敤 lostmsg: '', // 椤甸潰涓㈠け鏃剁殑鎻愮ず淇℃伅 config: {}, // 椤甸潰閰嶇疆淇℃伅锛屽寘鎷寜閽�佹悳绱€�佹樉绀哄垪銆佹爣绛剧瓑 @@ -62,7 +64,7 @@ * @description 鑾峰彇椤甸潰閰嶇疆淇℃伅 */ async loadconfig () { - const { permAction } = this.props + const { permAction, param } = this.props let _param = { func: 'sPC_Get_LongParam', @@ -140,6 +142,7 @@ }) this.setState({ + BID: param && param.BID ? param.BID : '', loadingview: false, config: config, tabActive: _tabActive, @@ -243,7 +246,7 @@ * @description 涓昏〃鏁版嵁鍔犺浇 */ async loadmaindata () { - const { setting, searchKey } = this.state + const { setting, searchKey, BID } = this.state let param = '' this.setState({ @@ -256,6 +259,10 @@ param = this.getDefaultParam() } + if (BID) { + param.BID = BID + } + // 鏁版嵁绠$悊鏉冮檺 if (this.props.dataManager) { param.dataM = 'Y' diff --git a/src/tabviews/zshare/actionList/normalbutton/index.jsx b/src/tabviews/zshare/actionList/normalbutton/index.jsx index 06de85c..dccda3a 100644 --- a/src/tabviews/zshare/actionList/normalbutton/index.jsx +++ b/src/tabviews/zshare/actionList/normalbutton/index.jsx @@ -847,6 +847,7 @@ } cell.data_sql = Utils.formatOptions(_option.sql) + cell.base_sql = window.btoa(window.encodeURIComponent(_option.sql)) cell.arr_field = _option.field } @@ -878,6 +879,7 @@ } cell.data_sql = Utils.formatOptions(_option.sql) + cell.base_sql = window.btoa(window.encodeURIComponent(_option.sql)) cell.arr_field = _option.field } diff --git a/src/tabviews/zshare/actionList/printbutton/index.jsx b/src/tabviews/zshare/actionList/printbutton/index.jsx index d2af58f..ac12a98 100644 --- a/src/tabviews/zshare/actionList/printbutton/index.jsx +++ b/src/tabviews/zshare/actionList/printbutton/index.jsx @@ -1065,6 +1065,7 @@ } cell.data_sql = Utils.formatOptions(_option.sql) + cell.base_sql = window.btoa(window.encodeURIComponent(_option.sql)) cell.arr_field = _option.field } @@ -1096,6 +1097,7 @@ } cell.data_sql = Utils.formatOptions(_option.sql) + cell.base_sql = window.btoa(window.encodeURIComponent(_option.sql)) cell.arr_field = _option.field } diff --git a/src/tabviews/zshare/mutilform/index.jsx b/src/tabviews/zshare/mutilform/index.jsx index e55e72c..08a4407 100644 --- a/src/tabviews/zshare/mutilform/index.jsx +++ b/src/tabviews/zshare/mutilform/index.jsx @@ -5,6 +5,7 @@ import moment from 'moment' import Api from '@/api' +import options from '@/store/options.js' import { formRule, calendarColors } from '@/utils/option.js' import Utils from '@/utils/utils.js' import FileUpload from '../fileupload' @@ -176,7 +177,7 @@ newval = newval.format('YYYY-MM-DD HH:mm:ss') === 'Invalid date' ? '' : newval } if (!newval && item.initval) { - newval = moment().subtract(item.initval, 'days') + newval = moment(moment().subtract(item.initval, 'days').format('YYYY-MM-DD') + ' 00:00:00', 'YYYY-MM-DD HH:mm:ss') } else if (!newval) { newval = null } @@ -268,110 +269,255 @@ * @description 鑾峰彇涓嬫媺琛ㄥ崟閫夐」淇℃伅 */ improveActionForm = () => { + const { BID, menuType } = this.props const { formlist } = this.state + + // 闇�瑕佸姩鎬佽幏鍙栦笅鎷夎彍鍗曠殑琛ㄥ崟 + let deForms = formlist.filter(item => ['select', 'link', 'multiselect'].includes(item.type) && item.resourceType === '1' && (item.type === 'link' || item.hidden !== 'true')) + + if (deForms.length === 0) { + return + } else if (menuType !== 'HS' && options.sysType === 'local' && !window.GLOB.systemType) { + this.improveSimpleActionForm(deForms) + return + } + let deffers = [] + let mainItems = [] // 浜戠鎴栧崟鐐规暟鎹� + let localItems = [] // 鏈湴鏁版嵁 - formlist.forEach(item => { - if ( - !['select', 'link', 'multiselect'].includes(item.type) || - item.resourceType !== '1' || - (item.type !== 'link' && item.hidden === 'true') - ) return - - let param = { - func: 'sPC_Get_SelectedList', - LText: item.data_sql, - obj_name: 'data', - arr_field: item.arr_field + deForms.forEach(item => { + if (item.database === 'sso') { + mainItems.push(`select '${item.field}' as obj_name,'${item.arr_field}' as arr_field,'${item.base_sql}' as LText`) + } else { + localItems.push(`select '${item.field}' as obj_name,'${item.arr_field}' as arr_field,'${item.base_sql}' as LText`) } - let isSSO = item.database === 'sso' + }) + + if (menuType !== 'HS' && window.GLOB.systemType !== 'production') { + localItems = [...localItems, ...mainItems] + mainItems = [] + } - if (this.props.BID) { - param.BID = this.props.BID - } + // 鏈湴璇锋眰 + let param = { + func: 'sPC_Get_SelectedList', + LText: localItems.join(' union all '), + obj_name: '', + arr_field: '', + table_type: 'Y' + } + if (BID) { + param.BID = BID + } + + if (param.LText) { + param.LText = Utils.formatOptions(param.LText) param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000' param.secretkey = Utils.encrypt(param.LText, param.timestamp) - if (this.props.menuType === 'HS') { // 浜戠鏁版嵁楠岃瘉 + if (menuType === 'HS') { // 浜戠鏁版嵁楠岃瘉 param.open_key = Utils.encrypt(param.secretkey, param.timestamp, true) - } else if (window.GLOB.systemType !== 'production') { - isSSO = false } deffers.push( new Promise(resolve => { - Api.getSystemCacheConfig(param, isSSO).then(res => { - res.$search = item + Api.getSystemCacheConfig(param).then(res => { + if (!res.status) { + notification.warning({ + top: 92, + message: res.message, + duration: 5 + }) + } resolve(res) }) }) - ) - }) + ) + } - if (deffers.length === 0) return + // 绯荤粺璇锋眰 + let mainparam = { + func: 'sPC_Get_SelectedList', + LText: mainItems.join(' union all '), + obj_name: '', + arr_field: '', + table_type: 'Y' + } - let _field = {} - let error = '' - Promise.all(deffers).then(result => { - result.forEach(res => { - if (res.status) { - let options = res.data.map(cell => { - let item = { - key: Utils.getuuid(), - Value: cell[res.$search.valueField], - Text: cell[res.$search.valueText] - } + if (BID) { + mainparam.BID = BID + } - if (res.$search.type === 'link') { - item.ParentID = cell[res.$search.linkField] - } else if (res.$search.type === 'select' && res.$search.linkSubField && res.$search.linkSubField.length > 0) { - res.$search.linkSubField.forEach(_field => { - item[_field] = (cell[_field] || cell[_field] === 0) ? cell[_field] : '' - }) - } + if (mainparam.LText) { + mainparam.LText = Utils.formatOptions(mainparam.LText) + mainparam.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000' + mainparam.secretkey = Utils.encrypt(mainparam.LText, mainparam.timestamp) - return item - }) - - _field[res.$search.uuid] = options - } else { - error = res + if (menuType === 'HS') { // 浜戠鏁版嵁楠岃瘉 + mainparam.open_key = Utils.encrypt(mainparam.secretkey, mainparam.timestamp, true) + if (options.cloudServiceApi) { + mainparam.rduri = options.cloudServiceApi + mainparam.userid = sessionStorage.getItem('CloudUserID') || '' + mainparam.LoginUID = sessionStorage.getItem('CloudLoginUID') || '' } - }) - - if (error) { - notification.warning({ - top: 92, - message: error.message, - duration: 5 - }) + } else if (window.GLOB.mainSystemApi) { + mainparam.rduri = window.GLOB.mainSystemApi } + deffers.push( + new Promise(resolve => { + Api.getSystemCacheConfig(mainparam).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 + let _formlist = formlist.map(item => { - if (item.type === 'select' || item.type === 'link' || item.type === 'multiselect') { - if (item.resourceType === '1' && _field.hasOwnProperty(item.uuid)) { - item.oriOptions = [...item.oriOptions, ..._field[item.uuid]] - } - } - return item - }) - - _formlist = _formlist.map(item => { - if (item.type === 'link') { - if (item.supInitVal) { - item.options = item.oriOptions.filter(option => option.ParentID === item.supInitVal) - } else { - item.options = item.oriOptions - } - } else if (item.type === 'select' || item.type === 'multiselect') { - item.options = item.oriOptions + if (['select', 'link', 'multiselect'].includes(item.type) && result[item.field] && result[item.field].length > 0) { + let options = result[item.field].map(cell => { + let _cell = { + key: Utils.getuuid(), + Value: cell[item.valueField], + Text: cell[item.valueText] + } + + if (item.type === 'link') { + _cell.ParentID = cell[item.linkField] + } else if (item.type === 'select' && item.linkSubField && item.linkSubField.length > 0) { + item.linkSubField.forEach(_field => { + _cell[_field] = (cell[_field] || cell[_field] === 0) ? cell[_field] : '' + }) + } + + return _cell + }) + + item.oriOptions = [...item.oriOptions, ...options] } return item }) this.setState({ - formlist: _formlist + formlist: _formlist.map(item => { + if (item.type === 'link') { + if (item.supInitVal) { + item.options = item.oriOptions.filter(option => option.ParentID === item.supInitVal) + } else { + item.options = item.oriOptions + } + } else if (item.type === 'select' || item.type === 'multiselect') { + item.options = item.oriOptions + } + return item + }) + }) + }) + } + + /** + * @description 娴嬭瘯绯荤粺鑾峰彇涓嬫媺琛ㄥ崟閫夐」淇℃伅 + */ + improveSimpleActionForm = (deForms) => { + const { formlist } = this.state + + let deffers = deForms.map(form => { + let param = { + func: 'sPC_Get_SelectedList', + LText: form.data_sql, + obj_name: form.field, + arr_field: form.arr_field + } + + if (this.props.BID) { + param.BID = this.props.BID + } + + param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000' + param.secretkey = Utils.encrypt(param.LText, param.timestamp) + + return ( + new Promise(resolve => { + Api.getSystemCacheConfig(param).then(res => { + if (!res.status) { + notification.warning({ + top: 92, + message: res.message, + duration: 5 + }) + } + resolve(res) + }) + }) + ) + }) + + Promise.all(deffers).then(response => { + let result = {} + response.forEach(res => { + result = {...result, ...res} + }) + + delete result.ErrCode + delete result.ErrMesg + delete result.message + delete result.status + + let _formlist = formlist.map(item => { + if (['select', 'link', 'multiselect'].includes(item.type) && result[item.field] && result[item.field].length > 0) { + let options = result[item.field].map(cell => { + let _cell = { + key: Utils.getuuid(), + Value: cell[item.valueField], + Text: cell[item.valueText] + } + + if (item.type === 'link') { + _cell.ParentID = cell[item.linkField] + } else if (item.type === 'select' && item.linkSubField && item.linkSubField.length > 0) { + item.linkSubField.forEach(_field => { + _cell[_field] = (cell[_field] || cell[_field] === 0) ? cell[_field] : '' + }) + } + + return _cell + }) + + item.oriOptions = [...item.oriOptions, ...options] + } + return item + }) + + this.setState({ + formlist: _formlist.map(item => { + if (item.type === 'link') { + if (item.supInitVal) { + item.options = item.oriOptions.filter(option => option.ParentID === item.supInitVal) + } else { + item.options = item.oriOptions + } + } else if (item.type === 'select' || item.type === 'multiselect') { + item.options = item.oriOptions + } + return item + }) }) }) } diff --git a/src/tabviews/zshare/topSearch/index.jsx b/src/tabviews/zshare/topSearch/index.jsx index ab365b4..a809ad3 100644 --- a/src/tabviews/zshare/topSearch/index.jsx +++ b/src/tabviews/zshare/topSearch/index.jsx @@ -5,6 +5,7 @@ import moment from 'moment' import Api from '@/api' +import options from '@/store/options.js' import DateGroup from '@/tabviews/zshare/dategroup' import Utils from '@/utils/utils.js' import './index.scss' @@ -38,6 +39,9 @@ let required = {} let _list = [] let fieldMap = new Map() + let mainItems = [] // 浜戠鎴栧崟鐐规暟鎹� + let localItems = [] // 鏈湴鏁版嵁 + let deForms = [] // 娴嬭瘯绯荤粺锛屽崟涓姹� searchlist.forEach(item => { if (fieldMap.has(item.field)) { @@ -50,13 +54,40 @@ style[item.field] = item.type required[item.field] = item.required === 'true' - if (item.type === 'select' || item.type === 'link') { - if (item.setAll === 'true') { + if (['select', 'link', 'multiselect'].includes(item.type)) { + if (item.setAll === 'true' && item.type !== 'multiselect') { item.options.unshift({ key: Utils.getuuid(), Value: '', Text: this.props.dict['main.all'] }) + } + + // 鏁版嵁婧愭煡璇㈣鍙� + if (item.resourceType === '1' && item.dataSource) { + let _option = Utils.getSelectQueryOptions(item) + + if (this.props.dataManager) { // 鏁版嵁鏉冮檺 + _option.sql = _option.sql.replace(/\$@/ig, '/*') + _option.sql = _option.sql.replace(/@\$/ig, '*/') + } else { + _option.sql = _option.sql.replace(/@\$|\$@/ig, '') + } + + // 娴嬭瘯绯荤粺鍗曚釜璇锋眰 + if (this.props.menuType !== 'HS' && options.sysType === 'local' && !window.GLOB.systemType) { + deForms.push({ + ...item, + arr_field: _option.field, + data_sql: Utils.formatOptions(_option.sql) + }) + } else { // 鍚堝苟璇锋眰锛屽尯鍒嗘湰鍦板強绯荤粺 + if (item.database === 'sso') { + mainItems.push(`select '${item.field}' as obj_name,'${_option.field}' as arr_field,'${window.btoa(window.encodeURIComponent(_option.sql))}' as LText`) + } else { + localItems.push(`select '${item.field}' as obj_name,'${_option.field}' as arr_field,'${window.btoa(window.encodeURIComponent(_option.sql))}' as LText`) + } + } } item.oriOptions = fromJS(item.options).toJS() } @@ -75,7 +106,9 @@ message: '鏈煡璇㈠埌鎼滅储鏉′欢銆�' + item.label + '銆嬪叧鑱斿瓧娈碉紒', duration: 5 }) + item.supInitVal = '' } else { + item.supInitVal = supItem.initval item.options = item.oriOptions.filter(option => option.ParentID === supItem.initval) } } else if (item.type === 'group' && item.Hide !== 'true') { @@ -93,135 +126,237 @@ searchlist: _list, groups: _groups }, () => { - this.improveSearch() + if (this.props.menuType !== 'HS' && options.sysType === 'local' && !window.GLOB.systemType) { + this.improveSimpleSearch(deForms) + } else { + this.improveSearch(mainItems, localItems) + } }) } - improveSearch = () => { - let searchlist = fromJS(this.props.searchlist).toJS() + // 鏌ヨ涓嬫媺鑿滃崟 + improveSearch = (mainItems, localItems) => { + const { menuType, BID } = this.props let deffers = [] - searchlist.forEach(item => { - if (item.type !== 'multiselect' && item.type !== 'select' && item.type !== 'link') return - if (item.setAll === 'true') { - item.options.unshift({ - key: Utils.getuuid(), - Value: '', - Text: this.props.dict['main.all'] - }) + if (menuType !== 'HS' && window.GLOB.systemType !== 'production') { + localItems = [...localItems, ...mainItems] + mainItems = [] + } + + // 鏈湴璇锋眰 + let param = { + func: 'sPC_Get_SelectedList', + LText: localItems.join(' union all '), + obj_name: '', + arr_field: '', + table_type: 'Y' + } + + if (BID) { + param.BID = BID + } + + if (param.LText) { + param.LText = Utils.formatOptions(param.LText) + param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000' + param.secretkey = Utils.encrypt(param.LText, param.timestamp) + + if (menuType === 'HS') { // 浜戠鏁版嵁楠岃瘉 + param.open_key = Utils.encrypt(param.secretkey, param.timestamp, true) } - if (item.resourceType === '1' && item.dataSource) { - let _option = Utils.getSelectQueryOptions(item) - let _sql = Utils.formatOptions(_option.sql) - let isSSO = item.database === 'sso' - - let param = { - func: 'sPC_Get_SelectedList', - LText: _sql, - obj_name: 'data', - arr_field: _option.field - } - - if (this.props.BID) { - param.BID = this.props.BID - } - - if (this.props.dataManager) { // 鏁版嵁鏉冮檺 - param.LText = param.LText.replace(/\$@/ig, '/*') - param.LText = param.LText.replace(/@\$/ig, '*/') - } else { - param.LText = param.LText.replace(/@\$|\$@/ig, '') - } - - param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000' - param.secretkey = Utils.encrypt(param.LText, param.timestamp) - - if (this.props.menuType === 'HS') { // 浜戠鏁版嵁楠岃瘉 - param.open_key = Utils.encrypt(param.secretkey, param.timestamp, true) - } else if (window.GLOB.systemType !== 'production') { - isSSO = false - } - - let defer = new Promise(resolve => { - Api.getSystemCacheConfig(param, isSSO).then(res => { - res.search = item + deffers.push( + new Promise(resolve => { + Api.getSystemCacheConfig(param).then(res => { + if (!res.status) { + notification.warning({ + top: 92, + message: res.message, + duration: 5 + }) + } resolve(res) }) }) - deffers.push(defer) - } else if (item.resourceType === '1' && !item.dataSource) { - notification.warning({ - top: 92, - message: item.label + ': ' + this.props.dict['main.datasource.settingerror'], - duration: 5 - }) - } - }) - - if (deffers.length === 0) { - return + ) } - Promise.all(deffers).then(result => { - result.forEach(res => { - if (res.status) { - searchlist = searchlist.map(item => { - if (item.uuid === res.search.uuid) { - res.data.forEach(cell => { - let _item = { - key: Utils.getuuid(), - Value: cell[res.search.valueField], - Text: cell[res.search.valueText] - } + // 绯荤粺璇锋眰 + let mainparam = { + func: 'sPC_Get_SelectedList', + LText: mainItems.join(' union all '), + obj_name: '', + arr_field: '', + table_type: 'Y' + } - if (res.search.type === 'link') { - _item.ParentID = cell[res.search.linkField] - } + if (BID) { + mainparam.BID = BID + } - item.options.push(_item) + if (mainparam.LText) { + mainparam.LText = Utils.formatOptions(mainparam.LText) + mainparam.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000' + mainparam.secretkey = Utils.encrypt(mainparam.LText, mainparam.timestamp) + + if (menuType === 'HS') { // 浜戠鏁版嵁楠岃瘉 + mainparam.open_key = Utils.encrypt(mainparam.secretkey, mainparam.timestamp, true) + if (options.cloudServiceApi) { + mainparam.rduri = options.cloudServiceApi + mainparam.userid = sessionStorage.getItem('CloudUserID') || '' + mainparam.LoginUID = sessionStorage.getItem('CloudLoginUID') || '' + } + } else if (window.GLOB.mainSystemApi) { + mainparam.rduri = window.GLOB.mainSystemApi + } + + deffers.push( + new Promise(resolve => { + Api.getSystemCacheConfig(mainparam).then(res => { + if (!res.status) { + notification.warning({ + top: 92, + message: res.message, + duration: 5 }) } - return item + resolve(res) }) - } else { - notification.warning({ - top: 92, - message: res.search.label + ':' + res.message, - duration: 5 + }) + ) + } + + Promise.all(deffers).then(response => { + let result = {...response[0], ...(response[1] || {})} + + delete result.ErrCode + delete result.ErrMesg + delete result.message + delete result.status + + let _searchlist = this.state.searchlist.map(item => { + if (['select', 'link', 'multiselect'].includes(item.type) && result[item.field] && result[item.field].length > 0) { + let options = result[item.field].map(cell => { + let _item = { + key: Utils.getuuid(), + Value: cell[item.valueField], + Text: cell[item.valueText] + } + + if (item.type === 'link') { + _item.ParentID = cell[item.linkField] + } + + return _item }) + + item.oriOptions = [...item.oriOptions, ...options] } - }) - - let _list = [] - let fieldMap = new Map() - - searchlist.forEach(item => { - if (fieldMap.has(item.field)) { - item.field = item.field + '@tail@' - } - fieldMap.set(item.field, true) - - if (item.type === 'select' || item.type === 'link') { - item.oriOptions = fromJS(item.options).toJS() - } - - _list.push(item) - }) - - _list = _list.map(item => { - if (item.type === 'link') { - let supItem = _list.filter(form => form.field === item.linkField)[0] - - if (supItem) { - item.options = item.oriOptions.filter(option => option.ParentID === supItem.initval) - } - } - return item }) - this.setState({searchlist: _list}) + this.setState({ + searchlist: _searchlist.map(item => { + if (item.type === 'link') { + if (item.supInitVal) { + item.options = item.oriOptions.filter(option => option.ParentID === item.supInitVal) + } else { + item.options = item.oriOptions + } + } else if (item.type === 'select' || item.type === 'multiselect') { + item.options = item.oriOptions + } + + return item + }) + }) + }) + } + + // 娴嬭瘯绯荤粺鍗曚釜璇锋眰涓嬫媺閫夐」 + improveSimpleSearch = (deForms) => { + if (deForms.length === 0) return + + let deffers = deForms.map(item => { + let param = { + func: 'sPC_Get_SelectedList', + LText: item.data_sql, + obj_name: item.field, + arr_field: item.arr_field + } + + if (this.props.BID) { + param.BID = this.props.BID + } + + param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000' + param.secretkey = Utils.encrypt(param.LText, param.timestamp) + + return ( + new Promise(resolve => { + Api.getSystemCacheConfig(param).then(res => { + if (!res.status) { + notification.warning({ + top: 92, + message: res.message, + duration: 5 + }) + } + resolve(res) + }) + }) + ) + }) + + Promise.all(deffers).then(response => { + let result = {} + + response.forEach(res => { + result = {...result, ...res} + }) + + delete result.ErrCode + delete result.ErrMesg + delete result.message + delete result.status + + let _searchlist = this.state.searchlist.map(item => { + if (['select', 'link', 'multiselect'].includes(item.type) && result[item.field] && result[item.field].length > 0) { + let options = result[item.field].map(cell => { + let _item = { + key: Utils.getuuid(), + Value: cell[item.valueField], + Text: cell[item.valueText] + } + + if (item.type === 'link') { + _item.ParentID = cell[item.linkField] + } + + return _item + }) + + item.oriOptions = [...item.oriOptions, ...options] + } + return item + }) + + this.setState({ + searchlist: _searchlist.map(item => { + if (item.type === 'link') { + if (item.supInitVal) { + item.options = item.oriOptions.filter(option => option.ParentID === item.supInitVal) + } else { + item.options = item.oriOptions + } + } else if (item.type === 'select' || item.type === 'multiselect') { + item.options = item.oriOptions + } + + return item + }) + }) }) } diff --git a/src/utils/option.js b/src/utils/option.js index 812fba4..d267be0 100644 --- a/src/utils/option.js +++ b/src/utils/option.js @@ -90,7 +90,7 @@ export const dateOptions = { date: [ {value: '', text: _dict['model.empty']}, - {value: '0', text: '褰撳ぉ'}, + {value: '0', text: '浠婂ぉ'}, {value: 1, text: '鏄ㄥぉ'}, {value: 2, text: '鍓嶅ぉ'}, {value: 3, text: '鍓嶄笁澶�'}, @@ -130,7 +130,7 @@ ], datetime: [ {value: '', text: _dict['model.empty']}, - {value: '0', text: '鐜板湪'}, + {value: '0', text: '浠婂ぉ'}, {value: 1, text: '鏄ㄥぉ'}, {value: 3, text: '鍓嶄笁澶�'}, {value: 7, text: '鍓嶄竷澶�'}, diff --git a/src/utils/utils.js b/src/utils/utils.js index e033b10..ed6c47e 100644 --- a/src/utils/utils.js +++ b/src/utils/utils.js @@ -689,7 +689,7 @@ arrfield = arrfield.join(',') if (item.orderBy) { - sql = 'select distinct ' + arrfield + ',' + item.orderBy + ' as orderfield from ' + _datasource + ' order by orderfield ' + item.orderType + sql = `select ${arrfield} from (select distinct ${arrfield},${item.orderBy} as orderfield from ${_datasource} ) a order by orderfield ${item.orderType}` } else { sql = 'select distinct ' + arrfield + ' from ' + _datasource } -- Gitblit v1.8.0