Project.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <?php
  2. namespace app\admin\controller\dict;
  3. use app\common\controller\Backend;
  4. /**
  5. *
  6. *
  7. * @icon fa fa-circle-o
  8. */
  9. class Project extends Backend
  10. {
  11. /**
  12. * Project模型对象
  13. * @var \app\admin\model\dict\Project
  14. */
  15. protected $model = null;
  16. public function _initialize()
  17. {
  18. parent::_initialize();
  19. $this->model = new \app\admin\model\dict\Project;
  20. }
  21. /**
  22. * 查看
  23. */
  24. public function index()
  25. {
  26. //设置过滤方法
  27. $this->request->filter(['strip_tags']);
  28. if ($this->request->isAjax()) {
  29. //如果发送的来源是Selectpage,则转发到Selectpage
  30. if ($this->request->request('keyField')) {
  31. return $this->selectpage();
  32. }
  33. list($where, $sort, $order, $offset, $limit) = $this->buildparams($this->searchFields, true);
  34. $join = [
  35. ['constant c', 'p.exam_class_id = c.id', 'LEFT']
  36. ];
  37. $field = ['c.constant_value as exam_class','p.*'];
  38. $total = $this->model->alias('p')
  39. ->join($join)
  40. ->where($where)
  41. ->order($sort, $order)
  42. ->count();
  43. $list = $this->model->alias('p')
  44. ->join($join)
  45. ->where($where)
  46. ->order($sort, $order)
  47. ->limit($offset, $limit)
  48. ->field($field)
  49. ->select();
  50. $list = collection($list)->toArray();
  51. $result = array("total" => $total, "rows" => $list);
  52. return json($result);
  53. }
  54. return $this->view->fetch();
  55. }
  56. }