| | |
| | | const AntvPie = asyncComponent(() => import('@/tabviews/custom/components/chart/antv-pie')) |
| | | const DataCard = asyncComponent(() => import('@/tabviews/custom/components/card/data-card')) |
| | | const PropCard = asyncComponent(() => import('@/tabviews/custom/components/card/prop-card')) |
| | | const TableCard = asyncComponent(() => import('@/tabviews/custom/components/card/table-card')) |
| | | const NormalTable = asyncComponent(() => import('@/tabviews/custom/components/table/normal-table')) |
| | | const BraftEditor = asyncComponent(() => import('@/tabviews/custom/components/editor/braft-editor')) |
| | | const SandBox = asyncComponent(() => import('@/tabviews/custom/components/code/sand-box')) |
| | | |
| | | class BillPrint extends Component { |
| | | state = { |
| | | dict: localStorage.getItem('lang') !== 'en-US' ? zhCN : enUS, |
| | | dict: sessionStorage.getItem('lang') !== 'en-US' ? zhCN : enUS, |
| | | loadingview: true, |
| | | dataManager: false, |
| | | printing: false, |
| | | pages: null, |
| | | BID: '', |
| | | data: '', |
| | |
| | | UNSAFE_componentWillMount() { |
| | | try { |
| | | let param = JSON.parse(window.decodeURIComponent(window.atob(this.props.match.params.param))) |
| | | |
| | | sessionStorage.setItem('dataM', param.dataM || '') |
| | | sessionStorage.setItem('localDataM', param.dataM || '') |
| | | this.setState({ |
| | | BID: param.id || '', |
| | | tempId: param.tempId, |
| | | dataManager: param.dataManager |
| | | tempId: param.tempId |
| | | }, () => { |
| | | this.getMenuParam() |
| | | }) |
| | |
| | | } |
| | | |
| | | getMenuParam = () => { |
| | | const { tempId, BID, dataManager } = this.state |
| | | const { tempId, BID } = this.state |
| | | |
| | | let _param = { |
| | | func: 'sPC_Get_LongParam', |
| | |
| | | } |
| | | |
| | | 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' |
| | | |
| | | if (config.pageSize === 'A0') { |
| | | if (config.pageLayout === 'horizontal') { |
| | | config.style.height = 1305 |
| | | } else { |
| | | config.style.height = 1305 |
| | | } |
| | | } else if (config.pageSize === 'A1') { |
| | | if (config.pageLayout === 'horizontal') { |
| | | config.style.height = 1305 |
| | | } else { |
| | | config.style.height = 1305 |
| | | } |
| | | } else if (config.pageSize === 'A2') { |
| | | if (config.pageLayout === 'horizontal') { |
| | | config.style.height = 1305 |
| | | } else { |
| | | config.style.height = 1305 |
| | | } |
| | | } else if (config.pageSize === 'A3') { |
| | | if (config.pageLayout === 'horizontal') { |
| | | config.style.height = 1305 |
| | | } else { |
| | | config.style.height = 1305 |
| | | } |
| | | } else if (config.pageSize === 'A5') { |
| | | if (config.pageLayout === 'horizontal') { |
| | | config.style.height = 1305 |
| | | } else { |
| | | config.style.height = 1305 |
| | | } |
| | | } else { |
| | | if (config.pageLayout === 'horizontal') { |
| | | config.style.height = 895 |
| | | } else { |
| | | config.style.height = 1305 |
| | | 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, |
| | | } |
| | | } |
| | | |
| | | // config.style.height = 895 |
| | | 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)) |
| | | config.components = config.components.map(component => { |
| | | if (component.action) component.action = [] |
| | | if (component.search) component.search = [] |
| | | component.data = [] // 初始化数据为空 |
| | | |
| | | if (['propcard', 'brafteditor', 'sandbox'].includes(component.subtype) && component.wrap.datatype === 'static') { |
| | | 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 |
| | | if (component.setting.interType !== 'system') { // 不使用系统函数时 |
| | | component.setting.sync = 'false' |
| | | return component |
| | |
| | | component.setting.dataresource = '(' + component.setting.dataresource + ') tb' |
| | | } |
| | | |
| | | if (dataManager) { // 数据权限 |
| | | if (sessionStorage.getItem('dataM') === 'true') { // 数据权限 |
| | | component.setting.dataresource = component.setting.dataresource.replace(/\$@/ig, '/*') |
| | | component.setting.dataresource = component.setting.dataresource.replace(/@\$/ig, '*/') |
| | | _customScript = _customScript.replace(/\$@/ig, '/*') |
| | |
| | | _customScript = _customScript.replace(/@\$|\$@/ig, '') |
| | | } |
| | | |
| | | component.setting.dataresource = component.setting.dataresource.replace(/@BID@/ig, BID) |
| | | _customScript = _customScript.replace(/@BID@/ig, BID) |
| | | // 外联数据库替换 |
| | | if (window.GLOB.externalDatabase !== null) { |
| | | component.setting.dataresource = component.setting.dataresource.replace(/@db@/ig, window.GLOB.externalDatabase) |
| | | _customScript = _customScript.replace(/@db@/ig, window.GLOB.externalDatabase) |
| | | } |
| | | |
| | | component.setting.customScript = _customScript // 整理后自定义脚本 |
| | | |
| | |
| | | _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) |
| | | let param = UtilsDM.getQueryDataParams(component.setting, arr_field, [], component.setting.order || '', 1, 1000, BID, '') |
| | | |
| | | param.componentId = component.uuid |
| | | |
| | |
| | | }) |
| | | } |
| | | |
| | | reload = () => { |
| | | this.setState({ |
| | | loadingview: true, |
| | | pages: null, |
| | | data: '', |
| | | config: null |
| | | }, () => { |
| | | this.getMenuParam() |
| | | }) |
| | | } |
| | | |
| | | /** |
| | | * @description 获取系统存储过程 sPC_Get_TableData 的参数 |
| | | */ |
| | |
| | | |
| | | // 测试系统打印查询语句 |
| | | if ((options.sysType === 'local' && !window.GLOB.systemType) || window.debugger === true) { |
| | | _customScript && console.log(`${_dataresource ? '' : '/*不执行默认sql*/\n'}${_customScript}`) |
| | | _dataresource && console.log(_dataresource) |
| | | _customScript && console.info(`${_dataresource ? '' : '/*不执行默认sql*/\n'}${_customScript}`) |
| | | _dataresource && console.info(_dataresource) |
| | | } |
| | | |
| | | return { |
| | |
| | | } |
| | | |
| | | getFormatParam = (params) => { |
| | | const { BID } = this.state |
| | | |
| | | if (!params || params.length === 0) return '' |
| | | let LText_field = [] |
| | | let LText = params.map((item, index) => { |
| | |
| | | let param = { |
| | | func: 'sPC_Get_structured_data', |
| | | LText: LText.join(' union all '), |
| | | LText_field: LText_field.join(' union all ') |
| | | LText_field: LText_field.join(' union all '), |
| | | BID: BID || '' |
| | | } |
| | | |
| | | param.LText = Utils.formatOptions(param.LText) |
| | |
| | | let _results = results.filter(Boolean) |
| | | |
| | | let comps = components.map(item => { |
| | | if (item.subtype === 'propcard' && item.wrap.datatype === 'static') return item |
| | | if (!item.format) return item |
| | | |
| | | _results.forEach(res => { |
| | | if (res.componentId === item.uuid && res.data) { |
| | |
| | | this.setState({loadingview: false, pages}) |
| | | } |
| | | |
| | | // everyPCount, firstCount, lastCount |
| | | while (!over) { |
| | | let page = [] |
| | | let count = 0 |
| | |
| | | |
| | | comps.forEach((_item, index) => { |
| | | let item = fromJS(_item).toJS() |
| | | |
| | | if (index + 1 >= length && !_pageover) { |
| | | pagesover = true |
| | | } |
| | | |
| | | 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 |
| | | } else if (item.subtype === 'datacard' || item.type === 'table') { |
| | | if (_item.dataArray && _item.dataArray.length > 0) { |
| | | item.data = [] |
| | | |
| | | item.data = [] |
| | | |
| | | while (count < limit && _item.dataArray.length > 0) { |
| | | item.data.push(_item.dataArray.shift()) |
| | | count++ |
| | | while (count < limit && _item.dataArray.length > 0) { |
| | | item.data.push(_item.dataArray.shift()) |
| | | count++ |
| | | } |
| | | |
| | | if (count >= limit) { |
| | | _pageover = true |
| | | } |
| | | page.push(item) |
| | | } |
| | | |
| | | if (count >= limit) { |
| | | _pageover = true |
| | | } |
| | | page.push(item) |
| | | } else { |
| | | } else if (!item.added) { |
| | | _item.added = true |
| | | page.push(item) |
| | | } |
| | | |
| | | if (index + 1 === length && !_pageover) { |
| | | if (index + 1 >= length && !_pageover) { |
| | | pagesover = true |
| | | } |
| | | }) |
| | |
| | | page.push(item) |
| | | } else if (_pageover) { |
| | | return |
| | | } else if (item.type === 'card' && item.subtype === 'datacard') { |
| | | if (!_item.dataArray || _item.dataArray.length === 0) return |
| | | } else if (item.subtype === 'datacard' || item.type === 'table') { |
| | | if (_item.dataArray && _item.dataArray.length > 0) { |
| | | item.data = [] |
| | | |
| | | item.data = [] |
| | | |
| | | while (count < limit && _item.dataArray.length > 0) { |
| | | item.data.push(_item.dataArray.shift()) |
| | | count++ |
| | | while (count < limit && _item.dataArray.length > 0) { |
| | | item.data.push(_item.dataArray.shift()) |
| | | count++ |
| | | } |
| | | |
| | | if (count >= limit) { |
| | | _pageover = true |
| | | } |
| | | page.push(item) |
| | | } |
| | | |
| | | if (count >= limit) { |
| | | _pageover = true |
| | | } |
| | | page.push(item) |
| | | } else { |
| | | } else if (!item.added) { |
| | | _item.added = true |
| | | page.push(item) |
| | | } |
| | | |
| | |
| | | pages.push(page) |
| | | pageIndex++ |
| | | |
| | | if (pageIndex >= 2000 || pagesover) { |
| | | if (pageIndex >= 200 || pagesover) { |
| | | over = true |
| | | } |
| | | } |
| | |
| | | } |
| | | |
| | | print = () => { |
| | | let bdhtml = window.document.body.innerHTML |
| | | const { config, printing } = this.state |
| | | |
| | | if (printing) return |
| | | |
| | | let jubuData = document.getElementById('bill-print').innerHTML |
| | | window.document.body.innerHTML = jubuData |
| | | document.getElementsByTagName('body')[0].style.zoom = 0.8 |
| | | |
| | | this.setState({printing: true}) |
| | | |
| | | try { |
| | | if (window.ActiveXObject) { |
| | | let hkeyRoot |
| | | let hkeyPath |
| | | let hkeyKey |
| | | // eslint-disable-next-line |
| | | let RegWsh = new ActiveXObject('WScript.Shell') |
| | | let iframe = document.createElement('IFRAME') |
| | | let linkList = document.getElementsByTagName('link') // 获取父窗口link标签对象列表 |
| | | let styleList = document.getElementsByTagName('style') // 获取父窗口style标签对象列表 |
| | | |
| | | hkeyRoot = 'HKEY_CURRENT_USER' |
| | | hkeyPath = '\\Software\\Microsoft\\Internet Explorer\\PageSetup\\' |
| | | |
| | | // 设置页眉/脚的字体样式 |
| | | hkeyKey = 'font' |
| | | RegWsh.RegWrite(hkeyRoot + hkeyPath + hkeyKey, 'font-size: 12px; font-family: 黑体; line-height: 24px') |
| | | |
| | | // 设置页眉 |
| | | hkeyKey = 'header' |
| | | RegWsh.RegWrite(hkeyRoot + hkeyPath + hkeyKey, '打印编号') |
| | | |
| | | // 设置页脚 |
| | | hkeyKey = 'footer' |
| | | RegWsh.RegWrite(hkeyRoot + hkeyPath + hkeyKey, '&b第 &p 页/共 &P 页') |
| | | |
| | | // 设置页边距(0.6 要乘以 2.5为实际打印的尺寸) |
| | | hkeyKey = 'margin_bottom' |
| | | RegWsh.RegWrite(hkeyRoot + hkeyPath + hkeyKey, '0.6') |
| | | |
| | | hkeyKey = 'margin_left' |
| | | RegWsh.RegWrite(hkeyRoot + hkeyPath + hkeyKey, '0.6') |
| | | |
| | | hkeyKey = 'margin_right' |
| | | RegWsh.RegWrite(hkeyRoot + hkeyPath + hkeyKey, '0.6') |
| | | |
| | | hkeyKey = 'margin_top' |
| | | RegWsh.RegWrite(hkeyRoot + hkeyPath + hkeyKey, '0.6') |
| | | |
| | | window.print() |
| | | } else { |
| | | window.print() |
| | | 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;}</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(() => { |
| | | iframe.contentWindow.focus() |
| | | iframe.contentWindow.print() |
| | | |
| | | document.body.removeChild(iframe) |
| | | |
| | | setTimeout(() => { |
| | | window.close() |
| | | }, 2000) |
| | | }, 500) |
| | | } catch (e) { |
| | | notification.warning({ |
| | | top: 92, |
| | |
| | | duration: 5 |
| | | }) |
| | | } |
| | | |
| | | window.document.body.innerHTML = bdhtml |
| | | window.location.reload() |
| | | } |
| | | |
| | | getComponents = (components) => { |
| | | const { dataManager } = this.state |
| | | |
| | | return components.map(item => { |
| | | 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} /> |
| | | <AntvBarAndLine config={item} initdata={item.data} mainSearch={[]} menuType="" /> |
| | | </Col> |
| | | ) |
| | | } else if (item.type === 'pie') { |
| | | return ( |
| | | <Col span={item.width} key={item.uuid}> |
| | | <AntvPie config={item} initdata={item.data} mainSearch={[]} menuType="" dataManager={dataManager} /> |
| | | <AntvPie config={item} initdata={item.data} mainSearch={[]} menuType="" /> |
| | | </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} /> |
| | | <DataCard config={item} initdata={item.data} mainSearch={[]} menuType="" /> |
| | | </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} /> |
| | | <PropCard config={item} initdata={item.data} mainSearch={[]} menuType="" /> |
| | | </Col> |
| | | ) |
| | | } else if (item.type === 'table' && item.subtype === 'tablecard') { |
| | | return ( |
| | | <Col span={item.width} key={item.uuid}> |
| | | <TableCard config={item} initdata={item.data} mainSearch={[]} menuType="" /> |
| | | </Col> |
| | | ) |
| | | } else if (item.type === 'table' && item.subtype === 'normaltable') { |
| | | return ( |
| | | <Col span={item.width} key={item.uuid}> |
| | | <NormalTable config={item} initdata={item.data} mainSearch={[]} menuType="" /> |
| | | </Col> |
| | | ) |
| | | } else if (item.type === 'editor') { |
| | | return ( |
| | | <Col span={item.width} key={item.uuid}> |
| | | <BraftEditor config={item} initdata={item.data} mainSearch={[]} menuType="" /> |
| | | </Col> |
| | | ) |
| | | } else if (item.type === 'code') { |
| | | return ( |
| | | <Col span={item.width} key={item.uuid}> |
| | | <SandBox config={item} initdata={item.data} mainSearch={[]} menuType="" /> |
| | | </Col> |
| | | ) |
| | | } else { |
| | |
| | | <div className="bill-print-wrap" > |
| | | {loadingview && <Spin size="large" />} |
| | | {pages ? <div id="bill-print"> |
| | | {pages.map((components, index) => (<div className="print-page" key={index} style={config.style}><Row>{this.getComponents(components)}</Row></div>))} |
| | | {pages.map((components, index) => (<div className="print-page" key={index} style={{...config.style, overflow: 'hidden', boxSizing: 'border-box'}}><Row>{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} |
| | | {!loadingview && !viewlost ? <div className="refresh-button"><Button icon="reload" size="large" shape="circle" onClick={this.reload}></Button></div> : null} |
| | | </div> |
| | | ) |
| | | } |