common.js 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432
  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 goodColor = [];
  15. var badColor = [];
  16. var goodColor1 = [];
  17. var badColor1 = [];
  18. var userIDs = [];
  19. var schedulepass = 0, schedulefail = 0, schedulestack = 0;
  20. var todayotherpass = 0, todayotherfail = 0, todayotherstack = 0;
  21. var lastTimeHistory = "";
  22. var histoires = [];
  23. var hispass = [];
  24. var hisfail = [];
  25. var hisstack = [];
  26. var hisrate = [];
  27. var goodpass = [];
  28. var goodid = [];
  29. var goodfailrate = [];
  30. var goodpass1 = [];
  31. var goodid1 = [];
  32. var goodfailrate1 = [];
  33. var badpass = [];
  34. var badid = [];
  35. var badfailrate = [];
  36. var badpass1 = [];
  37. var badid1 = [];
  38. var badfailrate1 = [];
  39. function history_success(obj, sta) {
  40. var histoire = first_parse(this, obj);
  41. var i, j, t;
  42. console.log(" histoire : ");
  43. console.log(histoire);
  44. if (this.url.indexOf("type=1") >= 0) {
  45. t = 1;
  46. } else if (this.url.indexOf("type=2") >= 0) {
  47. t = 2;
  48. } else if (this.url.indexOf("type=3") >= 0) {
  49. t = 3;
  50. } else {
  51. t = 0;
  52. return;
  53. }
  54. histoires[t] = histoire;
  55. if (t === 2 || t === 3) {
  56. hispass[t] = 0;
  57. hisfail[t] = 0;
  58. hisstack[t] = 0;
  59. hisrate[t] = 0;
  60. for (i = 0; i < histoire.length - 1; i++) { //除了今日
  61. hispass[t] = histoire[i].passNum + hispass[t];
  62. hisfail[t] = histoire[i].failNum + hisfail[t];
  63. hisstack[t] = histoire[i].avgDue + hisstack[t];
  64. }
  65. orighispass[t] = hispass[t];
  66. orighisfail[t] = hisfail[t];
  67. orighisstack[t] = hisstack[t];
  68. hispass[t] += hispass[0];
  69. hisfail[t] += hisfail[0];
  70. hisstack[t] += hisstack[0];
  71. hisrate[t] = get_factor(hispass[t], hisfail[t]);
  72. } else if (t === 1) {
  73. hispass[1] = histoire[0].passNum;
  74. hisfail[1] = histoire[0].failNum;
  75. hisstack[1] = histoire[0].avgDue;
  76. hisrate[t] = get_factor(hispass[1], hisfail[1]);
  77. }
  78. todayotherpass = histoire[histoire.length - 1].passNum;
  79. todayotherfail = histoire[histoire.length - 1].failNum;
  80. todayotherstack = histoire[histoire.length - 1].avgDue;
  81. update_all_history();
  82. }
  83. function update_all_history(){
  84. hispass[0] = todayotherpass + schedulepass;
  85. hisfail[0] = todayotherfail + schedulefail;
  86. hisstack[0] = todayotherstack + schedulestack;
  87. hisrate[0] = get_factor(hispass[0], hisfail[0]);
  88. if(typeof hisrate[0] == "undefined" || isNaN(hisrate[0])){
  89. send_alert("请重试!");
  90. }
  91. for(i=2;i<=3;i++){
  92. hispass[i] = orighispass[i] + hispass[0];
  93. hisfail[i] = orighisfail[i] + hisfail[0];
  94. hisstack[i] = orighisstack[i] + hisstack[0];
  95. hisrate[i] = get_factor(hispass[i], hisfail[i]);
  96. }
  97. }
  98. var todayotherpass , todayotherfail, todayotherstack;
  99. var orighisfail= [], orighispass=[], orighisstack=[];
  100. function isUserOfThisFlow(uid) {
  101. var isExist = false;
  102. userIDs.forEach(function (vals) {
  103. if (vals == uid) {
  104. isExist = true;
  105. }
  106. });
  107. return isExist;
  108. }
  109. function on_red_rank_success(obj, sta) {
  110. var redchart = first_parse(this, obj);
  111. var i, j;
  112. i = j = 0;
  113. console.log(" redchart : ");
  114. console.log(redchart);
  115. for (i = 0; i < redchart.list.length; i++) {
  116. goodid[i] = getUserName(redchart.list[i].workerId);
  117. goodpass[i] = redchart.list[i].passNum;
  118. if(redchart.list[i].passNum + redchart.list[i].failNum > 0) {
  119. goodfailrate[i] = Math.floor(redchart.list[i].failNum * 10000 / (redchart.list[i].passNum + redchart.list[i].failNum)) / 100;
  120. }else{
  121. goodfailrate[i] = 0;
  122. }
  123. if(isUserOfThisFlow(redchart.list[i].workerId)){
  124. goodColor[i] = 'red';
  125. }else{
  126. goodColor[i] = '';
  127. }
  128. }
  129. }
  130. function on_red_rank_success1(obj, sta) {
  131. var redchart = first_parse(this, obj);
  132. var i, j;
  133. i = j = 0;
  134. console.log(" redchart : ");
  135. console.log(redchart);
  136. for (i = 0; i < redchart.list.length; i++) {
  137. goodid1[i] = getUserName(redchart.list[i].workerId);
  138. goodpass1[i] = redchart.list[i].passNum;
  139. if(redchart.list[i].passNum + redchart.list[i].failNum > 0) {
  140. goodfailrate1[i] = Math.floor(redchart.list[i].failNum * 10000 / (redchart.list[i].passNum + redchart.list[i].failNum)) / 100;
  141. }else{
  142. goodfailrate1[i] = 0;
  143. }
  144. if(isUserOfThisFlow(redchart.list[i].workerId)){
  145. goodColor1[i] = 'red';
  146. }else{
  147. goodColor1[i] = '';
  148. }
  149. }
  150. }
  151. function on_black_rank_success(obj, sta) {
  152. var blackchart = first_parse(this, obj);
  153. var i, j;
  154. i = j = 0;
  155. console.log(" black chart : ");
  156. console.log(blackchart);
  157. for (i = 0; i < blackchart.list.length; i++) {
  158. badid[i] = getUserName(blackchart.list[i].workerId);
  159. badpass[i] = blackchart.list[i].passNum;
  160. //badfailrate[i] = blackchart.list[i].failRate / 100;
  161. if(blackchart.list[i].passNum + blackchart.list[i].failNum > 0) {
  162. badfailrate[i] = Math.floor(blackchart.list[i].failNum * 10000 / (blackchart.list[i].passNum + blackchart.list[i].failNum)) / 100;
  163. }else{
  164. badfailrate[i] = 0;
  165. }
  166. if(isUserOfThisFlow(blackchart.list[i].workerId)){
  167. badColor[i] = 'green';
  168. }else{
  169. badColor[i] = '';
  170. }
  171. }
  172. }
  173. function on_black_rank_success1(obj, sta) {
  174. var blackchart = first_parse(this, obj);
  175. var i, j;
  176. i = j = 0;
  177. console.log(" black chart : ");
  178. console.log(blackchart);
  179. for (i = 0; i < blackchart.list.length; i++) {
  180. badid1[i] = getUserName(blackchart.list[i].workerId);
  181. badpass1[i] = blackchart.list[i].passNum;
  182. //badfailrate[i] = blackchart.list[i].failRate / 100;
  183. if(blackchart.list[i].passNum + blackchart.list[i].failNum > 0) {
  184. badfailrate1[i] = Math.floor(blackchart.list[i].failNum * 10000 / (blackchart.list[i].passNum + blackchart.list[i].failNum)) / 100;
  185. }else{
  186. badfailrate1[i] = 0;
  187. }
  188. if(isUserOfThisFlow(blackchart.list[i].workerId)){
  189. badColor1[i] = 'green';
  190. }else{
  191. badColor1[i] = '';
  192. }
  193. }
  194. }
  195. function getSpotHtml(htmlbody, i) {
  196. if(typeof hispass[i] === "undefined"){
  197. htmlbody += "<tr>";
  198. htmlbody += `<tr>
  199. <td> - </td>
  200. <td> - </td>
  201. <td> - </td>
  202. <td> - </td>
  203. <td> - </td>
  204. </tr>`;
  205. htmlbody += "</tr>";
  206. return htmlbody;
  207. }
  208. htmlbody += "<tr>";
  209. htmlbody += `<tr>
  210. <td>${timeday[i]}</td>
  211. <td>${hispass[i]}</td>
  212. <td>${hisfail[i]}</td>
  213. <td>${hisstack[i]}</td>
  214. <td>${hisrate[i] + '%'}</td>
  215. </tr>`;
  216. htmlbody += "</tr>";
  217. return htmlbody;
  218. }
  219. function getSpotHtml1(htmlbody, i) {
  220. if(typeof goodid[i] === "undefined"){
  221. htmlbody += "<tr>";
  222. htmlbody += `<tr>
  223. <td> - </td>
  224. <td> - </td>
  225. <td> - </td>
  226. <td> - </td>
  227. </tr>`;
  228. htmlbody += "</tr>";
  229. return htmlbody;
  230. }
  231. htmlbody += "<tr>";
  232. htmlbody += `<tr ">
  233. <td style="background-color: ${goodColor[i]}">${goodid[i]}</td>
  234. <td style="background-color: ${goodColor[i]}">${goodpass[i]}</td>
  235. <td style="background-color: ${goodColor1[i]}">${goodid1[i]}</td>
  236. <td style="background-color: ${goodColor1[i]}">${goodfailrate1[i] + '%'}</td>
  237. </tr>`;
  238. htmlbody += "</tr>";
  239. return htmlbody;
  240. }
  241. /*function getSpotHtml3(htmlbody, i) {
  242. if(typeof goodid1[i] === "undefined"){
  243. htmlbody += "<tr>";
  244. htmlbody += `<tr>
  245. <td> - </td>
  246. <td> - </td>
  247. </tr>`;
  248. htmlbody += "</tr>";
  249. return htmlbody;
  250. }
  251. htmlbody += "<tr>";
  252. htmlbody += `<tr style="background-color: ${goodColor1[i]}">
  253. <td>${goodid1[i]}</td>
  254. <td>${goodfailrate1[i] + '%'}</td>
  255. </tr>`;
  256. htmlbody += "</tr>";
  257. return htmlbody;
  258. }*/
  259. function getSpotHtml2(htmlbody, i) {
  260. if(typeof badid[i] === "undefined"){
  261. htmlbody += "<tr>";
  262. htmlbody += `<tr>
  263. <td> - </td>
  264. <td> - </td>
  265. <td> - </td>
  266. <td> - </td>
  267. </tr>`;
  268. htmlbody += "</tr>";
  269. return htmlbody;
  270. }
  271. htmlbody += "<tr>";
  272. if(typeof badColor[i] === "undefined"){
  273. htmlbody += `<tr>
  274. <td style="background-color: ${badColor[i]}">${badid[i]}</td>
  275. <td style="background-color: ${badColor[i]}">${badpass[i]}</td>
  276. <td style="background-color: ${badColor1[i]}">${badid1[i]}</td>
  277. <td style="background-color: ${badColor1[i]}">${badfailrate1[i] + '%'}</td>
  278. </tr>`;
  279. }else {
  280. htmlbody += `<tr >
  281. <td style="background-color: ${badColor[i]}">${badid[i]}</td>
  282. <td style="background-color: ${badColor[i]}">${badpass[i]}</td>
  283. <td style="background-color: ${badColor1[i]}">${badid1[i]}</td>
  284. <td style="background-color: ${badColor1[i]}">${badfailrate1[i] + '%'}</td>
  285. </tr>`;
  286. }
  287. htmlbody += "</tr>";
  288. return htmlbody;
  289. }
  290. /*function getSpotHtml4(htmlbody, i) {
  291. if(typeof badid1[i] === "undefined"){
  292. htmlbody += "<tr>";
  293. htmlbody += `<tr>
  294. <td> - </td>
  295. <td> - </td>
  296. </tr>`;
  297. htmlbody += "</tr>";
  298. return htmlbody;
  299. }
  300. htmlbody += "<tr>";
  301. if(typeof badColor1[i] === "undefined"){
  302. htmlbody += `<tr style="background-color: ${badColor1[i]}">
  303. <td>${badid1[i]}</td>
  304. <td>${badfailrate1[i] + '%'}</td>
  305. </tr>`;
  306. }else {
  307. htmlbody += `<tr style="background-color: ${badColor1[i]}">
  308. <td>${badid1[i]}</td>
  309. <td>${badfailrate1[i] + '%'}</td>
  310. </tr>`;
  311. }
  312. htmlbody += "</tr>";
  313. return htmlbody;
  314. }*/
  315. var lastTimeRank0 = "";
  316. var lastTimeRank1 = "";
  317. var lastTimeRank2 = "";
  318. var lastTimeRank3 = "";
  319. var lastTimeRank4 = "";
  320. function showEachSpot() {
  321. var htmlbody = "", one_person = "";
  322. var i = 0;
  323. var triGap = 4;
  324. htmlbody = "";
  325. for (i = 0; i < triGap; i++) {
  326. htmlbody = getSpotHtml(htmlbody, i);
  327. }
  328. if(lastTimeRank0 !== htmlbody) {
  329. $("#rank-one").html(htmlbody);
  330. lastTimeRank0 = htmlbody;
  331. }
  332. //console.log(htmlbody);
  333. }
  334. function showEachSpot1() {
  335. var htmlbody = "", one_person = "";
  336. var i = 0;
  337. var triGap = 3;
  338. htmlbody = "";
  339. for (i = 0; i < triGap; i++) {
  340. htmlbody = getSpotHtml1(htmlbody, i);
  341. }
  342. if(lastTimeRank1 !== htmlbody){
  343. $("#rank-two").html(htmlbody);
  344. lastTimeRank1 = htmlbody;
  345. }
  346. //console.log(htmlbody);
  347. }
  348. /*function showEachSpot3() {
  349. var htmlbody = "", one_person = "";
  350. var i = 0;
  351. var triGap = 3;
  352. htmlbody = "";
  353. for (i = 0; i < triGap; i++) {
  354. htmlbody = getSpotHtml3(htmlbody, i);
  355. }
  356. if(lastTimeRank3 !== htmlbody){
  357. $("#rank-four").html(htmlbody);
  358. lastTimeRank3 = htmlbody;
  359. }
  360. //console.log(htmlbody);
  361. }*/
  362. function showEachSpot2() {
  363. var htmlbody = "", one_person = "";
  364. var i = 0;
  365. var triGap = 3;
  366. htmlbody = "";
  367. for (i = 0; i < triGap; i++) {
  368. htmlbody = getSpotHtml2(htmlbody, i);
  369. }
  370. if(lastTimeRank2 !== htmlbody){
  371. $("#rank-three").html(htmlbody);
  372. lastTimeRank2 = htmlbody;
  373. }
  374. //console.log(htmlbody);
  375. }
  376. /*function showEachSpot4() {
  377. var htmlbody = "", one_person = "";
  378. var i = 0;
  379. var triGap = 3;
  380. htmlbody = "";
  381. for (i = 0; i < triGap; i++) {
  382. htmlbody = getSpotHtml4(htmlbody, i);
  383. }
  384. if(lastTimeRank4 !== htmlbody){
  385. $("#rank-five").html(htmlbody);
  386. lastTimeRank4 = htmlbody;
  387. }
  388. //console.log(htmlbody);
  389. }*/