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

打印预览修改

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