1], [['limit'], 'default', 'value' => 20], ]; } /** * 型号列表 */ public function search() { if (!$this->validate()) { return $this->getModelError(); } //未完成 if ($this->status == 1) { $status = [0, 1, 2]; } //完成 if ($this->status == 2) { $status = [3]; } $query = Report::find() ->select('id,model_number,pdf_path,pdf_at,step') ->where([ 'user_id' => $this->user_id ])->andFilterWhere([ 'in', 'step', $status ]); $count = $query->count(); $pagination = new Pagination(['totalCount' => $count, 'pageSize' => $this->limit, 'page' => $this->page - 1]); $list = $query->offset($pagination->offset)->limit($pagination->limit)->orderBy(['id' => SORT_DESC])->asArray()->all(); foreach ($list as $key => $value) { $value['pdf_at_cn'] = ''; if (!empty($value['pdf_at'])) { $value['pdf_at_cn'] = date('Y-m-d H:i:s', $value['pdf_at']); } $value['pdf_path'] = SiteHelper::getFullUrl($value['pdf_path']); $list[$key] = $value; } $end_flag = $this->page > $pagination->pageCount ? true : false; return [ 'code' => 0, 'msg' => 'ok', 'data' => $list, 'count' => $count, 'page_size' => $this->limit, 'page_count' => $pagination->pageCount, 'page_no' => $this->page, 'end_flag' => $end_flag ]; } }