model = new \app\admin\model\Patient(); } /** * 若需重写查看、编辑、删除等方法,请复制 @see \app\admin\library\traits\Backend 中对应的方法至此进行重写 */ /** * 查看 * @throws Throwable */ public function index(): void { if ($this->request->param('select')) { $this->select(); } list($where, $alias, $limit, $order) = $this->queryBuilder(); $res = $this->model ->field($this->indexField) ->withJoin($this->withJoinTable, $this->withJoinType) ->alias($alias) ->where($where) ->order($order) ->paginate($limit); foreach ($res->items() as $k=>&$v) { $v->ID_CARDNUM = empty($v->ID_CARDNUM) ? '' : substr($v->ID_CARDNUM,0, 10) . '****' . substr($v->ID_CARDNUM,14); $v->NAME = mb_substr( $v->NAME, 0, 1) . str_repeat('*', ceil((strlen($v->NAME) - 1)/4)); $len = strlen($v->INSUR_CARD_NO); $v->INSUR_CARD_NO = mb_substr( $v->INSUR_CARD_NO, 0, ceil($len/2)).str_repeat('*', ceil($len/2)); } $this->success('', [ 'list' => $res->items(), 'total' => $res->total(), 'remark' => get_route_remark(), ]); } public function asyncAttachment():void { try { $params = $this->request->post(); $type = $params['file']; //文件流类型 文件后缀 $url = '/attachment/'.time().'.'.$type; $filePath = $_SERVER['DOCUMENT_ROOT'].$url; // 确保目录存在 $dirPath = dirname($filePath); if (!is_dir($dirPath)) { mkdir($dirPath, 0755, true); // 第三个参数 true 表示可以创建多级目录 } // 写入文件 $data = $params['data']; file_put_contents($filePath, $data); $arr = [ 'report_code'=>$params['report_code'], 'type'=>$params['type'], 'url'=>$url ]; Db::name('report_attachment')->insert($arr); $this->success('success'); }catch (\Exception $e) { $this->error($e->getMessage()); } } public function getAttachment(): void { $params = $this->request->post(); $code = $params['report_code']; $url = Db::name('report_attachment')->where('report_code',$code)->value('url'); if(!empty($url)) { $this->success($url); }else{ $this->error('无可用的附件'); } } }