showHardware.js 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361
  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.id] &&
  61. window.hardwareHotList[row.id].showPannel({ focus: true });
  62. });
  63. $(".hard-header").click(function () {
  64. $(".hard-body").toggle();
  65. }
  66. )
  67. $("#fengxiang").click(function () {
  68. $(".air-con").hide();
  69. $(".oper-con").fadeToggle();
  70. }
  71. )
  72. $("#moshi").click(function () {
  73. $(".oper-con").hide();
  74. $(".air-con").fadeToggle();
  75. }
  76. )
  77. let getList = function (params) {
  78. return new Promise((resolve, reject) => {
  79. $.ajax({
  80. method: "POST",
  81. data : JSON.stringify({
  82. "devTypeId": "",
  83. "name": "",
  84. "pageNum": params.cPage,
  85. "pageSize": params.pSize,
  86. "searchKey": "",
  87. "userId": "77547f7af360c5d8e14932866b844d53"
  88. }),
  89. headers: {
  90. "Content-Type": "application/json",
  91. },
  92. dataType: "json",
  93. contentType: "application/json",
  94. url: url + "/api/device/listPage",
  95. success: function (data) {
  96. if (data.code == 0) {
  97. resolve({
  98. data:data.data.records,
  99. totals: data.data.total,
  100. });
  101. } else {
  102. reject(data);
  103. }
  104. },
  105. });
  106. });
  107. };
  108. window.changeDeviceStatus = function (item, paramCode, paramValue, success, fail) {//设置设备
  109. console.log(item);
  110. $(".waiting").addClass('showloading')
  111. let tmp = item.infoAttribute.hardware
  112. $.ajax({
  113. method: "GET",
  114. headers: {
  115. "Content-Type": "application/json",
  116. },
  117. dataType: "json",
  118. contentType: "application/json",
  119. url: url + `/api/device/control/${tmp.id}/${paramCode}/${paramValue}/03`,
  120. success: function (data) {
  121. console.log(data.msg)
  122. $(".waiting").romoveClass('showloading')
  123. if (data.code === 0) {
  124. success && success()
  125. } else {
  126. fail && fail()
  127. }
  128. },error:function(){
  129. $(".waiting").romoveClass('showloading')
  130. fail && fail()
  131. }
  132. });
  133. }
  134. window.loadTemperature = function (params={}) {
  135. let {id="temperature",val} = params
  136. //加载温度计
  137. var chartDom = document.getElementById(id);
  138. var myChart = echarts.init(chartDom);
  139. let option = {
  140. series: [
  141. {
  142. name: "Indicator",
  143. type: "gauge",
  144. data: [{
  145. value: val,
  146. name:'温度',
  147. itemStyle:{
  148. color: "#23EACF",
  149. fontSize:14
  150. },
  151. detail: {
  152. formatter: "{value}℃",
  153. color: "#23EACF",
  154. fontSize:24,
  155. offsetCenter: ['0%', '28%'],
  156. },
  157. title: {
  158. offsetCenter: ['0%', '80%'],
  159. color: "#fff",
  160. fontSize:20
  161. }
  162. }],
  163. radius: "100%",
  164. startAngle: 240,
  165. endAngle: -60,
  166. axisLine: {
  167. show: false
  168. },
  169. axisTick:{
  170. show: true,
  171. length:12,
  172. lineStyle:{
  173. color:'#339ED3'
  174. }
  175. },
  176. splitLine: {
  177. show: true,
  178. length:15,
  179. lineStyle:{
  180. color: "rgba(255, 255, 255, 1)",
  181. }
  182. },
  183. axisLabel: {
  184. color: "#23EACF"
  185. },
  186. pointer: {
  187. show: true,
  188. itemStyle:{
  189. color: "#23EACF"
  190. },
  191. width: 4.5,
  192. length: "46%"
  193. }
  194. },
  195. {
  196. name: "Indicator1",
  197. type: "gauge",
  198. data: [{
  199. value: val,
  200. detail:{
  201. show:false
  202. }
  203. }],
  204. radius: "50%",
  205. startAngle: 240,
  206. endAngle: -60,
  207. axisLine: {
  208. show: true,
  209. lineStyle:{
  210. width:5
  211. }
  212. },
  213. progress: {
  214. show: true,
  215. width:5,
  216. itemStyle:{
  217. color: "#23EACF"
  218. }
  219. },
  220. axisTick:{
  221. show: false,
  222. },
  223. splitLine: {
  224. show: false,
  225. },
  226. axisLabel: {
  227. show: false,
  228. },
  229. pointer: {
  230. show: false,
  231. }
  232. }
  233. ]
  234. }
  235. option && myChart.setOption(option, true);
  236. }
  237. window.loadAirConditioner = function (params={}) {
  238. let {id="air-conditioner",val,type} = params
  239. //加载温度计
  240. var chartDom = document.getElementById(id);
  241. var myChart = echarts.init(chartDom);
  242. let option = {
  243. series: [
  244. {
  245. name: "Indicator",
  246. type: "gauge",
  247. data: [{
  248. value: val,
  249. name:type,
  250. itemStyle:{
  251. color: "#23EACF",
  252. fontSize:14
  253. },
  254. detail: {
  255. offsetCenter: ['0%', '0'],
  256. formatter: "{value}℃",
  257. color: "#fff",
  258. fontSize:22
  259. },
  260. title: {
  261. offsetCenter: ['0%', '26%'],
  262. color: "#fff",
  263. fontSize:16
  264. }
  265. }],
  266. radius: "100%",
  267. startAngle: 220,
  268. endAngle: -40,
  269. progress: {
  270. show: true,
  271. roundCap:true,
  272. itemStyle:{
  273. color: "#23EACF"
  274. }
  275. },
  276. axisLine: {
  277. show: true,
  278. roundCap:true,
  279. lineStyle:{
  280. color: [[1, '#ffffff']]
  281. }
  282. },
  283. axisTick:{
  284. show: false
  285. },
  286. splitLine: {
  287. show: false
  288. },
  289. axisLabel: {
  290. show: false,
  291. },
  292. pointer: {
  293. show: false,
  294. }
  295. }
  296. ]
  297. }
  298. option && myChart.setOption(option, true);
  299. }
  300. window.loadMonitor = function (params={}) {
  301. let {id,url} = params
  302. console.log(id,url);
  303. var video = document.getElementById(id);
  304. if (Hls.isSupported()) {
  305. var hls = new Hls();
  306. hls.loadSource(url||'http://14.215.216.123:18080/rtp/00A153DF/hls.m3u8');
  307. hls.attachMedia(video);
  308. hls.on(Hls.Events.MEDIA_ATTACHED, function () {
  309. video.play();
  310. });
  311. }
  312. // hls.js is not supported on platforms that do not have Media Source Extensions (MSE) enabled.
  313. // 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.
  314. // This is using the built-in support of the plain video element, without using hls.js.
  315. else if (video.canPlayType('application/vnd.apple.mpegurl')) {
  316. video.src = url||'http://14.215.216.123:18080/rtp/00A153DF/hls.m3u8';
  317. video.addEventListener('canplay', function () {
  318. video.play();
  319. });
  320. }
  321. }
  322. /*loadMonitor({
  323. id:"monitor",
  324. url:'http://14.215.216.123:18080/rtp/00A153DF/hls.m3u8'
  325. })
  326. loadAirConditioner({
  327. id:"air-conditioner",
  328. val:50,
  329. type:'冷风'
  330. }) */
  331. loadAirConditioner({
  332. id:"air-conditioner",
  333. val:50,
  334. type:'冷风'
  335. })
  336. });