| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596 |
- <?php
- namespace app\admin\controller\ps;
- use app\common\controller\Backend;
- use app\common\library\ps\PaperSize;
- use app\common\library\ps\PrintPlanner;
- use app\common\library\ps\TemplateIngest;
- /**
- * 流程单-模板
- *
- * @icon fa fa-file-text-o
- */
- class Template extends Backend
- {
- /**
- * Template模型对象
- * @var \app\admin\model\ps\Template
- */
- protected $model = null;
- protected $relationSearch = true;
- protected $searchFields = 'id,name';
- public function _initialize()
- {
- parent::_initialize();
- $this->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();
- }
- }
|