apply-list.blade.php 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  1. @extends('admin.layout-content')
  2. @section('header')
  3. <style>
  4. </style>
  5. @endsection
  6. @section('content')
  7. <div class="layui-card">
  8. <div class="layui-card-header sg-card-header">
  9. 调用订单设备列表
  10. </div>
  11. <div class="layui-card-body">
  12. <form class="layui-form" id="sg-search-form">
  13. <input type="hidden" name="type" value="apply">
  14. {{--<div class="layui-form-item layui-row">--}}
  15. {{--<div class="layui-inline">--}}
  16. {{--<div class="layui-input-inline">--}}
  17. {{--<input type="text" name="name" placeholder="请输入名称" autocomplete="off" class="layui-input" value="{{ request('name') }}">--}}
  18. {{--</div>--}}
  19. {{--</div>--}}
  20. {{--<div class="layui-inline">--}}
  21. {{--<div class="layui-btn" id="sg-search-btn">搜索</div>--}}
  22. {{--</div>--}}
  23. {{--</div>--}}
  24. </form>
  25. <table id="sg-main-table" class="layui-hide" lay-filter="tableEvent"></table>
  26. <script type="text/html" id="sg-table-bar">
  27. <div class="layui-btn-group">
  28. <div class="layui-btn-group">
  29. <a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
  30. <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="delete">删除</a>
  31. </div>
  32. </div>
  33. </script>
  34. </div>
  35. </div>
  36. @endsection
  37. @section('footer')
  38. <script>
  39. $(function () {
  40. layui.use(['table', 'layer'], function(){
  41. var table = layui.table,
  42. layer = layui.layer,
  43. form = layui.form,
  44. laydate = layui.laydate,
  45. top_window = window;
  46. $('#sg-back-btn').on('click', function () {
  47. window.history.go(-1);
  48. });
  49. table.render({
  50. elem: '#sg-main-table',
  51. url: '{{ $pre_uri }}' + 'get',
  52. cellMinWidth: 80,
  53. cols: [[
  54. { field: 'id', title: 'ID', align: 'center' },
  55. { field: 'order_id', title: '订单ID', align: 'center' },
  56. { field: 'number', title: '固定资产编号', align: 'center' },
  57. { field: 'device_name_name', title: '租赁设备名称', align: 'center' },
  58. { field: 'spec_name', title: '设备规格型号', align: 'center' },
  59. { field: 'work_point_name', title: '目前在用工点', align: 'center' },
  60. { field: 'start_date', title: '调用开始时间', align: 'center' },
  61. { field: 'end_date', title: '调用结束时间', align: 'center' },
  62. { field: 'status_label', title: '设备状态', align: 'center' },
  63. // { title: '操作', align:'center', toolbar: '#sg-table-bar' }
  64. ]],
  65. page: {
  66. layout: ['count', 'prev', 'page', 'next', 'skip', 'refresh'],
  67. limit: 15
  68. },
  69. even: true,
  70. where: transformToJson($('#sg-search-form').serializeArray()),
  71. done: function(res, curr, count) {
  72. }
  73. });
  74. table.on('tool(tableEvent)', function(obj){
  75. var data = obj.data;
  76. if(obj.event === 'delete'){
  77. layer.confirm('确定要删除吗?', function(index) {
  78. $.ajax({
  79. method: 'POST',
  80. url: '{{ $pre_uri }}' + 'delete',
  81. headers: {
  82. 'X-CSRF-TOKEN': '{{ csrf_token() }}'
  83. },
  84. data: {
  85. id: data.id
  86. },
  87. success: function (data) {
  88. if(data.status === 'success') {
  89. obj.del();
  90. } else {
  91. layer.msg(data.info, {
  92. icon: 2
  93. });
  94. }
  95. layer.close(index);
  96. },
  97. error: function () {
  98. layer.close(index);
  99. layer.msg('删除失败', {
  100. icon: 2
  101. });
  102. }
  103. });
  104. });
  105. } else if(obj.event === 'edit') {
  106. layer.open({
  107. title: '编辑成员',
  108. type: 2,
  109. area: ['90%', '90%'],
  110. content: '{{ $pre_uri }}' + 'edit?id=' + data.id,
  111. end: function () {
  112. top_window.location.reload();
  113. }
  114. });
  115. }
  116. });
  117. if($('#search-begin-date').length > 0) {
  118. laydate.render({
  119. elem: '#search-begin-date',
  120. done: function () {
  121. updateTableBySearch();
  122. }
  123. });
  124. }
  125. if($('#search-end-date').length > 0) {
  126. laydate.render({
  127. elem: '#search-end-date',
  128. done: function () {
  129. updateTableBySearch();
  130. }
  131. });
  132. }
  133. function transformToJson(formData){
  134. var obj={};
  135. for (var i in formData) {
  136. obj[formData[i].name]=formData[i]['value'];
  137. }
  138. return obj;
  139. }
  140. function updateTableBySearch() {
  141. table.reload('sg-main-table', {
  142. where: transformToJson($('#sg-search-form').serializeArray()),
  143. page: {
  144. curr: 1
  145. }
  146. });
  147. }
  148. $('#sg-search-btn').click(function() {
  149. updateTableBySearch();
  150. });
  151. // $('#sg-search-form').change(function () {
  152. // updateTableBySearch();
  153. // });
  154. //
  155. // form.on('select()', function(){
  156. // updateTableBySearch();
  157. // });
  158. $('#sg-create-btn').on('click', function () {
  159. layer.open({
  160. title: '创建' + '{{ $model_name }}',
  161. type: 2,
  162. area: ['90%', '90%'],
  163. content: '{{ $pre_uri }}' + 'create',
  164. end: function () {
  165. top_window.location.reload();
  166. }
  167. });
  168. });
  169. $('#sg-table-top-container').on('click', '.btn-delete-many', function () {
  170. layer.confirm('确定要删除所有选中行吗?', function () {
  171. var data = table.checkStatus('sg-main-table').data;
  172. if(data.length <= 0) {
  173. layer.msg('选择不能为空', {
  174. icon: 2
  175. });
  176. return false;
  177. }
  178. var ids = [];
  179. for(var i = 0; i < data.length; ++i) {
  180. ids.push(data[i]['id']);
  181. }
  182. $.ajax({
  183. method: 'POST',
  184. url: '{{ $pre_uri }}' + 'deleteMany',
  185. headers: {
  186. 'X-CSRF-TOKEN': '{{ csrf_token() }}'
  187. },
  188. data: {
  189. ids: JSON.stringify(ids)
  190. },
  191. success: function (data) {
  192. if(data.status === 'success') {
  193. top_window.location.reload();
  194. } else {
  195. layer.msg(data.info, {
  196. icon: 2
  197. });
  198. }
  199. },
  200. error: function () {
  201. layer.msg('删除失败', {
  202. icon: 2
  203. });
  204. }
  205. });
  206. })
  207. });
  208. });
  209. })
  210. </script>
  211. @endsection