model = new \app\admin\model\ps\Template; $this->view->assign("statusList", $this->model->getStatusList()); $this->view->assign("sourceList", $this->model->getSourceList()); $this->view->assign("licenseTypeList", $this->model->getLicenseTypeList()); $this->view->assign('paperList', PaperSize::presets()); $this->view->assign('fieldCatalog', PrintPlanner::fieldCatalog()); $factories = []; try { $factories = (new \app\admin\model\ps\Factory()) ->where('status', 'normal') ->order('id desc') ->column('name', 'id'); } catch (\Exception $e) { $factories = []; } $this->view->assign('factories', $factories); } /** * 上传标准图 + 色块图并识版入库 */ public function add() { if (false === $this->request->isPost()) { return $this->view->fetch(); } $params = $this->request->post('row/a'); if (empty($params)) { $this->error(__('Parameter %s can not be empty', '')); } try { $result = TemplateIngest::ingest($params); } catch (\Exception $e) { $this->error($e->getMessage()); } $msg = '已入库,识别到 ' . $result['cells'] . ' 个填写格(' . $result['paper'] . ',图 ' . $result['image'] . ')'; if (!empty($result['unlabeled'])) { $msg .= ',其中 ' . $result['unlabeled'] . ' 个未读出色块文字,套打时这些格不会填值'; } $this->success($msg, null, $result); } /** * 查看 */ public function index() { $this->request->filter(['strip_tags', 'trim']); if ($this->request->isAjax()) { if ($this->request->request('keyField')) { return $this->selectpage(); } list($where, $sort, $order, $offset, $limit) = $this->buildparams(); $list = $this->model ->with(['factory']) ->where($where) ->order($sort, $order) ->paginate($limit); $result = array("total" => $list->total(), "rows" => $list->items()); return json($result); } return $this->view->fetch(); } }