index.blade.php 11 KB

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