From 09dc74e264b6262cbe41c9c8476e24705871d4a6 Mon Sep 17 00:00:00 2001
From: yxh <172933527@qq.com>
Date: 星期日, 08 十一月 2026 23:31:17 +0800
Subject: [PATCH] yxh

---
 src/components/RoomBedSelect/src/RoomBedSelect.vue |  327 ++++++++++++++++++++++++++++++++++++++++--------------
 1 files changed, 241 insertions(+), 86 deletions(-)

diff --git a/src/components/RoomBedSelect/src/RoomBedSelect.vue b/src/components/RoomBedSelect/src/RoomBedSelect.vue
index 12dacc8..6cf9896 100644
--- a/src/components/RoomBedSelect/src/RoomBedSelect.vue
+++ b/src/components/RoomBedSelect/src/RoomBedSelect.vue
@@ -1,23 +1,22 @@
 <script lang="ts" setup>
 import { RoomVO } from '@/api/ecg/room'
-import {PropType} from "vue";
-import {useCheckTypeStore} from "@/store/modules/checkType";
-import {UserVO} from "@/store/modules/user";
+import { PropType } from "vue";
+import { UserVO } from "@/store/modules/user";
+import { getCheckTypeName } from "../../../utils/checkTypeFormatter";
+// 鍔ㄦ�� :src 涓嶄細琚� Vite 鑷姩澶勭悊锛岄渶瑕佹樉寮� import
+import openImg from '@/assets/room/open.jpg'
+import doctorImg from '@/assets/room/desk-doctor.jpg'
 
-const emit = defineEmits(['event-haveseat', 'event-leaveseat', 'event-setcurseat'])
+const emit = defineEmits(['event-haveseat', 'event-leaveseat', 'event-setcurseat', 'event-takeover'])
 
 defineComponent({
   name: 'RoomBedSelect'
 })
 
