apply-index.blade.php 11 KB

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