diff --git a/Laravel.zip b/Laravel.zip deleted file mode 100644 index 8577519..0000000 Binary files a/Laravel.zip and /dev/null differ diff --git a/Laravel/app/Http/Controllers/API/Admin/YeWu/PlanListController.php b/Laravel/app/Http/Controllers/API/Admin/YeWu/PlanListController.php index ef32112..1590e53 100644 --- a/Laravel/app/Http/Controllers/API/Admin/YeWu/PlanListController.php +++ b/Laravel/app/Http/Controllers/API/Admin/YeWu/PlanListController.php @@ -7,6 +7,7 @@ use App\Services\Admin\YeWu\PlanListService; use DateTime; use Illuminate\Http\Request; use Illuminate\Support\Facades\DB; +use Illuminate\Support\Facades\Log; use Tools; class PlanListController extends Controller @@ -19,6 +20,8 @@ class PlanListController extends Controller $department_id = $userInfo[0]->department_id; $dateRange = request('dateRange'); $planModelIds = request('ids'); + $HolidayEnable = request('HolidayEnable'); + $date_type = request('date_type'); //循环日期和勾选的模板创建明细 if (count($dateRange) == 2 && count($planModelIds) > 0) { $models = DB::table('s_source_roster')->whereIn('id', $planModelIds)->get(); @@ -39,31 +42,47 @@ class PlanListController extends Controller ->where('date', '<=', $end_date->format('Y-m-d')) ->where('is_del', 0) ->get(); - $msg='当前选中的'; - $msglist=''; - $msgIds=''; + $msg = '当前选中的'; + $msglist = ''; + $msgIds = ''; if (count($checkList) > 0) { - foreach ($models as $model ){ + foreach ($models as $model) { foreach ($checkList as $item) { - $msglist.=$item->date.' '; - $msgIds.=$item->id.' '; + $msglist .= $item->date . ' '; + $msgIds .= $item->id . ' '; } - if($item->roster_id==$model->id){ - $msg.=" ".$model->weekname.$model->begin_time.'-'.$model->end_time." "; + if ($item->roster_id == $model->id) { + $msg .= " " . $model->weekname . $model->begin_time . '-' . $model->end_time . " "; } - } - return \Yz::Return(false,'已有重复的计划明细,禁止创建!'.$msg.'已存在相同记录,存在于:'.$msglist.'对应记录Id为:'.$msgIds.'请先删除后再操作', $checkList); + return \Yz::Return(false, '已有重复的计划明细,禁止创建!' . $msg . '已存在相同记录,存在于:' . $msglist . '对应记录Id为:' . $msgIds . '请先删除后再操作', $checkList); } + //查询勾选的时间范围内所有的节假日 + $holiday_list=DB::table('s_holiday')->whereBetween('date',$dateRange)->where(['type'=>2])->pluck('date')->toArray(); // 循环日期并判断星期 $current_date = clone $start_date; DB::beginTransaction(); - $success_count=0;//成功创建的数量 + $success_count = 0;//成功创建的数量 while ($current_date <= $end_date) { + //如果是节假日模板,则判断当前日期是否是节假日,不是则跳过 + if ($date_type == 2) { + if (!in_array($current_date->format('Y-m-d'),$holiday_list)){ + // 将当前日期增加一天 + $current_date->modify('+1 day'); + continue; + } + } + //如果选择节假日不可用,并且当前日期是节假日,则跳过 + if($HolidayEnable==0 and in_array($current_date->format('Y-m-d'),$holiday_list)){ + // 将当前日期增加一天 + $current_date->modify('+1 day'); + continue; + } + // 获取当前日期的星期几(0表示星期日,1表示星期一,以此类推) $weekday = $current_date->format('w'); $weekname = ''; @@ -91,77 +110,79 @@ class PlanListController extends Controller break; } foreach ($models as $model) { - if ($model->weekname == $weekname) { - // 插入明细表 - $data = [ - 'roster_id' => $model->id, - 'date' => $current_date, - 'weekname' => $weekname, - 'department_id' => $model->department_id, - 'resources_id' => $model->resources_id, - 'device_id' => $model->device_id, - 'period_id' => $model->period_id, - 'patient_type' => $model->patient_type, - 'begin_time' => $model->begin_time, - 'end_time' => $model->end_time, - 'end_reservation_time' => $model->end_reservation_time, - 'time_unit' => $model->time_unit, - 'status' => 1, - 'adduser' => $userid, - 'is_del' => 0, - ]; - - - - $plan_id = DB::table('s_source_roster_detail')->insertGetId($data); - if($plan_id){ - $success_count++; - } - // 插入数量表 - $model_count_info = DB::table('s_source_roster_count')->where(['roster_id' => $model->id])->get(); - if (count($model_count_info) > 0) { - foreach ($model_count_info as $info) { - $i_c = DB::table('s_source_roster_detail_count')->insert([ - 'roster_detail_id' => $plan_id, - 'appointment_type_id' => $info->appointment_type_id, - 'count' => $info->count, - 'max_total' => $info->max_total, - ]); - if (!$i_c) { - DB::rollBack(); - return \Yz::echoError1('渠道数量创建失败'); - } + if ($date_type == 1 and $model->date_type==1) { + if ($model->weekname <> $weekname) continue; + } + + // 插入明细表 + $data = [ + 'roster_id' => $model->id, + 'date' => $current_date, + 'weekname' => $weekname, + 'department_id' => $model->department_id, + 'resources_id' => $model->resources_id, + 'device_id' => $model->device_id, + 'period_id' => $model->period_id, + 'patient_type' => $model->patient_type, + 'begin_time' => $model->begin_time, + 'end_time' => $model->end_time, + 'end_reservation_time' => $model->end_reservation_time, + 'time_unit' => $model->time_unit, + 'status' => 1, + 'adduser' => $userid, + 'is_del' => 0, + ]; + + + $plan_id = DB::table('s_source_roster_detail')->insertGetId($data); + if ($plan_id) { + $success_count++; + } + // 插入数量表 + $model_count_info = DB::table('s_source_roster_count')->where(['roster_id' => $model->id])->get(); + if (count($model_count_info) > 0) { + foreach ($model_count_info as $info) { + $i_c = DB::table('s_source_roster_detail_count')->insert([ + 'roster_detail_id' => $plan_id, + 'appointment_type_id' => $info->appointment_type_id, + 'count' => $info->count, + 'max_total' => $info->max_total, + ]); + if (!$i_c) { + DB::rollBack(); + return \Yz::echoError1('渠道数量创建失败'); } - } else { - DB::rollBack(); - return \Yz::echoError1('模板数量信息异常,请重新选择!异常模板Id:' . $model->id); } - if(isset($model->device_id)){ - $device_ids =explode(",", $model->device_id); - foreach ($device_ids as $dv_key=>$dv_value){ - $i_dev = DB::table('s_source_roster_detail_device')->insert([ - 'roster_detail_id' => $plan_id, - 'device_id' => $dv_value, - ]); - if (!$i_dev) { - DB::rollBack(); - return \Yz::echoError1('设备关联创建失败'); - } + } else { + DB::rollBack(); + return \Yz::echoError1('模板数量信息异常,请重新选择!异常模板Id:' . $model->id); + } + if (isset($model->device_id)) { + $device_ids = explode(",", $model->device_id); + foreach ($device_ids as $dv_key => $dv_value) { + $i_dev = DB::table('s_source_roster_detail_device')->insert([ + 'roster_detail_id' => $plan_id, + 'device_id' => $dv_value, + ]); + if (!$i_dev) { + DB::rollBack(); + return \Yz::echoError1('设备关联创建失败'); } - - }else{ - DB::rollBack(); - return \Yz::echoError1('模板未关联设备,请重新选择!异常模板Id:' . $model->id); } + } else { + DB::rollBack(); + return \Yz::echoError1('模板未关联设备,请重新选择!异常模板Id:' . $model->id); } + + } // 将当前日期增加一天 $current_date->modify('+1 day'); } DB::commit(); - return \Yz::Return(true, '执行完成,范围:'.$dateRange[0].'-'.$dateRange[1].',共计生成计划 '.$success_count.' 条', ['dateRange'=>$dateRange,'success_count'=>$success_count]); + return \Yz::Return(true, '执行完成,范围:' . $dateRange[0] . '-' . $dateRange[1] . ',共计生成计划 ' . $success_count . ' 条', ['dateRange' => $dateRange, 'success_count' => $success_count]); } } @@ -242,7 +263,7 @@ class PlanListController extends Controller } } - return \Yz::Return(true, '获取成功', ['list' => $list,'count' => $count]); + return \Yz::Return(true, '获取成功', ['list' => $list, 'count' => $count]); } public function GetDetail() @@ -320,12 +341,13 @@ class PlanListController extends Controller $appointment_type = request('appointment_type'); //预约类型 $appointment_date = request('date'); //预约日期 $service = new PlanListService(); - return $service->GetEnablePlan($regnum,$entrustid,$episodeid,$appointment_type,$appointment_date); + return $service->GetEnablePlan($regnum, $entrustid, $episodeid, $appointment_type, $appointment_date); } + //获取最近可用的,计划 日期 public function NearestEnablePlanDate() { - $dateRange=7; + $dateRange = 7; $regnum = request('regnum'); $entrustids = request('entrustid'); $episodeid = request('episodeid'); @@ -333,31 +355,31 @@ class PlanListController extends Controller $appointment_date = request('date'); //预约日期 $service = new PlanListService(); - $date_arr=[]; + $date_arr = []; $startDate = new DateTime(); - // 设定结束日期为当前日期加7天 + // 设定结束日期为当前日期加7天 $endDate = new DateTime(); - $endDate->modify('+'.$dateRange.' day'); - // 循环遍历每一天 + $endDate->modify('+' . $dateRange . ' day'); + // 循环遍历每一天 $currentDate = $startDate; while ($currentDate <= $endDate) { - $nowdate= $currentDate->format('Y-m-d'); - $s=$service->GetEnablePlan($regnum,$entrustids,$episodeid,$appointment_type,$nowdate); - if($s['status']){ - $list= $s['data']['plan_list']; - if(count($list)>0){ - $date_arr[]= $s['data']['appointment_date']; + $nowdate = $currentDate->format('Y-m-d'); + $s = $service->GetEnablePlan($regnum, $entrustids, $episodeid, $appointment_type, $nowdate); + if ($s['status']) { + $list = $s['data']['plan_list']; + if (count($list) > 0) { + $date_arr[] = $s['data']['appointment_date']; } } - if(count($date_arr)>=2){ + if (count($date_arr) >= 2) { break; } // 每次循环增加一天 $currentDate->modify('+1 day'); } - return \Yz::Return(true,'查询完成',['list'=>$date_arr]); + return \Yz::Return(true, '查询完成', ['list' => $date_arr]); } @@ -374,7 +396,7 @@ class PlanListController extends Controller if (!isset($do_type)) return \Yz::echoError1('参数:操作类型 不能为空'); $service = new PlanListService(); - return $service->YuYue($planid,$appointment_type,$mainlistid,$do_type); + return $service->YuYue($planid, $appointment_type, $mainlistid, $do_type); } public function CancelYuYue(Request $request) @@ -386,10 +408,10 @@ class PlanListController extends Controller $password = request('password'); $userid = $request->get('userid');//中间件产生的参数 $query = DB::table('users')->where(['id' => $userid])->get(); - if(password_verify($password,$query[0]->pwd)) { + if (password_verify($password, $query[0]->pwd)) { $service = new PlanListService(); - return $service->CancelYuYue($MainListId,$reg_num); + return $service->CancelYuYue($MainListId, $reg_num); // $mainInfo = DB::table('s_list')->where(['id' => $MainListId])->first(); // if (!$mainInfo) return \Yz::echoError1('医嘱不存在'); @@ -421,7 +443,7 @@ class PlanListController extends Controller // return \Yz::echoError1('取消异常'); // } - }else{ + } else { return \Yz::echoError1('密码不正确'); } } @@ -430,24 +452,24 @@ class PlanListController extends Controller public function GetUsedList() { $planid = request('planid'); - $qudaoid= request('qudaoid'); - $list=DB::table('s_list') - ->leftJoin('s_department_resources','s_list.reservation_sources','=','s_department_resources.id') - ->select('s_list.*','s_department_resources.department_resources_name') - ->where(['s_list.roster_id'=>$planid,'s_list.is_del'=>0,'s_list.is_nullify'=>0])->whereIn('s_list.list_status',[1,2,3]); + $qudaoid = request('qudaoid'); + $list = DB::table('s_list') + ->leftJoin('s_department_resources', 's_list.reservation_sources', '=', 's_department_resources.id') + ->select('s_list.*', 's_department_resources.department_resources_name') + ->where(['s_list.roster_id' => $planid, 's_list.is_del' => 0, 's_list.is_nullify' => 0])->whereIn('s_list.list_status', [1, 2, 3]); if (!empty($qudaoid)) { - $list=$list->where(['s_list.appointment_type_id'=>$qudaoid]); + $list = $list->where(['s_list.appointment_type_id' => $qudaoid]); } - $list=$list->get(); - $qudao=DB::table('s_appointment_type')->get(); - foreach ($list as $key=>$item){ - foreach ($qudao as $q){ - if($q->id==$item->appointment_type_id){ - $item->qudao_name=$q->name; + $list = $list->get(); + $qudao = DB::table('s_appointment_type')->get(); + foreach ($list as $key => $item) { + foreach ($qudao as $q) { + if ($q->id == $item->appointment_type_id) { + $item->qudao_name = $q->name; } } } - return \Yz::Return(true,'查询完成',$list); + return \Yz::Return(true, '查询完成', $list); } } diff --git a/Laravel/app/Http/Controllers/API/Admin/YeWu/PlanModelController.php b/Laravel/app/Http/Controllers/API/Admin/YeWu/PlanModelController.php index f66bc84..c5a98c3 100644 --- a/Laravel/app/Http/Controllers/API/Admin/YeWu/PlanModelController.php +++ b/Laravel/app/Http/Controllers/API/Admin/YeWu/PlanModelController.php @@ -15,13 +15,14 @@ class PlanModelController extends Controller $searchInfo = request('searchInfo'); $page = request('page'); $pageSize = request('pageSize'); + $searchInfo['date_type']=$searchInfo['date_type']?$searchInfo['date_type']:1; $department_id = 0; $list = DB::table('s_source_roster') ->leftJoin('s_department_resources', 's_source_roster.resources_id', '=', 's_department_resources.id') // ->leftJoin('s_devices', 's_source_roster.device_id', '=', 's_devices.id') ->leftJoin('s_period', 's_source_roster.period_id', '=', 's_period.id') ->select('s_source_roster.*', 's_department_resources.department_resources_name', 's_period.period_name') - ->where(['s_source_roster.is_del' => 0]); + ->where(['s_source_roster.is_del' => 0,'s_source_roster.date_type' => $searchInfo['date_type']]); if ($group == 1) {//如果是管理员 if (!empty($searchInfo['department_id'])) { $list = $list->where('s_source_roster.department_id', $searchInfo['department_id']); @@ -95,73 +96,85 @@ class PlanModelController extends Controller public function Save(Request $request) { $userid = $request->get('userid');//中间件产生的参数 - $bitian = array('xingqi', 'max_total', 'qudao_total', 'period_id', 'begin_time', 'end_time', 'end_reservation_time', 'resources_id', 'devices', 'patientType'); - $bitian_zh = array('星期', '当日总量', '渠道数量', '时间段', '开始时间', '结束时间', '停止预约时间', '资源', '设备', '患者类型'); + $date_type = request('date_type'); $planInfo = request('planInfo'); + $bitian = array('max_total', 'qudao_total', 'period_id', 'begin_time', 'end_time', 'end_reservation_time', 'resources_id', 'devices', 'patientType'); + $bitian_zh = array('当日总量', '渠道数量', '时间段', '开始时间', '结束时间', '停止预约时间', '资源', '设备', '患者类型'); + if($date_type==1){//如果是普通类型计划 1普通2节假日 + $bitian[]='xingqi'; + $bitian_zh[]='星期'; + } foreach ($bitian as $key => $field) { //必填项不能为空 if (array_key_exists($field, $planInfo) && $planInfo[$field] !== '' && $planInfo[$field] !== null && $planInfo[$field] !== [] && $planInfo[$field] !== 0) { } else { return \Yz::echoError1($bitian_zh[$key] . ' 不能为空'); } } + if($planInfo['end_reservation_time']>$planInfo['end_time']) return \Yz::echoError1('停止预约时间不能超过结束时间'); $userInfo = DB::table('users')->where(['id' => $userid])->first(); if (!isset($userInfo->department_id)) return \Yz::echoError1('该用户未绑定科室'); $department_id = $userInfo->department_id; DB::beginTransaction(); - foreach ($planInfo['xingqi'] as $key => $value) { - $data = [ - 'department_id' => $department_id, - 'weekname' => $value, - 'resources_id' => $planInfo['resources_id'], - 'device_id' => isset($planInfo['devices']) ? implode(',', $planInfo['devices']) : '', - 'period_id' => $planInfo['period_id'], //时间段id - 'patient_type' => isset($planInfo['patientType']) ? implode(',', $planInfo['patientType']) : '',//病人类型 - 'begin_time' => $planInfo['begin_time'], - 'end_time' => $planInfo['end_time'], - 'end_reservation_time' => $planInfo['end_reservation_time'], - 'time_unit' => $planInfo['time_unit'], - 'status' => $planInfo['status'], - 'adduser' => $userid, - ]; - if($planInfo['end_reservation_time']>$planInfo['end_time']) return \Yz::echoError1('停止预约时间不能超过结束时间'); - - //判断记录是否存在 - $is_ex = DB::table('s_source_roster')->where([ - 'department_id' => $department_id, - 'weekname' => $value, - 'resources_id' => $planInfo['resources_id'], -// 'period_id' => $planInfo['period_id'], //时间段id - 'is_del' => 0, - ]); - if ($planInfo['id'] > 0) { - $is_ex = $is_ex->where('id', '<>', $planInfo['id']); - } - - $start = $planInfo['begin_time']; - $end = $planInfo['end_time']; - $is_ex = $is_ex->where(function ($query) use ($start, $end) { - // 情况1:开始时间在查询区间内 - $query->whereBetween('begin_time', [$start, $end]) - ->orWhereBetween('end_time', [$start, $end]); - // 情况2:查询区间的开始时间在数据库记录的开始和结束时间之间 - // 注意:对于时间类型的比较,直接使用字符串比较可能不够精确,特别是跨天情况,以下逻辑需根据实际情况调整 - $query->orWhere(function ($query) use ($start, $end) { - $query->where('begin_time', '<=', $start) - ->where('end_time', '>=', $end); - }); - })->get(); - // dd($is_ex); - //遍历判断设备是否有重叠,有则返回错误 - foreach ($is_ex as $k => $v) { - $db_device_ids = explode(',', $v->device_id); - $overlap = array_intersect($planInfo['devices'], $db_device_ids); - if (count($overlap) > 0) { + $data = [ + 'department_id' => $department_id, + 'weekname' => '', + 'resources_id' => $planInfo['resources_id'], + 'device_id' => isset($planInfo['devices']) ? implode(',', $planInfo['devices']) : '', + 'period_id' => $planInfo['period_id'], //时间段id + 'patient_type' => isset($planInfo['patientType']) ? implode(',', $planInfo['patientType']) : '',//病人类型 + 'begin_time' => $planInfo['begin_time'], + 'end_time' => $planInfo['end_time'], + 'end_reservation_time' => $planInfo['end_reservation_time'], + 'time_unit' => $planInfo['time_unit'], + 'status' => $planInfo['status'], + 'adduser' => $userid, + 'date_type' => $date_type, + ]; + $param=[ + 'department_id' => $department_id, + 'resources_id' => $planInfo['resources_id'], + 'is_del' => 0, + 'date_type' => $date_type, + ]; + if($date_type==1){ + foreach ($planInfo['xingqi'] as $key => $value) { + $data['weekname'] = $value; + //判断记录是否存在 + $param['weekname'] = $value; + $check=$this->Check($planInfo,$param,$value); + if(!$check['status']){ DB::rollBack(); - return \Yz::echoError1($value . '时段服务组关联重复,计划id为:' . $v->id); + return \Yz::echoError1($check['msg']); + } + if ($planInfo['id'] == 0) {//新增 + $roster_id = DB::table('s_source_roster')->insertGetId($data); + if ($roster_id) { + foreach ($planInfo['qudao_total'] as $k => $v) { + $i_c = DB::table('s_source_roster_count')->insert([ + 'roster_id' => $roster_id, + 'appointment_type_id' => $v['id'], + 'max_total' => $planInfo['max_total'], + 'count' => $v['count'], + ]); + if (!$i_c) { + DB::rollBack(); + return \Yz::echoError1('保存失败'); + } + } + } else { + DB::rollBack(); + return \Yz::echoError1('保存失败'); + } } - } + } + }elseif ($date_type==2){ + $check=$this->Check($planInfo,$param,"当前选定的"); + if(!$check['status']){ + DB::rollBack(); + return \Yz::echoError1($check['msg']); + } if ($planInfo['id'] == 0) {//新增 $roster_id = DB::table('s_source_roster')->insertGetId($data); if ($roster_id) { @@ -181,29 +194,62 @@ class PlanModelController extends Controller DB::rollBack(); return \Yz::echoError1('保存失败'); } - } else {//修改 - $data['id'] = $planInfo['id']; + } - $i = DB::table('s_source_roster')->where(['id' => $planInfo['id'], 'is_del' => 0])->update($data); + } + if($planInfo['id'] > 0) {//修改 + $data['id'] = $planInfo['id']; - foreach ($planInfo['qudao_total'] as $k => $v) { - $i_c = DB::table('s_source_roster_count')->where(['roster_id' => $planInfo['id'], 'appointment_type_id' => $v['appointment_type_id']])->update([ - 'max_total' => $planInfo['max_total'], - 'count' => $v['count'], - ]); + $i = DB::table('s_source_roster')->where(['id' => $planInfo['id'], 'is_del' => 0])->update($data); - } - if ($i or $i_c) { - } else { - DB::rollBack(); - return \Yz::echoError1('保存失败'); - } - } + foreach ($planInfo['qudao_total'] as $k => $v) { + $i_c = DB::table('s_source_roster_count')->where(['roster_id' => $planInfo['id'], 'appointment_type_id' => $v['appointment_type_id']])->update([ + 'max_total' => $planInfo['max_total'], + 'count' => $v['count'], + ]); + } + if ($i or $i_c) { + } else { + DB::rollBack(); + return \Yz::echoError1('保存失败'); + } } + DB::commit(); return \Yz::Return(true, '保存成功', []); } + //检测提交的信息是否有效 + function Check($planInfo,$param,$shiduan) + { + $is_ex = DB::table('s_source_roster')->where($param); + if ($planInfo['id'] > 0) { + $is_ex = $is_ex->where('id', '<>', $planInfo['id']); + } + + $start = $planInfo['begin_time']; + $end = $planInfo['end_time']; + $is_ex = $is_ex->where(function ($query) use ($start, $end) { + // 情况1:开始时间在查询区间内 + $query->whereBetween('begin_time', [$start, $end]) + ->orWhereBetween('end_time', [$start, $end]); + // 情况2:查询区间的开始时间在数据库记录的开始和结束时间之间 + // 注意:对于时间类型的比较,直接使用字符串比较可能不够精确,特别是跨天情况,以下逻辑需根据实际情况调整 + $query->orWhere(function ($query) use ($start, $end) { + $query->where('begin_time', '<=', $start) + ->where('end_time', '>=', $end); + }); + })->get(); + //遍历判断设备是否有重叠,有则返回错误 + foreach ($is_ex as $k => $v) { + $db_device_ids = explode(',', $v->device_id); + $overlap = array_intersect($planInfo['devices'], $db_device_ids); + if (count($overlap) > 0) { + return ['status'=>false,'msg'=>$shiduan . '时段服务组关联重复,计划id为:' . $v->id]; + } + } + return ['status'=>true,'msg'=>'']; + } //获取模板信息详情 public function GetDetailInfo() diff --git a/Laravel/app/Http/Controllers/API/Admin/YeWu/TimePeriodController.php b/Laravel/app/Http/Controllers/API/Admin/YeWu/TimePeriodController.php index 5ef931c..e20058d 100644 --- a/Laravel/app/Http/Controllers/API/Admin/YeWu/TimePeriodController.php +++ b/Laravel/app/Http/Controllers/API/Admin/YeWu/TimePeriodController.php @@ -57,11 +57,12 @@ class TimePeriodController extends Controller $searchInfo =request('searchInfo'); $page =request('page'); $pageSize =request('pageSize'); + $searchInfo['date_type']=$searchInfo['date_type']?$searchInfo['date_type']:1; $department_id=0; $list=DB::table('s_period') ->leftJoin('s_department', 's_period.department_id', '=', 's_department.id') ->select('s_period.*','s_department.department_name') - ->where(['s_period.is_del'=>0]); + ->where(['s_period.is_del'=>0,'s_period.date_type'=>$searchInfo['date_type']]); if($group==1){//如果是管理员 if(!empty($searchInfo['department_id'])){ @@ -83,9 +84,14 @@ class TimePeriodController extends Controller { $userid = $request->get('userid');//中间件产生的参数 $group = $request->get('role');//中间件产生的参数 + $date_type =request('date_type'); $userInfo = DB::table('users')->where(['id'=>$userid])->get(); $department_id=$userInfo[0]->department_id; + $list=DB::table('s_period'); + if(isset($date_type)){ + $list=$list->where('date_type',$date_type); + } $list=$list->where(['department_id'=>$department_id,'period_status'=>1,'is_del'=>0])->get(); if(count($list)>0){ return \Yz::Return(true, '操作成功',$list); diff --git a/YiJi-admin/.env.production b/YiJi-admin/.env.production index eccfff5..fbbaee0 100644 --- a/YiJi-admin/.env.production +++ b/YiJi-admin/.env.production @@ -1,6 +1,6 @@ ENV = 'production' -VITE_APP_API = 'http://10.50.120.166/YiJiYuYue/Laravel/public/api/' -VITE_APP_FILE = 'http://10.50.120.166/YiJiYuYue/Laravel/public/' +VITE_APP_API_66 = 'http://10.50.120.166/YiJiYuYue/Laravel/public/api/' +VITE_APP_FILE_666 = 'http://10.50.120.166/YiJiYuYue/Laravel/public/' -VITE_APP_API_6666 = 'https://yiji.yuluo.online/Laravel/public/api/' -VITE_APP_FILE_555 = 'https://yiji.yuluo.online/Laravel/public/' +VITE_APP_API = 'https://yiji.yuluo.online/Laravel/public/api/' +VITE_APP_FILE = 'https://yiji.yuluo.online/Laravel/public/' diff --git a/YiJi-admin/src/views/AppointmentMngr/PlanModel.vue b/YiJi-admin/src/views/AppointmentMngr/PlanModel.vue index f652f06..8d49b68 100644 --- a/YiJi-admin/src/views/AppointmentMngr/PlanModel.vue +++ b/YiJi-admin/src/views/AppointmentMngr/PlanModel.vue @@ -43,11 +43,18 @@ 生成选中的计划 - + + + 工作日 + 节假日 + + + - + @@ -92,13 +99,13 @@ :page-sizes="[15, 50, 100, 200]" layout="total,sizes, prev, pager, next" :total="total" @size-change="PageSizeChange" @current-change="PageCurrentChange" /> --> - + - - 全选 - + + 全选 + {{ item.label }} @@ -106,11 +113,20 @@ - - 当日总量 + + + + 根据总量 + 根据时长(分钟) + + - + + 设置渠道比例可自动分配 @@ -172,7 +188,8 @@ - 此诊室包含多台设备,如同时勾选多个,被勾选设备将共同占用分配的名额。如需为设备单独分配名额,请单独勾选(推荐) + + 此诊室包含多台设备,如同时勾选多个,被勾选设备将共同占用分配的名额。如需为设备单独分配名额,请单独勾选(推荐) {{ item.device_name }} @@ -208,6 +225,10 @@ + + + @@ -245,7 +266,7 @@ ElMessage, ElMessageBox } from 'element-plus' - + let CountType = ref("1"); //渠道数量设置方式 let loading = ref(false) let tableData = ref([]) let currentPage = ref(1) //当前页码 @@ -284,6 +305,8 @@ CreatePlanList({ dateRange: dateRange.value, ids: ids, + HolidayEnable:HolidayEnable.value, + date_type:searchInfo.value.date_type }).then(res => { if (res.status) { CreatePlanDialogVisible.value = false; @@ -292,12 +315,12 @@ type: 'success', }) } else { - ElMessageBox.alert(res.msg, '提示', { - // if you want to disable its autofocus - // autofocus: false, - confirmButtonText: '确定', - dangerouslyUseHTMLString: true, - }) + ElMessageBox.alert(res.msg, '提示', { + // if you want to disable its autofocus + // autofocus: false, + confirmButtonText: '确定', + dangerouslyUseHTMLString: true, + }) } }) } @@ -308,6 +331,8 @@ xingqi: null, status: null, }) + let HolidayEnable=ref(1) + let date_type_name =ref('工作日') let dialogVisible = ref(false) const GetList = () => { PlanModelGetList({ @@ -363,7 +388,7 @@ let PlanInfo = ref(DataDefault()) const Add = (row = null) => { - CheckedAll.value=false + CheckedAll.value = false dialogVisible.value = true PlanInfo.value = DataDefault() @@ -381,7 +406,11 @@ } } - + const DateTypeChange=()=>{ + if(searchInfo.value.date_type==1) date_type_name.value='工作日' + if(searchInfo.value.date_type==2) date_type_name.value='节假日' + GetList() + } const Save = () => { // console.log(PlanInfo.value) //判断各个渠道和是否等于总数 @@ -404,6 +433,7 @@ .then(() => { loading.value = true PlanModelSave({ + date_type:searchInfo.value.date_type, planInfo: PlanInfo.value }).then(res => { loading.value = false @@ -497,7 +527,6 @@ } //监听最大值输入 const MaxCountChange = (e) => { - console.log(e) if (e === '' || e == null || e === 0) { PlanInfo.value.max_total = 0 } @@ -532,17 +561,18 @@ let index = PlanInfo.value.qudao_total.indexOf(minRatioItem); console.log("最小且非零项在原数组中的位置:", index); console.log(bodongzhi); - if(bodongzhi>0){ - PlanInfo.value.qudao_total[index].count = PlanInfo.value.qudao_total[index].count -bodongzhi + if (bodongzhi > 0) { + PlanInfo.value.qudao_total[index].count = PlanInfo.value.qudao_total[index].count - bodongzhi } - if(bodongzhi<0 && index>0){ - PlanInfo.value.qudao_total[index-1].count = PlanInfo.value.qudao_total[index-1].count -bodongzhi + if (bodongzhi < 0 && index > 0) { + PlanInfo.value.qudao_total[index - 1].count = PlanInfo.value.qudao_total[index - 1].count - + bodongzhi } - if(bodongzhi<0 && index==0){ - PlanInfo.value.qudao_total[index].count = PlanInfo.value.qudao_total[index].count -bodongzhi + if (bodongzhi < 0 && index == 0) { + PlanInfo.value.qudao_total[index].count = PlanInfo.value.qudao_total[index].count - bodongzhi } - - PlanInfo.value.qudao_total.sort((a, b) => b.ratio - a.ratio); + + PlanInfo.value.qudao_total.sort((a, b) => b.ratio - a.ratio); } } @@ -551,7 +581,7 @@ let TimePeriodList = ref([]) const GetEnableTimePeriod = () => { loading.value = true - TimePeriodGetEnableList().then(res => { + TimePeriodGetEnableList({date_type:searchInfo.value.date_type}).then(res => { loading.value = false if (res.status) { TimePeriodList.value = res.data @@ -614,7 +644,7 @@ //切换资源 let devicesList = ref([]) const resourceChange = () => { - PlanInfo.value.devices=[]; + PlanInfo.value.devices = []; loading.value = true ResourceGetBindDeviceList({ resource_id: PlanInfo.value.resources_id @@ -629,89 +659,148 @@ }) } //获取当月日期范围 - const setMonthRange=()=>{ - GetServiceDateTime().then(res => { - if (res.status) { - let currentdate=res.data.datetime.substring(0,10) + const setMonthRange = () => { + GetServiceDateTime().then(res => { + if (res.status) { + let currentdate = res.data.datetime.substring(0, 10) var date = new Date(currentdate); - - // 获取当前月份(注意:JavaScript中的月份是从0开始计数的) - var currentMonth = date.getMonth(); - - // 计算下个月的月份,考虑到12月后应跳转到次年1月 - var nextMonthMonth = (currentMonth + 1) % 12; - var nextMonthYear = date.getFullYear() + ((currentMonth + 1) / 12 | 0); // 处理年份的进位 - - // 获取当前日期的日 - var currentDay = date.getDate(); - - // 创建下个月的同一天日期对象,需检查下月是否有同日,若无则调整至下月最后一天 - var nextMonthSameDay = new Date(nextMonthYear, nextMonthMonth, currentDay); - - // 检查是否需要调整到下月的最后一天(例如,3月31日到4月没有31日) - if (nextMonthSameDay.getMonth() !== nextMonthMonth) { - // 如果构造的日期月份变了,说明原日超出下月范围,应调整为下月最后一天 - nextMonthSameDay = new Date(nextMonthYear, nextMonthMonth, 0); - } - - // 返回格式化的日期字符串,可根据需要调整格式 - let nextMonth= nextMonthSameDay.toISOString().split('T')[0]; // 默认返回YYYY-MM-DD格式 - dateRange.value=[currentdate,nextMonth]; - } - - }) - } - let CheckedAll=ref(false); + + // 获取当前月份(注意:JavaScript中的月份是从0开始计数的) + var currentMonth = date.getMonth(); + + // 计算下个月的月份,考虑到12月后应跳转到次年1月 + var nextMonthMonth = (currentMonth + 1) % 12; + var nextMonthYear = date.getFullYear() + ((currentMonth + 1) / 12 | 0); // 处理年份的进位 + + // 获取当前日期的日 + var currentDay = date.getDate(); + + // 创建下个月的同一天日期对象,需检查下月是否有同日,若无则调整至下月最后一天 + var nextMonthSameDay = new Date(nextMonthYear, nextMonthMonth, currentDay); + + // 检查是否需要调整到下月的最后一天(例如,3月31日到4月没有31日) + if (nextMonthSameDay.getMonth() !== nextMonthMonth) { + // 如果构造的日期月份变了,说明原日超出下月范围,应调整为下月最后一天 + nextMonthSameDay = new Date(nextMonthYear, nextMonthMonth, 0); + } + + // 返回格式化的日期字符串,可根据需要调整格式 + let nextMonth = nextMonthSameDay.toISOString().split('T')[0]; // 默认返回YYYY-MM-DD格式 + dateRange.value = [currentdate, nextMonth]; + } + + }) + } + let CheckedAll = ref(false); //星期全选事件 - const CheckedAllFunc=(e)=>{ - if(e){ - PlanInfo.value.xingqi=['星期一','星期二','星期三','星期四','星期五','星期六','星期日']; - }else{ - PlanInfo.value.xingqi=[] + const CheckedAllFunc = (e) => { + if (e) { + PlanInfo.value.xingqi = ['星期一', '星期二', '星期三', '星期四', '星期五', '星期六', '星期日']; + } else { + PlanInfo.value.xingqi = [] } } //合并显示 - let bb_countRowspan=1; - const arraySpanMethod=({ - row, - column, - rowIndex, - columnIndex, - })=>{ - - const fields =['weekname'] - const cellValue =row[column.property] - let countRowspan=1 - - if(cellValue && fields.includes(column.property)){ - const prevRow = tableData.value[rowIndex-1] - let nextRow=tableData.value[rowIndex+1] - if(prevRow&& prevRow[column.property]=== cellValue && prevRow.declareRegion == row.declareRegion){ - bb_countRowspan=countRowspan - return {rowspan:0,colspan:0} - - - }else{ - while(nextRow && nextRow[column.property]===cellValue && nextRow.declareRegion==row.declareRegion){ - nextRow=tableData.value[++countRowspan+rowIndex] - } - if(countRowspan>1){ - bb_countRowspan=countRowspan - return {rowspan:countRowspan,colspan:1} - - } - } - - } - if (columnIndex === 3) { - if(bb_countRowspan>1){ - return {rowspan:bb_countRowspan,colspan:1} - }else{ - return {rowspan:0,colspan:0} - } - } + let bb_countRowspan = 1; + const arraySpanMethod = ({ + row, + column, + rowIndex, + columnIndex, + }) => { + + const fields = ['weekname'] + const cellValue = row[column.property] + let countRowspan = 1 + + if (cellValue && fields.includes(column.property)) { + const prevRow = tableData.value[rowIndex - 1] + let nextRow = tableData.value[rowIndex + 1] + if (prevRow && prevRow[column.property] === cellValue && prevRow.declareRegion == row.declareRegion) { + bb_countRowspan = countRowspan + return { + rowspan: 0, + colspan: 0 + } + + + } else { + while (nextRow && nextRow[column.property] === cellValue && nextRow.declareRegion == row + .declareRegion) { + nextRow = tableData.value[++countRowspan + rowIndex] + } + if (countRowspan > 1) { + bb_countRowspan = countRowspan + return { + rowspan: countRowspan, + colspan: 1 + } + + } + } + + } + // if (columnIndex === 3) { + // if (bb_countRowspan > 1) { + // return { + // rowspan: bb_countRowspan, + // colspan: 1 + // } + // } else { + // return { + // rowspan: 0, + // colspan: 0 + // } + // } + // } + } + //总量设置方式切换 + const CountTypeChange = (e) => { + CountType.value = e + MaxCountChange(0) + TimeLongChange(0) + if (e == 2) { + + } + } + //监听时长输入 + const TimeLongChange=(timelong)=>{ + if (CountType.value == 2) { //如果是根据时长计算总量 + if (PlanInfo.value.begin_time == '' || PlanInfo.value.end_time == '') { + ElMessage.error("请先设置时段") + PlanInfo.value.max_total = 0 + return false + } + ComPuteCountByTime(timelong) + } + } + //根据时长计算总量 + const ComPuteCountByTime = (timelong) => { + let count=calculateTimeSegments(PlanInfo.value.begin_time,PlanInfo.value.end_time,timelong) + PlanInfo.value.max_total=count + MaxCountChange(count) + } + //根据时间段和跨度算出数量 + function calculateTimeSegments(startTime, endTime, span) { + // 将时间字符串转换为分钟数 + function timeToMinutes(timeStr) { + const [hours, minutes] = timeStr.split(':').map(Number); + return hours * 60 + minutes; + } + + const startMinutes = timeToMinutes(startTime); + const endMinutes = timeToMinutes(endTime); + + // 计算总的时间差(以分钟为单位) + const totalMinutes = endMinutes - startMinutes; + + // 计算可以划分的时间段数量 + const segments = Math.floor(totalMinutes / span); + + return segments; } onMounted(() => { + searchInfo.value.date_type=1 GetList() GetDepartmentEnableList() getEnableResource() diff --git a/YiJi-admin/src/views/AppointmentMngr/TimePeriodMngr.vue b/YiJi-admin/src/views/AppointmentMngr/TimePeriodMngr.vue index 0b40bb8..d255171 100644 --- a/YiJi-admin/src/views/AppointmentMngr/TimePeriodMngr.vue +++ b/YiJi-admin/src/views/AppointmentMngr/TimePeriodMngr.vue @@ -13,6 +13,13 @@ 添加 + + + 工作日 + 节假日 + + @@ -132,7 +139,7 @@ } PeriodInfo.value.period_begin_time=PeriodInfo.value.timeRange[0] PeriodInfo.value.period_end_time=PeriodInfo.value.timeRange[1] - + PeriodInfo.value.date_type=searchInfo.value.date_type loading.value = true TimePeriodSave({PeriodInfo:PeriodInfo.value}).then(res => { loading.value = false @@ -207,12 +214,14 @@ } //选定时间范围 const changeTimeRange=()=>{ - PeriodInfo.value.period_deadline=PeriodInfo.value.timeRange[1] - - + } + //切换类型 + const DateTypeChange=()=>{ + GetList() } onMounted(()=>{ + searchInfo.value.date_type=1 GetList() GetDepartmentEnableList() })