text: MWF.xDesktop.requireApp("Attendance","Explorer",null,!1),MWF.xDesktop.requireApp("Selector","package",null,!1),MWF.xDesktop.requireApp("Template","Explorer",null,!1),MWF.xDesktop.requireApp("Template","MForm",null,!1),MWF.xApplication.Attendance.AppealExplorer=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/$AppealExplorer/",this.cssPath="../x_component_Attendance/$AppealExplorer/"+this.options.style+"/css.wcss",this._loadCss(),this.actions=i,this.node=$(e),this.preMonthDate=new Date,this.initData(),this.personActions||(this.personActions=new MWF.xAction.org.express.RestActions)},load:function(){this.loadConfig(),this.loadToolbar(),this.loadFilter(),this.loadContentNode();var e=(this.preMonthDate.getMonth()+1).toString();1==e.length&&(e="0"+e);var t={status:"0",yearString:this.preMonthDate.getFullYear().toString(),monthString:e};this.loadView(t),this.setNodeScroll()},loadConfig:function(){var e;this.config={},this.configSetting=new Object(null),this.actions.listSetting(function(t){t.data?(t.data.map(function(e){this.configSetting[e.configCode]=e}.bind(this)),e=this.configSetting.APPEALABLE.configValue):e=null}.bind(this),null,!1),this.config.APPEALABLE=!e||"false"!=e},loadToolbar:function(){this.toolbarNode=new Element("div",{styles:this.css.toolbarNode}),this.toolbarNode.inject(this.node);var e=this.path+"toolbar.json";MWF.getJSON(e,function(e){e.each(function(e){this.config.APPEALABLE||"onlock"!=e.condition?this.config.APPEALABLE&&"onlock"!=e.condition&&this.createToolbarItemNode(e):this.createToolbarItemNode(e)}.bind(this))}.bind(this))},loadFilter:function(){this.fileterNode=new Element("div.fileterNode",{styles:this.css.fileterNode}).inject(this.node);var e=new Element("table",{width:"100%",border:"0",cellpadding:"5",cellspacing:"0",styles:this.css.filterTable,class:"filterTable"}).inject(this.fileterNode),t=new Element("tr").inject(e);this.createYearSelectTd(t),this.createMonthSelectTd(t),this.createStatusSelectTd(t),this.createAppealReasonTd(t),this.createUnitTd(t),this.createPersonTd(t),this.createActionTd(t)},createStatusSelectTd:function(e){var t=new Element("td",{styles:this.css.filterTableTitle,text:"审批状态"}).inject(e);t=new Element("td",{styles:this.css.filterTableValue}).inject(e);this.status=new MDomItem(t,{name:"status",type:"select",value:"0",selectText:["所有状态","待处理","审批通过","审批未通过"],selectValue:["999","0","1","-1"]},!0,this.app),this.status.load()},createAppealReasonTd:function(e){var t=new Element("td",{styles:this.css.filterTableTitle,text:"申诉原因"}).inject(e);t=new Element("td",{styles:this.css.filterTableValue}).inject(e);this.appealReason=new MDomItem(t,{name:"appealReason",type:"select",selectText:["","临时请假","出差","因公外出","其他"]},!0,this.app),this.appealReason.load()},createUnitTd:function(e){var t=this,i=new Element("td",{styles:this.css.filterTableTitle,text:"部门"}).inject(e);i=new Element("td",{styles:this.css.filterTableValue}).inject(e);this.unitName=new MDomItem(i,{name:"unitName",style:{width:"60px"},defaultValue:this.app.manageUnits.length>0?this.app.manageUnits[0]:"",event:{click:function(e){t.selecePerson(e,"unit")}}},!0,this.app),this.unitName.load()},createPersonTd:function(e){var t=this,i=new Element("td",{styles:this.css.filterTableTitle,text:"人员"}).inject(e);i=new Element("td",{styles:this.css.filterTableValue}).inject(e);this.empName=new MDomItem(i,{name:"empName",style:{width:"60px"},event:{click:function(e){t.selecePerson(e,"person")}}},!0,this.app),this.empName.load()},createYearSelectTd:function(e){var t=new Element("td",{styles:this.css.filterTableTitle,text:"年度"}).inject(e);t=new Element("td",{styles:this.css.filterTableValue}).inject(e);this.yearString=new MDomItem(t,{name:"yearString",type:"select",selectValue:function(){for(var e=[],t=(new Date).getFullYear(),i=0;i<6;i++)e.push(t--);return e}},!0,this.app),this.yearString.load()},createMonthSelectTd:function(e){var t=new Element("td",{styles:this.css.filterTableTitle,text:"月份"}).inject(e);t=new Element("td",{styles:this.css.filterTableValue}).inject(e);this.monthString=new MDomItem(t,{name:"monthString",type:"select",selectValue:["","01","02","03","04","05","06","07","08","09","10","11","12"]},!0,this.app),this.monthString.load()},createActionTd:function(e){var t=new Element("td",{styles:this.css.filterTableValue}).inject(e);new Element("button",{text:"查询",styles:this.css.filterButton}).inject(t).addEvent("click",function(){var e={status:this.status.getValue(),appealReason:this.appealReason.getValue(),unitName:this.unitName.getValue(),empName:this.empName.getValue(),yearString:this.yearString.getValue(),monthString:this.monthString.getValue()};this.loadView(e)}.bind(this))},selecePerson:function(e,t){var i="选择人员";"topUnit"==t?i="选择公司":"unit"==t&&(i="选择部门");var s={type:t,title:i,count:"1",values:[e.get("value")]||[],onComplete:function(t){var i=[];t.each(function(e){i.push(e.data.name)}.bind(this)),e.set("value",i.join(","))}.bind(this)};new MWF.O2Selector(this.app.content,s)},setContentSize:function(){var e=this.toolbarNode?this.toolbarNode.getSize():{x:0,y:0},t=this.app.titleBar?this.app.titleBar.getSize():{x:0,y:0},i=this.fileterNode?this.fileterNode.getSize():{x:0,y:0},s=this.node.getSize(),n=this.elementContentNode.getStyle("padding-top").toFloat(),a=this.elementContentNode.getStyle("padding-bottom").toFloat(),o=this.filterConditionNode?this.filterConditionNode.getSize():{x:0,y:0},l=s.y-e.y-n-a-o.y-t.y-i.y;this.elementContentNode.setStyle("height",l+"px"),this.pageCount=(l/30).toInt()+5,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.AppealExplorer.View(this.elementContentNode,this.app,this,this.viewData,this.options.searchKey),this.view.filterData=e,this.view.load(),this.setContentSize()},createDocument:function(){this.view&&this.view._createDocument()},agreeAppeals:function(e){var t=this,i=0;this.view.items.each(function(e){e.checkboxElement&&e.checkboxElement.get("checked")&&i++}.bind(this)),0!=i?this.app.confirm("warn",e,"同意申诉","确定处理您选择的"+i+"份申诉？",350,120,(function(){t.batchAppeals=!0,t.view.items.each(function(e){e.checkboxElement&&e.checkboxElement.get("checked")&&e.agree(!0)}.bind(this)),t.view&&t.view.reload(),t.batchAppeals=!1,t.app.notice("处理成功","success"),this.close()}),(function(){this.close()})):this.app.notice("请先选择申诉","error")},denyAppeals:function(e){var t=this,i=0;this.view.items.each(function(e){e.checkboxElement&&e.checkboxElement.get("checked")&&i++}.bind(this)),0!=i?this.app.confirm("warn",e,"不同意申诉","确定处理您选择的"+i+"份申诉？",350,120,(function(){t.batchAppeals=!0,t.view.items.each(function(e){e.checkboxElement&&e.checkboxElement.get("checked")&&e.deny(!0)}.bind(this)),t.view&&t.view.reload(),t.batchAppeals=!1,t.app.notice("处理成功","success"),this.close()}),(function(){this.close()})):this.app.notice("请先选择申诉","error")}}),MWF.xApplication.Attendance.AppealExplorer.View=new Class({Extends:MWF.xApplication.Attendance.Explorer.View,_createItem:function(e){return new MWF.xApplication.Attendance.AppealExplorer.Document(this.table,e,this.explorer,this)},_getCurrentPageData:function(e,t){t||(t=20);var i=this.items.length?this.items[this.items.length-1].data.id:"(0)",s=this.filterData||{};s.processPerson1=layout.desktop.session.user.distinguishedName,this.actions.listAppealFilterNext(i,t,s,function(t){var i=t.data;i.each(function(e){e.APPEALABLE=this.explorer.config.APPEALABLE,e.APPEAL_AUDIFLOWTYPE=this.explorer.configSetting.APPEAL_AUDIFLOWTYPE.configValue}.bind(this)),i.sort((function(e,t){return parseInt(t.appealDateString.replace(/-/g,""))-parseInt(e.appealDateString.replace(/-/g,""))})),t.data=i,e&&e(t)}.bind(this))},_removeDocument:function(e,t){},_createDocument:function(){},_openDocument:function(e){if(e.appealAuditInfo&&e.appealAuditInfo.workId){var t=e.appealAuditInfo.workId,i={workId:t,appId:"process.Work"+t};this.app.desktop.openApplication(null,"process.Work",i)}else{new MWF.xApplication.Attendance.AppealExplorer.Appeal(this.explorer,e).open()}}}),MWF.xApplication.Attendance.AppealExplorer.Document=new Class({Extends:MWF.xApplication.Attendance.Explorer.Document,agree:function(){var e={ids:[this.data.id],status:"1"};this.process(e)},deny:function(e){var t={ids:[this.data.id],status:"-1"};this.process(t)},process:function(e){this.app.restActions.processAppeal(e,function(e){"ERROR"==e.type?this.app.notice(e.message,"error"):this.explorer.batchAppeals||(this.explorer.view&&this.explorer.view.reload(),this.app.notice("处理成功","success"))}.bind(this),null,!1)}}),MWF.xApplication.Attendance.AppealExplorer.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,!1)},open:function(e){this.isNew=!1,this.isEdited=!1,this._open()},create:function(){this.isNew=!0,this._open()},edit:function(){this.explorer.config.APPEALABLE&&(this.isEdited=!0),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(){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);new Element("table",{width:"100%",border:"0",cellpadding:"5",cellspacing:"0",styles:this.css.editTable,class:"editTable"}).inject(this.createTableArea);var e=this.data,t="发起";0==e.status?t="待处理":1==e.status?t="审批通过":-1==e.status&&(t="审批不通过"),this.data.appealStatusShow=t;this.createTableArea.set("html","<table width='100%' bordr='0' cellpadding='5' cellspacing='0' styles='formTable'><tr><td colspan='4' styles='formTableHead'>申诉处理单</td></tr><tr><td styles='formTableTitle' lable='empNameShow'></td>    <td styles='formTableValue' item='empNameShow'></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' colspan='3'></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></table>"),this.document=new MForm(this.createTableArea,this.data,{style:"popup",isEdited:this.isEdited||this.isNew,itemTemplate:{empNameShow:{text:"员工姓名",type:"innertext",value:this.data.empName.split("@")[0]},recordDateString:{text:"考勤日期",type:"innertext"},onDutyTime:{text:"上班打卡时间",type:"innertext"},offDutyTime:{text:"下班打卡时间",type:"innertext"},statusShow:{text:"考勤状态",type:"innertext"},appealStatusShow:{text:"审批状态",type:"innertext"},appealReason:{text:"申述原因",type:"innertext"},address:{text:"地点",type:"innertext"},selfHolidayType:{text:"请假类型",type:"innertext"},startTime:{text:"开始日期",type:"innertext"},endTime:{text:"结束日期",type:"innertext"},appealDescription:{text:"事由",type:"innertext"}}},this.app,this.css),this.document.load(),this.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)),(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=[];"临时请假"==e?t=["selfHolidayType","startTime","endTime"]:"出差"==e?t=["address","startTime","endTime"]:"因公外出"==e?t=["address","startTime","endTime","appealDescription"]:"其他"==e&&(t=["appealDescription"]),["selfHolidayType","startTime","endTime","address","appealDescription"].each(function(e){this.createTableArea.getElement("[contain='"+e+"']").setStyle("display",t.contains(e)?"":"none"),(this.isNew||this.isEdited)&&(this.document.items[e].options.notEmpty=!!t.contains(e))}.bind(this))},setCreateNodeSize:function(){var e=this.app.node.getSize();this.app.content.getSize();this.createAreaNode.setStyles({width:e.x+"px",height:e.y+"px"});var t=(e.y-"570")/2;this.createNode.setStyles({height:"570px","margin-top":t+"px",width:"800px"}),this.createContainerNode.setStyles({height:"570px"});var i="570"-(this.createIconNode?this.createIconNode.getSize():{x:0,y:0}).y-60;this.createFormNode.setStyles({height:i+"px","margin-top":"60px"})},cancelCreate:function(e){this.createMarkNode.destroy(),this.createAreaNode.destroy()},deny:function(e){var t={ids:[this.data.id],status:"-1",opinion1:this.document.items.opinion1.getValue()};this.process(t)},okCreate:function(e){var t={ids:[this.data.id],status:"1",opinion1:this.document.items.opinion1.getValue()};this.process(t)},process:function(e){this.app.restActions.processAppeal(e,function(e){"ERROR"==e.type?this.app.notice(e.message,"error"):(this.createMarkNode.destroy(),this.createAreaNode.destroy(),this.explorer.view&&this.explorer.view.reload(),this.app.notice("处理成功","success"))}.bind(this))}});