UnitDetail.js 34 KB

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