ServiceItem.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <?php
  2. namespace app\admin\controller;
  3. use app\common\controller\Backend;
  4. /**
  5. * 需求项目管理
  6. *
  7. */
  8. class ServiceItem extends Backend
  9. {
  10. /**
  11. * ServiceItem模型对象
  12. * @var \app\admin\model\ServiceItem
  13. */
  14. protected $model = null;
  15. protected $defaultSortField = 'weigh,desc';
  16. protected $preExcludeFields = ['id', 'create_time', 'update_time'];
  17. protected $withJoinTable = ['admin'];
  18. protected $quickSearchField = ['id'];
  19. public function initialize()
  20. {
  21. parent::initialize();
  22. $this->model = new \app\admin\model\ServiceItem;
  23. }
  24. /**
  25. * 查看
  26. */
  27. public function index()
  28. {
  29. $this->request->filter(['strip_tags', 'trim']);
  30. // 如果是select则转发到select方法,若select未重写,其实还是继续执行index
  31. if ($this->request->param('select')) {
  32. $this->select();
  33. }
  34. list($where, $alias, $limit, $order) = $this->queryBuilder();
  35. $res = $this->model
  36. ->withJoin($this->withJoinTable, $this->withJoinType)
  37. ->alias($alias)
  38. ->where($where)
  39. ->order($order)
  40. ->paginate($limit);
  41. $res->visible(['admin' => ['username']]);
  42. $this->success('', [
  43. 'list' => $res->items(),
  44. 'total' => $res->total(),
  45. 'remark' => get_route_remark(),
  46. ]);
  47. }
  48. /**
  49. * 若需重写查看、编辑、删除等方法,请复制 @see \app\admin\library\traits\Backend 中对应的方法至此进行重写
  50. */
  51. }