newLazhang.js 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. getUserId();
  2. var FlowRealTime = new (function () {
  3. this.pgName = "flowDashBoard";
  4. this.page = new SinglePage(this.pgName);
  5. this.scheduleId = utils_get_param("scheduleId");
  6. this.flowId = utils_get_param("flowId");
  7. if(scheduleId == null || flowId == null)
  8. {
  9. send_alert(`清重新进入本页面!<a href='denglu.html'> 返回主页 </a>`);
  10. return;
  11. }
  12. this.flowPlace = " % flowPlace %";
  13. this.flowName = " % flowPlace %";
  14. this.scheduleLoadDataService = new DataObjectService("fcWorkScheduleLoad", ONDEMAND /*AUTO & FAST*/, "?scheduleId=" + scheduleId);
  15. this.oaStaffService = new DataObjectService("fcWorkScheduleLoad", ONDEMAND, "");
  16. this.sectorService = new DataObjectService("fcWorkScheduleLoad", ONDEMAND, "");
  17. this.flowService = new DataObjectService("fcFlow", ONDEMAND, "");
  18. this.MeduimData = new (function () {
  19. this.initializeUsers = function(list){
  20. list.forEach(function (val, it, arr) {
  21. var isExist = false;
  22. userIDs.forEach(function (vals) {
  23. if (vals == val.userId) {
  24. isExist = true;
  25. }
  26. });
  27. if (!isExist) userIDs.push(val.userId);
  28. });
  29. };
  30. })();
  31. this.initPage = function() {
  32. // todo...
  33. };
  34. this.Action = new (function (parent) {
  35. this.parent = parent;
  36. this.doStopSchedule = function () {
  37. get_data("fcWorkSchedule/stopSchedule?userId=" + userId + "&scheduleId=" + scheduleId, this.parent.UI.showStopSuccess, this.parent);
  38. };
  39. this.confirmStopSchedule = function () {
  40. var out = confirm("真的要下班吗?");
  41. if (out == true) {
  42. this.doStopSchedule();
  43. } else {
  44. }
  45. };
  46. })(this);
  47. this.UI = new (function (parent) {
  48. this.p = parent;
  49. this.showClearPanel = function () {
  50. $("#clearModal").modal('show');
  51. };
  52. this.showStopSuccess = function (obj, sta, scope) {
  53. send_alert("下班操作成功! <a href='denglu.html'> 点击这里返回控制主页 </a>");
  54. };
  55. this.bind = function () {
  56. $(".confirm-clear-data").click(function(){
  57. FlowRealTime.ClearDataControl.clearDataOfDeviceId($('#handInput').val());
  58. });
  59. $(".open-clear-panel").click(function () {
  60. FlowRealTime.UI.showClearPanel();
  61. })
  62. $(".close-schedule").click(function () {
  63. FlowRealTime.Action.confirmStopSchedule();
  64. })
  65. }
  66. })(this);
  67. this.ClearDataControl = new (function (parent) {
  68. this.p = parent;
  69. this.finished = true;
  70. this.executed = false;
  71. this.directCount = -1;
  72. this.clearDataOfDeviceId = function (handId) {
  73. this.executed = false;
  74. this.directCount = -1;
  75. this.finished = true;
  76. var hand = handId;
  77. hand = hand.trim();
  78. var possible = "0123456789,-*";
  79. for(let i = 0; i < hand.length ; i++){
  80. if(possible.indexOf(hand.charAt(i)) === -1){
  81. send_alert("您的输入有误,请重新输入 : " +handId);
  82. return;
  83. }
  84. }
  85. get_data("endpoint/clearBoard?flowId=" + flowId + "&handheldId=" + hd, this.clearSuccess);
  86. };
  87. this.clearSuccess = function (obj, sta) {
  88. console.warn("------- 手持设备清空 ----------");
  89. console.warn(obj);
  90. send_alert("发送清空请求成功, 正在等待采集端进行处理...");
  91. this.finished = false;
  92. setTimeout(this.resultVerifyTimeout, 8000, this);
  93. setTimeout(this.getVerify, 300, this);
  94. }
  95. this.getVerify = function (obj) {
  96. if (obj.finished) return;
  97. get_data("endpoint/heartbeat?flowId=" + flowId, obj.onVerifyResult);
  98. setTimeout(obj.getVerify, 100, obj);
  99. };
  100. this.onVerifyResult = function (obj, sta) {
  101. var parsed = {};
  102. if (typeof(obj) === "string") {
  103. parsed = JSON.parse(obj);
  104. } else {
  105. parsed = obj;
  106. }
  107. if (typeof(parsed) === "object") {
  108. if (parsed.ret === "10000") {
  109. //ok
  110. if (parsed.model == null || parsed.model === undefined) {
  111. executed = true;
  112. finished = true;
  113. } else if (typeof(obj.model) === "object") {
  114. // 没有拿到,继续
  115. if (obj.model.list != null && obj.model.list.length > 0) {
  116. var direct = obj.model.list[0];
  117. if (direct.eventType + "" !== "500") {
  118. // OK
  119. executed = true;
  120. finished = true;
  121. } else if (direct.arg2 + "" !== "" + $("#handInput").val()) {
  122. // OK
  123. executed = true;
  124. finished = true;
  125. } else {
  126. directCount = direct.counter;
  127. }
  128. }
  129. }
  130. }
  131. }
  132. }
  133. this.resultVerifyTimeout = function (obj) {
  134. finished = true;
  135. if (executed) {
  136. // 执行成功
  137. } else {
  138. if (directCount >= 0) {
  139. get_data("endpoint/ack?counter=" + directCount, function () {
  140. console.log("撤销操作成功");
  141. console.log(this);
  142. });
  143. directCount = -1;
  144. send_alert("请求已经超时!请注意,采集端可能没有执行成功。即将撤销您的请求。");
  145. } else {
  146. send_alert("请求已经超时!请注意,采集端可能没有执行成功。");
  147. }
  148. }
  149. }
  150. })(this);
  151. })();
  152. $(document).ready(function(){
  153. FlowRealTime.initPage();
  154. FlowRealTime.UI.bind();
  155. });