selectHardware.js 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  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. checkboxConfig: {
  14. useRowCheck: true,
  15. useRadio: true,
  16. },
  17. query: { pluginId: 1 },
  18. supportAjaxPage: true,
  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. key: "id",
  34. text: "id",
  35. }
  36. ],
  37. });
  38. // 确认事件
  39. $('#gcommit').click(function () {
  40. let item = Array.from(GridManager.getCheckedTr(gName))
  41. if (item.length<=0) {
  42. alert('请选择设备')
  43. return
  44. }
  45. window.editTool.hotpoint.addHardware(item[0])
  46. $('.jsGrid-body').hide()
  47. //alert(item)
  48. console.log(GridManager.getCheckedTr(gName));
  49. })
  50. // 取消事件
  51. $('#gcancel,.gr-header>img').click(function () {
  52. $('.jsGrid-body').hide()
  53. console.log(GridManager.getCheckedTr(gName));
  54. })
  55. //搜索事件
  56. $('.gr-header > .search').click(function () {
  57. var _query = {
  58. title: document.querySelector('[name="title"]').value,
  59. type: document.querySelector('[name="type"]').value,
  60. content: document.querySelector('[name="content"]').value,
  61. cPage: 1
  62. };
  63. grtable.GM('setQuery', _query, function(){
  64. console.log('setQuery执行成功');
  65. });
  66. })
  67. //设备添加
  68. $('#grAdd').click(function () {
  69. $('.jsGrid-body').show()
  70. })
  71. //设备删除
  72. $('#grDel').click(function () {
  73. })
  74. // 阻止冒泡
  75. $('.jsGrid-con').on('click keydown keyup keypress',function (event) {
  76. event.stopPropagation();
  77. })
  78. let getList = function(params) {
  79. return new Promise((resolve, reject) => {
  80. $.ajax({
  81. method: 'GET',
  82. headers: {
  83. 'Content-Type': 'application/json'
  84. },
  85. dataType: 'json',
  86. contentType: 'application/json',
  87. url: url + 'api/device/list',
  88. success: function(data) {
  89. console.log(data);
  90. if (data.code === 0) {
  91. resolve({
  92. ...data,
  93. totals:data.data.length
  94. });
  95. }
  96. else {
  97. reject(data);
  98. }
  99. }
  100. })
  101. })
  102. };
  103. })