提交 6f4e78f4 authored 作者: 钟是志's avatar 钟是志

打印页面宽高设置

上级 efebf7bd
import React, { Component, Fragment } from 'react'; import React, { Component, Fragment } from 'react';
import { queryConfig } from '../services'; import { queryConfig } from '../services';
import { getInfo } from '@/highOrderComponent/Service'; import { getInfo } from '@/highOrderComponent/Service';
...@@ -25,7 +23,7 @@ export default class ViewPrint extends Component { ...@@ -25,7 +23,7 @@ export default class ViewPrint extends Component {
} }
countImageHeight = () => { countImageHeight = () => {
if(!this.state.configAll){ if (!this.state.configAll) {
return false; return false;
} }
const { const {
...@@ -125,11 +123,15 @@ export default class ViewPrint extends Component { ...@@ -125,11 +123,15 @@ export default class ViewPrint extends Component {
if (!viewData || !minHeight) { if (!viewData || !minHeight) {
return null; return null;
} }
if(!configAll.backgroundUrl){ if (!configAll.backgroundUrl) {
console.error('没有设置模版图片无法使用'); console.error('没有设置模版图片无法使用');
return null; return null;
} }
const { hasPrintBackground, backgroundUrl } = configAll; const { hasPrintBackground, backgroundUrl, wide, high } = configAll;
const imageStyle = {
height: high || '902px',
width: wide || 'auto',
};
return ( return (
<Fragment> <Fragment>
<Shell styleShell={{ marginTop: '0', marginBottom: '20px' }}> <Shell styleShell={{ marginTop: '0', marginBottom: '20px' }}>
...@@ -169,12 +171,19 @@ export default class ViewPrint extends Component { ...@@ -169,12 +171,19 @@ export default class ViewPrint extends Component {
return ( return (
<div className={styles.outSideDivPrint} <div className={styles.outSideDivPrint}
key={index + 'divKey'} key={index + 'divKey'}
style={{
...imageStyle,
}}
> >
<img <img
src={backgroundUrl} src={backgroundUrl}
draggable={false} draggable={false}
className={styles.bgimagePrint} className={styles.bgimagePrint}
alt={'背景图'} alt={'背景图'}
style={{
width: 'auto',
height: '100%',
}}
/> />
{this.detailDom(info)} {this.detailDom(info)}
</div> </div>
...@@ -188,25 +197,27 @@ export default class ViewPrint extends Component { ...@@ -188,25 +197,27 @@ export default class ViewPrint extends Component {
<div <div
ref={(node) => (this.content = node)} ref={(node) => (this.content = node)}
style={{ style={{
display: showWindowPrint ? 'block' : 'none', display: showWindowPrint || true ? 'block' : 'none',
}}> }}>
{!showWindowPrint {viewData.map((info, index) => {
? null
: viewData.map((info, index) => {
return ( return (
<div <div
className={styles.outSideDivPrint} className={styles.outSideDivPrint}
key={`${index}divKey`} key={`${index}divKey`}
style={{ style={{
minHeight: minHeight || 700, ...imageStyle,
}}> }}
>
{hasPrintBackground ? ( {hasPrintBackground ? (
<img <img
src={backgroundUrl} src={backgroundUrl}
draggable={false} draggable={false}
className={styles.bgimagePrint} className={styles.bgimagePrint}
alt={'背景图'} alt={'背景图'}
/> style={{
width: 'auto',
height: '100%',
}} />
) : null} ) : null}
{this.detailDom(info)} {this.detailDom(info)}
......
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
} }
.outSideDivPrint{ .outSideDivPrint{
position: relative; position: relative;
width: 100%; width: auto;
margin-bottom: 10px; margin-bottom: 10px;
page-break-after: always; page-break-after: always;
.bgimagePrint{ .bgimagePrint{
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论