hlist.html 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. <div class="row">
  2. <div class="col-md-12">
  3. <div class="tile">
  4. <div class="tile-body">
  5. <table class="table table-hover table-bordered" id="sampleTable">
  6. <thead>
  7. <tr>
  8. <th>id</th>
  9. <th>客户端id</th>
  10. <th>备注</th>
  11. <th>host</th>
  12. <th>location</th>
  13. <th>内网目标</th>
  14. <th>host改写</th>
  15. <th>压缩方式</th>
  16. <th>加密</th>
  17. <th>用户名</th>
  18. <th>密码</th>
  19. <th>出口流量</th>
  20. <th>入口流量</th>
  21. <th>操作</th>
  22. </tr>
  23. </thead>
  24. <tbody>
  25. </tbody>
  26. </table>
  27. </div>
  28. </div>
  29. </div>
  30. </div>
  31. </main>
  32. <script type="text/javascript">
  33. function del(id) {
  34. if (confirm("确定要删除数据吗?")) {
  35. $.ajax({
  36. type: "POST",
  37. url: "/index/delhost",
  38. data: {"id": id},
  39. success: function (res) {
  40. alert(res.msg)
  41. if (res.status) {
  42. document.location.reload();
  43. }
  44. }
  45. })
  46. }
  47. }
  48. function add() {
  49. window.location.href = "/index/addhost?vkey={{.task_id}}&client_id={{.client_id}}"
  50. }
  51. function edit(id) {
  52. window.location.href = "/index/edithost?id=" + id
  53. }
  54. $(document).ready(function () {
  55. var table = $('#sampleTable').DataTable({
  56. responsive: {
  57. details: {
  58. display: $.fn.dataTable.Responsive.display.childRowImmediate
  59. }
  60. },
  61. dom: 'Bfrtip',
  62. processing: true,
  63. serverSide: true,
  64. autoWidth: false,
  65. ordering: false,
  66. ajax: {
  67. url: window.location,
  68. type: 'POST'
  69. },
  70. dom: '<"top"fl><"toolbar">rt<"bottom"ip><"clear">',
  71. columns: [ //这个是显示到界面上的个数据 格式为 {data:'显示的字段名'}
  72. {data: 'Id'},
  73. {data: 'Remark'},
  74. {data: 'Remark'},
  75. {data: 'Host'},
  76. {data: 'Location'},
  77. {data: 'Target'},
  78. {data: 'HostChange'},
  79. {data: 'HostChange'},
  80. {data: 'HostChange'},
  81. {data: 'HostChange'},
  82. {data: 'HostChange'},
  83. {data: 'HostChange'},
  84. {data: 'HostChange'},
  85. {data: 'Target'},
  86. ],
  87. bFilter: false,
  88. columnDefs: [{
  89. targets: -1,
  90. render: function (data, type, row, meta) {
  91. return '<div class="btn-group" role="group" aria-label="..."> ' +
  92. '<button onclick="del(\'' + row.Id + '\')" type="button" class="btn btn-danger btn-sm">删除</button>' +
  93. '<button onclick="edit(\'' + row.Id + '\')" type="button" class="btn btn-primary btn-sm">编辑查看</button> '
  94. + ' </div>'
  95. }
  96. },
  97. {
  98. targets: 1,
  99. render: function (data, type, row, meta) {
  100. return row.Client.Id
  101. }
  102. },
  103. {
  104. targets: -2,
  105. render: function (data, type, row, meta) {
  106. return change(row.Flow.InletFlow)
  107. }
  108. },
  109. {
  110. targets: -3,
  111. render: function (data, type, row, meta) {
  112. return change(row.Flow.ExportFlow)
  113. }
  114. },
  115. {
  116. targets: -4,
  117. render: function (data, type, row, meta) {
  118. return row.Client.Cnf.P
  119. }
  120. },
  121. {
  122. targets: -5,
  123. render: function (data, type, row, meta) {
  124. return row.Client.Cnf.U
  125. }
  126. }
  127. ,
  128. {
  129. targets: -6,
  130. render: function (data, type, row, meta) {
  131. if (row.Client.Cnf.Crypt == "0") {
  132. return "不加密"
  133. } else {
  134. return "加密"
  135. }
  136. }
  137. }
  138. ,
  139. {
  140. targets: -7,
  141. render: function (data, type, row, meta) {
  142. return row.Client.Cnf.Compress
  143. }
  144. }
  145. ],
  146. buttons: []
  147. });
  148. $("#sampleTable_length").html('<button class="btn btn-primary" onclick="add()" type="button">新增</button>')
  149. })
  150. ;
  151. </script>