Starter.min.js 12 KB

1
  1. MWF.require("MWF.widget.Mask",null,false);MWF.xApplication.cms=MWF.xApplication.cms||{};MWF.xApplication.cms.Index=MWF.xApplication.cms.Index||{};MWF.xApplication.cms.Index.Starter=new Class({Extends:MWF.widget.Common,Implements:[Options,Events],options:{style:"default",ignoreDrafted:false,categoryFlag:"",columnFlag:"",appFlag:""},initialize:function(t,e,i,s){this.setOptions(s);this.path="/x_component_cms_Index/$Starter/";this.cssPath="/x_component_cms_Index/$Starter/"+this.options.style+"/css.wcss";this._loadCss();MWF.xDesktop.requireApp("cms.Index","$Starter."+MWF.language,null,false);this.lp=MWF.xApplication.cms.Index.Starter.lp;this.columnData=t;this.categoryData=e;this.app=i},initData:function(){var t=this.options.appFlag||this.options.columnFlag;if(!this.columnData&&t){MWF.Actions.get("x_cms_assemble_control").getColumn(t,function(t){this.columnData=t.data}.bind(this),null,false)}var e=this.options.categoryFlag;if(!this.categoryData&&e){MWF.Actions.get("x_cms_assemble_control").getCategory(e,function(t){this.categoryData=t.data;if(!this.columnData){MWF.Actions.get("x_cms_assemble_control").getColumn(this.categoryData.appId,function(t){this.columnData=t.data}.bind(this),null,false)}}.bind(this),null,false)}},load:function(){this.initData();this.identityList=this.getIdentities();if(this.options.ignoreDrafted){this._load();this.fireEvent("postLoad")}else if(this.categoryData.workflowAppId&&this.categoryData.workflowFlag){this._load();this.fireEvent("postLoad")}else{var t={categoryIdList:[this.categoryData.id],creatorList:[layout.desktop.session.user.distinguishedName]};this.getDocumentAction(function(){this.documentAction.listDraftNext("(0)",1,t,function(t){if(t.data.length>0){this._openDocument(t.data[0].id);this.fireEvent("postLoad")}else{this._load();this.fireEvent("postLoad")}}.bind(this))}.bind(this))}},_load:function(){if(this.categoryData&&this.isIgnoreTitle()&&this.identityList.length==1){this.okStart()}else{this.createMarkNode();this.createAreaNode();this.createStartNode();this.checkSubject();this.areaNode.inject(this.markNode,"after");this.areaNode.fade("in");$("form_startSubject").focus();this.setStartNodeSize();this.setStartNodeSizeFun=this.setStartNodeSize.bind(this);this.app.addEvent("resize",this.setStartNodeSizeFun)}},_openDocument:function(t,e){var i=this;var s="cms.Document"+t;if(i.app.desktop.apps[s]){i.app.desktop.apps[s].setCurrent()}else{var a={readonly:false,documentId:t,appId:s,postPublish:function(){this.fireEvent("postPublish")}.bind(this)};this.app.desktop.openApplication(e,"cms.Document",a)}},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.formNode=new Element("div",{styles:this.css.formNode}).inject(this.createNode);var t=this.categoryData.name||this.categoryData.categoryName;var e='<table width="100%" height="90%" border="0" cellPadding="0" cellSpacing="0">'+'<tr><td colSpan="2" style="height: 60px; line-height: 60px; text-align: center; font-size: 24px; font-weight: bold">'+this.lp.start+" - "+t+"</td></tr>"+'<tr><td style="height: 30px; line-height: 30px; text-align: left">'+this.lp.department+":</td>"+'<td style="; text-align: left;" id="form_startDepartment"></td></tr>'+'<tr><td style="height: 30px; line-height: 30px; text-align: left">'+this.lp.identity+":</td>"+'<td style="; text-align: left;"><div id="form_startIdentity"></div></td></tr>'+'<tr><td style="height: 30px; line-height: 30px; text-align: left">'+this.lp.date+":</td>"+'<td style="; text-align: left;"><div id="form_startDate"></div></td></tr>'+'<tr><td style="height: 30px; line-height: 30px; text-align: left">'+this.lp.subject+":</td>"+'<td style="; text-align: left;"><input type="text" id="form_startSubject" '+'style="width: 99%; border:1px solid #999; background-color:#FFF; border-radius: 3px; box-shadow: 0px 0px 6px #CCC; '+'height: 26px;"/></td></tr>'+"</table>";this.formNode.set("html",e);this.setStartFormContent();this.cancelActionNode=new Element("div",{styles:this.css.cancelActionNode,text:this.lp.cancel}).inject(this.formNode);this.startOkActionNode=new Element("div",{styles:this.css.startOkActionNode,text:this.lp.ok}).inject(this.formNode);this.cancelActionNode.addEvent("click",function(t){this.cancelStart(t)}.bind(this));this.startOkActionNode.addEvent("click",function(t){this.okStart(t)}.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.loadDepartments()},isIgnoreTitle:function(){return this.categoryData&&this.categoryData.documentType!="信息"},checkSubject:function(){if(this.categoryData){if(this.isIgnoreTitle()){this.subjectInput.getParent("tr").setStyle("display","none")}else{this.subjectInput.getParent("tr").setStyle("display","")}}},loadDepartments:function(){MWF.Actions.get("x_organization_assemble_personal").getPerson(function(t){var e=t.data&&t.data.woIdentityList?t.data.woIdentityList:[];var i=[];e.each(function(t){if(t.distinguishedName)i.push(t)}.bind(this));var s=i.length==1?true:false;i.each(function(t){var e=new MWF.xApplication.cms.Index.Starter.DepartmentSel(t,this,this.departmentSelArea,this.identityArea);if(s)e.selected()}.bind(this))}.bind(this),null)},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 i=t.y*.8;var s=t.y*.2/2;if(i>500)i=500;this.createNode.setStyles({height:""+i+"px","margin-top":""+s+"px"});var a=this.createNewNode.getSize();var o=i*.7;if(o>250)o=250;var n=i*.3/2-a.y;this.formNode.setStyles({height:""+o+"px","margin-top":""+n+"px"})},cancelStart:function(t){var e=this;if($("form_startSubject").get("value")){this.app.confirm("warn",t,this.lp.start_cancel_title,this.lp.start_cancel,"320px","100px",function(){e.markNode.destroy();e.areaNode.destroy();this.close()},function(){this.close()},null,this.app.content)}else{this.markNode.destroy();this.areaNode.destroy()}},okStart:function(){if(this.categoryData.workflowAppId&&this.categoryData.workflowFlag){this._createProcessDocument()}else{this._createDocument()}},_createDocument:function(t){var e=$("form_startSubject").get("value")||"";this.getDocumentAction();var i={id:this.documentAction.getUUID(),isNewDocument:true,title:e,creatorIdentity:this.identityArea.get("value"),appId:this.categoryData.appId,categoryId:this.categoryData.id,form:this.categoryData.formId,formName:this.categoryData.formName,docStatus:"draft",categoryName:this.categoryData.name||this.categoryData.categoryName,categoryAlias:this.categoryData.alias||this.categoryData.categoryAlias,attachmentList:[]};if(!i.title&&!this.isIgnoreTitle()){$("form_startSubject").setStyle("border-color","red");$("form_startSubject").focus();this.app.notice(this.lp.inputSubject,"error")}else if(!i.creatorIdentity){this.departmentSelArea.setStyle("border-color","red");this.app.notice(this.lp.selectStartId,"error")}else{if(this.isIgnoreTitle())i.title="无标题";this.mask=new MWF.widget.Mask({style:"desktop"});this.mask.loadNode(this.areaNode);this.getDocumentAction(function(){this.documentAction.addDocument(i,function(t){this.mask.hide();this.markNode.destroy();this.areaNode.destroy();this._openDocument(t.data.id);this.app.notice(this.lp.Started,"success")}.bind(this),null)}.bind(this))}},getDocumentAction:function(t){if(!this.documentAction){this.documentAction=MWF.Actions.get("x_cms_assemble_control");if(t)t()}else{if(t)t()}},_createProcessDocument:function(t){var e=$("form_startSubject").get("value")||"";var i=this.categoryData.workflowFlag;var s={title:$("form_startSubject").get("value"),identity:this.identityArea.get("value")};if(!s.title||!this.isIgnoreTitle()){$("form_startSubject").setStyle("border-color","red");$("form_startSubject").focus();this.app.notice(this.lp.inputSubject,"error")}else if(!s.identity){this.departmentSelArea.setStyle("border-color","red");this.app.notice(this.lp.selectStartId,"error")}else{if(this.isIgnoreTitle())e="无标题";var a={cmsDocument:{isNewDocument:true,title:e,creatorIdentity:s.identity,appId:this.categoryData.appId,categoryId:this.categoryData.id,docStatus:"draft",categoryName:this.categoryData.name||this.categoryData.categoryName,categoryAlias:this.categoryData.alias||this.categoryData.categoryAlias,createTime:(new Date).format("db"),attachmentList:[]}};this.mask=new MWF.widget.Mask({style:"desktop"});this.mask.loadNode(this.areaNode);this.getDocumentAction(function(){MWF.Actions.get("x_processplatform_assemble_surface").startWork(function(t){this.mask.hide();this.markNode.destroy();this.areaNode.destroy();this.afterStartProcess(t.data,s.title,this.categoryData.workflowName,a);this.app.notice(this.lp.Started,"success")}.bind(this),null,i,s)}.bind(this))}},afterStartProcess:function(t,e,i,s){var a=[];var o=[];t.each(function(t){if(t.currentTaskIndex!=-1)o.push(t.taskList[t.currentTaskIndex].work);a.push(this.getStartWorkInforObj(t))}.bind(this));var n=o[0];MWF.Actions.get("x_processplatform_assemble_surface").saveData(function(){if(o.length==1){var t={workId:n};this.app.desktop.openApplication(null,"process.Work",t);this.createStartWorkResault(a,e,i,false)}else{this.createStartWorkResault(a,e,i,true)}}.bind(this),null,n,s)},getStartWorkInforObj:function(i){var s=[];var a="";i.taskList.each(function(t,e){s.push(t.person+"("+t.department+")");if(i.currentTaskIndex==e)a=t.id}.bind(this));return{activity:i.fromActivityName,users:s,currentTask:a}},createStartWorkResault:function(t,e,i,s){var a="";t.each(function(t){a+="<div><b>"+this.lp.nextActivity+'<font style="color: #ea621f">'+t.activity+"</font>, "+this.lp.nextUser+'<font style="color: #ea621f">'+t.users.join(", ")+"</font></b>";if(t.currentTask&&s){a+='&nbsp;&nbsp;&nbsp;&nbsp;<span value="'+t.currentTask+'">'+this.lp.deal+"</span></div>"}else{a+="</div>"}}.bind(this));var o={subject:this.lp.processStarted,content:"<div>"+this.lp.processStartedMessage+"“["+i+"]"+e+"”</div>"+a};var n=layout.desktop.message.addTooltip(o);var r=layout.desktop.message.addMessage(o);this.setStartWorkResaultAction(n);this.setStartWorkResaultAction(r)},setStartWorkResaultAction:function(t){var e=t.node.getElements("span");e.setStyles(this.css.dealStartedWorkAction);var i=this;e.addEvent("click",function(t){var e={taskId:this.get("value")};i.app.desktop.openApplication(t,"process.Work",e)})}});MWF.xApplication.cms.Index.Starter.DepartmentSel=new Class({initialize:function(t,e,i,s){this.data=t;this.starter=e;this.container=i;this.idArea=s;this.css=this.starter.css;this.isSelected=false;this.load()},load:function(){this.node=new Element("div",{styles:this.css.departSelNode}).inject(this.container);var t=this.data.woUnit?this.data.woUnit.name:this.lp.unnamedUnit;this.node.set("text",this.data.woUnit.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.name,value:this.data.distinguishedName})}},unSelected:function(){if(this.isSelected){if(this.starter.currentDepartment)this.starter.currentDepartment=null;this.node.setStyles(this.css.departSelNode);this.isSelected=false}}});