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

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

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