cim.js 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  1. var normal = '<div style="width: 10px; height: 10px; display: inline-block; border-radius: 5px; background-color: green;"></div>'
  2. var abnormal = '<div style="width: 10px; height: 10px; display: inline-block; border-radius: 5px; background-color: red;"></div>'
  3. var offline = '<div style="width: 10px; height: 10px; display: inline-block; border-radius: 5px; background-color: gray;"></div><span> 离线</span>'
  4. var online = '<div style="width: 10px; height: 10px; display: inline-block; border-radius: 5px; background-color: green;"></div><span> 在线</span>'
  5. function getCims() {
  6. $.ajax({
  7. url: "/Cim/GetCims",
  8. method: "GET",
  9. headers: { "Content-Type": "application/json" },
  10. async: true,
  11. data: {
  12. isShowError: $("#isShowError").prop("checked")
  13. },
  14. success: function (result) {
  15. if (result.code === 0) {
  16. $("#cims").html("");
  17. for (var i = 0; i < result.data.length; i++) {
  18. var html =
  19. "<div class='col-lg-3'>" +
  20. "<div class='cim-div'>" +
  21. "<ul style='list-style: none; padding: 0;'>" +
  22. "<li style='padding-top: 2px;'><b>" + result.data[i].topic + "</b></li>" +
  23. "<li style='padding-top: 4px;'>" + (result.data[i].isConnected === true ? online : offline) + "</li>" +
  24. "<li style='padding-top: 2px;'>IP. " + result.data[i].ipAddress + "</li>" +
  25. "<li style='padding-top: 2px;'>Name. " + result.data[i].user + "</li>" +
  26. "<li style='padding-top: 2px;'>PLC. " + (result.data[i].plcIsConnected === true ? normal : abnormal) +
  27. "&nbsp;&nbsp;/&nbsp;&nbsp;EAP. " + (result.data[i].eapIsConnected === true ? normal : abnormal) + "</li>" +
  28. "<li style='padding-top: 4px;'>EAP. " + result.data[i].eapip + ":" + result.data[i].eapPort + "</li>" +
  29. "<li style='padding-top: 4px;'>Ver. " + result.data[i].version + "</li>" +
  30. "<li style='padding-top: 4px;'>" + result.data[i].time + "</li>" +
  31. "</ul>" +
  32. "</div>" +
  33. "</div>";
  34. $("#cims").append(html);
  35. }
  36. }
  37. }
  38. });
  39. }
  40. function getChangeShifts() {
  41. $.ajax({
  42. url: "/Cim/ChangeShifts",
  43. method: "GET",
  44. headers: { "Content-Type": "application/json" },
  45. async: true,
  46. success: function (result) {
  47. if (result.code === 0) {
  48. $("#changeShift").html("");
  49. $("#changeShiftLabel").text("未换班机台 " + result.data.length + " 台");
  50. for (var i = 0; i < result.data.length; i++) {
  51. var html =
  52. "<p>" + result.data[i].topic + "</P>";
  53. $("#changeShift").append(html);
  54. }
  55. }
  56. }
  57. });
  58. }
  59. $("#isShowError").change(function () {
  60. getCims();
  61. });
  62. function Init() {
  63. getCims();
  64. getChangeShifts();
  65. }
  66. Init();
  67. setInterval(Init, 10000);
  68. function modal_issued_show() {
  69. $("#modal_issued").modal("show");
  70. }
  71. var zTreeObj;
  72. var setting = {
  73. check: {
  74. enable: true
  75. }
  76. };
  77. $.ajax({
  78. url: "/ProductionLine/GetProductionLineMachineTree",
  79. type: "GET",
  80. async: true,
  81. success: function (zNodes) {
  82. zTreeObj = $.fn.zTree.init($("#productionLineTree"), setting, zNodes);
  83. }
  84. });
  85. function setEap() {
  86. var nodes = zTreeObj.getCheckedNodes(true);
  87. if (nodes.length === 0) {
  88. alert("请勾选设备!");
  89. return;
  90. }
  91. var ids = new Array();
  92. for (var i = 0; i < nodes.length; i++) {
  93. if (nodes[i].level === 1) {
  94. ids.push(nodes[i].id);
  95. }
  96. }
  97. if (ids.length === 0) {
  98. alert("请勾选设备!");
  99. return;
  100. }
  101. var ip = $("#eapIp").val();
  102. var port = $("#eapPort").val();
  103. if (ip === "" || port === "") {
  104. alert("请填写 IP/Port!");
  105. return;
  106. }
  107. $.ajax({
  108. url: "/Cim/SetEAP",
  109. type: "POST",
  110. async: true,
  111. data: {
  112. "ids": ids.toString(),
  113. "ip": ip,
  114. "port": port
  115. },
  116. success: function (rev) {
  117. alert(rev.message);
  118. }
  119. });
  120. }
  121. function setEapIp() {
  122. var nodes = zTreeObj.getCheckedNodes(true);
  123. if (nodes.length === 0) {
  124. alert("请勾选设备!");
  125. return;
  126. }
  127. var ids = new Array();
  128. for (var i = 0; i < nodes.length; i++) {
  129. if (nodes[i].level === 1) {
  130. ids.push(nodes[i].id);
  131. }
  132. }
  133. if (ids.length === 0) {
  134. alert("请勾选设备!");
  135. return;
  136. }
  137. var ip = $("#eapIp1").val();
  138. if (ip === "") {
  139. alert("请填写 IP!");
  140. return;
  141. }
  142. $.ajax({
  143. url: "/Cim/SetEapIp",
  144. type: "POST",
  145. async: true,
  146. data: {
  147. "ids": ids.toString(),
  148. "ip": ip
  149. },
  150. success: function (rev) {
  151. alert(rev.message);
  152. }
  153. });
  154. }
  155. function setUpdateApp() {
  156. var nodes = zTreeObj.getCheckedNodes(true);
  157. if (nodes.length === 0) {
  158. alert("请勾选设备!");
  159. return;
  160. }
  161. var ids = new Array();
  162. for (var i = 0; i < nodes.length; i++) {
  163. if (nodes[i].level === 1) {
  164. ids.push(nodes[i].id);
  165. }
  166. }
  167. if (ids.length === 0) {
  168. alert("请勾选设备!");
  169. return;
  170. }
  171. $.ajax({
  172. url: "/Cim/UpdateApp",
  173. type: "POST",
  174. async: true,
  175. data: {
  176. "ids": ids.toString()
  177. },
  178. success: function (rev) {
  179. alert(rev.message);
  180. }
  181. });
  182. }