showHardware.js 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  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. });