sensitiveWordsList.blade.php 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  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">
  7. <div class="panel">
  8. <div class="panel-heading">
  9. <h2 class="panel-title">敏感词列表
  10. <small>(用于屏蔽注册邮箱后缀)</small>
  11. </h2>
  12. <div class="panel-actions">
  13. <button class="btn btn-primary" data-toggle="modal" data-target="#add_sensitive_words"> 添加敏感词</button>
  14. </div>
  15. </div>
  16. <div class="panel-body">
  17. <table class="table text-center" data-toggle="table" data-mobile-responsive="true">
  18. <thead class="thead-default">
  19. <tr>
  20. <th> #</th>
  21. <th> 敏感词</th>
  22. <th> 操作</th>
  23. </tr>
  24. </thead>
  25. <tbody>
  26. @if($list->isEmpty())
  27. <tr>
  28. <td colspan="3">暂无数据</td>
  29. </tr>
  30. @else
  31. @foreach($list as $vo)
  32. <tr>
  33. <td> {{$vo->id}} </td>
  34. <td> {{$vo->words}} </td>
  35. <td>
  36. <button class="btn btn-danger" onclick="delWord('{{$vo->id}}')">
  37. <i class="icon wb-trash"></i>
  38. </button>
  39. </td>
  40. </tr>
  41. @endforeach
  42. @endif
  43. </tbody>
  44. </table>
  45. </div>
  46. <div class="panel-footer">
  47. <div class="row">
  48. <div class="col-md-4 col-sm-4">
  49. 共 <code>{{$list->total()}}</code> 条记录
  50. </div>
  51. <div class="col-md-8 col-sm-8">
  52. <div class="float-right">
  53. <nav class="Page navigation">
  54. {{ $list->links() }}
  55. </nav>
  56. </div>
  57. </div>
  58. </div>
  59. </div>
  60. </div>
  61. </div>
  62. <div id="add_sensitive_words" class="modal fade" tabindex="-1" data-focus-on="input:first" data-keyboard="false">
  63. <div class="modal-dialog modal-simple modal-center">
  64. <div class="modal-content">
  65. <div class="modal-header">
  66. <button type="button" class="close" data-dismiss="modal" aria-label="Close">
  67. <span aria-hidden="true">×</span>
  68. </button>
  69. <h4 class="modal-title"> 添加敏感词 </h4>
  70. </div>
  71. <div class="modal-body">
  72. <input type="text" name="words" id="words" placeholder="请填入敏感词" class="form-control">
  73. </div>
  74. <div class="modal-footer">
  75. <button data-dismiss="modal" class="btn btn-danger"> 关 闭 </button>
  76. <button data-dismiss="modal" class="btn btn-success" onclick="addSensitiveWords()"> 提 交 </button>
  77. </div>
  78. </div>
  79. </div>
  80. </div>
  81. @endsection
  82. @section('script')
  83. <script src="/assets/global/vendor/bootstrap-table/bootstrap-table.min.js"></script>
  84. <script src="/assets/global/vendor/bootstrap-table/extensions/mobile/bootstrap-table-mobile.min.js"></script>
  85. <script type="text/javascript">
  86. // 添加敏感词
  87. function addSensitiveWords() {
  88. const words = $('#words').val();
  89. if (words.trim() === '') {
  90. swal.fire({title: '敏感词不能为空', type: 'warning', timer: 1000, showConfirmButton: false});
  91. $("#words").focus();
  92. return false;
  93. }
  94. $.post("/sensitiveWords/add", {_token: '{{csrf_token()}}', words: words}, function (ret) {
  95. if (ret.status === 'success') {
  96. swal.fire({title: ret.message, type: 'success', timer: 1000, showConfirmButton: false})
  97. .then(() => window.location.reload())
  98. } else {
  99. swal.fire({title: ret.message, type: "error"}).then(() => window.location.reload())
  100. }
  101. });
  102. }
  103. // 删除敏感词
  104. function delWord(id) {
  105. swal.fire({
  106. title: '警告',
  107. text: '确定删除该敏感词',
  108. type: 'warning',
  109. showCancelButton: true,
  110. cancelButtonText: '取消',
  111. confirmButtonText: '确定',
  112. }).then((result) => {
  113. if (result.value) {
  114. $.post("/sensitiveWords/del", {id: id, _token: '{{csrf_token()}}'}, function (ret) {
  115. if (ret.status === 'success') {
  116. swal.fire({title: ret.message, type: 'success', timer: 1000, showConfirmButton: false})
  117. .then(() => window.location.reload())
  118. } else {
  119. swal.fire({title: ret.message, type: "error"}).then(() => window.location.reload())
  120. }
  121. })
  122. }
  123. })
  124. }
  125. </script>
  126. @endsection