all.blade.php 9.9 KB

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