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

打印修改

上级 c28e41ee
...@@ -91,28 +91,58 @@ export default class ViewPrint extends Component { ...@@ -91,28 +91,58 @@ export default class ViewPrint extends Component {
return res; return res;
}; };
printOne = (review = false) => { printOne = (optionType = 0) => {
const { printIndex, configAll, viewData } = this.state; const { printIndex, configAll, viewData } = this.state;
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 dom = document.getElementById(`printDomId-${printIndex}`);
if (review) { if (optionType >= 1) {
strHTML = document.getElementById(`printDomId_0`).innerHTML; dom = document.getElementById('printDomId-0');
} }
LODOP.PRINT_INITA(0, 0, `${wide}cm`, `${high}cm`, `printDomId_${printIndex}`); if (!dom) {
LODOP.SET_PRINT_PAGESIZE(printMeth, `${wide}cm`, `${high}cm`, 'CreateCustomPage'); // 打印方向 console.error('dom节点没找到');
return false;
}
const strHTML = dom.innerHTML;
LODOP.PRINT_INITA(
0,
0,
`${wide}cm`,
`${high}cm`,
`printDomId-${Math.random() * 10000}`,
);
LODOP.SET_PRINT_PAGESIZE(
printMeth,
`${wide}cm`,
`${high}cm`,
'CreateCustomPage',
); // 打印方向
LODOP.ADD_PRINT_HTM(0, 0, '100%', '100%', strHTML); // HTML 打印 LODOP.ADD_PRINT_HTM(0, 0, '100%', '100%', strHTML); // HTML 打印
if (review) {
switch (optionType) {
case 1:
LODOP.PREVIEW(); // 打印预览 LODOP.PREVIEW(); // 打印预览
} else { break;
case 2:
debugger;
LODOP.PRINT_DESIGN();
break;
case 0:
LODOP.PRINT(); // 打印 LODOP.PRINT(); // 打印
break;
default:
break;
} }
}; };
printPreview = () => { printPreview = () => {
// 打印预览 // 打印预览
this.printOne(true); this.printOne(1);
};
printSetUp = () => {
this.printOne(2);
}; };
printedDataSave = (index) => { printedDataSave = (index) => {
...@@ -143,7 +173,7 @@ export default class ViewPrint extends Component { ...@@ -143,7 +173,7 @@ export default class ViewPrint extends Component {
LODOPObj.On_Return_Remain = true; LODOPObj.On_Return_Remain = true;
LODOPObj.On_Return = (TaskId, Value) => { LODOPObj.On_Return = (TaskId, Value) => {
if (Number(Value) === 1) { if (Number(Value) === 1) {
message.info(`正在打印第${printIndex + 1}张`); message.info(`正在打印第${printIndex + 1}, 共${viewData.length}`);
this.printedDataSave(printIndex); this.printedDataSave(printIndex);
} }
this.setState({ printIndex: this.state.printIndex + 1 }, () => { this.setState({ printIndex: this.state.printIndex + 1 }, () => {
...@@ -182,7 +212,8 @@ export default class ViewPrint extends Component { ...@@ -182,7 +212,8 @@ export default class ViewPrint extends Component {
render() { render() {
const { configAll, viewData, showWindowPrint, loading } = this.state; const { configAll, viewData, showWindowPrint, loading } = this.state;
if (!viewData) { if (!viewData) {
return <Shell styleShell={{ marginTop: '0', marginBottom: '20px' }}> return (
<Shell styleShell={{ marginTop: '0', marginBottom: '20px' }}>
<div style={{ height: '54px', padding: '12px 0 12px 12px' }}> <div style={{ height: '54px', padding: '12px 0 12px 12px' }}>
<ButtonDiy <ButtonDiy
name={'返回'} name={'返回'}
...@@ -191,7 +222,8 @@ export default class ViewPrint extends Component { ...@@ -191,7 +222,8 @@ export default class ViewPrint extends Component {
}} }}
/> />
</div> </div>
</Shell>; </Shell>
);
} }
if (!configAll.backgroundUrl) { if (!configAll.backgroundUrl) {
console.error('没有设置模版图片无法使用'); console.error('没有设置模版图片无法使用');
...@@ -207,7 +239,7 @@ export default class ViewPrint extends Component { ...@@ -207,7 +239,7 @@ export default class ViewPrint extends Component {
const templateInfo = templateCode.find((x) => { const templateInfo = templateCode.find((x) => {
return x.path === pathname; return x.path === pathname;
}); });
if(!templateInfo){ if (!templateInfo) {
console.error('未找到templateInfo', pathname); console.error('未找到templateInfo', pathname);
} }
return ( return (
...@@ -236,6 +268,18 @@ export default class ViewPrint extends Component { ...@@ -236,6 +268,18 @@ export default class ViewPrint extends Component {
}} }}
/> />
<Authorized authority={'/jc/setting/PrintPositionSetting'}>
<span style={{ float: 'right' }}>
<ButtonDiy
name={'打印调试模式(实施)'}
handleClick={() => {
this.printSetUp();
}}
loading={loading}
/>
</span>
</Authorized>
<Authorized authority={'/jc/setting/PrintPositionSetting'}> <Authorized authority={'/jc/setting/PrintPositionSetting'}>
<span style={{ float: 'right' }}> <span style={{ float: 'right' }}>
<ButtonDiy <ButtonDiy
...@@ -284,7 +328,7 @@ export default class ViewPrint extends Component { ...@@ -284,7 +328,7 @@ export default class ViewPrint extends Component {
}}> }}>
{viewData.map((info, index) => { {viewData.map((info, index) => {
return ( return (
<div key={`${index}divKey`} id={`printDomId_${index}`}> <div key={`${index}divKey`} id={`printDomId-${index}`}>
<div <div
style={{ style={{
position: 'relative', position: 'relative',
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论