ProcessStarter.min.js 7.5 KB

1
  1. MWF.require("MWF.widget.Mask",null,false);MWF.xApplication.process=MWF.xApplication.process||{};MWF.xApplication.process.TaskCenter=MWF.xApplication.process.TaskCenter||{};MWF.xApplication.process.TaskCenter.ProcessStarter=new Class({Extends:MWF.widget.Common,Implements:[Options,Events],options:{style:"default"},initialize:function(t,e,s){this.setOptions(s);this.path="/x_component_process_TaskCenter/$ProcessStarter/";this.cssPath="/x_component_process_TaskCenter/$ProcessStarter/"+this.options.style+"/css.wcss";this._loadCss();MWF.xDesktop.requireApp("process.TaskCenter","$ProcessStarter."+MWF.language,null,false);this.lp=MWF.xApplication.process.TaskCenter.ProcessStarter.lp;this.data=t;this.app=e},load:function(){this.getOrgAction(function(){if(this.app.desktop.session.user.name){this.orgAction.listIdentityByPerson(function(t){this.identitys=t.data;if(t.data.length){if(t.data.length==1){var e={title:this.data.name+"-"+this.lp.unnamed,identity:this.identitys[0].name};this.mask=new MWF.widget.Mask({style:"desktop"});this.mask.loadNode(this.app.content);this.getWorkAction(function(){this.workAction.startWork(function(t){this.mask.hide();this.fireEvent("started",[t.data,e.title,this.data.name]);this.app.refreshAll();this.app.notice(this.lp.processStarted,"success")}.bind(this),null,this.data.id,e)}.bind(this))}else{this.createMarkNode();this.createAreaNode();this.createStartNode();this.areaNode.inject(this.markNode,"after");this.areaNode.fade("in");this.setStartNodeSize();this.setStartNodeSizeFun=this.setStartNodeSize.bind(this);this.app.addEvent("resize",this.setStartNodeSizeFun)}}}.bind(this),null,this.app.desktop.session.user.id)}}.bind(this))},createMarkNode:function(){this.markNode=new Element("div#mark",{styles:this.css.markNode,events:{mouseover:function(t){t.stopPropagation()},mouseout:function(t){t.stopPropagation()}}}).inject(this.app.content)},createAreaNode:function(){this.areaNode=new Element("div#area",{styles:this.css.areaNode})},createStartNode:function(){this.createNode=new Element("div",{styles:this.css.createNode}).inject(this.areaNode);this.createNewNode=new Element("div",{styles:this.css.createNewNode}).inject(this.createNode);this.createCloseNode=new Element("div",{styles:this.css.createCloseNode}).inject(this.createNode);this.createCloseNode.addEvent("click",function(t){this.cancelStartProcess(t)}.bind(this));this.formNode=new Element("div",{styles:this.css.formNode}).inject(this.createNode);var t='<table width="100%" height="90%" border="0" cellPadding="0" cellSpacing="0">'+'<tr><td colSpan="2" style="height: 50px; line-height: 60px; text-align: center; font-size: 24px; font-weight: bold">'+this.lp.start+" - "+this.data.name+"</td></tr>"+'<tr><td colSpan="2" style="height: 40px; color: #0044cc; line-height: 60px; text-align: center; font-size: 18px; font-weight: bold">'+this.lp.selectStartIdentity+"</td></tr>"+'<tr><td colSpan="2" id="form_startIdentity"></td></tr>'+"</table>";this.formNode.set("html",t);this.identityArea=this.formNode.getElementById("form_startIdentity");MWF.xDesktop.requireApp("Organization","PersonExplorer",function(){var t={data:this.app.desktop.session.user,explorer:{app:{lp:this.lp},actions:this.orgAction}};var e=this;this.identitys.each(function(s){var i=new MWF.xApplication.Organization.PersonExplorer.Identity(this.identityArea,s,t,this.css);i.node.store("identity",i);i.node.addEvents({mouseover:function(){this.setStyles(e.css.identityNode_over);this.getFirst().getLast().setStyles(e.css.identityInforNameTextNode_over);this.getFirst().getNext().getFirst().setStyles(e.css.identityTitleNode_over);this.getFirst().getNext().getNext().getFirst().setStyles(e.css.identityTitleNode_over);this.getFirst().getNext().getNext().getNext().getFirst().setStyles(e.css.identityTitleNode_over)},mouseout:function(){this.setStyles(e.css.identityNode);this.getFirst().getLast().setStyles(e.css.identityInforNameTextNode);this.getFirst().getNext().getFirst().setStyles(e.css.identityTitleNode);this.getFirst().getNext().getNext().getFirst().setStyles(e.css.identityTitleNode);this.getFirst().getNext().getNext().getNext().getFirst().setStyles(e.css.identityTitleNode)},click:function(){var t=this.retrieve("identity");if(t){e.okStartProcess(t.data.name)}}})}.bind(this))}.bind(this))},setStartFormContent:function(){this.dateArea=this.formNode.getElementById("form_startDate");var t=new Date;this.dateArea.set("text",t.format("%Y-%m-%d %H:%M"));this.departmentSelArea=this.formNode.getElementById("form_startDepartment");this.identityArea=this.formNode.getElementById("form_startIdentity");this.getOrgAction(function(){this.loadDepartments()}.bind(this))},loadDepartments:function(){var t=this.identitys.length==1;this.identitys.each(function(e){var s=new MWF.xApplication.process.TaskCenter.ProcessStarter.DepartmentSel(e,this,this.departmentSelArea,this.identityArea);if(t)s.selected()}.bind(this))},getOrgAction:function(t){if(!this.orgAction){MWF.xDesktop.requireApp("Organization","Actions.RestActions",function(){this.orgAction=new MWF.xApplication.Organization.Actions.RestActions;if(t)t()}.bind(this))}else{if(t)t()}},setStartNodeSize:function(){var t=this.app.content.getSize();var e=this.app.content.getSize();this.markNode.setStyles({width:""+e.x+"px",height:""+e.y+"px"});this.areaNode.setStyles({width:""+t.x+"px",height:""+t.y+"px"});var s=t.y*.7;var i=t.y*.3/2;this.createNode.setStyles({height:""+s+"px","margin-top":""+i+"px"});var n=this.identitys.length*294;this.formNode.setStyles({width:""+n+"px"});n=n+60;this.createNode.setStyles({width:""+n+"px"})},cancelStartProcess:function(t){this.markNode.destroy();this.areaNode.destroy()},okStartProcess:function(t){var e={title:this.data.name+"-"+this.lp.unnamed,identity:t};if(!e.identity){this.departmentSelArea.setStyle("border-color","red");this.app.notice(this.lp.selectStartId,"error")}else{this.mask=new MWF.widget.Mask({style:"desktop"});this.mask.loadNode(this.areaNode);this.getWorkAction(function(){this.workAction.startWork(function(t){this.mask.hide();this.markNode.destroy();this.areaNode.destroy();this.fireEvent("started",[t.data,e.title,this.data.name]);this.app.refreshAll();this.app.notice(this.lp.processStarted,"success")}.bind(this),null,this.data.id,e)}.bind(this))}},getWorkAction:function(t){if(!this.workAction){MWF.xDesktop.requireApp("process.TaskCenter","Actions.RestActions",function(){this.workAction=new MWF.xApplication.process.TaskCenter.Actions.RestActions;if(t)t()}.bind(this))}else{if(t)t()}}});MWF.xApplication.process.TaskCenter.ProcessStarter.DepartmentSel=new Class({initialize:function(t,e,s,i){this.data=t;this.starter=e;this.container=s;this.idArea=i;this.css=this.starter.css;this.isSelected=false;this.load()},load:function(){this.node=new Element("div",{styles:this.css.departSelNode}).inject(this.container);this.starter.orgAction.getDepartmentByIdentity(function(t){this.node.set("text",t.data.name)}.bind(this),null,this.data.name);this.node.addEvents({mouseover:function(){if(!this.isSelected)this.node.setStyles(this.css.departSelNode_over)}.bind(this),mouseout:function(){if(!this.isSelected)this.node.setStyles(this.css.departSelNode_out)}.bind(this),click:function(){this.selected()}.bind(this)})},selected:function(){if(!this.isSelected){if(this.starter.currentDepartment)this.starter.currentDepartment.unSelected();this.node.setStyles(this.css.departSelNode_selected);this.isSelected=true;this.starter.currentDepartment=this;this.idArea.set({text:this.data.display,value:this.data.name})}},unSelected:function(){if(this.isSelected){if(this.starter.currentDepartment)this.starter.currentDepartment=null;this.node.setStyles(this.css.departSelNode);this.isSelected=false}}});