index.blade.php 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. @extends('admin/layout')
  2. @section('content')
  3. <body class="gray-bg">
  4. <div class="wrapper wrapper-content animated fadeInRight">
  5. <div class="row">
  6. <div class="col-sm-12">
  7. <div class="ibox float-e-margins">
  8. <div class="ibox-content">
  9. <form class="row" id="searchForm">
  10. <div class="col-md-2">
  11. <div class="input-group">
  12. <span class="input-group-btn">
  13. <button type="button" class="btn btn-md btn-primary" onclick="units.save(0)"
  14. style="margin-left: 10px"> <span class="glyphicon glyphicon-plus"></span> 添加</button>
  15. <button type="button" class="btn btn-md btn-danger" onclick="units.batchDelete()"
  16. style="margin-left: 10px"><span
  17. class="glyphicon glyphicon-remove"></span> 删除</button>
  18. <button type="button" class="btn btn-md btn-info" onclick="units.toggleStatus(1)"
  19. style="margin-left: 10px"><span
  20. class="glyphicon glyphicon-remove"></span> 启用</button>
  21. <button type="button" class="btn btn-md btn-warning"
  22. onclick="units.toggleStatus(0)"
  23. style="margin-left: 10px"><span
  24. class="glyphicon glyphicon-remove"></span> 禁用</button>
  25. </span>
  26. </div>
  27. </div>
  28. </form>
  29. <hr>
  30. <div class="table-responsive">
  31. <table id="table" class="table table-condensed" data-mobile-responsive="true"></table>
  32. </div>
  33. </div>
  34. </div>
  35. </div>
  36. </div>
  37. </div>
  38. </body>
  39. @endsection
  40. @section('footer')
  41. <script>
  42. var units = {
  43. getIdsBySelections: function () {
  44. var selections = $("#table").bootstrapTable('getSelections');
  45. var ids = [];
  46. $.each(selections, function (inx, val) {
  47. ids.push(val.id);
  48. });
  49. return ids;
  50. },
  51. save: function (id) {
  52. layer.open({
  53. type: 2,
  54. content: ['/admin/products/' + id],
  55. area: ['60%', '60%'],
  56. title: '保存'
  57. });
  58. },
  59. search: function () {
  60. tips.selectPage();
  61. },
  62. batchDelete: function () {
  63. var ids = units.getIdsBySelections();
  64. if (ids.length === 0) {
  65. layer.alert('请先选择您所要操作的对象', {icon: 0});
  66. return;
  67. }
  68. layer.confirm('您确定要删除吗?', {icon: 3, title: '删除信息'}, function (index, layero) {
  69. layer.close(index);
  70. tips.ajax({url: '/admin/products', type: 'delete', data: {ids: ids}, tableRefresh: '#table'});
  71. });
  72. },
  73. toggleStatus: function (toggleStatus) {
  74. var ids = units.getIdsBySelections();
  75. if (ids.length === 0) {
  76. layer.alert('请先选择您所要操作的对象', {icon: 0});
  77. return;
  78. }
  79. layer.confirm('您确定要继续此操作吗?', {icon: 3, title: '状态切换'}, function (index, layero) {
  80. layer.close(index);
  81. tips.ajax({
  82. url: '/admin/products/status',
  83. type: 'put',
  84. data: {ids: ids, toggle: toggleStatus},
  85. tableRefresh: '#table'
  86. });
  87. });
  88. }
  89. };
  90. var config = {};
  91. config.url = '/admin/products';
  92. config.columns = [ //字段
  93. {checkbox: true},
  94. {
  95. title: '序号', align: 'center', formatter: function (value, item, index) {
  96. return index + 1;
  97. }
  98. },
  99. {title: '产品名称', field: 'title', align: 'center'},
  100. {title: '备注', field: 'remark', align: 'center'},
  101. {title: '状态', field: 'status_title', align: 'center'},
  102. {title: '创建时间', field: 'created_at', align: 'center'},
  103. {
  104. title: '操作', field: 'id', align: 'center',
  105. formatter: function (value, row) {
  106. var str = '';
  107. str += '<button onclick="units.save(' + value + ')" class="btn btn-xs"><span class="glyphicon glyphicon-edit"></span>编辑</button>&nbsp;';
  108. // str += '<button onclick="units.delete(' + value + ')" class="btn btn-xs"><span class="glyphicon glyphicon-del"></span>删除</button>';
  109. return str;
  110. }
  111. }
  112. ];
  113. tips.bootstrapTable(config);
  114. </script>
  115. @endsection