eight
2024-08-29 43fa7872d8337d85e8486123b4302fbbae2d343a
src/views/ecg/room/RoomLoginSelect.vue
@@ -16,7 +16,7 @@
<script setup lang="ts">
import {RoomBedSelect} from "@/components/RoomBedSelect"
import { RoomApi, RoomVO } from '@/api/ecg/room'
import { queueApi } from '@/api/ecg/queue'
import { QueueApi } from '@/api/ecg/queue'
import {useUserStore} from "@/store/modules/user";
import {ElMessage, ElMessageBox} from "element-plus";
import {isStringEmpty} from "@/utils/stringUtil";
@@ -53,11 +53,13 @@
/** 查询列表 */
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[];
@@ -71,14 +73,10 @@
}
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 QueueApi.bedDoctorOff(curSel.value)
      if (data !== 0) {
        ElMessage({
          message: '内部错误!' + data,
@@ -88,7 +86,13 @@
        return
      }
    }
    data = await queueApi.bedDoctorOn(tempRoomVO)
    curSel.value.docId = null
    curSel.value.docName = null
    const tempRoomVO = cloneDeep(newRoomVO)
    tempRoomVO.docId = curUser.id
    tempRoomVO.docName = curUser.nickname
    data = await QueueApi.bedDoctorOn(tempRoomVO)
    if (data !== 0) {
      ElMessage({
        message: '内部错误!' + data,
@@ -97,18 +101,12 @@
      });
      return
    }
    newRoomVO.docId = curUser.id
    newRoomVO.docName = curUser.nickname
    curSel.value = newRoomVO
    userStore.setRoomInfoAction(curSel.value)
  }
  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 +117,8 @@
}
const leaveSeatConfirm = async () => {
  if (curSel.value.roomId !== null) {
      let data = await queueApi.bedDoctorOff(curSel.value)
  if (curSel.value.docId !== null) {
      let data = await QueueApi.bedDoctorOff(curSel.value)
      if (data !== 0) {
          ElMessage({
              message: '内部错误!' + data,
@@ -132,15 +130,6 @@
    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()
@@ -199,6 +188,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">