PeopleDetail.js 35 KB

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