From 01ee694a3bb8048372fc793a8de314d70b688b35 Mon Sep 17 00:00:00 2001
From: yxh <172933527@qq.com>
Date: 星期日, 18 十月 2026 22:36:21 +0800
Subject: [PATCH] 修改了工位
---
src/components/RoomBedSelect/src/RoomBedSelect.vue | 296 ++++++++++++++++++++++++++++++++++++++++++++++------------
1 files changed, 232 insertions(+), 64 deletions(-)
diff --git a/src/components/RoomBedSelect/src/RoomBedSelect.vue b/src/components/RoomBedSelect/src/RoomBedSelect.vue
index 437055d..b2ade54 100644
--- a/src/components/RoomBedSelect/src/RoomBedSelect.vue
+++ b/src/components/RoomBedSelect/src/RoomBedSelect.vue
@@ -1,99 +1,267 @@
<script lang="ts" setup>
import { RoomVO } from '@/api/ecg/room'
-import {PropType} from "vue";
-import {useUserStore} from "@/store/modules/user";
-const emit = defineEmits(['event-haveseat', 'event-leaveseat'])
+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({
-defineProps({
- title: {
- type: String,
- required: true
- },
- bedList: {
- type: Array as PropType<RoomVO[]>,
+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 userStore = useUserStore()
-const curUser = userStore.getUser
-
-const onHaveSeatclick = (newItem: RoomVO) => {
- emit('event-haveseat', newItem)
-}
-const onLeaveSeatclick = (curItem: RoomVO) => {
- emit('event-leaveseat', 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)
+}
</script>
<template>
- <el-card style="width: 200px" shadow="hover" >
- <template #header>{{title}}</template>
- <div v-for="(bedItem, index) in bedList" :key="index">
- <div class="deskwarp">
- <img
- v-if="curBed.roomId !== bedItem.roomId || curBed.bedNo !== bedItem.bedNo"
- src="@/assets/room/desk.png"
- style="width: 100%"
- alt="鏃犲尰鐢�"
- />
- <img
- v-else
- src="@/assets/room/desk-doctor.jpeg"
- style="width: 100%"
- alt="鏈夊尰鐢�"
- />
- <div>{{bedItem.bedNo}} {{bedItem.docName}}</div>
- <el-button v-if="bedItem.docId === null" @click = onHaveSeatclick(bedItem)>
- 鍏ュ骇
- </el-button>
- <el-button v-if="bedItem.docId === curUser.id" @click = onLeaveSeatclick(bedItem)>
- 绂诲骇
- </el-button>
+ <!--
+ 闇�姹傦細鐢ㄦ埛閫夋嫨鐨�**褰撳墠璇婂**鍗$墖瑕佸姞棰滆壊锛屼笌鍏朵粬鍗$墖鍖哄垎寮�銆�
+ 杩欓噷缁欏崱鐗囧姞 `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>
+ </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;
+ 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