| | |
| | | import React, { Component } from 'react' |
| | | import { is, fromJS } from 'immutable' |
| | | import { Col, Row, Spin, notification, Button } from 'antd' |
| | | import { Col, Row, Spin, notification, Button, Modal } from 'antd' |
| | | import moment from 'moment' |
| | | import md5 from 'md5' |
| | | |
| | | import Api from '@/api' |
| | | import Utils from '@/utils/utils.js' |
| | | import zhCN from '@/locales/zh-CN/main.js' |
| | | import enUS from '@/locales/en-US/main.js' |
| | | import options from '@/store/options.js' |
| | | import { styles } from '@/store/options.js' |
| | | import UtilsDM from '@/utils/utils-datamanage.js' |
| | | import NotFount from '@/components/404' |
| | | import asyncComponent from '@/utils/asyncComponent' |
| | |
| | | // 通用组件 |
| | | const AntvBarAndLine = asyncComponent(() => import('@/tabviews/custom/components/chart/antv-bar-line')) |
| | | const AntvPie = asyncComponent(() => import('@/tabviews/custom/components/chart/antv-pie')) |
| | | const AntvDashboard = asyncComponent(() => import('@/tabviews/custom/components/chart/antv-dashboard')) |
| | | const AntvScatter = asyncComponent(() => import('@/tabviews/custom/components/chart/antv-scatter')) |
| | | const DataCard = asyncComponent(() => import('@/tabviews/custom/components/card/data-card')) |
| | | const PropCard = asyncComponent(() => import('@/tabviews/custom/components/card/prop-card')) |
| | | const DoubleDataCard = asyncComponent(() => import('@/tabviews/custom/components/card/double-data-card')) |
| | | const TableCard = asyncComponent(() => import('@/tabviews/custom/components/card/table-card')) |
| | | const NormalTable = asyncComponent(() => import('@/tabviews/custom/components/table/normal-table')) |
| | | const SandBox = asyncComponent(() => import('@/tabviews/custom/components/code/sand-box')) |
| | | const TimeLine = asyncComponent(() => import('@/tabviews/custom/components/timeline/normal-timeline')) |
| | | const BraftEditor = asyncComponent(() => import('@/tabviews/custom/components/editor/braft-editor')) |
| | | const Balcony = asyncComponent(() => import('@/tabviews/custom/components/card/balcony')) |
| | | const AntvG6 = asyncComponent(() => import('@/tabviews/custom/components/chart/antv-G6')) |
| | | const AntvX6 = asyncComponent(() => import('@/tabviews/custom/components/chart/antv-X6')) |
| | | const DebugTable = asyncComponent(() => import('@/tabviews/debugtable')) |
| | | |
| | | class BillPrint extends Component { |
| | | state = { |
| | | dict: localStorage.getItem('lang') !== 'en-US' ? zhCN : enUS, |
| | | loadingview: true, |
| | | dataManager: false, |
| | | printing: false, |
| | | pages: null, |
| | | BID: '', |
| | | data: '', |
| | | tempId: '', |
| | | pageId: '', |
| | | config: null, |
| | | urlParam: null, |
| | | visible: false, |
| | | rePos: false, |
| | | loading: false, |
| | | auto: true, |
| | | ismob: /(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i.test(navigator.userAgent) |
| | | } |
| | | |
| | | reloading = false |
| | | |
| | | UNSAFE_componentWillMount() { |
| | | try { |
| | | let param = JSON.parse(window.decodeURIComponent(window.atob(this.props.match.params.param))) |
| | | const { params } = this.props.match |
| | | |
| | | if (params.menuId) { |
| | | this.setState({ |
| | | BID: param.id || '', |
| | | tempId: param.tempId, |
| | | dataManager: param.dataManager |
| | | BID: params.id || '', |
| | | tempId: params.menuId |
| | | }, () => { |
| | | this.getMenuParam() |
| | | this.getTouristMsg() |
| | | }) |
| | | } catch { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '菜单信息解析错误!', |
| | | duration: 5 |
| | | }) |
| | | } else { |
| | | try { |
| | | let param = JSON.parse(window.decodeURIComponent(window.atob(params.param))) |
| | | |
| | | sessionStorage.setItem('dataM', param.dataM || '') |
| | | let urlParam = {...param} |
| | | |
| | | delete urlParam.tempId |
| | | delete urlParam.pageId |
| | | delete urlParam.dataM |
| | | |
| | | Object.keys(urlParam).forEach(key => { |
| | | if (key === key.toLowerCase()) return |
| | | urlParam[key.toLowerCase()] = urlParam[key] |
| | | delete urlParam[key] |
| | | }) |
| | | |
| | | this.setState({ |
| | | BID: param.id || '', |
| | | tempId: param.tempId, |
| | | urlParam: urlParam, |
| | | pageId: param.pageId || '' |
| | | }, () => { |
| | | setTimeout(() => { |
| | | this.getMenuParam() |
| | | }, 200) |
| | | }) |
| | | } catch (e) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '菜单信息解析错误!', |
| | | duration: 5 |
| | | }) |
| | | } |
| | | } |
| | | } |
| | | |
| | | shouldComponentUpdate (nextProps, nextState) { |
| | | return !is(fromJS(this.state), fromJS(nextState)) |
| | | } |
| | | |
| | | componentDidMount() { |
| | | const that = this |
| | | |
| | | if (window.GLOB.sysType !== 'cloud') { |
| | | Object.defineProperty(window, 'debugger', { |
| | | configurable: true, |
| | | enumerable: true, |
| | | set(value) { |
| | | if (value === true) { |
| | | window.GLOB.debugger = true |
| | | } else if (value === 0) { |
| | | if (window.backend) { |
| | | sessionStorage.setItem('systemRun', 'front') |
| | | window.location.reload() |
| | | } else { |
| | | window.mkInfo('系统当前未使用后端脚本!') |
| | | } |
| | | } else if (value === false) { |
| | | if (sessionStorage.getItem('systemRun') === 'front') { |
| | | sessionStorage.removeItem('systemRun') |
| | | window.location.reload() |
| | | } else { |
| | | window.GLOB.debugger = false |
| | | } |
| | | } |
| | | } |
| | | }) |
| | | |
| | | Object.defineProperty(window, 'debug', { |
| | | configurable: true, |
| | | enumerable: true, |
| | | set(value) { |
| | | if (value + '' === 'false') { |
| | | window.GLOB.debugger = false |
| | | window.GLOB.breakpoint = false |
| | | sessionStorage.removeItem('breakpoint') |
| | | } else { |
| | | window.GLOB.debugger = true |
| | | window.GLOB.breakpoint = value + '' |
| | | sessionStorage.setItem('breakpoint', value) |
| | | } |
| | | that.debugChange() |
| | | } |
| | | }) |
| | | } |
| | | |
| | | document.onkeydown = (event) => { |
| | | let e = event || window.event |
| | | let keyCode = e.keyCode || e.which || e.charCode |
| | | let preKey = '' |
| | | |
| | | if (e.ctrlKey) { |
| | | preKey = 'ctrl' |
| | | } else if (e.shiftKey) { |
| | | preKey = 'shift' |
| | | } else if (e.altKey) { |
| | | preKey = 'alt' |
| | | } |
| | | |
| | | if (!preKey || !keyCode) return |
| | | |
| | | let _shortcut = `${preKey}+${keyCode}` |
| | | |
| | | if (window.GLOB.breakpoint && _shortcut === 'ctrl+67') { |
| | | window.GLOB.breakpoint = false |
| | | sessionStorage.removeItem('breakpoint') |
| | | |
| | | that.debugChange() |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | |
| | | } |
| | | } |
| | | |
| | | debugChange = () => { |
| | | this.setState({visible: !this.state.visible}) |
| | | } |
| | | |
| | | getTouristMsg = () => { |
| | | Api.getTouristMsg().then(result => { |
| | | if (result.status) { |
| | | sessionStorage.setItem('UserID', result.UserID || '') |
| | | sessionStorage.setItem('LoginUID', result.LoginUID || '') |
| | | sessionStorage.setItem('dataM', 'false') |
| | | |
| | | // 获取系统信息 |
| | | let _param = { |
| | | func: 's_Get_style', |
| | | TypeCharOne: 'PC', |
| | | LText: `select '${window.GLOB.appkey}'`, |
| | | } |
| | | |
| | | if (window.GLOB.style_appkey) { |
| | | _param.style_appkey = window.GLOB.style_appkey |
| | | } |
| | | |
| | | _param.userid = result.UserID |
| | | _param.LoginUID = result.LoginUID |
| | | _param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') |
| | | _param.secretkey = Utils.encrypt(_param.LText, _param.timestamp) |
| | | |
| | | Api.getSystemConfig(_param).then(res => { |
| | | if (res.status) { |
| | | window.GLOB.style = res.CSS |
| | | document.title = res.titleName |
| | | sessionStorage.setItem('appname', res.appname || '') |
| | | |
| | | if (window.GLOB.style && styles[window.GLOB.style]) { |
| | | document.body.className = styles[window.GLOB.style] + ' ' + (res.split_line_show === 'false' ? 'hidden-split-line' : '') |
| | | } |
| | | |
| | | if (res.titlelogo) { |
| | | let link = document.querySelector("link[rel*='icon']") || document.createElement('link') |
| | | link.type = 'image/x-icon' |
| | | link.rel = 'shortcut icon' |
| | | link.href = res.titlelogo |
| | | document.getElementsByTagName('head')[0].appendChild(link) |
| | | } |
| | | } |
| | | |
| | | this.getMenuParam() |
| | | }) |
| | | } else { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: result.message, |
| | | duration: 5 |
| | | }) |
| | | } |
| | | }) |
| | | } |
| | | |
| | | getMenuParam = () => { |
| | | const { tempId, BID, dataManager } = this.state |
| | | const { tempId, BID, urlParam } = this.state |
| | | |
| | | let _param = { |
| | | func: 'sPC_Get_LongParam', |
| | | MenuID: tempId |
| | | } |
| | | |
| | | if (window.GLOB.mainSystemApi) { // 从单点登录服务器取打印配置信息 |
| | | _param.rduri = window.GLOB.mainSystemApi |
| | | } |
| | | window.GLOB.dataFormat = false // 打印去除水印 |
| | | |
| | | Api.getLocalConfig(_param).then(result => { |
| | | Api.getCacheConfig(_param).then(result => { |
| | | if (result.status) { |
| | | let config = '' |
| | | |
| | | try { |
| | | config = JSON.parse(window.decodeURIComponent(window.atob(result.LongParam))) |
| | | config = window.decodeURIComponent(window.atob(result.LongParam)) |
| | | config = config.replace(/@mywebsite@\//ig, window.GLOB.baseurl) |
| | | config = JSON.parse(config) |
| | | } catch (e) { |
| | | console.warn('Parse Failure') |
| | | config = '' |
| | |
| | | this.setState({ |
| | | viewlost: true, |
| | | loadingview: false, |
| | | lostmsg: this.state.dict['main.view.unenabled'] |
| | | lostmsg: '抱歉,您访问的页面未启用,请联系管理员。' |
| | | }) |
| | | return |
| | | } |
| | | |
| | | config.style = config.style || {} |
| | | config.zoom = 1 |
| | | if (config.webTitle) { |
| | | document.title = config.webTitle |
| | | } |
| | | |
| | | if (config.pageSize === 'A3') { |
| | | if (config.pageLayout === 'horizontal') { |
| | | config.zoom = 1.35 |
| | | config.style.height = 845 |
| | | } else { |
| | | config.style.height = 1695 |
| | | config.style = config.style || {} |
| | | config.pageSize = ['A4', 'A3', 'A5'].includes(config.pageSize) ? config.pageSize : 'A4' |
| | | config.pageLayout = config.pageLayout !== 'horizontal' ? 'vertical' : 'horizontal' |
| | | config.pagePadding = config.pagePadding !== 'without' ? 'default' : 'without' |
| | | |
| | | let pageParam = { |
| | | A4: { |
| | | vertical: 980, |
| | | horizontal: 1200, |
| | | verticaldefault: 1.455, |
| | | verticalwithout: 1.411, |
| | | horizontaldefault: 0.679, |
| | | horizontalwithout: 0.701, |
| | | }, |
| | | A3: { |
| | | vertical: 1200, |
| | | horizontal: 1600, |
| | | verticaldefault: 1.441, |
| | | verticalwithout: 1.410, |
| | | horizontaldefault: 0.688, |
| | | horizontalwithout: 0.703, |
| | | }, |
| | | A5: { |
| | | vertical: 700, |
| | | horizontal: 1000, |
| | | verticaldefault: 1.478, |
| | | verticalwithout: 1.413, |
| | | horizontaldefault: 0.669, |
| | | horizontalwithout: 0.700, |
| | | } |
| | | } else if (config.pageSize === 'A5') { |
| | | config.zoom = 0.7 |
| | | if (config.pageLayout === 'horizontal') { |
| | | config.style.height = 840 |
| | | } else { |
| | | config.style.height = 1700 |
| | | } |
| | | } else { |
| | | if (config.pageLayout === 'horizontal') { |
| | | config.style.height = 845 |
| | | } else { |
| | | config.style.height = 1680 |
| | | } |
| | | } |
| | | |
| | | config.width = pageParam[config.pageSize][config.pageLayout] |
| | | config.style.height = Math.floor(config.width * pageParam[config.pageSize][config.pageLayout + config.pagePadding]) |
| | | |
| | | if (config.printCustom === 'true' && config.printWidth && config.printHeight) { |
| | | config.width = config.printWidth |
| | | config.style.height = config.printHeight |
| | | } |
| | | |
| | | let params = [] |
| | | let _pars = [] |
| | | |
| | | config.components = config.components.filter(item => !['tabs', 'search'].includes(item.type) && item.subtype !== 'tablecard') |
| | | config.components = config.components.filter(item => !['tabs', 'search'].includes(item.type)) |
| | | |
| | | let urlparam = urlParam ? {...urlParam} : {} |
| | | if (config.urlFields && config.urlFields.length) { |
| | | config.urlFields.forEach(field => { |
| | | let key = field.toLowerCase() |
| | | if (urlparam[key] !== undefined) return |
| | | urlparam[key] = '' |
| | | }) |
| | | } |
| | | |
| | | if (window.backend && config.allSqls) { |
| | | let keys = Object.keys(urlparam) |
| | | config.allSqls.forEach(item => { |
| | | item.id = md5(window.GLOB.appkey + item.v_id) |
| | | if (['datasource', 'interface', 'excelOut'].includes(item.type)) { |
| | | item.urlkeys = keys |
| | | item.urlparam = urlparam |
| | | if (config.flow_code) { |
| | | item.works_flow_code = config.flow_code |
| | | } |
| | | } |
| | | window.GLOB.CacheData.set('sql_' + item.uuid, item) |
| | | }) |
| | | } |
| | | |
| | | let userName = sessionStorage.getItem('User_Name') || '' |
| | | let fullName = sessionStorage.getItem('Full_Name') || '' |
| | | |
| | | let regs = [ |
| | | { reg: /@userName@/ig, value: `'${userName}'` }, |
| | | { reg: /@fullName@/ig, value: `'${fullName}'` } |
| | | ] |
| | | |
| | | if (window.GLOB.externalDatabase !== null) { |
| | | regs.push({ |
| | | reg: /@db@/ig, |
| | | value: window.GLOB.externalDatabase |
| | | }) |
| | | } |
| | | |
| | | if (config.urlFields) { |
| | | config.urlFields.forEach(field => { |
| | | let val = `'${urlparam[field.toLowerCase()]}'` |
| | | regs.push({ |
| | | reg: new RegExp('@' + field + '@', 'ig'), |
| | | value: val |
| | | }) |
| | | }) |
| | | } |
| | | |
| | | window.GLOB.CacheData.set(tempId, {$BID: BID}) |
| | | |
| | | let initInters = [] |
| | | |
| | | this.formatInterSetting(config.interfaces, regs, initInters, params, BID, config.MenuName) |
| | | |
| | | config.components = config.components.map(component => { |
| | | if (component.action) component.action = [] |
| | | if (component.search) component.search = [] |
| | | if (component.action) { |
| | | component.action = component.action.filter(cell => { |
| | | cell = this.resetButton(component, cell) |
| | | cell.$toolbtn = true |
| | | |
| | | return !cell.hidden |
| | | }) |
| | | } |
| | | if (component.search) { |
| | | component.search = [] |
| | | component.$searches = [] |
| | | } |
| | | component.data = [] // 初始化数据为空 |
| | | |
| | | component.$menuname = (config.MenuName || '') + '-' + (component.name || '') |
| | | |
| | | if (component.subtype === 'tablecard') { // 兼容 |
| | | component.type = 'card' |
| | | } |
| | | |
| | | component.$pageId = tempId |
| | | if (component.setting && component.setting.supModule) { |
| | | let pid = component.setting.supModule.pop() |
| | | if (pid && pid !== 'empty') { |
| | | component.setting.supModule = pid |
| | | } else { |
| | | component.setting.supModule = '' |
| | | } |
| | | } |
| | | |
| | | if (component.type === 'table') { |
| | | let getColumns = (cols) => { |
| | | return cols.filter(item => { |
| | | if (item.Hide === 'true') return false |
| | | |
| | | item.IsSort = 'false' |
| | | |
| | | if (item.type === 'number') { |
| | | if (typeof(item.decimal) === 'number') { |
| | | item.round = Math.pow(10, item.decimal) |
| | | if (item.format === 'percent') { |
| | | item.decimal = item.decimal > 2 ? item.decimal - 2 : 0 |
| | | } |
| | | } |
| | | } else if (item.type === 'formula') { |
| | | if (typeof(item.decimal) === 'number') { |
| | | item.round = Math.pow(10, item.decimal) |
| | | } |
| | | } else if (item.type === 'colspan') { |
| | | item.subcols = getColumns(item.subcols) |
| | | if (item.subcols.length === 0) { |
| | | return false |
| | | } |
| | | } else if (item.type === 'custom') { |
| | | item.elements = item.elements.filter(cell => { |
| | | if (cell.eleType === 'button') { |
| | | cell = this.resetButton(component, cell) |
| | | |
| | | return !cell.hidden |
| | | } |
| | | |
| | | cell = this.resetElement(cell) |
| | | |
| | | return true |
| | | }) |
| | | if (item.elements.length === 0) { |
| | | return false |
| | | } |
| | | } else { |
| | | item.IsSort = 'false' |
| | | } |
| | | |
| | | if (item.marks && item.marks.length === 0) { |
| | | item.marks = null |
| | | } |
| | | |
| | | return true |
| | | }) |
| | | } |
| | | component.cols = getColumns(component.cols) |
| | | component.statFields = [] |
| | | } else if (['card', 'carousel', 'timeline'].includes(component.type)) { |
| | | component.subcards && component.subcards.forEach(card => { |
| | | if (card.style.boxShadow) { |
| | | delete card.style.hShadow |
| | | delete card.style.vShadow |
| | | delete card.style.shadowBlur |
| | | delete card.style.shadowColor |
| | | } |
| | | |
| | | card.elements = card.elements.filter(cell => { |
| | | if (cell.eleType === 'button') { |
| | | cell = this.resetButton(component, cell) |
| | | |
| | | return !cell.hidden |
| | | } |
| | | |
| | | cell = this.resetElement(cell) |
| | | |
| | | return true |
| | | }) |
| | | |
| | | if (!card.backElements || card.backElements.length === 0) return |
| | | |
| | | card.backElements = card.backElements.filter(cell => { |
| | | if (cell.eleType === 'button') { |
| | | cell = this.resetButton(component, cell) |
| | | |
| | | return !cell.hidden |
| | | } |
| | | |
| | | cell = this.resetElement(cell) |
| | | |
| | | return true |
| | | }) |
| | | }) |
| | | } else if (component.type === 'balcony') { |
| | | component.elements = component.elements.filter(cell => { |
| | | if (cell.eleType === 'button') { |
| | | cell = this.resetButton(component, cell) |
| | | |
| | | return !cell.hidden |
| | | } |
| | | |
| | | cell = this.resetElement(cell) |
| | | |
| | | return true |
| | | }) |
| | | } |
| | | |
| | | if (component.wrap && component.wrap.datatype === 'static') { |
| | | component.format = '' |
| | | } else if (component.wrap && component.wrap.datatype === 'public') { |
| | | component.componentId = component.wrap.publicId |
| | | component.format = '' |
| | | } |
| | | |
| | | if (!component.setting) return component // 不使用系统函数时 |
| | | if (!component.format || (component.subtype === 'propcard' && component.wrap.datatype === 'static')) return component // 没有动态数据 数据格式 array 或 object |
| | | if (!component.format) return component // 没有动态数据 数据格式 array 或 object |
| | | |
| | | component.setting.arr_field = component.columns ? component.columns.map(col => col.field).join(',') : '' |
| | | component.setting.laypage = false // 是否分页,转为boolean 统一格式 |
| | | component.setting.$name = component.$menuname |
| | | |
| | | if (component.format === 'object') { |
| | | component.setting.$top = true |
| | | } |
| | | |
| | | if (component.setting.interType !== 'system') { // 不使用系统函数时 |
| | | component.setting.sync = 'false' |
| | | return component |
| | | } |
| | | |
| | | component.setting.uuid = component.uuid |
| | | |
| | | let _customScript = '' |
| | | let _tailScript = '' |
| | | component.scripts && component.scripts.forEach(script => { |
| | | if (script.status !== 'false') { |
| | | if (script.status === 'false') return |
| | | if (script.position !== 'back') { |
| | | _customScript += ` |
| | | ${script.sql} |
| | | ` |
| | | } else { |
| | | _tailScript += ` |
| | | ${script.sql} |
| | | ` |
| | | } |
| | |
| | | delete component.scripts |
| | | |
| | | component.setting.execute = component.setting.execute !== 'false' // 默认sql是否执行,转为boolean 统一格式 |
| | | component.setting.laypage = false // 是否分页,转为boolean 统一格式 |
| | | component.setting.onload = 'true' // 默认加载 |
| | | |
| | | if (!component.setting.execute) { |
| | |
| | | component.setting.dataresource = '(' + component.setting.dataresource + ') tb' |
| | | } |
| | | |
| | | if (dataManager) { // 数据权限 |
| | | component.setting.dataresource = component.setting.dataresource.replace(/\$@/ig, '/*') |
| | | component.setting.dataresource = component.setting.dataresource.replace(/@\$/ig, '*/') |
| | | _customScript = _customScript.replace(/\$@/ig, '/*') |
| | | _customScript = _customScript.replace(/@\$/ig, '*/') |
| | | 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, '') |
| | | _customScript = _customScript.replace(/@\$|\$@/ig, '') |
| | | 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 // 后置自定义脚本 |
| | | |
| | | if (window.backend && config.allSqls) { |
| | | component.setting.sync = 'false' |
| | | } else if (_tailScript) { |
| | | component.setting.sync = 'false' |
| | | } |
| | | component.dataName = 'mk' + component.uuid.slice(-18) |
| | | |
| | | // floor 组件的层级 |
| | | // dataName 系统生成的数据源名称 |
| | | // pageable 是否分页,组件属性,不分页的组件才可以统一查询 |
| | | if (component.dataName && component.setting.sync === 'true') { |
| | | if (component.setting.sync === 'true') { |
| | | let param = this.getDefaultParam(component) |
| | | _pars.push(param) |
| | | } else { |
| | | let arr_field = component.columns.map(col => col.field).join(',') |
| | | let param = UtilsDM.getQueryDataParams(component.setting, arr_field, [], component.setting.order || '', 1, 1000, BID, '', dataManager) |
| | | } else if (component.subtype !== 'dualdatacard') { |
| | | let param = UtilsDM.getQueryDataParams(component.setting, [], component.setting.order || '', 1, 1000, BID) |
| | | |
| | | param.componentId = component.uuid |
| | | |
| | |
| | | return component |
| | | }) |
| | | |
| | | _pars = this.getFormatParam(_pars) |
| | | _pars = this.getFormatParam(_pars, config.MenuName) |
| | | |
| | | if (_pars) { |
| | | _pars.componentId = 'union' |
| | | _pars.componentId = '' |
| | | params.unshift(_pars) |
| | | } else if (window.backend && config.allSqls && params.length > 0) { |
| | | let data = [] |
| | | let ids = [] |
| | | params = params.filter(item => { |
| | | if (!item.$backend || item.public) return true |
| | | ids.push(item.componentId) |
| | | item.data[0].exps.forEach(cell => { |
| | | if (cell.key === 'mk_obj_name') { |
| | | cell.value = 'mk' + item.componentId.slice(-18) |
| | | } |
| | | }) |
| | | data.push(item.data[0]) |
| | | return false |
| | | }) |
| | | if (data.length > 0) { |
| | | params.push({ |
| | | $backend: true, |
| | | $type: 's_Get_TableData', |
| | | componentId: '', |
| | | componentIds: ids, |
| | | data |
| | | }) |
| | | } |
| | | } |
| | | |
| | | if (config.everyPCount && !config.printPage) { // 兼容 |
| | | config.printPage = 'page' |
| | | } |
| | | |
| | | config.printPage = config.printPage || 'auto' |
| | | |
| | | if (config.printPage === 'auto') { |
| | | config.everyPCount = 99999 |
| | | } |
| | | |
| | | config.limit = config.everyPCount || 15 |
| | | |
| | | this.setState({ |
| | | auto: config.printPage === 'auto', |
| | | config |
| | | }, () => { |
| | | if (params.length === 0) { |
| | | if (config.normalcss) { |
| | | let node = document.getElementById(config.uuid) |
| | | node && node.remove() |
| | | |
| | | let ele = document.createElement('style') |
| | | ele.id = config.uuid |
| | | ele.innerHTML = config.normalcss |
| | | document.getElementsByTagName('head')[0].appendChild(ele) |
| | | } |
| | | |
| | | if (params.length === 0 && initInters.length === 0) { |
| | | this.setState({loadingview: false, pages: [config.components]}) |
| | | |
| | | this.autoExec() |
| | | } else if (initInters.length > 0) { |
| | | this.loadinit(initInters, params) |
| | | } else { |
| | | this.loadmaindata(params) |
| | | } |
| | |
| | | }) |
| | | } |
| | | |
| | | resetButton = (item, cell) => { |
| | | cell.logLabel = item.$menuname + '-' + cell.label |
| | | cell.Ot = cell.Ot || 'requiredSgl' |
| | | cell.syncComponentId = '' |
| | | cell.$menuId = item.uuid |
| | | |
| | | cell.hidden = cell.hidden === 'true' |
| | | if (!['pop', 'prompt', 'exec', 'innerpage', 'form'].includes(cell.OpenType)) { |
| | | cell.hidden = true |
| | | } |
| | | |
| | | if (cell.controlField) { |
| | | if (/,/ig.test(cell.controlVal)) { |
| | | cell.controlVals = cell.controlVal.split(',') |
| | | } else { |
| | | cell.controlVals = [(cell.controlVal || '')] |
| | | } |
| | | } |
| | | |
| | | return cell |
| | | } |
| | | |
| | | resetElement = (cell) => { |
| | | cell.style = cell.style || {} |
| | | |
| | | if (cell.style.display === 'inline-block') { |
| | | cell.style.verticalAlign = 'top' |
| | | } |
| | | |
| | | if (cell.marks && cell.marks.length === 0) { |
| | | cell.marks = null |
| | | } |
| | | if (cell.anchors && cell.anchors.length === 0) { |
| | | cell.anchors = null |
| | | } |
| | | |
| | | if (['text', 'number', 'formula'].includes(cell.eleType)) { |
| | | 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.eleType === 'formula' && typeof(cell.decimal) === 'number') { |
| | | cell.round = Math.pow(10, cell.decimal) |
| | | } |
| | | } |
| | | |
| | | return cell |
| | | } |
| | | |
| | | formatInterSetting = (inters, regs, initInters, params, BID, MenuName) => { |
| | | if (!inters) return [] |
| | | |
| | | let delay = 15 |
| | | inters.forEach(inter => { |
| | | if (inter.status !== 'true') return |
| | | |
| | | inter.setting.delay = delay |
| | | delay += 15 |
| | | |
| | | inter.setting.supModule = '' |
| | | inter.setting.arr_field = inter.columns.map(col => col.field).join(',') |
| | | inter.setting.$name = (MenuName || '') + '-公共数据源-' + inter.setting.name |
| | | |
| | | if (inter.setting.interType !== 'system') { |
| | | let param = UtilsDM.getQueryDataParams(inter.setting, [], inter.setting.order || '', 1, 1000, BID) |
| | | |
| | | param.componentId = inter.uuid |
| | | |
| | | if (inter.setting.loadlevel === 'init') { |
| | | initInters.push(param) |
| | | } else { |
| | | param.public = true |
| | | params.push(param) |
| | | } |
| | | return |
| | | } |
| | | |
| | | inter.setting.uuid = inter.uuid |
| | | |
| | | let _customScript = '' |
| | | let _tailScript = '' |
| | | inter.scripts.forEach(script => { |
| | | if (script.status === 'false') return |
| | | if (script.position !== 'back') { |
| | | _customScript += ` |
| | | ${script.sql} |
| | | ` |
| | | } else { |
| | | _tailScript += ` |
| | | ${script.sql} |
| | | ` |
| | | } |
| | | }) |
| | | delete inter.scripts |
| | | |
| | | inter.setting.execute = inter.setting.execute !== 'false' |
| | | inter.setting.laypage = false |
| | | inter.setting.$top = true |
| | | |
| | | if (!inter.setting.execute) { |
| | | inter.setting.dataresource = '' |
| | | } |
| | | if (/\s/.test(inter.setting.dataresource)) { |
| | | inter.setting.dataresource = '(' + inter.setting.dataresource + ') tb' |
| | | } |
| | | |
| | | if (sessionStorage.getItem('dataM') === 'true') { // 数据权限 |
| | | inter.setting.dataresource = inter.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 { |
| | | inter.setting.dataresource = inter.setting.dataresource.replace(/@\$|\$@/ig, '').replace(/@datam@/ig, '\'\'') |
| | | _customScript = _customScript.replace(/@\$|\$@/ig, '').replace(/@datam@/ig, '\'\'') |
| | | _tailScript = _tailScript.replace(/@\$|\$@/ig, '').replace(/@datam@/ig, '\'\'') |
| | | } |
| | | |
| | | regs.forEach(cell => { |
| | | inter.setting.dataresource = inter.setting.dataresource.replace(cell.reg, cell.value) |
| | | _customScript = _customScript.replace(cell.reg, cell.value) |
| | | _tailScript = _tailScript.replace(cell.reg, cell.value) |
| | | }) |
| | | |
| | | inter.setting.customScript = _customScript // 整理后自定义脚本 |
| | | inter.setting.tailScript = _tailScript // 后置自定义脚本 |
| | | |
| | | let param = UtilsDM.getQueryDataParams(inter.setting, [], inter.setting.order || '', 1, 1000, BID) |
| | | |
| | | param.componentId = inter.uuid |
| | | |
| | | if (inter.setting.loadlevel === 'init') { |
| | | initInters.push(param) |
| | | } else { |
| | | param.public = true |
| | | params.push(param) |
| | | } |
| | | }) |
| | | } |
| | | |
| | | reload = () => { |
| | | const { tempId } = this.state |
| | | |
| | | this.setState({ |
| | | loadingview: true, |
| | | pages: null, |
| | | data: '', |
| | | config: null |
| | | }, () => { |
| | | Api.deleteMenuStorage(tempId) |
| | | setTimeout(() => { |
| | | this.getMenuParam() |
| | | }, 50) |
| | | }) |
| | | } |
| | | |
| | | /** |
| | | * @description 获取系统存储过程 sPC_Get_TableData 的参数 |
| | | * @description 获取系统存储过程参数 |
| | | */ |
| | | getDefaultParam = (component) => { |
| | | const { columns, setting, dataName, format } = component |
| | | |
| | | let arr_field = columns.map(col => col.field) |
| | | let _dataresource = setting.dataresource |
| | | let _customScript = setting.customScript |
| | | |
| | | if (setting.order && _dataresource) { |
| | | _dataresource = `select top 1000 ${arr_field.join(',')} from (select ${arr_field.join(',')} ,ROW_NUMBER() over(order by ${setting.order}) as rows from ${_dataresource}) tmptable order by tmptable.rows ` |
| | | _dataresource = `select top 1000 ${setting.arr_field} from (select ${setting.arr_field} ,ROW_NUMBER() over(order by ${setting.order}) as rows from ${_dataresource}) tmptable order by tmptable.rows ` |
| | | } else if (_dataresource) { |
| | | _dataresource = `select top 1000 ${arr_field.join(',')} from ${_dataresource} ` |
| | | } |
| | | |
| | | // 测试系统打印查询语句 |
| | | if ((options.sysType === 'local' && !window.GLOB.systemType) || window.debugger === true) { |
| | | _customScript && console.log(`${_dataresource ? '' : '/*不执行默认sql*/\n'}${_customScript}`) |
| | | _dataresource && console.log(_dataresource) |
| | | _dataresource = `select top 1000 ${setting.arr_field} from ${_dataresource} ` |
| | | } |
| | | |
| | | return { |
| | | name: dataName, |
| | | columns: columns, |
| | | par_tablename: '', |
| | | order: setting.order || '', |
| | | type: format === 'array' ? format : '', |
| | | primaryKey: setting.primaryKey || '', |
| | | foreign_key: '', |
| | | sql: _dataresource, |
| | | script: _customScript |
| | | script: _customScript, |
| | | } |
| | | } |
| | | |
| | | getFormatParam = (params) => { |
| | | getFormatParam = (params, MenuName) => { |
| | | const { BID } = this.state |
| | | |
| | | if (!params || params.length === 0) return '' |
| | | let LText_field = [] |
| | | |
| | | let userName = sessionStorage.getItem('User_Name') || '' |
| | | let fullName = sessionStorage.getItem('Full_Name') || '' |
| | | let RoleID = sessionStorage.getItem('role_id') || '' |
| | | let departmentcode = sessionStorage.getItem('departmentcode') || '' |
| | | let organization = sessionStorage.getItem('organization') || '' |
| | | let mk_user_type = sessionStorage.getItem('mk_user_type') || '' |
| | | let nation = sessionStorage.getItem('nation') || '' |
| | | let province = sessionStorage.getItem('province') || '' |
| | | let city = sessionStorage.getItem('city') || '' |
| | | let district = sessionStorage.getItem('district') || '' |
| | | let address = sessionStorage.getItem('address') || '' |
| | | |
| | | let regoptions = [ |
| | | { reg: /@pageSize@/ig, value: 9999 }, |
| | | { reg: /@pageIndex@/ig, value: 1}, |
| | | { reg: /@ID@/ig, value: `''`}, |
| | | { reg: /@BID@/ig, value: `'${BID || ''}'`}, |
| | | { reg: /@LoginUID@/ig, value: `'${sessionStorage.getItem('LoginUID') || ''}'`}, |
| | | { reg: /@SessionUid@/ig, value: `'${localStorage.getItem('SessionUid') || ''}'`}, |
| | | { reg: /@UserID@/ig, value: `'${sessionStorage.getItem('UserID') || ''}'`}, |
| | | { reg: /@Appkey@/ig, value: `'${window.GLOB.appkey || ''}'`}, |
| | | { reg: /@lang@/ig, value: `'${sessionStorage.getItem('lang')}'`}, |
| | | { reg: /@typename@/ig, value: `'admin'`}, |
| | | ] |
| | | |
| | | let LText = params.map((item, index) => { |
| | | let _sql = item.sql |
| | | let _script = item.script |
| | | |
| | | if (index === 0) { |
| | | _script = `declare @ErrorCode nvarchar(50),@retmsg nvarchar(4000) select @ErrorCode='',@retmsg ='' |
| | | _script = `declare @ErrorCode nvarchar(50),@retmsg nvarchar(4000),@UserName nvarchar(50),@FullName nvarchar(50),@RoleID nvarchar(512),@mk_departmentcode nvarchar(512),@mk_organization nvarchar(512),@mk_user_type nvarchar(20),@mk_nation nvarchar(50),@mk_province nvarchar(50),@mk_city nvarchar(50),@mk_district nvarchar(50),@mk_address nvarchar(100) |
| | | select @ErrorCode='',@retmsg ='',@UserName='${userName}', @FullName='${fullName}', @RoleID='${RoleID}', @mk_departmentcode='${departmentcode}', @mk_organization='${organization}', @mk_user_type='${mk_user_type}', @mk_nation='${nation}', @mk_province='${province}', @mk_city='${city}', @mk_district='${district}', @mk_address='${address}' |
| | | ${_script} |
| | | ` |
| | | } |
| | | |
| | | _sql = _sql.replace(/@orderBy@/ig, item.order) |
| | | _script = _script.replace(/@orderBy@/ig, item.order) |
| | | |
| | | regoptions.forEach(cell => { |
| | | _sql = _sql.replace(cell.reg, cell.value) |
| | | _script = _script.replace(cell.reg, cell.value) |
| | | }) |
| | | |
| | | // 测试系统打印查询语句 |
| | | if (window.GLOB.debugger === true) { |
| | | _script && window.mkInfo(`${_sql ? '' : '/*不执行默认sql*/\n'}${_script}`) |
| | | _sql && window.mkInfo(_sql) |
| | | } |
| | | |
| | | item.columns.forEach(cell => { |
| | |
| | | |
| | | let param = { |
| | | func: 'sPC_Get_structured_data', |
| | | LText: LText.join(' union all '), |
| | | LText_field: LText_field.join(' union all '), |
| | | BID: BID || '' |
| | | BID: BID || '', |
| | | username: userName, |
| | | fullName: fullName |
| | | } |
| | | |
| | | param.LText = Utils.formatOptions(param.LText) |
| | | param.LText_field = Utils.formatOptions(param.LText_field) |
| | | if (MenuName) { |
| | | param.menuname = MenuName |
| | | } |
| | | |
| | | param.exec_type = window.GLOB.execType || 'y' |
| | | param.LText = Utils.formatOptions(LText.join(' union all '), param.exec_type) |
| | | param.custom_script = Utils.formatOptions(LText_field.join(' union all '), param.exec_type) |
| | | |
| | | param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') |
| | | param.secretkey = Utils.encrypt(param.LText, param.timestamp) |
| | | param.secretkey = Utils.encrypt('', param.timestamp) |
| | | |
| | | return param |
| | | } |
| | | |
| | | loadinit = (initInters, params) => { |
| | | let deffers = initInters.map(item => { |
| | | let componentId = item.componentId |
| | | delete item.componentId |
| | | return new Promise(resolve => { |
| | | Api.genericInterface(item).then(res => { |
| | | if (!res.status) { |
| | | if (res.ErrCode !== '-2') { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: res.message, |
| | | duration: 5 |
| | | }) |
| | | } |
| | | resolve() |
| | | } else { |
| | | let _data = { $$empty: true } |
| | | if (res.data && res.data[0]) { |
| | | _data = res.data[0] |
| | | } |
| | | window.GLOB.CacheData.set(componentId, _data) |
| | | } |
| | | resolve() |
| | | }) |
| | | }) |
| | | }) |
| | | |
| | | Promise.all(deffers).then(() => { |
| | | if (params.length === 0) { |
| | | this.setState({loadingview: false, pages: [this.state.config.components]}) |
| | | |
| | | this.autoExec() |
| | | } else { |
| | | this.loadmaindata(params) |
| | | } |
| | | }) |
| | | } |
| | | |
| | | /** |
| | | * @description 主表数据加载 |
| | | */ |
| | | loadmaindata = (params) => { |
| | | const { components, everyPCount, firstCount, lastCount } = this.state.config |
| | | const { components, limit } = this.state.config |
| | | |
| | | let deffers = params.map(item => { |
| | | let componentId = item.componentId |
| | | let ids = item.componentIds |
| | | delete item.componentId |
| | | delete item.componentIds |
| | | delete item.public |
| | | return new Promise(resolve => { |
| | | Api.getLocalConfig(item).then(res => { |
| | | Api.genericInterface(item).then(res => { |
| | | if (!res.status) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: res.message, |
| | | duration: 5 |
| | | }) |
| | | if (item.func === 'sPC_Get_structured_data' && /将截断字符串或二进制数据/ig.test(res.message)) { |
| | | res.message = res.message + '请检查字段集' |
| | | } |
| | | if (res.ErrCode === 'version_up') { |
| | | this.reloadTabs() |
| | | } else if (res.ErrCode !== '-2') { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: res.message, |
| | | duration: 5 |
| | | }) |
| | | } |
| | | resolve(false) |
| | | } else if (ids) { |
| | | ids.forEach(id => { |
| | | let _id = 'mk' + id.slice(-18) |
| | | |
| | | if (res[_id]) { |
| | | let _data = { $$empty: true } |
| | | if (res[_id][0]) { |
| | | _data = res[_id][0] |
| | | } |
| | | window.GLOB.CacheData.set(id, _data) |
| | | } |
| | | }) |
| | | |
| | | resolve(res) |
| | | } else { |
| | | res.componentId = componentId |
| | | |
| | | let _data = { $$empty: true } |
| | | if (res.data && res.data[0]) { |
| | | _data = res.data[0] |
| | | } |
| | | window.GLOB.CacheData.set(componentId, _data) |
| | | |
| | | resolve(res) |
| | | } |
| | | }) |
| | |
| | | let _results = results.filter(Boolean) |
| | | |
| | | let comps = components.map(item => { |
| | | if (item.subtype === 'propcard' && item.wrap.datatype === 'static') return item |
| | | item.wrap = item.wrap || {} |
| | | item.data = null |
| | | |
| | | if (!item.format) return item |
| | | |
| | | if ((item.subtype === 'datacard' && item.wrap.layout !== 'flex') || item.type === 'table') { |
| | | item.$page = true |
| | | } |
| | | |
| | | _results.forEach(res => { |
| | | if (res.componentId === item.uuid && res.data) { |
| | | item.data = res.data |
| | | if ((res.componentId === item.uuid || res.componentId === item.componentId) && res.data) { |
| | | item.dataArray = fromJS(res.data).toJS() |
| | | } else if (res.componentId === 'union' && res[item.dataName]) { |
| | | item.data = res[item.dataName] |
| | | item.dataArray = fromJS(res[item.dataName]).toJS() |
| | | } else if (res[item.dataName]) { |
| | | let data = res[item.dataName] |
| | | if (!Array.isArray(data)) { |
| | | data = [data] |
| | | } |
| | | item.dataArray = fromJS(data).toJS() |
| | | } |
| | | }) |
| | | |
| | | if (item.$page && !item.dataArray) { |
| | | item.$page = false |
| | | } |
| | | |
| | | return item |
| | | }) |
| | |
| | | this.setState({loadingview: false, pages}) |
| | | } |
| | | |
| | | while (!over) { |
| | | let page = [] |
| | | let count = 0 |
| | | let _pageover = false |
| | | let pagesover = false |
| | | let setData = (item) => { |
| | | if (item.setting && item.setting.sync === 'true' && item.data) { |
| | | item.dataName = Utils.getuuid() |
| | | window.GLOB.SyncData.set(item.dataName, item.data) |
| | | } |
| | | } |
| | | |
| | | let limit = pageIndex === 1 ? (firstCount || 20) : (everyPCount || 20) |
| | | |
| | | comps.forEach((_item, index) => { |
| | | let item = fromJS(_item).toJS() |
| | | if (item.wrap && item.wrap.printType === 'headerOrfooter') { // 页眉页脚 |
| | | page.push(item) |
| | | } else if (_pageover) { |
| | | return |
| | | } else if (item.type === 'card' && item.subtype === 'datacard') { |
| | | if (!_item.dataArray || _item.dataArray.length === 0) return |
| | | |
| | | item.data = [] |
| | | |
| | | while (count < limit && _item.dataArray.length > 0) { |
| | | item.data.push(_item.dataArray.shift()) |
| | | count++ |
| | | } |
| | | |
| | | if (count >= limit) { |
| | | _pageover = true |
| | | } |
| | | page.push(item) |
| | | } else { |
| | | page.push(item) |
| | | } |
| | | |
| | | if (index + 1 === length && !_pageover) { |
| | | pagesover = true |
| | | } |
| | | }) |
| | | |
| | | if (pagesover && lastCount && count > lastCount) { |
| | | pagesover = false |
| | | page = [] |
| | | count = 0 |
| | | _pageover = false |
| | | |
| | | if (pageIndex === 1) { |
| | | limit = (everyPCount - firstCount) + (everyPCount - lastCount) |
| | | |
| | | if (limit <= 0) { |
| | | limit = firstCount |
| | | } |
| | | } else { |
| | | limit = lastCount |
| | | } |
| | | |
| | | comps.forEach((_item, index) => { |
| | | let item = fromJS(_item).toJS() |
| | | if (item.wrap && item.wrap.printType === 'headerOrfooter') { // 页眉页脚 |
| | | page.push(item) |
| | | } else if (_pageover) { |
| | | return |
| | | } else if (item.type === 'card' && item.subtype === 'datacard') { |
| | | if (!_item.dataArray || _item.dataArray.length === 0) return |
| | | if (this.state.config.printPage === 'custom' && this.state.config.printScripts) { |
| | | try { |
| | | // eslint-disable-next-line |
| | | let func = new Function('components', 'pages', 'notification', this.state.config.printScripts) |
| | | func(comps, pages, notification) |
| | | } catch (e) { |
| | | console.warn(e) |
| | | |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '自定义脚本执行错误!', |
| | | duration: 5 |
| | | }) |
| | | } |
| | | } else { |
| | | while (!over) { |
| | | let page = [] |
| | | let count = 0 |
| | | let _pageover = false |
| | | |
| | | comps.forEach(comp => { |
| | | let item = fromJS(comp).toJS() |
| | | |
| | | if (item.wrap.printType === 'headerOrfooter') { // 页眉页脚 |
| | | item.data = item.dataArray || null |
| | | setData(item) |
| | | page.push(item) |
| | | comp.added = true |
| | | } |
| | | |
| | | if (_pageover) return |
| | | |
| | | if (item.$page && comp.dataArray.length > 0) { |
| | | item.data = [] |
| | | |
| | | while (count < limit && _item.dataArray.length > 0) { |
| | | item.data.push(_item.dataArray.shift()) |
| | | while (count + 1 <= limit && comp.dataArray.length > 0) { |
| | | item.data.push(comp.dataArray.shift()) |
| | | count++ |
| | | } |
| | | |
| | | if (count >= limit) { |
| | | if (count >= limit || comp.dataArray.length > 0) { |
| | | _pageover = true |
| | | } |
| | | page.push(item) |
| | | } else { |
| | | page.push(item) |
| | | } |
| | | |
| | | if (index + 1 === length && !_pageover) { |
| | | pagesover = true |
| | | if (comp.dataArray.length === 0) { |
| | | comp.added = true |
| | | } |
| | | |
| | | setData(item) |
| | | page.push(item) |
| | | } else if (!comp.added) { |
| | | if (item.wrap.printHeight) { |
| | | count += item.wrap.printHeight |
| | | if (count >= limit) { |
| | | _pageover = true |
| | | return |
| | | } |
| | | } |
| | | |
| | | item.data = item.dataArray || null |
| | | |
| | | setData(item) |
| | | page.push(item) |
| | | comp.added = true |
| | | } |
| | | }) |
| | | } |
| | | |
| | | pages.push(page) |
| | | pageIndex++ |
| | | |
| | | if (pageIndex >= 2000 || pagesover) { |
| | | over = true |
| | | |
| | | pages.push(page) |
| | | pageIndex++ |
| | | |
| | | if (pageIndex >= 2000 || comps.findIndex(comp => !comp.added) === -1) { |
| | | over = true |
| | | } |
| | | } |
| | | } |
| | | |
| | | this.setState({loadingview: false, pages}) |
| | | let total = pages.length |
| | | let date = moment().format('YYYY-MM-DD') |
| | | let datetime = moment().format('YYYY-MM-DD HH:mm:ss') |
| | | let rePos = false |
| | | |
| | | pages.forEach((page, index) => { |
| | | page.forEach(item => { |
| | | if (item.wrap.printType === 'headerOrfooter') { // 页眉页脚 |
| | | if (item.type === 'balcony') { |
| | | if (item.style.position === 'absolute') { |
| | | rePos = true |
| | | } |
| | | item.elements.forEach(cell => { |
| | | if (cell.eleType === 'text' && cell.datatype === 'static') { |
| | | cell.value = cell.value.replace(/@total@/ig, total).replace(/@pageIndex@/ig, index + 1).replace(/@date@/ig, date).replace(/@datetime@/ig, datetime) |
| | | } |
| | | }) |
| | | } else if (item.subtype === 'propcard') { |
| | | item.subcards.forEach(card => { |
| | | card.elements.forEach(cell => { |
| | | if (cell.eleType === 'text' && cell.datatype === 'static') { |
| | | cell.value = cell.value.replace(/@total@/ig, total).replace(/@pageIndex@/ig, index + 1).replace(/@date@/ig, date).replace(/@datetime@/ig, datetime) |
| | | } |
| | | }) |
| | | }) |
| | | } |
| | | } |
| | | }) |
| | | }) |
| | | |
| | | this.setState({loadingview: false, pages, rePos}) |
| | | |
| | | this.autoExec() |
| | | }) |
| | | } |
| | | |
| | | print = () => { |
| | | autoExec = () => { |
| | | const { config } = this.state |
| | | |
| | | let jubuData = document.getElementById('bill-print').innerHTML |
| | | window.document.body.innerHTML = jubuData |
| | | document.getElementsByTagName('body')[0].style.width = '1200px' |
| | | document.getElementsByTagName('body')[0].style.margin = '0 auto' |
| | | document.getElementsByTagName('body')[0].style.zoom = config.zoom |
| | | if (config.autoExec !== 'true') return |
| | | |
| | | try { |
| | | if (window.ActiveXObject) { |
| | | let hkeyRoot |
| | | let hkeyPath |
| | | let hkeyKey |
| | | // eslint-disable-next-line |
| | | let RegWsh = new ActiveXObject('WScript.Shell') |
| | | setTimeout(() => { |
| | | this.print() |
| | | }, config.autoExecSplit || 500) |
| | | } |
| | | |
| | | hkeyRoot = 'HKEY_CURRENT_USER' |
| | | hkeyPath = '\\Software\\Microsoft\\Internet Explorer\\PageSetup\\' |
| | | reloadTabs = () => { |
| | | if (this.reloading) return |
| | | |
| | | // 设置页眉/脚的字体样式 |
| | | hkeyKey = 'font' |
| | | RegWsh.RegWrite(hkeyRoot + hkeyPath + hkeyKey, 'font-size: 12px; font-family: 黑体; line-height: 24px') |
| | | let time = new Date().getTime() |
| | | |
| | | // 设置页眉 |
| | | hkeyKey = 'header' |
| | | RegWsh.RegWrite(hkeyRoot + hkeyPath + hkeyKey, '打印编号') |
| | | let oldTime = sessionStorage.getItem('mk_reloadTabs') |
| | | |
| | | if (oldTime && time - oldTime < 180000) return |
| | | |
| | | // 设置页脚 |
| | | hkeyKey = 'footer' |
| | | RegWsh.RegWrite(hkeyRoot + hkeyPath + hkeyKey, '&b第 &p 页/共 &P 页') |
| | | sessionStorage.setItem('mk_reloadTabs', time) |
| | | |
| | | // 设置页边距(0.6 要乘以 2.5为实际打印的尺寸) |
| | | hkeyKey = 'margin_bottom' |
| | | RegWsh.RegWrite(hkeyRoot + hkeyPath + hkeyKey, '0.6') |
| | | this.reloading = true |
| | | |
| | | hkeyKey = 'margin_left' |
| | | RegWsh.RegWrite(hkeyRoot + hkeyPath + hkeyKey, '0.6') |
| | | Api.getAppVersion(true).then(() => { |
| | | window.location.reload() |
| | | }, (message) => { |
| | | Modal.error({ |
| | | title: message || '系统配置更新失败!', |
| | | }) |
| | | }) |
| | | } |
| | | |
| | | hkeyKey = 'margin_right' |
| | | RegWsh.RegWrite(hkeyRoot + hkeyPath + hkeyKey, '0.6') |
| | | canvasToImage(canvas) { |
| | | let image = new Image() |
| | | image.src = canvas.toDataURL('image/jpg') |
| | | image.style = 'width:100%;height:100%;position:absolute;z-index:1;left:0px;top:0px;' |
| | | return image |
| | | } |
| | | |
| | | hkeyKey = 'margin_top' |
| | | RegWsh.RegWrite(hkeyRoot + hkeyPath + hkeyKey, '0.6') |
| | | chartToImage(canvas) { |
| | | let image = new Image() |
| | | image.src = canvas.toDataURL('image/jpg') |
| | | image.style = `width:100%;height:${canvas.style.height || '100%'};` |
| | | return image |
| | | } |
| | | |
| | | window.print() |
| | | } else { |
| | | window.print() |
| | | print = () => { |
| | | const { config, printing, BID, tempId, pageId } = this.state |
| | | |
| | | if (printing) return |
| | | |
| | | this.setState({printing: true}) |
| | | |
| | | if (config.callback === 'true') { |
| | | this.setState({loading: true}) |
| | | |
| | | Api.genericInterface({ |
| | | func: 's_print_proc', |
| | | username: sessionStorage.getItem('User_Name') || '', |
| | | fullname: sessionStorage.getItem('Full_Name') || '', |
| | | BID: BID || '', |
| | | print_type: config.callNo || '', |
| | | MenuNo: config.MenuNo || '', |
| | | Menuid: tempId || '' |
| | | }).then(res => { |
| | | if (!res.status) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: res.message || '执行失败!', |
| | | duration: 5 |
| | | }) |
| | | |
| | | this.setState({printing: false, loading: false}) |
| | | return |
| | | } |
| | | |
| | | let refresh = !/@no_target_menu@/i.test(res.message) |
| | | |
| | | this.setState({loading: false}) |
| | | |
| | | if (pageId && refresh) { |
| | | localStorage.setItem('menuUpdate', new Date().getTime() + ',' + pageId + ',menu') |
| | | } |
| | | |
| | | setTimeout(() => { |
| | | this.execPrint() |
| | | }, 300) |
| | | }) |
| | | } else { |
| | | this.execPrint() |
| | | } |
| | | } |
| | | |
| | | execPrint = () => { |
| | | const { config } = this.state |
| | | |
| | | let qrcodes = document.getElementsByClassName('qrcode-box') |
| | | |
| | | for (let i = 0; i < qrcodes.length; i++) { |
| | | let canvas = qrcodes[i].getElementsByTagName('canvas')[0] |
| | | |
| | | if (canvas) { |
| | | let img = this.canvasToImage(canvas) |
| | | |
| | | canvas.remove() |
| | | qrcodes[i].append(img) |
| | | } |
| | | } |
| | | |
| | | let charts = document.getElementsByTagName('canvas') |
| | | |
| | | if (charts.length) { |
| | | for (let i = 0; i < charts.length; i++) { |
| | | let img = this.chartToImage(charts[i]) |
| | | let parentNode = charts[i].parentNode |
| | | |
| | | parentNode.append(img) |
| | | } |
| | | |
| | | document.getElementsByTagName('body')[0].style.zoom = 1 |
| | | while (charts[0]) { |
| | | charts[0].remove() |
| | | } |
| | | } |
| | | |
| | | let jubuData = document.getElementById('bill-print').innerHTML |
| | | |
| | | try { |
| | | let iframe = document.createElement('IFRAME') |
| | | let linkList = document.getElementsByTagName('link') // 获取父窗口link标签对象列表 |
| | | let styleList = document.getElementsByTagName('style') // 获取父窗口style标签对象列表 |
| | | |
| | | iframe.style.marginTop = '600px' |
| | | document.body.appendChild(iframe) |
| | | let doc = iframe.contentWindow.document |
| | | |
| | | doc.open() |
| | | doc.write(`<!DOCTYPE html><html lang="en"><head>`) |
| | | for (let i = 0;i < linkList.length;i++) { |
| | | if (linkList[i].type === 'text/css') { |
| | | doc.write(`<LINK rel="stylesheet" type="text/css" href="${linkList[i].href}">`) |
| | | } |
| | | } |
| | | doc.write(`<style>body{width: ${config.width}px!important;}*{border-style: solid;border-width: 0;}.ant-table-placeholder{display: none;}.ant-empty{display: none;}</style>`) |
| | | for (let i = 0;i < styleList.length;i++) { |
| | | doc.write('<style>' + styleList[i].innerHTML + '</style>') |
| | | } |
| | | doc.write(`</head><body>`) |
| | | doc.write(jubuData) |
| | | doc.write(`</body></html>`) |
| | | doc.close() |
| | | |
| | | setTimeout(() => { |
| | | window.close() |
| | | }, 2000) |
| | | iframe.contentWindow.focus() |
| | | iframe.contentWindow.print() |
| | | |
| | | document.body.removeChild(iframe) |
| | | |
| | | setTimeout(() => { |
| | | window.close() |
| | | }, 2000) |
| | | }, 500) |
| | | } catch (e) { |
| | | notification.warning({ |
| | | top: 92, |
| | |
| | | } |
| | | |
| | | getComponents = (components) => { |
| | | const { dataManager } = this.state |
| | | |
| | | return components.map(item => { |
| | | let style = null |
| | | |
| | | if (item.style && item.style.clear === 'left') { |
| | | style = {clear: 'left'} |
| | | } else if (item.style && item.style.clear === 'right') { |
| | | style = {float: 'right'} |
| | | } |
| | | |
| | | if (item.type === 'bar' || item.type === 'line') { |
| | | return ( |
| | | <Col span={item.width} key={item.uuid}> |
| | | <AntvBarAndLine config={item} initdata={item.data} mainSearch={[]} menuType="" dataManager={dataManager} /> |
| | | <Col span={item.width} style={style} key={item.uuid}> |
| | | <AntvBarAndLine config={item}/> |
| | | </Col> |
| | | ) |
| | | } else if (item.type === 'pie') { |
| | | return ( |
| | | <Col span={item.width} key={item.uuid}> |
| | | <AntvPie config={item} initdata={item.data} mainSearch={[]} menuType="" dataManager={dataManager} /> |
| | | <Col span={item.width} style={style} key={item.uuid}> |
| | | <AntvPie config={item} /> |
| | | </Col> |
| | | ) |
| | | } else if (item.type === 'scatter') { |
| | | return ( |
| | | <Col span={item.width} style={style} key={item.uuid}> |
| | | <AntvScatter config={item}/> |
| | | </Col> |
| | | ) |
| | | } else if (item.type === 'dashboard') { |
| | | return ( |
| | | <Col span={item.width} style={style} key={item.uuid}> |
| | | <AntvDashboard config={item}/> |
| | | </Col> |
| | | ) |
| | | } else if (item.type === 'card' && item.subtype === 'datacard') { |
| | | return ( |
| | | <Col span={item.width} key={item.uuid}> |
| | | <DataCard config={item} initdata={item.data} mainSearch={[]} menuType="" dataManager={dataManager} /> |
| | | <Col span={item.width} style={style} key={item.uuid}> |
| | | <DataCard config={item} /> |
| | | </Col> |
| | | ) |
| | | } else if (item.type === 'card' && item.subtype === 'propcard') { |
| | | return ( |
| | | <Col span={item.width} key={item.uuid}> |
| | | <PropCard config={item} initdata={item.data} mainSearch={[]} menuType="" dataManager={dataManager} /> |
| | | <Col span={item.width} style={style} key={item.uuid}> |
| | | <PropCard config={item} /> |
| | | </Col> |
| | | ) |
| | | } else if (item.type === 'card' && item.subtype === 'dualdatacard') { |
| | | return ( |
| | | <Col span={item.width} style={style} key={item.uuid}> |
| | | <DoubleDataCard config={item}/> |
| | | </Col> |
| | | ) |
| | | } else if (item.type === 'card' && item.subtype === 'tablecard') { |
| | | return ( |
| | | <Col span={item.width} style={style} key={item.uuid}> |
| | | <TableCard config={item}/> |
| | | </Col> |
| | | ) |
| | | } else if (item.type === 'table' && item.subtype === 'normaltable') { |
| | | return ( |
| | | <Col span={item.width} style={style} key={item.uuid}> |
| | | <NormalTable config={item}/> |
| | | </Col> |
| | | ) |
| | | } else if (item.type === 'code') { |
| | | return ( |
| | | <Col span={item.width} style={style} key={item.uuid}> |
| | | <SandBox config={item}/> |
| | | </Col> |
| | | ) |
| | | } else if (item.type === 'balcony') { |
| | | if (item.wrap.printType === 'headerOrfooter' && item.style.position === 'absolute') { |
| | | return ( |
| | | <Balcony key={item.uuid} config={item}/> |
| | | ) |
| | | } else { |
| | | return ( |
| | | <Col span={item.width} style={style} key={item.uuid}> |
| | | <Balcony config={item}/> |
| | | </Col> |
| | | ) |
| | | } |
| | | } else if (item.type === 'timeline') { |
| | | return ( |
| | | <Col span={item.width} style={style} key={item.uuid}> |
| | | <TimeLine config={item}/> |
| | | </Col> |
| | | ) |
| | | } else if (item.type === 'editor') { |
| | | return ( |
| | | <Col span={item.width} style={style} key={item.uuid}> |
| | | <BraftEditor config={item}/> |
| | | </Col> |
| | | ) |
| | | } else if (item.type === 'antvG6') { |
| | | return ( |
| | | <Col span={item.width} style={style} key={item.uuid}> |
| | | <AntvG6 config={item}/> |
| | | </Col> |
| | | ) |
| | | } else if (item.type === 'antvX6') { |
| | | return ( |
| | | <Col span={item.width} style={style} key={item.uuid}> |
| | | <AntvX6 config={item}/> |
| | | </Col> |
| | | ) |
| | | } else { |
| | |
| | | } |
| | | |
| | | render() { |
| | | const { loadingview, viewlost, config, pages } = this.state |
| | | const { loadingview, viewlost, config, pages, auto, rePos, loading, ismob } = this.state |
| | | |
| | | return ( |
| | | <div className="bill-print-wrap" > |
| | | {loadingview && <Spin size="large" />} |
| | | {loadingview || loading ? <Spin size="large" /> : null} |
| | | {pages ? <div id="bill-print"> |
| | | {pages.map((components, index) => (<div className="print-page" key={index} style={{...config.style, overflow: 'hidden'}}><Row>{this.getComponents(components)}</Row></div>))} |
| | | {pages.map((components, index) => (<div className={'print-page' + (auto ? ' auto' : '') + (rePos ? ' reset-position' : '')} key={index} style={{...config.style, overflow: 'hidden', boxSizing: 'border-box'}}><Row className="component-wrap">{this.getComponents(components)}</Row></div>))} |
| | | </div> : null} |
| | | {viewlost ? <NotFount msg={this.state.lostmsg} /> : null} |
| | | {pages && !loadingview && !viewlost ? <div className="print-button"><Button icon="printer" size="large" shape="circle" onClick={this.print}></Button></div> : null} |
| | | {config && window.GLOB.breakpoint ? <DebugTable /> : null} |
| | | {pages && !loadingview && !viewlost && !ismob ? <div className="print-button"><Button icon="printer" size="large" shape="circle" onClick={this.print}></Button></div> : null} |
| | | {!loadingview && !viewlost && !ismob ? <div className="refresh-button"><Button icon="reload" size="large" shape="circle" onClick={this.reload}></Button></div> : null} |
| | | </div> |
| | | ) |
| | | } |