Tabletemplate.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <?php
  2. namespace app\admin\controller\example;
  3. use app\common\controller\Backend;
  4. /**
  5. * 表格模板示例
  6. *
  7. * @icon fa fa-table
  8. * @remark 可以通过使用表格模板将表格中的行渲染成一样的展现方式,基于此功能可以任意定制自己想要的展示列表
  9. */
  10. class Tabletemplate extends Backend
  11. {
  12. protected $model = null;
  13. public function _initialize()
  14. {
  15. parent::_initialize();
  16. $this->model = model('AdminLog');
  17. }
  18. /**
  19. * 查看
  20. */
  21. public function index()
  22. {
  23. if ($this->request->isAjax())
  24. {
  25. list($where, $sort, $order, $offset, $limit) = $this->buildparams(NULL);
  26. $total = $this->model
  27. ->where($where)
  28. ->order($sort, $order)
  29. ->count();
  30. $list = $this->model
  31. ->where($where)
  32. ->order($sort, $order)
  33. ->limit($offset, $limit)
  34. ->select();
  35. $result = array("total" => $total, "rows" => $list);
  36. return json($result);
  37. }
  38. return $this->view->fetch();
  39. }
  40. /**
  41. * 详情
  42. */
  43. public function detail($ids)
  44. {
  45. $row = $this->model->get(['id' => $ids]);
  46. if (!$row)
  47. $this->error(__('No Results were found'));
  48. $this->view->assign("row", $row->toArray());
  49. return $this->view->fetch();
  50. }
  51. }