common.js 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  1. function load_table_red_rank() {
  2. get_data("fcBiWorkerDaily/get?type=0&limit=3", on_red_rank_success);
  3. }
  4. function load_table_black_rank() {
  5. get_data("fcBiWorkerDaily/get?type=4&limit=3", on_black_rank_success);
  6. }
  7. var lastTimeHistory = "";
  8. function history_success(obj, sta) {
  9. var history = first_parse(this, obj);
  10. var i, j, t;
  11. console.log(" history : ");
  12. console.log(history);
  13. if (this.url.indexOf("type=1") >= 0) {
  14. t = 1;
  15. } else if (this.url.indexOf("type=2") >= 0) {
  16. t = 2;
  17. } else if (this.url.indexOf("type=3") >= 0) {
  18. t = 3;
  19. } else {
  20. t = 0;
  21. }
  22. if (t === 2 || t === 3) {
  23. hispass[t] = 0;
  24. hisfail[t] = 0;
  25. hisstack[t] = 0;
  26. hisrate[t] = 0;
  27. for (i = 0; i < history.length - 1; i++) {
  28. hispass[t] = history[i].passNum + hispass[t];
  29. hisfail[t] = history[i].failNum + hisfail[t];
  30. hisstack[t] = history[i].avgDue + hisstack[t];
  31. }
  32. hispass[t] += hispass[0];
  33. hisfail[t] += hisfail[0];
  34. hisstack[t] += hisstack[0];
  35. if (hispass[t] + hisfail[t] === 0) {
  36. hisrate[t] = 0;
  37. } else {
  38. hisrate[t] = Math.floor(hisfail[t] * 10000 / (hispass[t] + hisfail[t])) / 100;
  39. }
  40. } else if (t === 1) {
  41. hispass[1] = history[0].passNum;
  42. hisfail[1] = history[0].failNum;
  43. hisstack[1] = history[0].avgDue;
  44. if (hispass[1] + hisfail[1] === 0) {
  45. hisrate[1] = 0;
  46. } else {
  47. hisrate[1] = Math.floor(hisfail[1] * 10000 / (hispass[1] + hisfail[1])) / 100;
  48. }
  49. }
  50. todayotherpass = history[history.length - 1].passNum;
  51. todayotherfail = history[history.length - 1].failNum;
  52. todayotherstack = history[history.length - 1].avgDue;
  53. }
  54. var todayotherpass , todayotherfail, todayotherstack;
  55. function isUserOfThisFlow(uid) {
  56. var isExist = false;
  57. userIDs.forEach(function (vals) {
  58. if (vals == uid) {
  59. isExist = true;
  60. }
  61. });
  62. return isExist;
  63. }
  64. function on_red_rank_success(obj, sta) {
  65. var redchart = first_parse(this, obj);
  66. var i, j;
  67. i = j = 0;
  68. console.log(" redchart : ");
  69. console.log(redchart);
  70. for (i = 0; i < redchart.list.length; i++) {
  71. goodid[i] = getUserName(redchart.list[i].workerId);
  72. goodpass[i] = redchart.list[i].passNum;
  73. if(redchart.list[i].passNum + redchart.list[i].failNum > 0) {
  74. goodfailrate[i] = Math.floor(redchart.list[i].failNum * 10000 / (redchart.list[i].passNum + redchart.list[i].failNum)) / 100;
  75. }else{
  76. goodfailrate[i] = 0;
  77. }
  78. if(isUserOfThisFlow(redchart.list[i].workerId)){
  79. goodColor[i] = 'red';
  80. }else{
  81. goodColor[i] = '';
  82. }
  83. }
  84. }
  85. function on_black_rank_success(obj, sta) {
  86. var blackchart = first_parse(this, obj);
  87. var i, j;
  88. i = j = 0;
  89. console.log(" black chart : ");
  90. console.log(blackchart);
  91. for (i = 0; i < blackchart.list.length; i++) {
  92. badid[i] = getUserName(blackchart.list[i].workerId);
  93. badpass[i] = blackchart.list[i].passNum;
  94. //badfailrate[i] = blackchart.list[i].failRate / 100;
  95. if(blackchart.list[i].passNum + blackchart.list[i].failNum > 0) {
  96. badfailrate[i] = Math.floor(blackchart.list[i].failNum * 10000 / (blackchart.list[i].passNum + blackchart.list[i].failNum)) / 100;
  97. }else{
  98. badfailrate[i] = 0;
  99. }
  100. if(isUserOfThisFlow(blackchart.list[i].workerId)){
  101. badColor[i] = 'green';
  102. }else{
  103. badColor[i] = '';
  104. }
  105. }
  106. }
  107. function getSpotHtml(htmlbody, i) {
  108. if(typeof hispass[i] === "undefined"){
  109. htmlbody += "<tr>";
  110. htmlbody += `<tr>
  111. <td> - </td>
  112. <td> - </td>
  113. <td> - </td>
  114. <td> - </td>
  115. <td> - </td>
  116. </tr>`;
  117. htmlbody += "</tr>";
  118. return htmlbody;
  119. }
  120. htmlbody += "<tr>";
  121. htmlbody += `<tr>
  122. <td>${timeday[i]}</td>
  123. <td>${hispass[i]}</td>
  124. <td>${hisfail[i]}</td>
  125. <td>${hisstack[i]}</td>
  126. <td>${hisrate[i] + '%'}</td>
  127. </tr>`;
  128. htmlbody += "</tr>";
  129. return htmlbody;
  130. }
  131. function getSpotHtml1(htmlbody, i) {
  132. if(typeof goodid[i] === "undefined"){
  133. htmlbody += "<tr>";
  134. htmlbody += `<tr>
  135. <td> - </td>
  136. <td> - </td>
  137. <td> - </td>
  138. </tr>`;
  139. htmlbody += "</tr>";
  140. return htmlbody;
  141. }
  142. htmlbody += "<tr>";
  143. htmlbody += `<tr style="background-color: ${goodColor[i]}">
  144. <td>${goodid[i]}</td>
  145. <td>${goodpass[i]}</td>
  146. <td>${goodfailrate[i] + '%'}</td>
  147. </tr>`;
  148. htmlbody += "</tr>";
  149. return htmlbody;
  150. }
  151. function getSpotHtml2(htmlbody, i) {
  152. if(typeof badid[i] === "undefined"){
  153. htmlbody += "<tr>";
  154. htmlbody += `<tr style="background-color: ${badColor[i]}">
  155. <td> - </td>
  156. <td> - </td>
  157. <td> - </td>
  158. </tr>`;
  159. htmlbody += "</tr>";
  160. return htmlbody;
  161. }
  162. htmlbody += "<tr>";
  163. htmlbody += `<tr>
  164. <td>${badid[i]}</td>
  165. <td>${badpass[i]}</td>
  166. <td>${badfailrate[i] + '%'}</td>
  167. </tr>`;
  168. htmlbody += "</tr>";
  169. return htmlbody;
  170. }
  171. var lastTimeRank1 = "";
  172. var lastTimeRank2 = "";
  173. var lastTimeRank3 = "";
  174. function showEachSpot() {
  175. var htmlbody = "", one_person = "";
  176. var i = 0;
  177. var triGap = 4;
  178. htmlbody = "";
  179. for (i = 0; i < triGap; i++) {
  180. htmlbody = getSpotHtml(htmlbody, i);
  181. }
  182. if(lastTimeRank1 !== htmlbody) {
  183. $("#rank-one").html(htmlbody);
  184. lastTimeRank1 = htmlbody;
  185. }
  186. //console.log(htmlbody);
  187. }
  188. function showEachSpot1() {
  189. var htmlbody = "", one_person = "";
  190. var i = 0;
  191. var triGap = 3;
  192. htmlbody = "";
  193. for (i = 0; i < triGap; i++) {
  194. htmlbody = getSpotHtml1(htmlbody, i);
  195. }
  196. if(lastTimeRank2 !== htmlbody){
  197. $("#rank-two").html(htmlbody);
  198. lastTimeRank2 = htmlbody;
  199. }
  200. //console.log(htmlbody);
  201. }
  202. function showEachSpot2() {
  203. var htmlbody = "", one_person = "";
  204. var i = 0;
  205. var triGap = 3;
  206. htmlbody = "";
  207. for (i = 0; i < triGap; i++) {
  208. htmlbody = getSpotHtml2(htmlbody, i);
  209. }
  210. if(lastTimeRank3 !== htmlbody){
  211. $("#rank-three").html(htmlbody);
  212. lastTimeRank3 = htmlbody;
  213. }
  214. //console.log(htmlbody);
  215. }