| 1 |
- MWF.xDesktop.requireApp("Attendance","Explorer",null,false);MWF.xDesktop.requireApp("Template","MDomItem",null,false);MWF.xDesktop.requireApp("Organization","Selector.package",null,false);MWF.xApplication.Attendance.StatisticsCycleExplorer=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/$StatisticsCycleExplorer/";this.cssPath="/x_component_Attendance/$StatisticsCycleExplorer/"+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},loadView:function(){this.view=new MWF.xApplication.Attendance.StatisticsCycleExplorer.View(this.elementContentNode,this.app,this,this.viewData,this.options.searchKey);this.view.load();this.setContentSize()},createDocument:function(){if(this.view)this.view._createDocument()}});MWF.xApplication.Attendance.StatisticsCycleExplorer.View=new Class({Extends:MWF.xApplication.Attendance.Explorer.View,_createItem:function(e){return new MWF.xApplication.Attendance.StatisticsCycleExplorer.Document(this.table,e,this.explorer,this)},_getCurrentPageData:function(e,t){this.actions.listCycle(function(t){if(e)e(t)})},_removeDocument:function(e,t){this.actions.deleteCycle(e.id,function(e){this.explorer.view.reload();this.app.notice(this.app.lp.deleteDocumentOK,"success")}.bind(this))},_createDocument:function(){var e=new MWF.xApplication.Attendance.StatisticsCycleExplorer.StatisticsCycle(this.explorer);e.create()},_openDocument:function(e){var t=new MWF.xApplication.Attendance.StatisticsCycleExplorer.StatisticsCycle(this.explorer,e);t.edit()}});MWF.xApplication.Attendance.StatisticsCycleExplorer.Document=new Class({Extends:MWF.xApplication.Attendance.Explorer.Document});MWF.xApplication.Attendance.StatisticsCycleExplorer.StatisticsCycle=new Class({Extends:MWF.widget.Common,options:{width:"600",height:"600"},initialize:function(e,t){this.explorer=e;this.app=e.app;this.data=t||{};this.css=this.explorer.css;this.load()},load:function(){},open:function(e){this.isNew=false;this.isEdited=false},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 e=this;this.createNode=new Element("div",{styles:this.css.createNode}).inject(this.createAreaNode);this.createIconNode=new Element("div",{styles:this.isNew?this.css.createNewNode:this.css.createIconNode}).inject(this.createNode);this.createFormNode=new Element("div",{styles:this.css.createFormNode}).inject(this.createNode);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 t=new Element("table",{width:"100%",height:"250",border:"0",cellpadding:"5",cellspacing:"0",styles:this.css.editTable,class:"editTable"}).inject(this.createTableArea);var i=this.data;var s=new Element("tr").inject(t);var n=new Element("td",{styles:this.css.editTableHead,colspan:"4",text:"统计周期设置"}).inject(s);var s=new Element("tr").inject(t);var n=new Element("td",{styles:this.css.editTableTitle,text:"公司名称:"}).inject(s);var n=new Element("td",{styles:this.css.editTableValue}).inject(s);if(!this.isNew&&!this.isEdited){n.set("text",i.companyName)}else{this.companyName=new MDomItem(n,{name:"companyName",value:i.companyName,style:this.css.inputPersonStyle,event:{dblclick:function(t){e.selectPeople(this,"company",t.get("value").split(","))}}},true,this.app);this.companyName.load();new Element("div",{text:"双击选择,填写'*'匹配所有公司",styles:{color:"#ccc"}}).inject(n)}var s=new Element("tr").inject(t);var n=new Element("td",{styles:this.css.editTableTitle,text:"部门名称:"}).inject(s);var n=new Element("td",{styles:this.css.editTableValue}).inject(s);if(!this.isNew&&!this.isEdited){n.set("text",i.organizationName)}else{this.departmentName=new MDomItem(n,{name:"departmentName",value:i.departmentName,style:this.css.inputPersonStyle,event:{dblclick:function(t){e.selectPeople(this,"department",t.get("value").split(","))}}},true,this.app);this.departmentName.load();new Element("div",{text:"双击选择,填写'*'匹配所有部门",styles:{color:"#ccc"}}).inject(n)}var s=new Element("tr").inject(t);var n=new Element("td",{styles:this.css.editTableTitle,text:"统计周期年份:"}).inject(s);var n=new Element("td",{styles:this.css.editTableValue}).inject(s);if(!this.isNew&&!this.isEdited){n.set("text",i.cycleYear||"")}else{this.cycleYear=new MDomItem(n,{name:"cycleYear",type:"select",value:i.cycleYear||(new Date).getFullYear(),selectValue:function(){var e=[];var t=(new Date).getFullYear()+5;for(var i=0;i<10;i++){e.push(t--)}return e}},true,this.app);this.cycleYear.load()}var s=new Element("tr").inject(t);var n=new Element("td",{styles:this.css.editTableTitle,text:"统计周期月份:"}).inject(s);var n=new Element("td",{styles:this.css.editTableValue}).inject(s);if(!this.isNew&&!this.isEdited){n.set("text",i.cycleMonth||"")}else{this.cycleMonth=new MDomItem(n,{name:"cycleMonth",type:"select",value:i.cycleMonth,selectValue:["01","02","03","04","05","06","07","08","09","10","11","12"]},true,this.app);this.cycleMonth.load()}var s=new Element("tr").inject(t);var n=new Element("td",{styles:this.css.editTableTitle,text:"开始日期:"}).inject(s);var n=new Element("td",{styles:this.css.editTableValue}).inject(s);this.cycleStartDateString=new MDomItem(n,{name:"cycleStartDateString",value:i.cycleStartDateString,style:this.css.inputTimeStyle,event:{click:function(t){var i=new Date(e.cycleYear.getValue()+"-"+e.cycleMonth.getValue()+"-"+"01");e.selectDateTime(this,false,false,i.decrement("month",1))}}},true,this.app);this.cycleStartDateString.load();var s=new Element("tr").inject(t);var n=new Element("td",{styles:this.css.editTableTitle,text:"结束日期:"}).inject(s);var n=new Element("td",{styles:this.css.editTableValue}).inject(s);this.cycleEndDateString=new MDomItem(n,{name:"cycleEndDateString",value:i.cycleEndDateString,style:this.css.inputTimeStyle,event:{click:function(t){var i=new Date(e.cycleYear.getValue()+"-"+e.cycleMonth.getValue()+"-"+"01");e.selectDateTime(this,false,false,i)}}},true,this.app);this.cycleEndDateString.load();var s=new Element("tr").inject(t);var n=new Element("td",{styles:this.css.editTableTitle,text:"说明备注:"}).inject(s);var n=new Element("td",{styles:this.css.editTableValue}).inject(s);this.description=new MDomItem(n,{type:"textarea",name:"description",value:i.description,style:this.css.inputTextAreaStyle},true,this.app);this.description.load();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.createOkActionNode=new Element("div",{styles:this.css.createOkActionNode,text:"确定"}).inject(this.createFormNode);this.createOkActionNode.addEvent("click",function(e){this.okCreate(e)}.bind(this))}},setCreateNodeSize:function(e,t,i,s){if(!e)e=this.options&&this.options.width?this.options.width:"50%";if(!t)t=this.options&&this.options.height?this.options.height:"50%";if(!i)i=this.options&&this.options.top?this.options.top:0;if(!s)s=this.options&&this.options.left?this.options.left:0;var n=this.app.content.getSize();var a=n.x;var c=n.y;"string"==typeof e&&(1<e.length&&"%"==e.substr(e.length-1,1))&&(e=parseInt(a*parseInt(e,10)/100,10));"string"==typeof t&&(1<t.length&&"%"==t.substr(t.length-1,1))&&(t=parseInt(c*parseInt(t,10)/100,10));300>e&&(e=300);220>t&&(t=220);i=i||parseInt((c-t)/2,10);s=s||parseInt((a-e)/2,10);this.createAreaNode.setStyles({width:""+e+"px",height:""+t+"px",top:""+i+"px",left:""+s+"px"});this.createNode.setStyles({width:""+e+"px",height:""+t+"px"});var l=this.createIconNode?this.createIconNode.getSize():{x:0,y:0};var o=this.formTopNode?this.formTopNode.getSize():{x:0,y:0};var r=this.formBottomNode?this.formBottomNode.getSize():{x:0,y:0};var h=t-l.y-o.y-r.y;this.createFormNode.setStyles({height:""+h+"px"})},cancelCreate:function(e){var t=this;this.createMarkNode.destroy();this.createAreaNode.destroy();delete t},okCreate:function(e){var t={companyName:this.companyName.get("value")==""?"*":this.companyName.get("value"),departmentName:this.departmentName.get("value")==""?"*":this.departmentName.get("value"),cycleYear:this.cycleYear.get("value"),cycleMonth:this.cycleMonth.get("value"),cycleStartDateString:this.cycleStartDateString.get("value"),cycleEndDateString:this.cycleEndDateString.get("value"),description:this.description.get("value")};if(this.data.id)t.id=this.data.id;if(t.cycleStartDateString&&t.cycleEndDateString){this.app.restActions.saveCycle(t,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(this.isNew?this.app.lp.createSuccess:this.app.lp.updateSuccess,"success")}}.bind(this))}else{this.app.notice("请选择开始日期和结束日期","error")}},selectDateTime:function(e,t,i,s){var n={style:"xform",timeOnly:t,isTime:i,target:this.app.content};if(s)n.baseDate=s;MWF.require("MWF.widget.Calendar",function(){var t=new MWF.widget.Calendar(e,n);t.show()}.bind(this))},selectPeople:function(e,t,i){var s;if(t=="department"){s="选择部门"}else if(t=="company"){s="选择公司"}else{s="选择个人"}var n={type:t,title:s,count:"1",names:i||[],onComplete:function(t){var i=[];t.each(function(e){i.push(e.data.name)}.bind(this));e.set("value",i.join(","))}.bind(this)};var a=new MWF.OrgSelector(this.app.content,n)}});
|