apply-list.blade.php 11 KB

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