From b8e1395f02c929eaa96b949cf6027ee2a43856a6 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期二, 06 九月 2022 19:03:37 +0800 Subject: [PATCH] 2022-09-06 --- src/tabviews/custom/index.jsx | 83 ++++++++++++++++++++++++++++++++--------- 1 files changed, 64 insertions(+), 19 deletions(-) diff --git a/src/tabviews/custom/index.jsx b/src/tabviews/custom/index.jsx index c468159..abe3ac2 100644 --- a/src/tabviews/custom/index.jsx +++ b/src/tabviews/custom/index.jsx @@ -581,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) { @@ -590,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 @@ -671,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 @@ -704,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 @@ -746,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 @@ -792,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 @@ -812,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 @@ -837,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 @@ -1051,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 => { -- Gitblit v1.8.0