| | |
| | | |
| | | import Api from '@/api' |
| | | import Utils from '@/utils/utils.js' |
| | | import options, { styles } from '@/store/options.js' |
| | | import zhCN from '@/locales/zh-CN/main.js' |
| | | import enUS from '@/locales/en-US/main.js' |
| | | import options from '@/store/options.js' |
| | | import UtilsDM from '@/utils/utils-datamanage.js' |
| | | import NotFount from '@/components/404' |
| | | import asyncComponent from '@/utils/asyncComponent' |
| | |
| | | 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 Balcony = asyncComponent(() => import('@/tabviews/custom/components/card/balcony')) |
| | | |
| | | class BillPrint extends Component { |
| | | state = { |
| | |
| | | data: '', |
| | | tempId: '', |
| | | config: null, |
| | | auto: true |
| | | } |
| | | |
| | | UNSAFE_componentWillMount() { |
| | | const { params } = this.props.match |
| | | |
| | | if (params.menuId) { |
| | | this.setState({ |
| | | BID: params.id || '', |
| | | tempId: params.menuId |
| | | }, () => { |
| | | this.getTouristMsg() |
| | | }) |
| | | } else { |
| | | try { |
| | | let param = JSON.parse(window.decodeURIComponent(window.atob(this.props.match.params.param))) |
| | | let param = JSON.parse(window.decodeURIComponent(window.atob(params.param))) |
| | | |
| | | sessionStorage.setItem('dataM', param.dataM || '') |
| | | sessionStorage.setItem('localDataM', param.dataM || '') |
| | |
| | | }) |
| | | } |
| | | } |
| | | } |
| | | |
| | | shouldComponentUpdate (nextProps, nextState) { |
| | | return !is(fromJS(this.state), fromJS(nextState)) |
| | |
| | | } |
| | | } |
| | | |
| | | getTouristMsg = () => { |
| | | Api.getTouristMsg().then(result => { |
| | | if (result.status) { |
| | | sessionStorage.setItem('UserID', result.UserID || '') |
| | | sessionStorage.setItem('LoginUID', result.LoginUID || '') |
| | | sessionStorage.setItem('dataM', 'false') |
| | | |
| | | this.getMenuParam() |
| | | |
| | | // 获取系统信息 |
| | | let _param = { |
| | | func: 's_Get_style', |
| | | TypeCharOne: 'PC', |
| | | LText: `select '${window.GLOB.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 |
| | | |
| | | 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) |
| | | } |
| | | } |
| | | }) |
| | | } else { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: result.message, |
| | | duration: 5 |
| | | }) |
| | | } |
| | | }) |
| | | } |
| | | |
| | | getMenuParam = () => { |
| | | const { tempId, BID } = this.state |
| | | |
| | |
| | | func: 'sPC_Get_LongParam', |
| | | MenuID: tempId |
| | | } |
| | | |
| | | window.GLOB.dataFormat = false // 打印去除水印 |
| | | |
| | | if (window.GLOB.mainSystemApi) { // 从单点登录服务器取打印配置信息 |
| | | _param.rduri = window.GLOB.mainSystemApi |
| | |
| | | if (component.search) component.search = [] |
| | | component.data = [] // 初始化数据为空 |
| | | |
| | | if (component.type === 'table' && component.subtype === 'normaltable') { |
| | | let getColumns = (cols) => { |
| | | return cols.map(item => { |
| | | if (item.type === 'colspan') { |
| | | item.subcols = getColumns(item.subcols) |
| | | } else { |
| | | item.IsSort = 'false' |
| | | } |
| | | |
| | | return item |
| | | }) |
| | | } |
| | | component.cols = getColumns(component.cols) |
| | | } |
| | | |
| | | if (component.wrap.datatype === 'static') { |
| | | component.format = '' |
| | | } |
| | |
| | | } |
| | | |
| | | /** |
| | | * @description 获取系统存储过程 sPC_Get_TableData 的参数 |
| | | * @description 获取系统存储过程参数 |
| | | */ |
| | | getDefaultParam = (component) => { |
| | | const { columns, setting, dataName, format } = component |
| | |
| | | } |
| | | |
| | | // 测试系统打印查询语句 |
| | | if ((options.sysType === 'local' && !window.GLOB.systemType) || window.debugger === true) { |
| | | if (window.GLOB.debugger === true || (window.debugger === true && options.sysType !== 'cloud')) { |
| | | _customScript && console.info(`${_dataresource ? '' : '/*不执行默认sql*/\n'}${_customScript}`) |
| | | _dataresource && console.info(_dataresource) |
| | | } |
| | |
| | | if (!params || params.length === 0) return '' |
| | | let LText_field = [] |
| | | let transaction = false |
| | | |
| | | 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 city = sessionStorage.getItem('city') || '' |
| | | |
| | | if (sessionStorage.getItem('isEditState') === 'true') { |
| | | userName = sessionStorage.getItem('CloudUserName') || '' |
| | | fullName = sessionStorage.getItem('CloudFullName') || '' |
| | | } |
| | | |
| | | 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(50),@mk_organization nvarchar(50),@login_city nvarchar(50) |
| | | select @ErrorCode='',@retmsg ='',@UserName='${userName}', @FullName='${fullName}', @RoleID='${RoleID}', @mk_departmentcode='${departmentcode}', @mk_organization='${organization}', @login_city='${city}' |
| | | ${_script} |
| | | ` |
| | | } |
| | |
| | | this.setState({loadingview: false, pages}) |
| | | } |
| | | |
| | | let auto = true |
| | | |
| | | if (comps[comps.length - 1].wrap && comps[comps.length - 1].wrap.printHeight) { |
| | | auto = false |
| | | } |
| | | |
| | | while (!over) { |
| | | let page = [] |
| | | let count = 0 |
| | |
| | | return |
| | | } else if (item.subtype === 'datacard' || item.type === 'table') { |
| | | if (_item.dataArray && _item.dataArray.length > 0) { |
| | | if (item.subtype === 'datacard' && item.wrap.layout === 'flex') { |
| | | if (!item.added && item.wrap.printHeight) { |
| | | count += item.wrap.printHeight |
| | | if (count >= limit) { |
| | | _pageover = true |
| | | } |
| | | if (count <= limit) { |
| | | _item.added = true |
| | | page.push(item) |
| | | } |
| | | } else if (!item.added) { |
| | | _item.added = true |
| | | page.push(item) |
| | | } |
| | | } else { |
| | | item.data = [] |
| | | |
| | | while (count < limit && _item.dataArray.length > 0) { |
| | | while (count + 1 <= limit && _item.dataArray.length > 0) { |
| | | item.data.push(_item.dataArray.shift()) |
| | | count++ |
| | | } |
| | |
| | | if (count >= limit) { |
| | | _pageover = true |
| | | } |
| | | page.push(item) |
| | | } |
| | | _item.added = true |
| | | } else if (!item.added) { |
| | | _item.added = true |
| | | page.push(item) |
| | | } |
| | | } else if (!item.added && item.wrap && item.wrap.printHeight) { |
| | | if (item.wrap.empty === 'hidden' && (!item.data || item.data.length === 0)) { |
| | | _item.added = true |
| | | return |
| | | } |
| | | |
| | | count += item.wrap.printHeight |
| | | if (count >= limit) { |
| | | _pageover = true |
| | | } |
| | | if (count <= limit) { |
| | | _item.added = true |
| | | page.push(item) |
| | | } |
| | | } else if (!item.added) { |
| | |
| | | return |
| | | } else if (item.subtype === 'datacard' || item.type === 'table') { |
| | | if (_item.dataArray && _item.dataArray.length > 0) { |
| | | if (item.subtype === 'datacard' && item.wrap.layout === 'flex') { |
| | | if (!item.added && item.wrap.printHeight) { |
| | | count += item.wrap.printHeight |
| | | if (count >= limit) { |
| | | _pageover = true |
| | | } |
| | | if (count <= limit) { |
| | | _item.added = true |
| | | page.push(item) |
| | | } |
| | | } else if (!item.added) { |
| | | _item.added = true |
| | | page.push(item) |
| | | } |
| | | } else { |
| | | item.data = [] |
| | | |
| | | while (count < limit && _item.dataArray.length > 0) { |
| | | while (count + 1 <= limit && _item.dataArray.length > 0) { |
| | | item.data.push(_item.dataArray.shift()) |
| | | count++ |
| | | } |
| | |
| | | if (count >= limit) { |
| | | _pageover = true |
| | | } |
| | | page.push(item) |
| | | } |
| | | _item.added = true |
| | | } else if (!item.added) { |
| | | _item.added = true |
| | | page.push(item) |
| | | } |
| | | } else if (!item.added && item.wrap && item.wrap.printHeight) { |
| | | if (item.wrap.empty === 'hidden' && (!item.data || item.data.length === 0)) { |
| | | _item.added = true |
| | | return |
| | | } |
| | | count += item.wrap.printHeight |
| | | if (count >= limit) { |
| | | _pageover = true |
| | | } |
| | | if (count <= limit) { |
| | | _item.added = true |
| | | page.push(item) |
| | | } |
| | | } else if (!item.added) { |
| | |
| | | } |
| | | } |
| | | |
| | | this.setState({loadingview: false, pages}) |
| | | this.setState({loadingview: false, pages, auto}) |
| | | }) |
| | | } |
| | | |
| | |
| | | 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>`) |
| | | 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>') |
| | | } |
| | |
| | | <SandBox config={item} initdata={item.data} mainSearch={[]} menuType="" /> |
| | | </Col> |
| | | ) |
| | | } else if (item.type === 'balcony') { |
| | | return ( |
| | | <Col span={item.width} key={item.uuid}> |
| | | <Balcony config={item} initdata={item.data} menuType="" /> |
| | | </Col> |
| | | ) |
| | | } else if (item.type === 'timeline') { |
| | | return ( |
| | | <Col span={item.width} key={item.uuid}> |
| | |
| | | } |
| | | |
| | | render() { |
| | | const { loadingview, viewlost, config, pages } = this.state |
| | | const { loadingview, viewlost, config, pages, auto } = this.state |
| | | |
| | | return ( |
| | | <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, overflow: 'hidden', boxSizing: 'border-box'}}><Row>{this.getComponents(components)}</Row></div>))} |
| | | {pages.map((components, index) => (<div className={'print-page' + (auto ? ' auto' : '')} 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} |