editLabel.blade.php 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. @extends('admin.layouts')
  2. @section('content')
  3. <div class="page-content container">
  4. <div class="panel">
  5. <div class="panel-heading">
  6. <h2 class="panel-title">编辑标签</h2>
  7. </div>
  8. @if (Session::has('errorMsg'))
  9. <div class="alert alert-danger">
  10. <button class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span><span class="sr-only">{{trans('home.close')}}</span></button>
  11. <strong>错误:</strong> {{Session::get('errorMsg')}}
  12. </div>
  13. @endif
  14. <div class="panel-body">
  15. <form action="/admin/editLabel" method="post" enctype="multipart/form-data" class="form-horizontal" onsubmit="return doSubmit();">
  16. <div class="form-group row">
  17. <label for="name" class="col-form-label col-md-1">标签</label>
  18. <input type="text" class="form-control col-md-6" name="name" id="name" value="{{$label->name}}" autofocus required>
  19. <input type="hidden" name="_token" value="{{csrf_token()}}">
  20. </div>
  21. <div class="form-group row">
  22. <label for="sort" class="col-form-label col-md-1">排序</label>
  23. <input type="text" class="form-control col-md-6" name="sort" id="sort" value="{{$label->sort}}" required/>
  24. <span class="text-help offset-md-1"> 排序值越高显示时越靠前 &ensp;&ensp;&ensp;&ensp;&ensp;&ensp;&ensp;&ensp;&ensp;&ensp;&ensp;&ensp;&ensp;&ensp;&ensp;&ensp;&ensp;&ensp;&ensp;&ensp;&ensp;&ensp;&ensp;&ensp;&ensp;&ensp;&ensp;&ensp;&ensp;&ensp;&ensp;&ensp;&ensp;&ensp;&ensp;&ensp;&ensp;&ensp;&ensp;&ensp;</span>
  25. </div>
  26. <div class="form-actions">
  27. <button type="submit" class="btn btn-success">提交</button>
  28. </div>
  29. </form>
  30. </div>
  31. </div>
  32. </div>
  33. @endsection
  34. @section('script')
  35. <script type="text/javascript">
  36. // ajax同步提交
  37. function doSubmit() {
  38. const _token = '{{csrf_token()}}';
  39. const id = '{{$label->id}}';
  40. const name = $('#name').val();
  41. const sort = $('#sort').val();
  42. $.ajax({
  43. type: "POST",
  44. url: "/admin/editLabel",
  45. async: false,
  46. data: {_token: _token, id: id, name: name, sort: sort},
  47. dataType: 'json',
  48. success: function (ret) {
  49. if (ret.status === 'success') {
  50. swal.fire({title: ret.message, type: 'success', timer: 1000, showConfirmButton: false})
  51. .then(() => window.location.href = '/admin/labelList')
  52. } else {
  53. swal.fire({title: ret.message, type: "error"}).then(() => window.location.reload())
  54. }
  55. }
  56. });
  57. return false;
  58. }
  59. </script>
  60. @endsection