UnitDingdingIndex.js 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. MWF.xApplication.Attendance = MWF.xApplication.Attendance || {};
  2. MWF.require("MWF.xAction.org.express.RestActions", null,false);
  3. MWF.xDesktop.requireApp("Attendance", "lp."+MWF.language, null, false);
  4. MWF.xDesktop.requireApp("Attendance", "Common", null, false);
  5. MWF.xDesktop.requireApp("Attendance", "UnitIndex", null, false);
  6. MWF.xApplication.Attendance.UnitDingdingIndex = new Class({
  7. Extends: MWF.xApplication.Attendance.UnitIndex,
  8. Implements: [Options, Events],
  9. options: {
  10. "style": "default"
  11. },
  12. loadData : function( callback, unit, year, month, async ){
  13. this.statusColor = {
  14. "resultNormal" : "#4A90E2", //绿色,正常
  15. "leaveEarlyTimes":"#AC71E3", //蓝色,早退
  16. "lateTimes":"#F5A623", //黄色,迟到
  17. "seriousLateTimes" : "#c45f17",//严重迟到
  18. "notSignedCount":"#FF8080", //粉红色,未签到
  19. "absenteeismTimes" : "#8B572A"//矿工
  20. };
  21. if( !unit )unit = this.unit;
  22. if( !year )year = this.year;
  23. if( !month )month = this.month;
  24. if( this.data[ unit + year + month ] ) {
  25. if(callback)callback();
  26. }else{
  27. var action = o2.Actions.load("x_attendance_assemble_control");
  28. action.DingdingAttendanceStatisticAction.unitMonth(unit, year, month, function(json){
  29. var d = json.data || {};
  30. var data = this.data[ unit + year + month ] = {};
  31. var totals = data.totalData = {
  32. resultNormal: d.resultNormal || 0,
  33. lateTimes: d.lateTimes || 0,
  34. leaveEarlyTimes: d.leaveEarlyTimes || 0,
  35. absenteeismTimes: d.absenteeismTimes || 0,
  36. seriousLateTimes: d.seriousLateTimes || 0,
  37. notSignedCount: d.notSignedCount || 0
  38. }
  39. var total = 0;
  40. for( var n in totals ){
  41. total += totals[n];
  42. }
  43. data.rateData = {
  44. resultNormal : (!totals.resultNormal || !total) ? 0 : ((totals.resultNormal/total * 100).toFixed(2) + "%"),
  45. lateTimes : (!totals.lateTimes || !total) ? 0 : ((totals.lateTimes/total * 100).toFixed(2) + "%"),
  46. leaveEarlyTimes : (!totals.leaveEarlyTimes || !total) ? 0 : ((totals.leaveEarlyTimes/total * 100).toFixed(2) + "%"),
  47. absenteeismTimes : (!totals.absenteeismTimes || !total) ? 0 : ((totals.absenteeismTimes/total * 100).toFixed(2) + "%"),
  48. seriousLateTimes : (!totals.seriousLateTimes || !total) ? 0 : ((totals.seriousLateTimes/total * 100).toFixed(2) + "%"),
  49. notSignedCount : (!totals.notSignedCount || !total) ? 0 : ((totals.notSignedCount/total* 100).toFixed(2) + "%")
  50. }
  51. if(callback)callback();
  52. }.bind(this), null, async);
  53. }
  54. },
  55. loadDetail : function(){
  56. this.detailArea.empty();
  57. this.detailNode = new Element("div",{
  58. "styles" : this.css.detailNode
  59. }).inject(this.detailArea);
  60. this.detailTitleNode = new Element("div",{
  61. "styles" : this.css.detailTitleNode,
  62. "text" : this.lp.attendanceStatisic
  63. }).inject(this.detailNode)
  64. var table = new Element("table", {
  65. "width" : "100%", "border" : "0", "cellpadding" : "5", "cellspacing" : "0", "styles" : this.css.table, "class" : "editTable"
  66. }).inject( this.detailNode );
  67. var tr = new Element("tr", { "styles" : this.css.listHeadNode }).inject(table);
  68. var td = new Element("td", { "styles" : this.css.tableTitle, "text" : this.lp.name }).inject(tr);
  69. var td = new Element("td", { "styles" : this.css.tableTitle, "text" : this.lp.onDutyTimes }).inject(tr);
  70. var td = new Element("td", { "styles" : this.css.tableTitle, "text" : this.lp.offDutyTimes }).inject(tr);
  71. var td = new Element("td", { "styles" : this.css.tableTitle, "text" : this.lp.resultNormal }).inject(tr);
  72. var td = new Element("td", { "styles" : this.css.tableTitle, "text" : this.lp.lateTimes }).inject(tr);
  73. var td = new Element("td", { "styles" : this.css.tableTitle, "text" : this.lp.seriousLateTimes }).inject(tr);
  74. var td = new Element("td", { "styles" : this.css.tableTitle, "text" : this.lp.leaveEarlyTimes }).inject(tr);
  75. var td = new Element("td", { "styles" : this.css.tableTitle, "text" : this.lp.absenteeismTimes }).inject(tr);
  76. var td = new Element("td", { "styles" : this.css.tableTitle, "text" : this.lp.notSignedCount }).inject(tr);
  77. var action = o2.Actions.load("x_attendance_assemble_control");
  78. action.DingdingAttendanceStatisticAction.personMonthWithUnit(this.unit, this.year, this.month, function(json){
  79. var data = json.data || [];
  80. data.sort( function(a, b){
  81. return b.workDayCount - a.workDayCount;
  82. });
  83. data.each(function( d ){
  84. var tr = new Element("tr").inject(table);
  85. var td = new Element("td", { "styles" : this.css.tableValue , "text": d.o2User.split("@")[0] }).inject(tr);
  86. var td = new Element("td", { "styles" : this.css.tableValue , "text": d.onDutyTimes }).inject(tr);
  87. var td = new Element("td", { "styles" : this.css.tableValue , "text": d.offDutyTimes }).inject(tr);
  88. var td = new Element("td", { "styles" : this.css.tableValue , "text": d.resultNormal }).inject(tr);
  89. var td = new Element("td", { "styles" : this.css.tableValue , "text": d.lateTimes }).inject(tr);
  90. var td = new Element("td", { "styles" : this.css.tableValue , "text": d.seriousLateTimes }).inject(tr);
  91. var td = new Element("td", { "styles" : this.css.tableValue , "text": d.leaveEarlyTimes }).inject(tr);
  92. var td = new Element("td", { "styles" : this.css.tableValue , "text": d.absenteeismTimes }).inject(tr);
  93. var td = new Element("td", { "styles" : this.css.tableValue , "text": d.notSignedCount }).inject(tr);
  94. }.bind(this))
  95. }.bind(this));
  96. }
  97. });