From bfd22a923c955d3286b580c49d9c95e295595a92 Mon Sep 17 00:00:00 2001 From: sa0ChunLuyu Date: Fri, 31 Jul 2026 19:44:03 +0800 Subject: [PATCH] =?UTF-8?q?=E6=89=93=E5=8D=B0=E8=A1=A8=E6=A0=BC=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../API/Admin/YeWu/WorkMainController.php | 19 ++- .../Http/Controllers/API/PdfController.php | 160 ++++++++++++++++++ .../API/Third/CSharpController.php | 4 +- .../views/pdf/MainListPrint.blade.php | 143 ++++++++++++++++ Laravel/routes/api.php | 1 + YiJi-admin/src/views/YeWu/MainList.vue | 63 +++++-- 6 files changed, 371 insertions(+), 19 deletions(-) create mode 100644 Laravel/resources/views/pdf/MainListPrint.blade.php diff --git a/Laravel/app/Http/Controllers/API/Admin/YeWu/WorkMainController.php b/Laravel/app/Http/Controllers/API/Admin/YeWu/WorkMainController.php index 5797c76..0d9389a 100644 --- a/Laravel/app/Http/Controllers/API/Admin/YeWu/WorkMainController.php +++ b/Laravel/app/Http/Controllers/API/Admin/YeWu/WorkMainController.php @@ -210,7 +210,24 @@ public function GetList(Request $request) $count = $list; $count = $count->count(); - $list=$list->orderBy('id', 'desc')->limit($pageSize)->skip(($page - 1) * $pageSize) // 跳过前9999条记录 + + //动态排序 + $orderField = $searchInfo['orderField'] ?? ''; + $orderDirection = ($searchInfo['orderDirection'] ?? '') == 'ascending' ? 'asc' : 'desc'; + $allowedFields = ['reg_num', 'episodeid', 'user_name', 'user_sex', 'user_brithday', 'entrust', 'is_pay', 'list_status', 'reservation_department', 'user_phone', 'reservation_time', 'entrust_date_time']; + if (!empty($orderField) && in_array($orderField, $allowedFields)) { + if ($orderField === 'reservation_time') { + $list = $list->orderByRaw("CONCAT(IFNULL(s_list.reservation_date,''), ' ', IFNULL(s_period.period_begin_time,'')) $orderDirection"); + } elseif ($orderField === 'entrust_date_time') { + $list = $list->orderByRaw("CONCAT(IFNULL(s_list.entrust_date,''), ' ', IFNULL(s_list.entrust_time,'')) $orderDirection"); + } else { + $list = $list->orderBy('s_list.' . $orderField, $orderDirection); + } + } else { + $list = $list->orderBy('s_list.id', 'desc'); + } + + $list=$list->limit($pageSize)->skip(($page - 1) * $pageSize) ->take($pageSize)->get(); //匹配设备(服务组) diff --git a/Laravel/app/Http/Controllers/API/PdfController.php b/Laravel/app/Http/Controllers/API/PdfController.php index 99c1dc3..fa43d41 100644 --- a/Laravel/app/Http/Controllers/API/PdfController.php +++ b/Laravel/app/Http/Controllers/API/PdfController.php @@ -597,4 +597,164 @@ public function GenerateGroupedCheckPdf() return $pdf->inline('GenerateGroupedCheckPdf.pdf'); } + + //打印主表列表 + public function PrintMainList() + { + $searchInfo = request('searchInfo'); + if (is_string($searchInfo)) { + $searchInfo = json_decode($searchInfo, true); + } + $dev = request('Dev', '0'); + + //用户权限过滤(复用 GetList 逻辑) + $userid = request('userid'); + $userInfo = DB::table('users')->where(['id' => $userid])->first(); + if(!$userInfo){ + return \Yz::JsonReturn(false, '用户信息不存在'); + } + $department = DB::table('s_department')->where(['id' => $userInfo->department_id,'is_del'=>0])->first(); + if(!$department){ + return \Yz::JsonReturn(false, '用户所属科室信息不存在'); + } + + //复用 GetList 筛选逻辑(去分页,查全部) + $list = DB::table('s_list') + ->leftJoin('s_period','s_list.reservation_time','=','s_period.id') + ->leftJoin('s_department_resources','s_list.reservation_sources','=','s_department_resources.id') + ->select('s_list.*','s_period.period_begin_time','s_period.period_end_time','s_department_resources.department_resources_name','s_department_resources.department_resources_addr') + ->where(['s_list.is_del'=>0,'s_list.is_nullify'=>0]); + + if($userInfo->group==2){ + $list=$list->where(['wardcode'=> $department->department_number]); + }elseif($userInfo->group==7){ + $list=$list->where(['reservation_department'=>$department->department_name]); + }else{ + $deptQuery = DB::table('s_department') + ->where('is_del', 0) + ->where(function($q) use ($userInfo) { + $q->where('id', $userInfo->department_id) + ->orWhere('pid', $userInfo->department_id); + }); + $deptNumbers = clone $deptQuery; + $deptNumbers = $deptNumbers->pluck('department_number'); + $deptIds = $deptQuery->pluck('id'); + + if ($department->is_workbench == 1) { + $linkedIds = json_decode($department->linked_departments, true); + if (!empty($linkedIds) && is_array($linkedIds)) { + $linkedQuery = DB::table('s_department') + ->where('is_del', 0) + ->where(function($q) use ($linkedIds) { + $q->whereIn('id', $linkedIds) + ->orWhereIn('pid', $linkedIds); + }); + $linkedDeptNumbers = clone $linkedQuery; + $deptNumbers = $deptNumbers->merge($linkedDeptNumbers->pluck('department_number')); + $linkedDeptIds = $linkedQuery->pluck('id'); + $deptIds = $deptIds->merge($linkedDeptIds); + } + } + + $list = $list->where(function ($q) use($deptNumbers, $deptIds) { + $q->whereIn('RISRAcceptDeptCode', $deptNumbers) + ->orWhereIn('reservation_department_code', $deptNumbers) + ->orWhereIn('s_department_resources.department_id', $deptIds); + }); + } + + $dateType = $searchInfo['dateType'] ?? 'reservation_date'; + if ($searchInfo['dateRange']!=null and count($searchInfo['dateRange']) == 2) { + if ($dateType === 'both') { + $list = $list->where(function ($q) use($searchInfo) { + $q->whereBetween('s_list.entrust_date', $searchInfo['dateRange']) + ->orWhereBetween('s_list.reservation_date', $searchInfo['dateRange']); + }); + } elseif ($dateType === 'entrust_date') { + $list = $list->whereBetween('s_list.entrust_date', $searchInfo['dateRange']); + } else { + $list = $list->whereBetween('s_list.reservation_date', $searchInfo['dateRange']); + } + } + if (isset($searchInfo['list_status'])) { + $list = $list->where('s_list.list_status', $searchInfo['list_status']); + } + if (isset($searchInfo['patient_type'])) { + $list = $list->where('s_list.patient_type', $searchInfo['patient_type']); + } + if (!empty($searchInfo['resources'])) { + $list = $list->whereIn('s_list.reservation_sources', $searchInfo['resources']); + } + if (isset($searchInfo['services_group'])) { + $list = $list->whereRaw("FIND_IN_SET(?, s_list.services_group)", [$searchInfo['services_group']]); + } + if (isset($searchInfo['reg_num'])) { + $list = $list->where('s_list.reg_num', $searchInfo['reg_num']); + } + if (isset($searchInfo['user_name'])) { + $list = $list->where('s_list.user_name', 'like','%'.$searchInfo['user_name'].'%'); + } + if (isset($searchInfo['doctor'])) { + $list = $list->where('s_list.docotr', 'like','%'.$searchInfo['doctor'].'%'); + } + if (isset($searchInfo['apply_department'])) { + $list = $list->where('s_list.reservation_department', 'like','%'.$searchInfo['apply_department'].'%'); + } + + //动态排序 + $orderField = $searchInfo['orderField'] ?? ''; + $orderDirection = ($searchInfo['orderDirection'] ?? '') == 'ascending' ? 'asc' : 'desc'; + $allowedFields = ['reg_num', 'episodeid', 'user_name', 'user_sex', 'user_brithday', 'entrust', 'is_pay', 'list_status', 'reservation_department', 'user_phone', 'reservation_time', 'entrust_date_time']; + if (!empty($orderField) && in_array($orderField, $allowedFields)) { + if ($orderField === 'reservation_time') { + $list = $list->orderByRaw("CONCAT(IFNULL(s_list.reservation_date,''), ' ', IFNULL(s_period.period_begin_time,'')) $orderDirection"); + } elseif ($orderField === 'entrust_date_time') { + $list = $list->orderByRaw("CONCAT(IFNULL(s_list.entrust_date,''), ' ', IFNULL(s_list.entrust_time,'')) $orderDirection"); + } else { + $list = $list->orderBy('s_list.' . $orderField, $orderDirection); + } + } else { + $list = $list->orderBy('s_list.id', 'desc'); + } + + if ($dev == '2') { + $debugList = clone $list; + return \Yz::JsonReturn(true, '调试', [ + 'count' => $debugList->count(), + 'sql' => $list->toSql(), + 'bindings' => $list->getBindings(), + 'group' => $userInfo->group, + 'department_id' => $userInfo->department_id, + 'department_name' => $department->department_name, + 'department_number' => $department->department_number, + 'is_workbench' => $department->is_workbench, + ]); + } + + $list = $list->get(); + + //按25行分页 + $perPage = 50; + $pages = $list->chunk($perPage); + $totalPages = $pages->count(); + + if ($dev == '1') { + $pdf = SnappyPdf::loadView('pdf.MainListPrint', [ + 'pages' => $pages, + 'totalPages' => $totalPages, + 'perPage' => $perPage, + ]) + ->setOption('page-width', '210mm') + ->setOption('page-height', '297mm') + ->setOption('margin-top', '5mm') + ->setOption('margin-bottom', '5mm') + ->setOption('margin-left', '5mm') + ->setOption('margin-right', '5mm') + ->setOption('header-spacing', '0') + ->setOption('footer-spacing', '0'); + return $pdf->inline('MainListPrint.pdf'); + } + + return \Yz::JsonReturn(true, '功能开发中', ['count' => $list->count(), 'totalPages' => $totalPages]); + } } \ No newline at end of file diff --git a/Laravel/app/Http/Controllers/API/Third/CSharpController.php b/Laravel/app/Http/Controllers/API/Third/CSharpController.php index 839ee58..9d64f75 100644 --- a/Laravel/app/Http/Controllers/API/Third/CSharpController.php +++ b/Laravel/app/Http/Controllers/API/Third/CSharpController.php @@ -55,8 +55,8 @@ public function SaveApply($orderNo) 'visitSqNo' => $entrust->episodeid, 'requestNo' => $entrust->app_num, 'visitTypeCode' => $patientHisTypeMap[$entrust->patient_type], - 'orderStatus'=>1 - //'feeFlag' => $entrust->is_pay == 0 ? 0 : 1, // 住院=0,其他=1 +// 'orderStatus'=>1 + 'feeFlag' => $entrust->is_pay == 0 ? 0 : 1, // 住院=0,其他=1 ]; $hisInfo=[]; $His = new HisController(); diff --git a/Laravel/resources/views/pdf/MainListPrint.blade.php b/Laravel/resources/views/pdf/MainListPrint.blade.php new file mode 100644 index 0000000..55c0203 --- /dev/null +++ b/Laravel/resources/views/pdf/MainListPrint.blade.php @@ -0,0 +1,143 @@ + + + + + 预约信息明细 + + + +@php + $serialBase = 0; +@endphp +@foreach ($pages as $pageIndex => $pageItems) + @php + $currentPage = $pageIndex + 1; + @endphp +
+ + + + + + + + + + + + + + + + + + + + + + + @foreach ($pageItems as $index => $item) + @php + $serial = $pageIndex * $perPage + $loop->iteration; + $isInpatient = $item->patient_type == 0; + $entrustText = $item->entrust; + if (!empty($item->requestComment)) { + $entrustText .= '(' . $item->requestComment . ')'; + } + $periodText = ''; + if (!empty($item->period_begin_time) && !empty($item->period_end_time)) { + $periodText = substr($item->period_begin_time, 0, 5) . '~' . substr($item->period_end_time, 0, 5); + } + @endphp + + + + + + + + + + + + @endforeach + {{-- 不足25行补空行 --}} + @for ($i = count($pageItems); $i < $perPage; $i++) + + + + + + + + + + + + @endfor + +
序号 床号秦皇岛中医医院 预约信息明细共{{ $totalPages }}页/第{{ $currentPage }}页
{{ $serial }}{{ $isInpatient ? substr($item->episodeid, -10) : '' }}{{ $isInpatient ? $item->bedno : '' }}{{ $item->user_name }}{{ $isInpatient ? $item->warddesc : '' }}{{ $entrustText }}{{ $item->reservation_date }}{{ $periodText }}{{ $item->department_resources_addr }}
         
