rent-list.blade.php 9.6 KB

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