index.blade.php 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  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-title"></div>
  9. <div class="ibox-content">
  10. <form class="row" id="searchForm">
  11. <div class="col-md-4">
  12. <div class="input-group">
  13. <span class="input-group-btn">
  14. <button type="button" class="btn btn-md btn-info"
  15. onclick="units.statusToggle(1)"><span
  16. class="glyphicon glyphicon-hand-up"></span> 启用</button>
  17. <button type="button" class="btn btn-md btn-warning"
  18. onclick="units.statusToggle(0)"
  19. style="margin-left: 10px"><span
  20. class="glyphicon glyphicon-hand-down"></span> 禁用</button>
  21. <button type="button" class="btn btn-md btn-primary"
  22. style="margin-left: 10px" onclick="units.edit(0)"> <span
  23. class="glyphicon glyphicon-plus"></span> 添加</button>
  24. <button type="button" class="btn btn-md btn-danger" onclick="units.delete()"
  25. style="margin-left: 10px"><span
  26. class="glyphicon glyphicon-remove"></span> 删除</button>
  27. </span>
  28. </div>
  29. </div>
  30. <div class="col-md-6 pull-right">
  31. <div class="input-group">
  32. <input type="text" placeholder="请输入联系人或手机号" class="input-md form-control"
  33. name="keyword"
  34. id="keyword">
  35. <span class="input-group-btn">
  36. <button type="button" class="btn btn-md btn-primary"
  37. onclick="units.search()"> 搜索</button>
  38. <button type="reset" class="btn btn-md btn-primary" style="margin-left: 10px"
  39. name="resetBtn"> 重置</button> </span>
  40. </div>
  41. </div>
  42. </form>
  43. <hr>
  44. <div class="table-responsive">
  45. <table id="table" class="table table-condensed" data-mobile-responsive="true"></table>
  46. </div>
  47. </div>
  48. </div>
  49. </div>
  50. </div>
  51. </div>
  52. </body>
  53. @endsection
  54. @section('footer')
  55. <script>
  56. var units = {
  57. statusToggle: function (status) {
  58. var ids = units.getIdsBySelections();
  59. if (ids.length === 0) {
  60. layer.alert('请先选择您所要操作的对象', {icon: 0});
  61. return;
  62. }
  63. tips.ajax(
  64. {
  65. url: '/admin/agents/status',
  66. type: 'put',
  67. data: {ids: ids, status: status},
  68. success: function () {
  69. tips.tableRefresh('#table');
  70. }
  71. });
  72. },
  73. search: function () {
  74. tips.selectPage();
  75. },
  76. getIdsBySelections: function () {
  77. var selections = $("#table").bootstrapTable('getSelections');
  78. var ids = [];
  79. $.each(selections, function (inx, val) {
  80. ids.push(val.id);
  81. });
  82. return ids;
  83. },
  84. edit: function (id) {
  85. var title = '添加';
  86. if (id > 0) {
  87. title = '编辑';
  88. }
  89. layer.open({
  90. type: 2,
  91. content: ['/admin/agents/' + id],
  92. area: ['100%', '100%'],
  93. title: title
  94. });
  95. },
  96. delete: function () {
  97. var ids = units.getIdsBySelections();
  98. if (ids.length === 0) {
  99. layer.alert('请先选择您所要操作的对象', {icon: 0});
  100. return;
  101. }
  102. layer.confirm('您确定要删除吗?', {icon: 3, title: '删除信息'}, function (index, layero) {
  103. layer.close(index);
  104. tips.ajax({
  105. url: '/admin/agents',
  106. type: 'delete',
  107. data: {ids: ids},
  108. tableRefresh: '#table'
  109. });
  110. });
  111. }
  112. };
  113. var config = {};
  114. config.url = '/admin/agents';
  115. config.columns = [ //字段
  116. {checkbox: true},
  117. {
  118. title: '序号', align: 'center', formatter: function (value, item, index) {
  119. return index + 1;
  120. }
  121. },
  122. {title: '公司名称', field: 'company_name', align: 'center'},
  123. {title: '联系人', field: 'contact_name', align: 'center'},
  124. {title: '手机号', field: 'mobile', align: 'center'},
  125. {title: '折扣', field: 'discount', align: 'center'},
  126. {title: '签约时间', field: 'sign_at', align: 'center'},
  127. {
  128. title: '状态', field: 'status', align: 'center', formatter: function (value, row) {
  129. return value ? '<button class="btn btn-xs btn-info">启用</button>' : '<button class="btn btn-xs btn-warning">禁用</button>';
  130. }
  131. },
  132. {title: '创建时间', field: 'created_at', align: 'center'},
  133. {
  134. title: '操作', field: 'id', align: 'center',
  135. formatter: function (value, row) {
  136. return (
  137. '<button onclick="units.edit(' + value + ')" class="btn btn-xs"><span class="glyphicon glyphicon-edit"></span>编辑</button>&nbsp;'
  138. );
  139. }
  140. }
  141. ];
  142. tips.bootstrapTable(config);
  143. </script>
  144. @endsection