From a4b16f78be9eb35c56d6dbadf54b3096257fc6c7 Mon Sep 17 00:00:00 2001 From: sa0ChunLuyu Date: Tue, 28 Jul 2026 01:56:42 +0800 Subject: [PATCH] =?UTF-8?q?=E6=89=B9=E9=87=8F=E5=81=9C=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../API/Admin/YeWu/PlanListController.php | 59 ++++++++++++++++++- .../app/Services/Admin/YeWu/RosterService.php | 36 ++++++----- Laravel/routes/api.php | 2 + YiJi-admin/src/api/api.js | 8 +++ .../src/views/AppointmentMngr/PlanList.vue | 32 ++++++++++ .../views/AppointmentMngr/PlanListAdmin.vue | 33 +++++++++++ 6 files changed, 153 insertions(+), 17 deletions(-) diff --git a/Laravel/app/Http/Controllers/API/Admin/YeWu/PlanListController.php b/Laravel/app/Http/Controllers/API/Admin/YeWu/PlanListController.php index 67b485f..9c60642 100644 --- a/Laravel/app/Http/Controllers/API/Admin/YeWu/PlanListController.php +++ b/Laravel/app/Http/Controllers/API/Admin/YeWu/PlanListController.php @@ -419,6 +419,7 @@ public function BatchGenerateByDateRange(Request $request, RosterService $roster $dateRange = request('dateRange'); $HolidayEnable = request('HolidayEnable', 1); $autoMode = request('autoMode', 1); + $type = request('type'); $userid = 0; try { @@ -439,7 +440,11 @@ public function BatchGenerateByDateRange(Request $request, RosterService $roster foreach ($depts as $dept) { $today = date('Y-m-d'); $endDate = date('Y-m-d', strtotime("+{$dept->auto_gen_days} days")); - $deptDateRange = [$today, $endDate]; + if ($type === 'all') { + $deptDateRange = [$today, $endDate]; + } else { + $deptDateRange = [$endDate, $endDate]; + } $resources = DB::table('s_department_resources') ->where('department_id', $dept->id) @@ -848,4 +853,56 @@ public function DelAdmin(Request $request) return \Yz::echoError1('删除失败'); } } + + //批量禁用计划明细 + public function BatchDisable(Request $request) + { + $userid = $request->get('userid'); + $userInfo = DB::table('users')->where(['id' => $userid])->get(); + $department_id = $userInfo[0]->department_id; + $ids = request('ids'); + $u1 = DB::table('s_source_roster_detail')->where(['department_id' => $department_id])->whereIn('id', $ids)->update([ + 'status' => 0 + ]); + if ($u1) { + //记录操作日志 + $firstId = !empty($ids) ? $ids[0] : 0; + DB::table('s_source_roster_detail_log')->insert([ + 'roster_detail_id' => $firstId, + 'type' => '批量禁用', + 'content' => json_encode(['ids' => $ids, 'count' => count($ids)], JSON_UNESCAPED_UNICODE), + 'userid' => $userid + ]); + return \Yz::Return(true, '批量禁用成功', []); + } else { + return \Yz::echoError1('批量禁用失败'); + } + } + + //管理员批量禁用计划明细 + public function BatchDisableAdmin(Request $request) + { + $userid = $request->get('userid'); + $department_id = request('department_id'); + if (!$department_id) { + return \Yz::echoError1('科室信息不存在'); + } + $ids = request('ids'); + $u1 = DB::table('s_source_roster_detail')->where(['department_id' => $department_id])->whereIn('id', $ids)->update([ + 'status' => 0 + ]); + if ($u1) { + //记录操作日志 + $firstId = !empty($ids) ? $ids[0] : 0; + DB::table('s_source_roster_detail_log')->insert([ + 'roster_detail_id' => $firstId, + 'type' => '批量禁用', + 'content' => json_encode(['ids' => $ids, 'count' => count($ids)], JSON_UNESCAPED_UNICODE), + 'userid' => $userid + ]); + return \Yz::Return(true, '批量禁用成功', []); + } else { + return \Yz::echoError1('批量禁用失败'); + } + } } diff --git a/Laravel/app/Services/Admin/YeWu/RosterService.php b/Laravel/app/Services/Admin/YeWu/RosterService.php index ff1e24d..b4de125 100644 --- a/Laravel/app/Services/Admin/YeWu/RosterService.php +++ b/Laravel/app/Services/Admin/YeWu/RosterService.php @@ -95,6 +95,26 @@ public function generatePlans($dateRange, $planModelIds, $userId, $dateType = 1, continue; } + // --- 资源级存在性检查:当天该资源下是否有任何号源 --- + $resources_id = $models->first()->resources_id; + $resourceExists = DB::table('s_source_roster_detail') + ->where('resources_id', $resources_id) + ->where('date', $current_date_str) + ->where('is_del', 0) + ->exists(); + + if ($resourceExists) { + foreach ($models as $model) { + $skippedDates[] = [ + 'date' => $current_date_str, + 'template_id' => $model->id, + 'reason' => '已存在', + ]; + } + $current_date->modify('+1 day'); + continue; + } + // --- 获取星期 --- $weekday = (int)$current_date->format('w'); $weekname = $this->getWeekName($weekday); @@ -119,22 +139,6 @@ public function generatePlans($dateRange, $planModelIds, $userId, $dateType = 1, continue; } - // 检查当天该模板是否已有号源明细(存在即跳过) - $exists = DB::table('s_source_roster_detail') - ->where('roster_id', $model->id) - ->where('date', $current_date_str) - ->where('is_del', 0) - ->exists(); - - if ($exists) { - $skippedDates[] = [ - 'date' => $current_date_str, - 'template_id' => $model->id, - 'reason' => '已存在', - ]; - continue; - } - // --- 构造插入数据 --- $data = [ 'roster_id' => $model->id, diff --git a/Laravel/routes/api.php b/Laravel/routes/api.php index 0349b91..09e65d7 100644 --- a/Laravel/routes/api.php +++ b/Laravel/routes/api.php @@ -121,6 +121,8 @@ Route::post('admin/PlanTongJi','App\Http\Controllers\API\Admin\YeWu\PlanListController@TongJi');//计划统计 Route::post('admin/PlanDetailChangeInfo','App\Http\Controllers\API\Admin\YeWu\PlanListController@ChangeInfo');//修改计划详情信息 Route::post('admin/PlanListDel','App\Http\Controllers\API\Admin\YeWu\PlanListController@Del');//删除计划详情 + Route::post('admin/PlanListBatchDisable','App\Http\Controllers\API\Admin\YeWu\PlanListController@BatchDisable');//批量禁用 + Route::post('admin/PlanListBatchDisableAdmin','App\Http\Controllers\API\Admin\YeWu\PlanListController@BatchDisableAdmin');//管理员批量禁用 Route::post('admin/SaveLockedCount','App\Http\Controllers\API\Admin\YeWu\PlanListController@SaveLockedCount');//保存占位数量 Route::post('admin/GetMainList','App\Http\Controllers\API\Admin\YeWu\WorkMainController@GetList');//获取主表列表 Route::post('admin/GetMainListByDept','App\Http\Controllers\API\Admin\YeWu\WorkMainController@GetListByDept');//管理员获取主表列表(支持科室切换) diff --git a/YiJi-admin/src/api/api.js b/YiJi-admin/src/api/api.js index 84e4718..eace81e 100644 --- a/YiJi-admin/src/api/api.js +++ b/YiJi-admin/src/api/api.js @@ -367,6 +367,14 @@ export const PlanDetailPlanListDel = (data = {}) => { export const PlanDetailPlanListDelAdmin = (data = {}) => { return axios({ url: import.meta.env.VITE_APP_API + 'v1/admin/PlanListDelAdmin', data: data }) } +//批量禁用计划明细 +export const PlanListBatchDisable = (data = {}) => { + return axios({ url: import.meta.env.VITE_APP_API + 'v1/admin/PlanListBatchDisable', data: data }) +} +//批量禁用计划明细(管理员接口) +export const PlanListBatchDisableAdmin = (data = {}) => { + return axios({ url: import.meta.env.VITE_APP_API + 'v1/admin/PlanListBatchDisableAdmin', data: data }) +} //admin获取主表列表 export const GetMainList = (data = {}) => { return axios({ url: import.meta.env.VITE_APP_API + 'v1/admin/GetMainList', data: data }) diff --git a/YiJi-admin/src/views/AppointmentMngr/PlanList.vue b/YiJi-admin/src/views/AppointmentMngr/PlanList.vue index 4ac7f19..25cbe7e 100644 --- a/YiJi-admin/src/views/AppointmentMngr/PlanList.vue +++ b/YiJi-admin/src/views/AppointmentMngr/PlanList.vue @@ -46,6 +46,7 @@ 搜索 删除 + 批量禁用
@@ -308,6 +309,7 @@ PlanDetailChangeInfo, PlanListGetDetail, PlanDetailPlanListDel, + PlanListBatchDisable, GetPlanUsedList, SaveLockedCount } from '@/api/api.js' @@ -634,6 +636,36 @@ }) }) } + const BatchDisable = () => { + if (selectedPlanArr.value.length == 0) { + ElMessage.error("请至少勾选1条记录") + return false + } + ElMessageBox.confirm( + '确定批量禁用勾选的号源吗?', + '提示', { + confirmButtonText: '确定', + cancelButtonText: '取消', + type: 'warning', + } + ).then(() => { + loading.value = true + PlanListBatchDisable({ + ids: selectedPlanArr.value + }).then(res => { + loading.value = false + if (res.status) { + ElMessage({ + message: '批量禁用成功', + type: 'success', + }) + GetList() + } else { + ElMessage.error(res.msg) + } + }) + }) + } let MingXiDialogVisible = ref(false); let MingXiLoading = ref(false) let MingXiList = ref(null); diff --git a/YiJi-admin/src/views/AppointmentMngr/PlanListAdmin.vue b/YiJi-admin/src/views/AppointmentMngr/PlanListAdmin.vue index 91eee25..7ba0a06 100644 --- a/YiJi-admin/src/views/AppointmentMngr/PlanListAdmin.vue +++ b/YiJi-admin/src/views/AppointmentMngr/PlanListAdmin.vue @@ -46,6 +46,7 @@ 搜索 删除 + 批量禁用
@@ -308,6 +309,7 @@ PlanDetailChangeInfoAdmin, PlanListGetDetail, PlanDetailPlanListDelAdmin, + PlanListBatchDisableAdmin, GetPlanUsedList, SaveLockedCount } from '@/api/api.js' @@ -646,6 +648,37 @@ }) }) } + const BatchDisable = () => { + if (selectedPlanArr.value.length == 0) { + ElMessage.error("请至少勾选1条记录") + return false + } + ElMessageBox.confirm( + '确定批量禁用勾选的号源吗?', + '提示', { + confirmButtonText: '确定', + cancelButtonText: '取消', + type: 'warning', + } + ).then(() => { + loading.value = true + PlanListBatchDisableAdmin({ + ids: selectedPlanArr.value, + department_id: searchInfo.value.department_id + }).then(res => { + loading.value = false + if (res.status) { + ElMessage({ + message: '批量禁用成功', + type: 'success', + }) + GetList() + } else { + ElMessage.error(res.msg) + } + }) + }) + } let MingXiDialogVisible = ref(false); let MingXiLoading = ref(false) let MingXiList = ref(null);