showHardware.js 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337
  1. $(function () {
  2. let url = ``;
  3. // let url = `http://192.168.0.135:8004`;
  4. let gName = "Gridtable";
  5. let grtable = document.querySelector("#gridtb");
  6. grtable.GM({
  7. gridManagerName: gName,
  8. height: "300px",
  9. ajaxData: function (setting) {
  10. console.log(setting.pageData,setting.sortData);
  11. // 传入分页及排序的配置项
  12. return getList(Object.assign({}, setting.pageData, setting.sortData));
  13. },
  14. ajaxType: "POST",
  15. supportCheckbox: false,
  16. supportAjaxPage: true,
  17. useNoTotalsMode: true,
  18. pageSize:10,
  19. columnData: [
  20. {
  21. key: "code",
  22. text: "硬件编号",
  23. },
  24. {
  25. key: "devTypeName",
  26. text: "硬件状态",
  27. },
  28. {
  29. key: "name",
  30. text: "热点名字",
  31. },
  32. ,
  33. {
  34. key: "id",
  35. width: "100px",
  36. align: "center",
  37. text: "查看",
  38. template: function (username) {
  39. var titleNode = document.createElement("div");
  40. // titleNode.attr('href', `https://www.lovejavascript.com/#!zone/blog/content.html?id=${rowObject.id}`);
  41. titleNode.setAttribute("title", username);
  42. titleNode.classList.add("plugin-action");
  43. titleNode.innerHTML = `<img src="./images/jiantou2.png" alt="">`;
  44. return titleNode;
  45. },
  46. },
  47. ],
  48. });
  49. // 阻止冒泡
  50. $(".hardware-list").on("click keydown keyup keypress", function (event) {
  51. event.stopPropagation();
  52. });
  53. //点击前往查看
  54. $(grtable).on("click", ".plugin-action", function (e) {
  55. const row = GridManager.getRowData(
  56. gName,
  57. e.currentTarget.parentElement.parentElement
  58. );
  59. console.log(row);
  60. window.hardwareHotList[row.code] &&
  61. window.hardwareHotList[row.code].showPannel({ focus: true });
  62. });
  63. $(".hard-header").click(function () {
  64. $(".hard-body").toggle();
  65. }
  66. )
  67. let getList = function (params) {
  68. return new Promise((resolve, reject) => {
  69. $.ajax({
  70. method: "POST",
  71. data : JSON.stringify({
  72. "devTypeId": "",
  73. "name": "",
  74. "pageNum": params.cPage,
  75. "pageSize": params.pSize,
  76. "searchKey": "",
  77. "userId": "77547f7af360c5d8e14932866b844d53"
  78. }),
  79. headers: {
  80. "Content-Type": "application/json",
  81. },
  82. dataType: "json",
  83. contentType: "application/json",
  84. url: url + "/api/device/listPage",
  85. success: function (data) {
  86. if (data.code == 0) {
  87. resolve({
  88. data:data.data.records,
  89. totals: data.data.total,
  90. });
  91. } else {
  92. reject(data);
  93. }
  94. },
  95. });
  96. });
  97. };
  98. window.changeDeviceStatus = function (item) {
  99. console.log(item);
  100. let tmp = item.infoAttribute.hardware
  101. $.ajax({
  102. method: "GET",
  103. headers: {
  104. "Content-Type": "application/json",
  105. },
  106. dataType: "json",
  107. contentType: "application/json",
  108. url: url + `/api/device/control/${tmp.id}/${tmp.deviceCode}/${paramValue}/03`,
  109. success: function (data) {
  110. if (data.code === 0) {
  111. resolve({
  112. ...data,
  113. totals: data.data.length,
  114. });
  115. } else {
  116. reject(data);
  117. }
  118. },
  119. });
  120. }
  121. window.loadTemperature = function (params={}) {
  122. let {id="temperature",val} = params
  123. //加载温度计
  124. var chartDom = document.getElementById(id);
  125. var myChart = echarts.init(chartDom);
  126. let option = {
  127. series: [
  128. {
  129. name: "Indicator",
  130. type: "gauge",
  131. data: [{
  132. value: val,
  133. name:'温度',
  134. itemStyle:{
  135. color: "#23EACF",
  136. fontSize:14
  137. },
  138. detail: {
  139. formatter: "{value}℃",
  140. color: "#23EACF",
  141. fontSize:24,
  142. offsetCenter: ['0%', '28%'],
  143. },
  144. title: {
  145. offsetCenter: ['0%', '80%'],
  146. color: "#fff",
  147. fontSize:20
  148. }
  149. }],
  150. radius: "100%",
  151. startAngle: 240,
  152. endAngle: -60,
  153. axisLine: {
  154. show: false
  155. },
  156. axisTick:{
  157. show: true,
  158. length:12,
  159. lineStyle:{
  160. color:'#339ED3'
  161. }
  162. },
  163. splitLine: {
  164. show: true,
  165. length:15,
  166. lineStyle:{
  167. color: "rgba(255, 255, 255, 1)",
  168. }
  169. },
  170. axisLabel: {
  171. color: "#23EACF"
  172. },
  173. pointer: {
  174. show: true,
  175. itemStyle:{
  176. color: "#23EACF"
  177. },
  178. width: 4.5,
  179. length: "46%"
  180. }
  181. },
  182. {
  183. name: "Indicator1",
  184. type: "gauge",
  185. data: [{
  186. value: val,
  187. detail:{
  188. show:false
  189. }
  190. }],
  191. radius: "50%",
  192. startAngle: 240,
  193. endAngle: -60,
  194. axisLine: {
  195. show: true,
  196. lineStyle:{
  197. width:5
  198. }
  199. },
  200. progress: {
  201. show: true,
  202. width:5,
  203. itemStyle:{
  204. color: "#23EACF"
  205. }
  206. },
  207. axisTick:{
  208. show: false,
  209. },
  210. splitLine: {
  211. show: false,
  212. },
  213. axisLabel: {
  214. show: false,
  215. },
  216. pointer: {
  217. show: false,
  218. }
  219. }
  220. ]
  221. }
  222. option && myChart.setOption(option, true);
  223. }
  224. window.loadAirConditioner = function (params={}) {
  225. let {id="air-conditioner",val,type} = params
  226. //加载温度计
  227. var chartDom = document.getElementById(id);
  228. var myChart = echarts.init(chartDom);
  229. let option = {
  230. series: [
  231. {
  232. name: "Indicator",
  233. type: "gauge",
  234. data: [{
  235. value: val,
  236. name:type,
  237. itemStyle:{
  238. color: "#23EACF",
  239. fontSize:14
  240. },
  241. detail: {
  242. offsetCenter: ['0%', '0'],
  243. formatter: "{value}℃",
  244. color: "#fff",
  245. fontSize:22
  246. },
  247. title: {
  248. offsetCenter: ['0%', '26%'],
  249. color: "#fff",
  250. fontSize:16
  251. }
  252. }],
  253. radius: "100%",
  254. startAngle: 220,
  255. endAngle: -40,
  256. progress: {
  257. show: true,
  258. roundCap:true,
  259. itemStyle:{
  260. color: "#23EACF"
  261. }
  262. },
  263. axisLine: {
  264. show: true,
  265. roundCap:true,
  266. lineStyle:{
  267. color: [[1, '#ffffff']]
  268. }
  269. },
  270. axisTick:{
  271. show: false
  272. },
  273. splitLine: {
  274. show: false
  275. },
  276. axisLabel: {
  277. show: false,
  278. },
  279. pointer: {
  280. show: false,
  281. }
  282. }
  283. ]
  284. }
  285. option && myChart.setOption(option, true);
  286. }
  287. window.loadMonitor = function (params={}) {
  288. let {id,url} = params
  289. console.log(id,url);
  290. var video = document.getElementById(id);
  291. if (Hls.isSupported()) {
  292. var hls = new Hls();
  293. hls.loadSource(url||'http://14.215.216.123:18080/rtp/00A153DF/hls.m3u8');
  294. hls.attachMedia(video);
  295. hls.on(Hls.Events.MEDIA_ATTACHED, function () {
  296. video.play();
  297. });
  298. }
  299. // hls.js is not supported on platforms that do not have Media Source Extensions (MSE) enabled.
  300. // When the browser has built-in HLS support (check using `canPlayType`), we can provide an HLS manifest (i.e. .m3u8 URL) directly to the video element throught the `src` property.
  301. // This is using the built-in support of the plain video element, without using hls.js.
  302. else if (video.canPlayType('application/vnd.apple.mpegurl')) {
  303. video.src = url||'http://14.215.216.123:18080/rtp/00A153DF/hls.m3u8';
  304. video.addEventListener('canplay', function () {
  305. video.play();
  306. });
  307. }
  308. }
  309. loadMonitor({
  310. id:"monitor",
  311. url:'http://14.215.216.123:18080/rtp/00A153DF/hls.m3u8'
  312. })
  313. loadAirConditioner({
  314. id:"air-conditioner",
  315. val:50,
  316. type:'冷风'
  317. })
  318. });