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