task_save.blade.php 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324
  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. <style>
  6. .selectedTable {
  7. }
  8. .selectedTable td {
  9. border: 1px solid #E3E3E3;
  10. padding: 6px 18px;
  11. }
  12. </style>
  13. @endsection
  14. @section('content')
  15. <body class="gray-bg">
  16. <div class="wrapper wrapper-content animated fadeInRight">
  17. <div class="row">
  18. <div class="col-sm-12">
  19. <div class="ibox float-e-margins">
  20. <div class="ibox-content">
  21. <form class="form-horizontal" id="form">
  22. <div class="form-group">
  23. <label class="col-sm-2 control-label" for="site_id"><span
  24. class="red">* </span>站点:</label>
  25. <div class="col-sm-8 ">
  26. <select data-placeholder="选择站点..." class="chosen-select" style="width:350px; "
  27. id="site_id" name="site_id" onchange="units.renderOptimizePage(this)">
  28. <option value="">请选择站点</option>
  29. @foreach ($sites as $site)
  30. <option value="{{$site->id}}"
  31. @if(($data->site_id??null)==$site->id) selected @endif
  32. @if($siteId==$site->id) selected @endif>
  33. {{$site->cn_title}}
  34. </option>
  35. @endforeach
  36. </select>
  37. </div>
  38. </div>
  39. <div class="form-group">
  40. <label class="col-sm-2 control-label" for="worker_id">指派:</label>
  41. <div class="col-sm-8 ">
  42. <select data-placeholder="选择站点..." class="chosen-select" style="width:350px; "
  43. id="worker_id" name="worker_id">
  44. <option value="">请选择兼职人员</option>
  45. @foreach ($workers as $item)
  46. <option value="{{$item->id}}"
  47. @if(($data->worker_id??null)==$item->id) selected @endif>{{$item->username}}</option>
  48. @endforeach
  49. </select>
  50. </div>
  51. </div>
  52. <div class="form-group">
  53. <label class="col-sm-2 control-label" for="title"><span class="red">* </span>标题:</label>
  54. <div class="col-sm-8">
  55. <input type="text" class="form-control" id="title" name="title"
  56. value="{{$data->title??''}}">
  57. </div>
  58. </div>
  59. <div class="form-group">
  60. <label class="col-sm-2 control-label" for="link_ids"><span
  61. class="red">* </span>外链种类:</label>
  62. <div class="col-sm-2 ">
  63. <button type="button" class="btn btn-warning" onclick="units.choseLinkType()">选择平台
  64. </button>
  65. <input type="hidden" id="link_ids" value="{{$linkIdsStr}}">
  66. <input type="hidden" id="link_ids_with_time">
  67. </div>
  68. <div class="col-sm-3">
  69. <table class="selectedTable">
  70. <thead>
  71. <tr>
  72. <td>时间</td>
  73. <td>外链平台</td>
  74. </tr>
  75. </thead>
  76. <tbody id="linkTableBody">
  77. @foreach($selectedLinkTypeList as $item)
  78. <tr>
  79. <td>无</td>
  80. <td>【{{$typeList[$item->type]??''}}】{{$item->url}}</td>
  81. </tr>
  82. @endforeach
  83. </tbody>
  84. </table>
  85. </div>
  86. <div class="col-sm-2">
  87. @php $optimizePageIds=json_decode($data->optimize_page_ids??"[]",true); @endphp
  88. <select name="optimizePage" id="optimizePage" class="form-control" multiple>
  89. @foreach($optimizePageList as $page)
  90. <option value="{{$page['id']}}"
  91. @if(in_array($page['id'],$optimizePageIds)) selected @endif>
  92. 【{{$page['keyword']}}】{{$page['url']}}</option>
  93. @endforeach
  94. </select>
  95. ctrl+鼠标选中
  96. </div>
  97. </div>
  98. <div class="form-group">
  99. <label class="col-sm-2 control-label" for="link_review_at"><span class="red">* </span>
  100. 链接审核时间:</label>
  101. <div class="col-sm-6">
  102. <input type="text" style="width: 200px" class="form-control my-date deadline"
  103. name="link_review_at" id="link_review_at"
  104. value="{{$data->link_review_at??''}}">
  105. </div>
  106. </div>
  107. <div class="form-group">
  108. <label class="col-sm-2 control-label" for="demand">要求:</label>
  109. <div class="col-sm-8">
  110. <!-- 编辑器容器 -->
  111. <script id="demand" name="demand"
  112. type="text/plain">{!! $data->demand??'' !!}</script>
  113. </div>
  114. </div>
  115. <div class="form-group">
  116. <label class="col-sm-2 control-label" for="release_at"><span
  117. class="red"></span>发布时间:</label>
  118. <div class="col-sm-8">
  119. <input type="text" class="form-control my-date deadline" id="audit_at"
  120. name="release_at"
  121. value="{{$data->release_at??''}}">
  122. </div>
  123. </div>
  124. <div class="hr-line-dashed"></div>
  125. <div class="form-group">
  126. <div class="col-sm-4 col-sm-offset-2">
  127. {{--待分配 任务中--}}
  128. @if(!$data|| in_array($data->status,[1,2]))
  129. <button class="btn btn-primary" type="button"
  130. onclick="units.save({{$data->id??0}})">
  131. 保存
  132. </button>
  133. @endif
  134. <button class="btn btn-white closeLayer" type="button">取消</button>
  135. </div>
  136. </div>
  137. </form>
  138. </div>
  139. </div>
  140. </div>
  141. </div>
  142. </div>
  143. </body>
  144. @endsection
  145. @section('footer')
  146. @include('vendor.ueditor.assets')
  147. <script src="{{asset('js/plugins/chosen/chosen.jquery.js')}}"></script>
  148. <script src="{{asset('js/plugins/layDate-v5.0.9/laydate/laydate.js')}}"></script>
  149. <script>
  150. //同时绑定多个
  151. lay('.deadline').each(function () {
  152. laydate.render({
  153. elem: this
  154. , trigger: 'click',
  155. type: 'datetime'
  156. });
  157. });
  158. var ue = UE.getEditor('demand');
  159. ue.ready(function () {
  160. ue.setHeight(300);
  161. ue.execCommand('serverparam', '_token', '{{ csrf_token() }}'); // 设置 CSRF token.
  162. {{--ue.setContent("{!! $data->content??'' !!}");--}}
  163. });
  164. var config = {".chosen-select": {}};
  165. for (var selector in config) $(selector).chosen(config[selector]);
  166. var units = {
  167. renderOptimizePage: function (_this) {
  168. var checkVal = $(_this).val();
  169. if (checkVal != "") {
  170. var ajaxConfig = {
  171. url: '/admin/link/task/optimizePage?siteId=' + checkVal,
  172. type: 'GET',
  173. success: function (result) {
  174. var str = '';
  175. $.each(result.data, function (inx, data) {
  176. str += '<option value="' + data.id + '">' + data.keyword + '[' + data.url + ']' + '</option>';
  177. });
  178. console.log(result.data);
  179. $("#optimizePage").append(str);
  180. }
  181. };
  182. tips.ajax(ajaxConfig);
  183. } else {
  184. $("#optimizePage").html('');
  185. }
  186. },
  187. save: function (id) {
  188. var url = '/admin/link/task/' + id + '/save';
  189. var task = tips.getFormValues('#form');
  190. task.optimize_page_ids = $("#optimizePage").val();
  191. var link_ids_str = $("#link_ids").val();
  192. var link_ids_with_time_str = $("#link_ids_with_time").val();
  193. var linkIds, linkIdsWithTime = null;
  194. if (!link_ids_str && !link_ids_with_time_str) {
  195. layer.alert('请先选择外链种类', {icon: 3});
  196. return;
  197. }
  198. if (link_ids_str) {
  199. linkIds = JSON.parse(link_ids_str);
  200. }
  201. if (link_ids_with_time_str) {
  202. linkIdsWithTime = JSON.parse(link_ids_with_time_str);
  203. }
  204. var ajaxConfig = {
  205. url: url,
  206. type: 'put',
  207. data: {task: task, link: {link_ids: linkIds, link_ids_with_time: linkIdsWithTime}},
  208. success: function (result) {
  209. layer.msg(result.message, {icon: 6, time: 1000}, function () {
  210. tips.closeParentLayer();
  211. window.parent.tips.tableRefresh('#table');
  212. });
  213. }
  214. };
  215. tips.ajax(ajaxConfig);
  216. },
  217. choseLinkType: function () {
  218. var siteId = $("#site_id").val();
  219. var linkIdsValArr;
  220. var linkIdsVal = $("#link_ids").val();
  221. if (linkIdsVal) {
  222. linkIdsValArr = JSON.parse(linkIdsVal);
  223. } else {
  224. linkIdsValArr = [];
  225. }
  226. var linkIds = '';
  227. $.each(linkIdsValArr, function (inx, val) {
  228. linkIds += 'linkIds[]=' + val + '&';
  229. });
  230. layer.open({
  231. type: 2,
  232. content: ['/admin/link/chose/' + "{{$data->id??0}}?siteId=" + siteId + "&" + linkIds],
  233. area: ['80%', '100%'],
  234. btn: ['确认', '取消'],
  235. title: '选择外链库',
  236. yes: function (index, layero) {
  237. var son = $(layero).find('iframe')[0].contentWindow;
  238. //包括时间的数据
  239. var withData = $(son.document.body).find("#choseData").val();
  240. if (withData != "") { //如果是包括时间不为空
  241. try {
  242. var withDataObj = JSON.parse(withData);
  243. $("#link_ids_with_time").val(withData);
  244. $("#linkTableBody").html('');
  245. $.each(withDataObj, function (inx, data) {
  246. $.each(data.selectItems, function (key, items) {
  247. $("#linkTableBody").append('<tr><td>' + data.release_at + '</td><td>【' + items.type + '】' + items.url + '</td></tr>');
  248. })
  249. });
  250. } catch (e) {
  251. layer.alert("脚本执行失败");
  252. return;
  253. }
  254. } else {
  255. var choseCheckBox = [], directChoseItems = [];
  256. $(son.document.body).find(".ibox-content").find("[name=linkIds]input:checked").each(function () {
  257. choseCheckBox.push($(this).val());
  258. directChoseItems.push({type: $(this).data('type'), url: $(this).data('url')})
  259. });
  260. $("#linkTableBody").html('');
  261. $.each(directChoseItems, function (inx, data) {
  262. $("#linkTableBody").append('<tr><td>无</td><td>【' + data.type + '】' + data.url + '</td></tr>');
  263. });
  264. $("#link_ids").val(JSON.stringify(choseCheckBox));
  265. }
  266. layer.close(index)
  267. }
  268. });
  269. }
  270. };
  271. </script>
  272. @endsection