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

打印功能易用性修改

上级 1b4d745b
...@@ -14,7 +14,7 @@ import { imageStyleAll, A4Height, A4Width, styleCount } from './ViewPrint/config ...@@ -14,7 +14,7 @@ import { imageStyleAll, A4Height, A4Width, styleCount } from './ViewPrint/config
let domIdTemp = ''; let domIdTemp = '';
const HandleDetailFunction = ({ isDownObj }) => { const HandleDetailFunction = ({ isDownObj, updateOnePostion, config }) => {
for (let item in isDownObj) { for (let item in isDownObj) {
if (isDownObj[item]) { if (isDownObj[item]) {
domIdTemp = item; domIdTemp = item;
...@@ -23,16 +23,25 @@ const HandleDetailFunction = ({ isDownObj }) => { ...@@ -23,16 +23,25 @@ const HandleDetailFunction = ({ isDownObj }) => {
if (!domIdTemp) { if (!domIdTemp) {
return null; return null;
} }
const id = domIdTemp.replace('dragKey-', '');
const itemConfig = config.find((y) => {
return y.id + '' === id;
});
const dom = document.getElementById(domIdTemp); const dom = document.getElementById(domIdTemp);
const x = dom.style.left; const x = itemConfig.x;
const y = dom.style.top; const y = itemConfig.y;
return <Fragment > return <Fragment>
<span dangerouslySetInnerHTML={{ __html: dom.innerHTML }} /> <span dangerouslySetInnerHTML={{ __html: dom.innerHTML }}/>
<span> 偏移量(x,y)</span>
<InputNumber precision={0} <InputNumber precision={0}
min={0} onChange={(value) => {
updateOnePostion({ id, x: value, y });
}}
value={x}/> value={x}/>
<InputNumber precision={0} <InputNumber precision={0}
min={0} onChange={(value) => {
updateOnePostion({ id, y: value, x });
}}
value={y}/> value={y}/>
</Fragment>; </Fragment>;
}; };
...@@ -113,7 +122,16 @@ export default class Index extends Component { ...@@ -113,7 +122,16 @@ export default class Index extends Component {
} }
}; };
handleOnMouseUp = (e, id) => { // 鼠标 按钮 收起 updateOnePostion = ({ id, x, y }) => {
const { updateConfig } = this.props;
updateConfig({
id,
x,
y,
});
};
handleOnMouseUp = (e, id) => { // 鼠标 按钮 收起 更新数据到props
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]) {
...@@ -127,7 +145,6 @@ export default class Index extends Component { ...@@ -127,7 +145,6 @@ export default class Index extends Component {
mouseX = x; mouseX = x;
mouseY = y; mouseY = y;
const { updateConfig } = this.props; const { updateConfig } = this.props;
updateConfig({ updateConfig({
id: id.replace('dragKey-', ''), id: id.replace('dragKey-', ''),
x: styleLeft, x: styleLeft,
...@@ -157,15 +174,19 @@ export default class Index extends Component { ...@@ -157,15 +174,19 @@ export default class Index extends Component {
}; };
return ( return (
<div className={styles.outSideDiv}> <div className={styles.outSideDiv}>
{/* <div style={{ marginLeft: '45%', height: '100px' }}> <div style={{ marginLeft: '45%', height: '100px' }}>
<HandleDetailFunction isDownObj={isDownObj}/> <HandleDetailFunction isDownObj={isDownObj}
</div>*/} config={config}
updateOnePostion={this.updateOnePostion}
/>
</div>
<div <div
onMouseMove={(e) => { onMouseMove={(e) => {
this.handleOnMouseMove(e); this.handleOnMouseMove(e);
}} }}
style={{ style={{
...imageStyle, ...imageStyle,
position: 'relative',
}}> }}>
<img <img
src={backgroundUrl} src={backgroundUrl}
......
...@@ -18,11 +18,28 @@ const normalTextRender = (text, config) => { ...@@ -18,11 +18,28 @@ const normalTextRender = (text, config) => {
if (!text || text === 'undefined' || typeof text === 'undefined') { if (!text || text === 'undefined' || typeof text === 'undefined') {
return null; return null;
} }
const configInfoJSON = ( config.info && isJSON(config.info) && JSON.parse(config.info) ) || {} ;
const configTextStyle = config.info && isJSON(config.info) && JSON.parse(config.info).textStyle || {}; const configTextStyle = configInfoJSON.textStyle || {}; // 文本的样式
const configTextBreakLength = configInfoJSON.textBreakLength || undefined; // 字数过宽换行
const width = config.wide ? config.wide + 'px' : 'auto'; const width = config.wide ? config.wide + 'px' : 'auto';
const height = config.high ? config.high + 'px' : 'auto'; const height = config.high ? config.high + 'px' : 'auto';
if(configTextBreakLength && text.length > configTextBreakLength) {
text = [text.substr(0, configTextBreakLength), text.substr(configTextBreakLength)];
return text.map((x, index) => {
return <div
key={x}
style={{
...styleCount(config),
marginBottom: '0',
width,
textAlign: 'right',
...configTextStyle,
}}>
{x}
</div>;
});
}
if (config.mark && text.indexOf(config.mark) > -1) { // 换行分隔符 if (config.mark && text.indexOf(config.mark) > -1) { // 换行分隔符
text = text.split(config.mark); text = text.split(config.mark);
let length = text.length; let length = text.length;
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论