TopUnitDetail.js 32 KB

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