diff --git a/com.actionsoft.apps.coe.pal/web/com.actionsoft.apps.coe.pal/js/coe.team.pal.designer.js b/com.actionsoft.apps.coe.pal/web/com.actionsoft.apps.coe.pal/js/coe.team.pal.designer.js index 622a828a..c788a5a6 100644 --- a/com.actionsoft.apps.coe.pal/web/com.actionsoft.apps.coe.pal/js/coe.team.pal.designer.js +++ b/com.actionsoft.apps.coe.pal/web/com.actionsoft.apps.coe.pal/js/coe.team.pal.designer.js @@ -320,9 +320,12 @@ $(function() { // 快捷调整画布大小点击事件 $('#bar_resize').off('click').on('click',function () { - let pos = getCanvasContentEdge() + var pos = getCanvasContentEdge() + var minPageWidth = 1050 var elements = Model.define.elements; var shapeIds = []; + var contentWidth = pos.right - pos.left + var contentHeight = pos.bottom - pos.top for(var shapeId in elements){ shapeIds.push(shapeId); } @@ -339,24 +342,33 @@ $(function() { var outlinkers = Utils.getOutlinkers(selected); movingShapes = selected.concat(outlinkers); } - if(movingShapes.length > 0) { - // 下移或上移 距顶部60 默认padding 60 + if(movingShapes.length > 0 && contentWidth <= minPageWidth - 180*2) { + // 下移或上移 距顶部120 默认padding 60 Designer.op.moveShape(movingShapes, { x : 0, - y : 120 - pos.top + y : 180 - pos.top }); + Designer.setPageStyle({ + width: minPageWidth, + height: contentHeight + 360 + }); + } else if(movingShapes.length > 0 && contentWidth > minPageWidth - 180*2) { // 右移或左移 距左部60 默认padding 60 Designer.op.moveShape(movingShapes, { - x : 120 - pos.left, + x : 180 - pos.left, y : 0 }); + // 下移或上移 距顶部120 默认padding 60 + Designer.op.moveShape(movingShapes, { + x : 0, + y : 180 - pos.top + }); + Designer.setPageStyle({ + width: contentWidth + 180*2, + height: contentHeight + 180*2 + }); } - var contentWidth = pos.right - pos.left - var contentHeight = pos.bottom - pos.top - Designer.setPageStyle({ - width: contentWidth + 240, - height: contentHeight + 240 - }); + Model.updateMulti(movingShapes); $("#saving_tip").css("color", "rgb(255, 0, 0)"); $("#saving_tip").text("文件已修改,未保存"); movingShapes = null; @@ -377,23 +389,60 @@ function getCanvasContentEdge() { var yArr = [] for (let key in elements) { if (elements[key].points == undefined) { // 形状 - xArr.push(elements[key].props.x) - yArr.push(elements[key].props.y) + xArr.push({ + x: elements[key].props.x, + type: 'shape', + shapeWidth: elements[key].props.w + }) + yArr.push({ + y: elements[key].props.y, + type: 'shape', + shapeHeight: elements[key].props.h + }) } else { - xArr.push(elements[key].from.x) - xArr.push(elements[key].to.x) - yArr.push(elements[key].from.y) - yArr.push(elements[key].to.y) + xArr.push({ + x: elements[key].from.x, + type: 'line' + }) + xArr.push({ + x: elements[key].to.x, + type: 'line' + }) + yArr.push({ + y: elements[key].from.y, + type: 'line' + }) + yArr.push({ + y: elements[key].to.y, + type: 'line' + }) for (let i = 0; i < elements[key].points.length; i++) { - xArr.push(elements[key].points[i].x) - yArr.push(elements[key].points[i].y) + xArr.push({ + x: elements[key].points[i].x, + type: 'line' + }) + yArr.push({ + y: elements[key].points[i].y, + type: 'line' + }) } } } - pos.left = Math.min.apply(null,xArr) - pos.right = Math.max.apply(null,xArr) - pos.top = Math.min.apply(null,yArr) - pos.bottom = Math.max.apply(null,yArr) + pos.left = Math.min.apply(Math,xArr.map(item => { return item.x })) + pos.top = Math.min.apply(Math,yArr.map(item => { return item.y })) + // 特殊处理右和下 若有图形 加上图形的高/宽 + for (let i = 0; i < xArr.length; i++) { + if(xArr[i].type == 'shape') { + xArr[i].x += xArr[i].shapeWidth + } + } + for (let i = 0; i < yArr.length; i++) { + if(yArr[i].type == 'shape') { + yArr[i].y += yArr[i].shapeHeight + } + } + pos.right = Math.max.apply(Math,xArr.map(item => { return item.x })) + pos.bottom = Math.max.apply(Math,yArr.map(item => { return item.y })) return pos }