diff --git a/Laravel/app/Http/Controllers/API/Admin/YeWu/DeptCheckItemController.php b/Laravel/app/Http/Controllers/API/Admin/YeWu/DeptCheckItemController.php
index ca6b30a..c5492e8 100644
--- a/Laravel/app/Http/Controllers/API/Admin/YeWu/DeptCheckItemController.php
+++ b/Laravel/app/Http/Controllers/API/Admin/YeWu/DeptCheckItemController.php
@@ -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);
+ }
}
\ No newline at end of file
diff --git a/Laravel/app/Services/Admin/YeWu/DeptCheckItemService.php b/Laravel/app/Services/Admin/YeWu/DeptCheckItemService.php
index e00c103..e2a0f81 100644
--- a/Laravel/app/Services/Admin/YeWu/DeptCheckItemService.php
+++ b/Laravel/app/Services/Admin/YeWu/DeptCheckItemService.php
@@ -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();
+ }
}
\ No newline at end of file
diff --git a/Laravel/routes/api.php b/Laravel/routes/api.php
index bba6f20..c198763 100644
--- a/Laravel/routes/api.php
+++ b/Laravel/routes/api.php
@@ -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');//删除当前科室下的设备
diff --git a/YiJi-admin/src/api/api.js b/YiJi-admin/src/api/api.js
index 97406d0..7e914a6 100644
--- a/YiJi-admin/src/api/api.js
+++ b/YiJi-admin/src/api/api.js
@@ -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 })
diff --git a/YiJi-admin/src/views/YeWu/DeptCheckItemConfig.vue b/YiJi-admin/src/views/YeWu/DeptCheckItemConfig.vue
index adea6eb..fdf0198 100644
--- a/YiJi-admin/src/views/YeWu/DeptCheckItemConfig.vue
+++ b/YiJi-admin/src/views/YeWu/DeptCheckItemConfig.vue
@@ -34,6 +34,7 @@
批量关联排班
批量设置检查须知
批量设置温馨提示
+ 同步项目
@@ -280,6 +281,38 @@
确定
+
+
+
+
+
+
+
+
+
+
+
+
+
+
{{ syncResult.added }}
+
新增项目
+
+
+
{{ syncResult.removed }}
+
移除项目
+
+
+
{{ syncResult.updated }}
+
更新项目
+
+
+
+
+
+
+ 确定
+
+
@@ -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