鹿和sa0ChunLuyu 3 weeks ago
parent 888d3912a1
commit a114c2cf3a

@ -27,6 +27,19 @@ public function GetItemList()
return $s->GetItemList($searchInfo, $page, $pageSize);
}
//导出检查项目列表
public function ExportItemList()
{
$searchInfo = request('searchInfo');
$s = new CheckItemService;
$html = $s->ExportItemList($searchInfo);
$content = '<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns="http://www.w3.org/TR/REC-html40"><meta charset="utf-8">' . $html . '</html>';
return response($content, 200, [
'Content-Type' => 'application/vnd.ms-excel;charset=utf-8',
'Content-Disposition' => 'attachment; filename="check_items_export.xls"',
]);
}
//绑定设备
public function BindDevice()
{

@ -71,6 +71,11 @@ public function CheckAppointment()
$patientType = $mapping[$visitTypeCode] ?? 9;
foreach ($data_v['itemList'] as $item_k => $item) {
// 检查科室是否参与预约
$dept = DB::table('s_department')->where('department_number', $item["execDeptCode"])->where('appointment_enabled', 1)->first();
if (!$dept) {
return \Yz::JsonReturn(false, '该科室未参与预约', []);
}
$entrust_ids[] = $item['orderNo'];
$termCodes[] = $item['termCode'];
//查询库里是否存在该检医嘱

@ -21,21 +21,27 @@ public function handle(Request $request, Closure $next)
$insert_id=self::requestLog($request,$insert_id); //记录请求时日志,不含返回信息
$response = $next($request);
// 只对 JSON 响应进行 code 注入
if ($response instanceof \Illuminate\Http\JsonResponse) {
$content = $response->getContent();
$data = json_decode($content, true); // 解码响应内容为关联数组
$data = json_decode($content, true);
// 在关联数组中添加 code 字段
// $data['code'] = 200;
$data['code'] = $response->getStatusCode();
$modifiedContent = json_encode($data,JSON_UNESCAPED_UNICODE); // 编码修改后的关联数组为 JSON 字符串
$modifiedContent = json_encode($data,JSON_UNESCAPED_UNICODE);
$response->setContent($modifiedContent);
}
if(env('REQUEST_LOG') and $response->getStatusCode()==200){ //如果返回状态为200进行log
$ip=self::getTrustedProxiesIp(); //真实ip
$request_header=$request->header(); //请求头
// dd($response);
$response_data = [];
if ($response instanceof \Illuminate\Http\JsonResponse) {
$response_data = $response->getData(); //返回data,json格式
} else {
$response_data = $response->getContent();
}
$post_data=$request->post(); //post请求数据
$get_data=$request->query(); //get请求
$request_url=$request->getPathInfo();//访问的接口地址

@ -83,11 +83,114 @@ public function GetItemList($searchInfo,$page,$pageSize){
->join('s_devices', 's_check_item_device.device_id', '=', 's_devices.id')
->select('s_devices.*')
->where('item_id',$v->id)->get();
// 解析原始科室
$deptNames = [];
if (!empty($v->hisExecDepts)) {
$deptCodes = json_decode($v->hisExecDepts, true);
if (!empty($deptCodes) && is_array($deptCodes)) {
$deptNames = DB::table('s_department')
->whereIn('department_number', $deptCodes)
->pluck('department_name')
->toArray();
}
}
$list[$k]->his_exec_dept_names = $deptNames;
}
return \Yz::Return(true, '查询成功', ['list'=>$list,'count'=>$count]);
}
//导出检查项目列表
public function ExportItemList($searchInfo)
{
$small_id=[];
$list=DB::table('s_check_item')->where('s_check_item.is_del', 0)->whereNotNull('sheetType')->where('sheetType', '!=', '');
if(empty($searchInfo['bigClass'])!==true and empty($searchInfo['smallClass'])===true){
$small_id= DB::table('s_check_item_class')->where(['pid'=>$searchInfo['bigClass'],'is_del'=>0])->pluck('id')->toArray();
$list= $list->whereIn('item_class_id',$small_id);
}
if(!empty($searchInfo['smallClass'])){
$small_id[0]=$searchInfo['smallClass'];
$list= $list->whereIn('item_class_id',$small_id);
}
if(!empty($searchInfo['name'])){
$list->where(function($query) use ($searchInfo) {
$query->where('item_name', 'like', '%'.$searchInfo['name'].'%')
->orWhere('item_code', 'like', '%'.$searchInfo['name'].'%');
});
}
if (isset($searchInfo['deviceBind']) && $searchInfo['deviceBind'] !== '') {
if ($searchInfo['deviceBind'] == 1) {
$list->whereIn('s_check_item.id', function($q) {
$q->select('item_id')->from('s_check_item_device');
});
} elseif ($searchInfo['deviceBind'] == 0) {
$list->whereNotIn('s_check_item.id', function($q) {
$q->select('item_id')->from('s_check_item_device');
});
}
}
if (isset($searchInfo['hisExecDepts']) && $searchInfo['hisExecDepts'] !== '') {
if ($searchInfo['hisExecDepts'] == 1) {
$list->whereNotNull('hisExecDepts')->where('hisExecDepts', '!=', '');
} elseif ($searchInfo['hisExecDepts'] == 0) {
$list->where(function($q) {
$q->whereNull('hisExecDepts')->orWhere('hisExecDepts', '');
});
}
}
$list = $list->orderBy('s_check_item.id')->get();
// 构建 HTML 表格
$html = '<table border="1" cellpadding="6" cellspacing="0" style="border-collapse:collapse;width:100%;font-size:12px;font-family:微软雅黑;">';
$html .= '<thead><tr style="background:#4472C4;color:#fff;font-weight:bold;text-align:center;">';
$html .= '<th style="padding:8px;">检查项目代码</th><th style="padding:8px;">检查项目名称</th><th style="padding:8px;">HIS执行科室</th><th style="padding:8px;">关联排班</th></tr></thead><tbody>';
foreach ($list as $v) {
// 解析原始科室名称
$deptNames = [];
if (!empty($v->hisExecDepts)) {
$deptCodes = json_decode($v->hisExecDepts, true);
if (!empty($deptCodes) && is_array($deptCodes)) {
$deptNames = DB::table('s_department')
->whereIn('department_number', $deptCodes)
->pluck('department_name')
->toArray();
}
}
// 获取关联排班名称
$deviceNames = DB::table('s_check_item_device')
->join('s_devices', 's_check_item_device.device_id', '=', 's_devices.id')
->where('item_id', $v->id)
->pluck('s_devices.device_name')
->toArray();
$deptCount = count($deptNames);
$deviceCount = count($deviceNames);
$maxRows = max($deptCount, $deviceCount, 1);
// 第一行,带合并单元格和背景色
$html .= '<tr style="background:#d9e2f3;">';
$html .= '<td rowspan="'.$maxRows.'" style="vertical-align:middle;text-align:center;padding:4px;">'.$v->item_code.'</td>';
$html .= '<td rowspan="'.$maxRows.'" style="vertical-align:middle;text-align:center;padding:4px;">'.$v->item_name.'</td>';
$html .= '<td style="padding:4px;">'.($deptNames[0] ?? '').'</td>';
$html .= '<td style="padding:4px;">'.($deviceNames[0] ?? '').'</td>';
$html .= '</tr>';
// 后续行
for ($i = 1; $i < $maxRows; $i++) {
$html .= '<tr>';
$html .= '<td style="padding:4px;">'.($deptNames[$i] ?? '').'</td>';
$html .= '<td style="padding:4px;">'.($deviceNames[$i] ?? '').'</td>';
$html .= '</tr>';
}
}
$html .= '</tbody></table>';
return $html;
}
//绑定设备
public function BindDevice($item_id,$device_ids){
$data=[];

@ -52,7 +52,8 @@
Route::post('admin/CalendarListDel','App\Http\Controllers\API\Admin\YeWu\healthCalendarController@Del'); //admin后台删除日历
Route::post('admin/CalendarChangeInfo','App\Http\Controllers\API\Admin\YeWu\healthCalendarController@ChangeInfo'); //admin后台更新日历
Route::post('admin/GetCheckItemClassList','App\Http\Controllers\API\Admin\YeWu\CheckItemController@GetClassList');//admin后台获取检查项目类别列表
Route::post('admin/GetCheckItemList','App\Http\Controllers\API\Admin\YeWu\CheckItemController@GetItemList');//admin后台获取检
Route::post('admin/GetCheckItemList','App\Http\Controllers\API\Admin\YeWu\CheckItemController@GetItemList');//admin后台获取检查项目列表
Route::post('admin/CheckItemExportList','App\Http\Controllers\API\Admin\YeWu\CheckItemController@ExportItemList');//admin后台导出检查项目列表
Route::post('admin/GetDeptCheckItemClassList','App\Http\Controllers\API\Admin\YeWu\DeptCheckItemController@GetClassList');//获取当前科室权限的检查项目类别列表
Route::post('admin/GetDeptCheckItemList','App\Http\Controllers\API\Admin\YeWu\DeptCheckItemController@GetItemList');//获取当前科室权限的检查项目列表
Route::post('admin/DeptItemBindDevice','App\Http\Controllers\API\Admin\YeWu\DeptCheckItemController@BindDevice');//当前科室权限的检查项目绑定设备

@ -117,6 +117,10 @@ export const GetCheckItemClassList = (data = {}) => {
export const GetCheckItemList = (data = {}) => {
return axios({ url: import.meta.env.VITE_APP_API + 'v1/admin/GetCheckItemList', data: data })
}
//admin后台导出检查项目列表
export const CheckItemExportList = (data = {}) => {
return axios({ url: import.meta.env.VITE_APP_API + 'v1/admin/CheckItemExportList', data: data, responseType: 'blob' })
}
//admin后台获取设备列表
export const GetDeviceList = (data = {}) => {

@ -17,6 +17,10 @@ axios.interceptors.request.use(
//响应拦截器
axios.interceptors.response.use(
async response => {
// 如果是 blob 响应,直接返回原始响应
if (response.config.responseType === 'blob') {
return response
}
const res = response.data
console.log(response)
if (res.code !== 200) {

@ -34,12 +34,19 @@
<el-button type="warning" @click="GetHisItemClass()" style="margin-left: 10px; margin-left: 40px;">同步分类</el-button>
<el-button type="warning" @click="GetHisCheckItem()" style="margin-left: 10px;">同步检查项目</el-button>
<el-button type="primary" @click="BatchLinkDevice()" style="margin-left: 10px;">批量关联排班</el-button>
<el-button type="success" @click="ExportItemList()" style="margin-left: 10px;">导出</el-button>
</el-row>
</div>
<el-table ref="checkItemTableRef" :data="tableData" style="width: 100%; margin-top: 10px;" row-key="id" @sort-change="onSortChange" @selection-change="onSelectionChange">
<el-table-column type="selection" width="50" />
<el-table-column prop="item_code" label="检查项目编号" width="160" sortable="custom" />
<el-table-column prop="item_name" label="检查项目名称" sortable="custom" />
<el-table-column prop="his_exec_dept_names" label="原始科室" width="200">
<template #default="scope">
<el-tag v-for="(name, idx) in scope.row.his_exec_dept_names" :key="idx"
class="ml-2" style="margin-bottom: 2px; margin-right: 4px;">{{ name }}</el-tag>
</template>
</el-table-column>
<el-table-column prop="reservation_method_name" label="预约方式" />
<el-table-column prop="limosis" label="要求空腹" width="100">
<template #default="scope">
@ -279,6 +286,7 @@
import {
GetCheckItemClassList,
GetCheckItemList,
CheckItemExportList,
GetEnableDeviceList,
ItemBindDevice,
GetYuYueTypes,
@ -414,6 +422,23 @@
const onSelectionChange = (rows) => {
selectedCheckItems.value = rows
}
//
const ExportItemList = () => {
loading.value = true
CheckItemExportList({
searchInfo: searchInfo.value
}).then(res => {
loading.value = false
const blob = new Blob([res.data], { type: 'application/vnd.ms-excel;charset=utf-8' })
const link = document.createElement('a')
link.href = URL.createObjectURL(blob)
link.download = '检查项目列表.xls'
link.click()
URL.revokeObjectURL(link.href)
}).catch(() => {
loading.value = false
})
}
//穿
const LinkDeviceClick = (row) => {

Loading…
Cancel
Save