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

打印效果修改

上级 c8378d7f
...@@ -23,6 +23,7 @@ export default class ViewPrint extends Component { ...@@ -23,6 +23,7 @@ export default class ViewPrint extends Component {
loading: true, loading: true,
printIndex: 0, printIndex: 0,
showWindowPrint: false, showWindowPrint: false,
preaparePrint: false,
}; };
this.getConfigInfo = queryConfig.bind(this); this.getConfigInfo = queryConfig.bind(this);
} }
...@@ -95,11 +96,12 @@ export default class ViewPrint extends Component { ...@@ -95,11 +96,12 @@ export default class ViewPrint extends Component {
printOne = (optionType = 0) => { printOne = (optionType = 0) => {
const { printIndex, configAll, viewData } = this.state; const { printIndex, configAll, viewData } = this.state;
let { info } = configAll; let { info } = configAll;
if(isJSON(info)){ if (isJSON(info)) {
info = JSON.parse(info); info = JSON.parse(info);
}else{ } else {
info = defaultConfigInfo; info = defaultConfigInfo;
} }
console.log(info);
const { printMeth } = configAll; const { printMeth } = configAll;
const { wide, high } = configAll; const { wide, high } = configAll;
const { LODOP } = window; const { LODOP } = window;
...@@ -111,11 +113,12 @@ export default class ViewPrint extends Component { ...@@ -111,11 +113,12 @@ export default class ViewPrint extends Component {
console.error('dom节点没找到'); console.error('dom节点没找到');
return false; return false;
} }
console.log(wide, high);
const strHTML = dom.innerHTML; const strHTML = dom.innerHTML;
LODOP.SET_SHOW_MODE('LANGUAGE', 0); LODOP.SET_SHOW_MODE('LANGUAGE', 0);
LODOP.SET_LICENSES('成都市知用科技有限公司', '649677881727389907689190562356', '', ''); LODOP.SET_LICENSES('成都市知用科技有限公司', '649677881727389907689190562356', '', '');
LODOP.PRINT_INITA(0, 0, `${wide}cm`, `${high}cm`, `printDomId${printIndex}`); // LODOP.PRINT_INITA(0, 0, `${wide}cm`, `${high}cm`, `printDomId${printIndex}`);
LODOP.PRINT_INIT(`${Math.random() * 10000 + 'test'}`);
LODOP.SET_PRINT_MODE('RESELECT_PAGESIZE', true);
LODOP.SET_PRINT_PAGESIZE(printMeth, info.paperWidth, info.paperHeight, 'CreateCustomPage'); // 打印方向 纸张大小. LODOP.SET_PRINT_PAGESIZE(printMeth, info.paperWidth, info.paperHeight, 'CreateCustomPage'); // 打印方向 纸张大小.
LODOP.ADD_PRINT_HTML(0, 0, '100%', '100%', strHTML); // HTML 打印 LODOP.ADD_PRINT_HTML(0, 0, '100%', '100%', strHTML); // HTML 打印
switch (optionType) { switch (optionType) {
...@@ -207,7 +210,7 @@ export default class ViewPrint extends Component { ...@@ -207,7 +210,7 @@ export default class ViewPrint extends Component {
}; };
render() { render() {
const { configAll, viewData, showWindowPrint, loading } = this.state; const { configAll, viewData, showWindowPrint, loading, preaparePrint } = this.state;
if (!viewData) { if (!viewData) {
return ( return (
<Shell styleShell={{ marginTop: '0', marginBottom: '20px' }}> <Shell styleShell={{ marginTop: '0', marginBottom: '20px' }}>
...@@ -247,42 +250,50 @@ export default class ViewPrint extends Component { ...@@ -247,42 +250,50 @@ export default class ViewPrint extends Component {
name={'打印设备选择'} name={'打印设备选择'}
handleClick={() => { handleClick={() => {
window.LODOP.SELECT_PRINTER(); window.LODOP.SELECT_PRINTER();
this.setState({
preaparePrint: true,
});
}} }}
loading={loading} loading={loading}
/> />
<ButtonDiy <ButtonDiy
name={'打印'} name={'打印预览'}
handleClick={() => { handleClick={() => {
this.printByLodop(); if (!preaparePrint) {
message.warning('请先选择打印设备');
return false;
}
this.printPreview();
}} }}
loading={loading} loading={loading}
/> />
<ButtonDiy <ButtonDiy
name={'返回'} name={'打印'}
handleClick={() => { handleClick={() => {
router.goBack(); if (!preaparePrint) {
message.warning('请先选择打印设备');
return false;
}
this.printByLodop();
}} }}
loading={loading}
/> />
<Authorized authority={'/jc/setting/PrintPositionSetting'}>
<span style={{ float: 'right' }}> <span style={{ float: 'right' }}>
<ButtonDiy <ButtonDiy
name={'打印调试模式(实施)'} name={'返回'}
handleClick={() => { handleClick={() => {
this.printSetUp(); router.goBack();
}} }}
loading={loading}
/> />
</span> </span>
</Authorized>
<Authorized authority={'/jc/setting/PrintPositionSetting'}> <Authorized authority={'/jc/setting/PrintPositionSetting'}>
<span style={{ float: 'right' }}> <span style={{ float: 'right' }}>
<ButtonDiy <ButtonDiy
name={'打印预览(实施)'} name={'打印调试模式(实施)'}
handleClick={() => { handleClick={() => {
this.printPreview(); this.printSetUp();
}} }}
loading={loading} loading={loading}
/> />
...@@ -331,7 +342,7 @@ export default class ViewPrint extends Component { ...@@ -331,7 +342,7 @@ export default class ViewPrint extends Component {
<div <div
style={{ style={{
position: 'relative', position: 'relative',
// pageBreakAfter: 'always', pageBreakAfter: 'avoid',
...imageStyle, ...imageStyle,
backgroundColor: '#fff', backgroundColor: '#fff',
}}> }}>
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论