sensitiveWordsList.blade.php 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. @extends('admin.layouts')
  2. @section('css')
  3. <link href="/assets/global/vendor/bootstrap-table/bootstrap-table.min.css" type="text/css" rel="stylesheet">
  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-sm-4">
  49. 共 <code>{{$list->total()}}</code> 条记录
  50. </div>
  51. <div class="col-sm-8">
  52. <nav class="Page navigation float-right">
  53. {{$list->links()}}
  54. </nav>
  55. </div>
  56. </div>
  57. </div>
  58. </div>
  59. </div>
  60. <div id="add_sensitive_words" class="modal fade" tabindex="-1" data-focus-on="input:first" data-keyboard="false">
  61. <div class="modal-dialog modal-simple modal-center">
  62. <div class="modal-content">
  63. <div class="modal-header">
  64. <button type="button" class="close" data-dismiss="modal" aria-label="Close">
  65. <span aria-hidden="true">×</span>
  66. </button>
  67. <h4 class="modal-title"> 添加敏感词 </h4>
  68. </div>
  69. <div class="modal-body">
  70. <input type="text" name="words" id="words" placeholder="请填入敏感词" class="form-control"/>
  71. </div>
  72. <div class="modal-footer">
  73. <button data-dismiss="modal" class="btn btn-danger"> 关 闭 </button>
  74. <button data-dismiss="modal" class="btn btn-success" onclick="addSensitiveWords()"> 提 交 </button>
  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" type="text/javascript"></script>
  82. <script src="/assets/global/vendor/bootstrap-table/extensions/mobile/bootstrap-table-mobile.min.js" type="text/javascript"></script>
  83. <script type="text/javascript">
  84. // 添加敏感词
  85. function addSensitiveWords() {
  86. const words = $('#words').val();
  87. if (words.trim() === '') {
  88. swal.fire({title: '敏感词不能为空', type: 'warning', timer: 1000, showConfirmButton: false});
  89. $("#words").focus();
  90. return false;
  91. }
  92. $.post("/sensitiveWords/add", {_token: '{{csrf_token()}}', words: words}, function (ret) {
  93. if (ret.status === 'success') {
  94. swal.fire({title: ret.message, type: 'success', timer: 1000, showConfirmButton: false})
  95. .then(() => window.location.reload())
  96. } else {
  97. swal.fire({title: ret.message, type: "error"}).then(() => window.location.reload())
  98. }
  99. });
  100. }
  101. // 删除敏感词
  102. function delWord(id) {
  103. swal.fire({
  104. title: '警告',
  105. text: '确定删除该敏感词',
  106. type: 'warning',
  107. showCancelButton: true,
  108. cancelButtonText: '取消',
  109. confirmButtonText: '确定',
  110. }).then((result) => {
  111. if (result.value) {
  112. $.post("/sensitiveWords/del", {id: id, _token: '{{csrf_token()}}'}, function (ret) {
  113. if (ret.status === 'success') {
  114. swal.fire({title: ret.message, type: 'success', timer: 1000, showConfirmButton: false})
  115. .then(() => window.location.reload())
  116. } else {
  117. swal.fire({title: ret.message, type: "error"}).then(() => window.location.reload())
  118. }
  119. })
  120. }
  121. })
  122. }
  123. </script>
  124. @endsection