diff --git a/com.actionsoft.apps.coe.pal/web/com.actionsoft.apps.coe.pal/lib/designer/scripts/diagraming/designer.methods.debug.js b/com.actionsoft.apps.coe.pal/web/com.actionsoft.apps.coe.pal/lib/designer/scripts/diagraming/designer.methods.debug.js index c97af809..9d5e25d3 100755 --- a/com.actionsoft.apps.coe.pal/web/com.actionsoft.apps.coe.pal/lib/designer/scripts/diagraming/designer.methods.debug.js +++ b/com.actionsoft.apps.coe.pal/web/com.actionsoft.apps.coe.pal/lib/designer/scripts/diagraming/designer.methods.debug.js @@ -349,6 +349,21 @@ function moveShapeAndFile(type,sublinePos,movedDistance) { if (movingLines[i].from[type] > sublinePos && moreFromIndex == -1) { movingLines[i].from[type] += movedDistance + if(type == 'y') { + if(movingLines[i].from.x == movingLines[i].to.x && movingLines[i].points.length == 2) { // 直线拐点为中点 + for (let k = 0; k < movingLines[i].points.length; k++) { + movingLines[i].points[k].x = movingLines[i].from.x + movingLines[i].points[k].y = (movingLines[i].from.y + movingLines[i].to.y) / 2 + } + } + } else { + if(movingLines[i].from.y == movingLines[i].to.y && movingLines[i].points.length == 2) { // 直线拐点为中点 + for (let k = 0; k < movingLines[i].points.length; k++) { + movingLines[i].points[k].y = movingLines[i].from.y + movingLines[i].points[k].x = (movingLines[i].from.x + movingLines[i].to.x) / 2 + } + } + } } else if(movingLines[i].from[type] <= sublinePos && fromIndex !== -1) { for (let j = 0; j < movingLines[i].points.length; j++) { if(movingLines[i].points[j][type] == movingLines[i].from[type]) { @@ -359,6 +374,21 @@ function moveShapeAndFile(type,sublinePos,movedDistance) { } if (movingLines[i].to[type] > sublinePos && moreToIndex == -1) { movingLines[i].to[type] += movedDistance + if(type == 'y') { + if(movingLines[i].from.x == movingLines[i].to.x && movingLines[i].points.length == 2) { // 直线拐点为中点 + for (let j = 0; j < movingLines[i].points.length; j++) { + movingLines[i].points[j].x = movingLines[i].from.x + movingLines[i].points[j].y = (movingLines[i].from.y + movingLines[i].to.y) / 2 + } + } + } else { + if(movingLines[i].from.y == movingLines[i].to.y && movingLines[i].points.length == 2) { // 直线拐点为中点 + for (let j = 0; j < movingLines[i].points.length; j++) { + movingLines[i].points[j].y = movingLines[i].from.y + movingLines[i].points[j].x = (movingLines[i].from.x + movingLines[i].to.x) / 2 + } + } + } } else if(passedShapes.length > 0 && movingLines[i].to[type] <= sublinePos && toIndex !== -1) { for (let j = 0; j < movingLines[i].points.length; j++) { if(movingLines[i].points[j][type] == movingLines[i].to[type]) { diff --git a/com.actionsoft.apps.coe.pal/web/com.actionsoft.apps.coe.pal/lib/designer/scripts/diagraming/designer.methods.js b/com.actionsoft.apps.coe.pal/web/com.actionsoft.apps.coe.pal/lib/designer/scripts/diagraming/designer.methods.js index 6905eab6..3607eb4b 100755 --- a/com.actionsoft.apps.coe.pal/web/com.actionsoft.apps.coe.pal/lib/designer/scripts/diagraming/designer.methods.js +++ b/com.actionsoft.apps.coe.pal/web/com.actionsoft.apps.coe.pal/lib/designer/scripts/diagraming/designer.methods.js @@ -1 +1 @@ -function isLineBelowOrRight(e,t,r){let i=!1;e.from[t]>=r&&(i=!0),e.to[t]>=r&&(i=!0);for(let n=0;n=r&&(i=!0);return i}function filterShapeAndLine(e,t){var r=Model.define.elements,i=[],n=[],o=[],a=[],l=[],s=0,d=[],p=0,h=[],g=[];for(let e in r)null==r[e].points?i.push(r[e]):n.push(r[e]),"lane"==r[e].category&&o.push(r[e]);for(let r=0;rt?h.push(i[r]):i[r].props.x<=t&&i[r].props.x+i[r].props.w/2>=t?(a.push(i[r]),h.push(i[r])):i[r].props.x+i[r].props.w/2=t?l.push(i[r]):d.push(i[r]):"y"==e&&(i[r].props[e]>t?h.push(i[r]):i[r].props.y<=t&&i[r].props.y+i[r].props.h/2>=t?(a.push(i[r]),h.push(i[r])):i[r].props.y+i[r].props.h/2=t?l.push(i[r]):d.push(i[r]));for(let r=0;re.id==n[r].id);isLineBelowOrRight(n[r],e,t)&&-1==i&&g.push(n[r])}if(d.length>0&&"y"==e?p=Math.max.apply(Math,d.map(e=>e.props.y+e.props.h)):d.length>0&&"x"==e&&(p=Math.max.apply(Math,d.map(e=>e.props.x+e.props.w))),a.concat(l).length>0&&(s=Math.max.apply(Math,a.concat(l).map(t=>t.props[e]))),a.length>0){let e=Utils.getOutlinkers(a);for(let t=0;tr.id==e[t].id)&&g.push(e[t])}return{passedShapes:a,passedMoreShapes:l,passedShapesEdge:s,sublineSideEdge:p,movingShapes:h,movingLines:g,laneArr:o}}function moveShapeAndFile(e,t,r){console.log("间距调节方法调用");var i=filterShapeAndLine(e,t),n=i.movingLines,o=i.movingShapes,a=i.passedShapes,l=i.passedMoreShapes;if(0==i.laneArr.length){"y"==e?Designer.op.moveShape(o,{x:0,y:r}):"x"==e&&Designer.op.moveShape(o,{x:r,y:0});for(let i=0;ie.id==n[i].from.id),s=a.findIndex(e=>e.id==n[i].to.id),d=l.findIndex(e=>e.id==n[i].from.id),p=l.findIndex(e=>e.id==n[i].to.id);for(let o=0;ot&&(n[i].points[o][e]+=r);if(n[i].from[e]>t&&-1==d)n[i].from[e]+=r;else if(n[i].from[e]<=t&&-1!==o){for(let t=0;tt&&-1==p)n[i].to[e]+=r;else if(a.length>0&&n[i].to[e]<=t&&-1!==s){for(let t=0;t0&&Model.updateMulti(s)}else moveLanes(e,t,r)}function moveLanes(e,t,r){var i=filterShapeAndLine(e,t),n=i.movingLines,o=i.movingShapes,a=i.passedShapes,l=i.passedMoreShapes,s=i.laneArr,d=[],p=[];for(let e=0;e{let i=r.lanes.findIndex(e=>""==e.parent),n=r.lanes.findIndex(e=>"verticalSeparatorBar"==e.name),o=r.lanes.findIndex(e=>"horizontalSeparatorBar"==e.name),a=r.lanes[i],l=r.lanes[n],s=r.lanes[o];if("x"==e){let e=a.props.xt,i=void 0!==l&&l.props.xt,n=a.props.xt;"verticalPool"==r.name?r.isPassed=e&&!i:"horizontalPool"==r.name&&(r.isPassed=e&&!n),r.lanes.forEach(e=>{e.props.x+e.props.w>t&&r.changed.push(e)})}else if("y"==e){let e=a.props.yt,i=void 0!==s&&s.props.yt,n=a.props.yt;"verticalPool"==r.name?r.isPassed=e&&!n:"horizontalPool"==r.name&&(r.isPassed=e&&!i),r.lanes.forEach(e=>{e.props.y+e.props.h>t&&r.changed.push(e)})}}),"x"==e?(Designer.op.moveShape(o.filter(e=>"lane"!==e.category),{x:r,y:0}),d.forEach(e=>{e.changed.forEach(i=>{if(e.isPassed){if(e.isPassed){if("verticalPool"==e.name)switch(i.name){case"verticalPool":i.props.w+=r;break;case"verticalLane":i.props.w+=i.props.xt?r:0,i.props.x+=i.props.x>t?r:0;break;case"horizontalSeparator":i.props.w+=r}if("horizontalPool"==e.name)switch(i.name){case"horizontalPool":case"horizontalLane":i.props.w+=r;break;case"verticalSeparator":i.props.w+=i.props.xt?r:0,i.props.x+=i.props.x>t?r:0;break;case"horizontalSeparatorBar":i.props.w+=r}}}else i.props.x+=r;p.push(i),Designer.painter.renderShape(i)})})):"y"==e&&(Designer.op.moveShape(o.filter(e=>"lane"!==e.category),{x:0,y:r}),d.forEach(e=>{e.changed.forEach(i=>{if(e.isPassed){if(e.isPassed){if("verticalPool"==e.name)switch(i.name){case"verticalPool":case"verticalLane":i.props.h+=r;break;case"horizontalSeparator":i.props.h+=i.props.yt?r:0,i.props.y+=i.props.y>t?r:0;break;case"verticalSeparatorBar":i.props.h+=r}if("horizontalPool"==e.name)switch(i.name){case"horizontalPool":i.props.h+=r;break;case"horizontalLane":i.props.h+=i.props.yt?r:0,i.props.y+=i.props.y>t?r:0;break;case"verticalSeparator":i.props.h+=r}}}else i.props.y+=r;p.push(i),Designer.painter.renderShape(i)})}));for(let i=0;ie.id==n[i].from.id),s=a.findIndex(e=>e.id==n[i].to.id),d=l.findIndex(e=>e.id==n[i].from.id),p=l.findIndex(e=>e.id==n[i].to.id);for(let o=0;ot&&(n[i].points[o][e]+=r);if(n[i].from[e]>t&&-1==d)n[i].from[e]+=r;else if(n[i].from[e]<=t&&-1!==o){for(let t=0;tt&&-1==p)n[i].to[e]+=r;else if(a.length>0&&n[i].to[e]<=t&&-1!==s){for(let t=0;t"lane"!==e.category).concat(p).concat(n);h.length>0&&Model.updateMulti(h)}function getCanvasContentEdge(){var e={top:0,bottom:0,left:0,right:0},t=Model.define.elements,r=[],i=[];for(let e in t)if(null==t[e].points)r.push({x:t[e].props.x,type:"shape",shapeWidth:t[e].props.w}),i.push({y:t[e].props.y,type:"shape",shapeHeight:t[e].props.h});else{r.push({x:t[e].from.x,type:"line"}),r.push({x:t[e].to.x,type:"line"}),i.push({y:t[e].from.y,type:"line"}),i.push({y:t[e].to.y,type:"line"});for(let n=0;ne.x)),e.top=Math.min.apply(Math,i.map(e=>e.y));for(let e=0;ee.x)),e.bottom=Math.max.apply(Math,i.map(e=>e.y)),e}function addDefaultSchemaShape(){Schema.addCategory({name:"standard",text:"Standard",dataAttributes:[]}),Schema.addShape({name:"standardText",title:"",text:"",category:"standard",attribute:{linkable:!1},props:{w:160,h:40},anchors:[],textBlock:{x:0,y:0,w:"w",h:"h"},path:[{lineStyle:{lineWidth:0},fillStyle:{type:"none"},actions:{ref:"rectangle"}}]}),Schema.addShape({name:"standardImage",title:"",text:"",attribute:{linkable:!1,editable:!1,visible:!1},category:"standard",props:{w:100,h:70},path:[{lineStyle:{lineWidth:0},actions:{ref:"rectangle"}}]}),Schema.addShape({name:"standardRectangle",title:"",text:"",attribute:{visible:!1},category:"standard",props:{w:100,h:70},path:[{actions:{ref:"rectangle"}}]})}Designer.addFunction("open",function(definition){if(""!=definition){"string"==typeof definition&&eval("definition = "+definition),$(".shape_box").remove(),Model.define.elements={},Model.persistence.elements={},Model.define.page=definition.page,Model.define.processProperties=definition.processProperties,Model.define.processDocument=definition.processDocument,Model.define.uuid=definition.uuid,process.title=definition.title,Model.persistence.page=Utils.copy(definition.page),Designer.initialize.initCanvas();var shapes=definition.elements,shapeCount=0;for(var shapeId in shapes){var shape=shapes[shapeId];"linker"!=shape.name&&(Schema.initShapeFunctions(shape),Designer.painter.renderShape(shape),Model.add(shape,!1)),shapeCount++}for(var shapeId in shapes){var shape=shapes[shapeId];"linker"==shape.name&&(Designer.painter.renderLinker(shape),Model.add(shape,!1))}0==shapeCount&&Model.build(),Navigator.draw()}}),Designer.addFunction("selectAll",function(){var e=Model.define.elements,t=[];for(var r in e)t.push(r);Utils.selectShape(t)}),Designer.addFunction("selectVertical",function(){var e;console.log("调节垂直间距");var t,r=$("#designer_subline1"),i=$("#designer_subline2"),n=$("#canvas_container"),o=$("#designer_canvas");n.bind("mousemove.drag",function(a){Designer.op.destroy();let l=Utils.getRelativePos(a.pageX,a.pageY,o);r.css({display:"block","z-index":Model.orderList.length+4,width:Model.define.page.width,height:0,borderStyle:"dotted",borderWidth:"1px",left:0,top:l.y}),n.bind("mousedown.drag",function(a){Designer.op.destroy(),n.unbind("mousemove.drag");let l=Utils.getRelativePos(a.pageX,a.pageY,o);e=l.y,t=filterShapeAndLine("y",e),r.css({display:"block","z-index":Model.orderList.length+4,width:Model.define.page.width,height:0,borderStyle:"dotted",borderWidth:"1px",left:0,top:l.y}),i.css({display:"block","z-index":Model.orderList.length+5,width:Model.define.page.width,height:0,borderStyle:"dotted",borderWidth:"1px",left:0,top:l.y,cursor:"move"}),n.bind("mousemove.drag",function(n){Designer.op.destroy();var a=Utils.getRelativePos(n.pageX,n.pageY,o);if(a.y>=e)r.css({borderColor:"rgb(114,253,107)",backgroundColor:"rgba(114,253,107,0.5)",height:a.y-e}),i.css({borderColor:"rgb(114,253,107)",backgroundColor:"transparent",height:0}),i.css({top:a.y});else{let n=t.passedShapesEdge-t.sublineSideEdge>0?t.passedShapesEdge:t.sublineSideEdge;a.y0&&moveShapeAndFile("y",e,n),o>0&&moveShapeAndFile("y",e,0-o),r.css({borderColor:"#333",backgroundColor:"transparent",height:0}),i.css({borderColor:"#333",backgroundColor:"transparent",height:0}),r.hide(),i.hide();var a=getCanvasContentEdge(),l=Model.define.page;a.bottom>l.height-l.padding&&(Designer.setPageStyle({height:a.bottom+l.padding+30}),$("#page_size_w").spinner("value",a.bottom+l.padding+30)),$(document).unbind("mouseup.drop")})}),$(document).bind("mouseup.drag",function(){n.unbind("mousemove.drag"),n.unbind("mousedown.drag"),$(document).unbind("mouseup.drag")})})})}),Designer.addFunction("selectHorizontal",function(){var e;console.log("调节水平间距");var t,r=$("#designer_subline1"),i=$("#designer_subline2"),n=$("#canvas_container"),o=$("#designer_canvas");n.bind("mousemove.drag",function(a){Designer.op.destroy();let l=Utils.getRelativePos(a.pageX,a.pageY,o);r.css({display:"block","z-index":Model.orderList.length+4,width:0,height:Model.define.page.height,borderStyle:"dotted",borderWidth:"1px",left:l.x,top:0}),n.bind("mousedown.drag",function(a){Designer.op.destroy(),n.unbind("mousemove.drag");let l=Utils.getRelativePos(a.pageX,a.pageY,o);e=l.x,t=filterShapeAndLine("x",e),r.css({display:"block","z-index":Model.orderList.length+4,width:0,height:Model.define.page.height,borderStyle:"dotted",borderWidth:"1px",left:l.x,top:0}),i.css({display:"block","z-index":Model.orderList.length+5,width:0,height:Model.define.page.height,borderStyle:"dotted",borderWidth:"1px",left:l.x,top:0,cursor:"move"}),n.bind("mousemove.drag",function(n){Designer.op.destroy();var a=Utils.getRelativePos(n.pageX,n.pageY,o);if(a.x>=e)r.css({borderColor:"rgb(114,253,107)",backgroundColor:"rgba(114,253,107,0.5)",width:a.x-e}),i.css({borderColor:"rgb(114,253,107)",backgroundColor:"transparent",width:0}),i.css({left:a.x});else{let n=t.passedShapesEdge-t.sublineSideEdge>0?t.passedShapesEdge:t.sublineSideEdge;a.x0&&moveShapeAndFile("x",e,n),o>0&&moveShapeAndFile("x",e,0-o),r.css({borderColor:"#333",backgroundColor:"transparent",width:0}),i.css({borderColor:"#333",backgroundColor:"transparent",width:0}),r.hide(),i.hide();var a=getCanvasContentEdge(),l=Model.define.page;a.right>l.width-l.padding&&(Designer.setPageStyle({width:a.right+l.padding+30}),$("#page_size_w").spinner("value",a.right+l.padding+30)),$(document).unbind("mouseup.drop")})}),$(document).bind("mouseup.drag",function(){n.unbind("mousemove.drag"),n.unbind("mousedown.drag"),$(document).unbind("mouseup.drag")})})})}),Designer.addFunction("setFontStyle",function(e){var t=Utils.getSelected();if(0!=t.length){for(var r=0;r1&&Designer.painter.drawControls(o),Model.updateMulti(r),Utils.showLinkerControls()}}),Designer.addFunction("matchSize",function(e){var t=Utils.getSelected();if(0!=t.length&&e){for(var r=null,i=null,n=[],o=0;or)&&(r=l.props.w),(null==i||l.props.h>i)&&(i=l.props.h))}"auto"==e.w&&(e.w=r),"auto"==e.h&&(e.h=i),Utils.removeAnchors();var a=[];for(o=0;o=0;i--){r-=1,(g=t[i]).props.zindex=r}}else if("backward"==e){var p=null;for(o=null,i=0;i=0;r--){var i=Model.orderList[r];if(!(i.zindex>=e.props.zindex||Utils.isSelected(i.id))){var n=Model.getShapeById(i.id),o=Utils.getShapeBox(n);if(Utils.rectCross(t,o))return n}}return null}}),Designer.addFunction("group",function(){var e=Utils.getSelected();if(!(e.length<2)){for(var t=Utils.newId(),r=0;r4&&(e=4),Utils.hideLinkerCursor(),Designer.config.scale=e,Designer.initialize.initCanvas(),Model.define.elements){var r=Model.define.elements[t];Designer.painter.renderShape(r)}var i=Utils.getSelectedIds(),n=Utils.getSelectedLockedIds();Utils.mergeArray(i,n),Utils.unselect(),Utils.selectShape(i),Utils.showLinkerCursor()}),Designer.addFunction("setShapeProps",function(e){var t=Utils.getSelected();if(0!=t.length&&e){for(var r=[],i=[],n=0;n0&&Model.updateMulti(r);var d=Utils.getSelectedIds();Utils.unselect(),Utils.selectShape(d)}}),Designer.addFunction("addDataAttribute",function(e){var t=Utils.getSelectedIds(),r=Model.getShapeById(t[0]);r.dataAttributes||(r.dataAttributes=[]),e.id=Utils.newId(),e.category="custom",r.dataAttributes.push(e),MessageSource.doWithoutUpdateDock(function(){Model.update(r)})}),Designer.addFunction("updateDataAttribute",function(e){var t=Utils.getSelectedIds(),r=Model.getShapeById(t[0]);r.dataAttributes||(r.dataAttributes=[]);for(var i=!1,n=0;n=i&&(r=!0),e.to[t]>=i&&(r=!0);for(let o=0;o=i&&(r=!0);return r}function filterShapeAndLine(e,t){var i=Model.define.elements,r=[],o=[],n=[],a=[],l=[],s=0,d=[],p=0,h=[],g=[];for(let e in i)null==i[e].points?r.push(i[e]):o.push(i[e]),"lane"==i[e].category&&n.push(i[e]);for(let i=0;it?h.push(r[i]):r[i].props.x<=t&&r[i].props.x+r[i].props.w/2>=t?(a.push(r[i]),h.push(r[i])):r[i].props.x+r[i].props.w/2=t?l.push(r[i]):d.push(r[i]):"y"==e&&(r[i].props[e]>t?h.push(r[i]):r[i].props.y<=t&&r[i].props.y+r[i].props.h/2>=t?(a.push(r[i]),h.push(r[i])):r[i].props.y+r[i].props.h/2=t?l.push(r[i]):d.push(r[i]));for(let i=0;ie.id==o[i].id);isLineBelowOrRight(o[i],e,t)&&-1==r&&g.push(o[i])}if(d.length>0&&"y"==e?p=Math.max.apply(Math,d.map(e=>e.props.y+e.props.h)):d.length>0&&"x"==e&&(p=Math.max.apply(Math,d.map(e=>e.props.x+e.props.w))),a.concat(l).length>0&&(s=Math.max.apply(Math,a.concat(l).map(t=>t.props[e]))),a.length>0){let e=Utils.getOutlinkers(a);for(let t=0;ti.id==e[t].id)&&g.push(e[t])}return{passedShapes:a,passedMoreShapes:l,passedShapesEdge:s,sublineSideEdge:p,movingShapes:h,movingLines:g,laneArr:n}}function moveShapeAndFile(e,t,i){console.log("间距调节方法调用");var r=filterShapeAndLine(e,t),o=r.movingLines,n=r.movingShapes,a=r.passedShapes,l=r.passedMoreShapes;if(0==r.laneArr.length){"y"==e?Designer.op.moveShape(n,{x:0,y:i}):"x"==e&&Designer.op.moveShape(n,{x:i,y:0});for(let r=0;re.id==o[r].from.id),s=a.findIndex(e=>e.id==o[r].to.id),d=l.findIndex(e=>e.id==o[r].from.id),p=l.findIndex(e=>e.id==o[r].to.id);for(let n=0;nt&&(o[r].points[n][e]+=i);if(o[r].from[e]>t&&-1==d){if(o[r].from[e]+=i,"y"==e){if(o[r].from.x==o[r].to.x&&2==o[r].points.length)for(let e=0;et&&-1==p){if(o[r].to[e]+=i,"y"==e){if(o[r].from.x==o[r].to.x&&2==o[r].points.length)for(let e=0;e0&&o[r].to[e]<=t&&-1!==s){for(let t=0;t0&&Model.updateMulti(s)}else moveLanes(e,t,i)}function moveLanes(e,t,i){var r=filterShapeAndLine(e,t),o=r.movingLines,n=r.movingShapes,a=r.passedShapes,l=r.passedMoreShapes,s=r.laneArr,d=[],p=[];for(let e=0;e{let r=i.lanes.findIndex(e=>""==e.parent),o=i.lanes.findIndex(e=>"verticalSeparatorBar"==e.name),n=i.lanes.findIndex(e=>"horizontalSeparatorBar"==e.name),a=i.lanes[r],l=i.lanes[o],s=i.lanes[n];if("x"==e){let e=a.props.xt,r=void 0!==l&&l.props.xt,o=a.props.xt;"verticalPool"==i.name?i.isPassed=e&&!r:"horizontalPool"==i.name&&(i.isPassed=e&&!o),i.lanes.forEach(e=>{e.props.x+e.props.w>t&&i.changed.push(e)})}else if("y"==e){let e=a.props.yt,r=void 0!==s&&s.props.yt,o=a.props.yt;"verticalPool"==i.name?i.isPassed=e&&!o:"horizontalPool"==i.name&&(i.isPassed=e&&!r),i.lanes.forEach(e=>{e.props.y+e.props.h>t&&i.changed.push(e)})}}),"x"==e?(Designer.op.moveShape(n.filter(e=>"lane"!==e.category),{x:i,y:0}),d.forEach(e=>{e.changed.forEach(r=>{if(e.isPassed){if(e.isPassed){if("verticalPool"==e.name)switch(r.name){case"verticalPool":r.props.w+=i;break;case"verticalLane":r.props.w+=r.props.xt?i:0,r.props.x+=r.props.x>t?i:0;break;case"horizontalSeparator":r.props.w+=i}if("horizontalPool"==e.name)switch(r.name){case"horizontalPool":case"horizontalLane":r.props.w+=i;break;case"verticalSeparator":r.props.w+=r.props.xt?i:0,r.props.x+=r.props.x>t?i:0;break;case"horizontalSeparatorBar":r.props.w+=i}}}else r.props.x+=i;p.push(r),Designer.painter.renderShape(r)})})):"y"==e&&(Designer.op.moveShape(n.filter(e=>"lane"!==e.category),{x:0,y:i}),d.forEach(e=>{e.changed.forEach(r=>{if(e.isPassed){if(e.isPassed){if("verticalPool"==e.name)switch(r.name){case"verticalPool":case"verticalLane":r.props.h+=i;break;case"horizontalSeparator":r.props.h+=r.props.yt?i:0,r.props.y+=r.props.y>t?i:0;break;case"verticalSeparatorBar":r.props.h+=i}if("horizontalPool"==e.name)switch(r.name){case"horizontalPool":r.props.h+=i;break;case"horizontalLane":r.props.h+=r.props.yt?i:0,r.props.y+=r.props.y>t?i:0;break;case"verticalSeparator":r.props.h+=i}}}else r.props.y+=i;p.push(r),Designer.painter.renderShape(r)})}));for(let r=0;re.id==o[r].from.id),s=a.findIndex(e=>e.id==o[r].to.id),d=l.findIndex(e=>e.id==o[r].from.id),p=l.findIndex(e=>e.id==o[r].to.id);for(let n=0;nt&&(o[r].points[n][e]+=i);if(o[r].from[e]>t&&-1==d)o[r].from[e]+=i;else if(o[r].from[e]<=t&&-1!==n){for(let t=0;tt&&-1==p)o[r].to[e]+=i;else if(a.length>0&&o[r].to[e]<=t&&-1!==s){for(let t=0;t"lane"!==e.category).concat(p).concat(o);h.length>0&&Model.updateMulti(h)}function getCanvasContentEdge(){var e={top:0,bottom:0,left:0,right:0},t=Model.define.elements,i=[],r=[];for(let e in t)if(null==t[e].points)i.push({x:t[e].props.x,type:"shape",shapeWidth:t[e].props.w}),r.push({y:t[e].props.y,type:"shape",shapeHeight:t[e].props.h});else{i.push({x:t[e].from.x,type:"line"}),i.push({x:t[e].to.x,type:"line"}),r.push({y:t[e].from.y,type:"line"}),r.push({y:t[e].to.y,type:"line"});for(let o=0;oe.x)),e.top=Math.min.apply(Math,r.map(e=>e.y));for(let e=0;ee.x)),e.bottom=Math.max.apply(Math,r.map(e=>e.y)),e}function addDefaultSchemaShape(){Schema.addCategory({name:"standard",text:"Standard",dataAttributes:[]}),Schema.addShape({name:"standardText",title:"",text:"",category:"standard",attribute:{linkable:!1},props:{w:160,h:40},anchors:[],textBlock:{x:0,y:0,w:"w",h:"h"},path:[{lineStyle:{lineWidth:0},fillStyle:{type:"none"},actions:{ref:"rectangle"}}]}),Schema.addShape({name:"standardImage",title:"",text:"",attribute:{linkable:!1,editable:!1,visible:!1},category:"standard",props:{w:100,h:70},path:[{lineStyle:{lineWidth:0},actions:{ref:"rectangle"}}]}),Schema.addShape({name:"standardRectangle",title:"",text:"",attribute:{visible:!1},category:"standard",props:{w:100,h:70},path:[{actions:{ref:"rectangle"}}]})}Designer.addFunction("open",function(definition){if(""!=definition){"string"==typeof definition&&eval("definition = "+definition),$(".shape_box").remove(),Model.define.elements={},Model.persistence.elements={},Model.define.page=definition.page,Model.define.processProperties=definition.processProperties,Model.define.processDocument=definition.processDocument,Model.define.uuid=definition.uuid,process.title=definition.title,Model.persistence.page=Utils.copy(definition.page),Designer.initialize.initCanvas();var shapes=definition.elements,shapeCount=0;for(var shapeId in shapes){var shape=shapes[shapeId];"linker"!=shape.name&&(Schema.initShapeFunctions(shape),Designer.painter.renderShape(shape),Model.add(shape,!1)),shapeCount++}for(var shapeId in shapes){var shape=shapes[shapeId];"linker"==shape.name&&(Designer.painter.renderLinker(shape),Model.add(shape,!1))}0==shapeCount&&Model.build(),Navigator.draw()}}),Designer.addFunction("selectAll",function(){var e=Model.define.elements,t=[];for(var i in e)t.push(i);Utils.selectShape(t)}),Designer.addFunction("selectVertical",function(){var e;console.log("调节垂直间距");var t,i=$("#designer_subline1"),r=$("#designer_subline2"),o=$("#canvas_container"),n=$("#designer_canvas");o.bind("mousemove.drag",function(a){Designer.op.destroy();let l=Utils.getRelativePos(a.pageX,a.pageY,n);i.css({display:"block","z-index":Model.orderList.length+4,width:Model.define.page.width,height:0,borderStyle:"dotted",borderWidth:"1px",left:0,top:l.y}),o.bind("mousedown.drag",function(a){Designer.op.destroy(),o.unbind("mousemove.drag");let l=Utils.getRelativePos(a.pageX,a.pageY,n);e=l.y,t=filterShapeAndLine("y",e),i.css({display:"block","z-index":Model.orderList.length+4,width:Model.define.page.width,height:0,borderStyle:"dotted",borderWidth:"1px",left:0,top:l.y}),r.css({display:"block","z-index":Model.orderList.length+5,width:Model.define.page.width,height:0,borderStyle:"dotted",borderWidth:"1px",left:0,top:l.y,cursor:"move"}),o.bind("mousemove.drag",function(o){Designer.op.destroy();var a=Utils.getRelativePos(o.pageX,o.pageY,n);if(a.y>=e)i.css({borderColor:"rgb(114,253,107)",backgroundColor:"rgba(114,253,107,0.5)",height:a.y-e}),r.css({borderColor:"rgb(114,253,107)",backgroundColor:"transparent",height:0}),r.css({top:a.y});else{let o=t.passedShapesEdge-t.sublineSideEdge>0?t.passedShapesEdge:t.sublineSideEdge;a.y0&&moveShapeAndFile("y",e,o),n>0&&moveShapeAndFile("y",e,0-n),i.css({borderColor:"#333",backgroundColor:"transparent",height:0}),r.css({borderColor:"#333",backgroundColor:"transparent",height:0}),i.hide(),r.hide();var a=getCanvasContentEdge(),l=Model.define.page;a.bottom>l.height-l.padding&&(Designer.setPageStyle({height:a.bottom+l.padding+30}),$("#page_size_w").spinner("value",a.bottom+l.padding+30)),$(document).unbind("mouseup.drop")})}),$(document).bind("mouseup.drag",function(){o.unbind("mousemove.drag"),o.unbind("mousedown.drag"),$(document).unbind("mouseup.drag")})})})}),Designer.addFunction("selectHorizontal",function(){var e;console.log("调节水平间距");var t,i=$("#designer_subline1"),r=$("#designer_subline2"),o=$("#canvas_container"),n=$("#designer_canvas");o.bind("mousemove.drag",function(a){Designer.op.destroy();let l=Utils.getRelativePos(a.pageX,a.pageY,n);i.css({display:"block","z-index":Model.orderList.length+4,width:0,height:Model.define.page.height,borderStyle:"dotted",borderWidth:"1px",left:l.x,top:0}),o.bind("mousedown.drag",function(a){Designer.op.destroy(),o.unbind("mousemove.drag");let l=Utils.getRelativePos(a.pageX,a.pageY,n);e=l.x,t=filterShapeAndLine("x",e),i.css({display:"block","z-index":Model.orderList.length+4,width:0,height:Model.define.page.height,borderStyle:"dotted",borderWidth:"1px",left:l.x,top:0}),r.css({display:"block","z-index":Model.orderList.length+5,width:0,height:Model.define.page.height,borderStyle:"dotted",borderWidth:"1px",left:l.x,top:0,cursor:"move"}),o.bind("mousemove.drag",function(o){Designer.op.destroy();var a=Utils.getRelativePos(o.pageX,o.pageY,n);if(a.x>=e)i.css({borderColor:"rgb(114,253,107)",backgroundColor:"rgba(114,253,107,0.5)",width:a.x-e}),r.css({borderColor:"rgb(114,253,107)",backgroundColor:"transparent",width:0}),r.css({left:a.x});else{let o=t.passedShapesEdge-t.sublineSideEdge>0?t.passedShapesEdge:t.sublineSideEdge;a.x0&&moveShapeAndFile("x",e,o),n>0&&moveShapeAndFile("x",e,0-n),i.css({borderColor:"#333",backgroundColor:"transparent",width:0}),r.css({borderColor:"#333",backgroundColor:"transparent",width:0}),i.hide(),r.hide();var a=getCanvasContentEdge(),l=Model.define.page;a.right>l.width-l.padding&&(Designer.setPageStyle({width:a.right+l.padding+30}),$("#page_size_w").spinner("value",a.right+l.padding+30)),$(document).unbind("mouseup.drop")})}),$(document).bind("mouseup.drag",function(){o.unbind("mousemove.drag"),o.unbind("mousedown.drag"),$(document).unbind("mouseup.drag")})})})}),Designer.addFunction("setFontStyle",function(e){var t=Utils.getSelected();if(0!=t.length){for(var i=0;i1&&Designer.painter.drawControls(n),Model.updateMulti(i),Utils.showLinkerControls()}}),Designer.addFunction("matchSize",function(e){var t=Utils.getSelected();if(0!=t.length&&e){for(var i=null,r=null,o=[],n=0;ni)&&(i=l.props.w),(null==r||l.props.h>r)&&(r=l.props.h))}"auto"==e.w&&(e.w=i),"auto"==e.h&&(e.h=r),Utils.removeAnchors();var a=[];for(n=0;n=0;r--){i-=1,(g=t[r]).props.zindex=i}}else if("backward"==e){var p=null;for(n=null,r=0;r=0;i--){var r=Model.orderList[i];if(!(r.zindex>=e.props.zindex||Utils.isSelected(r.id))){var o=Model.getShapeById(r.id),n=Utils.getShapeBox(o);if(Utils.rectCross(t,n))return o}}return null}}),Designer.addFunction("group",function(){var e=Utils.getSelected();if(!(e.length<2)){for(var t=Utils.newId(),i=0;i4&&(e=4),Utils.hideLinkerCursor(),Designer.config.scale=e,Designer.initialize.initCanvas(),Model.define.elements){var i=Model.define.elements[t];Designer.painter.renderShape(i)}var r=Utils.getSelectedIds(),o=Utils.getSelectedLockedIds();Utils.mergeArray(r,o),Utils.unselect(),Utils.selectShape(r),Utils.showLinkerCursor()}),Designer.addFunction("setShapeProps",function(e){var t=Utils.getSelected();if(0!=t.length&&e){for(var i=[],r=[],o=0;o0&&Model.updateMulti(i);var d=Utils.getSelectedIds();Utils.unselect(),Utils.selectShape(d)}}),Designer.addFunction("addDataAttribute",function(e){var t=Utils.getSelectedIds(),i=Model.getShapeById(t[0]);i.dataAttributes||(i.dataAttributes=[]),e.id=Utils.newId(),e.category="custom",i.dataAttributes.push(e),MessageSource.doWithoutUpdateDock(function(){Model.update(i)})}),Designer.addFunction("updateDataAttribute",function(e){var t=Utils.getSelectedIds(),i=Model.getShapeById(t[0]);i.dataAttributes||(i.dataAttributes=[]);for(var r=!1,o=0;o