site_task.blade.php 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409
  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. <link href="{{asset('js/plugins/jquery-pretty-radio-checkbox/css/jquery-labelauty.css')}}" rel="stylesheet">
  6. <style>
  7. .ul-content {
  8. margin: 0;
  9. padding: 0;
  10. list-style-type: none;
  11. }
  12. .ul-content li {
  13. padding: 20px 10px 10px;
  14. display: none;
  15. }
  16. .ul-content .active {
  17. display: block;
  18. }
  19. .my-table {
  20. margin-top: 10px;
  21. width: 100%;
  22. }
  23. .my-table tr {
  24. border: 1px solid #f1f1f1;
  25. }
  26. .my-table td {
  27. padding: 8px;
  28. }
  29. .operateAdd, .operateDel {
  30. font-weight: 600;
  31. cursor: pointer;
  32. text-align: center;
  33. }
  34. .mainStep {
  35. border: 1px solid #999;
  36. padding: 12px;
  37. margin-top: 20px;
  38. }
  39. .mainStepText {
  40. display: inline-block;
  41. width: 180px;
  42. }
  43. .my-select {
  44. /*width: 60% !important;*/
  45. }
  46. .radio-label,
  47. .radio-check {
  48. display: inline-block;
  49. position: relative;
  50. margin-right: 5px;
  51. }
  52. .radio-label input[type="checkbox"] {
  53. appearance: none; /*清楚默认样式*/
  54. -webkit-appearance: none;
  55. /* opacity: 0; */
  56. outline: none;
  57. position: absolute;
  58. z-index: 2;
  59. width: 6px;
  60. height: 6px;
  61. top: 10px;
  62. left: 10px;
  63. border-radius: 50%;
  64. background: #b4b4b4;
  65. }
  66. .radio-label label {
  67. display: inline-block;
  68. min-width: 50px;
  69. height: 24px;
  70. line-height: 24px;
  71. text-align: center;
  72. padding-right: 10px;
  73. border-radius: 5px;
  74. padding-left: 25px;
  75. color: #fff;
  76. background-color: #c9c9c9;
  77. }
  78. .radio-label input[type="checkbox"]:checked {
  79. opacity: 0;
  80. }
  81. .radio-label input[type="checkbox"]:checked + label {
  82. color: #fff;
  83. background-color: #3597db;
  84. }
  85. .radio-label input[type="checkbox"]:checked + label::after {
  86. content: "";
  87. position: absolute;
  88. left: 12px;
  89. top: 5px;
  90. width: 5px;
  91. height: 12px;
  92. border-right: 1px solid #fff;
  93. border-bottom: 1px solid #fff;
  94. transform: rotate(45deg);
  95. }
  96. .dropdown.bootstrap-select {
  97. width: 240px !important;
  98. }
  99. </style>
  100. @endsection
  101. @section('content')
  102. <div style="display: flex;justify-content: space-between;padding: 10px;">
  103. <select class="selectpicker form-control"
  104. id="site_ids" name="site_ids" data-live-search="true"
  105. title="请选择站点" autocomplete="off">
  106. <option value="">请选择站点</option>
  107. @foreach ($sites as $site)
  108. <option value="{{$site->id}}">{{$site->cn_title}}</option>
  109. @endforeach
  110. </select>
  111. <button type="button" class="btn btn-success" onclick="utils.saveFlow()">保存
  112. </button>
  113. </div>
  114. <ul class="ul-content">
  115. <li class="active">
  116. <form id="form">
  117. </form>
  118. </li>
  119. </ul>
  120. @endsection
  121. @section('footer_extend')
  122. <script src="https://cdn.jsdelivr.net/npm/bootstrap-select@1.13.9/dist/js/bootstrap-select.min.js"></script>
  123. <script src="{{asset('js/plugins/layDate-v5.0.9/laydate/laydate.js')}}"></script>
  124. <script>
  125. var site;
  126. var siteStatus;
  127. var role;
  128. var optimizationPersonnel;
  129. $("#site_ids").change(function () {
  130. var siteId = $('#site_ids').val();
  131. if (!siteId) {
  132. siteId = 0;
  133. }
  134. var ajaxConfig = {
  135. url: '/admin/work-task/site-status/' + siteId,
  136. type: 'post',
  137. /**
  138. * @param result.data.siteStatus int
  139. * @param result.data.tasksList array
  140. * @param result.data.rolesList array
  141. * @param result.data.optimizationPersonnel array
  142. */
  143. success: function (result) {
  144. var fulfil = [];
  145. var user = [];
  146. site = result.data.siteId;
  147. siteStatus = result.data.siteStatus;
  148. role = result.data.rolesList;
  149. optimizationPersonnel = result.data.optimizationPersonnel;
  150. var html =
  151. '<main id="main">' +
  152. '<table class="my-table">' +
  153. '<colgroup>' +
  154. '<col style="width:5%">' +
  155. '<col style="width:15%">' +
  156. '<col style="width:25%">' +
  157. '<col style="width:10%">' +
  158. '<col style="width:15%">' +
  159. '<col style="width:15%">' +
  160. '<col style="width:15%">' +
  161. '</colgroup>' +
  162. '<thead>' +
  163. '<tr>' +
  164. '<td class="operateAdd">' +
  165. '<a href="javascript:;" onclick="utils.add(this)"><i class="fa fa-plus" aria-hidden="true" style="font-size: 18px"></i></a>' +
  166. '</td>' +
  167. '<td>标题</td>' +
  168. '<td>内容</td>' +
  169. '<td>是否完成</td>' +
  170. '<td>安排时间</td>' +
  171. '<td>完成时间</td>' +
  172. '<td>人员</td>' +
  173. '</tr>' +
  174. '</thead>' +
  175. '<tbody>';
  176. if (result.data.infoList.length > 0) {
  177. $.each(result.data.tasksList, function (index, value) {
  178. var object = {};
  179. object.fulfil = value.fulfil;
  180. object.task_id = value.task_id;
  181. fulfil.push(object);
  182. var userObject = {};
  183. userObject.user_id = value.personnel;
  184. userObject.task_id = value.task_id;
  185. user.push(userObject);
  186. var title = value.title;
  187. if (!value.title) {
  188. title = '';
  189. }
  190. var data = value.data;
  191. if (!value.data) {
  192. data = '';
  193. }
  194. var flow_except_date = value.flow_except_date;
  195. if (!value.flow_except_date) {
  196. flow_except_date = '';
  197. }
  198. var initial_date = value.initial_date;
  199. if (!value.initial_date) {
  200. initial_date = '';
  201. }
  202. html +=
  203. '<tr>' +
  204. '<td class="operateDel" onclick="utils.del(this)"><i class="fa fa-times" aria-hidden="true" style="font-size:18px"></i></td>' +
  205. '<td>' +
  206. '<input type="text" class="form-control" name="title" value="' + title + '"></td>' +
  207. '<td>' +
  208. '<input type="text" class="form-control" name="data" value="' + data + '"></td>' +
  209. '<td>' +
  210. '<select class="form-control" id="fulfil' + value.task_id + '" name="fulfil">' +
  211. '<option value="1">未完成</option>' +
  212. '<option value="2">完成</option>' +
  213. '</select>' +
  214. '</td>' +
  215. '<td>' +
  216. '<input type="text" class="form-control deadline" name="initial_date" value="' + initial_date + '" autocomplete="off">' +
  217. '</td>' +
  218. '<td>' +
  219. '<input type="text" class="form-control deadline" name="flow_except_date" value="' + flow_except_date + '" autocomplete="off">' +
  220. '</td>' +
  221. '<td>' +
  222. '<select class="my-select" id="personnel' + value.task_id + '" name="personnel" data-container="body" data-live-search="true">';
  223. html += '<option value="0">请选择人员</option>';
  224. $.each(result.data.optimizationPersonnel, function (kk, vv) {
  225. html += '<option value="' + vv.id + '">' + vv.nickname + '</option>';
  226. });
  227. html += '</select>' +
  228. '</td>' +
  229. '</tr>';
  230. });
  231. }
  232. html += '</tbody>' +
  233. '</table>' +
  234. '</main>';
  235. var object = $('#form');
  236. object.empty();
  237. object.append(html);
  238. //时间插件
  239. lay('.deadline').each(function () {
  240. laydate.render({
  241. elem: this
  242. , trigger: 'click'
  243. });
  244. });
  245. $('.my-select').selectpicker();
  246. if (result.data.infoList.length > 0) {
  247. $.each(result.data.infoList, function (index, value) {
  248. $('#color' + value).attr('checked', 'checked');
  249. });
  250. }
  251. if (fulfil.length > 0) {
  252. $.each(fulfil, function (index, value) {
  253. $('#fulfil' + value.task_id).val(value.fulfil);
  254. });
  255. }
  256. if (user.length > 0) {
  257. $.each(user, function (index, value) {
  258. $('#personnel' + value.task_id).val(value.user_id).trigger("change");
  259. });
  260. }
  261. }
  262. };
  263. tips.ajax(ajaxConfig);
  264. });
  265. var utils = {
  266. add: function (_this) {
  267. var rowspan = $(_this).parent().next().attr('rowspan');
  268. $(_this).parent().next().attr('rowspan', rowspan + 1);
  269. var str =
  270. '<tr>' +
  271. '<td class="operateDel" onclick="utils.del(this)"><i class="fa fa-times" aria-hidden="true" style="font-size:18px"></i></td>' +
  272. '<td>' +
  273. '<input type="text" class="form-control" name="title">' +
  274. '</td>' +
  275. '<td>' +
  276. '<input type="text" class="form-control" name="data">' +
  277. '</td>' +
  278. '<td>' +
  279. '<select class="form-control" id="fulfil" name="fulfil">' +
  280. '<option value="1" >未完成</option>' +
  281. '<option value="2" >完成</option>' +
  282. '</select>' +
  283. '</td>' +
  284. '<td>' +
  285. '<input type="text" class="form-control deadline" name="initial_date" autocomplete="off" value="{{$date}}">' +
  286. '</td>' +
  287. '<td>' +
  288. '<input type="text" class="form-control deadline" name="flow_except_date" autocomplete="off">' +
  289. '</td>' +
  290. '<td>' +
  291. '<select class="my-select" id="personnel" name="personnel" data-container="body" data-live-search="true">';
  292. str += '<option value="0">请选择人员</option>';
  293. $.each(optimizationPersonnel, function (kk, vv) {
  294. str += '<option value="' + vv.id + '">' + vv.nickname + '</option>';
  295. });
  296. str += '</select>' +
  297. '</td>' +
  298. '</tr>';
  299. $(_this).parent().parent().parent().next().prepend(str);
  300. //时间插件
  301. lay('.deadline').each(function () {
  302. laydate.render({
  303. elem: this
  304. , trigger: 'click'
  305. });
  306. });
  307. $('.my-select').selectpicker();
  308. },
  309. del: function (_this) {
  310. $(_this).parent().remove();
  311. },
  312. saveFlow: function () {
  313. var flowData = [];
  314. var infoList = [];
  315. $('input[name="info"]:checked').each(function () {
  316. infoList.push($(this).val());
  317. });
  318. var list = infoList.toString();
  319. $(".my-table").each(function () {
  320. $(this).find("tbody tr").each(function () {
  321. var title = $(this).find("[name=title]").val();
  322. var data = $(this).find("[name=data]").val();
  323. var flow_except_date = $(this).find("[name=flow_except_date]").val();
  324. var initial_date = $(this).find("[name=initial_date]").val();
  325. var fulfil = $(this).find("[name=fulfil]").val();
  326. var personnel = $(this).find("[name=personnel]").val();
  327. var temp = {
  328. title: title,
  329. data: data,
  330. fulfil: fulfil,
  331. flow_except_date: flow_except_date,
  332. initial_date: initial_date,
  333. personnel: personnel
  334. }
  335. ;
  336. flowData.push(temp);
  337. });
  338. });
  339. var ajaxConfig = {
  340. url: '/admin/work-task/save/siteId/' + site + '/status/' + siteStatus,
  341. type: 'post',
  342. data: {
  343. infoList: list,
  344. dataList: flowData
  345. },
  346. success: function () {
  347. layer.msg('操作成功', {
  348. icon: 1,
  349. time: 1500 //2秒关闭(如果不配置,默认是3秒)
  350. }, function () {
  351. parent.location.reload()
  352. });
  353. }
  354. };
  355. tips.ajax(ajaxConfig);
  356. }
  357. };
  358. </script>
  359. @endsection