批量停用

main
鹿和sa0ChunLuyu 1 week ago
parent 67131f2739
commit a4b16f78be

@ -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"));
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('批量禁用失败');
}
}
}

@ -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,

@ -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');//管理员获取主表列表(支持科室切换)

@ -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 })

@ -46,6 +46,7 @@
</el-form-item>
<el-button @click="GetList()" style="margin-left: 10px;">搜索</el-button>
<el-button type="danger" @click="Del()" style="margin-left: 10px;">删除</el-button>
<el-button type="warning" @click="BatchDisable()" style="margin-left: 10px;">批量禁用</el-button>
</el-row>
</div>
<div style="display: flex;" class="planInfo">
@ -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);

@ -46,6 +46,7 @@
</el-form-item>
<el-button @click="GetList()" style="margin-left: 10px;">搜索</el-button>
<el-button type="danger" @click="Del()" style="margin-left: 10px;">删除</el-button>
<el-button type="warning" @click="BatchDisable()" style="margin-left: 10px;">批量禁用</el-button>
</el-row>
</div>
<div style="display: flex;" class="planInfo">
@ -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);

Loading…
Cancel
Save