deviceList.blade.php 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. @extends('admin.layouts')
  2. @section('css')
  3. <link rel="stylesheet" href="/assets/global/vendor/bootstrap-table/bootstrap-table.min.css">
  4. @endsection
  5. @section('content')
  6. <div class="page-content container-fluid">
  7. <div class="panel">
  8. <div class="panel-heading">
  9. <h3 class="panel-title">订阅设备列表</h3>
  10. </div>
  11. <div class="panel-body">
  12. <div class="form-inline pb-20">
  13. <div class="form-group">
  14. <select name="status" id="status" class="form-control">
  15. <option value="" @if(Request::get('status') == '') selected hidden @endif>账号状态</option>
  16. <option value="-1" @if(Request::get('status') == '-1') selected hidden @endif>禁用</option>
  17. <option value="0" @if(Request::get('status') == '0') selected hidden @endif>未激活</option>
  18. <option value="1" @if(Request::get('status') == '1') selected hidden @endif>正常</option>
  19. </select>
  20. </div>
  21. <div class="btn-group">
  22. <button class="btn btn-primary" onclick="doSearch()">搜索</button>
  23. <button class="btn btn-danger" onclick="doReset()">重置</button>
  24. </div>
  25. </div>
  26. <table class="text-center" data-toggle="table" data-mobile-responsive="true">
  27. <thead class="thead-default">
  28. <tr>
  29. <th> #</th>
  30. <th> 名称</th>
  31. <th> 类型</th>
  32. <th> 平台</th>
  33. <th> 请求头</th>
  34. <th> 操作</th>
  35. </tr>
  36. </thead>
  37. <tbody>
  38. @if($deviceList->isEmpty())
  39. <tr>
  40. <td colspan="6">暂无数据</td>
  41. </tr>
  42. @else
  43. @foreach($deviceList as $vo)
  44. <tr>
  45. <td> {{$vo->id}} </td>
  46. <td> {{$vo->name}} </td>
  47. <td> {!! $vo->type_label !!} </td>
  48. <td> {!! $vo->platform_label !!} </td>
  49. <td> {{$vo->header}} </td>
  50. <td>
  51. @if($vo->status == 0)
  52. <button class="btn btn-sm btn-outline-success" onclick="setDeviceStatus('{{$vo->id}}', 1)">启用</button>
  53. @endif
  54. @if($vo->status == 1)
  55. <button class="btn btn-sm btn-outline-danger" onclick="setDeviceStatus('{{$vo->id}}', 0)">禁用</button>
  56. @endif
  57. </td>
  58. </tr>
  59. @endforeach
  60. @endif
  61. </tbody>
  62. </table>
  63. </div>
  64. <div class="panel-footer">
  65. <div class="row">
  66. <div class="col-md-4 col-sm-4">
  67. <p class="dataTables_info" role="status" aria-live="polite">共
  68. <code>{{$deviceList->total()}}</code> 条记录</p>
  69. </div>
  70. <div class="col-md-8 col-sm-8">
  71. <div class="float-right">
  72. <nav aria-label="Page navigation">{{ $deviceList->links() }}</nav>
  73. </div>
  74. </div>
  75. </div>
  76. </div>
  77. </div>
  78. </div>
  79. @endsection
  80. @section('script')
  81. <script src="/assets/global/vendor/bootstrap-table/bootstrap-table.min.js"></script>
  82. <script src="/assets/global/vendor/bootstrap-table/extensions/mobile/bootstrap-table-mobile.min.js"></script>
  83. <script type="text/javascript">
  84. // 搜索
  85. function doSearch() {
  86. const status = $("#status option:selected").val();
  87. window.location.href = '/subscribe/deviceList' + '?status=' + status;
  88. }
  89. // 重置
  90. function doReset() {
  91. window.location.href = '/subscribe/deviceList';
  92. }
  93. // 启用禁用订阅设备
  94. function setDeviceStatus(id, status) {
  95. $.post("/subscribe/setDeviceStatus", {
  96. _token: '{{csrf_token()}}',
  97. id: id,
  98. status: status
  99. }, function (ret) {
  100. swal.fire({text: ret.message, timer: 1000, showConfirmButton: false,})
  101. .then(() => {
  102. window.location.reload();
  103. })
  104. });
  105. }
  106. </script>
  107. @endsection