MWF.xApplication.Execution=MWF.xApplication.Execution||{};MWF.xDesktop.requireApp("Template","MPopupForm",null,false);MWF.xDesktop.requireApp("Template","MForm",null,false);MWF.xDesktop.requireApp("Execution","Attachment",null,false);MWF.xApplication.Execution.WorkForm=new Class({Extends:MPopupForm,Implements:[Options,Events],options:{style:"default",width:"800",height:"100%",hasTop:true,hasIcon:false,hasBottom:true,title:"",draggable:false,closeAction:true},initialize:function(explorer,actions,data,options){this.setOptions(options);this.explorer=explorer;this.app=explorer.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=data||{};this.actions=actions},load:function(){if(this.options.isNew){if(this.options.parentWorkId){this.actions.getBaseWorkInfo(this.options.parentWorkId,function(json){if(json.data){this.parentWorkData=json.data}}.bind(this),function(xhr,text,error){this.showErrorMessage(xhr,text,error)}.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(json){if(json.data){this.data=json.data}}.bind(this),function(xhr,text,error){this.showErrorMessage(xhr,text,error)}.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 html=""+""+" "+" "+""+" "+" "+" "+" "+""+" "+" "+" "+" "+""+" "+" "+" "+" "+""+" "+" "+""+" "+""+" "+""+""+" "+""+" "+""+"
"+"
"+"
"+"
"+"
"+"
"+"
"+"
"+"
"+"
"+"
"+"
";this.formTableArea.set("html",html);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 taObj=this.formTableArea.getElements("textarea");taObj.setStyles({height:"70px"});this.attachmentArea=this.formTableArea.getElement("[item='attachments']");this.loadAttachment(this.attachmentArea);this.tmpLp=this.lp.processInfo;this.processInfo=new Element("div.processInfo",{styles:this.css.processInfoDiv}).inject(this.formTableArea);this.processInfoTitle=new Element("div.processInfoTitle",{styles:this.css.processInfoTitleDiv,text:this.tmpLp.title}).inject(this.processInfo);this.processInfoContent=new Element("div.processInfoContent",{styles:this.css.processInfoContent}).inject(this.processInfo);var tHead="";var tBody="";tBody+="";tBody+="";tBody+="";tBody+="";tBody+="";tBody+="";if(this.data.workDeployAuthorizeRecords){this.data.workDeployAuthorizeRecords.each(function(d){tBody+="";tBody+="";tBody+="";tBody+="";tBody+="";tBody+="";tBody+=""}.bind(this))}var tBottom="
"+this.tmpLp.operate+""+this.tmpLp.time+""+this.tmpLp.source.split("@")[0]+""+this.tmpLp.target.split("@")[0]+""+this.tmpLp.opinion+"
"+d.operationTypeCN+""+d.operationTime+""+d.source.split("@")[0]+""+d.target.split("@")[0]+""+d.opinion+"
";this.processInfoContent.set("html",tHead+tBody+tBottom);this.formatStyles(this.processInfoContent)},formatStyles:function(obj){obj.getElements("[styles]").each(function(el){var styles=el.get("styles");if(styles&&this.css[styles]){el.setStyles(this.css[styles])}}.bind(this))},getItemTemplate:function(lp){_self=this;return{centerWorkTitle:{text:lp.centerWorkTitle+":",type:"innerText",value:this.data.centerWorkInfo?this.data.centerWorkInfo.title:this.data.centerWorkTitle?this.data.centerWorkTitle.title:""},workType:{text:lp.workType+":",type:"select",notEmpty:true,selectValue:lp.workTypeValue.split(",")},workLevel:{text:lp.workLevel+":",type:"select",notEmpty:true,selectValue:lp.workLevelValue.split(",")},timeLimit:{text:lp.timeLimit+":",tType:"date",name:"completeDateLimitStr",notEmpty:true,attr:{readonly:true}},reportCycle:{text:lp.reportCycle+":",type:"select",notEmpty:true,selectText:lp.reportCycleText.split(","),className:_self.isEdited||_self.isNew?"inputSelectUnformatWidth":"",event:{change:function(item,ev){if(item.get("value")==lp.reportCycleText.split(",")[0]){this.form.getItem("reportDay").resetItemOptions(lp.weekDayValue.split(","),lp.weekDayText.split(","))}else if(item.get("value")==lp.reportCycleText.split(",")[1]){this.form.getItem("reportDay").resetItemOptions(lp.monthDayValue.split(","),lp.monthDayText.split(","))}}.bind(this)}},reportDay:{type:"select",name:"reportDayInCycle",notEmpty:true,selectValue:!this.data.reportCycle||this.data.reportCycle==lp.reportCycleText.split(",")[0]?lp.weekDayValue.split(","):lp.monthDayValue.split(","),selectText:!this.data.reportCycle||this.data.reportCycle==lp.reportCycleText.split(",")[0]?lp.weekDayText.split(","):lp.monthDayText.split(","),className:_self.isEdited||_self.isNew?"inputSelectUnformatWidth":""},dutyDepartment:{type:"org",orgType:"unit",text:lp.dutyDepartment+":",name:"responsibilityUnitName",notEmpty:true,attr:{readonly:true},event:{change:function(item){var department=item.getValue(",");if(department){_self.getDepartmentLeader(department,function(leader){_self.form.getItem("dutyPerson").setValue(leader)})}}}},dutyPerson:{type:"org",orgType:"identity",text:lp.dutyPerson+":",count:1,name:"responsibilityIdentity",notEmpty:true,attr:{readonly:true},onQuerySelect:function(item){var department=this.form.getItem("dutyDepartment").getValue();department=typeOf(department)=="string"?[department]:department;var list=[];(department||[]).each(function(d){return list.push(d.split("@")[0])});item.options.units=list||[]}.bind(this)},secondDepartment:{text:lp.secondDepartment+":",type:"org",orgType:"unit",name:"cooperateUnitNameList",value:this.cooperateUnitNameList?this.cooperateUnitNameList.join(","):"",count:0,attr:{readonly:true},event:{change:function(item){var deptstr=item.getValue(",");if(deptstr){var depts=deptstr.split(",");var users="";for(var i=0;i0){if(callback)callback(json.data.identityList[0])}}.bind(this),null,false)},showErrorMessage:function(xhr,text,error){var errorText=error;if(xhr)errorMessage=xhr.responseText;if(errorMessage!=""){var e=JSON.parse(errorMessage);if(e.message){this.app.notice(e.message,"error")}else{this.app.notice(errorText,"error")}}else{this.app.notice(errorText,"error")}}});