科室级别的更新项目

main
鹿和sa0ChunLuyu 7 days ago
parent e3768dd500
commit 27d1f65f40

@ -54,4 +54,19 @@ public function Save()
$service = new DeptCheckItemService();
return $service->Save($Info);
}
//同步检查项目分类
public function SyncItemClass()
{
$service = new DeptCheckItemService();
return $service->SyncItemClass();
}
//同步检查项目 + 返回当前科室统计
public function SyncCheckItem(Request $request)
{
$userid = $request->get('userid');
$service = new DeptCheckItemService();
return $service->SyncCheckItem($userid);
}
}

@ -181,4 +181,65 @@ public function Save($Info){
return \Yz::Return(false, 'id不能为空');
}
}
//同步检查项目分类(全量,复用 HIS 逻辑)
public function SyncItemClass()
{
$hisController = app(\App\Http\Controllers\API\His\CheckItemController::class);
return $hisController->UpdateItemClass();
}
//同步检查项目(全量) + 返回当前科室相关统计
public function SyncCheckItem($userid)
{
// 1. 同步前快照:当前科室所有符合条件的项目 code
$beforeCodes = $this->getDeptItemCodes($userid);
// 2. 调用 HIS 同步项目(全量)
request()->merge(['termClassId' => 155]);
$hisController = app(\App\Http\Controllers\API\His\CheckItemController::class);
$hisController->UpdateCheckItem();
// 3. 同步后快照
$afterCodes = $this->getDeptItemCodes($userid);
// 4. 对比统计
$beforeSet = array_flip($beforeCodes);
$afterSet = array_flip($afterCodes);
return \Yz::Return(true, '同步完成', [
'added' => count(array_diff_key($afterSet, $beforeSet)),
'removed' => count(array_diff_key($beforeSet, $afterSet)),
'updated' => count(array_intersect_key($beforeSet, $afterSet)),
]);
}
//获取当前科室所有符合条件的项目 code 列表
private function getDeptItemCodes($userid)
{
$user = DB::table('users')->where('id', $userid)->first();
if (!$user || !$user->department_id) return [];
$deptNumbers = DB::table('s_department')
->where('is_del', 0)
->where(function($q) use ($user) {
$q->where('id', $user->department_id)
->orWhere('pid', $user->department_id);
})
->pluck('department_number')
->toArray();
if (empty($deptNumbers)) return [];
return DB::table('s_check_item')
->where('is_del', 0)
->whereNotNull('sheetType')->where('sheetType', '!=', '')
->where(function($q) use ($deptNumbers) {
foreach ($deptNumbers as $num) {
$q->orWhere('hisExecDepts', 'like', '%"' . $num . '"%');
}
})
->pluck('item_code')
->toArray();
}
}

@ -60,6 +60,8 @@
Route::post('admin/DeptItemBindDevice','App\Http\Controllers\API\Admin\YeWu\DeptCheckItemController@BindDevice');//当前科室权限的检查项目绑定设备
Route::post('admin/DeptSaveItemInfo','App\Http\Controllers\API\Admin\YeWu\DeptCheckItemController@Save');//当前科室权限的保存检查项目信息
Route::post('admin/DeptBatchUpdateNotice','App\Http\Controllers\API\Admin\YeWu\DeptCheckItemController@BatchUpdateNotice');//科室版本批量更新检查须知/温馨提示
Route::post('admin/DeptSyncItemClass','App\Http\Controllers\API\Admin\YeWu\DeptCheckItemController@SyncItemClass');//科室版本同步检查项目分类
Route::post('admin/DeptSyncCheckItem','App\Http\Controllers\API\Admin\YeWu\DeptCheckItemController@SyncCheckItem');//科室版本同步检查项目
Route::post('admin/GetDeptDeviceListPage','App\Http\Controllers\API\Admin\YeWu\DeptDeviceController@GetList');//获取当前科室下的设备列表(分页)
Route::post('admin/SaveDeptDevice','App\Http\Controllers\API\Admin\YeWu\DeptDeviceController@Save');//保存当前科室下的设备
Route::post('admin/DelDeptDevice','App\Http\Controllers\API\Admin\YeWu\DeptDeviceController@Del');//删除当前科室下的设备

