showHardware.js 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  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": ""
  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. //记载温度计
  122. var chartDom = document.getElementById('temperature');
  123. var myChart = echarts.init(chartDom);
  124. option = {
  125. series: [
  126. {
  127. name: "Indicator",
  128. type: "gauge",
  129. data: [{
  130. value: 50,
  131. name:'温度',
  132. itemStyle:{
  133. color: "#23EACF",
  134. fontSize:14
  135. },
  136. detail: {
  137. formatter: "{value}℃",
  138. color: "#23EACF",
  139. fontSize:24,
  140. offsetCenter: ['0%', '28%'],
  141. },
  142. title: {
  143. offsetCenter: ['0%', '80%'],
  144. color: "#fff",
  145. fontSize:20
  146. }
  147. }],
  148. radius: "100%",
  149. startAngle: 240,
  150. endAngle: -60,
  151. axisLine: {
  152. show: false
  153. },
  154. axisTick:{
  155. show: true,
  156. length:12,
  157. lineStyle:{
  158. color:'#339ED3'
  159. }
  160. },
  161. splitLine: {
  162. show: true,
  163. length:15,
  164. lineStyle:{
  165. color: "rgba(255, 255, 255, 1)",
  166. }
  167. },
  168. axisLabel: {
  169. color: "#23EACF"
  170. },
  171. pointer: {
  172. show: true,
  173. itemStyle:{
  174. color: "#23EACF"
  175. },
  176. width: 4.5,
  177. length: "46%"
  178. }
  179. },
  180. {
  181. name: "Indicator1",
  182. type: "gauge",
  183. data: [{
  184. value: 50,
  185. detail:{
  186. show:false
  187. }
  188. }],
  189. radius: "50%",
  190. startAngle: 240,
  191. endAngle: -60,
  192. axisLine: {
  193. show: true,
  194. lineStyle:{
  195. width:5
  196. }
  197. },
  198. progress: {
  199. show: true,
  200. width:5,
  201. itemStyle:{
  202. color: "#23EACF"
  203. }
  204. },
  205. axisTick:{
  206. show: false,
  207. },
  208. splitLine: {
  209. show: false,
  210. },
  211. axisLabel: {
  212. show: false,
  213. },
  214. pointer: {
  215. show: false,
  216. }
  217. }
  218. ]
  219. }
  220. option && myChart.setOption(option, true);
  221. });