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

打印修改

上级 c28e41ee
...@@ -44,7 +44,7 @@ export default class ViewPrint extends Component { ...@@ -44,7 +44,7 @@ export default class ViewPrint extends Component {
} }
let i = 0; let i = 0;
for (const item of viewData) { for (const item of viewData) {
// item.name = ['黎处', '王昊楠', '古力娜扎', '古丽尼帕尔·阿布都黑利力'][i] || '钟是志'; // item.name = ['黎处', '王昊楠', '古力娜扎', '古丽尼帕尔·阿布都黑利力'][i] || '钟是志';
i++; i++;
for (let z in item) { for (let z in item) {
if (item[z] === null || item[z] === 'null') { if (item[z] === null || item[z] === 'null') {
...@@ -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) {
LODOP.PREVIEW(); // 打印预览 switch (optionType) {
} else { case 1:
LODOP.PRINT(); // 打印 LODOP.PREVIEW(); // 打印预览
break;
case 2:
debugger;
LODOP.PRINT_DESIGN();
break;
case 0:
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 }, () => {
...@@ -171,7 +201,7 @@ export default class ViewPrint extends Component { ...@@ -171,7 +201,7 @@ export default class ViewPrint extends Component {
{ {
showWindowPrint: true, showWindowPrint: true,
printIndex: 0, printIndex: 0,
loading: true, loading: true,
}, },
() => { () => {
this.printOneByOne(); this.printOneByOne();
...@@ -182,16 +212,18 @@ export default class ViewPrint extends Component { ...@@ -182,16 +212,18 @@ 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 (
<div style={{ height: '54px', padding: '12px 0 12px 12px' }}> <Shell styleShell={{ marginTop: '0', marginBottom: '20px' }}>
<ButtonDiy <div style={{ height: '54px', padding: '12px 0 12px 12px' }}>
name={'返回'} <ButtonDiy
handleClick={() => { name={'返回'}
router.goBack(); handleClick={() => {
}} router.goBack();
/> }}
</div> />
</Shell>; </div>
</Shell>
);
} }
if (!configAll.backgroundUrl) { if (!configAll.backgroundUrl) {
console.error('没有设置模版图片无法使用'); console.error('没有设置模版图片无法使用');
...@@ -207,9 +239,9 @@ export default class ViewPrint extends Component { ...@@ -207,9 +239,9 @@ 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 (
<Fragment> <Fragment>
<Shell styleShell={{ marginTop: '0', marginBottom: '20px' }}> <Shell styleShell={{ marginTop: '0', marginBottom: '20px' }}>
...@@ -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 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论