optimization_process.blade.php 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333
  1. @extends('admin/site/side_layout')
  2. @section('header_extend')
  3. <link rel="stylesheet"
  4. href="https://cdn.jsdelivr.net/npm/bootstrap-select@1.13.9/dist/css/bootstrap-select.min.css">
  5. <style>
  6. .ul-content {
  7. margin: 0;
  8. padding: 0;
  9. list-style-type: none;
  10. }
  11. .ul-content li {
  12. padding: 20px 10px 10px;
  13. display: none;
  14. }
  15. .ul-content .active {
  16. display: block;
  17. }
  18. .my-table {
  19. margin-top: 10px;
  20. width: 100%;
  21. }
  22. .my-table tr {
  23. border: 1px solid #f1f1f1;
  24. }
  25. .my-table td {
  26. padding: 8px;
  27. }
  28. .operateAdd, .operateDel {
  29. font-weight: 600;
  30. cursor: pointer;
  31. text-align: center;
  32. }
  33. .mainStep {
  34. border: 1px solid #999;
  35. padding: 12px;
  36. margin-top: 20px;
  37. }
  38. .mainStepText {
  39. display: inline-block;
  40. width: 180px;
  41. }
  42. </style>
  43. @endsection
  44. @section('right')
  45. <ul class="ul-content">
  46. <li class="active">
  47. <main id="main">
  48. <button type="button" class="btn btn-success" onclick="utils.addMain()">新增步骤</button>
  49. <button type="button" class="btn btn-info" onclick="utils.saveFlowTpl()">保存</button>
  50. @foreach($tplStageList as $stage)
  51. <div class="mainStep">
  52. <h4 style="display: inline-block">优化步骤:<input type="text" class="form-control mainStepText"
  53. name="step_title" value="{{$stage['title']}}"
  54. data-id="{{$stage['id']}}"
  55. style="width: 260px;display: inline-block"></h4>
  56. <a onclick="utils.delMain(this)">删除步骤</a>
  57. <div>
  58. @foreach($stage['optimization_flow_info_list'] as $info)
  59. <table class="my-table">
  60. <colgroup>
  61. <col style="width: 20%">
  62. <col style="width: 20%">
  63. <col style="width: 10%">
  64. <col style="width: 10%">
  65. <col style="width: 20%">
  66. <col style="width: 10%">
  67. </colgroup>
  68. <thead>
  69. <tr>
  70. <td>具体流程 <input type="hidden" value="{{$info['id']}}" name="infoId"></td>
  71. <td>备注</td>
  72. <td>开始时间</td>
  73. <td>截止时间</td>
  74. <td>执行人</td>
  75. <td class="operateAdd">
  76. <a href="javascript:;"
  77. onclick="utils.add(this)">添加</a>
  78. </td>
  79. </tr>
  80. </thead>
  81. <tbody class="connectedSortable">
  82. @foreach($info['detail_list'] as $item)
  83. @if(!empty($item['children']))
  84. @foreach($item['children'] as $index)
  85. <tr>
  86. <td><input type="text" class="form-control" name="flow_name"
  87. value="{{$index['flow_name']??''}}"></td>
  88. <td><input type="text" class="form-control" name="flow_remark"
  89. value="{{$index['flow_remark']??''}}"></td>
  90. <td><input type="text" class="form-control my-date"
  91. onclick="utils.bindDate(this)" name="flow_start_date"
  92. value="{{$index['flow_start_date']??''}}"></td>
  93. <td><input type="text" class="form-control my-date"
  94. onclick="utils.bindDate(this)" name="flow_done_date"
  95. value="{{$index['flow_done_date']??''}}"></td>
  96. <td><input type="text" class="form-control" name="duty_man"
  97. value="{{$index['duty_man']??''}}">
  98. </td>
  99. <td class="operateDel" onclick="utils.del(this)">删除</td>
  100. </tr>
  101. @endforeach
  102. @endif
  103. @endforeach
  104. </tbody>
  105. </table>
  106. @endforeach
  107. </div>
  108. </div>
  109. @endforeach
  110. </main>
  111. </li>
  112. </ul>
  113. @endsection
  114. @section('footer_extend')
  115. <script src="https://cdn.jsdelivr.net/npm/bootstrap-select@1.13.9/dist/js/bootstrap-select.min.js"></script>
  116. <script src="{{asset('js/plugins/layDate-v5.0.9/laydate/laydate.js')}}"></script>
  117. <script src="{{asset('js/jquery-ui-1.10.4.min.js')}}"></script>
  118. <script>
  119. $(function () {
  120. $('.my-select').selectpicker({
  121. liveSearch: true
  122. });
  123. $("tbody").sortable({
  124. connectWith: ".connectedSortable"
  125. }).disableSelection();
  126. });
  127. $(function () {
  128. $(".my-date").trigger('click');
  129. $('.my-select').selectpicker();
  130. });
  131. var utils = {
  132. add: function (_this) {
  133. var rowspan = $(_this).parent().next().attr('rowspan');
  134. $(_this).parent().next().attr('rowspan', rowspan + 1)
  135. var str = ' <tr>' +
  136. ' <td><input type="text" class="form-control" name="flow_name"></td>\n' +
  137. ' <td><input type="text" class="form-control" name="flow_remark"></td>\n' +
  138. ' <td><input type="text" class="form-control my-date" name="flow_start_date" onclick="utils.bindDate(this)"></td>\n' +
  139. ' <td><input type="text" class="form-control my-date" name="flow_done_date" onclick="utils.bindDate(this)"></td>\n' +
  140. ' <td><input type="text" class="form-control" name="duty_man"></td>'+
  141. ' </td>'+
  142. ' <td class="operateDel" onclick="utils.del(this)">删除</td>\n' +
  143. ' </tr>';
  144. $(_this).parent().parent().parent().next().append(str);
  145. $(".my-date").trigger('click');
  146. $('.my-select').selectpicker();
  147. },
  148. del: function (_this) {
  149. var mergedTd = $(_this).parent().parent().find(".mergedTd")
  150. var rowspan = mergedTd.attr('rowspan');
  151. mergedTd.attr('rowspan', rowspan - 1);
  152. $(_this).parent().remove();
  153. },
  154. addBig: function (_this) {
  155. var str = '<table class="my-table">\n' +
  156. ' <colgroup>\n' +
  157. ' <col style="width: 20%">\n' +
  158. ' <col style="width: 20%">\n' +
  159. ' <col style="width: 10%">\n' +
  160. ' <col style="width: 10%">\n' +
  161. ' <col style="width: 20%">\n' +
  162. ' <col style="width: 10%">\n' +
  163. ' </colgroup>\n' +
  164. ' <thead>\n' +
  165. ' <tr>\n' +
  166. ' <td>具体流程 <input type="hidden" value="0" name="infoId"> </td>\n' +
  167. ' <td>备注</td>\n' +
  168. ' <td>开始时间</td>\n' +
  169. ' <td>截止时间</td>\n' +
  170. ' <td>执行人</td>\n' +
  171. ' <td class="operateAdd">\n' +
  172. ' <a href="javascript:;" onclick="utils.add(this)">添加</a>\n' +
  173. ' </td>\n' +
  174. ' </tr>\n' +
  175. ' </thead>\n' +
  176. ' <tbody>\n' +
  177. ' <tr>\n' +
  178. ' <td><input type="text" class="form-control" name="flow_name"></td>\n' +
  179. ' <td><input type="text" class="form-control" name="flow_remark"></td>\n' +
  180. ' <td><input type="text" class="form-control my-date" name="flow_start_date" onclick="utils.bindDate(this)"></td>\n' +
  181. ' <td><input type="text" class="form-control my-date" name="flow_done_date" onclick="utils.bindDate(this)"></td>\n' +
  182. ' <td><input type="text" class="form-control" name="flow_remark"></td>\n' +
  183. ' <td class="operateDel" onclick="utils.del(this)">删除</td>\n' +
  184. ' </tr>\n' +
  185. ' </tbody>\n' +
  186. ' </table>';
  187. $(_this).next().next().append(str);
  188. $(".my-date").trigger('click');
  189. $('.my-select').selectpicker();
  190. },
  191. delBig: function (_this) {
  192. $(_this).parent().parent().parent().parent().remove()
  193. },
  194. delMain: function (_this) {
  195. $(_this).parent().remove()
  196. },
  197. addMain: function () {
  198. var str = ' <div class="mainStep">\n' +
  199. ' <h4 style="display: inline-block">优化步骤:<input type="text" class="form-control mainStepText"\n' +
  200. ' name="step_title" data-id="0"></h4>\n' +
  201. ' <a onclick="utils.delMain(this)">删除步骤</a>\n' +
  202. ' <div>\n' +
  203. ' <table class="my-table">\n' +
  204. ' <colgroup>\n' +
  205. ' <col style="width: 20%">\n' +
  206. ' <col style="width: 20%">\n' +
  207. ' <col style="width: 10%">\n' +
  208. ' <col style="width: 10%">\n' +
  209. ' <col style="width: 20%">\n' +
  210. ' <col style="width: 10%">\n' +
  211. ' </colgroup>\n' +
  212. ' <thead>\n' +
  213. ' <tr>\n' +
  214. ' <td>具体流程 <input type="hidden" value="0" name="infoId"> </td>\n' +
  215. ' <td>备注</td>\n' +
  216. ' <td>开始时间</td>\n' +
  217. ' <td>截止时间</td>\n' +
  218. ' <td>执行人</td>\n' +
  219. ' <td class="operateAdd">\n' +
  220. ' <a href="javascript:;" onclick="utils.add(this)">添加</a>\n' +
  221. ' </td>\n' +
  222. ' </tr>\n' +
  223. ' </thead>\n' +
  224. ' <tbody>\n' +
  225. ' <tr>\n' +
  226. ' <td><input type="text" class="form-control" name="flow_name"></td>\n' +
  227. ' <td><input type="text" class="form-control" name="flow_remark"></td>\n' +
  228. ' <td><input type="text" class="form-control my-date" name="flow_start_date" onclick="utils.bindDate(this)"></td>\n' +
  229. ' <td><input type="text" class="form-control my-date" name="flow_done_date" onclick="utils.bindDate(this)"></td>\n' +
  230. ' <td><input type="text" class="form-control" name="flow_name"></td>\n' +
  231. ' <td class="operateDel" onclick="utils.del(this)">删除</td>\n' +
  232. ' </tr>\n' +
  233. ' </tbody>\n' +
  234. ' </table>\n' +
  235. '\n' +
  236. ' </div>\n' +
  237. ' </div>';
  238. $("#main").append(str);
  239. $(".my-date").trigger('click');
  240. $('.my-select').selectpicker();
  241. },
  242. saveFlowTpl: function () {
  243. var flowAll = [];
  244. var errMsg = '';
  245. $(".mainStep").each(function () {
  246. var step_title_obj = $(this).find("[name=step_title]")
  247. var step_title = step_title_obj.val();
  248. var stepId = step_title_obj.data('id');
  249. var stepData = {step_title: step_title, step_id: stepId, children: []};
  250. if (!step_title) {
  251. errMsg += '优化步骤不能为空<br>';
  252. }
  253. $(this).find("table").each(function () {
  254. var flowData = {
  255. info_id: $(this).find("[name=infoId]").val(),
  256. children: []
  257. };
  258. $(this).find("tbody tr").each(function () {
  259. var flow_name = $(this).find("[name=flow_name]").val();
  260. var flow_remark = $(this).find("[name=flow_remark]").val();
  261. var flow_start_date = $(this).find("[name=flow_start_date]").val();
  262. var flow_done_date = $(this).find("[name=flow_done_date]").val();
  263. var duty_man = $(this).find("[name=duty_man]").val();
  264. if (!flow_name) {
  265. errMsg += '具体流程不能为空<br>';
  266. }
  267. var temp = {
  268. flow_name: flow_name,
  269. flow_remark: flow_remark,
  270. flow_start_date: flow_start_date,
  271. flow_done_date: flow_done_date,
  272. duty_man: duty_man
  273. };
  274. flowData.children.push(temp);
  275. });
  276. stepData.children.push(flowData);
  277. });
  278. flowAll.push(stepData);
  279. });
  280. if (errMsg !== '') {
  281. layer.alert(errMsg, {icon: 5});
  282. return;
  283. }
  284. var ajaxConfig = {
  285. url: '/admin/bqTraffic/optimizationProcessSave/{{$siteId}}',
  286. type: 'post',
  287. data: {
  288. dataList: flowAll
  289. }
  290. };
  291. tips.ajax(ajaxConfig);
  292. },
  293. bindDate: function (that) {
  294. var routeTime = {
  295. type: 'date',
  296. elem: that
  297. };
  298. laydate.render(routeTime);
  299. },
  300. };
  301. </script>
  302. @endsection