rent-list.blade.php 9.8 KB

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