showHardware.js 2.3 KB

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