common.js 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311
  1. getUserId();
  2. function load_table_red_rank() {
  3. // get_data("fcBiWorkerDaily/get?type=1&limit=3", on_red_rank_success);
  4. }
  5. function load_table_red_rank1() {
  6. // get_data("fcBiWorkerDaily/get?type=2&limit=3", on_red_rank_success1);
  7. }
  8. function load_table_black_rank1() {
  9. // get_data("fcBiWorkerDaily/get?type=3&limit=3", on_black_rank_success1);
  10. }
  11. function load_table_black_rank() {
  12. // get_data("fcBiWorkerDaily/get?type=0&limit=3", on_black_rank_success);
  13. }
  14. var RANK_TBL_ROW_COUNT = 4;
  15. var goodColor = [];
  16. var badColor = [];
  17. var goodColor1 = [];
  18. var badColor1 = [];
  19. var userIDs = [];
  20. var schedulepass = 0, schedulefail = 0, schedulestack = 0;
  21. var todayotherpass = 0, todayotherfail = 0, todayotherstack = 0;
  22. var lastTimeHistory = "";
  23. var histoires = [];
  24. var hispass = [];
  25. var hisfail = [];
  26. var hisstack = [];
  27. var hisrate = [];
  28. var goodpass = [];
  29. var goodid = [];
  30. var goodfailrate = [];
  31. var goodpass1 = [];
  32. var goodid1 = [];
  33. var goodfailrate1 = [];
  34. var badpass = [];
  35. var badid = [];
  36. var badfailrate = [];
  37. var badpass1 = [];
  38. var badid1 = [];
  39. var badfailrate1 = [];
  40. function history_success(obj, sta) {
  41. var histoire = first_parse(this, obj);
  42. var i, j, t;
  43. if(showNetwork) console.log(" histoire : ");
  44. if(showNetwork) console.log(histoire);
  45. if (this.url.indexOf("type=1") >= 0) {
  46. t = 1;
  47. } else if (this.url.indexOf("type=2") >= 0) {
  48. t = 2;
  49. } else if (this.url.indexOf("type=3") >= 0) {
  50. t = 3;
  51. } else {
  52. t = 0;
  53. return;
  54. }
  55. histoires[t] = histoire;
  56. if (t === 2 || t === 3) {
  57. hispass[t] = 0;
  58. hisfail[t] = 0;
  59. hisstack[t] = 0;
  60. hisrate[t] = 0;
  61. for (i = 0; i < histoire.length - 1; i++) { //除了今日
  62. hispass[t] = histoire[i].passNum + hispass[t];
  63. hisfail[t] = histoire[i].failNum + hisfail[t];
  64. hisstack[t] = histoire[i].avgDue + hisstack[t];
  65. }
  66. orighispass[t] = hispass[t];
  67. orighisfail[t] = hisfail[t];
  68. orighisstack[t] = hisstack[t];
  69. hispass[t] += hispass[0];
  70. hisfail[t] += hisfail[0];
  71. hisstack[t] += hisstack[0];
  72. hisrate[t] = get_factor(hispass[t], hisfail[t]);
  73. } else if (t === 1) {
  74. hispass[1] = histoire[0].passNum;
  75. hisfail[1] = histoire[0].failNum;
  76. hisstack[1] = histoire[0].avgDue;
  77. hisrate[t] = get_factor(hispass[1], hisfail[1]);
  78. }
  79. todayotherpass = histoire[histoire.length - 1].passNum;
  80. todayotherfail = histoire[histoire.length - 1].failNum;
  81. todayotherstack = histoire[histoire.length - 1].avgDue;
  82. update_all_history();
  83. }
  84. function update_all_history() {
  85. hispass[0] = todayotherpass + schedulepass;
  86. hisfail[0] = todayotherfail + schedulefail;
  87. hisstack[0] = todayotherstack + schedulestack;
  88. hisrate[0] = get_factor(hispass[0], hisfail[0]);
  89. if (typeof hisrate[0] == "undefined" || isNaN(hisrate[0])) {
  90. send_alert("请重试!");
  91. }
  92. for (i = 2; i <= 3; i++) {
  93. hispass[i] = orighispass[i] + hispass[0];
  94. hisfail[i] = orighisfail[i] + hisfail[0];
  95. hisstack[i] = orighisstack[i] + hisstack[0];
  96. hisrate[i] = get_factor(hispass[i], hisfail[i]);
  97. }
  98. }
  99. var todayotherpass, todayotherfail, todayotherstack;
  100. var orighisfail = [], orighispass = [], orighisstack = [];
  101. function isUserOfThisFlow(uid) {
  102. var isExist = false;
  103. userIDs.forEach(function (vals) {
  104. if (vals == uid) {
  105. isExist = true;
  106. }
  107. });
  108. return isExist;
  109. }
  110. function on_red_rank_success(obj, sta) {
  111. var redchart = first_parse(this, obj);
  112. var i, j;
  113. i = j = 0;
  114. if(showNetwork) console.log(" redchart : ");
  115. if(showNetwork) console.log(redchart);
  116. for (i = 0; i < redchart.list.length; i++) {
  117. goodid[i] = getUserName(redchart.list[i].workerId);
  118. goodpass[i] = redchart.list[i].passNum;
  119. if (redchart.list[i].passNum + redchart.list[i].failNum > 0) {
  120. goodfailrate[i] = Math.floor(redchart.list[i].failNum * 10000 / (redchart.list[i].passNum + redchart.list[i].failNum)) / 100;
  121. } else {
  122. goodfailrate[i] = 0;
  123. }
  124. if (isUserOfThisFlow(redchart.list[i].workerId)) {
  125. goodColor[i] = 'red';
  126. } else {
  127. goodColor[i] = '';
  128. }
  129. }
  130. }
  131. function on_red_rank_success1(obj, sta) {
  132. var redchart = first_parse(this, obj);
  133. var i, j;
  134. i = j = 0;
  135. if(showNetwork) console.log(" redchart : ");
  136. if(showNetwork) console.log(redchart);
  137. for (i = 0; i < redchart.list.length; i++) {
  138. goodid1[i] = getUserName(redchart.list[i].workerId);
  139. goodpass1[i] = redchart.list[i].passNum;
  140. if (redchart.list[i].passNum + redchart.list[i].failNum > 0) {
  141. goodfailrate1[i] = Math.floor(redchart.list[i].failNum * 10000 / (redchart.list[i].passNum + redchart.list[i].failNum)) / 100;
  142. } else {
  143. goodfailrate1[i] = 0;
  144. }
  145. if (isUserOfThisFlow(redchart.list[i].workerId)) {
  146. goodColor1[i] = 'red';
  147. } else {
  148. goodColor1[i] = '';
  149. }
  150. }
  151. }
  152. function on_black_rank_success(obj, sta) {
  153. var blackchart = first_parse(this, obj);
  154. var i, j;
  155. i = j = 0;
  156. if(showNetwork) console.log(" black chart : ");
  157. if(showNetwork) console.log(blackchart);
  158. for (i = 0; i < blackchart.list.length; i++) {
  159. badid[i] = getUserName(blackchart.list[i].workerId);
  160. badpass[i] = blackchart.list[i].passNum;
  161. //badfailrate[i] = blackchart.list[i].failRate / 100;
  162. if (blackchart.list[i].passNum + blackchart.list[i].failNum > 0) {
  163. badfailrate[i] = Math.floor(blackchart.list[i].failNum * 10000 / (blackchart.list[i].passNum + blackchart.list[i].failNum)) / 100;
  164. } else {
  165. badfailrate[i] = 0;
  166. }
  167. if (isUserOfThisFlow(blackchart.list[i].workerId)) {
  168. badColor[i] = 'green';
  169. } else {
  170. badColor[i] = '';
  171. }
  172. }
  173. }
  174. function on_black_rank_success1(obj, sta) {
  175. var blackchart = first_parse(this, obj);
  176. var i, j;
  177. i = j = 0;
  178. if(showNetwork) console.log(" black chart : ");
  179. if(showNetwork) console.log(blackchart);
  180. for (i = 0; i < blackchart.list.length; i++) {
  181. badid1[i] = getUserName(blackchart.list[i].workerId);
  182. badpass1[i] = blackchart.list[i].passNum;
  183. //badfailrate[i] = blackchart.list[i].failRate / 100;
  184. if (blackchart.list[i].passNum + blackchart.list[i].failNum > 0) {
  185. badfailrate1[i] = Math.floor(blackchart.list[i].failNum * 10000 / (blackchart.list[i].passNum + blackchart.list[i].failNum)) / 100;
  186. } else {
  187. badfailrate1[i] = 0;
  188. }
  189. if (isUserOfThisFlow(blackchart.list[i].workerId)) {
  190. badColor1[i] = 'green';
  191. } else {
  192. badColor1[i] = '';
  193. }
  194. }
  195. }
  196. function getHistoryTableBody(htmlbody, i) {
  197. if (typeof hispass[i] === "undefined") {
  198. htmlbody += "<tr>";
  199. htmlbody += `<tr>
  200. <td> - </td>
  201. <td> - </td>
  202. <td> - </td>
  203. <td> - </td>
  204. <td> - </td>
  205. </tr>`;
  206. htmlbody += "</tr>";
  207. return htmlbody;
  208. }
  209. htmlbody += "<tr>";
  210. htmlbody += `<tr>
  211. <td>${timeday[i]}</td>
  212. <td>${hispass[i]}</td>
  213. <td>${hisfail[i]}</td>
  214. <td>${hisstack[i]}</td>
  215. <td>${hisrate[i] + '%'}</td>
  216. </tr>`;
  217. htmlbody += "</tr>";
  218. return htmlbody;
  219. }
  220. function getRankingTableBody(htmlbody, i) {
  221. if (typeof goodRank === "undefined" || typeof goodRank[i] === "undefined") {
  222. htmlbody += "<tr>";
  223. htmlbody += `<tr>
  224. <td> - </td>
  225. <td> 0 </td>
  226. <td> 0 </td>
  227. <td> 0 </td>
  228. </tr>`;
  229. htmlbody += "</tr>";
  230. return htmlbody;
  231. }
  232. htmlbody += "<tr>";
  233. htmlbody += `<tr ">
  234. <td style="background-color: ${goodRank[i].color}">${goodRank[i].id}</td>
  235. <td style="background-color: ${goodRank[i].color}">${goodRank[i].pass}</td>
  236. <td style="background-color: ${goodRank[i].color}">${goodRank[i].fail}</td>
  237. <td style="background-color: ${goodRank[i].color}">${goodRank[i].failRate + '%'}</td>
  238. </tr>`;
  239. htmlbody += "</tr>";
  240. return htmlbody;
  241. }
  242. var lastTimeRank0 = "";
  243. var lastTimeRank1 = "";
  244. var lastTimeRank2 = "";
  245. var lastTimeRank3 = "";
  246. var lastTimeRank4 = "";
  247. function showHistoryData() {
  248. var htmlbody = "", one_person = "";
  249. var i = 0;
  250. var triGap = 4;
  251. htmlbody = "";
  252. for (i = 0; i < triGap; i++) {
  253. htmlbody = getHistoryTableBody(htmlbody, i);
  254. }
  255. if (lastTimeRank0 !== htmlbody) {
  256. $("#rank-one").html(htmlbody);
  257. lastTimeRank0 = htmlbody;
  258. }
  259. //console.log(htmlbody);
  260. }
  261. function showRedRanking() {
  262. //console.log(htmlbody);
  263. }
  264. function showBlackRanking() {
  265. return; // Not Showing Because we now try to scroll pages.
  266. //
  267. // var htmlbody = "", one_person = "";
  268. // var i = 0;
  269. // var triGap = RANK_TBL_ROW_COUNT;
  270. // htmlbody = "";
  271. // for (i = 0; i < triGap; i++) {
  272. // htmlbody = getBlackRanking(htmlbody, i);
  273. // }
  274. // if (lastTimeRank2 !== htmlbody) {
  275. // $("#rank-three").html(htmlbody);
  276. // lastTimeRank2 = htmlbody;
  277. // }
  278. //console.log(htmlbody);
  279. }