apply-index.blade.php 10 KB

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