eight
2025-04-15 589bcdb26f8e9d3e0d5ef46d27acc901c96d50ea
src/components/RoomBedSelect/src/RoomBedSelect.vue
@@ -1,52 +1,97 @@
<script lang="ts" setup>
import { RoomApi, RoomVO } from '@/api/ecg/room'
import { RoomVO } from '@/api/ecg/room'
import {PropType} from "vue";
import {useCheckTypeStore} from "@/store/modules/checkType";
import {UserVO} from "@/store/modules/user";
import {getCheckTypeName} from "../../../utils/checkTypeFormatter";
const emit = defineEmits(['event-haveseat', 'event-leaveseat', 'event-setcurseat'])
defineComponent({
  name: 'RoomBedSelect'
})
const  props = defineProps({
// defineProps({
  title: {
    type: String,
    type: Number,
    required: true
  },
  bedList: {
    type: Array as PropType<RoomVO[]>,
    required: true
  },
  modelValue: {
    type: String,
  curBed: {
    type: Object as PropType<RoomVO>,
    required: true
  },
  curUser: {
    type: Object as PropType<UserVO>,
    required: true
  }
})
const emit = defineEmits<{
    (e: 'update:modelValue', message: string): void;
}>();
const checkTypeStore = useCheckTypeStore();
const onclick = (item) => {
  emit('update:modelValue', item.bedNo);
const onHaveSeatclick = (newItem: RoomVO) => {
  emit('event-haveseat', newItem)
}
const onLeaveSeatclick = (curItem: RoomVO) => {
  emit('event-leaveseat', curItem)
}
const onSetCurSeatclick = (curItem: RoomVO) => {
  emit('event-setcurseat', curItem)
}
/** 初始化 **/
onMounted(() => {
    console.info(props.bedList)
})
</script>
<template>
  <el-card style="width: 200px" shadow="hover" >
    <template #header>{{title}}</template>
    <template #header>{{bedList[0].roomName}}</template>
    <div v-for="(bedItem, index) in bedList" :key="index">
      <div class="deskwarp">
        <img v-if="modelValue !== bedItem.bedNo"
            src="@/assets/room/desk.png"
             style="width: 100%"
             @click = onclick(bedItem)
        <div v-for="(checkType, subIndex) in bedItem.checkTypes" :key="subIndex">
          {{getCheckTypeName(checkType)}}
        </div>
        <div>
          {{bedItem.opType === 1?"领用":""}}
          {{bedItem.opType === 2?"安装":""}}
        </div>
        <img
            v-if="bedItem.docId === null"
            src="@/assets/room/open.jpg"
            style="width: 100%"
            alt="无医生"
        />
        <img v-else
        <img
            v-else
            src="@/assets/room/desk-doctor.jpeg"
             style="width: 100%"
             @click = onclick(bedItem)
            style="width: 100%"
            alt="有医生"
        />
        <div>{{bedItem.bedNo}}</div>
        <div>{{bedItem.bedNo}} {{bedItem.docName}} {{bedItem.status === 30?"-暂停":""}}</div>
        <el-button v-if="bedItem.docId === null" @click = onHaveSeatclick(bedItem)>
           入座
        </el-button>
        <div v-if="bedItem.docId === curUser.id">
          <el-button @click = onLeaveSeatclick(bedItem)>
             离座
          </el-button>
          <span v-if="bedItem.roomId === curBed.roomId && bedItem.bedNo === curBed.bedNo" >
             当前
          </span>
          <el-button v-else @click = onSetCurSeatclick(bedItem)>
             设为当前
          </el-button>
        </div>
        <el-divider/>
      </div>
    </div>
  </el-card>
@@ -76,6 +121,7 @@
  display: flex;
  flex-direction: column;
  align-items: center;
  /*height: 260px;*/
}
</style>