TopUnitDetail.js 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695
  1. MWF.xDesktop.requireApp("Attendance", "Explorer", null, false);
  2. MWF.xDesktop.requireApp("Selector", "package", null, false);
  3. MWF.xApplication.Attendance.TopUnitDetail = new Class({
  4. Extends: MWF.widget.Common,
  5. Implements: [Options, Events],
  6. options: {
  7. "style": "default"
  8. },
  9. initialize: function(node, app, actions, options){
  10. this.setOptions(options);
  11. this.app = app;
  12. this.lp = app.lp;
  13. this.path = "/x_component_Attendance/$TopUnitDetail/";
  14. this.cssPath = "/x_component_Attendance/$TopUnitDetail/"+this.options.style+"/css.wcss";
  15. this._loadCss();
  16. this.actions = actions;
  17. this.node = $(node);
  18. },
  19. load: function(){
  20. this.loadTab();
  21. },
  22. loadTab : function(){
  23. this.tabNode = new Element("div",{"styles" : this.css.tabNode }).inject(this.node);
  24. this.detailArea = new Element("div",{"styles" : this.css.tabPageContainer }).inject(this.tabNode);
  25. //this.selfHolidayArea = new Element("div",{"styles" : this.css.tabPageContainer }).inject(this.tabNode)
  26. this.detailStaticArea = new Element("div",{"styles" : this.css.tabPageContainer }).inject(this.tabNode);
  27. //this.selfHolidayStaticArea = new Element("div",{"styles" : this.css.tabPageContainer }).inject(this.tabNode)
  28. MWF.require("MWF.widget.Tab", function(){
  29. this.tabs = new MWF.widget.Tab(this.tabNode, {"style": "attendance"});
  30. this.tabs.load();
  31. this.detailPage = this.tabs.addTab(this.detailArea, this.lp.topUnitAttendanceDetail, false);
  32. this.detailPage.contentNodeArea.set("class","detailPage");
  33. this.detailPage.addEvent("show",function(){
  34. if( !this.detailExplorer ){
  35. this.detailExplorer = new MWF.xApplication.Attendance.TopUnitDetail.Explorer( this.detailArea, this );
  36. this.detailExplorer.load();
  37. }
  38. }.bind(this));
  39. this.detailStaticPage = this.tabs.addTab(this.detailStaticArea, this.lp.topUnitAttendanceStatic, false);
  40. this.detailStaticPage.contentNodeArea.set("class","detailStaticPage");
  41. this.detailStaticPage.addEvent("show",function(){
  42. if( !this.detailStaticExplorer ){
  43. this.detailStaticExplorer = new MWF.xApplication.Attendance.TopUnitDetail.DetailStaticExplorer( this.detailStaticArea, this );
  44. this.detailStaticExplorer.load();
  45. }
  46. }.bind(this));
  47. this.tabs.pages[0].showTab();
  48. }.bind(this));
  49. }
  50. });
  51. MWF.xApplication.Attendance.TopUnitDetail.Explorer = new Class({
  52. Extends: MWF.xApplication.Attendance.Explorer,
  53. Implements: [Options, Events],
  54. initialize: function(node, parent, options){
  55. this.setOptions(options);
  56. this.parent = parent;
  57. this.app = parent.app;
  58. this.css = parent.css;
  59. this.lp = this.app.lp;
  60. this.path = parent.path;
  61. this.actions = parent.actions;
  62. this.node = $(node);
  63. this.initData();
  64. if (!this.peopleActions) this.peopleActions = new MWF.xAction.org.express.RestActions();
  65. },
  66. initData: function(){
  67. this.toolItemNodes = [];
  68. },
  69. reload: function(){
  70. this.node.empty();
  71. this.load();
  72. },
  73. load: function(){
  74. this.loadFilter();
  75. this.loadContentNode();
  76. this.setNodeScroll();
  77. },
  78. loadFilter: function(){
  79. this.fileterNode = new Element("div.fileterNode", {
  80. "styles" : this.css.fileterNode
  81. }).inject(this.node);
  82. var html = "<table width='100%' bordr='0' cellpadding='5' cellspacing='0' styles='filterTable'>"+
  83. "<tr>" +
  84. " <td styles='filterTableValue' lable='q_topUnitName'></td>"+
  85. " <td styles='filterTableTitle' item='q_topUnitName'></td>"+
  86. " <td styles='filterTableTitle' lable='cycleYear'></td>"+
  87. " <td styles='filterTableValue' item='cycleYear'></td>" +
  88. " <td styles='filterTableTitle' lable='cycleMonth'></td>"+
  89. " <td styles='filterTableValue' item='cycleMonth'></td>" +
  90. " <td styles='filterTableTitle' lable='date'></td>"+
  91. " <td styles='filterTableValue' item='date'></td>" +
  92. " <td styles='filterTableTitle' lable='isAbsent'></td>"+
  93. " <td styles='filterTableValue' item='isAbsent'></td>" +
  94. " <td styles='filterTableTitle' lable='isLate'></td>"+
  95. " <td styles='filterTableValue' item='isLate'></td>" +
  96. " <td styles='filterTableTitle' lable='isLackOfTime'></td>"+
  97. " <td styles='filterTableValue' item='isLackOfTime'></td>" +
  98. " <td styles='filterTableValue' item='action'></td>" +
  99. " <td styles='filterTableValue' item='export'></td>" +
  100. "</tr>" +
  101. "</table>";
  102. this.fileterNode.set("html",html);
  103. MWF.xDesktop.requireApp("Template", "MForm", function(){
  104. this.form = new MForm( this.fileterNode, {}, {
  105. isEdited : true,
  106. itemTemplate : {
  107. q_topUnitName : { text : "公司", type : "org", orgType : "unit", notEmpty : true, style : {"min-width": "200px" } },
  108. cycleYear : {
  109. text : "年度",
  110. "type" : "select",
  111. "selectValue" : function(){
  112. var years = [];
  113. var year = new Date().getFullYear();
  114. for(var i=0; i<6; i++ ){
  115. years.push( year-- );
  116. }
  117. return years;
  118. },
  119. "event" : {
  120. "change" : function( item, ev ){
  121. var values = this.getDateSelectValue();
  122. item.form.getItem( "date").resetItemOptions( values , values )
  123. }.bind(this)
  124. }
  125. },
  126. cycleMonth : {
  127. text : "月份",
  128. "type" : "select",
  129. "defaultValue" : function(){
  130. var month = (new Date().getMonth() + 1 ).toString();
  131. return month.length == 1 ? "0"+month : month;
  132. },
  133. "selectValue" :["","01","02","03","04","05","06","07","08","09","10","11","12"],
  134. "event" : {
  135. "change" : function( item, ev ){
  136. var values = this.getDateSelectValue();
  137. item.form.getItem( "date").resetItemOptions( values , values )
  138. }.bind(this)
  139. }
  140. },
  141. date : { text : "日期", "type" : "select", "selectValue" : this.getDateSelectValue.bind(this) },
  142. isAbsent : { text: "缺勤", "type" : "select", "selectValue" : ["","true","false"], "selectText" : ["","缺勤","未缺勤"] },
  143. isLate : { text: "迟到", "type" : "select", "selectValue" : ["","true","false"], "selectText" : ["","迟到","未迟到"] },
  144. isLackOfTime : { text: "工时不足", "type" : "select", "selectValue" : ["","true","false"], "selectText" : ["","是","否"] },
  145. action : { "value" : "查询", type : "button", className : "filterButton", event : {
  146. click : function(){
  147. var result = this.form.getResult(true,",",true,true,false);
  148. if( !result )return;
  149. if( typeOf( result.isAbsent ) == "string" )result.isAbsent = this.getBoolean( result.isAbsent );
  150. if( typeOf( result.isLate ) == "string" )result.isLate = this.getBoolean( result.isLate );
  151. if( typeOf( result.isLackOfTime ) == "string" )result.isLackOfTime = this.getBoolean( result.isLackOfTime );
  152. if( result.date && result.date !="" ){
  153. result.q_date = result.cycleYear + "-" + result.cycleMonth + "-" + result.date;
  154. }
  155. this.loadView( result );
  156. }.bind(this)
  157. }},
  158. export : { "value" : "导出", type : "button", className : "filterButton", event : {
  159. click : function(){
  160. var result = this.form.getResult(true,",",true,true,false);
  161. if( !result )return;
  162. debugger;
  163. if( !result.q_topUnitName )result.q_topUnitName = "0";
  164. if( !result.q_unitName)result.q_unitName = "0";
  165. if( !result.q_empName)result.q_empName = "0";
  166. if( !result.cycleYear )result.cycleYear = "0";
  167. if( !result.cycleMonth )result.cycleMonth = "0";
  168. if( result.date && result.date !="" ){
  169. result.q_date = result.cycleYear + "-" + result.cycleMonth + "-" + result.date;
  170. }else{
  171. result.q_date ="0";
  172. }
  173. if( !result.isAbsent )result.isAbsent = "0";
  174. if( !result.isLackOfTime )result.isLackOfTime = "0";
  175. if( !result.isLate )result.isLate = "0";
  176. debugger;
  177. this.actions.detailsExportStream(result.q_topUnitName,result.q_unitName,result.q_empName,result.cycleYear,result.cycleMonth,result.q_date,result.isAbsent,result.isLackOfTime,result.isLate,true);
  178. }.bind(this)
  179. }}
  180. }
  181. }, this.app, this.css);
  182. this.form.load();
  183. }.bind(this), true);
  184. },
  185. getDateSelectValue : function(){
  186. if( this.form ){
  187. var year = parseInt(this.form.getItem("cycleYear").getValue());
  188. var month = parseInt(this.form.getItem("cycleMonth").getValue())-1;
  189. }else{
  190. var year = (new Date()).getFullYear() ;
  191. var month = (new Date()).getMonth() ;
  192. }
  193. var date = new Date(year, month, 1);
  194. var days = [];
  195. days.push("");
  196. while (date.getMonth() === month) {
  197. var d = date.getDate().toString();
  198. if( d.length == 1 )d = "0"+d;
  199. days.push( d );
  200. date.setDate(date.getDate() + 1);
  201. }
  202. return days;
  203. },
  204. //loadFilter : function(){
  205. // this.fileterNode = new Element("div.fileterNode", {
  206. // "styles" : this.css.fileterNode
  207. // }).inject(this.node)
  208. //
  209. // var table = new Element("table", {
  210. // "width" : "100%", "border" : "0", "cellpadding" : "5", "cellspacing" : "0", "styles" : this.css.filterTable, "class" : "filterTable"
  211. // }).inject( this.fileterNode );
  212. // var tr = new Element("tr").inject(table);
  213. //
  214. // this.createTopUnitTd( tr )
  215. // this.createYearSelectTd( tr )
  216. // this.createMonthSelectTd( tr )
  217. // this.createDateSelectTd( tr )
  218. // this.createIsAbsent(tr)
  219. // this.createIsLate( tr )
  220. // //this.createIsLeaveEarlier( tr )
  221. // this.createLackOfTimeCount(tr)
  222. // this.createActionTd( tr )
  223. //},
  224. //createTypeId : function(tr){
  225. // var _self = this;
  226. // var td = new Element("td", { "styles" : this.css.filterTableTitle, "text" : this.lp.type }).inject(tr);
  227. // var td = new Element("td", { "styles" : this.css.filterTableValue }).inject(tr);
  228. // this.q_type = new MDomItem( td, {
  229. // "name" : "q_type",
  230. // "type" : "select",
  231. // "selectValue": ["day","month"],
  232. // "selectText": [this.lp.staticByDay,this.lp.staticByMonth],
  233. // }, true, this.app );
  234. // this.q_type.load();
  235. //},
  236. //createTopUnitTd : function(tr){
  237. // var _self = this;
  238. // var td = new Element("td", { "styles" : this.css.filterTableTitle, "text" : this.lp.topUnit }).inject(tr);
  239. // var td = new Element("td", { "styles" : this.css.filterTableValue }).inject(tr);
  240. // this.q_topUnitName = new MDomItem( td, {
  241. // "name" : "q_topUnitName",
  242. // "event" : {
  243. // "click" : function(el){ _self.selecePerson(); }
  244. // }
  245. // }, true, this.app );
  246. // this.q_topUnitName.load();
  247. //},
  248. //createYearSelectTd : function( tr ){
  249. // var _self = this;
  250. // var td = new Element("td", { "styles" : this.css.filterTableTitle, "text" : this.lp.annuaal }).inject(tr);
  251. // var td = new Element("td", { "styles" : this.css.filterTableValue }).inject(tr);
  252. // this.cycleYear = new MDomItem( td, {
  253. // "name" : "cycleYear",
  254. // "type" : "select",
  255. // "selectValue" : function(){
  256. // var years = [];
  257. // var year = new Date().getFullYear();
  258. // for(var i=0; i<6; i++ ){
  259. // years.push( year-- );
  260. // }
  261. // return years;
  262. // },
  263. // "event" : {
  264. // "change" : function(){ if(_self.dateSelecterTd)_self.createDateSelectTd() }
  265. // }
  266. // }, true, this.app );
  267. // this.cycleYear.load();
  268. //},
  269. //createMonthSelectTd : function( tr ){
  270. // var _self = this;
  271. // var td = new Element("td", { "styles" : this.css.filterTableTitle, "text" : this.lp. months }).inject(tr);
  272. // var td = new Element("td", { "styles" : this.css.filterTableValue }).inject(tr);
  273. // this.cycleMonth = new MDomItem( td, {
  274. // "name" : "cycleMonth",
  275. // "type" : "select",
  276. // "defaultValue" : function(){
  277. // var month = (new Date().getMonth() + 1 ).toString();
  278. // return month.length == 1 ? "0"+month : month;
  279. // },
  280. // "selectValue" :["","01","02","03","04","05","06","07","08","09","10","11","12"],
  281. // "event" : {
  282. // "change" : function(){ if(_self.dateSelecterTd)_self.createDateSelectTd() }
  283. // }
  284. // }, true, this.app );
  285. // this.cycleMonth.load();
  286. //},
  287. //createDateSelectTd : function( tr ){
  288. // var _self = this;
  289. // if( tr ){
  290. // var td = new Element("td", { "styles" : this.css.filterTableTitle, "text" : this.lp.date }).inject(tr);
  291. // this.dateSelecterTd = new Element("td", { "styles" : this.css.filterTableValue }).inject(tr);
  292. // }
  293. // if( this.q_date ){
  294. // this.dateSelecterTd.empty();
  295. // }
  296. // this.q_date = new MDomItem( this.dateSelecterTd, {
  297. // "name" : "q_date",
  298. // "type" : "select",
  299. // "selectValue" : function(){
  300. // var year = parseInt(_self.cycleYear.getValue());
  301. // var month = parseInt(_self.cycleMonth.getValue())-1;
  302. // var date = new Date(year, month, 1);
  303. // var days = [];
  304. // days.push("");
  305. // while (date.getMonth() === month) {
  306. // var d = date.getDate().toString();
  307. // if( d.length == 1 )d = "0"+d
  308. // days.push( d );
  309. // date.setDate(date.getDate() + 1);
  310. // }
  311. // return days;
  312. // }
  313. // }, true, this.app );
  314. // this.q_date.load();
  315. //},
  316. //createIsAbsent: function(tr){
  317. // var td = new Element("td", { "styles" : this.css.filterTableTitle, "text" : this.lp.absent }).inject(tr);
  318. // var td = new Element("td", { "styles" : this.css.filterTableValue }).inject(tr);
  319. // this.isAbsent = new MDomItem( td, {
  320. // "name" : "isAbsent",
  321. // "type" : "select",
  322. // "selectValue" : ["","true","false"],
  323. // "selectText" : ["",this.lp.absent,this.lp.notAbsent],
  324. // }, true, this.app );
  325. // this.isAbsent.load();
  326. //},
  327. ////createIsLeaveEarlier: function(tr){
  328. //// var td = new Element("td", { "styles" : this.css.filterTableTitle, "text" : this.lp.leaveEarly }).inject(tr);
  329. //// var td = new Element("td", { "styles" : this.css.filterTableValue }).inject(tr);
  330. //// this.isLeaveEarlier = new MDomItem( td, {
  331. //// "name" : "isLeaveEarlier",
  332. //// "type" : "select",
  333. //// "selectValue" : ["-1","true","false"],
  334. //// "selectText" : ["","早退","未早退"],
  335. //// }, true, this.app );
  336. //// this.isLeaveEarlier.load();
  337. ////},
  338. //createLackOfTimeCount: function(tr){
  339. // var td = new Element("td", { "styles" : this.css.filterTableTitle, "text" : "工时不足" }).inject(tr);
  340. // var td = new Element("td", { "styles" : this.css.filterTableValue }).inject(tr);
  341. // this.isLackOfTime = new MDomItem( td, {
  342. // "name" : "isLackOfTime",
  343. // "type" : "select",
  344. // "selectValue" : ["","true","false"],
  345. // "selectText" : ["","是","否"],
  346. // }, true, this.app );
  347. // this.isLackOfTime.load();
  348. //},
  349. //createIsLate: function(tr){
  350. // var td = new Element("td", { "styles" : this.css.filterTableTitle, "text" : this.lp.late }).inject(tr);
  351. // var td = new Element("td", { "styles" : this.css.filterTableValue }).inject(tr);
  352. // this.isLate = new MDomItem( td, {
  353. // "name" : "isLate",
  354. // "type" : "select",
  355. // "selectValue" : ["","true","false"],
  356. // "selectText" : ["","迟到","未迟到"],
  357. // }, true, this.app );
  358. // this.isLate.load();
  359. //},
  360. //createActionTd : function( tr ){
  361. // var td = new Element("td", { "styles" : this.css.filterTableValue }).inject(tr);
  362. // var input = new Element("button",{
  363. // "text" : "查询",
  364. // "styles" : this.css.filterButton
  365. // }).inject(td);
  366. // input.addEvent("click", function(){
  367. // if( this.q_topUnitName.getValue().trim() == "" ){
  368. // this.app.notice( "请先选择公司", "error" );
  369. // return;
  370. // }
  371. // var filterData = {
  372. // q_topUnitName : this.q_topUnitName.getValue(),
  373. // cycleYear : this.cycleYear.getValue(),
  374. // cycleMonth : this.cycleMonth.getValue()
  375. // }
  376. // if( this.q_type ){
  377. // filterData.q_type = this.q_type.getValue();
  378. // }
  379. // if( this.isAbsent && this.isAbsent.getValue()!=""){
  380. // filterData.isAbsent = this.getBoolean( this.isAbsent.getValue());
  381. // }
  382. // if( this.isLeaveEarlier && this.isLeaveEarlier.getValue()!="" ){
  383. // filterData.isLeaveEarlier = this.getBoolean( this.isLeaveEarlier.getValue());
  384. // }
  385. // if( this.isLate && this.isLate.getValue()!=""){
  386. // filterData.isLate = this.getBoolean( this.isLate.getValue());
  387. // }
  388. // if( this.isLackOfTime && this.isLackOfTime.getValue()!=""){
  389. // filterData.isLackOfTime = this.getBoolean( this.isLackOfTime.getValue() );
  390. // }
  391. // if( this.q_date && this.q_date.getValue()!="" ){
  392. // filterData.q_date = this.cycleYear.getValue() + "-" + this.cycleMonth.getValue() + "-" + this.q_date.getValue();
  393. // }
  394. // this.loadView( filterData );
  395. // }.bind(this))
  396. //},
  397. getBoolean : function( value ){
  398. if( value === "true" )return true;
  399. if( value === "false" )return false;
  400. return value;
  401. },
  402. //selecePerson: function(){
  403. // var options = {
  404. // "type": "topUnit",
  405. // "title": "选择公司",
  406. // "count" : "1",
  407. // "onComplete": function(items){
  408. // var names = [];
  409. // items.each(function(item){
  410. // names.push(item.data.name);
  411. // }.bind(this));
  412. // this.q_topUnitName.setValue( names.join(",") )
  413. // }.bind(this)
  414. // };
  415. // var selector = new MWF.O2Selector(this.app.content, options);
  416. //},
  417. loadContentNode: function(){
  418. this.elementContentNode = new Element("div", {
  419. "styles": this.css.elementContentNode
  420. }).inject(this.node);
  421. this.app.addEvent("resize", function(){this.setContentSize();}.bind(this));
  422. },
  423. loadView : function( filterData ){
  424. this.elementContentNode.empty();
  425. if( this.view )delete this.view;
  426. this.view = new MWF.xApplication.Attendance.TopUnitDetail.View(this.elementContentNode, this.app,this );
  427. this.view.filterData = filterData;
  428. this.view.load();
  429. this.setContentSize();
  430. },
  431. setContentSize: function(){
  432. var tabNodeSize = this.parent.tabs ? this.parent.tabs.tabNodeContainer.getSize() : {"x":0,"y":0};
  433. var fileterNodeSize = this.fileterNode ? this.fileterNode.getSize() : {"x":0,"y":0};
  434. var nodeSize = this.parent.node.getSize();
  435. var pt = this.elementContentNode.getStyle("padding-top").toFloat();
  436. var pb = this.elementContentNode.getStyle("padding-bottom").toFloat();
  437. //var filterSize = this.filterNode.getSize();
  438. var height = nodeSize.y-tabNodeSize.y-pt-pb-fileterNodeSize.y-20;
  439. this.elementContentNode.setStyle("height", ""+height+"px");
  440. this.pageCount = (height/40).toInt()+5;
  441. if (this.view && this.view.items.length<this.pageCount){
  442. this.view.loadElementList(this.pageCount-this.view.items.length);
  443. }
  444. }
  445. });
  446. MWF.xApplication.Attendance.TopUnitDetail.DetailStaticExplorer = new Class({
  447. Extends: MWF.xApplication.Attendance.TopUnitDetail.Explorer,
  448. loadFilter: function(){
  449. this.fileterNode = new Element("div.fileterNode", {
  450. "styles" : this.css.fileterNode
  451. }).inject(this.node);
  452. var html = "<table width='100%' bordr='0' cellpadding='5' cellspacing='0' style='width: 660px;font-size: 14px;color:#666'>"+
  453. "<tr>" +
  454. " <td styles='filterTableValue' lable='q_topUnitName'></td>"+
  455. " <td styles='filterTableTitle' item='q_topUnitName'></td>"+
  456. " <td styles='filterTableTitle' lable='cycleYear'></td>"+
  457. " <td styles='filterTableValue' item='cycleYear'></td>" +
  458. " <td styles='filterTableTitle' lable='cycleMonth'></td>"+
  459. " <td styles='filterTableValue' item='cycleMonth'></td>" +
  460. " <td styles='filterTableValue' item='action'></td>" +
  461. " <td styles='filterTableValue' item='export'></td>" +
  462. "</tr>" +
  463. "</table>";
  464. this.fileterNode.set("html",html);
  465. MWF.xDesktop.requireApp("Template", "MForm", function(){
  466. this.form = new MForm( this.fileterNode, {}, {
  467. isEdited : true,
  468. itemTemplate : {
  469. q_topUnitName : { text : "公司", type : "org", orgType : "unit", notEmpty : true, style : {"min-width": "200px" } },
  470. cycleYear : {
  471. text : "年度",
  472. "type" : "select",
  473. "selectValue" : function(){
  474. var years = [];
  475. var year = new Date().getFullYear();
  476. for(var i=0; i<6; i++ ){
  477. years.push( year-- );
  478. }
  479. return years;
  480. }
  481. },
  482. cycleMonth : {
  483. text : "月份", notEmpty : true,
  484. "type" : "select",
  485. "defaultValue" : function(){
  486. var month = (new Date().getMonth() + 1 ).toString();
  487. return month.length == 1 ? "0"+month : month;
  488. },
  489. "selectValue" :["","01","02","03","04","05","06","07","08","09","10","11","12"]
  490. },
  491. action : { "value" : "查询", type : "button", className : "filterButton", event : {
  492. click : function(){
  493. var result = this.form.getResult(true,",",true,true,false);
  494. if( !result )return;
  495. this.loadView( result );
  496. }.bind(this)
  497. }},
  498. export : { "value" : "导出", type : "button", className : "filterButton", event : {
  499. click : function(){
  500. var result = this.form.getResult(true,",",true,true,false);
  501. if( !result )return;
  502. this.actions.exportTopUnitStatisticAttachment(result.q_topUnitName,result.cycleYear,result.cycleMonth,true);
  503. }.bind(this)
  504. }}
  505. }
  506. }, this.app, this.css);
  507. this.form.load();
  508. }.bind(this), true);
  509. },
  510. //loadFilter : function(){
  511. // this.fileterNode = new Element("div.fileterNode", {
  512. // "styles" : this.css.fileterNode
  513. // }).inject(this.node)
  514. //
  515. // var table = new Element("table", {
  516. // "width" : "100%", "border" : "0", "cellpadding" : "5", "cellspacing" : "0", "styles" : this.css.filterTable, "class" : "filterTable"
  517. // }).inject( this.fileterNode );
  518. // table.setStyle("width","600px")
  519. // var tr = new Element("tr").inject(table);
  520. //
  521. // //this.createTypeId(tr);
  522. // this.createTopUnitTd( tr )
  523. // this.createYearSelectTd( tr )
  524. // this.createMonthSelectTd( tr )
  525. // //this.createDateSelectTd( tr )
  526. // this.createActionTd( tr )
  527. //},
  528. //createActionTd : function( tr ){
  529. // var td = new Element("td", { "styles" : this.css.filterTableValue }).inject(tr);
  530. // var input = new Element("button",{
  531. // "text" : "查询",
  532. // "styles" : this.css.filterButton
  533. // }).inject(td);
  534. // input.addEvent("click", function(){
  535. // if( this.q_topUnitName.getValue().trim() == "" ){
  536. // this.app.notice( "请先选择公司", "error" );
  537. // return;
  538. // }
  539. // //if( this.q_type.getValue() == "day" && this.q_date.getValue()=="" ){
  540. // // this.app.notice( "请先选择日期", "error" );
  541. // // return;
  542. // //}
  543. // var filterData = {
  544. // q_topUnitName : this.q_topUnitName.getValue(),
  545. // cycleYear : this.cycleYear.getValue(),
  546. // cycleMonth : this.cycleMonth.getValue()
  547. // }
  548. // if( this.q_type ){
  549. // filterData.q_type = this.q_type.getValue();
  550. // }
  551. // if( this.isAbsent && this.isAbsent.getValue()!="" ){
  552. // filterData.isAbsent = this.isAbsent.getValue();
  553. // }
  554. // if( this.isLeaveEarlier && this.isLeaveEarlier.getValue()!="" ){
  555. // filterData.isLeaveEarlier = this.isLeaveEarlier.getValue();
  556. // }
  557. // if( this.isLate && this.isLate.getValue()!="" ){
  558. // filterData.isLate = this.isLate.getValue();
  559. // }
  560. // if( this.q_date && this.q_date.getValue()!="" ){
  561. // filterData.q_date = this.cycleYear.getValue() + "-" + this.cycleMonth.getValue() + "-" + this.q_date.getValue();
  562. // }
  563. // filterData.q_type = "month";
  564. // this.loadView( filterData );
  565. // }.bind(this))
  566. //},
  567. loadView : function( filterData ){
  568. this.elementContentNode.empty();
  569. if( this.view )delete this.view;
  570. this.view = new MWF.xApplication.Attendance.TopUnitDetail.DetailStaticView(this.elementContentNode, this.app,this );
  571. this.view.filterData = filterData;
  572. this.view.listItemUrl = this.path+"listItem_detailStatic.json";
  573. this.view.load();
  574. this.setContentSize();
  575. }
  576. });
  577. MWF.xApplication.Attendance.TopUnitDetail.View = new Class({
  578. Extends: MWF.xApplication.Attendance.Explorer.View,
  579. _createItem: function(data){
  580. return new MWF.xApplication.Attendance.TopUnitDetail.Document(this.table, data, this.explorer, this);
  581. },
  582. _getCurrentPageData: function(callback, count){
  583. if(!count)count=20;
  584. var id = (this.items.length) ? this.items[this.items.length-1].data.id : "(0)";
  585. var filter = this.filterData || {};
  586. //filter.key = this.sortField || this.sortFieldDefault || "";
  587. //filter.order = this.sortType || this.sortTypeDefault || "";
  588. this.actions.listDetailFilterNext( id, count, filter, function(json){
  589. if( callback )callback(json);
  590. }.bind(this));
  591. //var filter = this.filterData || {};
  592. //this.actions.listTopUnitDetailFilter( filter, function(json){
  593. // if( callback )callback(json);
  594. //}.bind(this))
  595. },
  596. _removeDocument: function(documentData, all){
  597. },
  598. _createDocument: function(){
  599. },
  600. _openDocument: function( documentData ){
  601. }
  602. });
  603. MWF.xApplication.Attendance.TopUnitDetail.DetailStaticView = new Class({
  604. Extends: MWF.xApplication.Attendance.Explorer.View,
  605. _createItem: function(data){
  606. return new MWF.xApplication.Attendance.TopUnitDetail.DetailStaticDocument(this.table, data, this.explorer, this);
  607. },
  608. _getCurrentPageData: function(callback, count){
  609. var filter = this.filterData || {};
  610. if( filter.q_type == "day" ) {
  611. this.actions.listUnitDateStaticByTopUnit( filter.q_topUnitName, filter.q_date, function(json){ //listStaticDayTopUnit
  612. //var data = json.data;
  613. //data.sort( function( a, b ){
  614. // return parseInt( b.statisticDate.replace(/-/g,"") ) - parseInt( a.statisticDate.replace(/-/g,"") );
  615. //})
  616. //json.data = data;
  617. if( callback )callback(json);
  618. }.bind(this))
  619. }else{
  620. if( !filter.cycleMonth || filter.cycleMonth == "" )filter.cycleMonth = "(0)";
  621. this.actions.listUnitMonthStaticByTopUnit( filter.q_topUnitName, filter.cycleYear, filter.cycleMonth, function(json){ //listUnitMonthStaticByTopUnit
  622. //var data = json.data;
  623. //data.sort( function( a, b ){
  624. // return parseInt( b.statisticYear + b.statisticMonth ) - parseInt( a.statisticYear + a.statisticMonth )
  625. //})
  626. //json.data = data;
  627. if( callback )callback(json);
  628. }.bind(this))
  629. }
  630. },
  631. _removeDocument: function(documentData, all){
  632. },
  633. _createDocument: function(){
  634. },
  635. _openDocument: function( documentData ){
  636. }
  637. });
  638. MWF.xApplication.Attendance.TopUnitDetail.Document = new Class({
  639. Extends: MWF.xApplication.Attendance.Explorer.Document
  640. });
  641. MWF.xApplication.Attendance.TopUnitDetail.DetailStaticDocument = new Class({
  642. Extends: MWF.xApplication.Attendance.Explorer.Document
  643. });