@ -208,6 +208,14 @@ export const DeptSaveItemInfo = (data = {}) => {
export const DeptBatchUpdateNotice = (data = {}) => {
return axios({ url: import.meta.env.VITE_APP_API + 'v1/admin/DeptBatchUpdateNotice', data: data })
}
//科室版本同步检查项目分类
export const DeptSyncItemClass = (data = {}) => {
return axios({ url: import.meta.env.VITE_APP_API + 'v1/admin/DeptSyncItemClass', data: data })
}
//科室版本同步检查项目
export const DeptSyncCheckItem = (data = {}) => {
return axios({ url: import.meta.env.VITE_APP_API + 'v1/admin/DeptSyncCheckItem', data: data })
}
//admin获取科室列表
export const GetDepartmentList = (data = {}) => {
return axios({ url: import.meta.env.VITE_APP_API + 'v1/admin/GetDepartmentList', data: data })

@ -34,6 +34,7 @@
<el-button type="primary" @click="BatchLinkDevice()" style="margin-left: 10px;">批量关联排班</el-button>
<el-button type="primary" @click="openBatchNotice('check_notice')" style="margin-left: 10px;">批量设置检查须知</el-button>
<el-button type="primary" @click="openBatchNotice('warm_tips')" style="margin-left: 10px;">批量设置温馨提示</el-button>
<el-button type="warning" @click="openSyncDialog" 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">
@ -280,6 +281,38 @@
<el-button type="primary" @click="saveBatchNotice"></el-button>
</template>
</el-dialog>
<el-dialog v-model="syncDialogVisible" title="同步项目" width="480px" :close-on-click-modal="false">
<template v-if="!syncDone">
<el-steps :active="syncStep" align-center finish-status="success" style="margin-top: 10px;">
<el-step title="同步分类" />
<el-step title="同步项目" />
</el-steps>
<el-progress :percentage="syncPercent" :stroke-width="14" style="margin-top: 24px;" />
</template>
<template v-else>
<el-result icon="success" title="同步完成">
<template #extra>
<div style="display: flex; justify-content: space-around; padding: 12px 0;">
<div style="text-align: center;">
<div style="font-size: 28px; font-weight: 700; color: #409eff;">{{ syncResult.added }}</div>
<div style="color: #999; font-size: 13px;">新增项目</div>
</div>
<div style="text-align: center;">
<div style="font-size: 28px; font-weight: 700; color: #e6a23c;">{{ syncResult.removed }}</div>
<div style="color: #999; font-size: 13px;">移除项目</div>
</div>
<div style="text-align: center;">
<div style="font-size: 28px; font-weight: 700; color: #67c23a;">{{ syncResult.updated }}</div>
<div style="color: #999; font-size: 13px;">更新项目</div>
</div>
</div>
</template>
</el-result>
</template>
<template #footer>
<el-button v-if="syncDone" type="primary" @click="syncDialogVisible = false"></el-button>
</template>
</el-dialog>
</div>
</template>
@ -303,7 +336,9 @@
GetCheckItemRules,
SaveCheckItemRules,
DeptBatchUpdateNotice,
GetItemRelatedResources
GetItemRelatedResources,
DeptSyncItemClass,
DeptSyncCheckItem
} from '@/api/api.js'
import {
ElMessage,
@ -421,6 +456,13 @@
let batchNoticeTitle = ref('')
let batchNoticeValue = ref('')
//
let syncDialogVisible = ref(false)
let syncStep = ref(0)
let syncPercent = ref(0)
let syncDone = ref(false)
let syncResult = ref({ added: 0, removed: 0, updated: 0 })
//
const linkDialogTitle = computed(() => {
return isBatchLink.value ? '批量关联排班' : '关联排班'
@ -480,6 +522,40 @@
})
}
//
const openSyncDialog = async () => {
syncDialogVisible.value = true
syncStep.value = 0
syncPercent.value = 0
syncDone.value = false
syncResult.value = { added: 0, removed: 0, updated: 0 }
// 1
const classRes = await DeptSyncItemClass()
if (!classRes.status) {
ElMessage.error('同步分类失败:' + (classRes.msg || '未知错误'))
syncDialogVisible.value = false
return
}
syncStep.value = 1
syncPercent.value = 50
// 2
const itemRes = await DeptSyncCheckItem()
if (!itemRes.status) {
ElMessage.error('同步项目失败:' + (itemRes.msg || '未知错误'))
syncDialogVisible.value = false
return
}
syncResult.value = itemRes.data
syncStep.value = 2
syncPercent.value = 100
syncDone.value = true
//
GetItemClassList()
}
//穿
const LinkDeviceClick = (row) => {
isBatchLink.value = false

Loading…
Cancel
Save