yxh
10 天以前 bd3f4b0a9b9207b647de0f0d8c52600a2742fd56
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
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
<script lang="ts" setup>
import { RoomApi, RoomVO } from '@/api/ecg/room'
import { QueueApi } from '@/api/ecg/queue'
import { PropType } from "vue";
import { DICT_TYPE, getIntDictOptions } from "@/utils/dict";
import { useCheckTypeStore } from "@/store/modules/checkType";
import { getCheckTypeName } from "../../../utils/checkTypeFormatter";
// 动态 :src 不会被 Vite 自动处理,需要显式 import(与 RoomBedSelect 一致)
import closeImg from '@/assets/room/close.jpg'
import openImg from '@/assets/room/open.jpg'
import doctorImg from '@/assets/room/desk-doctor.jpg'
 
const emit = defineEmits(['refresh'])
 
defineComponent({
  name: 'RoomStatus'
})
 
const props = defineProps({
  title: {
    type: String,
    required: true
  },
  bedList: {
    type: Array as PropType<RoomVO[]>,
    required: true
  }
})
 
const checkTypeStore = useCheckTypeStore();
 
const openBed = async (item) => {
    await QueueApi.bedOpen(item)
    emit('refresh')
}
 
const closeBed = async (item) => {
    await QueueApi.bedClose(item)
    emit('refresh')
}
 
/**
 * 工位状态图。与「诊室选择」页 (RoomBedSelect) 用同一套资源与尺寸:
 *   未开放(0)   → close.jpg
 *   已开放(10)  → open.jpg
 *   有医生(20/30) → desk-doctor.jpg
 */
const bedImg = (item: any) => {
  const st = Number(item?.status)
  if (st === 20 || st === 30) return doctorImg
  if (st === 10) return openImg
  return closeImg
}
 
/**
 * 【需求】图片旁边直接写清楚"开诊 / 闭诊"文字 —— 原来只有一张图,
 * 新来的同事看不出哪种图是开诊、哪种是闭诊,也不知道该点哪里。
 */
const stateKey = (item: any) => {
  const st = Number(item?.status)
  if (st === 20) return 'doctor'
  if (st === 30) return 'pause'
  if (st === 10) return 'open'
  return 'closed'
}
 
const stateText = (item: any) => {
  const st = Number(item?.status)
  if (st === 20) return '有医生'
  if (st === 30) return '暂停'
  if (st === 10) return '已开诊'
  return '已闭诊'
}
 
/** 鼠标悬停提示:告诉用户"点这张图会发生什么"(医生在座时不能直接闭诊) */
const stateHint = (item: any) => {
  const st = Number(item?.status)
  if (st === 0) return '已闭诊 —— 点击图片开诊'
  if (st === 10) return '已开诊 —— 点击图片闭诊'
  return '医生在座中,不能直接闭诊;需先在医生工作台「离座」'
}
 
/** 点击图片切换开诊状态:闭诊→开诊、开诊→闭诊;有医生/暂停 不变(与原来的点击逻辑一致) */
const onToggle = (item: any) => {
  const st = Number(item?.status)
  if (st === 0) return openBed(item)
  if (st === 10) return closeBed(item)
  return undefined
}
 
/** 初始化 **/
onMounted(() => {
})
 
</script>
 
<template>
  <!--
    需求:本页卡片改成与「诊室选择」页一致的样式。
    因此这里的排版/字号/图片尺寸/间距**逐项对齐** components/RoomBedSelect/src/RoomBedSelect.vue:
      · 卡片头:居中、padding 6px 10px、标题 16px/600
      · 卡片体:纵向排列、水平居中、gap 4px、padding 10px
      · 图片:80×64、object-fit contain
      · 主标签(床位号+医生名):15px/600、居中
      · 检查项目等次要信息:14px、次要色、居中、可换行
    区别:诊室选择是"一个工位一张卡片",本页是"一个诊室一张卡片、卡内列出该诊室各工位",
    故卡内每个工位是一个 bed-block;视觉规格与前者保持一致。
  -->
  <el-card class="room-status-card" shadow="hover">
    <template #header>
      <div class="bed-card__title">{{ title }}</div>
    </template>
 
    <div
      v-for="(bedItem, index) in bedList"
      :key="index"
      class="bed-block"
    >
      <!--
        【需求】图片 + 状态文字并排:一眼能看出"这是开诊还是闭诊",
        并且明确"点图片可切换"。医生在座(20/30)时点击不生效,用 title 说明原因。
      -->
      <div class="bed-card__img-row">
        <img
          class="bed-card__img"
          :src="bedImg(bedItem)"
          :alt="stateText(bedItem)"
          :title="stateHint(bedItem)"
          @click="onToggle(bedItem)"
        />
        <span class="bed-card__state" :class="`is-${stateKey(bedItem)}`">
          {{ stateText(bedItem) }}
        </span>
      </div>
 
      <div class="bed-card__label">
        {{ bedItem.bedNo }} {{ bedItem.docName }} {{ bedItem.status === 30 ? "-暂停" : "" }}
      </div>
 
      <div class="bed-card__meta">
        <span v-for="(checkType, subIndex) in bedItem.checkTypes" :key="subIndex">
          {{ getCheckTypeName(checkType) }}
        </span>
        <span v-if="bedItem.opType === 1">领用</span>
        <span v-if="bedItem.opType === 2">安装</span>
      </div>
    </div>
  </el-card>
</template>
 
<style scoped lang="scss">
/* 卡片本体:与 RoomBedSelect 的 .bed-card 对齐(只是宽度按本页需要略窄) */
.room-status-card {
  display: flex;
  flex-direction: column;
  width: 168px;
  margin: 0 6px 6px 0;
  overflow: hidden;
 
  // 卡片头(诊室名)
  :deep(.el-card__header) {
    flex: none;
    padding: 6px 10px;
    text-align: center;
  }
 
  // 卡片体:纵向排列、水平居中
  // 注意:这里**不用** flex:1 —— RoomBedSelect 是在等高网格里才需要它撑满;
  // 本页卡片高度由工位数决定,若撑满会把内容顶到上方、留下大片空白。
  :deep(.el-card__body) {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 10px;
  }
}
 
/* 卡内单个工位:与 RoomBedSelect 卡片体的排布一致 */
.bed-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  width: 100%;
  padding-bottom: 6px;
  border-bottom: 1px dashed var(--el-border-color-lighter);
 
  &:last-child {
    padding-bottom: 0;
    border-bottom: none;
  }
}
 
.bed-card__title {
  font-size: 16px;
  font-weight: 600;
  line-height: 1.2;
}
 
/* 【需求】图片 + 状态文字并排 */
.bed-card__img-row {
  display: flex;
  align-items: center;
  gap: 6px;
}
 
/* 图片固定小尺寸,不随卡片宽度放大(与 RoomBedSelect 相同) */
.bed-card__img {
  flex: none;
  width: 80px;
  height: 64px;
  object-fit: contain;
  cursor: pointer;
}
 
/* 状态文字:开诊/闭诊/有医生/暂停 用颜色区分,一眼可辨 */
.bed-card__state {
  font-size: 13px;
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
 
  &.is-open {
    color: var(--el-color-success);
  }
 
  &.is-closed {
    color: var(--el-text-color-secondary);
  }
 
  &.is-doctor {
    color: var(--el-color-primary);
  }
 
  &.is-pause {
    color: var(--el-color-warning);
  }
}
 
.bed-card__label {
  font-size: 15px;
  font-weight: 600;
  line-height: 1.3;
  text-align: center;
}
 
.bed-card__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;
}
</style>