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

打印功能修改. 还是搞不到事

上级 2042006f
......@@ -106,7 +106,7 @@ export default function DetailDom({ config, data }) {
const styleOutSide = {
position: 'absolute',
zIndex: 10,
fontWeight: 'bold',
fontWeight: '600',
left: x + 'px',
top: y + 'px',
};
......
......@@ -38,7 +38,6 @@ if (needCLodop()) {
//====获取LODOP对象的主过程:====
export function getLodop(dir, oOBJECT, oEMBED) {
console.log(dir, oOBJECT, oEMBED);
var basePath = '';
if (typeof (basePath) == 'undefined') {
basePath = getContextOrPath(false);
......
......@@ -6,7 +6,7 @@ export const A4Height = '29.6cm';
export const A4Width = '20.9cm';
export const imageStyleAll = {
width: '100%',
height: '100%',
// height: '100%',
};
export function getCLodopFuncJS() {
......
......@@ -69,7 +69,7 @@ export default class ViewPrint extends Component {
this.getViewData();
getCLodopFuncJS().then((response) => {
window.On_CLodop_Opened = function(){
console.log('On_CLodop_Opened');
console.log('打印插件准备就绪,随时可以打印');
window.On_CLodop_Opened = null;
};
if (response) {
......@@ -99,22 +99,25 @@ export default class ViewPrint extends Component {
printOne = () => {
const { printIndex, configAll, viewData } = this.state;
const { printMeth } = configAll;
const { wide, high } = configAll;
let LODOPObj = window.LODOP;
let strHTML = document.getElementById(`printDomId_${printIndex}`).innerHTML;
strHTML = strHTML.replace(
'break-after: page;',
'page-break-after: always;',
);
strHTML = `<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"></head><body>${strHTML}</body></html>`;
// console.log(strHTML);
LODOPObj.PRINT_INIT(`printDomId_${printIndex}`);
// window.LODOP.PRINT_INITA(1, 1, 770, 660, '测试预览功能');
LODOPObj.ADD_PRINT_HTM(0, 0, `${wide + 0.1}cm`, `${high + 0.1}cm`, strHTML); // 打印的宽高和 html
LODOPObj.SET_PRINT_PAGESIZE(2, 0, 0); // 纵向打印
LODOPObj.PREVIEW();
//LODOPObj.PRINT();
// LODOPObj.PRINT_SETUP();
strHTML = `${strHTML}`;
console.log(strHTML);
strHTML = `<div style="width: 24.7cm; height: 17cm">
<img src="http://zysoft.cdzhiyong.com:53003/dsf/u/upload/202006/05182802hzom.jpg"
style="width:100%;height: 100%;text-align: center"></div>`;
LODOP.PRINT_INITA(0, 0, `${wide + 1}cm`, `${high + 1}cm`, "printDomId_" + printIndex);
LODOP.SET_PRINT_MODE('POS_BASEON_PAPER', true);
LODOP.SET_PRINT_PAGESIZE(printMeth, 0, 0, "A4");
LODOP.ADD_PRINT_IMAGE(0, 0, "100%", "100%", strHTML);
LODOP.PREVIEW(); // 预览模式
// LODOPObj.PRINT(); // 直接打印
// LODOPObj.PRINT_SETUP();
};
printOneByOne = () => {
......@@ -175,8 +178,9 @@ export default class ViewPrint extends Component {
}
const { hasPrintBackground, backgroundUrl, wide, high } = configAll;
let imageStyle = {
height: `${high}cm` || A4Height,
width: `${wide}cm` || A4Width,
height: high ? `${high}cm` : A4Height,
width: wide ? `${wide}cm` : A4Width,
textAlign: 'center',
};
return (
<Fragment>
......@@ -202,11 +206,13 @@ export default class ViewPrint extends Component {
/>
<ButtonDiy
name={'打印'}
handleClick={this.setState({
printBg: false,
}, () => {
this.printByLodop();
})}
handleClick={() => {
this.setState({
printBg: false,
}, () => {
this.printByLodop();
});
}}
loading={loading}
/>
<ButtonDiy
......@@ -236,7 +242,7 @@ export default class ViewPrint extends Component {
alt={'背景图'}
style={imageStyleAll}
/>
{this.detailDom(info)}
{/* {this.detailDom(info)}*/}
</div>
);
})}
......@@ -248,7 +254,7 @@ export default class ViewPrint extends Component {
<div
ref={(node) => (this.content = node)}
style={{
display: showWindowPrint && false ? 'block' : 'none',
display: showWindowPrint || true ? 'block' : 'none',
}}>
{viewData.map((info, index) => {
return (
......@@ -259,11 +265,11 @@ export default class ViewPrint extends Component {
<div
style={{
position: 'relative',
width: 'auto',
pageBreakAfter: 'always',
// border: '1px solid red',
...imageStyle,
}}>
{hasPrintBackground || printBg ? (
{ true || hasPrintBackground || printBg ? (
<img
src={backgroundUrl}
draggable={false}
......@@ -271,10 +277,11 @@ export default class ViewPrint extends Component {
style={{
zIndex: 1,
...imageStyleAll,
// border: '1px solid red',
}}
/>
) : null}
{this.detailDom(info)}
{/* {this.detailDom(info)}*/}
</div>
</div>
);
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论