tpl.blade.php 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348
  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="nav nav-tabs">
  46. <li><a href="/admin/flow/sites/{{$siteId}}">流程</a></li>
  47. <li class="active"><a>模板</a></li>
  48. </ul>
  49. <ul class="ul-content">
  50. <li class="active">
  51. <main id="main">
  52. <button type="button" class="btn btn-success" onclick="utils.addMain()">新增步骤</button>
  53. <button type="button" class="btn btn-info" onclick="utils.saveFlowTpl()">保存</button>
  54. @foreach($tplStageList as $stage)
  55. <div class="mainStep">
  56. <h4 style="display: inline-block">建站步骤:<input type="text" class="form-control mainStepText"
  57. name="step_title" value="{{$stage->title}}"
  58. data-id="{{$stage->id}}"
  59. style="width: 260px;display: inline-block">
  60. </h4>
  61. <a onclick="utils.addBig(this)">添加大流程</a>
  62. <a onclick="utils.delMain(this)">删除步骤</a>
  63. <div>
  64. @foreach($stage->infoTplList as $info)
  65. <table class="my-table">
  66. <colgroup>
  67. <col span="3" style="width: 20%">
  68. <col style="width: 12%">
  69. <col style="width: 10%">
  70. <col style="width: 18%">
  71. </colgroup>
  72. <thead>
  73. <tr>
  74. <td>具体流程 <input type="hidden" value="{{$info->id}}" name="infoId"></td>
  75. <td>备注</td>
  76. <td>完成时间</td>
  77. <td>对接人</td>
  78. <td class="operateAdd">
  79. <a href="javascript:;" onclick="utils.add(this)">添加</a>
  80. <a href="javascript:" onclick="utils.delBig(this)">删除大流程</a>
  81. </td>
  82. </tr>
  83. </thead>
  84. <tbody class="connectedSortable">
  85. @foreach($info->detail_list as $item)
  86. <tr>
  87. <td><input type="text" class="form-control" name="flow_name"
  88. value="{{$item['flow_name']}}"></td>
  89. <td><input type="text" class="form-control" name="flow_remark"
  90. value="{{$item['flow_remark']}}"></td>
  91. <td><input type="text" class="form-control my-date"
  92. onclick="utils.bindDate(this)" name="flow_done_date"
  93. value="{{$item['flow_done_date']}}"></td>
  94. <td>
  95. <select name="duty_man" class="my-select" multiple
  96. data-container="body">
  97. @foreach(\App\Http\Models\FlowInfoTpl::RoleScope as $roleId=>$roleName)
  98. <option value="{{$roleId}}"
  99. @if(is_array($item['duty_man']) && in_array($roleId,$item['duty_man'])) selected @endif>
  100. {{$roleName}}
  101. </option>
  102. @endforeach
  103. </select>
  104. </td>
  105. <td class="operateDel" onclick="utils.del(this)">删除</td>
  106. </tr>
  107. @endforeach
  108. </tbody>
  109. </table>
  110. @endforeach
  111. </div>
  112. </div>
  113. @endforeach
  114. </main>
  115. </li>
  116. </ul>
  117. @endsection
  118. @section('footer_extend')
  119. <script src="https://cdn.jsdelivr.net/npm/bootstrap-select@1.13.9/dist/js/bootstrap-select.min.js"></script>
  120. <script src="{{asset('js/plugins/layDate-v5.0.9/laydate/laydate.js')}}"></script>
  121. <script src="{{asset('js/jquery-ui-1.10.4.min.js')}}"></script>
  122. <script>
  123. $(function () {
  124. $('.my-select').selectpicker({
  125. liveSearch: true
  126. });
  127. $("tbody").sortable({
  128. connectWith: ".connectedSortable"
  129. }).disableSelection();
  130. });
  131. $(function () {
  132. $(".my-date").trigger('click');
  133. $('.my-select').selectpicker();
  134. });
  135. var utils = {
  136. add: function (_this) {
  137. var rowspan = $(_this).parent().next().attr('rowspan');
  138. $(_this).parent().next().attr('rowspan', rowspan + 1)
  139. var str = ' <tr>\n' +
  140. ' <td><input type="text" class="form-control" name="flow_name"></td>\n' +
  141. ' <td><input type="text" class="form-control" name="flow_remark"></td>\n' +
  142. ' <td><input type="text" class="form-control my-date" name="flow_done_date" onclick="utils.bindDate(this)"></td>\n' +
  143. ' <td>\n' +
  144. ' <select name="duty_man" class="my-select" multiple data-container="body">\n' +
  145. @foreach(\App\Http\Models\FlowInfoTpl::RoleScope as $roleId=>$roleName)
  146. ' <option value="{{$roleId}}">{{$roleName}}</option>' +
  147. @endforeach
  148. ' </select>' +
  149. ' </td>\n' +
  150. ' <td class="operateDel" onclick="utils.del(this)">删除</td>\n' +
  151. ' </tr>';
  152. $(_this).parent().parent().parent().next().append(str);
  153. $(".my-date").trigger('click');
  154. $('.my-select').selectpicker();
  155. },
  156. del: function (_this) {
  157. var mergedTd = $(_this).parent().parent().find(".mergedTd")
  158. var rowspan = mergedTd.attr('rowspan');
  159. mergedTd.attr('rowspan', rowspan - 1);
  160. $(_this).parent().remove();
  161. },
  162. addBig: function (_this) {
  163. var str = '<table class="my-table">\n' +
  164. ' <colgroup>\n' +
  165. ' <col span="3" style="width: 20%">\n' +
  166. ' <col style="width: 12%">\n' +
  167. ' <col style="width: 10%">\n' +
  168. ' <col style="width: 18%">\n' +
  169. ' </colgroup>\n' +
  170. ' <thead>\n' +
  171. ' <tr>\n' +
  172. ' <td>具体流程 <input type="hidden" value="0" name="infoId"> </td>\n' +
  173. ' <td>备注</td>\n' +
  174. '\n' +
  175. ' <td>完成时间</td>\n' +
  176. ' <td>对接人</td>\n' +
  177. ' <td class="operateAdd">\n' +
  178. ' <a href="javascript:;" onclick="utils.add(this)">添加</a>\n' +
  179. ' <a href="javascript:" onclick="utils.delBig(this)">删除大流程</a>\n' +
  180. ' </td>\n' +
  181. ' </tr>\n' +
  182. ' </thead>\n' +
  183. ' <tbody>\n' +
  184. ' <tr>\n' +
  185. ' <td><input type="text" class="form-control" name="flow_name"></td>\n' +
  186. ' <td><input type="text" class="form-control" name="flow_remark"></td>\n' +
  187. ' <td><input type="text" class="form-control my-date" name="flow_done_date" onclick="utils.bindDate(this)"></td>\n' +
  188. ' <td>\n' +
  189. ' <select name="duty_man" class="my-select" multiple data-container="body">\n' +
  190. @foreach(\App\Http\Models\FlowInfoTpl::RoleScope as $roleId=>$roleName)
  191. ' <option value="{{$roleId}}">{{$roleName}}</option>' +
  192. @endforeach
  193. ' </select>\n' +
  194. ' </td>\n' +
  195. ' <td class="operateDel" onclick="utils.del(this)">删除</td>\n' +
  196. ' </tr>\n' +
  197. ' </tbody>\n' +
  198. ' </table>';
  199. $(_this).next().next().append(str);
  200. $(".my-date").trigger('click');
  201. $('.my-select').selectpicker();
  202. },
  203. delBig: function (_this) {
  204. $(_this).parent().parent().parent().parent().remove()
  205. },
  206. delMain: function (_this) {
  207. $(_this).parent().remove()
  208. },
  209. addMain: function () {
  210. var str = ' <div class="mainStep">\n' +
  211. ' <h4 style="display: inline-block">建站步骤:<input type="text" class="form-control mainStepText"\n' +
  212. ' name="step_title" data-id="0"></h4>\n' +
  213. ' <a onclick="utils.addBig(this)">添加大流程</a>\n' +
  214. ' <a onclick="utils.delMain(this)">删除步骤</a>\n' +
  215. ' <div>\n' +
  216. ' <table class="my-table">\n' +
  217. ' <colgroup>\n' +
  218. ' <col span="3" style="width: 20%">\n' +
  219. ' <col style="width: 12%">\n' +
  220. ' <col style="width: 10%">\n' +
  221. ' <col style="width: 18%">\n' +
  222. ' </colgroup>\n' +
  223. ' <thead>\n' +
  224. ' <tr>\n' +
  225. ' <td>具体流程 <input type="hidden" value="0" name="infoId"> </td>\n' +
  226. ' <td>备注</td>\n' +
  227. '\n' +
  228. ' <td>完成时间</td>\n' +
  229. ' <td>对接人</td>\n' +
  230. ' <td class="operateAdd">\n' +
  231. ' <a href="javascript:;" onclick="utils.add(this)">添加</a>\n' +
  232. ' <a href="javascript:" onclick="utils.delBig(this)">删除大流程</a>\n' +
  233. ' </td>\n' +
  234. ' </tr>\n' +
  235. ' </thead>\n' +
  236. ' <tbody>\n' +
  237. ' <tr>\n' +
  238. ' <td><input type="text" class="form-control" name="flow_name"></td>\n' +
  239. ' <td><input type="text" class="form-control" name="flow_remark"></td>\n' +
  240. ' <td><input type="text" class="form-control my-date" name="flow_done_date" onclick="utils.bindDate(this)"></td>\n' +
  241. ' <td>\n' +
  242. ' <select name="duty_man" class="my-select" multiple data-container="body">\n' +
  243. @foreach(\App\Http\Models\FlowInfoTpl::RoleScope as $roleId=>$roleName)
  244. '<option value="{{$roleId}}">{{$roleName}}</option>' +
  245. @endforeach
  246. ' </select>\n' +
  247. ' </td>\n' +
  248. ' <td class="operateDel" onclick="utils.del(this)">删除</td>\n' +
  249. ' </tr>\n' +
  250. ' </tbody>\n' +
  251. ' </table>\n' +
  252. '\n' +
  253. ' </div>\n' +
  254. ' </div>';
  255. $("#main").append(str);
  256. $(".my-date").trigger('click');
  257. $('.my-select').selectpicker();
  258. },
  259. saveFlowTpl: function () {
  260. var flowAll = [];
  261. var errMsg = '';
  262. $(".mainStep").each(function () {
  263. var step_title_obj = $(this).find("[name=step_title]")
  264. var step_title = step_title_obj.val();
  265. var stepId = step_title_obj.data('id');
  266. var stepData = {step_title: step_title, step_id: stepId, children: []};
  267. if (!step_title) {
  268. errMsg += '建站步骤不能为空<br>';
  269. }
  270. $(this).find("table").each(function () {
  271. var flowData = {
  272. info_id: $(this).find("[name=infoId]").val(),
  273. children: []
  274. };
  275. $(this).find("tbody tr").each(function () {
  276. var flow_name = $(this).find("[name=flow_name]").val();
  277. var flow_remark = $(this).find("[name=flow_remark]").val();
  278. var flow_done_date = $(this).find("[name=flow_done_date]").val();
  279. var duty_man = $(this).find("[name=duty_man]").val();
  280. if (!flow_name) {
  281. errMsg += '具体流程不能为空<br>';
  282. }
  283. var temp = {
  284. flow_name: flow_name,
  285. flow_remark: flow_remark,
  286. flow_done_date: flow_done_date,
  287. duty_man: duty_man
  288. };
  289. flowData.children.push(temp);
  290. });
  291. stepData.children.push(flowData);
  292. });
  293. flowAll.push(stepData);
  294. });
  295. if (errMsg !== '') {
  296. layer.alert(errMsg, {icon: 5});
  297. return;
  298. }
  299. var ajaxConfig = {
  300. url: '/admin/flow-tpl-save/sites/{{$siteId}}',
  301. type: 'post',
  302. data: {
  303. dataList: flowAll
  304. }
  305. };
  306. tips.ajax(ajaxConfig);
  307. },
  308. bindDate: function (that) {
  309. var routeTime = {
  310. type: 'date',
  311. elem: that
  312. };
  313. laydate.render(routeTime);
  314. },
  315. };
  316. </script>
  317. @endsection