From f07c42a322f41e14ef5b1bf8f2fd66fc5d338cdd Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期三, 28 六月 2023 18:17:09 +0800 Subject: [PATCH] 2023-06-28 --- src/tabviews/custom/popview/index.jsx | 377 +++++++++++++++++++++++++++++++---------------------- 1 files changed, 219 insertions(+), 158 deletions(-) diff --git a/src/tabviews/custom/popview/index.jsx b/src/tabviews/custom/popview/index.jsx index a3eb065..67bdd49 100644 --- a/src/tabviews/custom/popview/index.jsx +++ b/src/tabviews/custom/popview/index.jsx @@ -1,7 +1,7 @@ import React, {Component} from 'react' import PropTypes from 'prop-types' import { is, fromJS } from 'immutable' -import { notification, Spin, Row, Col } from 'antd' +import { notification, Spin, Row, Col, Modal } from 'antd' import Api from '@/api' import zhCN from '@/locales/zh-CN/main.js' @@ -41,6 +41,7 @@ const Voucher = asyncComponent(() => import('../components/module/voucher')) const Iframe = asyncComponent(() => import('../components/iframe')) const AntvG6 = asyncComponent(() => import('../components/chart/antv-G6')) +const AntvX6 = asyncComponent(() => import('../components/chart/antv-X6')) class CustomPage extends Component { static propTpyes = { @@ -97,7 +98,7 @@ // 鏁版嵁缂撳瓨璁剧疆 if (config.cacheUseful === 'true') { - if (!['day', 'hour'].includes(config.timeUnit)) { + if (!['day', 'hour', 'minute'].includes(config.timeUnit)) { config.timeUnit = 'day' } config.cacheTime = config.cacheTime || 1 @@ -302,6 +303,29 @@ item.search = Utils.initSearchVal(item.search) } + if (item.wrap && item.wrap.supType === 'multi') { // 鏁版嵁鍗″涓婄骇缁勪欢 + item.setting.supModule = item.supNodes[0].componentId + } else if (item.setting && item.setting.supModule && typeof(item.setting.supModule) !== 'string') { + let pid = item.setting.supModule.pop() + if (pid && pid !== 'empty') { + item.setting.supModule = pid + } else { + item.setting.supModule = '' + } + } + + // 鏉冮檺杩囨护 + if (item.action && item.action.length > 0) { + item.action = item.action.filter(cell => { + if (cell.hidden === 'true' || cell.OpenType === 'popview') return false + + cell = this.resetButton(item, cell, Tab) + cell.$toolbtn = true + + return true + }) + } + if (item.type === 'table') { let statFields = [] let getCols = (cols) => { @@ -310,6 +334,8 @@ return false } else if (col.Hide === 'true') { return false + } else if (col.type === 'action') { + col.type = 'custom' } if (col.type === 'number') { @@ -322,26 +348,31 @@ col.decimal = col.decimal > 2 ? col.decimal - 2 : 0 } } + } else if (col.type === 'formula') { + if (typeof(col.decimal) === 'number') { + col.round = Math.pow(10, col.decimal) + } } else if (col.type === 'colspan') { col.subcols = getCols(col.subcols || []) if (col.subcols.length === 0) { return false } } else if (col.type === 'custom') { - col.elements = col.elements.map(cell => { - 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 - } - } + col.elements = col.elements.filter(cell => { + if (cell.eleType === 'button') { + if (cell.hidden === 'true' || cell.OpenType === 'popview') return false + + cell = this.resetButton(item, cell, Tab) + } else { + cell = this.resetElement(cell) } - return cell + + return true }) + + if (col.elements.length === 0) { + return false + } } if (col.linkmenu && col.linkmenu.length > 0) { @@ -357,46 +388,20 @@ item.cols = getCols(item.cols) item.statFields = statFields - } - let mutil = false - if (item.wrap && item.wrap.supType === 'multi') { // 鏁版嵁鍗″涓婄骇缁勪欢 - mutil = true - item.setting.supModule = item.supNodes[0].componentId - } else if (item.setting && item.setting.supModule) { - let pid = item.setting.supModule.pop() - if (pid && pid !== 'empty') { - item.setting.supModule = pid - } else { - item.setting.supModule = '' + if (item.subtype === 'editable') { + item.submit.logLabel = item.$menuname + '-鎻愪氦' + item.submit.$menuId = item.uuid + item.submit.syncComponentId = item.submit.syncComponent ? (item.submit.syncComponent.pop() || '') : '' + + if (item.submit.syncComponentId && item.submit.syncComponentId === item.setting.supModule) { + item.submit.syncComponentId = '' + if (item.submit.execSuccess === 'grid') { + item.submit.execSuccess = 'mainline' + } + } } - } - - // 鏉冮檺杩囨护 - if (item.action && item.action.length > 0) { - item.action = item.action.filter(cell => { - if (cell.hidden === 'true' || ['popview', 'funcbutton'].includes(cell.OpenType)) return false - - cell.logLabel = item.$menuname + '-' + cell.label - cell.syncComponentId = cell.syncComponent ? (cell.syncComponent.pop() || '') : '' - cell.$menuId = item.uuid - cell.$tabId = Tab.uuid - cell.$toolbtn = true - - if (!mutil && cell.syncComponentId === item.setting.supModule) { - cell.syncComponentId = '' - } - - if (cell.btnstyle) { // 鍏煎 - cell.style = cell.style || {} - cell.style = {...cell.style, ...cell.btnstyle} - } - - return true - }) - } - - if (item.type === 'card' || item.type === 'carousel' || item.type === 'timeline') { + } else if (item.type === 'card' || item.type === 'carousel' || item.type === 'timeline') { item.subcards && item.subcards.forEach(card => { if (card.style.boxShadow) { delete card.style.hShadow @@ -407,66 +412,49 @@ card.elements = card.elements.filter(cell => { if (cell.eleType === 'button') { - if (cell.hidden === 'true' || ['popview', 'funcbutton'].includes(cell.OpenType)) return false + if (cell.hidden === 'true' || cell.OpenType === 'popview') return false - cell.logLabel = item.$menuname + '-' + cell.label - cell.Ot = cell.Ot || 'requiredSgl' - cell.syncComponentId = cell.syncComponent ? (cell.syncComponent.pop() || '') : '' - cell.$menuId = item.uuid - cell.$tabId = Tab.uuid - - if (!mutil && cell.syncComponentId === item.setting.supModule) { - cell.syncComponentId = '' - } - if (card.btnstyle) { // 鍏煎 - card.style = card.style || {} - card.style = {...card.style, ...card.btnstyle} - } - } 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 - } - } + cell = this.resetButton(item, cell, Tab) + } else { + cell = this.resetElement(cell) } return true }) + if (card.setting.click === 'menus') { + if (card.menus) { + card.menus = card.menus.filter(m => !!m.MenuID) + if (card.menus.length === 0) { + card.menus = null + } + } + if (!card.menus || item.subtype !== 'datacard' || card.$cardType === 'extendCard') { + card.setting.click = '' + } + } else if (card.setting.click === 'menu') { + if (!Array.isArray(card.setting.menu)) { + card.setting.click = '' + } + } + + if (item.subtype === 'dualdatacard' && card.$cardType !== 'extendCard') { + if (card.backSetting && card.backSetting.click === 'menu') { + if (!Array.isArray(card.backSetting.menu)) { + card.backSetting.click = '' + } + } + } + if (!card.backElements || card.backElements.length === 0) return card.backElements = card.backElements.filter(cell => { if (cell.eleType === 'button') { - if (cell.hidden === 'true' || ['popview', 'funcbutton'].includes(cell.OpenType)) return false + if (cell.hidden === 'true' || cell.OpenType === 'popview') return false - cell.logLabel = item.$menuname + '-' + cell.label - cell.Ot = cell.Ot || 'requiredSgl' - cell.syncComponentId = cell.syncComponent ? (cell.syncComponent.pop() || '') : '' - cell.$menuId = item.uuid - cell.$tabId = Tab.uuid - - if (!mutil && cell.syncComponentId === item.setting.supModule) { - cell.syncComponentId = '' - } - - if (card.btnstyle) { // 鍏煎 - card.style = card.style || {} - card.style = {...card.style, ...card.btnstyle} - } - } 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 - } - } + cell = this.resetButton(item, cell, Tab) + } else { + cell = this.resetElement(cell) } return true @@ -482,60 +470,15 @@ } item.elements = item.elements.filter(cell => { if (cell.eleType === 'button') { - if (cell.hidden === 'true' || ['popview', 'funcbutton'].includes(cell.OpenType)) return false + if (cell.hidden === 'true' || cell.OpenType === 'popview') return false - cell.logLabel = item.$menuname + '-' + cell.label - cell.syncComponentId = cell.syncComponent ? (cell.syncComponent.pop() || '') : '' - cell.$menuId = item.uuid - cell.$tabId = Tab.uuid - - if (cell.syncComponentId === item.wrap.supModule) { - cell.syncComponentId = '' - } - } 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 - } - } + cell = this.resetButton(item, cell, Tab) + } else { + cell = this.resetElement(cell) } return true }) - } else if (item.type === 'table') { - item.cols = item.cols.filter(col => { - if (col.type !== 'action') return true - col.elements = col.elements.filter(cell => { - if (cell.hidden === 'true' || ['popview', 'funcbutton'].includes(cell.OpenType)) return false - - cell.logLabel = item.$menuname + '-' + cell.label - cell.Ot = cell.Ot || 'requiredSgl' - cell.syncComponentId = cell.syncComponent ? (cell.syncComponent.pop() || '') : '' - cell.$menuId = item.uuid - cell.$tabId = Tab.uuid - - if (cell.syncComponentId === item.setting.supModule) { - cell.syncComponentId = '' - } - - if (cell.btnstyle) { // 鍏煎 - cell.style = cell.style || {} - cell.style = {...cell.style, ...cell.btnstyle} - } - - return true - }) - return col.elements.length !== 0 - }) - - if (item.subtype === 'editable') { - item.submit.logLabel = item.$menuname + '-鎻愪氦' - item.submit.$menuId = item.uuid - } } else if (item.type === 'form') { item.subcards = item.subcards.map(group => { group.subButton.uuid = group.uuid @@ -549,10 +492,13 @@ group.subButton.Ot = item.wrap.datatype === 'static' ? 'notRequired' : 'requiredSgl' } - group.subButton.syncComponentId = group.subButton.syncComponent ? group.subButton.syncComponent.pop() : '' + group.subButton.syncComponentId = group.subButton.syncComponent ? (group.subButton.syncComponent.pop() || '') : '' - if (group.subButton.syncComponentId === item.setting.supModule) { + if (group.subButton.syncComponentId && group.subButton.syncComponentId === item.setting.supModule) { group.subButton.syncComponentId = '' + if (group.subButton.execSuccess === 'grid') { + group.subButton.execSuccess = 'mainline' + } } group.fields = group.fields.map(cell => { @@ -617,6 +563,93 @@ return true }) + } + + resetButton = (item, cell, Tab) => { + cell.logLabel = item.$menuname + '-' + cell.label + cell.Ot = cell.Ot || 'requiredSgl' + cell.syncComponentId = cell.syncComponent ? (cell.syncComponent.pop() || '') : '' + cell.$menuId = item.uuid + cell.$MenuID = Tab.$MenuID + cell.$tabId = Tab.uuid + + if (cell.btnstyle) { // 鍏煎 + cell.style = cell.style || {} + cell.style = {...cell.style, ...cell.btnstyle} + } + + if (cell.controlField) { + if (/,/ig.test(cell.controlVal)) { + cell.controlVals = cell.controlVal.split(',') + } else { + cell.controlVals = [(cell.controlVal || '')] + } + } + + if (cell.syncComponentId) { + if (cell.syncComponentId === item.setting.supModule) { + cell.syncComponentId = '' + if (cell.execSuccess === 'line' || cell.execSuccess === 'grid') { + cell.execSuccess = 'mainline' + } + } else if (cell.syncComponentId === 'multiComponent') { + let ids = cell.syncComponents.map(m => { + return m.syncComId.pop() || '' + }) + + if (item.setting.supModule && ids.includes(item.setting.supModule)) { + if (cell.execSuccess === 'line' || cell.execSuccess === 'grid') { + cell.execSuccess = 'mainline' + } + ids = ids.filter(id => id !== item.setting.supModule) + } + + if (ids.length === 0) { + cell.syncComponentId = '' + } else { + cell.syncComponentIds = ids + } + } + } + + return cell + } + + resetElement = (cell) => { + cell.style = cell.style || {} + if (['text', 'number', 'formula'].includes(cell.eleType)) { + if (!cell.height) { + cell.innerHeight = 'auto' + } + + cell.innerHeight = cell.innerHeight || 'auto' + cell.alignItems = cell.height > 1 ? cell.alignItems : '' + + 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.type === 'formula' && typeof(cell.decimal) === 'number') { + cell.round = Math.pow(10, cell.decimal) + } + } else if (cell.eleType === 'icon') { + if (!cell.innerHeight) { // 鍏煎 + let fontSize = 14 + let lineHeight = 1.5 + + if (cell.style.fontSize) { + fontSize = parseInt(cell.style.fontSize) + } + if (cell.style.lineHeight) { + lineHeight = parseFloat(cell.style.lineHeight) + } + + cell.innerHeight = fontSize * lineHeight + } + } + + return cell } getPrinter = (item, parentId) => { @@ -713,7 +746,7 @@ // dataName 绯荤粺鐢熸垚鐨勬暟鎹簮鍚嶇О if (component.setting.sync === 'true') { - component.dataName = Utils.getdataName() + component.dataName = 'mk' + component.uuid.slice(-18) } // floor 缁勪欢鐨勫眰绾� @@ -765,6 +798,20 @@ Api.genericInterface(param).then(result => { if (result.status) { + if (result.message) { + if (result.ErrCode === 'Y') { + Modal.success({ + title: result.message + }) + } else if (result.ErrCode === 'S') { + notification.success({ + top: 92, + message: result.message, + duration: 2 + }) + } + } + delete result.status delete result.message delete result.ErrMesg @@ -789,11 +836,19 @@ data: '', loading: false }) - notification.error({ - top: 92, - message: result.message, - duration: 10 - }) + + if (!result.message) return + if (result.ErrCode === 'N') { + Modal.error({ + title: result.message, + }) + } else if (result.ErrCode !== '-2') { + notification.error({ + top: 92, + message: result.message, + duration: 10 + }) + } } }) } @@ -1021,6 +1076,12 @@ <AntvG6 config={item} data={data} mainSearch={mainSearch}/> </Col> ) + } else if (item.type === 'antvX6') { + return ( + <Col span={item.width} style={style} key={item.uuid}> + <AntvX6 config={item}/> + </Col> + ) } else { return null } -- Gitblit v1.8.0