MWF.xApplication.Execution=MWF.xApplication.Execution||{};MWF.xDesktop.requireApp("Template","Explorer",null,false);MWF.xDesktop.requireApp("Template","MForm",null,false);MWF.xDesktop.requireApp("Execution","Attachment",null,false);MWF.xApplication.Execution.WorkForm=new Class({Extends:MWF.xApplication.Template.Explorer.PopupForm,Implements:[Options,Events],options:{style:"default",width:"800",height:"100%",top:0,left:0,hasTop:true,hasIcon:false,hasBottom:true,title:"",draggable:false,closeAction:true},initialize:function(t,e,i,s){this.setOptions(s);this.explorer=t;this.app=t.app;this.lp=this.app.lp.workForm;this.actions=this.app.restActions;this.path="/x_component_Execution/$WorkForm/";this.cssPath=this.path+this.options.style+"/css.wcss";this._loadCss();this.options.title=this.lp.title;this.data=i||{};this.actions=e},load:function(){if(this.options.isNew){if(this.options.parentWorkId){this.actions.getBaseWorkInfo(this.options.parentWorkId,function(t){if(t.data){this.parentWorkData=t.data}}.bind(this),function(t,e,i){this.showErrorMessage(t,e,i)}.bind(this),false)}else if(this.options.centerWorkId){this.data.centerId=this.options.centerWorkId}else if(this.data.centerWorkId){this.data.centerId=this.data.centerWorkId}}else{if(this.data.id){this.id=this.data.id}else if(this.options.id){this.id=this.options.id}this.actions.getBaseWorkInfo(this.id,function(t){if(t.data){this.data=t.data}}.bind(this),function(t,e,i){this.showErrorMessage(t,e,i)}.bind(this),false)}if(this.options.isNew){this.create()}else if(this.options.isEdited){this.edit()}else{this.open()}},createTopNode:function(){if(!this.formTopNode){this.formTopNode=new Element("div.formTopNode",{styles:this.css.formTopNode}).inject(this.formNode);this.formTopIconNode=new Element("div",{styles:this.css.formTopIconNode}).inject(this.formTopNode);this.formTopTextNode=new Element("div",{styles:this.css.formTopTextNode,text:this.options.title+(this.data.title?"-"+this.data.title:"")}).inject(this.formTopNode);if(this.options.closeAction){this.formTopCloseActionNode=new Element("div",{styles:this.css.formTopCloseActionNode}).inject(this.formTopNode);this.formTopCloseActionNode.addEvent("click",function(){this.close()}.bind(this))}this.formTopContentNode=new Element("div",{styles:this.css.formTopContentNode}).inject(this.formTopNode);this._createTopContent()}},_createTopContent:function(){},_createTableContent:function(){var t="
"+""+" | "+" | "+" | "+" | "+"
"+" | "+" | "+" | "+" | "+"
"+" | "+" | "+" | "+" | "+"
"+" | "+" | "+"
"+" | "+" "+" "+" | "+"
"+" | "+" "+" "+" | "+"
"+"
"+" | "+" "+" "+" | "+"
"+" | "+" "+" | "+"
"+"
";this.formTableArea.set("html",t);this.loadForm()},loadForm:function(){if(this.parentWorkData){this.data.parentWorkId=this.parentWorkData.id;this.data.workDetail=this.parentWorkData.workDetail;this.data.centerId=this.parentWorkData.centerId}this.form=new MForm(this.formTableArea,this.data,{style:"execution",isEdited:this.isEdited||this.isNew,itemTemplate:this.getItemTemplate(this.lp)},this.app);this.form.load();var t=this.formTableArea.getElements("textarea");t.setStyles({height:"70px"});this.attachmentArea=this.formTableArea.getElement("[item='attachments']");this.loadAttachment(this.attachmentArea)},getItemTemplate:function(t){_self=this;return{workType:{text:t.workType+":",type:"select",notEmpty:true,selectValue:t.workTypeValue.split(",")},workLevel:{text:t.workLevel+":",type:"select",notEmpty:true,selectValue:t.workLevelValue.split(",")},timeLimit:{text:t.timeLimit+":",tType:"date",name:"completeDateLimitStr",notEmpty:true},reportCycle:{text:t.reportCycle+":",type:"select",notEmpty:true,selectText:t.reportCycleText.split(","),className:"inputSelectUnformatWidth",event:{change:function(e,i){if(e.get("value")==t.reportCycleText.split(",")[0]){this.form.getItem("reportDay").resetItemOptions(t.weekDayValue.split(","),t.weekDayText.split(","))}else if(e.get("value")==t.reportCycleText.split(",")[1]){this.form.getItem("reportDay").resetItemOptions(t.monthDayValue.split(","),t.monthDayText.split(","))}}.bind(this)}},reportDay:{type:"select",name:"reportDayInCycle",notEmpty:true,selectValue:!this.data.reportCycle||this.data.reportCycle==t.reportCycleText.split(",")[0]?t.weekDayValue.split(","):t.monthDayValue.split(","),selectText:!this.data.reportCycle||this.data.reportCycle==t.reportCycleText.split(",")[0]?t.weekDayText.split(","):t.monthDayText.split(","),className:"inputSelectUnformatWidth"},dutyDepartment:{text:t.dutyDepartment+":",tType:"department",name:"responsibilityOrganizationName",notEmpty:true,event:{change:function(t){var e=t.getValue();if(e){_self.getDepartmentLeader(e,function(t){_self.form.getItem("dutyPerson").setValue(t)})}}}},dutyPerson:{text:t.dutyPerson+":",tType:"identity",count:1,name:"responsibilityIdentity",notEmpty:true,onQuerySelect:function(t){var e=this.form.getItem("dutyDepartment").getValue();t.options.departments=e?[e]:[]}.bind(this)},secondDepartment:{text:t.secondDepartment+":",tType:"department",name:"cooperateOrganizationName",count:0,event:{change:function(t){var e=t.getValue();if(e){var i=e.split(",");var s="";for(var o=0;o0){if(e)e(t.data.identityList[0])}}.bind(this),null,this.app.lp.departmentLeader,t,false)},showErrorMessage:function(t,e,i){var s=i;if(t)errorMessage=t.responseText;if(errorMessage!=""){var o=JSON.parse(errorMessage);if(o.message){this.app.notice(o.message,"error")}else{this.app.notice(s,"error")}}else{this.app.notice(s,"error")}}});