Packagesku.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php
  2. namespace app\admin\controller\service;
  3. use app\common\controller\Backend;
  4. use think\Db;
  5. /**
  6. * 商品sku管理
  7. *
  8. * @icon fa fa-circle-o
  9. */
  10. class Packagesku extends Backend
  11. {
  12. /**
  13. * Packagesku模型对象
  14. * @var \app\admin\model\service\Packagesku
  15. */
  16. protected $model = null;
  17. public function _initialize()
  18. {
  19. parent::_initialize();
  20. $this->model = new \app\admin\model\service\Packagesku;
  21. $this->view->assign("typeList", $this->model->getTypeList());
  22. $this->view->assign("statusList", $this->model->getStatusList());
  23. }
  24. public function index()
  25. {
  26. //设置过滤方法
  27. $this->request->filter(['strip_tags', 'trim']);
  28. if (false === $this->request->isAjax()) {
  29. return $this->view->fetch();
  30. }
  31. //如果发送的来源是 Selectpage,则转发到 Selectpage
  32. if ($this->request->request('keyField')) {
  33. return $this->selectpage();
  34. }
  35. [$where, $sort, $order, $offset, $limit] = $this->buildparams();
  36. $list = $this->model
  37. ->where($where)
  38. ->where('type',1)
  39. ->where('status','normal')
  40. ->order($sort, $order)
  41. ->paginate($limit);
  42. foreach ($list as &$val)
  43. {
  44. $val->goodsname = \app\admin\model\service\Goods::where('id',$val->goods_id)->value('name');
  45. }
  46. $result = ['total' => $list->total(), 'rows' => $list->items()];
  47. return json($result);
  48. }
  49. }