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

打印预览修改

上级 9a26e2aa
......@@ -68,7 +68,7 @@ export default class ViewPrint extends Component {
componentDidMount() {
this.getViewData();
getCLodopFuncJS().then((response) => {
window.On_CLodop_Opened = function(){
window.On_CLodop_Opened = function() {
console.log('打印插件准备就绪,随时可以打印');
window.On_CLodop_Opened = null;
};
......@@ -78,7 +78,6 @@ export default class ViewPrint extends Component {
});
}
});
}
detailDom = (data) => {
......@@ -102,16 +101,28 @@ export default class ViewPrint extends Component {
const { printMeth } = configAll;
const { wide, high } = configAll;
const { LODOP } = window;
let strHTML = document.getElementById(`printDomId_${printIndex}`).innerHTML;
strHTML = strHTML.replace(
let strHTML = document.getElementById(`djfgkjdlfjg`).innerHTML;
/*strHTML = strHTML.replace(
'break-after: page;',
'page-break-after: always;',
);
strHTML = `${strHTML}`;
// strHTML = 'http://scjoyedu.eicp.net:53005/config/23333.pdf';
LODOP.PRINT_INITA(0, 0, `100%`, `100%`, "printDomId_" + printIndex);
LODOP.SET_PRINT_MODE('POS_BASEON_PAPER', true);
LODOP.SET_PRINT_PAGESIZE(printMeth, 0, 0, "A4");
strHTML = `<div style="
page-break-after: always;
background-color: red;
position: relative;
/!*background-image: url('http://zysoft.cdzhiyong.com:53003/dsf/u/upload/202006/05182802hzom.jpg');*!/
width: 29.6cm;
height: 21cm; "><div style="position: absolute;top: 10.5cm>123123
</div>
</div>`;
console.log(strHTML);*/
LODOP.PRINT_INITA(0, '-0.3cm', `100%`, `100%`, 'printDomId_' + printIndex);
// LODOP.SET_PRINT_MODE('POS_BASEON_PAPER', true);
// LODOP.SET_PRINT_STYLEA('All', 'VOrient', 2);
// LODOP.SET_PRINT_STYLEA('All', 'HOrient', 2);
LODOP.SET_PRINT_PAGESIZE(printMeth, 0, 0, 'A4'); // 纵向打印
//LODOP.SET_PRINT_PAGESIZE(1, 0, 0, 'A4'); // 纵向打印
LODOP.ADD_PRINT_HTM(0, 0, '100%', '100%', strHTML); // HTML 打印
// LODOP.ADD_PRINT_URL(0, 0, '100%', '100%', strHTML); // URL 打印
// LODOP.PRINT(); // 直接打印
......@@ -128,10 +139,15 @@ export default class ViewPrint extends Component {
let LODOPObj = window.LODOP;
LODOPObj.On_Return_Remain = true;
LODOPObj.On_Return = (TaskId, Value) => {
console.log(TaskId, Value === 1 || Value === '1' ? '已发出实际打印命令!' : '放弃打印!');
this.setState({
console.log(
TaskId,
Value === 1 || Value === '1' ? '已发出实际打印命令!' : '放弃打印!',
);
this.setState(
{
printIndex: this.state.printIndex + 1,
}, () => {
},
() => {
if (this.state.printIndex < length) {
message.info(`正在打印第${this.state.printIndex + 1}张奖状`);
this.printOne();
......@@ -166,7 +182,13 @@ export default class ViewPrint extends Component {
};
render() {
const { configAll, viewData, showWindowPrint, loading, printBg } = this.state;
const {
configAll,
viewData,
showWindowPrint,
loading,
printBg,
} = this.state;
if (!viewData) {
return null;
}
......@@ -194,11 +216,14 @@ export default class ViewPrint extends Component {
<ButtonDiy
name={'打印'}
handleClick={() => {
this.setState({
this.setState(
{
printBg: false,
}, () => {
},
() => {
this.printByLodop();
});
},
);
}}
loading={loading}
/>
......@@ -222,7 +247,7 @@ export default class ViewPrint extends Component {
style={{
...imageStyle,
}}>
{ hasPrintBackground ? (
{hasPrintBackground ? (
<img
src={backgroundUrl}
draggable={false}
......@@ -240,6 +265,27 @@ export default class ViewPrint extends Component {
})}
</div>
) : null}
<div id={'djfgkjdlfjg'}>
<div
style={{
pageBreakAfter: 'always',
// backgroundColor: 'red',
position: 'relative',
width: '100%',
height: '100%',
}}>
<img
src={backgroundUrl}
width={'1000px'}
height={'800px'}
style={{
// position: 'absolute',
// top: '-0.2cm',
}}
/>
</div>
</div>
{/** 打印的dom */}
{viewData && viewData.length ? (
......@@ -261,7 +307,7 @@ export default class ViewPrint extends Component {
// border: '1px solid red',
...imageStyle,
}}>
{ hasPrintBackground ? (
{hasPrintBackground ? (
<img
src={backgroundUrl}
draggable={false}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论