showHardware.js 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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. key: 'id',
  31. width: '100px',
  32. align: 'center',
  33. text: '查看',
  34. template: function(username){
  35. var titleNode = document.createElement('div');
  36. // titleNode.attr('href', `https://www.lovejavascript.com/#!zone/blog/content.html?id=${rowObject.id}`);
  37. titleNode.setAttribute('title', username);
  38. titleNode.classList.add('plugin-action');
  39. titleNode.innerHTML = `<img src="./images/jiantou2.png" alt="">`;
  40. return titleNode
  41. }
  42. },
  43. ],
  44. });
  45. // 阻止冒泡
  46. $('.hardware-list').on('click keydown keyup keypress',function (event) {
  47. event.stopPropagation();
  48. })
  49. //点击前往查看
  50. $(grtable).on('click', '.plugin-action', function(e) {
  51. const row = GridManager.getRowData(gName, e.currentTarget.parentElement.parentElement);
  52. console.log(row);
  53. });
  54. let getList = function(params) {
  55. return new Promise((resolve, reject) => {
  56. $.ajax({
  57. method: 'GET',
  58. headers: {
  59. 'Content-Type': 'application/json'
  60. },
  61. dataType: 'json',
  62. contentType: 'application/json',
  63. url: url + '/api/device/list',
  64. success: function(data) {
  65. console.log(data);
  66. if (data.code === 0) {
  67. resolve({
  68. ...data,
  69. totals:data.data.length
  70. });
  71. }
  72. else {
  73. reject(data);
  74. }
  75. }
  76. })
  77. })
  78. };
  79. })