model = new ShopDeliveryModel(); $this->assign('platformList', site_config('addonsd.platform_list')); $this->relationField=['customer','user','shops', 'variety', 'specs']; } /** * 查看 */ #[Route('GET,JSON','index')] public function index() { if (false === $this->request->isAjax()) { return $this->fetch(); } if($this->request->post('selectpage')){ return $this->selectpage(); } [$where, $order, $limit, $with] = $this->buildparams(); $list = $this->model ->withJoin($with,'left') //如果没有使用operate filter过滤的情况下,推荐使用with关联,可以提高查询效率 //->with($with) ->where($where) ->order($order) ->paginate($limit); //表格底部要有汇总:发货数量汇总 重量汇总 总价汇总 $total_num = $this->model->where($where)->sum('num'); $total_weigh = $this->model->where($where)->sum('weigh'); $total_price = $this->model->where($where)->sum('total_price'); $result = ['total' => $list->total(), 'rows' => $list->items(), 'total_num' => $total_num, 'total_weigh' => $total_weigh, 'total_price' => $total_price]; return json($result); } }