From 4cc738e535d1a20701d206e12cf9de8cc5a01170 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期六, 01 六月 2024 15:24:12 +0800 Subject: [PATCH] Merge branch 'develop' --- src/tabviews/custom/index.jsx | 337 ++++++++++++++++++++++++++++--------------------------- 1 files changed, 172 insertions(+), 165 deletions(-) diff --git a/src/tabviews/custom/index.jsx b/src/tabviews/custom/index.jsx index b56749d..9d8a16c 100644 --- a/src/tabviews/custom/index.jsx +++ b/src/tabviews/custom/index.jsx @@ -204,6 +204,7 @@ // 鏉冮檺杩囨护 let roleId = sessionStorage.getItem('role_id') || '' // 瑙掕壊ID let balMap = new Map() + let tbMap = new Map() let skip = config.permission === 'false' || window.GLOB.mkHS let urlparam = {} // url鍙傛暟 if (param) { @@ -261,7 +262,7 @@ let initInters = [] config.interfaces = this.formatInterSetting(config.interfaces, regs, MenuID, initInters, config.MenuName) - config.components = this.filterComponent(config.components, roleId, window.GLOB.mkActions, balMap, skip, urlparam, MenuID, config.interfaces, config.$cache, config.$time, config.MenuName, MenuID, MenuID, config.process === 'true') + config.components = this.filterComponent(config.components, roleId, window.GLOB.mkActions, balMap, tbMap, skip, urlparam, MenuID, config.$cache, config.$time, config.MenuName, MenuID, MenuID, config.process === 'true', regs) let params = [] let BID = urlparam.$BID || '' @@ -284,11 +285,7 @@ } }) - config.components = this.formatSetting(config.components, params, inherit, regs, balMap) - - if (balMap.size > 0) { - config.components = this.filterBalcony(config.components, balMap) - } + config.components = this.formatSetting(config.components, params, inherit, config.interfaces, balMap, tbMap) if (initInters.length > 0) { this.stepInter = { @@ -380,7 +377,7 @@ } } - filterComponent = (components, roleId, permAction, balMap, skip, urlparam, pageId, interfaces, cache, time, MenuName, searchId, syncId, process) => { + filterComponent = (components, roleId, permAction, balMap, tbMap, skip, urlparam, pageId, cache, time, MenuName, searchId, syncId, process, regs) => { return components.filter(item => { item.$pageId = pageId item.$searchId = searchId @@ -497,7 +494,7 @@ _searchId = tab.uuid } - tab.components = this.filterComponent(tab.components, roleId, permAction, balMap, skip, urlparam, pageId, interfaces, cache, time, MenuName, _searchId, tab.uuid, process) + tab.components = this.filterComponent(tab.components, roleId, permAction, balMap, tbMap, skip, urlparam, pageId, cache, time, MenuName, _searchId, tab.uuid, process, regs) if (_searchId === tab.uuid) { tab.components.forEach(cell => { @@ -521,7 +518,7 @@ return false } - item.components = this.filterComponent(item.components, roleId, permAction, balMap, skip, urlparam, pageId, interfaces, cache, time, MenuName, searchId, syncId, process) + item.components = this.filterComponent(item.components, roleId, permAction, balMap, tbMap, skip, urlparam, pageId, cache, time, MenuName, searchId, syncId, process, regs) return true } else if (['pie', 'bar', 'line', 'dashboard', 'scatter', 'chart', 'antvG6', 'antvX6'].includes(item.type)) { @@ -537,16 +534,6 @@ item.wrap.blacklist.filter(v => roleId.indexOf(v) > -1).length > 0 ) { return false - } - - if (item.wrap.datatype === 'public') { - let inter = interfaces.filter(int => item.wrap.publicId === int.uuid)[0] - if (!inter) { - item.wrap.datatype = 'static' - } else { - item.setting = {...inter.setting} - item.$searchId = inter.$searchId - } } } @@ -785,6 +772,9 @@ item.wrap.supModule = item.wrap.supModule.pop() item.setting.supModule = item.wrap.supModule } + if (item.wrap.datatype === 'public') { + balMap.set(item.wrap.publicId + 'public', true) + } item.elements = item.elements.filter(cell => { if (cell.eleType === 'button') { if (cell.hidden === 'true') return false @@ -843,43 +833,91 @@ item.wrap.supModule = '' } } + + // 鏁寸悊鏁版嵁婧� + if (item.setting && item.format && (!item.wrap || !['public', 'static'].includes(item.wrap.datatype))) { + item.setting.arr_field = item.columns ? item.columns.map(col => col.field).join(',') : '' + item.setting.useMSearch = item.setting.useMSearch === 'true' + item.setting.laypage = item.setting.laypage === 'true' // 鏄惁鍒嗛〉锛岃浆涓篵oolean 缁熶竴鏍煎紡 + + if (item.wrap && item.wrap.goback === 'true') { + item.setting.sync = 'false' + } + + if (item.format === 'object') { + item.setting.laypage = false + item.setting.$top = true + } + + if (item.setting.interType !== 'system') { // 涓嶄娇鐢ㄧ郴缁熷嚱鏁版椂 + item.setting.sync = 'false' + item.setting.dataresource = '' + } else { + let _customScript = '' + let _tailScript = '' + item.scripts && item.scripts.forEach(script => { + if (script.status === 'false') return + if (script.position !== 'back') { + _customScript += ` + ${script.sql} + ` + } else { + _tailScript += ` + ${script.sql} + ` + } + }) + delete item.scripts + item.setting.$name = item.$menuname || '' + item.setting.execute = item.setting.execute !== 'false' // 榛樿sql鏄惁鎵ц锛岃浆涓篵oolean 缁熶竴鏍煎紡 + + if (!item.setting.execute) { + item.setting.dataresource = '' + } + if (/\s/.test(item.setting.dataresource)) { + item.setting.dataresource = '(' + item.setting.dataresource + ') tb' + } - return true - }) - } + if (sessionStorage.getItem('dataM') === 'true') { // 鏁版嵁鏉冮檺 + item.setting.dataresource = item.setting.dataresource.replace(/\$@/ig, '/*').replace(/@\$/ig, '*/').replace(/@datam@/ig, '\'Y\'') + _customScript = _customScript.replace(/\$@/ig, '/*').replace(/@\$/ig, '*/').replace(/@datam@/ig, '\'Y\'') + _tailScript = _tailScript.replace(/\$@/ig, '/*').replace(/@\$/ig, '*/').replace(/@datam@/ig, '\'Y\'') + } else { + item.setting.dataresource = item.setting.dataresource.replace(/@\$|\$@/ig, '').replace(/@datam@/ig, '\'\'') + _customScript = _customScript.replace(/@\$|\$@/ig, '').replace(/@datam@/ig, '\'\'') + _tailScript = _tailScript.replace(/@\$|\$@/ig, '').replace(/@datam@/ig, '\'\'') + } - filterBalcony = (components, balMap) => { - return components.filter(item => { - if (item.type === 'tabs') { - item.subtabs = item.subtabs.map(tab => { - tab.components = this.filterBalcony(tab.components, balMap) - return tab - }) - } else if (item.type === 'group') { - item.components = this.filterBalcony(item.components, balMap) - } + regs.forEach(cell => { + item.setting.dataresource = item.setting.dataresource.replace(cell.reg, cell.value) + _customScript = _customScript.replace(cell.reg, cell.value) + _tailScript = _tailScript.replace(cell.reg, cell.value) + }) - if (item.type === 'balcony' && item.wrap.linkType === 'sync') { - let conf = balMap.get(item.wrap.syncModuleId) + item.setting.customScript = _customScript // 鏁寸悊鍚庤嚜瀹氫箟鑴氭湰 + item.setting.tailScript = _tailScript // 鍚庣疆鑷畾涔夎剼鏈� - if (!conf || conf === true) { - return false - } - - item.syncConfig = { - uuid: conf.uuid, - wrap: conf.wrap, - setting: conf.setting, - columns: conf.columns - } + item.setting.custompage = /@pageSize@|@orderBy@/i.test(item.setting.dataresource + item.setting.customScript) - if (item.wrap.checkAll === 'show') { - if (conf.subtype === 'datacard' && conf.wrap.cardType !== 'checkbox') { - item.wrap.checkAll = 'hidden' - } else if (conf.subtype === 'normaltable' && conf.wrap.tableType !== 'checkbox') { - item.wrap.checkAll = 'hidden' + if (!item.setting.execute || item.setting.custompage) { + item.forbidLine = true + } + + if (item.setting.sync === 'true') { + // pageable 鏄惁鍒嗛〉锛岀粍浠跺睘鎬э紝涓嶅垎椤电殑缁勪欢鎵嶅彲浠ョ粺涓�鏌ヨ + if ((!item.pageable || (item.pageable && !item.setting.laypage)) && item.setting.onload === 'true') { + + } else { + item.setting.sync = 'false' + } } } + } + + if (item.type === 'card' && item.subtype === 'datacard') { + tbMap.set(item.uuid, item) + } else if (item.type === 'table' && item.subtype !== 'editable') { + tbMap.set(item.uuid, item) } return true @@ -931,39 +969,45 @@ cell.modal.uuid = cell.uuid + 'pop' } - if (cell.verify && cell.verify.invalid === 'true') { - if (item.wrap && (item.wrap.datatype === 'static' || item.wrap.datatype === 'public')) { - cell.verify.invalid = 'false' - } else if (item.setting && item.setting.maxScript && item.setting.maxScript >= 300) { - cell.verify.invalid = 'false' - } else if (cell.intertype !== 'system' && cell.procMode !== 'system') { - cell.verify.invalid = 'false' - } else if (cell.sqlType === 'insert') { - cell.verify.invalid = 'false' - } else if (cell.Ot === 'notRequired') { - cell.verify.invalid = 'false' - } - } - - if (cell.verify && cell.verify.preHandle === 'true') { - let script = cell.verify.pre_func - if (!/#position-/.test(script) || /#position-init/.test(script)) { - try { - // eslint-disable-next-line - let func = new Function('btn', 'position', 'systemType', script) - func(cell, 'init', window.GLOB.systemType) - } catch (e) { - console.warn(e) + if (cell.verify) { + if (cell.verify.invalid === 'true') { + if (item.wrap && (item.wrap.datatype === 'static' || item.wrap.datatype === 'public')) { + cell.verify.invalid = 'false' + } else if (item.setting && item.setting.maxScript && item.setting.maxScript >= 300) { + cell.verify.invalid = 'false' + } else if (cell.intertype !== 'system' && cell.procMode !== 'system') { + cell.verify.invalid = 'false' + } else if (cell.sqlType === 'insert') { + cell.verify.invalid = 'false' + } else if (cell.Ot === 'notRequired') { + cell.verify.invalid = 'false' } } - if (/#position-inner/.test(script)) { - cell.$innerScript = script + + if (cell.verify.linkEnable === 'true' && /@/.test(cell.verify.linkUrl)) { + cell.returnValue = 'true' } - if (/#position-outer/.test(script)) { - cell.$outerScript = script - } - if (/#position-callback/.test(script)) { - cell.$callbackScript = script + + if (cell.verify.preHandle === 'true') { + let script = cell.verify.pre_func + if (!/#position-/.test(script) || /#position-init/.test(script)) { + try { + // eslint-disable-next-line + let func = new Function('btn', 'position', 'systemType', script) + func(cell, 'init', window.GLOB.systemType) + } catch (e) { + console.warn(e) + } + } + if (/#position-inner/.test(script)) { + cell.$innerScript = script + } + if (/#position-outer/.test(script)) { + cell.$outerScript = script + } + if (/#position-callback/.test(script)) { + cell.$callbackScript = script + } } } @@ -1083,20 +1127,64 @@ } // 鏍煎紡鍖栭粯璁よ缃� - formatSetting = (components, params, inherit, regs, balMap) => { + formatSetting = (components, params, inherit, interfaces, balMap, tbMap) => { 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, regs, balMap) + tab.components = this.formatSetting(tab.components, null, inherit, interfaces, balMap, tbMap) tab = {...tab, ...inherit} return tab }) return component } else if (component.type === 'group') { - component.components = this.formatSetting(component.components, params, null, regs, balMap) + component.components = this.formatSetting(component.components, params, null, interfaces, balMap, tbMap) return component - } else if (component.wrap && component.wrap.datatype === 'public') { + } + + if (component.type === 'balcony') { + if (component.wrap.linkType === 'sync') { + let conf = tbMap.get(component.wrap.syncModuleId) + + if (conf) { + component.syncConfig = { + uuid: conf.uuid, + wrap: conf.wrap, + setting: conf.setting, + columns: conf.columns + } + + if (component.wrap.checkAll === 'show') { + if (conf.subtype === 'datacard' && conf.wrap.cardType !== 'checkbox') { + component.wrap.checkAll = 'hidden' + } else if (conf.subtype === 'normaltable' && conf.wrap.tableType !== 'checkbox') { + component.wrap.checkAll = 'hidden' + } + } + } + } + } else if (balMap.has(component.uuid)) { + component.setting.$hasSyncModule = true + } + if (balMap.has(component.uuid + 'public')) { + component.$hasTopModule = true + } + + if (component.wrap && component.wrap.datatype === 'public') { + if (tbMap.has(component.wrap.publicId)) { + let tb = tbMap.get(component.wrap.publicId) + component.setting = {...tb.setting} + component.$searchId = tb.$searchId + component.wrap.publicId = component.wrap.publicId + 'tb' + } else { + let inter = interfaces.filter(int => component.wrap.publicId === int.uuid)[0] + if (!inter) { + component.wrap.datatype = 'static' + } else { + component.setting = {...inter.setting} + component.$searchId = inter.$searchId + } + } return component } else if (component.wrap && component.wrap.datatype === 'static') { component.format = '' @@ -1109,10 +1197,6 @@ return component } - component.setting.arr_field = component.columns ? component.columns.map(col => col.field).join(',') : '' - component.setting.useMSearch = component.setting.useMSearch === 'true' - component.setting.laypage = component.setting.laypage === 'true' // 鏄惁鍒嗛〉锛岃浆涓篵oolean 缁熶竴鏍煎紡 - if (component.setting.useMSearch) { if (!window.GLOB.SearchBox.has(component.$searchId)) { component.setting.useMSearch = false @@ -1127,79 +1211,7 @@ } } - if (component.wrap && component.wrap.goback === 'true') { - component.setting.sync = 'false' - } - - if (component.format === 'object') { - component.setting.laypage = false - component.setting.$top = true - } - - if (component.setting.interType !== 'system') { // 涓嶄娇鐢ㄧ郴缁熷嚱鏁版椂 - component.setting.sync = 'false' - component.setting.dataresource = '' - return component - } - - let _customScript = '' - let _tailScript = '' - component.scripts && component.scripts.forEach(script => { - if (script.status === 'false') return - if (script.position !== 'back') { - _customScript += ` - ${script.sql} - ` - } else { - _tailScript += ` - ${script.sql} - ` - } - }) - delete component.scripts - component.setting.$name = component.$menuname || '' - component.setting.execute = component.setting.execute !== 'false' // 榛樿sql鏄惁鎵ц锛岃浆涓篵oolean 缁熶竴鏍煎紡 - - if (!component.setting.execute) { - component.setting.dataresource = '' - } - if (/\s/.test(component.setting.dataresource)) { - component.setting.dataresource = '(' + component.setting.dataresource + ') tb' - } - - if (sessionStorage.getItem('dataM') === 'true') { // 鏁版嵁鏉冮檺 - component.setting.dataresource = component.setting.dataresource.replace(/\$@/ig, '/*').replace(/@\$/ig, '*/').replace(/@datam@/ig, '\'Y\'') - _customScript = _customScript.replace(/\$@/ig, '/*').replace(/@\$/ig, '*/').replace(/@datam@/ig, '\'Y\'') - _tailScript = _tailScript.replace(/\$@/ig, '/*').replace(/@\$/ig, '*/').replace(/@datam@/ig, '\'Y\'') - } else { - component.setting.dataresource = component.setting.dataresource.replace(/@\$|\$@/ig, '').replace(/@datam@/ig, '\'\'') - _customScript = _customScript.replace(/@\$|\$@/ig, '').replace(/@datam@/ig, '\'\'') - _tailScript = _tailScript.replace(/@\$|\$@/ig, '').replace(/@datam@/ig, '\'\'') - } - - regs.forEach(cell => { - component.setting.dataresource = component.setting.dataresource.replace(cell.reg, cell.value) - _customScript = _customScript.replace(cell.reg, cell.value) - _tailScript = _tailScript.replace(cell.reg, cell.value) - }) - - component.setting.customScript = _customScript // 鏁寸悊鍚庤嚜瀹氫箟鑴氭湰 - component.setting.tailScript = _tailScript // 鍚庣疆鑷畾涔夎剼鏈� - - component.setting.custompage = /@pageSize@|@orderBy@/i.test(component.setting.dataresource + component.setting.customScript) - - if (!component.setting.execute || component.setting.custompage) { - component.forbidLine = true - } - - if (component.setting.sync === 'true') { - // pageable 鏄惁鍒嗛〉锛岀粍浠跺睘鎬э紝涓嶅垎椤电殑缁勪欢鎵嶅彲浠ョ粺涓�鏌ヨ - if ((!component.pageable || (component.pageable && !component.setting.laypage)) && component.setting.onload === 'true') { - - } else { - component.setting.sync = 'false' - } - } + if (component.setting.interType !== 'system') return component // dataName 绯荤粺鐢熸垚鐨勬暟鎹簮鍚嶇О if (component.setting.sync === 'true') { @@ -1229,11 +1241,6 @@ component.setting.delay = delay delay += 20 - - if (balMap.has(component.uuid)) { - component.setting.$hasSyncModule = true - balMap.set(component.uuid, component) - } return component }) -- Gitblit v1.8.0