Bootstraptable.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <?php
  2. namespace app\admin\controller\example;
  3. use app\common\controller\Backend;
  4. /**
  5. * 表格完整示例
  6. *
  7. * @icon fa fa-table
  8. * @remark 在使用Bootstrap-table中的常用方式,更多使用方式可查看:http://bootstrap-table.wenzhixin.net.cn/zh-cn/
  9. */
  10. class Bootstraptable extends Backend
  11. {
  12. protected $model = null;
  13. protected $noNeedRight = ['change', 'detail'];
  14. public function _initialize()
  15. {
  16. parent::_initialize();
  17. $this->model = model('AdminLog');
  18. }
  19. /**
  20. * 查看
  21. */
  22. public function index()
  23. {
  24. if ($this->request->isAjax())
  25. {
  26. list($where, $sort, $order, $offset, $limit) = $this->buildparams(NULL);
  27. $total = $this->model
  28. ->where($where)
  29. ->order($sort, $order)
  30. ->count();
  31. $list = $this->model
  32. ->where($where)
  33. ->order($sort, $order)
  34. ->limit($offset, $limit)
  35. ->select();
  36. $result = array("total" => $total, "rows" => $list);
  37. return json($result);
  38. }
  39. return $this->view->fetch();
  40. }
  41. /**
  42. * 详情
  43. */
  44. public function detail($ids)
  45. {
  46. $row = $this->model->get(['id' => $ids]);
  47. if (!$row)
  48. $this->error(__('No Results were found'));
  49. $this->view->assign("row", $row->toArray());
  50. return $this->view->fetch();
  51. }
  52. /**
  53. * 变更
  54. * @internal
  55. */
  56. public function change()
  57. {
  58. $this->code = 1;
  59. }
  60. }