From bdfec44c9f3a37dbbe05bf14a252ffec04132a86 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期二, 06 九月 2022 21:24:28 +0800 Subject: [PATCH] Merge branch 'develop' --- src/tabviews/custom/index.jsx | 183 +++++++++++++++++++++++++++++---------------- 1 files changed, 117 insertions(+), 66 deletions(-) diff --git a/src/tabviews/custom/index.jsx b/src/tabviews/custom/index.jsx index 5b729ce..abe3ac2 100644 --- a/src/tabviews/custom/index.jsx +++ b/src/tabviews/custom/index.jsx @@ -73,11 +73,11 @@ * @description 鑾峰彇椤甸潰閰嶇疆淇℃伅 */ async loadconfig () { - const { permAction } = this.props + const { permAction, MenuID } = this.props let _param = { func: 'sPC_Get_LongParam', - MenuID: this.props.MenuID + MenuID: MenuID } let result = await Api.getCacheConfig(_param) @@ -140,7 +140,9 @@ let skip = config.permission === 'false' || window.GLOB.mkHS let param = this.props.param || {} // url鍙傛暟 - config.components = this.filterComponent(config.components, roleId, permAction, balMap, skip, param) + window.GLOB.CacheData.set(MenuID, param) + + config.components = this.filterComponent(config.components, roleId, permAction, balMap, skip, param, MenuID) // 鑾峰彇涓绘悳绱㈡潯浠� let mainSearch = [] @@ -443,8 +445,9 @@ }) } - filterComponent = (components, roleId, permAction, balMap, skip, urlparam) => { + filterComponent = (components, roleId, permAction, balMap, skip, urlparam, pageId) => { return components.filter(item => { + item.$pageId = pageId if (item.style && item.style.boxShadow) { delete item.style.hShadow @@ -526,21 +529,11 @@ } item.subtabs = item.subtabs.map(tab => { - tab.components = this.filterComponent(tab.components, roleId, permAction, balMap, skip, urlparam) + tab.$pageId = pageId + + tab.components = this.filterComponent(tab.components, roleId, permAction, balMap, skip, urlparam, pageId) return tab }) - - let supIds = [] - item.subtabs.forEach(tab => { - tab.components.forEach(comp => { - if (comp.type === 'tabs' && comp.parentIds) { - supIds.push(...comp.parentIds) - } else if (comp.setting && comp.setting.supModule) { - supIds.push(comp.setting.supModule) - } - }) - }) - item.parentIds = supIds return true } else if (item.type === 'group') { @@ -551,7 +544,7 @@ return false } - item.components = this.filterComponent(item.components, roleId, permAction, balMap, skip, urlparam) + item.components = this.filterComponent(item.components, roleId, permAction, balMap, skip, urlparam, pageId) return true } else if (['pie', 'bar', 'line', 'dashboard', 'scatter', 'chart'].includes(item.type)) { @@ -588,8 +581,16 @@ } else if (col.blacklist && col.blacklist.filter(v => roleId.indexOf(v) > -1).length > 0) { col.Hide = 'true' } - if (col.type === 'number' && col.sum === 'true' && !statFields.includes(col.field)) { - statFields.push(col) + if (col.type === 'number') { + if (col.sum === 'true' && !statFields.includes(col.field)) { + statFields.push(col) + } + if (typeof(col.decimal) === 'number') { + col.round = Math.pow(10, col.decimal) + if (col.format === 'percent') { + col.decimal = col.decimal > 2 ? col.decimal - 2 : 0 + } + } } else if (col.type === 'colspan') { col.subcols = getCols(col.subcols || []) if (col.subcols.length === 0) { @@ -597,8 +598,16 @@ } } else if (col.type === 'custom') { col.elements = col.elements.map(cell => { - if (['text', 'number', 'link'].includes(cell.eleType) && !cell.height) { - cell.innerHeight = 'auto' + if (['text', 'number', 'formula'].includes(cell.eleType)) { + if (!cell.height) { + cell.innerHeight = 'auto' + } + if (cell.eleType === 'number' && typeof(cell.decimal) === 'number') { + cell.round = Math.pow(10, cell.decimal) + if (cell.format === 'percent') { + cell.decimal = cell.decimal > 2 ? cell.decimal - 2 : 0 + } + } } else if (cell.eleType === 'icon') { let fontSize = 14 let lineHeight = 1.5 @@ -678,8 +687,6 @@ if (item.type === 'card') { item.subcards && item.subcards.forEach(card => { - let _hasheight = card.style.height && card.style.height !== 'auto' - if (card.style.boxShadow) { delete card.style.hShadow delete card.style.vShadow @@ -711,8 +718,16 @@ card.style = card.style || {} card.style = {...card.style, ...card.btnstyle} } - } else if (['text', 'number', 'link'].includes(cell.eleType) && !cell.height && _hasheight) { - cell.innerHeight = 'auto' + } else if (['text', 'number', 'formula'].includes(cell.eleType)) { + if (!cell.height) { + cell.innerHeight = 'auto' + } + if (cell.eleType === 'number' && typeof(cell.decimal) === 'number') { + cell.round = Math.pow(10, cell.decimal) + if (cell.format === 'percent') { + cell.decimal = cell.decimal > 2 ? cell.decimal - 2 : 0 + } + } } else if (cell.eleType === 'icon') { let fontSize = 14 let lineHeight = 1.5 @@ -753,8 +768,16 @@ card.style = card.style || {} card.style = {...card.style, ...card.btnstyle} } - } else if (['text', 'number', 'link'].includes(cell.eleType) && !cell.height && _hasheight) { - cell.innerHeight = 'auto' + } else if (['text', 'number', 'formula'].includes(cell.eleType)) { + if (!cell.height) { + cell.innerHeight = 'auto' + } + if (cell.eleType === 'number' && typeof(cell.decimal) === 'number') { + cell.round = Math.pow(10, cell.decimal) + if (cell.format === 'percent') { + cell.decimal = cell.decimal > 2 ? cell.decimal - 2 : 0 + } + } } else if (cell.eleType === 'icon') { let fontSize = 14 let lineHeight = 1.5 @@ -799,8 +822,16 @@ if (cell.OpenType === 'funcbutton' && cell.funcType === 'print' && cell.verify) { // 鎵撳嵃鏈鸿缃� cell = this.getPrinter(cell, item.uuid) } - } else if (['text', 'number', 'link'].includes(cell.eleType) && !cell.height) { - cell.innerHeight = 'auto' + } else if (['text', 'number', 'formula'].includes(cell.eleType)) { + if (!cell.height) { + cell.innerHeight = 'auto' + } + if (cell.eleType === 'number' && typeof(cell.decimal) === 'number') { + cell.round = Math.pow(10, cell.decimal) + if (cell.format === 'percent') { + cell.decimal = cell.decimal > 2 ? cell.decimal - 2 : 0 + } + } } else if (cell.eleType === 'icon') { let fontSize = 14 let lineHeight = 1.5 @@ -819,7 +850,6 @@ }) } else if ((item.type === 'table' && item.subtype === 'tablecard') || item.type === 'carousel' || item.type === 'timeline') { item.subcards && item.subcards.forEach(card => { - let _hasheight = card.style.height && card.style.height !== 'auto' card.elements = card.elements.filter(cell => { if (cell.eleType === 'button') { if (cell.hidden === 'true') return false @@ -844,8 +874,16 @@ card.style = card.style || {} card.style = {...card.style, ...card.btnstyle} } - } else if (['text', 'number', 'link'].includes(cell.eleType) && !cell.height && _hasheight) { - cell.innerHeight = 'auto' + } else if (['text', 'number', 'formula'].includes(cell.eleType)) { + if (!cell.height) { + cell.innerHeight = 'auto' + } + if (cell.eleType === 'number' && typeof(cell.decimal) === 'number') { + cell.round = Math.pow(10, cell.decimal) + if (cell.format === 'percent') { + cell.decimal = cell.decimal > 2 ? cell.decimal - 2 : 0 + } + } } else if (cell.eleType === 'icon') { let fontSize = 14 let lineHeight = 1.5 @@ -906,6 +944,7 @@ // group.subButton.$forbid = true // 涓嶅0鏄庢暟鎹簮鍙橀噺 group.subButton.OpenType = 'formSubmit' group.subButton.execError = 'never' + group.subButton.logLabel = item.$menuname + '-' + group.subButton.label if (!group.subButton.Ot) { group.subButton.Ot = item.wrap.datatype === 'static' ? 'notRequired' : 'requiredSgl' @@ -1057,13 +1096,13 @@ } if (sessionStorage.getItem('dataM') === 'true') { // 鏁版嵁鏉冮檺 - component.setting.dataresource = component.setting.dataresource.replace(/\$@/ig, '/*') + component.setting.dataresource = component.setting.dataresource.replace(/\$@/ig, '/*').replace(/@datam@/ig, 'Y') component.setting.dataresource = component.setting.dataresource.replace(/@\$/ig, '*/') - _customScript = _customScript.replace(/\$@/ig, '/*') + _customScript = _customScript.replace(/\$@/ig, '/*').replace(/@datam@/ig, 'Y') _customScript = _customScript.replace(/@\$/ig, '*/') } else { - component.setting.dataresource = component.setting.dataresource.replace(/@\$|\$@/ig, '') - _customScript = _customScript.replace(/@\$|\$@/ig, '') + component.setting.dataresource = component.setting.dataresource.replace(/@\$|\$@/ig, '').replace(/@datam@/ig, '') + _customScript = _customScript.replace(/@\$|\$@/ig, '').replace(/@datam@/ig, '') } regs.forEach(cell => { @@ -1119,7 +1158,7 @@ this.setState({loading: true, loadingview: false}) - Api.getLocalConfig(param).then(result => { + Api.genericInterface(param).then(result => { if (result.status) { delete result.status delete result.message @@ -1183,6 +1222,23 @@ } MKEmitter.removeListener('reloadMenuView', this.reloadMenuView) MKEmitter.removeListener('resetActiveMenu', this.resetActiveMenu) + + window.GLOB.CacheData.delete(this.props.MenuID) + this.deleteCache(this.state.config.components) + } + + deleteCache = (components) => { + components.forEach(item => { + if (item.type === 'tabs') { + item.subtabs.forEach(tab => { + this.deleteCache(tab.components) + }) + } else if (item.type === 'group') { + this.deleteCache(item.components) + } else { + window.GLOB.CacheData.delete(item.uuid) + } + }) } reloadview = () => { @@ -1211,51 +1267,46 @@ if (!config || !config.components) return return config.components.map(item => { - let _bid = BID - if (item.setting && item.setting.supModule) { - _bid = '' - } - if (item.type === 'bar' || item.type === 'line') { return ( <Col span={item.width} key={item.uuid}> - <AntvBarAndLine config={item} data={data} BID={_bid} mainSearch={mainSearch}/> + <AntvBarAndLine config={item} data={data} mainSearch={mainSearch}/> </Col> ) } else if (item.type === 'pie') { return ( <Col span={item.width} key={item.uuid}> - <AntvPie config={item} data={data} BID={_bid} mainSearch={mainSearch}/> + <AntvPie config={item} data={data} mainSearch={mainSearch}/> </Col> ) } else if (item.type === 'scatter') { return ( <Col span={item.width} key={item.uuid}> - <AntvScatter config={item} data={data} BID={_bid} mainSearch={mainSearch}/> + <AntvScatter config={item} data={data} mainSearch={mainSearch}/> </Col> ) } else if (item.type === 'dashboard') { return ( <Col span={item.width} key={item.uuid}> - <AntvDashboard config={item} data={data} BID={_bid} mainSearch={mainSearch}/> + <AntvDashboard config={item} data={data} mainSearch={mainSearch}/> </Col> ) } else if (item.type === 'form' && item.subtype === 'simpleform') { return ( <Col span={item.width} key={item.uuid}> - <SimpleForm config={item} data={data} BID={_bid} mainSearch={mainSearch}/> + <SimpleForm config={item} data={data} mainSearch={mainSearch}/> </Col> ) } else if (item.type === 'form' && item.subtype === 'stepform') { return ( <Col span={item.width} key={item.uuid}> - <StepForm config={item} data={data} BID={_bid} mainSearch={mainSearch}/> + <StepForm config={item} data={data} mainSearch={mainSearch}/> </Col> ) } else if (item.type === 'form' && item.subtype === 'tabform') { return ( <Col span={item.width} key={item.uuid}> - <TabForm config={item} data={data} BID={_bid} mainSearch={mainSearch}/> + <TabForm config={item} data={data} mainSearch={mainSearch}/> </Col> ) } else if (item.type === 'search') { @@ -1267,97 +1318,97 @@ } else if (item.type === 'tabs') { return ( <Col span={item.width} key={item.uuid}> - <AntvTabs config={item} BID={BID} mainSearch={mainSearch} /> + <AntvTabs config={item} mainSearch={mainSearch} /> </Col> ) } else if (item.type === 'card' && item.subtype === 'datacard') { return ( <Col span={item.width} key={item.uuid}> - <DataCard config={item} data={data} BID={_bid} mainSearch={mainSearch}/> + <DataCard config={item} data={data} mainSearch={mainSearch}/> </Col> ) } else if (item.type === 'card' && item.subtype === 'propcard') { return ( <Col span={item.width} key={item.uuid}> - <PropCard config={item} data={data} BID={_bid} mainSearch={mainSearch}/> + <PropCard config={item} data={data} mainSearch={mainSearch}/> </Col> ) } else if (item.type === 'balcony') { return ( <Col span={item.width} key={item.uuid}> - <Balcony config={item} data={data} BID={_bid}/> + <Balcony config={item} data={data}/> </Col> ) } else if (item.type === 'timeline') { return ( <Col span={item.width} key={item.uuid}> - <TimeLine config={item} data={data} BID={_bid}/> + <TimeLine config={item} data={data} mainSearch={mainSearch}/> </Col> ) } else if (item.type === 'carousel' && item.subtype === 'datacard') { return ( <Col span={item.width} key={item.uuid}> - <CarouselDataCard config={item} data={data} BID={_bid} mainSearch={mainSearch}/> + <CarouselDataCard config={item} data={data} mainSearch={mainSearch}/> </Col> ) } else if (item.type === 'carousel' && item.subtype === 'propcard') { return ( <Col span={item.width} key={item.uuid}> - <CarouselPropCard config={item} data={data} BID={_bid} mainSearch={mainSearch}/> + <CarouselPropCard config={item} data={data} mainSearch={mainSearch}/> </Col> ) } else if (item.type === 'table' && item.subtype === 'tablecard') { return ( <Col span={item.width} key={item.uuid}> - <TableCard config={item} data={data} BID={_bid} mainSearch={mainSearch}/> + <TableCard config={item} data={data} mainSearch={mainSearch}/> </Col> ) } else if (item.type === 'table' && item.subtype === 'normaltable') { return ( <Col span={item.width} key={item.uuid}> - <NormalTable config={item} data={data} BID={_bid} mainSearch={mainSearch}/> + <NormalTable config={item} data={data} mainSearch={mainSearch}/> </Col> ) } else if (item.type === 'table' && item.subtype === 'editable') { return ( <Col span={item.width} key={item.uuid}> - <EditTable config={item} BID={_bid} mainSearch={mainSearch}/> + <EditTable config={item} mainSearch={mainSearch}/> </Col> ) } else if (item.type === 'group' && item.subtype === 'normalgroup') { return ( <Col span={item.width} key={item.uuid}> - <NormalGroup config={item} BID={_bid} mainSearch={mainSearch}/> + <NormalGroup config={item} mainSearch={mainSearch}/> </Col> ) } else if (item.type === 'editor') { return ( <Col span={item.width} key={item.uuid}> - <BraftEditor config={item} data={data} BID={_bid} mainSearch={mainSearch}/> + <BraftEditor config={item} data={data} mainSearch={mainSearch}/> </Col> ) } else if (item.type === 'tree') { return ( <Col span={item.width} key={item.uuid}> - <NormalTree config={item} data={data} BID={_bid} mainSearch={mainSearch}/> + <NormalTree config={item} data={data} mainSearch={mainSearch}/> </Col> ) } else if (item.type === 'code') { return ( <Col span={item.width} key={item.uuid}> - <SandBox config={item} data={data} BID={_bid} mainSearch={mainSearch}/> + <SandBox config={item} data={data} mainSearch={mainSearch}/> </Col> ) } else if (item.type === 'chart') { return ( <Col span={item.width} key={item.uuid}> - <CustomChart config={item} data={data} BID={_bid} mainSearch={mainSearch}/> + <CustomChart config={item} data={data} mainSearch={mainSearch}/> </Col> ) } else if (item.type === 'module' && item.subtype === 'voucher') { return ( <Col span={item.width} key={item.uuid}> - <Voucher config={item} BID={_bid} /> + <Voucher config={item}/> </Col> ) } else { -- Gitblit v1.8.0