AbnormalExport.js 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. MWF.xDesktop.requireApp("Attendance", "Explorer", null, false);
  2. MWF.xDesktop.requireApp("Selector", "package", null, false);
  3. MWF.xApplication.Attendance.AbnormalExport = new Class({
  4. Extends: MWF.xApplication.Attendance.Explorer,
  5. Implements: [Options, Events],
  6. initialize: function(node, app, actions, options){
  7. this.setOptions(options);
  8. this.app = app;
  9. this.path = "../x_component_Attendance/$AbnormalExport/";
  10. this.cssPath = "../x_component_Attendance/$AbnormalExport/"+this.options.style+"/css.wcss";
  11. this._loadCss();
  12. this.actions = actions;
  13. this.node = $(node);
  14. this.initData();
  15. if (!this.personActions) this.personActions = new MWF.xAction.org.express.RestActions();
  16. },
  17. load: function(){
  18. // this.loadToolbar();
  19. this.loadFilter();
  20. this.loadContentNode();
  21. //this.loadView( filterData );
  22. this.setNodeScroll();
  23. },
  24. loadFilter : function(){
  25. this.fileterNode = new Element("div.fileterNode", {
  26. "styles": this.app.css.fileterNode
  27. }).inject(this.node);
  28. this.loadFilterStyle( function( css ) {
  29. this.filterFormCss = css;
  30. var table = new Element("table", {
  31. "width": "100%",
  32. "border": "0",
  33. "cellpadding": "5",
  34. "cellspacing": "0",
  35. "styles": this.app.css.filterTable,
  36. "class": "filterTable",
  37. "style": "width:300px;"
  38. }).inject(this.fileterNode);
  39. var tr = new Element("tr").inject(table);
  40. this.createYearSelectTd(tr);
  41. this.createMonthSelectTd(tr);
  42. this.createActionTd(tr);
  43. }.bind(this))
  44. },
  45. createYearSelectTd : function( tr ){
  46. var _self = this;
  47. var td = new Element("td", { "styles" :this.app.css.filterTableTitle, "text" : this.app.lp.annuaal }).inject(tr);
  48. var td = new Element("td", { "styles" : this.app.css.filterTableValue }).inject(tr);
  49. this.yearString = new MDomItem( td, {
  50. "name" : "yearString",
  51. "type" : "select",
  52. "selectValue" : function(){
  53. var years = [];
  54. var year = new Date().getFullYear();
  55. for(var i=0; i<6; i++ ){
  56. years.push( year-- );
  57. }
  58. return years;
  59. }
  60. }, true, this.app, this.filterFormCss );
  61. this.yearString.load();
  62. },
  63. createMonthSelectTd : function( tr ){
  64. var _self = this;
  65. var td = new Element("td", { "styles" : this.app.css.filterTableTitle, "text" : this.app.lp.months }).inject(tr);
  66. var td = new Element("td", { "styles" : this.app.css.filterTableValue }).inject(tr);
  67. this.monthString = new MDomItem( td, {
  68. "name" : "monthString",
  69. "type" : "select",
  70. "selectValue" :["01","02","03","04","05","06","07","08","09","10","11","12"]
  71. }, true, this.app, this.filterFormCss );
  72. this.monthString.load();
  73. },
  74. createActionTd : function( tr ){
  75. var td = new Element("td", { "styles" : this.app.css.filterTableValue }).inject(tr);
  76. var input = new Element("button",{
  77. "text" : this.app.lp.export,
  78. "styles" : this.app.css.filterButton
  79. }).inject(td);
  80. input.addClass("mainColor_bg");
  81. input.addEvent("click", function(){
  82. this.export(this.yearString.getValue(), this.monthString.getValue() );
  83. //this.loadView( filterData );
  84. }.bind(this))
  85. },
  86. setContentSize: function(){
  87. var toolbarSize = this.toolbarNode ? this.toolbarNode.getSize() : {"x":0,"y":0};
  88. var titlebarSize = this.app.titleBar ? this.app.titleBar.getSize() : {"x":0,"y":0};
  89. var filterSize = this.fileterNode ? this.fileterNode.getSize() : {"x":0,"y":0};
  90. var nodeSize = this.node.getSize();
  91. var pt = this.elementContentNode.getStyle("padding-top").toFloat();
  92. var pb = this.elementContentNode.getStyle("padding-bottom").toFloat();
  93. //var filterSize = this.filterNode.getSize();
  94. var filterConditionSize = this.filterConditionNode ? this.filterConditionNode.getSize() : {"x":0,"y":0};
  95. var height = nodeSize.y-toolbarSize.y-pt-pb-filterConditionSize.y-titlebarSize.y-filterSize.y;
  96. this.elementContentNode.setStyle("height", ""+height+"px");
  97. this.pageCount = (height/30).toInt()+5;
  98. if (this.view && this.view.items.length<this.pageCount){
  99. this.view.loadElementList(this.pageCount-this.view.items.length);
  100. }
  101. },
  102. export : function(year, month){
  103. this.actions.exportAbnormalAttachment(year,month);
  104. },
  105. loadView : function( filterData ){
  106. //this.elementContentNode.empty();
  107. //this.view = new MWF.xApplication.Attendance.AbnormalExport.View(this.elementContentNode, this.app,this, this.viewData, this.options.searchKey );
  108. //this.view.filterData = filterData;
  109. //this.view.load();
  110. //this.setContentSize();
  111. },
  112. createDocument: function(){
  113. //if(this.view)this.view._createDocument();
  114. }
  115. });
  116. MWF.xApplication.Attendance.AbnormalExport.View = new Class({
  117. Extends: MWF.xApplication.Attendance.Explorer.View,
  118. _createItem: function(data){
  119. //return new MWF.xApplication.Attendance.AbnormalExport.Document(this.table, data, this.explorer, this);
  120. },
  121. _getCurrentPageData: function(callback, count){
  122. //if(!count )count=20;
  123. //var id = (this.items.length) ? this.items[this.items.length-1].data.id : "(0)";
  124. //var filter = this.filterData || {};
  125. //filter.empName = layout.desktop.session.user.name;
  126. //this.actions.listAppealFilterNext(id, count, filter, function(json){
  127. // var data = json.data;
  128. // data.sort( function( a, b ){
  129. // return parseInt( b.appealDateString.replace(/-/g,"") ) - parseInt( a.appealDateString.replace(/-/g,"") );
  130. // })
  131. // json.data = data;
  132. // if (callback) callback(json);
  133. //});
  134. },
  135. _removeDocument: function(documentData, all){
  136. },
  137. _createDocument: function(){
  138. },
  139. _openDocument: function( documentData ){
  140. }
  141. });
  142. MWF.xApplication.Attendance.AbnormalExport.Document = new Class({
  143. Extends: MWF.xApplication.Attendance.Explorer.Document,
  144. agree : function(){
  145. },
  146. deny : function(){
  147. }
  148. });