hlist.html 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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>备注</th>
  10. <th>host</th>
  11. <th>内网目标</th>
  12. <th>host改写</th>
  13. <th>出口流量</th>
  14. <th>入口流量</th>
  15. <th>操作</th>
  16. </tr>
  17. </thead>
  18. <tbody>
  19. </tbody>
  20. </table>
  21. </div>
  22. </div>
  23. </div>
  24. </div>
  25. </main>
  26. <script type="text/javascript">
  27. function del(host) {
  28. if (confirm("确定要删除数据吗?")) {
  29. $.ajax({
  30. type: "POST",
  31. url: "/index/delhost",
  32. data: {"host": host},
  33. success: function (res) {
  34. alert(res.msg)
  35. if (res.status) {
  36. document.location.reload();
  37. }
  38. }
  39. })
  40. }
  41. }
  42. function add() {
  43. window.location.href = "/index/addhost?vkey={{.task_id}}&client_id={{.client_id}}"
  44. }
  45. function edit(host) {
  46. window.location.href = "/index/edithost?host=" + host
  47. }
  48. $(document).ready(function () {
  49. var table = $('#sampleTable').DataTable({
  50. responsive: {
  51. details: {
  52. display: $.fn.dataTable.Responsive.display.childRowImmediate
  53. }
  54. },
  55. dom: 'Bfrtip',
  56. processing: true,
  57. serverSide: true,
  58. autoWidth: false,
  59. ordering: false,
  60. ajax: {
  61. url: window.location,
  62. type: 'POST'
  63. },
  64. dom: '<"top"fl><"toolbar">rt<"bottom"ip><"clear">',
  65. columns: [ //这个是显示到界面上的个数据 格式为 {data:'显示的字段名'}
  66. {data: 'ClientId'},
  67. {data: 'Remark'},
  68. {data: 'Host'},
  69. {data: 'Target'},
  70. {data: 'HostChange'},
  71. {data: 'HostChange'},
  72. {data: 'HostChange'},
  73. {data: 'Target'},
  74. ],
  75. bFilter: false,
  76. columnDefs: [{
  77. targets: -1,
  78. render: function (data, type, row, meta) {
  79. return '<div class="btn-group" role="group" aria-label="..."> ' +
  80. '<button onclick="del(\'' + row.Host + '\')" type="button" class="btn btn-danger btn-sm">删除</button>' +
  81. '<button onclick="edit(\'' + row.Host + '\')" type="button" class="btn btn-primary btn-sm">编辑查看</button> '
  82. + ' </div>'
  83. }
  84. },
  85. {
  86. targets: -2,
  87. render: function (data, type, row, meta) {
  88. return change(row.Flow.InletFlow)
  89. }
  90. },
  91. {
  92. targets: -3,
  93. render: function (data, type, row, meta) {
  94. return change(row.Flow.ExportFlow)
  95. }
  96. }
  97. ],
  98. buttons: []
  99. });
  100. $("#sampleTable_length").html('<button class="btn btn-primary" onclick="add()" type="button">新增</button>')
  101. })
  102. ;
  103. </script>