sensitiveWordsList.blade.php 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  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"> 添加敏感词
  14. </button>
  15. </div>
  16. </div>
  17. <div class="panel-body">
  18. <table class="table text-md-center" data-toggle="table" data-mobile-responsive="true">
  19. <thead class="thead-default">
  20. <tr>
  21. <th> #</th>
  22. <th> 类型</th>
  23. <th> 敏感词</th>
  24. <th> 操作</th>
  25. </tr>
  26. </thead>
  27. <tbody>
  28. @foreach($list as $vo)
  29. <tr>
  30. <td> {{$vo->id}} </td>
  31. <td> {{$vo->type==1? '黑':'白'}} </td>
  32. <td> {{$vo->words}} </td>
  33. <td>
  34. <button class="btn btn-danger" onclick="delWord('{{$vo->id}}','{{$vo->words}}')">
  35. <i class="icon wb-trash"></i>
  36. </button>
  37. </td>
  38. </tr>
  39. @endforeach
  40. </tbody>
  41. </table>
  42. </div>
  43. <div class="panel-footer">
  44. <div class="row">
  45. <div class="col-sm-4">
  46. 共 <code>{{$list->total()}}</code> 条记录
  47. </div>
  48. <div class="col-sm-8">
  49. <nav class="Page navigation float-right">
  50. {{$list->links()}}
  51. </nav>
  52. </div>
  53. </div>
  54. </div>
  55. </div>
  56. </div>
  57. <div id="add_sensitive_words" class="modal fade" tabindex="-1" data-focus-on="input:first" data-keyboard="false">
  58. <div class="modal-dialog modal-simple modal-center modal-lg">
  59. <div class="modal-content">
  60. <div class="modal-header">
  61. <button type="button" class="close" data-dismiss="modal" aria-label="Close">
  62. <span aria-hidden="true">×</span>
  63. </button>
  64. <h4 class="modal-title"> 添加敏感词 </h4>
  65. </div>
  66. <div class="modal-body">
  67. <div class="form-group row">
  68. <label class="col-form-label col-md-2" for="type">类型</label>
  69. <div class="col-md-10 d-flex align-items-center">
  70. <div class="radio-custom radio-primary radio-inline">
  71. <input type="radio" name="type" value="1" checked/>
  72. <label for="type">黑名单</label>
  73. </div>
  74. <div class="radio-custom radio-primary radio-inline">
  75. <input type="radio" name="type" value="2"/>
  76. <label for="type">白名单</label>
  77. </div>
  78. </div>
  79. </div>
  80. <div class="form-group row">
  81. <label class="col-form-label col-md-2" for="words">敏感词</label>
  82. <div class="col-md-9">
  83. <input type="text" class="form-control" name="words" id="words" placeholder="请填入敏感词"/>
  84. </div>
  85. </div>
  86. </div>
  87. <div class="modal-footer">
  88. <button data-dismiss="modal" class="btn btn-danger"> 关 闭</button>
  89. <button data-dismiss="modal" class="btn btn-success" onclick="addSensitiveWords()"> 提 交</button>
  90. </div>
  91. </div>
  92. </div>
  93. </div>
  94. @endsection
  95. @section('script')
  96. <script src="/assets/global/vendor/bootstrap-table/bootstrap-table.min.js" type="text/javascript"></script>
  97. <script src="/assets/global/vendor/bootstrap-table/extensions/mobile/bootstrap-table-mobile.min.js"
  98. type="text/javascript"></script>
  99. <script type="text/javascript">
  100. // 添加敏感词
  101. function addSensitiveWords() {
  102. const words = $('#words').val();
  103. if (words.trim() === '') {
  104. swal.fire({title: '敏感词不能为空', type: 'warning', timer: 1000, showConfirmButton: false});
  105. $("#words").focus();
  106. return false;
  107. }
  108. $.post("/sensitiveWords/add", {
  109. _token: '{{csrf_token()}}',
  110. type: $("input:radio[name='type']:checked").val(),
  111. words: words
  112. }, 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. function delWord(id, name) {
  123. swal.fire({
  124. title: '警告',
  125. text: '确定删除敏感词 【' + name + '】 ?',
  126. type: 'warning',
  127. showCancelButton: true,
  128. cancelButtonText: '取消',
  129. confirmButtonText: '确定',
  130. }).then((result) => {
  131. if (result.value) {
  132. $.post("/sensitiveWords/delete", {id: id, _token: '{{csrf_token()}}'}, function (ret) {
  133. if (ret.status === 'success') {
  134. swal.fire({title: ret.message, type: 'success', timer: 1000, showConfirmButton: false})
  135. .then(() => window.location.reload())
  136. } else {
  137. swal.fire({title: ret.message, type: "error"}).then(() => window.location.reload())
  138. }
  139. })
  140. }
  141. })
  142. }
  143. </script>
  144. @endsection