all.blade.php 12 KB

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