From 17046362ab95b09b659c03892990d8c2b0f862d1 Mon Sep 17 00:00:00 2001 From: eight <641137800@qq.com> Date: 星期一, 02 九月 2024 10:54:23 +0800 Subject: [PATCH] fix bug 入座 离座 --- src/views/ecg/room/RoomLoginSelect.vue | 71 ++++++++++++++++------------------- 1 files changed, 33 insertions(+), 38 deletions(-) diff --git a/src/views/ecg/room/RoomLoginSelect.vue b/src/views/ecg/room/RoomLoginSelect.vue index 8c33ae0..9e5c25a 100644 --- a/src/views/ecg/room/RoomLoginSelect.vue +++ b/src/views/ecg/room/RoomLoginSelect.vue @@ -16,11 +16,11 @@ <script setup lang="ts"> import {RoomBedSelect} from "@/components/RoomBedSelect" import { RoomApi, RoomVO } from '@/api/ecg/room' -import { queueApi } from '@/api/ecg/queue' import {useUserStore} from "@/store/modules/user"; import {ElMessage, ElMessageBox} from "element-plus"; import {isStringEmpty} from "@/utils/stringUtil"; import {cloneDeep} from "lodash-es"; +import {DoctorApi} from "@/api/ecg/doctor"; const { push } = useRouter() defineOptions({ name: 'RoomLoginSelect' }) @@ -47,38 +47,40 @@ getList() }) +onActivated(() => { + getList() +}) + const resetPage = () => { getList() } /** 鏌ヨ鍒楄〃 */ const getList = async () => { + resetCurSel() + const data = await RoomApi.getOpeningBedMap() - console.info(data) bedMap.value = data; - isEmptyOpeningBed.value = true + isEmptyOpeningBed.value = true for (const key in data) { isEmptyOpeningBed.value = false const roomVOArray = data[key] as RoomVO[]; roomVOArray.forEach((roomVO) => { if (roomVO.docId === curUser.id) { - curSel.value = roomVO - return + curSel.value = roomVO + userStore.setRoomInfoAction(curSel.value) + return } } ) } } const haveSeatConfirm = async (newRoomVO: RoomVO) => { - const tempRoomVO = cloneDeep(newRoomVO) - tempRoomVO.docId = curUser.id - tempRoomVO.docName = curUser.nickname - if (newRoomVO !== curSel.value) { let data; - if (curSel.value.roomId !== null) { - data = await queueApi.bedDoctorOff(curSel.value) + if (curSel.value.docId !== null) { + data = await DoctorApi.bedDoctorOff(curSel.value) if (data !== 0) { ElMessage({ message: '鍐呴儴閿欒!' + data, @@ -88,7 +90,11 @@ return } } - data = await queueApi.bedDoctorOn(tempRoomVO) + + const tempRoomVO = cloneDeep(newRoomVO) + tempRoomVO.docId = curUser.id + tempRoomVO.docName = curUser.nickname + data = await DoctorApi.bedDoctorOn(tempRoomVO) if (data !== 0) { ElMessage({ message: '鍐呴儴閿欒!' + data, @@ -97,18 +103,9 @@ }); return } + + getList() } - - userStore.setRoomInfoAction(tempRoomVO) - - if (curSel.value.roomId !== null) { - curSel.value.docId = null - curSel.value.docName = null - } - - newRoomVO.docId = curUser.id - newRoomVO.docName = curUser.nickname - curSel.value = newRoomVO if (isStringEmpty(route.redirectedFrom?.fullPath)) push({ path: "/"}) @@ -119,8 +116,8 @@ } const leaveSeatConfirm = async () => { - if (curSel.value.roomId !== null) { - let data = await queueApi.bedDoctorOff(curSel.value) + if (curSel.value.docId !== null) { + let data = await DoctorApi.bedDoctorOff(curSel.value) if (data !== 0) { ElMessage({ message: '鍐呴儴閿欒!' + data, @@ -129,21 +126,10 @@ }); return } - - curSel.value.docId = null - curSel.value.docName = null - curSel.value = { - id: null, - roomId: null, - roomName: null, - bedNo: null, - status: null, - docId: null, - docName: null - } } userStore.clearRoomInfoAction() + getList() } const haveSeat = async (newRoomVO: RoomVO) => { @@ -190,7 +176,6 @@ return } - userStore.setRoomInfoAction(curSel.value) if (isStringEmpty(route.redirectedFrom?.fullPath)) push({ path: "/"}) else if(route.redirectedFrom?.fullPath === "/roomselect" ) @@ -199,6 +184,16 @@ push({ path: route.redirectedFrom?.fullPath}) } +const resetCurSel = () => { + curSel.value.id = null + curSel.value.roomId = null + curSel.value.roomName = null + curSel.value.bedNo = null + curSel.value.status = null + curSel.value.docId = null + curSel.value.docName = null +} + </script> <style scoped lang="scss"> -- Gitblit v1.9.3