sensitiveWordsList.blade.php 5.3 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"> 添加敏感词</button>
  14. </div>
  15. </div>
  16. <div class="panel-body">
  17. <table class="table text-md-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. <th> 操作</th>
  24. </tr>
  25. </thead>
  26. <tbody>
  27. @if($list->isEmpty())
  28. <tr>
  29. <td colspan="3">暂无数据</td>
  30. </tr>
  31. @else
  32. @foreach($list as $vo)
  33. <tr>
  34. <td> {{$vo->id}} </td>
  35. <td> {{$vo->type==1? '黑':'白'}} </td>
  36. <td> {{$vo->words}} </td>
  37. <td>
  38. <button class="btn btn-danger" onclick="delWord('{{$vo->id}}','{{$vo->words}}')">
  39. <i class="icon wb-trash"></i>
  40. </button>
  41. </td>
  42. </tr>
  43. @endforeach
  44. @endif
  45. </tbody>
  46. </table>
  47. </div>
  48. <div class="panel-footer">
  49. <div class="row">
  50. <div class="col-sm-4">
  51. 共 <code>{{$list->total()}}</code> 条记录
  52. </div>
  53. <div class="col-sm-8">
  54. <nav class="Page navigation float-right">
  55. {{$list->links()}}
  56. </nav>
  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 modal-lg">
  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. <div class="form-group row">
  73. <label class="col-form-label col-md-2" for="type">类型</label>
  74. <div class="col-md-10 d-flex align-items-center">
  75. <div class="radio-custom radio-primary radio-inline">
  76. <input type="radio" name="type" value="1" checked/>
  77. <label for="type">黑名单</label>
  78. </div>
  79. <div class="radio-custom radio-primary radio-inline">
  80. <input type="radio" name="type" value="2"/>
  81. <label for="type">白名单</label>
  82. </div>
  83. </div>
  84. </div>
  85. <div class="form-group row">
  86. <label class="col-form-label col-md-2" for="words">敏感词</label>
  87. <div class="col-md-9">
  88. <input type="text" class="form-control" name="words" id="words" placeholder="请填入敏感词"/>
  89. </div>
  90. </div>
  91. </div>
  92. <div class="modal-footer">
  93. <button data-dismiss="modal" class="btn btn-danger"> 关 闭</button>
  94. <button data-dismiss="modal" class="btn btn-success" onclick="addSensitiveWords()"> 提 交</button>
  95. </div>
  96. </div>
  97. </div>
  98. </div>
  99. @endsection
  100. @section('script')
  101. <script src="/assets/global/vendor/bootstrap-table/bootstrap-table.min.js" type="text/javascript"></script>
  102. <script src="/assets/global/vendor/bootstrap-table/extensions/mobile/bootstrap-table-mobile.min.js" type="text/javascript"></script>
  103. <script type="text/javascript">
  104. // 添加敏感词
  105. function addSensitiveWords() {
  106. const words = $('#words').val();
  107. if (words.trim() === '') {
  108. swal.fire({title: '敏感词不能为空', type: 'warning', timer: 1000, showConfirmButton: false});
  109. $("#words").focus();
  110. return false;
  111. }
  112. $.post("/sensitiveWords/add", {_token: '{{csrf_token()}}', type: $("input:radio[name='type']:checked").val(), words: words}, 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/del", {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