| 1 |
- MWF.xDesktop.requireApp("Attendance","Explorer",null,false);MWF.xDesktop.requireApp("Selector","package",null,false);MWF.xDesktop.requireApp("Template","MForm",null,false);MWF.xApplication.Attendance.MyAppeal=new Class({Extends:MWF.xApplication.Attendance.Explorer,Implements:[Options,Events],initialize:function(e,t,i,s){this.setOptions(s);this.app=t;this.path="/x_component_Attendance/$MyAppeal/";this.cssPath="/x_component_Attendance/$MyAppeal/"+this.options.style+"/css.wcss";this._loadCss();this.actions=i;this.node=$(e);this.initData();if(!this.personActions)this.personActions=new MWF.xAction.org.express.RestActions},load:function(){this.loadToolbar();this.loadFilter();this.loadContentNode();var e=((new Date).getMonth()+1).toString();if(e.length==1)e="0"+e;var t={status:"999",yearString:(new Date).getFullYear().toString(),monthString:e};this.loadView(t);this.setNodeScroll()},loadFilter:function(){this.fileterNode=new Element("div.fileterNode",{styles:this.css.fileterNode}).inject(this.node);var e="<table width='100%' bordr='0' cellpadding='5' cellspacing='0' style='width: 560px;font-size: 14px;color:#666'>"+"<tr>"+" <td styles='filterTableTitle' item='date'></td>"+" <td styles='filterTableTitle' lable='status'></td>"+" <td styles='filterTableValue' item='status'></td>"+" <td styles='filterTableTitle' lable='appealReason'></td>"+" <td styles='filterTableValue' item='appealReason'></td>"+" <td styles='filterTableValue' item='action'></td>"+"</tr>"+"</table>";this.fileterNode.set("html",e);MWF.xDesktop.requireApp("Template","MForm",function(){this.form=new MForm(this.fileterNode,{},{isEdited:true,itemTemplate:{date:{type:"innerText",value:(new Date).format(this.app.lp.dateFormatMonth)},status:{text:"申述状态",type:"select",value:"999",selectText:["所有状态","待处理","审批通过","审批未通过"],selectValue:["999","0","1","-1"]},appealReason:{text:"申述原因",type:"select",selectText:["","临时请假","出差","因公外出","其他"]},action:{value:"查询",type:"button",className:"filterButton",event:{click:function(){var e=this.form.getResult(true,",",true,true,false);if(!e)return;this.loadView(e)}.bind(this)}}}},this.app,this.css);this.form.load()}.bind(this),true)},setContentSize:function(){var e=this.toolbarNode?this.toolbarNode.getSize():{x:0,y:0};var t=this.app.titleBar?this.app.titleBar.getSize():{x:0,y:0};var i=this.fileterNode?this.fileterNode.getSize():{x:0,y:0};var s=this.node.getSize();var a=this.elementContentNode.getStyle("padding-top").toFloat();var n=this.elementContentNode.getStyle("padding-bottom").toFloat();var o=this.filterConditionNode?this.filterConditionNode.getSize():{x:0,y:0};var l=s.y-e.y-a-n-o.y-t.y-i.y;this.elementContentNode.setStyle("height",""+l+"px");this.pageCount=(l/30).toInt()+5;if(this.view&&this.view.items.length<this.pageCount){this.view.loadElementList(this.pageCount-this.view.items.length)}},loadView:function(e){this.elementContentNode.empty();this.view=new MWF.xApplication.Attendance.MyAppeal.View(this.elementContentNode,this.app,this,this.viewData,this.options.searchKey);this.view.filterData=e;this.view.load();this.setContentSize()},createDocument:function(){if(this.view)this.view._createDocument()}});MWF.xApplication.Attendance.MyAppeal.View=new Class({Extends:MWF.xApplication.Attendance.Explorer.View,_createItem:function(e){return new MWF.xApplication.Attendance.MyAppeal.Document(this.table,e,this.explorer,this)},_getCurrentPageData:function(i,e){if(!e)e=20;var t=this.items.length?this.items[this.items.length-1].data.id:"(0)";var s=this.filterData||{};var a=((new Date).getMonth()+1).toString();if(a.length==1)a="0"+a;s.yearString=(new Date).getFullYear().toString();s.monthString=a;s.empName=layout.desktop.session.user.distinguishedName;this.actions.listAppealFilterNext(t,e,s,function(e){var t=e.data;t.sort(function(e,t){return parseInt(t.appealDateString.replace(/-/g,""))-parseInt(e.appealDateString.replace(/-/g,""))});e.data=t;if(i)i(e)})},_removeDocument:function(e,t){},_createDocument:function(){},_openDocument:function(e){var t=new MWF.xApplication.Attendance.MyAppeal.Appeal(this.explorer,e);t.open()}});MWF.xApplication.Attendance.MyAppeal.Document=new Class({Extends:MWF.xApplication.Attendance.Explorer.Document,agree:function(){},deny:function(){}});MWF.xApplication.Attendance.MyAppeal.Appeal=new Class({Extends:MWF.widget.Common,initialize:function(e,t){this.explorer=e;this.app=e.app;this.data=t||{};this.css=this.explorer.css;this.load()},load:function(){this.app.restActions.getDetail(this.data.detailId,function(e){this.data.onDutyTime=e.data.onDutyTime;this.data.offDutyTime=e.data.offDutyTime}.bind(this),null,false)},open:function(e){this.isNew=false;this.isEdited=false;this._open()},create:function(){this.isNew=true;this._open()},edit:function(){this.isEdited=true;this._open()},_open:function(){this.createMarkNode=new Element("div",{styles:this.css.createMarkNode,events:{mouseover:function(e){e.stopPropagation()},mouseout:function(e){e.stopPropagation()}}}).inject(this.app.content,"after");this.createAreaNode=new Element("div",{styles:this.css.createAreaNode});this.createNode();this.createAreaNode.inject(this.createMarkNode,"after");this.createAreaNode.fade("in");this.setCreateNodeSize();this.setCreateNodeSizeFun=this.setCreateNodeSize.bind(this);this.addEvent("resize",this.setCreateNodeSizeFun)},createNode:function(){var t=this;this.createNode=new Element("div",{styles:this.css.createNode}).inject(this.createAreaNode);this.createContainerNode=new Element("div",{styles:this.css.createContainerNode}).inject(this.createNode);this.setScrollBar(this.createContainerNode);this.createFormNode=new Element("div",{styles:this.css.createFormNode}).inject(this.createContainerNode);this.createTableContainer=new Element("div",{styles:this.css.createTableContainer}).inject(this.createFormNode);this.createTableArea=new Element("div",{styles:this.css.createTableArea}).inject(this.createTableContainer);var e=this.data;var i="发起";if(e.status==0){i="待处理"}else if(e.status==1){i="审批通过"}else if(e.status==-1){i="申诉不通过"}this.data.appealStatusShow=i;var s="<table width='100%' bordr='0' cellpadding='5' cellspacing='0' styles='formTable'>"+"<tr><td colspan='4' styles='formTableHead'>申诉申请单</td></tr>"+"<tr><td styles='formTableTitle'>员工姓名</td>"+" <td styles='formTableValue'>"+this.data.empName.split("@")[0]+"</td>"+" <td styles='formTableTitle' lable='recordDateString'></td>"+" <td styles='formTableValue' item='recordDateString'></td></tr>"+"<tr><td styles='formTableTitle' lable='onDutyTime'></td>"+" <td styles='formTableValue' item='onDutyTime'></td>"+" <td styles='formTableTitle' lable='offDutyTime'></td>"+" <td styles='formTableValue' item='offDutyTime'></td></tr>"+"<tr><td styles='formTableTitle' lable='appealStatusShow'></td>"+" <td styles='formTableValue' item='appealStatusShow' colspan='3'></td></tr>"+"<tr><td styles='formTableTitle' lable='appealReason'></td>"+" <td styles='formTableValue' item='appealReason'></td>"+" <td styles='formTableTitle' lable='processPerson1Show'></td>"+" <td styles='formTableValue' item='processPerson1Show'></td></tr>"+"<tr contain='selfHolidayType'><td styles='formTableTitle' lable='selfHolidayType'></td>"+" <td styles='formTableValue' item='selfHolidayType' colspan='3'></td></tr>"+"<tr contain='address'><td styles='formTableTitle' lable='address'></td>"+" <td styles='formTableValue' item='address' colspan='3'></td></tr>"+"<tr contain='startTime'><td styles='formTableTitle' lable='startTime'></td>"+" <td styles='formTableValue' item='startTime' colspan='3'></td></tr>"+"<tr contain='endTime'><td styles='formTableTitle' lable='endTime'></td>"+" <td styles='formTableValue' item='endTime' colspan='3'></td></tr>"+"<tr contain='appealDescription'><td styles='formTableTitle' lable='appealDescription'></td>"+" <td styles='formTableValue' item='appealDescription' colspan='3'></td></tr>"+"<tr contain='opinion1'><td styles='formTableTitle' lable='opinion1'></td>"+" <td styles='formTableValue' item='opinion1' colspan='3'></td></tr>"+"</table>";this.createTableArea.set("html",s);this.document=new MForm(this.createTableArea,this.data,{style:"popup",isEdited:this.isEdited||this.isNew,itemTemplate:{recordDateString:{text:"考勤日期",type:"innertext"},onDutyTime:{text:"上班打卡时间",type:"innertext"},offDutyTime:{text:"下班打卡时间",type:"innertext"},statusShow:{text:"考勤状态",type:"innertext"},appealStatusShow:{text:"审批状态",type:"innertext"},processPerson1Show:{text:"审核人",type:"innertext",value:this.data.processPerson1.split("@")[0]},appealReason:{notEmpty:true,text:"申述原因",type:"select",selectValue:["","临时请假","出差","因公外出","其他"],event:{change:function(e){t.switchFieldByAppealReason(e.getValue())}}},address:{text:"地点"},selfHolidayType:{text:"请假类型",type:"select",selectValue:["","带薪年休假","带薪病假","带薪福利假","扣薪事假","其他"]},startTime:{text:"开始日期",tType:"datetime"},endTime:{text:"结束日期",tType:"datetime"},appealDescription:{text:"事由"},opinion1:{text:"审批意见"}}},this.app,this.css);this.document.load();t.switchFieldByAppealReason(this.data.appealReason);this.cancelActionNode=new Element("div",{styles:this.css.createCancelActionNode,text:"关闭"}).inject(this.createFormNode);this.cancelActionNode.addEvent("click",function(e){this.cancelCreate(e)}.bind(this));if(this.isNew||this.isEdited){this.denyActionNode=new Element("div",{styles:this.css.createDenyActionNode,text:"不同意"}).inject(this.createFormNode);this.createOkActionNode=new Element("div",{styles:this.css.createOkActionNode,text:"同意"}).inject(this.createFormNode);this.denyActionNode.addEvent("click",function(e){this.deny(e)}.bind(this));this.createOkActionNode.addEvent("click",function(e){this.okCreate(e)}.bind(this))}},switchFieldByAppealReason:function(e){var t=["selfHolidayType","startTime","endTime","address","appealDescription"];var i=[];if(e=="临时请假"){i=["selfHolidayType","startTime","endTime"]}else if(e=="出差"){i=["address","startTime","endTime"]}else if(e=="因公外出"){i=["address","startTime","endTime","appealDescription"]}else if(e=="其他"){i=["appealDescription"]}t.each(function(e){this.createTableArea.getElement("[contain='"+e+"']").setStyle("display",i.contains(e)?"":"none");if(this.isNew||this.isEdited)this.document.items[e].options.notEmpty=i.contains(e)?true:false}.bind(this))},setCreateNodeSize:function(){var e=this.app.node.getSize();var t=this.app.content.getSize();var i="560";var s="800";this.createAreaNode.setStyles({width:""+e.x+"px",height:""+e.y+"px"});var a=i;var n=(e.y-i)/2;this.createNode.setStyles({height:""+a+"px","margin-top":""+n+"px",width:""+s+"px"});this.createContainerNode.setStyles({height:""+a+"px"});var o=this.createIconNode?this.createIconNode.getSize():{x:0,y:0};var l=a-o.y-60;this.createFormNode.setStyles({height:""+l+"px","margin-top":""+60+"px"})},cancelCreate:function(e){this.createMarkNode.destroy();this.createAreaNode.destroy();delete this},deny:function(e){var t={ids:[this.data.id],status:"-1",opinion1:this.opinion1.getValue()};if(t.opinion1){this.process(t)}else{this.app.notice("请填写意见","error")}},okCreate:function(e){var t={ids:[this.data.id],status:"1",opinion1:this.opinion1.getValue()};this.process(t)},process:function(e){this.app.restActions.processAppeal(e,function(e){if(e.type=="ERROR"){this.app.notice(e.message,"error")}else{this.createMarkNode.destroy();this.createAreaNode.destroy();if(this.explorer.view)this.explorer.view.reload();this.app.notice("处理成功","success")}}.bind(this))}});
|