+
+@endforeach + + diff --git a/Laravel/routes/api.php b/Laravel/routes/api.php index 3a4952d..ffa895f 100644 --- a/Laravel/routes/api.php +++ b/Laravel/routes/api.php @@ -244,5 +244,6 @@ Route::any('/PacsSaveApplyInfo','App\Http\Controllers\API\Third\CSharpController@PacsSaveApplyInfo' )->middleware('log');;//调用此接口给pacs推送检查申请单 Route::any('/PacsCancelApplyInfo','App\Http\Controllers\API\Third\CSharpController@PacsCancelApplyInfo' )->middleware('log');;//调用此接口给pacs推送取消检查申请单 +Route::any('/PrintMainList','App\Http\Controllers\API\PdfController@PrintMainList' )->middleware('log');//打印主表列表 diff --git a/YiJi-admin/src/views/YeWu/MainList.vue b/YiJi-admin/src/views/YeWu/MainList.vue index bedbca0..8a38360 100644 --- a/YiJi-admin/src/views/YeWu/MainList.vue +++ b/YiJi-admin/src/views/YeWu/MainList.vue @@ -96,16 +96,16 @@ 取消报到 打印申请单 批量打印申请单 - 打印表格 + 打印表格 - + @select="handleSelect" @sort-change="onSortChange"> + - + - + - + - - + + - - + + + + - + - + + + - +