MWF.xApplication = MWF.xApplication || {}; MWF.xApplication.process = MWF.xApplication.process || {}; MWF.xApplication.process.ProcessDesigner = MWF.xApplication.process.ProcessDesigner || {}; MWF.APPPD = MWF.xApplication.process.ProcessDesigner; MWF.require("MWF.widget.Common", null, false); MWF.xDesktop.requireApp("process.ProcessDesigner", "lp."+MWF.language, null, false); MWF.xDesktop.requireApp("process.ProcessDesigner", "Property", null, false); MWF.xDesktop.requireApp("process.ProcessDesigner", "Activity", null, false); MWF.xDesktop.requireApp("process.ProcessDesigner", "Route", null, false); MWF.xApplication.process.ProcessDesigner.Process = new Class({ Extends: MWF.widget.Common, Implements: [Options, Events], options: { "style": "default", "isView": false }, initialize: function(paper, process, designer, options){ this.setOptions(options); this.path = "/x_component_process_ProcessDesigner/$Process/"; this.cssPath = "/x_component_process_ProcessDesigner/$Process/"+this.options.style+"/css.wcss"; this._loadCss(); this.designer = designer; this.process = process; this.process.projectionData = (process.project) ? JSON.parse(process.project) : null; this.paper = paper; if(this.designer.application) this.process.applicationName = this.designer.application.name; if(this.designer.application) this.process.application = this.designer.application.id; // if(this.designer.category) this.process.processCategory = this.designer.category.data.id; // this.process.starterMode = "assign"; this.activityTemplates = null; this.routeTemplates = null; //activity list this.begin = null; this.ends = {}; this.cancels={}; this.manuals = {}; this.conditions = {}; this.choices = {}; this.splits = {}; this.parallels = {}; this.merges = {}; this.embeds = {}; this.delays = {}; this.invokes = {}; this.services = {}; this.agents = {}; this.messages = {}; this.activitys=[]; this.selectedActivitys = []; this.selectedActivityDatas = []; this.scripts = {}; this.routes = {}; this.routeDatas = {}; this.isGrid = true; //activity loaded this.loadedBegin = false; this.loadedEnds = false; this.loadedCancels = false; this.loadedConditions = false; this.loadedChoices = false; this.loadedManuals = false; this.loadedSplits = false; this.loadedParallels = false; this.loadedMerges = false; this.loadedEmbeds = false; this.loadedDelays = false; this.loadedInvokes = false; this.loadedServices = false; this.loadedAgents = false; this.loadedMessages = false; this.isCreateRoute = false; this.currentCreateRoute = null; this.isCopyRoute = false; this.currentCopyRoute = null; this.isBrokenLine = false; this.isChangeRouteTo = false; this.isChangeRouteFrom = false; this.currentChangeRoute = null; this.unSelectedEvent = true; this.panel = null; this.property = null; // this.isFocus = false; this.isNewProcess = (this.process.id) ? false : true; }, load : function(){ // if (this.isNewProcess){ // this.process.createTime = new Date().format('db'); // this.process.updateTime = new Date().format('db'); // } this.createPropertyPanel(); this.loadProcessActivitys(function(){ // this.loadProcessActivitys(); this.loadProcessRoutes(); this.loadActivityRoutes(); this.loadProcessScripts(); this.checkLoadRoutes(); if (this.isNewProcess) this.checkUUID(); this.fireEvent("postLoad"); }.bind(this)); this.setEvent(); this.setMenu(); this.showProperty(); }, checkLoadRoutes: function(){ Object.each(this.routes, function(route){ if (!route.loaded) route.load(); }); }, checkUUID: function(){ //新流程, 此处处理所有元素的id this.process.isNewProcess = true; var idCount = (this.process.begin) ? 2 : 1; idCount += (this.process.endList) ? this.process.endList.length : 0; idCount += (this.process.manualList) ? this.process.manualList.length : 0; idCount += (this.process.conditionList) ? this.process.conditionList.length : 0; idCount += (this.process.choiceList) ? this.process.choiceList.length : 0; idCount += (this.process.parallelList) ? this.process.parallelList.length : 0; idCount += (this.process.splitList) ? this.process.splitList.length : 0; idCount += (this.process.mergeList) ? this.process.mergeList.length : 0; idCount += (this.process.embedList) ? this.process.embedList.length : 0; idCount += (this.process.invokeList) ? this.process.invokeList.length : 0; idCount += (this.process.cancelList) ? this.process.cancelList.length : 0; idCount += (this.process.delayList) ? this.process.delayList.length : 0; idCount += (this.process.messageList) ? this.process.messageList.length : 0; idCount += (this.process.serviceList) ? this.process.serviceList.length : 0; idCount += (this.process.routeList) ? this.process.routeList.length : 0; this.designer.actions.getId(idCount, function(ids){ this.checkUUIDs = ids.data; //流程ID this.process.id = this.checkUUIDs.pop().id; this.process.createTime = new Date().format('db'); this.process.updateTime = new Date().format('db'); for (var i=0; i8){ this.paper.canvas.removeEvent("mousemove", this.checkSelectMultiMouseMoveBind); if (!this.isCreateRoute && !this.isCopyRoute && !this.isBrokenLine && !this.isChangeRouteTo && !this.isChangeRouteFrom){ var x = Math.min(p.x, pMove.x); var y = Math.min(p.y, pMove.y); var width = Math.abs(pMove.x-p.x); var height = Math.abs(pMove.y-p.y); var selectBox = this.paper.rect(x, y, width, height, 0).attr({ "fill": "#a8caec", "stroke": "#3399ff", "stroke-width": "0.8", "fill-opacity": 0.5 }); this.beginSelectMultiMouseMoveBind = function(e){ this.beginSelectMultiMouseMove(e, p, selectBox); }.bind(this); this.endSelectMultiMouseMoveBind = function(e){ return this.endSelectMulti(e, p, selectBox); }.bind(this); this.unSelectedAll(); this.paper.canvas.addEvent("mousemove", this.beginSelectMultiMouseMoveBind); this.paper.canvas.addEvent("mouseup", this.endSelectMultiMouseMoveBind); } } }, checkSelectMultiStop: function(){ this.paper.canvas.removeEvent("mousemove", this.checkSelectMultiMouseMoveBind); }, beginSelectMultiMouseMove: function(e, p, rect){ var pMove = {"x": e.event.offsetX, "y": e.event.offsetY}; var x = Math.min(p.x, pMove.x); var y = Math.min(p.y, pMove.y); var width = Math.abs(pMove.x-p.x); var height = Math.abs(pMove.y-p.y); // rect.attr("path", MWFRaphael.getRectPath(x, y, width, height, 0)); rect.attr({ //"path", MWFRaphael.getRectPath(x, y, width, height, 0) "x": x, "y": y, "width": width, "height": height }); this.checkSelectActivity(e, p, rect); }, endSelectMulti: function(e, p, rect){ rect.remove(); if (this.selectedActivityDatas.length){ this.panel.data = this.selectedActivityDatas; } this.paper.canvas.removeEvent("mousemove", this.beginSelectMultiMouseMoveBind); this.paper.canvas.removeEvent("mouseup", this.endSelectMultiMouseMoveBind); if (this.selectedActivitys.length){ this.unSelectedEvent = false; window.setTimeout(function(){this.unSelectedEvent = true;}.bind(this), 300); } return false; }, checkSelectActivity: function(e, p, rect){ var pMove = {"x": e.event.offsetX, "y": e.event.offsetY}; var x = Math.min(p.x, pMove.x); var y = Math.min(p.y, pMove.y); var toX = Math.max(p.x, pMove.x); var toY = Math.max(p.y, pMove.y); this.activitys.each(function(activity){ var ax = activity.center.x; var ay = activity.center.y; if (ax>x && axy && ay