|
@@ -21,7 +21,7 @@ class MoveSignatureTool {
|
|
|
|
|
|
setSignature(obj, x, y, width, height, signature_name, signatureName, signType) {
|
|
|
// 只有签章才能移动
|
|
|
- if(signType){
|
|
|
+ if (signType) {
|
|
|
this.signatureList.push({
|
|
|
obj,
|
|
|
x,
|
|
@@ -34,7 +34,7 @@ class MoveSignatureTool {
|
|
|
signType
|
|
|
})
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
//获取鼠标在canvas中的位置
|
|
|
getMousePos(event, me) {
|
|
@@ -81,16 +81,16 @@ class MoveSignatureTool {
|
|
|
x: mousePos.x - me.activeImg.x,
|
|
|
y: mousePos.y - me.activeImg.y,
|
|
|
};
|
|
|
-
|
|
|
+
|
|
|
const orgTargetData = this.pageObj.items[0].signature_cells.find(item => item.signatureName === target.signatureName && item.signType === target.signType);
|
|
|
orgTargetData.isMoving = true;
|
|
|
this.render(me);
|
|
|
|
|
|
const { top, left } = $("#rptCanvas").position();
|
|
|
- $("#rptCanvas").after(`<div id='templateSignature' data-ID='${orgTargetData.signature_name}' style="background-image:url('${orgTargetData.path}') ;cursor: move;position: absolute;top: ${y + top + 10}px;left:${x + left + 10}px;width:${width}px;height:${height}px;"/>`);
|
|
|
+ $("#rptCanvas").after(`<div id='templateSignature' data-ID='${orgTargetData.signature_name}' style="background-image:url('${orgTargetData.path}');background-size: contain;cursor: move;position: absolute;top: ${y + top + 10}px;left:${x + left + 10}px;width:${width}px;height:${height}px;"/>`);
|
|
|
$("#templateSignature").unbind('mousemove').on('mousemove', (e) => { this.templateSignatureMove(e, this) });
|
|
|
$("#templateSignature").unbind('click').on('click', (e) => { this.templateSignatureClick(e, this) });
|
|
|
-
|
|
|
+
|
|
|
} else {
|
|
|
me.selected = false;
|
|
|
}
|
|
@@ -152,12 +152,30 @@ class MoveSignatureTool {
|
|
|
// $("#rptCanvas").unbind('mousemove').on('mousemove', (e) => { this.mouseMove(e, this) });
|
|
|
}
|
|
|
|
|
|
- // 临时签章移动事件
|
|
|
+ // 临时签章移动事件(控制签章只能在报表中移动)
|
|
|
templateSignatureMove(event, me) {
|
|
|
- const mousePos = me.getMousePos(event, me);
|
|
|
+
|
|
|
+
|
|
|
const { top, left } = $("#rptCanvas").position();
|
|
|
- event.currentTarget.style.top = `${mousePos.y - me.subPos.y + top}px`;
|
|
|
- event.currentTarget.style.left = `${mousePos.x - me.subPos.x + left}px`;
|
|
|
+ const canvasWidth = $("#rptCanvas").width();
|
|
|
+ const canvasHeight = $("#rptCanvas").height();
|
|
|
+ const signatureWidth = $("#templateSignature").width();
|
|
|
+ const signatureHeight = $("#templateSignature").height();
|
|
|
+ const maxTop = canvasHeight + top - signatureHeight; //签章的最大y坐标
|
|
|
+ const maxLeft = canvasWidth + left - signatureWidth; //签章的最大x坐标
|
|
|
+
|
|
|
+ const mousePos = me.getMousePos(event, me);
|
|
|
+ let newTop = mousePos.y - me.subPos.y + top;
|
|
|
+ let newLeft = mousePos.x - me.subPos.x + left;
|
|
|
+ if ((mousePos.y - me.subPos.y) < 0) newTop = top + me.jpcOutput.offsetY;
|
|
|
+ if ((mousePos.x - me.subPos.x) < 0) newLeft = left + me.jpcOutput.offsetX;
|
|
|
+ if ((mousePos.y - me.subPos.y) > maxTop - top) newTop = maxTop - me.jpcOutput.offsetXY;
|
|
|
+ if ((mousePos.x - me.subPos.x) > maxLeft - left) newLeft = maxLeft - me.jpcOutput.offsetX;
|
|
|
+
|
|
|
+ event.currentTarget.style.top = `${newTop}px`;
|
|
|
+ event.currentTarget.style.left = `${newLeft}px`;
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
// 临时签章点击事件
|
|
|
templateSignatureClick(event, me) {
|