showHardware.js 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. $(function () {
  2. let url = ``;
  3. // let url = `http://8.135.106.227: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. // 传入分页及排序的配置项
  11. return getList(Object.assign({}, setting.pageData, setting.sortData));
  12. },
  13. ajaxType: "POST",
  14. supportCheckbox: false,
  15. supportAjaxPage: true,
  16. useNoTotalsMode: true,
  17. columnData: [
  18. {
  19. key: "code",
  20. text: "硬件编号",
  21. },
  22. {
  23. key: "devTypeName",
  24. text: "硬件状态",
  25. },
  26. {
  27. key: "name",
  28. text: "热点名字",
  29. },
  30. ,
  31. {
  32. key: "id",
  33. width: "100px",
  34. align: "center",
  35. text: "查看",
  36. template: function (username) {
  37. var titleNode = document.createElement("div");
  38. // titleNode.attr('href', `https://www.lovejavascript.com/#!zone/blog/content.html?id=${rowObject.id}`);
  39. titleNode.setAttribute("title", username);
  40. titleNode.classList.add("plugin-action");
  41. titleNode.innerHTML = `<img src="./images/jiantou2.png" alt="">`;
  42. return titleNode;
  43. },
  44. },
  45. ],
  46. });
  47. // 阻止冒泡
  48. $(".hardware-list").on("click keydown keyup keypress", function (event) {
  49. event.stopPropagation();
  50. });
  51. //点击前往查看
  52. $(grtable).on("click", ".plugin-action", function (e) {
  53. const row = GridManager.getRowData(
  54. gName,
  55. e.currentTarget.parentElement.parentElement
  56. );
  57. console.log(row);
  58. window.hardwareHotList[row.code] &&
  59. window.hardwareHotList[row.code].showPannel({ focus: true });
  60. });
  61. $(".hard-header").click(function () {
  62. $(".hard-body").toggle();
  63. }
  64. )
  65. let getList = function (params) {
  66. return new Promise((resolve, reject) => {
  67. $.ajax({
  68. method: "GET",
  69. headers: {
  70. "Content-Type": "application/json",
  71. },
  72. dataType: "json",
  73. contentType: "application/json",
  74. url: url + "/api/device/list",
  75. success: function (data) {
  76. if (data.code === 0) {
  77. resolve({
  78. ...data,
  79. totals: data.data.length,
  80. });
  81. } else {
  82. reject(data);
  83. }
  84. },
  85. });
  86. });
  87. };
  88. window.changeDeviceStatus = function (item) {
  89. console.log(item);
  90. // $.ajax({
  91. // method: "GET",
  92. // headers: {
  93. // "Content-Type": "application/json",
  94. // },
  95. // dataType: "json",
  96. // contentType: "application/json",
  97. // url: url + "/api/device/list",
  98. // success: function (data) {
  99. // if (data.code === 0) {
  100. // resolve({
  101. // ...data,
  102. // totals: data.data.length,
  103. // });
  104. // } else {
  105. // reject(data);
  106. // }
  107. // },
  108. // });
  109. }
  110. });