save_wall.blade.php 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292
  1. @extends('admin/layout')
  2. @section('header')
  3. <link href="{{asset('css/plugins/chosen/chosen.css')}}" rel="stylesheet">
  4. @endsection
  5. @section('content')
  6. <body class="gray-bg">
  7. <div class="wrapper wrapper-content animated fadeInRight">
  8. <div class="row">
  9. <div class="col-sm-12">
  10. <div class="ibox float-e-margins">
  11. <div class="ibox-content">
  12. <form method="get" class="form-horizontal" id="form">
  13. <div class="form-group" style="display: none">
  14. <label class="col-sm-2 control-label" for="site_id"><span class="red">* </span>站点:</label>
  15. <div class="col-sm-8 ">
  16. <select data-placeholder="选择站点..." class="chosen-select" style="width:350px; "
  17. id="site_id" name="site_id">
  18. <option value="1">请选择站点</option>
  19. </select>
  20. </div>
  21. </div>
  22. <div class="form-group" style="display: none">
  23. <label class="col-sm-2 control-label" for="thumb">缩略图:</label>
  24. <div class="col-sm-8">
  25. <button type="button" class="btn btn-primary" name="file_upload">缩略图上传</button>
  26. <input type="file" value="" style="display: none" name="uploadFile">
  27. <input type="hidden" id="thumb" name="thumb" value="{{$data->thumb??''}}">
  28. </div>
  29. </div>
  30. <div class="form-group" @if (empty($data->thumb))style="display: none"
  31. @endif id="thumb_div">
  32. <div class="col-sm-8 col-sm-offset-2">
  33. <img style="height: 150px" src="{{$data->thumb??''}}">
  34. </div>
  35. </div>
  36. <div class="form-group" style="display: none">
  37. <label class="col-sm-2 control-label" for="translator_id">指派:</label>
  38. <div class="col-sm-8 ">
  39. <select data-placeholder="选择站点..." class="chosen-select" style="width:350px; "
  40. id="translator_id" name="translator_id">
  41. <option value="">请选择翻译人员</option>
  42. @foreach ($translators as $item)
  43. <option value="{{$item->id}}"
  44. @if(($data->translator_id??null)==$item->id) selected @endif>{{$item->username}}</option>
  45. @endforeach
  46. </select>
  47. </div>
  48. </div>
  49. <div class="form-group" style="display: none">
  50. <label class="col-sm-2 control-label" for="title"><span class="red">* </span>标题:</label>
  51. <div class="col-sm-8">
  52. <input type="text" class="form-control" id="title" name="title"
  53. value="测试标题">
  54. </div>
  55. </div>
  56. <div class="form-group">
  57. <label class="col-sm-2 control-label" for="content"><span class="red">* </span>正文:</label>
  58. <div class="col-sm-8">
  59. <!-- 编辑器容器 -->
  60. <script id="content" name="content"
  61. type="text/plain">{!! $data->content??'' !!}</script>
  62. </div>
  63. </div>
  64. <div id="group" style="display: none">
  65. @foreach($data->group??[[]] as $key=>$item)
  66. <div class="form-group">
  67. <label class="col-sm-2 control-label"><span class="red">* </span>中文关键词:</label>
  68. <div class="col-sm-2">
  69. <input type="text" class="form-control" name="cn_keyword" title=""
  70. value="0">
  71. </div>
  72. <label class="col-sm-1 control-label">英文关键词:</label>
  73. <div class="col-sm-2">
  74. <input type="text" class="form-control" name="en_keyword" title=""
  75. value="1">
  76. </div>
  77. <label class="col-sm-1 control-label">锚点链接:</label>
  78. <div class="col-sm-2">
  79. <input type="text" class="form-control" name="anchor" title=""
  80. value="2">
  81. </div>
  82. @if($key==0)
  83. <div class="col-sm-1">
  84. <button class="btn btn-primary" type="button"
  85. onclick="units.addGroup()">添加
  86. </button>
  87. </div>
  88. @else
  89. <div class="col-sm-1">
  90. <button class="btn btn-warning" type="button"
  91. onclick="units.delGroup(this)">删除
  92. </button>
  93. </div>
  94. @endif
  95. </div>
  96. @endforeach
  97. </div>
  98. <div class="form-group" style="display: none">
  99. <label class="col-sm-2 control-label" for="translate_title">英文标题:</label>
  100. <div class="col-sm-8">
  101. <input type="text" class="form-control" id="translate_title" name="translate_title"
  102. value="{{$data->translate_title??''}}">
  103. </div>
  104. </div>
  105. <div class="form-group" style="display: none">
  106. <label class="col-sm-2 control-label" for="translate_content">英文正文:</label>
  107. <div class="col-sm-8">
  108. <script id="translate_content" name="translate_content"
  109. type="text/plain">{!! $data->translate_content??'' !!}</script>
  110. </div>
  111. </div>
  112. <div class="hr-line-dashed"></div>
  113. <div class="form-group">
  114. <div class="col-sm-4 col-sm-offset-2">
  115. @if(($data->status??null)==1||!$data) {{--如果为添加和待翻译--}}
  116. @notCustomer
  117. <button class="btn btn-primary" type="button"
  118. onclick="units.save({{$data->id??0}})">
  119. 保存
  120. </button>
  121. @endNotCustomer
  122. @endif
  123. <button class="btn btn-white closeLayer" type="button">取消</button>
  124. </div>
  125. </div>
  126. </form>
  127. </div>
  128. </div>
  129. </div>
  130. </div>
  131. </div>
  132. </body>
  133. @endsection
  134. @section('footer')
  135. @include('vendor.ueditor.assets')
  136. <script src="{{asset('js/plugins/chosen/chosen.jquery.js')}}"></script>
  137. <script>
  138. var ue = UE.getEditor('content');
  139. ue.ready(function () {
  140. ue.setHeight(300);
  141. {{--ue.execCommand('serverparam', '_token', '{{ csrf_token() }}'); // 设置 CSRF token.--}}
  142. });
  143. var ueTranslate = UE.getEditor('translate_content');
  144. ueTranslate.ready(function () {
  145. ueTranslate.setHeight(300);
  146. });
  147. var config = {".chosen-select": {}};
  148. for (var selector in config) $(selector).chosen(config[selector]);
  149. var units = {
  150. save: function (id) {
  151. var url = '/admin/articles/' + id;
  152. var data = tips.getFormValues('#form');
  153. var group = [], cn_keyword, en_keyword, anchor;
  154. $("#group").find(".form-group").each(function () {
  155. cn_keyword = $(this).find("[name=cn_keyword]").val();
  156. en_keyword = $(this).find("[name=en_keyword]").val();
  157. anchor = $(this).find("[name=anchor]").val();
  158. if (cn_keyword.length !== 0 && en_keyword !== 0 && anchor !== 0) {
  159. group.push({
  160. cn_keyword: cn_keyword,
  161. en_keyword: en_keyword,
  162. anchor: anchor
  163. });
  164. }
  165. });
  166. data.group = group;
  167. var ajaxConfig = {
  168. url: url,
  169. type: 'put',
  170. data: data,
  171. success: function (result) {
  172. layer.msg(result.message, {icon: 6, time: 1000}, function () {
  173. tips.closeParentLayer();
  174. window.parent.tips.tableRefresh('#table');
  175. });
  176. }
  177. };
  178. tips.ajax(ajaxConfig);
  179. },
  180. addGroup: function () {
  181. var html = '<div class="form-group">' +
  182. '<label class="col-sm-2 control-label" >中文关键词:</label>\n' +
  183. '<div class="col-sm-2">' +
  184. '<input type="text" class="form-control" name="cn_keyword"\n' +
  185. 'value="">\n' +
  186. '</div>\n' +
  187. '<label class="col-sm-1 control-label">英文关键词:</label>\n' +
  188. '<div class="col-sm-2">\n' +
  189. '<input type="text" class="form-control" name="en_keyword" value="">\n' +
  190. '</div>\n' +
  191. '<label class="col-sm-1 control-label" >锚点链接:</label>\n' +
  192. '<div class="col-sm-2">\n' +
  193. '<input type="text" class="form-control" name="anchor" value="">\n' +
  194. '</div>\n' +
  195. '<div class="col-sm-1">\n' +
  196. '<button class="btn btn-warning" type="button" onclick="units.delGroup(this)">删除</button>\n' +
  197. '</div>\n' +
  198. '</div>';
  199. $("#group").append(html);
  200. },
  201. delGroup: function (_this) {
  202. $(_this).parent().parent().remove();
  203. }
  204. };
  205. $(document).on('click', '[name=file_upload]', function () {
  206. $(this).next().trigger('click');
  207. });
  208. $(document).on('change', '[name=uploadFile]', function () {
  209. var _this = this;
  210. if (!$(this)[0].files[0]) {
  211. return;
  212. }
  213. var formData = new FormData();
  214. formData.append('file', $(this)[0].files[0]);
  215. var ln;
  216. $.ajax({
  217. url: '/admin/tool/upload?notAsset=1',
  218. type: 'POST',
  219. cache: false,
  220. data: formData,
  221. processData: false,
  222. contentType: false,
  223. beforeSend: function () {
  224. ln = layer.load();
  225. },
  226. complete: function () {
  227. layer.close(ln);
  228. },
  229. success: function (result) {
  230. var data = result.data;
  231. var thumbDiv = $("#thumb_div");
  232. thumbDiv.css('display', '');
  233. thumbDiv.find("img").attr('src', data.file_url);
  234. $('#' + $(_this).data('for')).attr('src', data.file_url);
  235. $(_this).next().val(data.file_url);
  236. },
  237. error: function (XMLHttpRequest) {
  238. if (XMLHttpRequest.status === 500) {
  239. layer.alert("异步请求失败", {icon: 5});
  240. return;
  241. }
  242. layer.alert(JSON.parse(XMLHttpRequest.responseText).message, {icon: 0});
  243. }
  244. });
  245. });
  246. </script>
  247. @endsection