1. 检查项目管理功能下放到科室层

main
鹿和sa0ChunLuyu 3 weeks ago
parent 28b967f952
commit 99819b7e90

@ -39,4 +39,48 @@ public function Del()
return $service->Del($id);
}
// 获取当前用户科室下的设备列表
public function GetDeptList(Request $request)
{
$userid = $request->get('userid');
$service = new DevicesService();
return $service->GetDeptList($userid);
}
// 获取设备已绑定的检查项目
public function GetBindItems()
{
$device_id = request('device_id');
$service = new DevicesService();
return $service->GetBindItems($device_id);
}
// 绑定检查项目到设备
public function BindItem()
{
$item_id = request('item_id');
$device_id = request('device_id');
$service = new DevicesService();
return $service->BindItem($item_id, $device_id);
}
// 解除绑定
public function UnbindItem()
{
$item_id = request('item_id');
$device_id = request('device_id');
$service = new DevicesService();
return $service->UnbindItem($item_id, $device_id);
}
// 获取未绑定的检查项目(分页)
public function GetUnboundItems()
{
$device_id = request('device_id');
$keyword = request('keyword');
$page = request('page');
$pageSize = request('pageSize');
$service = new DevicesService();
return $service->GetUnboundItems($device_id, $keyword, $page, $pageSize);
}
}

