all.blade.php 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
  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>
  11. <div class="layui-card-body">
  12. <form class="layui-form" id="sg-search-form">
  13. <div class="layui-form-item layui-row">
  14. <div class="layui-inline">
  15. <div class="layui-input-inline">
  16. <select name="inner_device_name">
  17. <option value="0">设备名称</option>
  18. @foreach($inner_device_name as $option)
  19. <option value="{{ $option['id'] }}" {{ request('inner_device_name') == $option['id'] ? 'selected' : '' }}>{{ $option['name'] }}</option>
  20. @endforeach
  21. </select>
  22. </div>
  23. </div>
  24. <div class="layui-inline">
  25. <div class="layui-input-inline">
  26. <select name="status_label">
  27. <option value="0">状态</option>
  28. @foreach($status_label as $option)
  29. <option value="{{ $option['id'] }}" {{ request('status_label') == $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="part">维修清单列表</a>
  44. <a class="layui-btn layui-btn-xs layui-btn-danger" 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: 'id', title: 'ID', align: 'center' },
  69. { field: 'number', title: '固定资产编号', align: 'center' },
  70. { field: 'device_name', title: '设备名称', align: 'center' },
  71. { field: 'spec_name', title: '规格型号', align: 'center' },
  72. { field: 'project_name', title: '所在项目', align: 'center' },
  73. { field: 'status_label', title: '状态', align: 'center' },
  74. // { field: 'work_point_name', title: '上报工点', align: 'center' },
  75. { field: 'money', title: '维修总金额', align: 'center' },
  76. { field: 'reason', title: '维修原因', align: 'center' },
  77. { field: 'day', title: '维修日期', align: 'center' },
  78. { field: 'user_name', title: '提交人', align: 'center' },
  79. { field: 'user_phone', title: '联系电话', align: 'center' },
  80. { field: 'remark', title: '备注', align: 'center' },
  81. { title: '操作', align:'center', toolbar: '#sg-table-bar' }
  82. ]],
  83. page: {
  84. layout: ['count', 'prev', 'page', 'next', 'skip', 'refresh'],
  85. limit: 15
  86. },
  87. even: true,
  88. where: transformToJson($('#sg-search-form').serializeArray()),
  89. done: function(res, curr, count) {
  90. }
  91. });
  92. table.on('tool(tableEvent)', function(obj){
  93. var data = obj.data;
  94. if(obj.event === 'delete'){
  95. layer.confirm('确定要删除吗?', function(index) {
  96. $.ajax({
  97. method: 'POST',
  98. url: '{{ $pre_uri }}' + 'delete',
  99. headers: {
  100. 'X-CSRF-TOKEN': '{{ csrf_token() }}'
  101. },
  102. data: {
  103. id: data.id
  104. },
  105. success: function (data) {
  106. if(data.status === 'success') {
  107. obj.del();
  108. } else {
  109. layer.msg(data.info, {
  110. icon: 2
  111. });
  112. }
  113. layer.close(index);
  114. },
  115. error: function () {
  116. layer.close(index);
  117. layer.msg('删除失败', {
  118. icon: 2
  119. });
  120. }
  121. });
  122. });
  123. } else if(obj.event === 'edit') {
  124. layer.open({
  125. title: '编辑成员',
  126. type: 2,
  127. area: ['90%', '90%'],
  128. content: '{{ $pre_uri }}' + 'edit?id=' + data.id,
  129. end: function () {
  130. top_window.location.reload();
  131. }
  132. });
  133. } else if(obj.event === 'part') {
  134. layer.open({
  135. title: '维修部件',
  136. type: 2,
  137. area: ['90%', '90%'],
  138. content: '/admin/Part/index?repair_device_id=' + data.id,
  139. end: function () {
  140. top_window.location.reload();
  141. }
  142. });
  143. }
  144. });
  145. if($('#search-begin-date').length > 0) {
  146. laydate.render({
  147. elem: '#search-begin-date',
  148. done: function () {
  149. updateTableBySearch();
  150. }
  151. });
  152. }
  153. if($('#search-end-date').length > 0) {
  154. laydate.render({
  155. elem: '#search-end-date',
  156. done: function () {
  157. updateTableBySearch();
  158. }
  159. });
  160. }
  161. function transformToJson(formData){
  162. var obj={};
  163. for (var i in formData) {
  164. obj[formData[i].name]=formData[i]['value'];
  165. }
  166. return obj;
  167. }
  168. function updateTableBySearch() {
  169. table.reload('sg-main-table', {
  170. where: transformToJson($('#sg-search-form').serializeArray()),
  171. page: {
  172. curr: 1
  173. }
  174. });
  175. }
  176. $('#sg-search-btn').click(function() {
  177. updateTableBySearch();
  178. });
  179. // $('#sg-search-form').change(function () {
  180. // updateTableBySearch();
  181. // });
  182. //
  183. // form.on('select()', function(){
  184. // updateTableBySearch();
  185. // });
  186. $('#sg-create-btn').on('click', function () {
  187. layer.open({
  188. title: '创建' + '{{ $model_name }}',
  189. type: 2,
  190. area: ['90%', '90%'],
  191. content: '{{ $pre_uri }}' + 'create',
  192. end: function () {
  193. top_window.location.reload();
  194. }
  195. });
  196. });
  197. $('#sg-table-top-container').on('click', '.btn-delete-many', function () {
  198. layer.confirm('确定要删除所有选中行吗?', function () {
  199. var data = table.checkStatus('sg-main-table').data;
  200. if(data.length <= 0) {
  201. layer.msg('选择不能为空', {
  202. icon: 2
  203. });
  204. return false;
  205. }
  206. var ids = [];
  207. for(var i = 0; i < data.length; ++i) {
  208. ids.push(data[i]['id']);
  209. }
  210. $.ajax({
  211. method: 'POST',
  212. url: '{{ $pre_uri }}' + 'deleteMany',
  213. headers: {
  214. 'X-CSRF-TOKEN': '{{ csrf_token() }}'
  215. },
  216. data: {
  217. ids: JSON.stringify(ids)
  218. },
  219. success: function (data) {
  220. if(data.status === 'success') {
  221. top_window.location.reload();
  222. } else {
  223. layer.msg(data.info, {
  224. icon: 2
  225. });
  226. }
  227. },
  228. error: function () {
  229. layer.msg('删除失败', {
  230. icon: 2
  231. });
  232. }
  233. });
  234. })
  235. });
  236. });
  237. })
  238. </script>
  239. @endsection