Tablelink.php 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. <?php
  2. namespace app\admin\controller\example;
  3. use app\common\controller\Backend;
  4. /**
  5. * 表格联动
  6. * 点击左侧日志列表,右侧的表格数据会显示指定管理员的日志列表
  7. * @icon fa fa-table
  8. */
  9. class Tablelink extends Backend
  10. {
  11. protected $model = null;
  12. protected $noNeedRight = ['table1', 'table2'];
  13. public function _initialize()
  14. {
  15. parent::_initialize();
  16. $this->model = model('AdminLog');
  17. }
  18. public function table1()
  19. {
  20. $this->model = model('Admin');
  21. //设置过滤方法
  22. $this->request->filter(['strip_tags']);
  23. if ($this->request->isAjax()) {
  24. //如果发送的来源是Selectpage,则转发到Selectpage
  25. if ($this->request->request('keyField')) {
  26. return $this->selectpage();
  27. }
  28. list($where, $sort, $order, $offset, $limit) = $this->buildparams();
  29. $total = $this->model
  30. ->where($where)
  31. ->field('id,username')
  32. ->order($sort, $order)
  33. ->count();
  34. $list = $this->model
  35. ->where($where)
  36. ->field('id,username')
  37. ->order($sort, $order)
  38. ->limit($offset, $limit)
  39. ->select();
  40. $result = array("total" => $total, "rows" => $list);
  41. return json($result);
  42. }
  43. return $this->view->fetch('index');
  44. }
  45. public function table2()
  46. {
  47. $this->model = model('AdminLog');
  48. //设置过滤方法
  49. $this->request->filter(['strip_tags']);
  50. if ($this->request->isAjax()) {
  51. //如果发送的来源是Selectpage,则转发到Selectpage
  52. if ($this->request->request('keyField')) {
  53. return $this->selectpage();
  54. }
  55. list($where, $sort, $order, $offset, $limit) = $this->buildparams();
  56. $total = $this->model
  57. ->where($where)
  58. ->order($sort, $order)
  59. ->count();
  60. $list = $this->model
  61. ->where($where)
  62. ->order($sort, $order)
  63. ->limit($offset, $limit)
  64. ->select();
  65. $result = array("total" => $total, "rows" => $list);
  66. return json($result);
  67. }
  68. return $this->view->fetch('index');
  69. }
  70. }