hlist.html 5.1 KB

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