sync.blade.php 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  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-title">
  12. <h5>站点软文同步
  13. {{--<small>包括自定义样式的复选和单选按钮</small>--}}
  14. </h5>
  15. <div class="ibox-tools">
  16. <a class="collapse-link">
  17. <i class="fa fa-chevron-up"></i>
  18. </a>
  19. <a class="dropdown-toggle" data-toggle="dropdown" href="form_basic.html#">
  20. <i class="fa fa-wrench"></i>
  21. </a>
  22. <ul class="dropdown-menu dropdown-user">
  23. <li><a href="form_basic.html#">选项1</a>
  24. </li>
  25. <li><a href="form_basic.html#">选项2</a>
  26. </li>
  27. </ul>
  28. <a class="close-link">
  29. <i class="fa fa-times"></i>
  30. </a>
  31. </div>
  32. </div>
  33. <div class="ibox-content">
  34. <form class="form-horizontal" id="form">
  35. <div class="form-group">
  36. <label class="col-sm-2 control-label">同步文章:</label>
  37. <div class="col-sm-6">
  38. @foreach($articles as $item)
  39. <label class="form-control">{{$item->title}}</label>
  40. <input type="hidden" name="articleIds" value="{{$item->id}}">
  41. @endforeach
  42. {{--<div class="input-group m-b">--}}
  43. {{--<input type="text" class="form-control"> <span--}}
  44. {{--class="input-group-addon">.00</span>--}}
  45. {{--</div>--}}
  46. {{--<div class="input-group m-b"><span class="input-group-addon">&yen;</span>--}}
  47. {{--<input type="text" class="form-control"> <span--}}
  48. {{--class="input-group-addon">.00</span>--}}
  49. {{--</div>--}}
  50. {{--<div class="input-group m-b"><span class="input-group-addon"> <input--}}
  51. {{--type="checkbox"> </span>--}}
  52. {{--<input type="text" class="form-control">--}}
  53. {{--</div>--}}
  54. {{--<div class="input-group"><span class="input-group-addon"> <input--}}
  55. {{--type="radio"> </span>--}}
  56. {{--<input type="text" class="form-control">--}}
  57. {{--</div>--}}
  58. </div>
  59. </div>
  60. <div class="form-group">
  61. <label class="col-sm-2 control-label" for="remoteContent">同步至:</label>
  62. <div class="col-sm-6">
  63. <select class="form-control m-b" name="remote_content_id" id="remoteContent"
  64. onchange="units.select(this)">
  65. <option value="">请选择</option>
  66. </select>
  67. </div>
  68. </div>
  69. <div class="form-group">
  70. <label class="col-sm-2 control-label" for="template_id">页面模板:</label>
  71. <div class="col-sm-6">
  72. <select class="form-control m-b" name="template_id" id="template_id">
  73. <option value="">请选择模板</option>
  74. @foreach($removeTemplate as $item)
  75. <option
  76. value="{{$item['id']}}">{{$item['name'].'('.$item['alias'].')'}}</option>
  77. @endforeach
  78. </select>
  79. </div>
  80. </div>
  81. <div class="hr-line-dashed"></div>
  82. <div class="form-group">
  83. <label class="col-sm-2 control-label" for="release_at">发布日期:</label>
  84. <div class="col-sm-6">
  85. <div class="input-group m-b">
  86. <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
  87. <input type="text" class="form-control" id="release_at" name="release_at">
  88. </div>
  89. </div>
  90. </div>
  91. <div class="form-group">
  92. <label class="col-sm-2 control-label" for="release_interval">发布间隔:</label>
  93. <div class="col-sm-2">
  94. <div class="input-group m-b">
  95. <input type="text" class="form-control" name="release_interval"
  96. id="release_interval">
  97. <span class="input-group-addon">天</span>
  98. </div>
  99. </div>
  100. </div>
  101. <div class="hr-line-dashed"></div>
  102. <div class="form-group">
  103. <div class="col-sm-4 col-sm-offset-2">
  104. <button class="btn btn-primary" type="button" onclick="units.sync()">开始同步</button>
  105. <button class="btn btn-white closeLayer" type="submit">关闭页面</button>
  106. </div>
  107. </div>
  108. </form>
  109. </div>
  110. </div>
  111. </div>
  112. </div>
  113. </div>
  114. </body>
  115. @endsection
  116. @section('footer')
  117. <script src="{{asset('js/plugins/chosen/chosen.jquery.js')}}"></script>
  118. <script src="{{asset('js/plugins/layDate-v5.0.9/laydate/laydate.js')}}"></script>
  119. <script src="https://cdn.bootcss.com/lodash.js/4.17.10/lodash.core.min.js"></script>
  120. <script>
  121. var remoteContent =@json($remoteContent);
  122. $(function () {
  123. // remoteContent = JSON.parse(remoteContent);
  124. var initRemoveContent = _.filter(remoteContent, {parent_id: "0"});
  125. var rc = $("#remoteContent");
  126. $.each(initRemoveContent, function (inx, val) {
  127. rc.append("<option value='" + val.id + "'>" + val.name + "</option>");
  128. });
  129. // rc.chosen({});
  130. });
  131. var units = {
  132. save: function (id) {
  133. var url = '/admin/articles/' + id;
  134. var data = tips.getFormValues('#form');
  135. var ajaxConfig = {
  136. url: url,
  137. type: 'put',
  138. data: data,
  139. success: function (result) {
  140. layer.msg(result.message, {icon: 6, time: 1000}, function () {
  141. tips.closeParentLayer();
  142. window.parent.tips.tableRefresh('#table');
  143. });
  144. }
  145. };
  146. tips.ajax(ajaxConfig);
  147. },
  148. select: function (_this) {
  149. $(_this).nextAll().remove();
  150. var subContent = _.filter(remoteContent, {parent_id: $(_this).val()});
  151. if (subContent.length !== 0) {
  152. var head = '<select class="form-control m-b chosen-select" name="remote_content_id" onchange="units.select(this)"><option value="">请选择</option>';
  153. $.each(subContent, function (inx, val) {
  154. head += '<option value="' + val.id + '">' + val.name + '</option>';
  155. });
  156. var foot = '</select>';
  157. $(_this).after(head + foot);
  158. // $(_this).next().chosen({});
  159. }
  160. },
  161. sync: function () {
  162. var article_ids = [];
  163. $("[name=articleIds]").each(function () {
  164. article_ids.push($(this).val());
  165. });
  166. var remote_content_id = '';
  167. $("[name=remote_content_id]").each(function () {
  168. if ($(this).val()) {
  169. remote_content_id = $(this).val()
  170. }
  171. });
  172. var data = tips.getFormValues('#form');
  173. data.article_ids = article_ids;
  174. data.remote_content_id = remote_content_id;
  175. var ajaxConfig = {
  176. url: '/admin/sites/{{$siteId}}/articles-sync',
  177. type: 'put',
  178. data: data
  179. };
  180. tips.ajax(ajaxConfig);
  181. }
  182. };
  183. laydate.render({
  184. elem: '#release_at', //指定元素
  185. type: 'datetime'
  186. });
  187. </script>
  188. @endsection