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

打印页面宽高设置

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