yxh
2026-10-03 d553a4be94d4f6ee162cc353a28b220403909cfc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
<script lang="ts" setup>
import { RoomVO } from '@/api/ecg/room'
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'])
 
defineComponent({
  name: 'RoomBedSelect'
})
 
const props = defineProps({
  // 一个床位一张卡片
  bed: {
    type: Object as PropType<RoomVO>,
    required: true
  },
  curBed: {
    type: Object as PropType<RoomVO>,
    required: true
  },
  curUser: {
    type: Object as PropType<UserVO>,
    required: true
  }
})
 
// 该床位是否已由当前医生入座
const isMine = computed(() => props.bed.docId != null && props.bed.docId === props.curUser.id)
// 该床位是否就是当前会话使用中的工位
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)
}
 
</script>
 
<template>
  <!--
    需求:用户选择的**当前诊室**卡片要加颜色,与其他卡片区分开。
    这里给卡片加 `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__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">
      <el-button v-if="!isMine" @click="onHaveSeatclick(bed)"> 入座 </el-button>
      <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">
/* ==========================================================================
   需求:用户选择的**当前诊室**卡片加颜色,与其他卡片区分。
   注意类名 `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);
 
  :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);
  }
}
 
/* 卡片头:诊室名 + 当前诊室角标 */
.bed-card__header {
  display: flex;
  align-items: center;
  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;
  }
 
  &__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>