GoodsLabelGroup.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php
  2. namespace app\admin\controller\shop;
  3. use app\common\controller\Backend;
  4. use think\Db;
  5. use think\exception\PDOException;
  6. use think\Exception;
  7. use think\exception\ValidateException;
  8. class GoodsLabelGroup extends Backend
  9. {
  10. /**
  11. * GoodsLabelGroup模型对象
  12. * @var \app\admin\model\shop\GoodsLabelGroup
  13. */
  14. protected $model = null;
  15. public function _initialize()
  16. {
  17. parent::_initialize();
  18. $this->model = new \app\admin\model\shop\GoodsLabelGroup;
  19. $this->view->assign("statusList", $this->model->getStatusList());
  20. $this->assignconfig("statusList", json_encode($this->model->getStatusList()));
  21. }
  22. public function getList()
  23. {
  24. $list = $this->model->field('id,name')->select();
  25. return json($list);
  26. }
  27. public function index()
  28. {
  29. $this->relationSearch = false;
  30. $this->request->filter(['strip_tags', 'trim']);
  31. if ($this->request->isAjax()) {
  32. if ($this->request->request('keyField')) {
  33. return $this->selectpage();
  34. }
  35. list($where, $sort, $order, $offset, $limit) = $this->buildparams();
  36. $list = $this->model
  37. ->where($where)
  38. ->order($sort, $order)
  39. ->paginate($limit);
  40. foreach ($list as $row) {
  41. $row->visible(['id', 'name', 'sort', 'status', 'createtime', 'updatetime']);
  42. $row->visible(['status_text']);
  43. $row->hidden(['deletetime']);
  44. }
  45. $result = array("total" => $list->total(), "rows" => $list->items());
  46. return json($result);
  47. }
  48. return $this->view->fetch();
  49. }
  50. }