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

打印功能调整

上级 d574ff5a
...@@ -7,10 +7,37 @@ ...@@ -7,10 +7,37 @@
* 在up 的时候 更新元素dom的新位置到props * 在up 的时候 更新元素dom的新位置到props
* */ * */
import React, { Component } from 'react'; import React, { Component, Fragment } from 'react';
import styles from './index.less'; import styles from './index.less';
import { InputNumber } from 'antd';
import { imageStyleAll, A4Height, A4Width, styleCount } from './ViewPrint/config'; import { imageStyleAll, A4Height, A4Width, styleCount } from './ViewPrint/config';
let domIdTemp = '';
const HandleDetailFunction = ({ isDownObj }) => {
for (let item in isDownObj) {
if (isDownObj[item]) {
domIdTemp = item;
}
}
if (!domIdTemp) {
return null;
}
const dom = document.getElementById(domIdTemp);
const x = dom.style.left;
const y = dom.style.top;
return <Fragment >
<span dangerouslySetInnerHTML={{ __html: dom.innerHTML }} />
<InputNumber precision={0}
min={0}
value={x}/>
<InputNumber precision={0}
min={0}
value={y}/>
</Fragment>;
};
export default class Index extends Component { export default class Index extends Component {
constructor(props) { constructor(props) {
super(props); super(props);
...@@ -26,7 +53,7 @@ export default class Index extends Component { ...@@ -26,7 +53,7 @@ export default class Index extends Component {
}; };
} }
handleOnMouseDown = (e, id) => { handleOnMouseDown = (e, id) => { // 鼠标按钮 按下
const div = document.getElementById(id); const div = document.getElementById(id);
const { isDownObj } = this.state; const { isDownObj } = this.state;
const newDrag = { const newDrag = {
...@@ -46,7 +73,7 @@ export default class Index extends Component { ...@@ -46,7 +73,7 @@ export default class Index extends Component {
}); });
}; };
handleOnMouseMove = (e) => { handleOnMouseMove = (e) => { // 鼠标 移动
const { drag, isDownObj } = this.state; const { drag, isDownObj } = this.state;
if (new Date().getTime() - this.time1 < 17) { if (new Date().getTime() - this.time1 < 17) {
this.time1 = new Date().getTime(); this.time1 = new Date().getTime();
...@@ -86,7 +113,7 @@ export default class Index extends Component { ...@@ -86,7 +113,7 @@ export default class Index extends Component {
} }
}; };
handleOnMouseUp = (e, id) => { handleOnMouseUp = (e, id) => { // 鼠标 按钮 收起
const { drag, isDownObj } = this.state; const { drag, isDownObj } = this.state;
let { mouseX, mouseY, objX, objY } = drag; let { mouseX, mouseY, objX, objY } = drag;
if (isDownObj[id]) { if (isDownObj[id]) {
...@@ -121,16 +148,18 @@ export default class Index extends Component { ...@@ -121,16 +148,18 @@ export default class Index extends Component {
render() { render() {
const { const {
backgroundUrl, backgroundUrl,
configAll: { config, wide, high, }, configAll: { config, wide, high },
} = this.props; } = this.props;
const { isDownObj } = this.state;
const imageStyle = { const imageStyle = {
height: `${high}cm` || A4Height, height: `${high}cm` || A4Height,
width: `${wide}cm` || A4Width, width: `${wide}cm` || A4Width,
}; };
console.log(imageStyle);
return ( return (
<div className={styles.outSideDiv}> <div className={styles.outSideDiv}>
{/* <div style={{ marginLeft: '45%', height: '100px' }}>
<HandleDetailFunction isDownObj={isDownObj}/>
</div>*/}
<div <div
onMouseMove={(e) => { onMouseMove={(e) => {
this.handleOnMouseMove(e); this.handleOnMouseMove(e);
...@@ -155,11 +184,13 @@ export default class Index extends Component { ...@@ -155,11 +184,13 @@ export default class Index extends Component {
key={item.id} key={item.id}
onMouseDown={(e) => { onMouseDown={(e) => {
this.handleOnMouseDown(e, domId); this.handleOnMouseDown(e, domId);
console.log(domId);
}} }}
onMouseUp={(e) => { onMouseUp={(e) => {
this.handleOnMouseUp(e, domId); this.handleOnMouseUp(e, domId);
}} }}
id={domId} id={domId}
style={{ style={{
top: `${item.y || 20 + index * 40}px`, top: `${item.y || 20 + index * 40}px`,
left: `${item.x || 20}px`, left: `${item.x || 20}px`,
......
import React, { Component, Fragment } from 'react'; import React, { Component, Fragment } from 'react';
import { queryConfig } from '../services'; import { queryConfig } from '../services';
import { getInfo } from '@/highOrderComponent/Service'; import { getInfo } from '@/highOrderComponent/Service';
import { message, Button } from 'antd'; import { message } from 'antd';
import Shell from '@/baseComponent/Shell'; import Shell from '@/baseComponent/Shell';
import ButtonDiy from '@/baseComponent/ButtonDiy'; import ButtonDiy from '@/baseComponent/ButtonDiy';
import router from 'umi/router'; import router from 'umi/router';
...@@ -101,9 +101,7 @@ export default class ViewPrint extends Component { ...@@ -101,9 +101,7 @@ export default class ViewPrint extends Component {
} else { } else {
info = defaultConfigInfo; info = defaultConfigInfo;
} }
console.log(info);
const { printMeth } = configAll; const { printMeth } = configAll;
const { wide, high } = configAll;
const { LODOP } = window; const { LODOP } = window;
let dom = document.getElementById(`printDomId-${printIndex}`); let dom = document.getElementById(`printDomId-${printIndex}`);
if (optionType >= 1) { if (optionType >= 1) {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论