entrance.js 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. var flowID = [];
  2. var flowname = [];
  3. var periodID = [];
  4. var periodname = [];
  5. getUserId();
  6. function page_document_load() {
  7. new_data_group("denglu",function(gp){
  8. if(gp.counter === 2){
  9. showEachSpot();
  10. showEachSpot1();
  11. }
  12. });
  13. checkIfExists();
  14. firsttime_load_spots_data();
  15. secondtime_load_spots_data();
  16. }
  17. function firsttime_load_spots_data() {
  18. group_get_data("denglu","fcFlow/list", first_success)
  19. }
  20. function first_success(obj, sta) {
  21. let output = first_parse(this, obj);
  22. //在这里排序 spo\
  23. console.log(" output : ");
  24. console.log(output);
  25. let i, j, k;
  26. j = 0;
  27. k = 0;
  28. for (i = 0; i < output.list.length; i++) {
  29. //if (userId+"" === ""+output.list[i].masterStaffNo) {
  30. flowID[j] = output.list[i].flowId;
  31. flowname[j] = output.list[i].flowName + "(产线)";
  32. j++;
  33. //} else {
  34. // flowID[j] = 0;
  35. // flowname[j] = output.list[i].flowName + "(无权限)";
  36. // j++;
  37. // k++;
  38. //}
  39. }
  40. if (k === output.list.length) {
  41. send_alert("请注意:您不是任一产线负责人<br>因此,您不得开始班次<br>如果有误,请修改产线的负责人信息 ");
  42. }
  43. }
  44. function secondtime_load_spots_data() {
  45. group_get_data("denglu","fcWorkPeriod/list", second_success);
  46. }
  47. function second_success(obj, sta) {
  48. var history = first_parse(this, obj).list;
  49. var i, j;
  50. console.log(" history : ");
  51. console.log(history);
  52. for (i = 0; i < history.length; i++) {
  53. periodID[i] = history[i].periodId;
  54. periodname[i] = history[i].periodName;
  55. }
  56. showEachSpot1();
  57. }
  58. function showEachSpot1() {
  59. var htmlbody = "", one_person = "";
  60. var i = 0;
  61. var triGap = periodID.length;
  62. htmlbody = "";
  63. for (i = 0; i < triGap; i++) {
  64. htmlbody = getSpotHtml1(htmlbody, i);
  65. }
  66. $("#period_ID").html(htmlbody);
  67. //console.log(htmlbody);
  68. }
  69. function getSpotHtml1(htmlbody, i) {
  70. htmlbody += "";
  71. htmlbody += `<option value="${periodID[i]}">${periodname[i]}</option>`;
  72. htmlbody += "";
  73. return htmlbody;
  74. }
  75. function showEachSpot() {
  76. var htmlbody = "", one_person = "";
  77. var i = 0;
  78. var triGap = flowID.length;
  79. htmlbody = "";
  80. for (i = 0; i < triGap; i++) {
  81. htmlbody = getSpotHtml(htmlbody, i);
  82. }
  83. $("#pro_areaCode").html(htmlbody);
  84. //console.log(htmlbody);
  85. }
  86. function getSpotHtml(htmlbody, i) {
  87. htmlbody += "";
  88. htmlbody += `<option value="${flowID[i]}">${flowname[i]}</option>`;
  89. htmlbody += "";
  90. return htmlbody;
  91. }
  92. function moveToStart(btn) {
  93. $(btn).attr("disabled", "disabled");
  94. var proAreaCode = $("#pro_areaCode").val();
  95. if(""+proAreaCode === "0"){
  96. send_alert("请确认您拥有本产线的权限");
  97. $(btn).attr("disabled","");
  98. return;
  99. }
  100. var periodnum = $("#period_ID").val();
  101. get_data("/fcWorkSchedule/startSchedule?flowId=" + proAreaCode + "&periodId=" + periodnum + "&userId="+userId, startToSchedule);
  102. }
  103. function startToSchedule(obj) {
  104. let output = first_parse(this, obj);
  105. if(output != undefined){
  106. var proAreaCode = $("#pro_areaCode").val();
  107. send_alert("即将跳转 拉长页面: scheduleId:"+output.scheduleId);
  108. location.href = 'lazhang.html?scheduleId=' + output.scheduleId + '&flowId=' + proAreaCode;
  109. }else{
  110. send_alert("开始失败!");
  111. }
  112. }
  113. function checkIfExists(){
  114. get_data("/fcWorkSchedule/remaining?status=100",on_receive_exist);
  115. }
  116. function getRemainHTML(obj) {
  117. var pdName = "";
  118. for(i=0;i<periodID.length;i++){
  119. if(periodID[i] == obj.periodId){
  120. pdName = periodname[i];
  121. break;
  122. }
  123. }
  124. return `<a href='lazhang.html?scheduleId=${obj.scheduleId}&flowId=${obj.flowId}&userId=${userId}' style="color:#d3a60c"> ${obj.flowName} ${obj.workDay} ${pdName}</a><br> `
  125. }
  126. function send_remain(a, tag) {
  127. $("#"+tag).html(a);
  128. $("#"+tag).show();
  129. return;
  130. }
  131. function on_receive_exist(objs, sta){
  132. let obj = first_parse(this, objs);
  133. console.log(obj);
  134. let wholehtml = "";
  135. if(obj != null && obj != undefined && obj.list != null){
  136. if(obj.list.length === 0){
  137. wholehtml = "当前没有正在进行的班次<br>请开始班次!";
  138. send_remain(wholehtml, "mpRemain");
  139. return;
  140. }
  141. let i = 0;
  142. wholehtml = "正在进行的班次: <br>";
  143. for(i=0;i<obj.list.length;i++){
  144. wholehtml += getRemainHTML(obj.list[i]);
  145. }
  146. send_remain(wholehtml, "mpRemain");
  147. send_remain("请及时关闭已完成班次,否则会影响工人结算、新班次数据统计!", "mpexist")
  148. }else{
  149. send_alert("查询失败");
  150. }
  151. }
  152. function logout(){
  153. setCookieWithTimeout("doibyUser","",-10);
  154. console.log(getCookie("doibyUser"));
  155. location.href="sign-in1.html";
  156. }