@ -13,6 +13,7 @@ class YiJiController extends Controller
//查询是否跳转医技
public function CheckAppointment()
{
try {
$cardNo = request('cardNo');//病人id
$visitSqNo = request('visitSqNo');//门诊挂号流水号/住院流水号
@ -20,10 +21,14 @@ public function CheckAppointment()
$moOrderList = request('OrderNoList');//医嘱号列表(数组)
$visitTypeCode = request('visitTypeCode');// 01:门诊 02:急诊 03:住院 04:体检 05:互联网 09:其他
$is_redirect = false;
$patientTypeMapping = ['03' => 0, '01' => 1, '02' => 2, '04' => 3];
$patientType = $patientTypeMapping[$visitTypeCode] ?? 9; $is_redirect = false;
$url = "";
$entrust_ids = [];
$termCodes = [];
if (!is_array($requestNoList)) {
return \Yz::JsonReturn(false, 'requestNoList 参数必须是数组', []);
}
foreach ($requestNoList as $requestNo) {
//1.查询his获取申请单全部检查项目
$data = [
@ -33,8 +38,12 @@ public function CheckAppointment()
'feeFlag' => 0,
];
$debug_roc_url = 'http://192.168.80.39:7801/roc/order-service/api/v1/apply/pacs/apply/create/query';
$debug_roc_params = $data;
$His = new HisController();
$res = $His::Get("查询检查申请单", $data);
$debug_hisResponse = $res;
if ($res['code'] == 200) {
$res_data = $res['data'];
foreach ($res_data as $data_k => $data_v) {
@ -63,6 +72,7 @@ public function CheckAppointment()
$patientType = $mapping[$visitTypeCode] ?? 9;
foreach ($data_v['itemList'] as $item_k => $item) {
$entrust_ids[] = $item['orderNo'];
$termCodes[] = $item['termCode'];
//查询库里是否存在该检医嘱
$db_item = DB::table('s_list')->where(['entrust_id' => $item['orderNo']])->first();
if (!$db_item) {
@ -134,13 +144,57 @@ public function CheckAppointment()
if (true) {
// 检查是否有诊室参与预约
$termCodes = array_unique($termCodes);
$hasEnabledRoom = 0;
if (!empty($termCodes)) {
$hasEnabledRoom = DB::table('s_check_item')
->whereIn('s_check_item.item_code', $termCodes)
->join('s_check_item_device', 's_check_item.id', '=', 's_check_item_device.item_id')
->join('s_source_roster_detail_device', 's_check_item_device.device_id', '=', 's_source_roster_detail_device.device_id')
->join('s_source_roster_detail', 's_source_roster_detail_device.roster_detail_id', '=', 's_source_roster_detail.id')
->join('s_department_resources', 's_source_roster_detail.resources_id', '=', 's_department_resources.id')
->where('s_source_roster_detail.status', 1)
->where('s_source_roster_detail.is_del', 0)
->where('s_department_resources.is_del', 0)
->where('s_department_resources.department_resources_status', 1)
->where('s_department_resources.appointment_enabled', 1)
->whereRaw("FIND_IN_SET(?, s_source_roster_detail.patient_type)", [$patientType])
->count();
}
if ($hasEnabledRoom > 0) {
$is_redirect = true;
$url = $this->build_yiji_url($cardNo, $entrust_ids, $visitSqNo);
} else {
$is_redirect = false;
$url = '';
}
// 查询执行诊室名称
$roomNames = [];
if (!empty($termCodes)) {
$roomNames = DB::table('s_check_item')
->whereIn('s_check_item.item_code', $termCodes)
->join('s_check_item_device', 's_check_item.id', '=', 's_check_item_device.item_id')
->join('s_source_roster_detail_device', 's_check_item_device.device_id', '=', 's_source_roster_detail_device.device_id')
->join('s_source_roster_detail', 's_source_roster_detail_device.roster_detail_id', '=', 's_source_roster_detail.id')
->join('s_department_resources', 's_source_roster_detail.resources_id', '=', 's_department_resources.id')
->where('s_source_roster_detail.status', 1)
->where('s_source_roster_detail.is_del', 0)
->where('s_department_resources.is_del', 0)
->where('s_department_resources.department_resources_status', 1)
->where('s_department_resources.appointment_enabled', 1)
->whereRaw("FIND_IN_SET(?, s_source_roster_detail.patient_type)", [$patientType])
->distinct()
->pluck('s_department_resources.department_resources_name')
->toArray();
}
return \Yz::JsonReturn(true, '查询成功', ['is_redirect' => $is_redirect, 'url' => $url, 'room_names' => $roomNames, 'debug_termCodes' => $termCodes, 'debug_hisResponse' => $debug_hisResponse ?? [], 'debug_roc_url' => $debug_roc_url ?? '', 'debug_roc_params' => $debug_roc_params ?? []]);
} catch (\Exception $e) {
return \Yz::JsonReturn(false, '接口异常:' . $e->getMessage(), ['error_file' => $e->getFile(), 'error_line' => $e->getLine()]);
}
return \Yz::JsonReturn(true, '查询成功', ['is_redirect' => $is_redirect, 'url' => $url]);
}
function QueryHisShenQingDan()

@ -12,7 +12,7 @@ public function GetList($searchInfo,$page,$pageSize){
$where[]=['device_name','like','%'.$searchInfo['name'].'%'];
}
$count= $list->where($where)->count();
$list= $list->where($where)->skip(($page-1)*$pageSize) // 跳过前9999条记录
$list= $list->where($where)->skip(($page-1)*$pageSize)
->take($pageSize)->get();
return \Yz::Return(true, '查询成功', ['list'=>$list,'count'=>$count]);
}
@ -48,4 +48,109 @@ public function Del($id){
return \Yz::Return(false, '删除失败');
}
}
// 获取当前用户科室下的设备列表
public function GetDeptList($userid)
{
$user = DB::table('users')->where('id', $userid)->first();
if (!$user || !$user->department_id) {
return \Yz::Return(true, '查询成功', []);
}
$list = DB::table('s_devices')
->join('s_department_resources_device', 's_devices.id', '=', 's_department_resources_device.device_id')
->where('s_department_resources_device.department_id', $user->department_id)
->where('s_devices.is_del', 0)
->where('s_devices.status', 1)
->select('s_devices.*',
DB::raw('(SELECT COUNT(*) FROM s_check_item_device WHERE device_id = s_devices.id) AS bind_count'))
->distinct()
->orderBy('s_devices.id')
->get();
return \Yz::Return(true, '查询成功', $list);
}
// 获取设备已绑定的检查项目
public function GetBindItems($device_id)
{
$list = DB::table('s_check_item_device')
->join('s_check_item', 's_check_item_device.item_id', '=', 's_check_item.id')
->leftJoin('s_check_item_class', 's_check_item.item_class_id', '=', 's_check_item_class.id')
->where('s_check_item_device.device_id', $device_id)
->where('s_check_item.is_del', 0)
->select('s_check_item.id', 's_check_item.item_code', 's_check_item.item_name',
's_check_item_class.item_class_name')
->orderBy('s_check_item.id')
->get();
return \Yz::Return(true, '查询成功', $list);
}
// 绑定检查项目到设备
public function BindItem($item_id, $device_id)
{
// 检查是否已存在
$exists = DB::table('s_check_item_device')
->where('item_id', $item_id)
->where('device_id', $device_id)
->first();
if ($exists) {
return \Yz::Return(false, '该绑定关系已存在');
}
$id = DB::table('s_check_item_device')->insertGetId([
'item_id' => $item_id,
'device_id' => $device_id,
]);
if ($id) {
return \Yz::Return(true, '绑定成功');
} else {
return \Yz::Return(false, '绑定失败');
}
}
// 解除绑定
public function UnbindItem($item_id, $device_id)
{
$deleted = DB::table('s_check_item_device')
->where('item_id', $item_id)
->where('device_id', $device_id)
->delete();
if ($deleted) {
return \Yz::Return(true, '解绑成功');
} else {
return \Yz::Return(false, '解绑失败');
}
}
// 获取未绑定的检查项目(分页,排除已绑定的)
public function GetUnboundItems($device_id, $keyword, $page, $pageSize)
{
$list = DB::table('s_check_item')
->leftJoin('s_check_item_class', 's_check_item.item_class_id', '=', 's_check_item_class.id')
->where('s_check_item.is_del', 0)
->where('s_check_item.status', 1)
->whereNotNull('s_check_item.sheetType')
->where('s_check_item.sheetType', '!=', '')
->whereNotExists(function ($query) use ($device_id) {
$query->select(DB::raw(1))
->from('s_check_item_device')
->whereColumn('s_check_item_device.item_id', 's_check_item.id')
->where('s_check_item_device.device_id', $device_id);
});
if (!empty($keyword)) {
$list->where(function ($q) use ($keyword) {
$q->where('s_check_item.item_name', 'like', '%' . $keyword . '%')
->orWhere('s_check_item.item_code', 'like', '%' . $keyword . '%');
});
}
$count = $list->count();
$items = $list->select('s_check_item.id', 's_check_item.item_code', 's_check_item.item_name',
's_check_item_class.item_class_name')
->orderBy('s_check_item.id')
->skip(($page - 1) * $pageSize)
->take($pageSize)
->get();
return \Yz::Return(true, '查询成功', ['list' => $items, 'count' => $count]);
}
}

@ -138,6 +138,7 @@ public function GetEnablePlan($regnum, $entrustids, $episodeid, $appointment_typ
AND a.STATUS = 1
AND a.is_del = 0
AND b.is_del = 0
AND b.appointment_enabled = 1
AND c.appointment_type_id = ?", $canshu);
foreach ($plan as $p) {
@ -178,6 +179,7 @@ public function GetEnablePlan($regnum, $entrustids, $episodeid, $appointment_typ
AND a.STATUS = 1
AND a.is_del = 0
AND b.is_del = 0
AND b.appointment_enabled = 1
AND c.appointment_type_id IN ($appointment_types_placeholders)", $canshu);
$mergedPlan = [];
@ -194,6 +196,15 @@ public function GetEnablePlan($regnum, $entrustids, $episodeid, $appointment_typ
$plan = array_values($mergedPlan);
}
//遍历列表 把超过当前时间的放在后面
// debug: 查看plan中的resources_id
$debugAllRids = [];
foreach ($plan as $p) {
$debugAllRids[] = $p->resources_id;
}
$debugAllRids = array_unique($debugAllRids);
$debugPlanCount = count($plan);
$debugSkipped = []; // 记录被跳过的
$debugPassed = []; // 记录通过的
$pl1 = [];
$pl2 = [];
$pp = [];
@ -201,7 +212,9 @@ public function GetEnablePlan($regnum, $entrustids, $episodeid, $appointment_typ
foreach ($plan as $key => $p) {
// //病人类型不符合的过滤掉
$planPatientType = explode(",", $p->patient_type);
if (!empty(array_diff($commPatientType, $planPatientType))) {
$diff = array_diff($commPatientType, $planPatientType);
if (!empty($diff)) {
$debugSkipped[] = ['rid' => $p->resources_id, 'reason' => 'patient_type', 'planTypes' => $p->patient_type, 'commTypes' => $commPatientType, 'diff' => array_values($diff)];
continue;
}
@ -209,10 +222,13 @@ public function GetEnablePlan($regnum, $entrustids, $episodeid, $appointment_typ
if (!empty($allItemRules)) {
$rulePass = $this->checkPlanAgainstRules($p, $allItemRules);
if (!$rulePass) {
$debugSkipped[] = ['rid' => $p->resources_id, 'reason' => 'rule'];
continue;
}
}
$debugPassed[] = $p->resources_id;
//过期的排在后面
$time = $p->date . ' ' . $p->end_time;
if ($time > $nowtime) {
@ -245,6 +261,11 @@ public function GetEnablePlan($regnum, $entrustids, $episodeid, $appointment_typ
'zhanWeiCount'=>$zhanweiCount,
'earliestPlan'=>$earliestPlan,
'is_emergency' => $allEmergency,
'debug_commonDevice' => $commonDevice,
'debug_planCount' => $debugPlanCount ?? 0,
'debug_allRids' => $debugAllRids ?? [],
'debug_skipped' => $debugSkipped ?? [],
'debug_passedRids' => array_values(array_unique($debugPassed ?? [])),
]);
}

@ -57,6 +57,11 @@
Route::post('admin/SaveDeviceList','App\Http\Controllers\API\Admin\YeWu\DevicesController@Save');//admin后台保存设备列表
Route::post('admin/GetEnableDeviceList','App\Http\Controllers\API\Admin\YeWu\DevicesController@GetEnableList');//admin后台可用设备列表
Route::post('admin/DelDevice','App\Http\Controllers\API\Admin\YeWu\DevicesController@Del');//admin后台删除设备列表
Route::post('admin/GetDeptDeviceList','App\Http\Controllers\API\Admin\YeWu\DevicesController@GetDeptList');//获取当前科室下的设备列表
Route::post('admin/GetDeviceBindItems','App\Http\Controllers\API\Admin\YeWu\DevicesController@GetBindItems');//获取设备已绑定的检查项目
Route::post('admin/BindItemToDevice','App\Http\Controllers\API\Admin\YeWu\DevicesController@BindItem');//绑定检查项目到设备
Route::post('admin/UnbindItemFromDevice','App\Http\Controllers\API\Admin\YeWu\DevicesController@UnbindItem');//解除绑定
Route::post('admin/GetUnboundCheckItems','App\Http\Controllers\API\Admin\YeWu\DevicesController@GetUnboundItems');//获取未绑定的检查项目(分页)
Route::post('admin/ItemBindDevice','App\Http\Controllers\API\Admin\YeWu\CheckItemController@BindDevice');//admin后台检查项目绑定设备
Route::post('admin/GetYuYueTypes','App\Http\Controllers\API\Admin\YeWu\YuYueTypeController@GetTypes');//admin后台获取预约类型
Route::post('admin/SaveItemInfo','App\Http\Controllers\API\Admin\YeWu\CheckItemController@Save');//admin后台保存检查项目信息

@ -140,6 +140,26 @@ export const GetEnableDeviceList = (data = {}) => {
export const ItemBindDevice = (data = {}) => {
return axios({ url: import.meta.env.VITE_APP_API + 'v1/admin/ItemBindDevice', data: data })
}
//admin后台获取当前科室下的设备列表
export const GetDeptDeviceList = (data = {}) => {
return axios({ url: import.meta.env.VITE_APP_API + 'v1/admin/GetDeptDeviceList', data: data })
}
//admin后台获取设备已绑定的检查项目
export const GetDeviceBindItems = (data = {}) => {
return axios({ url: import.meta.env.VITE_APP_API + 'v1/admin/GetDeviceBindItems', data: data })
}
//admin后台绑定检查项目到设备
export const BindItemToDevice = (data = {}) => {
return axios({ url: import.meta.env.VITE_APP_API + 'v1/admin/BindItemToDevice', data: data })
}
//admin后台解除绑定
export const UnbindItemFromDevice = (data = {}) => {
return axios({ url: import.meta.env.VITE_APP_API + 'v1/admin/UnbindItemFromDevice', data: data })
}
//admin后台获取未绑定的检查项目分页
export const GetUnboundCheckItems = (data = {}) => {
return axios({ url: import.meta.env.VITE_APP_API + 'v1/admin/GetUnboundCheckItems', data: data })
}
//admin后台获取预约类型
export const GetYuYueTypes = (data = {}) => {
return axios({ url: import.meta.env.VITE_APP_API + 'v1/admin/GetYuYueTypes', data: data })

@ -1,22 +1,26 @@
<template>
<div>
<el-dialog v-model="dialogVisible" title="资源信息" width="30%" @close="close()">
<el-form :model="ResourcesInfo" label-width="100px" v-loading="loading" style="padding-right: 40px;">
<el-dialog v-model="dialogVisible" title="诊室信息" width="30%" @close="close()">
<el-form :model="ResourcesInfo" label-width="110px" v-loading="loading" style="padding-right: 40px;">
<el-form-item label="所属科室:">
<el-select :filterable="true" clearable v-model="ResourcesInfo.department_id" placeholder="选择科室">
<el-option v-for="(item,index) in EnableDepartmentList" :key="index" :label="item.department_name" :value="item.id" />
</el-select>
</el-form-item>
<el-form-item label="资源名称:">
<el-form-item label="诊室名称:">
<el-input v-model="ResourcesInfo.department_resources_name" />
</el-form-item>
<el-form-item label="资源位置:">
<el-form-item label="诊室位置:">
<el-input v-model="ResourcesInfo.department_resources_addr" />
</el-form-item>
<el-form-item label="资源状态:">
<el-form-item label="诊室状态:">
<el-switch v-model="ResourcesInfo.department_resources_status" active-text="" inactive-text=""
:active-value="1" :inactive-value="0" />
</el-form-item>
<el-form-item label="参与预约:">
<el-switch v-model="ResourcesInfo.appointment_enabled" active-text="" inactive-text=""
:active-value="1" :inactive-value="0" />
</el-form-item>
<el-form-item label="时令:">
<div>
<el-switch v-model="ResourcesInfo.time_mode" size="large" active-text="" inactive-text="" :active-value="1" :inactive-value="0" @change="timeModeChange"/>
@ -93,7 +97,8 @@
department_resources_status:1,
department_resources_addr:'',
time_mode: 0, // 0 1
time_range: [] //
time_range: [], //
appointment_enabled: 1 //
})
//
@ -232,6 +237,7 @@
ResourcesInfo.value.department_resources_name=props.resourceInfo.department_resources_name
ResourcesInfo.value.department_resources_addr=props.resourceInfo.department_resources_addr
ResourcesInfo.value.department_resources_status=props.resourceInfo.department_resources_status
ResourcesInfo.value.appointment_enabled=props.resourceInfo.appointment_enabled ?? 1
//
ResourcesInfo.value.time_mode = props.resourceInfo.time_mode || 0

@ -150,7 +150,14 @@ const router = createRouter({
name: 'YewuDepartmentResources',
component: () => import('../views/YeWu/DepartmentResources.vue'),
meta: {
title: '资源管理'
title: '诊室管理'
}
},{
path: '/yewu/deviceCheckItemBind',
name: 'YewuDeviceCheckItemBind',
component: () => import('../views/YeWu/DeviceCheckItemBind.vue'),
meta: {
title: '检查项目管理'
}
},{
path: '/appointmentmngr/timeperiodmngr',

@ -0,0 +1,353 @@
<template>
<div v-loading="loading">
<div class="page-container">
<!-- 左侧服务组执行检查室列表 -->
<div class="left-panel">
<div class="panel-header">
<span class="panel-title">执行检查室</span>
</div>
<div class="device-list">
<div v-for="item in deviceList" :key="item.id"
class="device-item"
:class="{ active: selectedDevice?.id === item.id }"
@click="selectDevice(item)">
<div class="device-name">{{ item.device_name }}</div>
<div class="device-count">已绑定 {{ item.bind_count || 0 }} </div>
</div>
<div v-if="deviceList.length === 0" class="empty-tip">
暂无服务组
</div>
</div>
</div>
<!-- 右侧已绑定的检查项目 -->
<div class="right-panel">
<div class="panel-header">
<span class="panel-title">
{{ selectedDevice ? selectedDevice.device_name + ' - 已绑定的检查项目' : '请选择一个执行检查室' }}
</span>
</div>
<div v-if="selectedDevice" class="right-content">
<div style="margin-bottom: 12px;">
<el-button type="primary" @click="openBindDialog"></el-button>
</div>
<el-table :data="boundItems" style="width: 100%;" row-key="id" v-loading="boundLoading">
<el-table-column prop="item_code" label="项目编号" width="160" />
<el-table-column prop="item_name" label="检查项目名称" />
<el-table-column prop="item_class_name" label="医嘱类别" />
<el-table-column prop="" label="操作" width="100">
<template #default="scope">
<el-button type="danger" size="small" @click="removeBind(scope.row)"></el-button>
</template>
</el-table-column>
</el-table>
<div v-if="boundItems.length === 0 && !boundLoading" class="empty-tip" style="margin-top: 20px;">
暂无绑定的检查项目
</div>
</div>
</div>
</div>
</div>
<!-- 添加绑定弹窗 -->
<el-dialog v-model="showBindDialog" title="添加检查项目绑定" width="60%" @closed="closeBindDialog">
<div>
<div style="display: flex; gap: 12px; margin-bottom: 12px;">
<el-input v-model="bindSearchKeyword" placeholder="输入项目编号/名称搜索"
clearable style="flex: 1;" @input="onBindSearchInput" />
<el-button type="primary" @click="doBindSearch"></el-button>
<el-button @click="refreshBindList"></el-button>
</div>
<el-table :data="bindPageData" style="width: 100%;" row-key="id" v-loading="bindSearchLoading">
<el-table-column prop="item_code" label="项目编号" width="160" />
<el-table-column prop="item_name" label="检查项目名称" />
<el-table-column prop="item_class_name" label="医嘱类别" />
<el-table-column prop="" label="操作" width="100">
<template #default="scope">
<el-button type="primary" size="small" @click="addBindFromDialog(scope.row)"
:loading="bindItemLoading === scope.row.id">添加</el-button>
</template>
</el-table-column>
</el-table>
<div style="display: flex; justify-content: space-between; align-items: center; margin-top: 12px;">
<span style="color: #909399; font-size: 13px;"> {{ bindTotal }} </span>
<el-pagination v-model:current-page="bindCurrentPage" v-model:page-size="bindPageSize"
:page-sizes="[10]" layout="prev, pager, next" :total="bindTotal"
@current-change="onBindPageChange" />
</div>
</div>
</el-dialog>
</template>
<script setup>
import { ref, computed, onMounted } from 'vue'
import { ElMessage, ElMessageBox } from 'element-plus'
import {
GetDeptDeviceList,
GetDeviceBindItems,
GetUnboundCheckItems,
BindItemToDevice,
UnbindItemFromDevice
} from '@/api/api.js'
let loading = ref(false)
let deviceList = ref([])
let selectedDevice = ref(null)
let boundItems = ref([])
let boundLoading = ref(false)
let showBindDialog = ref(false)
let bindSearchKeyword = ref('')
let bindSearchResults = ref([])
let bindSearchLoading = ref(false)
let bindSearchTimer = null
let bindCurrentPage = ref(1)
let bindPageSize = ref(10)
let bindTotal = ref(0)
let bindItemLoading = ref(null)
//
const bindPageData = computed(() => bindSearchResults.value)
//
const getDeviceList = () => {
loading.value = true
GetDeptDeviceList().then(res => {
loading.value = false
if (res.status) {
deviceList.value = res.data
//
if (deviceList.value.length > 0) {
selectDevice(deviceList.value[0])
}
} else {
ElMessage.error(res.msg)
}
}).catch(() => {
loading.value = false
})
}
const selectDevice = (device) => {
selectedDevice.value = device
getBoundItems(device.id)
}
const getBoundItems = (deviceId) => {
boundLoading.value = true
GetDeviceBindItems({ device_id: deviceId }).then(res => {
boundLoading.value = false
if (res.status) {
boundItems.value = res.data
} else {
ElMessage.error(res.msg)
}
}).catch(() => {
boundLoading.value = false
})
}
// 10
const loadPage = () => {
bindSearchLoading.value = true
GetUnboundCheckItems({
device_id: selectedDevice.value.id,
keyword: bindSearchKeyword.value,
page: bindCurrentPage.value,
pageSize: bindPageSize.value
}).then(res => {
bindSearchLoading.value = false
if (res.status) {
bindSearchResults.value = res.data.list || []
bindTotal.value = res.data.count || 0
} else {
ElMessage.error(res.msg)
}
}).catch(() => {
bindSearchLoading.value = false
})
}
const openBindDialog = () => {
showBindDialog.value = true
bindSearchKeyword.value = ''
bindCurrentPage.value = 1
loadPage()
}
//
const onBindSearchInput = () => {
if (bindSearchTimer) clearTimeout(bindSearchTimer)
bindSearchTimer = setTimeout(() => {
bindCurrentPage.value = 1
loadPage()
}, 300)
}
const doBindSearch = () => {
bindCurrentPage.value = 1
loadPage()
}
const refreshBindList = () => {
loadPage()
}
const onBindPageChange = (page) => {
bindCurrentPage.value = page
loadPage()
}
const addBindFromDialog = (item) => {
bindItemLoading.value = item.id
BindItemToDevice({
item_id: item.id,
device_id: selectedDevice.value.id
}).then(res => {
bindItemLoading.value = null
if (res.status) {
ElMessage.success(`已绑定 ${item.item_name}`)
//
const idx = bindSearchResults.value.findIndex(i => i.id === item.id)
if (idx !== -1) {
bindSearchResults.value.splice(idx, 1)
}
bindTotal.value--
//
if (bindSearchResults.value.length === 0 && bindCurrentPage.value > 1) {
bindCurrentPage.value--
loadPage()
}
//
getBoundItems(selectedDevice.value.id)
} else {
ElMessage.error(res.msg)
}
}).catch(() => {
bindItemLoading.value = null
})
}
const closeBindDialog = () => {
bindSearchKeyword.value = ''
bindSearchResults.value = []
bindTotal.value = 0
bindCurrentPage.value = 1
}
const removeBind = (row) => {
ElMessageBox.confirm(`确定解绑 ${row.item_name} 吗?`, '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
}).then(() => {
UnbindItemFromDevice({
item_id: row.id,
device_id: selectedDevice.value.id
}).then(res => {
if (res.status) {
ElMessage.success('解绑成功')
getBoundItems(selectedDevice.value.id)
} else {
ElMessage.error(res.msg)
}
})
}).catch(() => {})
}
onMounted(() => {
getDeviceList()
})
</script>
<style scoped>
.page-container {
display: flex;
height: calc(100vh - 120px);
gap: 16px;
}
.left-panel {
width: 280px;
min-width: 280px;
border: 1px solid #e4e7ed;
border-radius: 8px;
background: #fff;
display: flex;
flex-direction: column;
overflow: hidden;
}
.panel-header {
padding: 14px 16px;
border-bottom: 1px solid #e4e7ed;
background: #f5f7fa;
display: flex;
align-items: center;
justify-content: space-between;
}
.panel-title {
font-size: 15px;
font-weight: 600;
color: #303133;
}
.device-list {
flex: 1;
overflow-y: auto;
padding: 8px 0;
}
.device-item {
padding: 12px 16px;
cursor: pointer;
border-left: 3px solid transparent;
transition: all 0.2s;
}
.device-item:hover {
background: #f0f5ff;
}
.device-item.active {
background: #ecf5ff;
border-left-color: #409eff;
}
.device-name {
font-size: 14px;
color: #303133;
font-weight: 500;
}
.device-count {
font-size: 12px;
color: #909399;
margin-top: 4px;
}
.right-panel {
flex: 1;
border: 1px solid #e4e7ed;
border-radius: 8px;
background: #fff;
display: flex;
flex-direction: column;
overflow: hidden;
}
.right-content {
flex: 1;
padding: 16px;
overflow-y: auto;
}
.empty-tip {
text-align: center;
color: #c0c4cc;
font-size: 14px;
padding: 40px 0;
}
</style>
Loading…
Cancel
Save