index.html 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  1. <!DOCTYPE html>
  2. <html lang="zh-CN">
  3. <head>
  4. <meta charset="utf-8">
  5. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  6. <meta name="viewport" content="width=device-width, initial-scale=1">
  7. <title>兴胜机械数字化车间</title>
  8. <link href="../css/bootstrap.css" rel="stylesheet">
  9. <link rel="stylesheet" href="../css/base.css">
  10. <link rel="stylesheet" href="../css/index.css">
  11. <style>
  12. .t_title{
  13. width: 100%;
  14. height: 100%;
  15. text-align: center;
  16. font-size: 3.8em;
  17. line-height: 80px;
  18. color: #fff;
  19. background: -webkit-linear-gradient(top, #4e72b8, #FFF);
  20. -webkit-background-clip: text;
  21. -webkit-text-fill-color: transparent;
  22. }
  23. #chart_map{
  24. cursor: pointer;
  25. }
  26. .t_show{
  27. position: absolute;
  28. top: 0;
  29. right: 0;
  30. border-radius: 2px;
  31. background: #2C58A6;
  32. padding: 2px 5px;
  33. color: #fff;
  34. cursor: pointer;
  35. }
  36. </style>
  37. </head>
  38. <body>
  39. <!--header-->
  40. <div class="header">
  41. <div class="bg_header">
  42. <div class="temp">
  43. <span id="temp"></span>
  44. <img style="top: -8%;position: absolute;" src="../images/icons8-温度-64.png">
  45. </div>
  46. <div class="hum">
  47. <span id="hum"></span>
  48. <img style="top: -8%;position: absolute; margin-left: 16%;" src="../images/icons8-湿度-60.png">
  49. </div>
  50. <div onclick="fullScreen()">
  51. <img class="fullScreen" src="../images/icons8-全屏-50.png">
  52. </div>
  53. <div class="header_nav fl t_title">
  54. 兴胜机械数字化车间
  55. </div>
  56. </div>
  57. </div>
  58. <!--main-->
  59. <div class="data_content" style="height: 100vh;">
  60. <div class="data_bottom">
  61. </div>
  62. </div>
  63. </body>
  64. <script src="../js/jquery.min.js"></script>
  65. <script src="../js/bootstrap.min.js"></script>
  66. <script src="../js/common.js"></script>
  67. <script src="../js/echarts.min.js"></script>
  68. <script src="../js/datatool.js"></script>
  69. <!-- <script src="scripts/china.js"></script> -->
  70. <script src="../js/guangxi.js"></script>
  71. <script type="text/javascript">
  72. // 假设设备信息的容器元素是一个 <div> 标签,并具有类名 "data_bottom"
  73. const container = document.querySelector('.data_bottom');
  74. var requestData;
  75. let shouldRefresh = true; // 一个标志,用于确定页面是否应该刷新
  76. function init(){
  77. callAPI();
  78. // 首次调用函数开始刷新
  79. setInterval(function() {
  80. refreshPage();
  81. }, 10000); // 设置10秒钟的定时器
  82. }
  83. function refreshPage() {
  84. $.ajax({
  85. url: "/bigScreen/getRefresh",
  86. type: "GET", // 指定请求类型为 POST
  87. dataType: "JSON",
  88. success: function (resp) {
  89. if(resp.data ||resp.data == null){
  90. location.reload(true); // 重新加载页面,参数为 true 表示强制从服务器重新加载
  91. }
  92. },
  93. error: function (error) {
  94. console.error("发生错误:", error);
  95. }
  96. });
  97. }
  98. function callAPI() {
  99. requestData = {
  100. // 根据你的后端要求构建 PageParam 对象
  101. pageParam: {
  102. // 可能需要添加具体的属性值,比如 pageSize, pageNumber 等等
  103. "openPage": "NO"
  104. }
  105. };
  106. $.ajax({
  107. url:"/admin/page/crudQuery/aDevice",
  108. type: "POST", // 指定请求类型为 POST
  109. contentType: "application/json", // 设置请求的内容类型为 JSON
  110. dataType: "JSON",
  111. data: JSON.stringify(requestData), // 将请求数据转换为 JSON 字符串
  112. success:function(resp){
  113. // 获取接口返回的设备信息数组
  114. const devices = resp.data.rows;
  115. var temp=devices[0].temp;
  116. var hum=devices[0].hum;
  117. $('#temp').text(temp);
  118. $('#hum').text(hum);
  119. // 循环遍历设备信息数组
  120. devices.forEach(device => {
  121. // 创建一个新的 div 元素用于展示设备信息
  122. const newDeviceDiv = document.createElement('div');
  123. newDeviceDiv.classList.add('bottom_1', 'fl', 't_btn5');
  124. // 构建设备信息的 HTML 结构
  125. newDeviceDiv.innerHTML = `
  126. <div class="main_title">
  127. <img src="../picture/t_7.png" alt="">
  128. ${device.deviceName ? device.deviceName : '未知'}
  129. </div>
  130. <div class="main_table t_btn8" id=\"${device.id}\">
  131. <img src="../picture/device/`+device.deviceModel+`.png" ">
  132. <table>
  133. <thead>
  134. <tr>
  135. <th style="color: ${device.deviceState === '在线' ? 'green' : 'red'};">${device.deviceState}</th>
  136. <th style="color: ${device.deviceWorkState === '加工' ? '' : 'orange'};">${device.deviceWorkState == null ? '' : device.deviceWorkState}</th>
  137. </tr>
  138. </thead>
  139. <tbody>
  140. <tr>
  141. <td>主程序号</td>
  142. <td>${(device.mainProg !== null && device.mainProg !== undefined && device.mainProg !== 'NaN' && device.mainProg !== '') ? device.mainProg : ''}</td>
  143. </tr>
  144. <tr>
  145. <td>主轴转速</td>
  146. <td>${(device.actSpindle !== null && device.actSpindle !== undefined && device.actSpindle !== 'NaN' && device.actSpindle !== '') ? device.actSpindle : '0'}</td>
  147. </tr>
  148. <tr>
  149. <td>主轴倍率</td>
  150. <td>${(device.spindleMagnification !== null && device.spindleMagnification !== undefined && device.spindleMagnification !== 'NaN' && device.spindleMagnification !== '') ? device.spindleMagnification + '%' : '0'}</td>
  151. </tr>
  152. <tr>
  153. <td>进给速度</td>
  154. <td>${(device.actFeed !== null && device.actFeed !== undefined && device.actFeed !== 'NaN' && device.actFeed !== '') ? device.actFeed : '0'}</td>
  155. </tr>
  156. <tr>
  157. <td>进给倍率</td>
  158. <td>${(device.feedRateOvr !== null && device.feedRateOvr !== undefined && device.feedRateOvr !== 'NaN' && device.feedRateOvr !== '') ? device.feedRateOvr + '%' : '0'}</td>
  159. </tr>
  160. </tbody>
  161. </table>
  162. </div>
  163. `;
  164. // 将创建的设备信息 div 添加到容器中
  165. container.appendChild(newDeviceDiv);
  166. const deviceContainer = document.getElementById(device.id);
  167. deviceContainer.addEventListener('click', function() {
  168. // 点击事件触发时,构建新的请求数据
  169. var detailRequestData = {
  170. deviceId: device.id // 假设接口需要的参数是 deviceId
  171. };
  172. const id = device.id; // 假设设备元素的 ID 存储在 data-id 属性中
  173. // 动态创建链接并跳转
  174. const link = document.createElement('a');
  175. link.href = '/admin/bigScreenDetail/index.html?id=' + encodeURIComponent(id);
  176. /*link.target = '_blank'; // 设置链接在新标签页中打开*/
  177. document.body.appendChild(link);
  178. link.click();
  179. });
  180. });
  181. }
  182. });
  183. }
  184. function fullScreen() {
  185. const element = document.documentElement; // 获取整个页面元素
  186. if (!document.fullscreenElement) {
  187. // 如果当前不是全屏状态,则请求全屏
  188. if (element.requestFullscreen) {
  189. element.requestFullscreen();
  190. } else if (element.webkitRequestFullscreen) {
  191. // 兼容性处理,针对某些浏览器
  192. element.webkitRequestFullscreen();
  193. } else if (element.msRequestFullscreen) {
  194. // 兼容性处理,针对IE浏览器
  195. element.msRequestFullscreen();
  196. }
  197. } else {
  198. // 如果当前是全屏状态,则退出全屏
  199. if (document.exitFullscreen) {
  200. document.exitFullscreen();
  201. } else if (document.webkitExitFullscreen) {
  202. // 兼容性处理,针对某些浏览器
  203. document.webkitExitFullscreen();
  204. } else if (document.msExitFullscreen) {
  205. // 兼容性处理,针对IE浏览器
  206. document.msExitFullscreen();
  207. }
  208. }
  209. }
  210. init();
  211. </script>
  212. </html>