-const  props = defineProps({
-// defineProps({
-  title: {
-    type: Number,
-    required: true
-  },
-  bedList: {
-    type: Array as PropType<RoomVO[]>,
+const props = defineProps({
+  // 涓�涓簥浣嶄竴寮犲崱鐗�
+  bed: {
+    type: Object as PropType<RoomVO>,
     required: true
   },
   curBed: {
@@ -30,97 +29,253 @@
   }
 })
 
-const checkTypeStore = useCheckTypeStore();
-
-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)
+// 璇ュ簥浣嶆槸鍚﹀凡鐢卞綋鍓嶅尰鐢熷叆搴�
+// 娉細鐢ㄥ瓧绗︿覆姣旇緝锛岄伩鍏嶅悗绔繑鍥� number / 鍓嶇 userId 涓� string 鏃惰鍒わ紙"1" !== 1锛�
+const isMine = computed(
+  () => props.bed.docId != null && String(props.bed.docId) === String(props.curUser.id)
+)
+// 璇ュ簥浣嶆槸鍚�**琚埆浜�**鍗犵敤锛氭鏃朵笉鍏佽鍏ュ骇锛堜笉鎸ゆ帀姝e湪鎿嶄綔鐨勪汉锛�
+const occupiedByOther = computed(
+  () => props.bed.docId != null && String(props.bed.docId) !== String(props.curUser.id)
+)
+// 鍗犵敤鎯呭喌鏂囨锛氱┖闂� / 鎴戠殑宸ヤ綅 / 宸插叆搴э細寮犱笁锛堟嬁涓嶅埌濮撳悕鏃舵樉绀虹紪鍙凤級
+const seatStateText = computed(() => {
+  if (props.bed.docId == null) return '绌洪棽'
+  if (isMine.value) return '鎴戠殑宸ヤ綅'
+  return props.bed.docName ? `宸插叆搴э細${props.bed.docName}` : `宸插叆搴э紙缂栧彿 ${props.bed.docId}锛塦
 })
+// 璇ュ簥浣嶆槸鍚﹀氨鏄綋鍓嶄細璇濅娇鐢ㄤ腑鐨勫伐浣�
+const isCurSeat = computed(
+  () => props.bed.roomId === props.curBed.roomId && props.bed.bedNo === props.curBed.bedNo
+)
+
+const onHaveSeatclick = (bed: RoomVO) => {
+  emit('event-haveseat', bed)
+}
+const onLeaveSeatclick = (bed: RoomVO) => {
+  emit('event-leaveseat', bed)
+}
+const onSetCurSeatclick = (bed: RoomVO) => {
+  emit('event-setcurseat', bed)
+}
+/** 銆愭湰闇�姹偮锋帴鐝嚜鍔╂帴绠°�戞妸"鍒汉鍗犵敤"鐨勫伐浣嶆帴绠¤繃鏉ワ紙鐖剁粍浠惰礋璐d簩娆$‘璁や笌璋冩帴鍙o級 */
+const onTakeOverclick = (bed: RoomVO) => {
+  emit('event-takeover', bed)
+}
 
 </script>
 
 <template>
-  <el-card style="width: 200px" shadow="hover" >
-    <template #header>{{bedList[0].roomName}}</template>
-    <div v-for="(bedItem, index) in bedList" :key="index">
-      <div class="deskwarp">
-
-        <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
-            src="@/assets/room/desk-doctor.jpeg"
-            style="width: 100%"
-            alt="鏈夊尰鐢�"
-        />
-        <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/>
+  <!--
+    闇�姹傦細鐢ㄦ埛閫夋嫨鐨�**褰撳墠璇婂**鍗$墖瑕佸姞棰滆壊锛屼笌鍏朵粬鍗$墖鍖哄垎寮�銆�
+    杩欓噷缁欏崱鐗囧姞 `is-current` 绫伙紙涓昏壊杈规 + 娴呰壊搴� + 闃村奖锛夛紝
+    骞跺湪鍗$墖澶村彸渚ф樉绀恒�屽綋鍓嶈瘖瀹ゃ�嶈鏍囷紝鍋氬埌涓�鐪煎彲杈ㄣ��
+  -->
+  <el-card
+    class="bed-card"
+    :class="{ 'is-current': isCurSeat }"
+    shadow="hover"
+    :body-style="{ padding: '10px' }"
+  >
+    <template #header>
+      <div class="bed-card__header">
+        <span class="bed-card__title">{{ bed.roomName }}</span>
+        <span v-if="isCurSeat" class="bed-card__badge">褰撳墠璇婂</span>
       </div>
+    </template>
+
+    <img
+      class="bed-card__img"
+      :src="bed.docId === null ? openImg : doctorImg"
+      :alt="bed.docId === null ? '鏃犲尰鐢�' : '鏈夊尰鐢�'"
+    />
+
+    <div class="bed-card__label">
+      {{ bed.bedNo }} {{ bed.docName }} {{ bed.status === 30 ? "-鏆傚仠" : "" }}
+    </div>
+
+    <!--
+      鍗犵敤鎯呭喌锛堟湰娆¢渶姹傦級锛氫竴鐪肩湅鍑鸿繖涓伐浣嶆槸"绌洪棽 / 鎴戠殑 / 鍒汉鐨�"銆�
+      鍘熸潵鍗$墖鍙湪鍥剧墖涓庡鍚嶄笂浣撶幇锛屽埆浜哄崰浜嗕篃鐪嬩笉鍑烘潵锛屼細鍑虹幇"鐐逛簡鍏ュ骇鍗磋鍚庣鎷掔粷"鐨勫洶鎯戙��
+    -->
+    <div
+      class="bed-card__seat"
+      :class="occupiedByOther ? 'is-occupied' : isMine ? 'is-mine' : 'is-free'"
+    >
+      {{ seatStateText }}
+    </div>
+
+    <div class="bed-card__meta">
+      <span v-for="(checkType, subIndex) in bed.checkTypes" :key="subIndex">
+        {{ getCheckTypeName(checkType) }}
+      </span>
+      <span v-if="bed.opType === 1">棰嗙敤</span>
+      <span v-if="bed.opType === 2">瀹夎</span>
+    </div>
+
+    <div class="bed-card__actions">
+      <!-- 宸茶**鍒汉**鍗犵敤鏃剁鐢ㄣ�屽叆搴с�嶏紙涓嶆尋鎺夋鍦ㄦ搷浣滅殑浜猴級锛屽苟鐢� tooltip 璇存槑鍘熷洜锛�
+           鍚屾椂鎻愪緵銆屾帴绠°�嶁�斺�斾笂涓�鐝尰鐢熶笅鐝病鐐圭搴ф椂锛屾帴鐝尰鐢熷彲鑷姪鎺ョ -->
+      <el-tooltip
+        v-if="!isMine"
+        :content="
+          occupiedByOther
+            ? `璇ュ伐浣嶇敱銆�${bed.docName || '鍏朵粬鍖荤敓'}銆嶆搷浣滀腑銆傝嫢鏄笂涓�鐝尰鐢熷繕璁扮搴э紝鍙偣銆屾帴绠°�峘
+            : '鍏ュ骇鍒拌宸ヤ綅'
+        "
+        placement="top"
+      >
+        <span>
+          <el-button :disabled="occupiedByOther" @click="onHaveSeatclick(bed)"> 鍏ュ骇 </el-button>
+          <!-- 銆愭湰闇�姹偮锋帴鐝嚜鍔╂帴绠°�戜粎"琚粬浜哄崰鐢�"鏃跺嚭鐜帮紱鎺ョ鍚庡鏂逛細琚己鍒剁搴� -->
+          <el-button
+            v-if="occupiedByOther"
+            type="warning"
+            plain
+            @click="onTakeOverclick(bed)"
+          >
+            鎺ョ
+          </el-button>
+        </span>
+      </el-tooltip>
+      <template v-else>
+        <el-button @click="onLeaveSeatclick(bed)"> 绂诲骇 </el-button>
+        <span v-if="isCurSeat" class="bed-card__current">褰撳墠</span>
+        <el-button v-else @click="onSetCurSeatclick(bed)"> 璁句负褰撳墠 </el-button>
+      </template>
     </div>
   </el-card>
 </template>
 
 <style scoped lang="scss">
-.card-title {
-  font-size: 14px;
-  font-weight: 600;
+/* ==========================================================================
+   闇�姹傦細鐢ㄦ埛閫夋嫨鐨�**褰撳墠璇婂**鍗$墖鍔犻鑹诧紝涓庡叾浠栧崱鐗囧尯鍒嗐��
+   娉ㄦ剰绫诲悕 `is-current` 涓� Element Plus 鑷甫鐨� `.is-*` 涓嶅啿绐侊紙鍗$墖涓婃病鏈夊叾瀹� is- 绫伙級銆�
+   ========================================================================== */
+.bed-card.is-current {
+  /* 涓昏壊杈规鍔犵矖 + 娴呰壊搴� + 鎶曞奖锛屼笁閲嶅尯鍒嗭紝杩滅湅涔熸槑鏄� */
+  border: 2px solid var(--el-color-primary);
+  background-color: var(--el-color-primary-light-9);
+  box-shadow: 0 0 8px var(--el-color-primary-light-5);
 
-  &::before {
-    position: relative;
-    top: 8px;
-    left: -5px;
-    display: inline-block;
-    width: 3px;
-    height: 14px;
-    //background-color: #105cfb;
-    background: var(--el-color-primary);
-    border-radius: 5px;
-    content: '';
-    transform: translateY(-50%);
+  :deep(.el-card__header) {
+    background-color: var(--el-color-primary-light-8);
+    border-bottom: 1px solid var(--el-color-primary-light-5);
+  }
+
+  .bed-card__title {
+    color: var(--el-color-primary);
   }
 }
 
-.deskwarp {
+/* 鍗$墖澶达細璇婂鍚� + 褰撳墠璇婂瑙掓爣 */
+.bed-card__header {
   display: flex;
-  flex-direction: column;
   align-items: center;
-  /*height: 260px;*/
+  justify-content: center;
+  gap: 6px;
 }
 
+.bed-card__badge {
+  flex: none;
+  padding: 0 5px;
+  font-size: 11px;
+  font-weight: 400;
+  line-height: 16px;
+  color: #fff;
+  background-color: var(--el-color-primary);
+  border-radius: 3px;
+  white-space: nowrap;
+}
+
+.bed-card {
+  display: flex;
+  flex-direction: column;
+  height: 100%;
+  overflow: hidden;
+
+  // 鍗$墖澶达紙璇婂鍚嶏級绱у噾鍖�
+  :deep(.el-card__header) {
+    flex: none;
+    padding: 6px 10px;
+    text-align: center;
+  }
+
+  // 鍗$墖浣擄細绾靛悜鎺掑垪銆佹按骞冲眳涓�
+  :deep(.el-card__body) {
+    display: flex;
+    flex: 1;
+    flex-direction: column;
+    align-items: center;
+    gap: 4px;
+  }
+
+  &__title {
+    font-size: 16px;
+    font-weight: 600;
+    line-height: 1.2;
+  }
+
+  // 鍥剧墖鍥哄畾灏忓昂瀵革紝涓嶅啀闅忓崱鐗囧搴︽斁澶�
+  &__img {
+    flex: none;
+    width: 80px;
+    height: 64px;
+    object-fit: contain;
+  }
+
+  &__label {
+    font-size: 15px;
+    font-weight: 600;
+    line-height: 1.3;
+    // 鍒楀鍥哄畾锛屽厑璁告崲琛岄伩鍏嶆孩鍑哄崱鐗�
+    text-align: center;
+  }
+
+  &__meta {
+    display: flex;
+    flex-wrap: wrap;
+    gap: 0 5px;
+    justify-content: center;
+    font-size: 14px;
+    line-height: 1.3;
+    color: var(--el-text-color-secondary);
+    text-align: center;
+  }
+
+  /* 鍗犵敤鎯呭喌锛氱┖闂�=缁裤�佹垜鐨�=涓昏壊銆佽鍒汉鍗�=姗欙紙閰嶅悎绂佺敤鍏ュ骇鎸夐挳锛� */
+  &__seat {
+    font-size: 13px;
+    font-weight: 600;
+    line-height: 1.3;
+    text-align: center;
+
+    &.is-free {
+      color: var(--el-color-success);
+    }
+
+    &.is-occupied {
+      color: var(--el-color-warning);
+    }
+
+    &.is-mine {
+      color: var(--el-color-primary);
+    }
+  }
+
+  &__actions {
+    display: flex;
+    flex-wrap: wrap;
+    gap: 5px;
+    align-items: center;
+    justify-content: center;
+    margin-top: 3px;
+  }
+
+  &__current {
+    font-size: 15px;
+    font-weight: 600;
+    color: var(--el-color-primary);
+  }
+}
 </style>

--
Gitblit v1.9.3