equipmentMonitoring.html 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491
  1. <!doctype html>
  2. <html>
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
  6. <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
  7. <meta name="format-detection" content="telephone=no">
  8. <title>设备监控</title>
  9. <link rel="stylesheet" type="text/css" href="../../css/api.css" />
  10. <link rel="stylesheet" type="text/css" href="../../css/style.css" />
  11. <link rel="stylesheet" href="../../css/projeck.css">
  12. </head>
  13. <style>
  14. body,
  15. html {
  16. background: #009FE8;
  17. }
  18. .api_layout {
  19. padding: 0 10px 10px 10px;
  20. -webkit-box-sizing: border-box;
  21. -moz-box-sizing: border-box;
  22. box-sizing: border-box;
  23. }
  24. .top {
  25. width: 100%;
  26. position: relative;
  27. }
  28. .top_img {
  29. display: block;
  30. width: 100%;
  31. height: 100%;
  32. border-radius: 10px;
  33. }
  34. .top p {
  35. position: absolute;
  36. top: 130px;
  37. right: 8px;
  38. font-weight: bold;
  39. font-size: 15px;
  40. }
  41. .content {
  42. padding: 15px;
  43. background: white;
  44. -webkit-box-sizing: border-box;
  45. -moz-box-sizing: border-box;
  46. box-sizing: border-box;
  47. width: 100%;
  48. /* margin-bottom: 13px; */
  49. margin-top: 6px;
  50. position: relative;
  51. padding-top: 13px;
  52. box-shadow: 0 3px 29px 0 rgba(59, 74, 116, 0.14);
  53. }
  54. /*.borderRa {
  55. -webkit-border-radius: 10px;
  56. -moz-border-radius: 10px;
  57. border-radius: 10px;
  58. }*/
  59. .con_two {
  60. display: inline-block;
  61. height: 100%;
  62. }
  63. .content .title {
  64. text-align: center;
  65. font-size: 15px;
  66. color: #222627;
  67. font-weight: bold;
  68. }
  69. .borderRa:after {
  70. content: "";
  71. position: absolute;
  72. top: 50px;
  73. left: 0;
  74. width: 100%;
  75. height: 1px;
  76. background: #F3F3F3;
  77. }
  78. .content .condition {
  79. display: inline-block;
  80. width: 100%;
  81. height: 140px;
  82. background: white;
  83. position: relative;
  84. padding-top: 30px;
  85. }
  86. .condition .draught {
  87. width: 14px;
  88. height: 14px;
  89. border-radius: 50%;
  90. background: #ff3d27;
  91. }
  92. .circular-name {
  93. display: flex;
  94. justify-content: center;
  95. align-items: center;
  96. }
  97. .circular-name span {
  98. font-size: 15px;
  99. margin-left: 5px;
  100. }
  101. .content .condition .statistical {
  102. display: inline-block;
  103. width: 100%;
  104. }
  105. .content .condition .statistical img {
  106. width: 100%;
  107. height: 100%;
  108. }
  109. .con {
  110. display: inline-block;
  111. width: 100%;
  112. height: 100%;
  113. padding: 0;
  114. }
  115. #tab_bar {
  116. width: 100%;
  117. height: 30px;
  118. }
  119. #tab_bar ul {
  120. padding: 0px;
  121. margin: 0px;
  122. height: 30px;
  123. text-align: center;
  124. border-bottom: 1px solid #f8f8fb;
  125. }
  126. #tab_bar li {
  127. list-style-type: none;
  128. float: left;
  129. width: 90px;
  130. height: 30px;
  131. line-height: 24px;
  132. color: #222627;
  133. }
  134. .tab_css {
  135. width: 100%;
  136. display: none;
  137. margin-top: 10px;
  138. }
  139. .tab_css .head {
  140. width: 100%;
  141. height: 40px;
  142. background: #F3F6FA;
  143. border-radius: 2px;
  144. color: #222627;
  145. display: flex;
  146. justify-content: space-between;
  147. }
  148. .head li {
  149. list-style: none;
  150. line-height: 40px;
  151. width: 25%;
  152. color: #222627;
  153. font-size: 13px;
  154. text-align: center;
  155. }
  156. .head li:first-child {
  157. width: 50%;
  158. }
  159. .items {
  160. padding: 0;
  161. margin: 0;
  162. width: 100%;
  163. border-radius: 2px;
  164. color: #222627;
  165. }
  166. .items .list {
  167. padding: 10px 0;
  168. text-align: center;
  169. display: flex;
  170. justify-content: space-between;
  171. position: relative;
  172. align-items: center;
  173. }
  174. .items .list span {
  175. width: 25%;
  176. color: #222627;
  177. font-size: 13px;
  178. }
  179. .list span:first-child {
  180. width: 50%;
  181. padding: 0 5px;
  182. box-sizing: border-box;
  183. }
  184. .list::after {
  185. content: '';
  186. position: absolute;
  187. bottom: 0;
  188. left: 0;
  189. width: 100%;
  190. height: 1px;
  191. background: #E8E9EA;
  192. }
  193. .list span:nth-child(2) {
  194. background: #64dcff;
  195. height: 20px;
  196. line-height: 20px;
  197. }
  198. #contents {
  199. margin-top: 23px;
  200. }
  201. </style>
  202. <body>
  203. <div class="api_layout">
  204. <div class="top">
  205. <img class="top_img" src="../../image/Equipmentmonito.png" alt="">
  206. <p class="time-box"></p>
  207. </div>
  208. <div class="content borderRa con_two">
  209. <p class="title">实时参数</p>
  210. <pseudo:after></pseudo:after>
  211. <div id="contents" class="con">
  212. <div id="tab_bar">
  213. <ul>
  214. <li id="tab1" onclick="myclick(1)" style="color: #3498DB;border-bottom: 2px solid #009FE8;font-weight: bold;">
  215. 1#设备
  216. </li>
  217. <li id="tab2" onclick="myclick(2)">
  218. 2#设备
  219. </li>
  220. </ul>
  221. </div>
  222. <div class="tab_css" id="tab1_content" style="display: block">
  223. </div>
  224. <div class="tab_css" id="tab2_content">
  225. </div>
  226. </div>
  227. </div>
  228. <div id="template_item_one">
  229. </div>
  230. <!-- 设备1# -->
  231. <div class="equipment_one_items tab_css" id="equipment_one" style="display: block">
  232. <div id="equipment_I_temperature" class="content borderRa con_two" style="padding: 15px 5px;">
  233. </div>
  234. <div id="equipment_I_vibration" class="content borderRa con_two" style="padding: 15px 5px;">
  235. </div>
  236. </div>
  237. <!-- 设备2# -->
  238. <div class="equipment_two_items tab_css" id="equipment_two" style="display: none">
  239. <div id="equipment_II_temperature" class="content borderRa con_two" style="padding: 15px 5px;">
  240. </div>
  241. <div id="equipment_II_vibration" class="content borderRa con_two" style="padding: 15px 5px;">
  242. </div>
  243. </div>
  244. </div>
  245. </body>
  246. <script type="text/template" id="fanTemplate">
  247. <ul class="head">
  248. <li>参数名称</li>
  249. <li>数值</li>
  250. <li>单位</li>
  251. </ul>
  252. <ul class="items">
  253. {{ for (var i = 0;i
  254. <it.length;i++) { }} <li class="list">
  255. <span>{{=it[i].title}}</span>
  256. <span>{{=it[i].val}}</span>
  257. <span>{{=it[i].unit}}</span>
  258. </li>
  259. {{ } }}
  260. </ul>
  261. </script>
  262. <script type="text/template" id="fan2Template">
  263. <ul class="head">
  264. <li>参数名称</li>
  265. <li>数值</li>
  266. <li>单位</li>
  267. </ul>
  268. <ul class="items">
  269. {{ for (var i = 0;i
  270. <it.length;i++) { }} <li class="list">
  271. <span>{{=it[i].title}}</span>
  272. <span>{{=it[i].val}}</span>
  273. <span>{{=it[i].unit}}</span>
  274. </li>
  275. {{ } }}
  276. </ul>
  277. </script>
  278. <script type="text/template" id="equipmentTemperature">
  279. <p class="title">设备温度趋势</p>
  280. <canvas id="equipmentTemperatureOne" style="width: 100%;height: 230px"></canvas>
  281. </script>
  282. <script type="text/template" id="equipmentVibration">
  283. <p class="title">设备震动趋势</p>
  284. <canvas id="equipmentVibrationOne" style="width: 100%;height: 230px"></canvas>
  285. </script>
  286. <script type="text/template" id="equipmentTemperatureSecond">
  287. <p class="title">设备温度趋势</p>
  288. <canvas id="equipmentTemperatureTwo" style="width: 100%;height: 230px"></canvas>
  289. </script>
  290. <script type="text/template" id="equipmentVibrationSecond">
  291. <p class="title">设备震动趋势</p>
  292. <canvas id="equipmentVibrationTwo" style="width: 100%;height: 230px"></canvas>
  293. </script>
  294. <script type="text/javascript" src="../../script/api.js"></script>
  295. <script src="../../script/f2.js"></script>
  296. <script type="text/javascript" src="../../script/doT.min.js"></script>
  297. <script type="text/javascript" src="../../script/config.js"></script>
  298. <script type="text/javascript" src="../../script/f2.js"></script>
  299. <script type="text/javascript">
  300. var header = ''
  301. // var toast = new auiToast()
  302. apiready = function() {
  303. setInterval(function() {
  304. $api.html($api.dom('.time-box'), getNowFormatDate());
  305. }, 1000)
  306. var info = $api.getStorage('data'),
  307. token = JSON.parse(info).data.access_token;
  308. headers = {
  309. "Authorization": "Bearer " + token
  310. };
  311. fanData(1)
  312. };
  313. // 参数依次为 容器的id名(containerId) script的模版id名(templateId)后台的返回数据(queryData)
  314. //canvas容器的id名() axisName是后台返回字段time (axisName) 最后一个参数是单位名称 (iValueName)例如 mm/s ...
  315. function f2ChartItem(containerId, templateId, queryData, canvasId, data, axisName, iValueName) {
  316. $apis.html(containerId, templateId, queryData);
  317. const chart = new F2.Chart({
  318. id: canvasId,
  319. pixelRatio: window.devicePixelRatio
  320. });
  321. chart.source(data, {
  322. time: {
  323. tickCount: 5
  324. },
  325. value: {
  326. tickCount: 8,
  327. min: 30,
  328. max: 100,
  329. formatter: function formatter(val) {
  330. // console.log(JSON.stringify(val));
  331. return val + iValueName;
  332. }
  333. }
  334. });
  335. chart.axis('value', {
  336. label: function label(text, index, total) {
  337. const textCfg = {};
  338. if (index === 0) {
  339. textCfg.textBaseline = 'bottom';
  340. } else if (index === total - 1) {
  341. textCfg.textBaseline = 'top';
  342. }
  343. return textCfg;
  344. }
  345. });
  346. chart.axis(axisName, {
  347. line: null,
  348. tickLine: {
  349. top: false
  350. },
  351. label: {
  352. offset: [-10, 10]
  353. }
  354. });
  355. chart.legend({
  356. position: 'top',
  357. offsetY: 15
  358. });
  359. chart.line()
  360. .position('time*value')
  361. .color('type')
  362. .shape('type', function(type) {
  363. if (type != '') {
  364. return 'line';
  365. }
  366. });
  367. chart.render();
  368. }
  369. // 1# 2#设备
  370. function fanData(type) {
  371. //
  372. $http.fnReuestDataNologing(UrlRouter.realList, header, 'get', '', function(ret, err) {
  373. // console.log(JSON.stringify(ret));
  374. // console.log(JSON.stringify(err));
  375. if (ret.code === 0) {
  376. // toast.hide();
  377. if (type == 1) {
  378. $apis.html(tab1_content, '#fanTemplate', ret.data.real['1#设备'].data);
  379. $api.css($api.dom('#equipment_one'), 'display: block');
  380. $api.css($api.dom('#equipment_two'), 'display: none');
  381. let temperatureData = ret.data.temperature['1#设备'].data;
  382. let equipmentVibrationData = ret.data.shock['1#设备'].data;
  383. console.log(JSON.stringify(temperatureData));
  384. // 设备1#温度趋势
  385. f2ChartItem(equipment_I_temperature, '#equipmentTemperature', temperatureData, 'equipmentTemperatureOne', temperatureData, 'time', '℃');
  386. // 设备1#震动趋势
  387. f2ChartItem(equipment_I_vibration, '#equipmentVibration', equipmentVibrationData, 'equipmentVibrationOne', equipmentVibrationData, 'time', 'mm/s');
  388. } else {
  389. $api.css($api.dom('#equipment_one'), 'display: none');
  390. $api.css($api.dom('#equipment_two'), 'display: block');
  391. $apis.html(tab2_content, '#fan2Template', ret.data.real['2#设备'].data);
  392. let temperatureDataTwo = ret.data.temperature['2#设备'].data;
  393. let equipmentVibrationDataTwo = ret.data.shock['2#设备'].data;
  394. //设备2#温度趋势
  395. f2ChartItem(equipment_II_temperature, '#equipmentTemperatureSecond', temperatureDataTwo, 'equipmentTemperatureTwo', temperatureDataTwo, 'time', '℃');
  396. f2ChartItem(equipment_II_vibration, '#equipmentVibrationSecond', equipmentVibrationDataTwo, 'equipmentVibrationTwo', equipmentVibrationDataTwo, 'time', 'mm/s');
  397. }
  398. }
  399. })
  400. }
  401. // tab切换
  402. var myclick = function(v) {
  403. var llis = document.getElementsByTagName("li");
  404. for (var i = 0; i < llis.length; i++) {
  405. var lli = llis[i];
  406. if (lli == document.getElementById("tab" + v)) {
  407. lli.style['border-bottom'] = '2px solid #009FE8';
  408. lli.style.color = "#3498DB";
  409. lli.style.fontWeight = "bold";
  410. } else {
  411. lli.style['border-bottom'] = "none";
  412. lli.style.color = "#273438";
  413. lli.style.fontWeight = "normal";
  414. }
  415. }
  416. var divs = document.getElementsByClassName("tab_css");
  417. for (var i = 0; i < divs.length; i++) {
  418. var divv = divs[i];
  419. if (divv == document.getElementById("tab" + v + "_content")) {
  420. divv.style.display = "block";
  421. fanData(v)
  422. } else {
  423. fanData(v)
  424. divv.style.display = "none";
  425. }
  426. }
  427. }
  428. </script>
  429. </html>