tool_update.blade.php 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. @extends('admin/layout')
  2. @section('header')
  3. <link href="{{asset('css/plugins/chosen/chosen.css')}}" rel="stylesheet">
  4. <link href="{{asset('css/plugins/switchery/switchery.css')}}" rel="stylesheet">
  5. <link rel="stylesheet"
  6. href="https://cdn.jsdelivr.net/npm/bootstrap-select@1.13.9/dist/css/bootstrap-select.min.css">
  7. @endsection
  8. @section('content')
  9. <body class="gray-bg">
  10. <div class="wrapper wrapper-content animated fadeInRight">
  11. <div class="row">
  12. <div class="col-sm-12">
  13. <div class="ibox float-e-margins">
  14. <div class="ibox-content">
  15. <form method="get" class="form-horizontal" id="form">
  16. <div class="form-group">
  17. <label class="col-sm-2 control-label" for="nickname"><span
  18. class="red">* </span>标题:</label>
  19. <div class="col-sm-6">
  20. <input type="text" class="form-control" id="title" name="title" autocomplete="off"
  21. value="{{$info->title??''}}">
  22. </div>
  23. </div>
  24. <div class="form-group">
  25. <label class="col-sm-2 control-label" for="username_new"><span class="red">* </span>
  26. 内容:</label>
  27. <div class="col-sm-6">
  28. <input type="text" class="form-control" id="content" name="content"
  29. value="{{$info->content??''}}" autocomplete="off">
  30. </div>
  31. </div>
  32. <div class="form-group">
  33. <label class="col-sm-2 control-label">图片:</label>
  34. <div class="col-sm-4">
  35. <button type="button" class="btn btn-primary" name="file_upload">文件上传
  36. </button>
  37. <input type="file" value="" style="display: none" name="uploadFile"
  38. data-for="logo_img">
  39. <img id="image" width="200px" src="{{$info->image??''}}">
  40. </div>
  41. </div>
  42. <div class="form-group">
  43. <label class="col-sm-2 control-label" for="translate_content">详情:</label>
  44. <div class="col-sm-8">
  45. <script id="translate_content" name="details"
  46. type="text/plain">{!! $info->details??''!!}</script>
  47. </div>
  48. </div>
  49. <div class="form-group">
  50. <div class="col-sm-4 col-sm-offset-2">
  51. <button class="btn btn-primary" type="button" data-id="{{$info->id??0}}"
  52. id="save">
  53. 保存
  54. </button>
  55. <button class="btn btn-white" type="button" id="cancel">取消</button>
  56. </div>
  57. </div>
  58. </form>
  59. </div>
  60. </div>
  61. </div>
  62. </div>
  63. </div>
  64. </body>
  65. @endsection
  66. @section('footer')
  67. @include('vendor.ueditor.assets')
  68. <script src="{{asset('js/plugins/switchery/switchery.js')}}"></script>
  69. <script src="https://cdn.jsdelivr.net/npm/bootstrap-select@1.13.9/dist/js/bootstrap-select.min.js"></script>
  70. <script>
  71. $(document).on('click', '#cancel', function () {
  72. tips.closeParentLayer();
  73. });
  74. var ue = UE.getEditor('content');
  75. ue.ready(function () {
  76. ue.setHeight(300);
  77. });
  78. var ueTranslate = UE.getEditor('translate_content');
  79. ueTranslate.ready(function () {
  80. ueTranslate.setHeight(300);
  81. });
  82. $(document).on('click', '[name=file_upload]', function () {
  83. $(this).next().trigger('click');
  84. });
  85. $(document).on('change', '[name=uploadFile]', function () {
  86. if (!$(this)[0].files[0]) {
  87. return;
  88. }
  89. var formData = new FormData();
  90. formData.append('file', $(this)[0].files[0]);
  91. var ln;
  92. $.ajax({
  93. url: '/admin/tool/upload',
  94. type: 'POST',
  95. cache: false,
  96. data: formData,
  97. processData: false,
  98. contentType: false,
  99. beforeSend: function () {
  100. ln = layer.load();
  101. },
  102. complete: function () {
  103. layer.close(ln);
  104. },
  105. success: function (result) {
  106. var data = result.data;
  107. $('#image').attr('src', data.file_url);
  108. },
  109. error: function (XMLHttpRequest) {
  110. if (XMLHttpRequest.status === 500) {
  111. layer.alert("异步请求失败", {icon: 5});
  112. return;
  113. }
  114. layer.alert(JSON.parse(XMLHttpRequest.responseText).message, {icon: 0});
  115. }
  116. });
  117. });
  118. $(document).on('click', '#save', function () {
  119. var data = tips.getFormValues('#form');
  120. data.image = $("#image").attr('src');
  121. var id = $(this).data('id');
  122. var url = '/admin/classroom/tool-update/' + id;
  123. var type = 'get';
  124. var ajaxConfig = {
  125. url: url,
  126. type: type,
  127. data: data,
  128. success: function (result) {
  129. layer.msg(result.message, {icon: 6, time: 1500}, function () {
  130. tips.closeParentLayer();
  131. window.parent.tips.tableRefresh('#table');
  132. });
  133. }
  134. };
  135. tips.ajax(ajaxConfig);
  136. });
  137. </script>
  138. @endsection