sensitiveWordsList.blade.php 5.2 KB

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