apply-index.blade.php 12 KB

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