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 @@ + + +
+ +| 序号 | ++ | 床号 | +秦皇岛中医医院 预约信息明细 | +共{{ $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 }} | +
| + | + | + | + | + | + | + | + | + |