From 1446994d504819c367e1ff667360eadb314f9ac6 Mon Sep 17 00:00:00 2001
From: yxh <172933527@qq.com>
Date: 星期日, 18 十月 2026 16:52:18 +0800
Subject: [PATCH] 修改了诊室工号
---
src/views/ecg/room/RoomLoginSelect.vue | 634 ++++++++++++++++++++++++++++++++++++++++++++++-----------
1 files changed, 512 insertions(+), 122 deletions(-)
diff --git a/src/views/ecg/room/RoomLoginSelect.vue b/src/views/ecg/room/RoomLoginSelect.vue
index 9922457..9d0755e 100644
--- a/src/views/ecg/room/RoomLoginSelect.vue
+++ b/src/views/ecg/room/RoomLoginSelect.vue
@@ -1,5 +1,35 @@
<template>
<div class="room-select">
+ <!--
+ 鏈〉鏄�**椤跺眰璺敱**锛堜笉鍦� Layout 閲岋級锛屽叏灞忕嫭鍗犮�佹病鏈変晶杈硅彍鍗曪紝
+ 鎵�浠ュ繀椤昏嚜宸辨彁渚涘嚭鍙o紙鏈闇�姹傦細鍘熸潵杩涙潵鍚庡嚭涓嶅幓锛夈��
+ -->
+ <div class="room-select__topbar">
+ <span class="room-select__title">閫夋嫨璇婂宸ヤ綅</span>
+ <div class="room-select__topbar-right">
+ <el-button size="default" @click="goBack">
+ <Icon icon="ep:back" class="mr-4px" />杩斿洖
+ </el-button>
+ <el-button size="default" @click="showIpDebug">
+ <Icon icon="ep:monitor" class="mr-4px" />IP 璇婃柇
+ </el-button>
+ <el-button size="default" type="danger" plain @click="doLogout">
+ <Icon icon="ep:switch-button" class="mr-4px" />閫�鍑虹櫥褰�
+ </el-button>
+ </div>
+ </div>
+
+ <!-- 閫夋嫨宸ヤ綅妯″紡鎻愮ず鍖猴細褰撳墠鐢佃剳IP + 鏈嚜鍔ㄥ尮閰嶅埌鐨勫師鍥狅紙妯″紡 1/3锛� -->
+ <div class="room-select__hint" v-if="hintText">
+ <el-alert :title="hintText" :type="hintType" :closable="false" show-icon />
+ <div class="room-select__ip">
+ <span>褰撳墠鐢佃剳IP锛�<b>{{ clientIp || '鏈瘑鍒�' }}</b></span>
+ <el-button link type="primary" @click="loadClientIp">閲嶆柊鑾峰彇</el-button>
+ <el-tag v-if="(mode === 2 || mode === 3) && canBindIp" size="small" type="success" effect="plain">鍏ュ骇鍚庝細鎶婅IP缁戝畾鍒版墍閫夊伐浣�</el-tag>
+ <el-tag v-else-if="(mode === 2 || mode === 3) && isIpv6" size="small" type="warning" effect="plain">IPv6 璁块棶锛屾湰娆′笉鍐欏叆IP缁戝畾锛堜粎閲囩敤 IPv4锛�</el-tag>
+ <el-tag v-else-if="(mode === 2 || mode === 3) && isLoopback" size="small" type="warning" effect="plain">鏈満璁块棶锛堝洖鐜湴鍧�锛夛紝鏈涓嶄細鍐欏叆IP缁戝畾</el-tag>
+ </div>
+ </div>
<div class="room-select__scroll">
<div class="room-select__list">
<div class="room-select__item" v-for="(bed, index) in bedList" :key="`${bed.roomId}-${bed.bedNo}-${index}`">
@@ -12,18 +42,27 @@
<el-button type="primary" size="large" @click="confirmCurSel">纭</el-button>
<el-button size="large" @click="resetPage">閲嶇疆</el-button>
</div>
+
+ <!-- IP 璇婃柇缁撴灉锛堟帓鏌�"宸ヤ綅缁戝畾鐨処P涓嶅"锛� -->
+ <el-dialog v-model="ipDebugVisible" title="IP 璇婃柇锛堝悗绔疄闄呰瘑鍒埌鐨勫鎴风鍦板潃锛�" width="640px">
+ <pre class="room-select__ip-debug">{{ ipDebugText }}</pre>
+ <template #footer>
+ <el-button @click="showIpDebug">閲嶆柊璇婃柇</el-button>
+ <el-button type="primary" @click="ipDebugVisible = false">鍏抽棴</el-button>
+ </template>
+ </el-dialog>
</div>
</template>
<script setup lang="ts">
import {RoomBedSelect} from "@/components/RoomBedSelect"
-import { RoomApi, RoomVO } from '@/api/ecg/room'
+import { RoomApi, RoomVO, isUsableSeatIp } from '@/api/ecg/room'
import {useUserStore} from "@/store/modules/user";
import {ElMessage, ElMessageBox} from "element-plus";
import {cloneDeep} from "lodash-es";
import {DoctorApi} from "@/api/ecg/doctor";
import {useRoomStore} from "@/store/modules/room";
-const { push } = useRouter()
+const { push, back } = useRouter()
defineOptions({ name: 'RoomLoginSelect' })
@@ -32,6 +71,185 @@
const userStore = useUserStore()
const roomStore = useRoomStore()
const curUser = userStore.getUser
+
+/* ==================== 閫夋嫨宸ヤ綅妯″紡锛�0/1/2/3锛夌浉鍏� ==================== */
+/** 閫夋嫨宸ヤ綅妯″紡锛�0 寮哄埗閫夋嫨 / 1 IP鍖归厤 / 2 鎵嬪姩閫夋嫨骞跺啓IP / 3 绯荤粺榛樿 */
+const mode = ref<number>(-1)
+/** 鍚庣璇嗗埆鍒扮殑鏈満IP */
+const clientIp = ref<string>('')
+/** 璇P鏄惁鏄湰鏈哄洖鐜紙127.x / ::1锛夆�斺�旇鏄庢祻瑙堝櫒鍜屾湇鍔″湪鍚屼竴鍙版満鍣紝涓嶈兘浣滀负宸ヤ綅缁戝畾鏍囪瘑 */
+const isLoopback = ref<boolean>(false)
+/** 璇P鏄惁鏄� IPv6锛堟湰绯荤粺宸ヤ綅缁戝畾浠呴噰鐢� IPv4锛� */
+const isIpv6 = ref<boolean>(false)
+/** 琚己鍒惰烦鏉ユ椂鐨勫師鍥狅細force/nomatch/occupied/error */
+const reason = ref<string>(new URLSearchParams(location.search).get('reason') || '')
+/** 宸ヤ綅琚崰鐢ㄦ椂鐨勫崰鐢ㄤ汉 */
+const occupiedBy = ref<string>(new URLSearchParams(location.search).get('who') || '')
+
+const hintText = computed(() => {
+ if (reason.value === 'multi') {
+ return `鏈満IP锛�${clientIp.value || '鏈瘑鍒�'}锛夊搴斿涓伐浣嶏紝鏃犳硶鑷姩纭畾锛岃鐐归�変綘鎵�鍦ㄧ殑宸ヤ綔浣嶇疆`
+ }
+ if (reason.value === 'occupied') {
+ return `鏈嚜鍔ㄥ尮閰嶅埌鍙敤宸ヤ綅锛氳IP瀵瑰簲鐨勫伐浣嶅凡琚�${occupiedBy.value || '鍏朵粬鍖荤敓'}鍗犵敤锛岃鎵嬪姩閫夋嫨宸ヤ綅`
+ }
+ if (reason.value === 'ip_is_server') {
+ return `璇嗗埆鍒扮殑鏄�愭湇鍔″櫒鑷韩鍦板潃銆戯紙${clientIp.value || '鏈瘑鍒�'}锛夛細璇存槑褰撳墠鏄湪鏈嶅姟鍣ㄤ笂/杩滅▼妗岄潰閲岃闂紝鎴栦唬鐞嗘妸瀹㈡埛绔湴鍧�鍐欐垚浜嗘湇鍔″櫒鍦板潃 鈥斺�� 涓嶈兘浣滀负宸ヤ綅鏍囪瘑锛岃鍦ㄥ尰鐢熺數鑴戜笂銆佺敤鏈嶅姟鍣ㄧ殑 IPv4 鍦板潃璁块棶锛涘彲鐐瑰彸涓娿�孖P 璇婃柇銆嶆煡鐪嬭鎯卄
+ }
+ if (reason.value === 'ip_invalid') {
+ return `鏈満IP涓嶅彲鐢紙${clientIp.value || '鏈瘑鍒�'}锛夛細鍥炵幆鍦板潃鎴� IPv6 涓嶈兘浣滀负宸ヤ綅鏍囪瘑锛岃鏀圭敤鏈嶅姟鍣ㄧ殑 IPv4 鍦板潃璁块棶锛涗篃鍙洿鎺ユ墜鍔ㄩ�夋嫨宸ヤ綅`
+ }
+ if (reason.value === 'nomatch') {
+ return `鏈嚜鍔ㄥ尮閰嶅埌宸ヤ綅锛堟湰鏈篒P锛�${clientIp.value || '鏈瘑鍒�'}锛夛紝璇锋墜鍔ㄩ�夋嫨宸ヤ綅`
+ }
+ if (reason.value === 'error') {
+ return '鑷姩鍖归厤宸ヤ綅澶辫触锛岃鎵嬪姩閫夋嫨宸ヤ綅'
+ }
+ if (mode.value === 2 || mode.value === 3) {
+ return '璇烽�夋嫨浣犵殑宸ヤ綅锛氱‘璁ゅ悗浼氭妸鏈満IP缁戝畾鍒拌宸ヤ綅锛屼互鍚庣櫥褰曞皢鎸塈P鑷姩鍖归厤'
+ }
+ return ''
+})
+
+const hintType = computed(() => (reason.value === 'occupied' ? 'warning' : 'info'))
+
+/** 鍙栨湰鏈篒P锛堝悗绔瘑鍒級锛岀敤浜庢彁绀轰笌妯″紡2/3鐨勭粦瀹� */
+const loadClientIp = async () => {
+ try {
+ const resp: any = await RoomApi.getIpBed()
+ clientIp.value = resp?.clientIp || ''
+ isLoopback.value = !!resp?.ipLoopback
+ isIpv6.value = !!resp?.ipv6
+ } catch (e) {
+ clientIp.value = ''
+ isLoopback.value = false
+ isIpv6.value = false
+ }
+}
+
+/* ==================== 鏈〉鍑哄彛锛堟湰娆¢渶姹傦細鍘熸潵杩涙潵鍚庡嚭涓嶅幓锛� ==================== */
+
+/**
+ * 杩斿洖涓婁竴椤碉紱娌℃湁鍘嗗彶鏃跺洖棣栭〉銆�
+ *
+ * 璇存槑锛氭湰椤垫槸**椤跺眰璺敱**銆佸叏灞忕嫭鍗狅紙涓嶅湪 Layout 閲岋級锛屽洜姝ゆ病鏈変晶杈硅彍鍗曞彲鐢ㄣ��
+ * 闈炲尰鐢熻鑹诧紙濡� admin锛夌偣杩欓噷鍗冲彲姝e父绂诲紑锛�**鏈叆搴х殑鍖荤敓**鑻�"杩斿洖"鍒板伐浣滃彴椤碉紝
+ * 浼氳璺敱瀹堝崼鍐嶆閫佸洖鏈〉锛堣繖鏄�"寮哄埗閫夊伐浣�"鐨勬棦瀹氳涓猴級鈥斺�� 閭g鎯呭喌璇风敤銆岄��鍑虹櫥褰曘�嶃��
+ */
+const goBack = () => {
+ if (window.history.length > 1) {
+ back()
+ } else {
+ push({ path: '/' })
+ }
+}
+
+/** 閫�鍑虹櫥褰曪細浠讳綍鎯呭喌閮借兘绂诲紑鏈〉锛堝厹搴曞嚭鍙o級 */
+const doLogout = async () => {
+ try {
+ await ElMessageBox.confirm('纭畾閫�鍑虹櫥褰曞悧锛�', '鎻愮ず', {
+ confirmButtonText: '纭畾閫�鍑�',
+ cancelButtonText: '鍙栨秷',
+ type: 'warning'
+ })
+ } catch {
+ return // 鐢ㄦ埛鍙栨秷
+ }
+ await userStore.loginOut()
+}
+
+/* ==================== IP 璇婃柇锛堟帓鏌�"宸ヤ綅缁戝畾鐨処P涓嶅"锛� ==================== */
+
+const ipDebugVisible = ref(false)
+const ipDebugText = ref('')
+
+/** 璋冨悗绔瘖鏂帴鍙o紝鎶�"鍚庣鍒板簳鎶婅皝褰撴垚浜嗗鎴风"閫愰」鎽婂紑 */
+const showIpDebug = async () => {
+ try {
+ const data: any = await RoomApi.ipDebug()
+ ipDebugText.value = Object.entries(data || {})
+ .map(([k, v]) => {
+ let text: string
+ if (Array.isArray(v)) {
+ text = v.length ? v.join('銆�') : '锛堟棤锛�'
+ } else if (v === null || v === undefined || v === '') {
+ text = '锛堢┖锛�'
+ } else {
+ text = String(v)
+ }
+ return `${k}锛�${text}`
+ })
+ .join('\n')
+ ipDebugVisible.value = true
+ } catch (e: any) {
+ ElMessage({
+ message: 'IP 璇婃柇澶辫触锛�' + (e?.message || e),
+ type: 'warning',
+ duration: 4000
+ })
+ }
+}
+
+/** 鏈満IP鏄惁鍙敤浜庣粦瀹氾紙鍥炵幆/鏈寚瀹�/鏈瘑鍒� 鈫� 涓嶈兘缁戝畾锛� */
+const canBindIp = computed(() => isUsableSeatIp(clientIp.value) && !isLoopback.value)
+
+/**
+ * 妯″紡 2/3锛氭妸鏈満IP鍐欏埌鎵�閫夊伐浣嶃��
+ * 鑻ヨIP宸茬粦鍦ㄥ埆鐨勫伐浣嶏紝鍏堝脊纭锛岀敤鎴峰悓鎰忓悗甯� force=true 瑕嗙洊銆�
+ * @returns 鏄惁鍙互缁х画鍏ュ骇
+ */
+const bindIpIfNeeded = async (bed: RoomVO): Promise<boolean> => {
+ if (mode.value !== 2 && mode.value !== 3) {
+ return true // 妯″紡 0/1 涓嶅啓IP
+ }
+ if (bed.id == null) {
+ return true
+ }
+ // 鍥炵幆锛�127.x / ::1锛夎鏄庢祻瑙堝櫒鍜屾湇鍔″湪鍚屼竴鍙版満鍣紝鏃犳硶浣滀负宸ヤ綅缁戝畾鏍囪瘑
+ if (isLoopback.value || !canBindIp.value) {
+ let msg: string
+ if (isLoopback.value) {
+ msg =
+ '褰撳墠璁块棶鏉ヨ嚜鏈満锛堝洖鐜湴鍧� ' +
+ clientIp.value +
+ '锛夛紝鏈涓嶅啓鍏P缁戝畾锛涜鍦ㄥ疄闄呭尰鐢熺殑鐢佃剳涓婅闂悗鍐嶇粦瀹�'
+ } else if (isIpv6.value) {
+ msg =
+ '褰撳墠璁块棶浣跨敤鐨勬槸 IPv6 鍦板潃锛�' +
+ clientIp.value +
+ '锛夛紝鏈郴缁熷伐浣嶇粦瀹氫粎閲囩敤 IPv4锛屾湰娆′笉鍐欏叆IP缁戝畾锛涜鏀圭敤鏈嶅姟鍣ㄧ殑 IPv4 鍦板潃璁块棶'
+ } else {
+ msg = '鏈兘璇嗗埆鍙敤鐨勬湰鏈篒Pv4鍦板潃锛�' + (clientIp.value || '绌�') + '锛夛紝鏈涓嶅啓鍏P缁戝畾'
+ }
+ ElMessage({ message: msg, type: 'warning', duration: 5000 })
+ return true
+ }
+ try {
+ let resp: any = await roomStore.bindCurrentIp(bed.id as number, false)
+ if (resp?.code === 409 || resp?.conflict) {
+ const target = `銆�${bed.roomName || ''} / ${bed.bedNo || ''}銆峘
+ await ElMessageBox.confirm(
+ `${resp.msg}锛屾槸鍚︽敼缁戝埌${target}锛燂紙鏀圭粦鍚庡師宸ヤ綅灏嗕笉鍐嶈嚜鍔ㄥ尮閰嶆湰鏈猴級`,
+ '鎻愮ず',
+ { confirmButtonText: '纭畾鏀圭粦', cancelButtonText: '鍙栨秷', type: 'warning' }
+ )
+ resp = await roomStore.bindCurrentIp(bed.id as number, true)
+ }
+ if (resp?.code !== 200) {
+ ElMessage({ message: resp?.msg || '缁戝畾鏈満IP澶辫触', type: 'warning', duration: 3000 })
+ return false
+ }
+ clientIp.value = resp.clientIp || clientIp.value
+ return true
+ } catch (err: any) {
+ if (err === 'cancel') {
+ return false
+ }
+ console.error('[bindIpIfNeeded] 缁戝畾鏈満IP寮傚父', err)
+ ElMessage({ message: '缁戝畾鏈満IP澶辫触锛�' + (err?.message || err), type: 'warning', duration: 3000 })
+ return false
+ }
+}
const isEmptyOpeningBed = ref<boolean>(true);
const bedMap = ref() // 鍒楄〃鐨勬暟鎹�
@@ -65,8 +283,11 @@
})
/** 鍒濆鍖� **/
-onMounted(() => {
+onMounted(async () => {
console.info( curUser.id + " onMounted")
+ // 璇诲彇銆岄�夋嫨宸ヤ綅妯″紡銆嶅苟鍙栨湰鏈篒P锛堟ā寮� 2/3 闇�瑕佸湪鍏ュ骇鏃舵妸IP鍐欏埌宸ヤ綅锛�
+ mode.value = await roomStore.loadRoomSelectMode()
+ loadClientIp()
getList()
})
@@ -95,15 +316,58 @@
if (roomStore.getIsSetRoom) {
const roomVOArray = data[key] as RoomVO[];
roomVOArray.forEach((roomVO) => {
- if (roomVO.docId === curUser.id
+ // 鐢ㄥ瓧绗︿覆姣旇緝锛岄伩鍏� docId(number) 涓� userId(string) 绫诲瀷涓嶅悓瀵艰嚧鍖归厤涓嶄笂
+ if (String(roomVO.docId) === String(curUser.id)
&& roomVO.roomId === roomStore.room!.roomId
&& roomVO.bedNo === roomStore.room!.bedNo) {
- curSel.value = roomVO
+ // 鈿狅笍 蹇呴』**鎷疯礉**锛歝urSel 鑻ヤ笌鍒楄〃椤瑰叡鐢ㄥ悓涓�涓璞★紝
+ // 鍚庣画 resetCurSel() 灏卞湴娓呴浂浼氭妸鍒楄〃閲岄偅寮犲崱鐗囩殑璇婂鍚�/宸ヤ綅鍙蜂竴璧锋竻鎺�
+ // 锛堢幇鍦哄弽棣堢殑"鍒囨崲宸ヤ綅鍚庡師宸ヤ綅缂栧彿/鍚嶇О鏈夋椂涓嶆樉绀�"灏辨槸杩欎釜鍘熷洜锛夈��
+ curSel.value = { ...roomVO }
roomStore.setRoomInfoAction(curSel.value)
}
})
}
}
+}
+
+/** 宸ヤ綅浣滀笟绫诲瀷 鈫� 宸ヤ綔鍙拌矾鐢憋紙0妫�鏌� 1棰嗙敤 2瑁呮満锛� */
+const workbenchPath = (opType?: number | null) => {
+ if (opType === 0) return '/ecg/doc/routine'
+ if (opType === 1) return '/ecg/doc/dev-ready'
+ if (opType === 2) return '/ecg/doc/dev-install'
+ return ''
+}
+
+/**
+ * 鍏ュ骇/鍒囨崲宸ヤ綅**涔嬪悗**鐨勫幓鍚戙��
+ *
+ * 銆愭湰娆¢渶姹傘�戜笉鍐�"閫夊畬宸ヤ綅灏辫嚜鍔ㄦ墦寮�鍙彿妫�鏌ラ〉" 鈥斺�� 绯荤粺涓嶇煡閬撶敤鎴锋帴涓嬫潵鏄鍋�
+ * 鍙彿妫�鏌ャ�佽澶囬鐢ㄣ�佽鏈鸿繕鏄媶鏈猴紝鏇夸粬鍐冲畾鍙嶈�岃澶氱偣涓�娆¤繑鍥炪�傝鍒欙細
+ * 鈶� 鑻ユ槸**琚矾鐢卞畧鍗涪杩囨潵**鐨勶紙甯� redirect / redirectedFrom锛夆啋 鍥炲埌浠栧師鏈兂鍘荤殑閭d竴椤碉紱
+ * 鈶� `forceEnter=true`锛堢敤鎴蜂富鍔ㄧ偣浜嗛《閮ㄣ�岀‘璁ゃ�嶆寜閽級鈫� 鎸夊伐浣嶄綔涓氱被鍨嬭繘鍏ュ搴斿伐浣滃彴
+ * 锛堣繖鏄敤鎴锋槑纭〃杈剧殑"鎴戣杩涘幓"锛屼笉绠楁浛浠栧喅瀹氾級锛�
+ * 鈶� 鍏朵綑锛堣嚜宸辩偣椤舵爮杩涙潵鎹㈠伐浣嶏級鈫� **鍋滅暀鍦ㄦ湰椤�**锛岀敱鐢ㄦ埛鑷繁浠庤彍鍗曢�夌洰鏍囬〉銆�
+ */
+const gotoAfterSeat = (opType?: number | null, forceEnter = false) => {
+ const redirect = (route.query.redirect as string) || route.redirectedFrom?.fullPath || ''
+ if (redirect && redirect !== '/roomselect') {
+ push({ path: redirect })
+ return
+ }
+ if (forceEnter) {
+ const path = workbenchPath(opType)
+ if (path) {
+ push({ path })
+ return
+ }
+ }
+ const seat = roomStore.getCurrentSeat
+ ElMessage({
+ message: `宸插叆搴э細${seat?.roomName || ''} ${seat?.bedNo || ''}锛堣浠庡乏渚ц彍鍗曡繘鍏ラ渶瑕佺殑宸ヤ綔鍙帮級`,
+ type: 'success',
+ duration: 4000
+ })
}
const confirmCurSel = () => {
@@ -115,104 +379,65 @@
});
return
}
-
- // curSel.value.opType 0 1 2
- if (curSel.value.opType === 0) {
- push({path: "/ecg/doc/routine"})
- }
- else if (curSel.value.opType === 1) {
- push({path: "/ecg/doc/dev-ready"})
- }
- else if (curSel.value.opType === 2) {
- push({path: "/ecg/doc/dev-install"})
- }
- else {
- push({path: route.redirectedFrom?.fullPath})
- }
-
-/*
- if (isStringEmpty(route.redirectedFrom?.fullPath))
- push({ path: "/ecg/doc/dev-ready"})
- else if(route.redirectedFrom?.fullPath === "/roomselect" )
- push({ path: "/ecg/doc/dev-ready"})
- else if(route.redirectedFrom?.fullPath === "/ecg/roomselect" )
- push({ path: "/ecg/doc/dev-ready"})
- else
- push({ path: route.redirectedFrom?.fullPath})
-*/
+ // 鐢ㄦ埛涓诲姩鐐广�岀‘璁ゃ��= 鏄庣‘瑕佽繘鍏ュ伐浣滃彴 鈫� 鎸夊伐浣嶄綔涓氱被鍨嬭繘鍏ワ紙鑻ユ湰娆℃槸琚涪杩囨潵鐨勶紝浼樺厛鍥炲師鐩爣椤碉級
+ gotoAfterSeat(curSel.value.opType, true)
}
const haveSeatConfirm = async (newRoomVO: RoomVO) => {
if (newRoomVO !== curSel.value) {
- let data;
-/* 淇濈暀杩欏潡閫昏緫
- if (curSel.value.docId !== null) {
- data = await DoctorApi.bedDoctorOff(curSel.value)
- if (data !== 0) {
- ElMessage({
- message: '鍐呴儴閿欒!' + data,
- type: 'info',
- duration: 3000 // 鑷姩鍏抽棴鏃堕棿锛岄粯璁や负3000ms
- });
- return
- }
+ // 妯″紡 2/3锛氬厛鎶婃湰鏈篒P缁戝畾鍒版墍閫夊伐浣嶏紙鍐茬獊鏃剁敱 bindIpIfNeeded 寮圭‘璁わ級
+ const canProceed = await bindIpIfNeeded(newRoomVO)
+ if (!canProceed) {
+ return
}
-*/
resetCurSel()
- await roomStore.clearRoomInfoAction()
const tempRoomVO = cloneDeep(newRoomVO)
tempRoomVO.docId = curUser.id
tempRoomVO.docName = curUser.nickname
- data = await DoctorApi.bedDoctorOn(tempRoomVO)
- if (data !== 0) {
- ElMessage({
- message: '鍐呴儴閿欒!' + data,
- type: 'info',
- duration: 3000 // 鑷姩鍏抽棴鏃堕棿锛岄粯璁や负3000ms
- });
+
+ // 銆愭湰娆¢渶姹傘�戣蛋 store 鐨勫叆搴у姩浣滐細鏈嶅姟绔叆搴ф垚鍔熷悗浼�**鑷姩閲婃斁鎴戣繖涓处鍙风殑鍏跺畠宸ヤ綅**
+ // 锛堜竴浜轰竴宸ヤ綅锛夛紝骞舵妸宸ヤ綅淇℃伅鍐欒繘浼氳瘽缂撳瓨銆�
+ const seated = await roomStore.seatRoom(tempRoomVO)
+ if (!seated) {
+ // 澶辫触鏃惰嚜鍔ㄨ皟璇婃柇鎺ュ彛锛屾妸搴撻噷鐪熷疄琛屼笌缁撹涓�璧风粰鍑猴紙渚夸簬鐜板満涓�閿畾浣嶏級
+ await reportSeatFailure(tempRoomVO)
+ getList()
return
}
- await roomStore.setRoomInfoAction(tempRoomVO)
- newRoomVO.docId = curUser.id
- newRoomVO.docName = curUser.nickname
- curSel.value = newRoomVO;
+ // 椤舵爮"褰撳墠宸ヤ綅"鏍囩鍒锋柊锛堝悗绔负鍑嗭級
+ await roomStore.fetchMySeat()
+
+ // 鈿狅笍 鐢�**鎷疯礉**鏇存柊"褰撳墠宸ヤ綅"锛歯ewRoomVO 鏄垪琛ㄩ噷鐨勫璞★紝
+ // 鐩存帴鏀瑰畠铏界劧鑳借鍗$墖鏄剧ず"鎴戠殑宸ヤ綅"锛屼絾鍚庣画 resetCurSel() 浼氳繛甯︽竻鎺夊崱鐗囩殑
+ // 璇婂鍚�/宸ヤ綅鍙凤紙鐜板満鍙嶉鐨勭幇璞★級銆傛敼涓烘嫹璐濆悗锛屽垪琛ㄦ暟鎹彧鐢� getList() 缁熶竴鍒锋柊銆�
+ curSel.value = { ...newRoomVO, docId: curUser.id, docName: curUser.nickname }
+
+ // 銆愭湰娆′慨澶嶃�戝叆搴ф垚鍔熷悗**閲嶆柊鎷変竴娆″垪琛�**锛氬惁鍒欏崱鐗囪繕鏄棫鐨� docId=null锛�
+ // 浼氫竴鐩存樉绀�"绌洪棽"锛堢幇鍦哄弽棣�"鍏ュ骇鍚庣殑宸ヤ綅杩樻槸鏄剧ず绌洪棽"锛夈��
+ await getList()
}
- // curSel.value.opType 0 1 2
- if (newRoomVO.opType === 0) {
- push({path: "/ecg/doc/routine"})
- }
- else if (newRoomVO.opType === 1) {
- push({path: "/ecg/doc/dev-ready"})
- }
- else if (newRoomVO.opType === 2) {
- push({path: "/ecg/doc/dev-install"})
- }
- else {
- push({path: route.redirectedFrom?.fullPath})
- }
-
-/*
- // curSel.value.opType 0 1 2
- if (isStringEmpty(route.redirectedFrom?.fullPath)) {
- push({path: "/ecg/doc/dev-ready"})
- }
- else if(route.redirectedFrom?.fullPath === "/roomselect" ) {
- push({path: "/ecg/doc/dev-ready"})
- }
- else if(route.redirectedFrom?.fullPath === "/ecg/roomselect" ) {
- push({path: "/ecg/doc/dev-ready"})
- }
- else {
- push({path: route.redirectedFrom?.fullPath})
- }
-*/
+ // 銆愭湰娆¢渶姹傘�戝叆搴�/鍒囨崲鎴愬姛鍚庝笉鍐嶈嚜鍔ㄦ墦寮�鍙彿妫�鏌ラ〉锛�
+ // 琚畧鍗涪杩囨潵鐨勫洖鍘熺洰鏍囬〉锛岃嚜宸辩偣杩涙潵鎹㈠伐浣嶇殑鍒欏仠鍦ㄦ湰椤碉紙瑙� gotoAfterSeat 璇存槑锛�
+ gotoAfterSeat(newRoomVO.opType, false)
}
const leaveSeatConfirm = async (roomVO: RoomVO) => {
+ // 銆愭湰娆¢渶姹傘�戠搴у彧鑳芥竻**鑷繁鐨�** doc_id锛堟湇鍔$ setBedDoctorOff 宸插姞 doc_id 鏉′欢锛夛紝
+ // 杩欓噷鍏堟嫤涓�閬擄紝閬垮厤"鏃佽/鍏朵粬鍖荤敓"鐐圭搴ф妸姝e湪鎿嶄綔鐨勪汉韪㈡帀銆�
+ // 鐢ㄥ瓧绗︿覆姣旇緝锛岄伩鍏� number/string 绫诲瀷宸紓瀵艰嚧璇垽銆�
+ if (roomVO.docId != null && String(roomVO.docId) !== String(curUser.id)) {
+ ElMessage({
+ message: `璇ュ伐浣嶇敱銆�${roomVO.docName || '鍏朵粬鍖荤敓'}銆嶆搷浣滀腑锛屾偍涓嶈兘璁╀粬绂诲骇`,
+ type: 'warning',
+ duration: 4000
+ })
+ return
+ }
+
if (roomVO.docId !== null) {
let data = await DoctorApi.bedDoctorOff(roomVO)
if (data !== 0) {
@@ -230,31 +455,133 @@
getList()
}
-const haveSeat = async (newRoomVO: RoomVO) => {
- // 1. 鎻愬彇涓嶅悓鐨勬彁绀鸿
- const message = newRoomVO.docId != null
- ? '宸茬粡鏈変汉浜�, 鏄惁纭畾瑕佺户缁叆搴�?'
- : '鍏ュ骇, 鏄惁缁х画?';
+/**
+ * 鎸� roomId + bedNo 鍙栬宸ヤ綅**鏈�鏂�**鐨勬暟鎹��
+ *
+ * 涓轰粈涔堝叆搴у墠瑕佸啀鎷変竴娆★細椤甸潰涓婄殑鍒楄〃鏄繘鍏ユ湰椤垫椂鎷夌殑锛屽尰鐢熷彲鑳藉仠鐣欏緢涔咃紝
+ * 鏈熼棿鍒汉姝eソ鎶婃煇涓伐浣嶅潗涓婁簡 鈥斺�� 杩欐椂鎸夋棫鏁版嵁鍒ゆ柇"绌洪棽"灏变細鍙戝嚭鍏ュ骇璇锋眰锛�
+ * 琚悗绔嫆缁濓紙鐜板満鍙嶉鐨�"閫変簡鍒汉宸插叆搴х殑宸ヤ綅鎶ラ敊"姝f槸杩欑鎯呭喌锛夈��
+ */
+const findLatestBed = async (bed: RoomVO): Promise<RoomVO | null> => {
+ try {
+ const map: any = await RoomApi.getOpeningBedMap()
+ const all: RoomVO[] = []
+ for (const key in map || {}) {
+ const arr = map[key]
+ if (Array.isArray(arr)) {
+ all.push(...arr)
+ }
+ }
+ return (
+ all.find(
+ (b) => String(b.roomId) === String(bed.roomId) && String(b.bedNo) === String(bed.bedNo)
+ ) || null
+ )
+ } catch (e) {
+ console.warn('[findLatestBed] 鍒锋柊宸ヤ綅鏈�鏂扮姸鎬佸け璐ワ紝鎸夐〉闈㈢幇鏈夋暟鎹户缁�', e)
+ return null
+ }
+}
+
+/**
+ * 鍏ュ骇澶辫触鏃剁殑鑷姪璇婃柇锛堟湰娆℃柊澧烇級銆�
+ *
+ * 鐜板満鍑虹幇杩�"宸ヤ綅鍦ㄥ簱閲屾槑鏄庣┖闂诧紝鍏ュ骇鍗存姤鐘舵�佸紓甯�"锛屽厜闈犲脊涓�鍙ラ敊璇彁绀烘棤娉曞畾浣嶃��
+ * 杩欓噷鍦ㄥけ璐ユ椂鑷姩璋� `GET /clinic/room/bed-state`锛屾妸搴撻噷**鍘熷琛�**涓庣粨璁轰竴璧峰脊缁欑敤鎴凤紝
+ * 鐢ㄦ埛鎶婂脊绐楀唴瀹瑰彂鍥炲嵆鍙畾浣嶏紙缁撳熬绌烘牸 / 鐘舵�佷笉瀵� / 宸茶鍒犻櫎 / 宸茶鍒汉鍗犵敤锛夈��
+ */
+const reportSeatFailure = async (bed: RoomVO) => {
+ let detail = ''
+ try {
+ const data: any = await RoomApi.bedState({ id: bed.id, roomId: bed.roomId, bedNo: bed.bedNo })
+ const row = Array.isArray(data?.琛屾槑缁�) && data.琛屾槑缁�.length ? data.琛屾槑缁哰0] : null
+ detail =
+ (data?.璇婃柇缁撹 ? `\n\n璇婃柇锛�${data.璇婃柇缁撹}` : '') +
+ (row
+ ? `\n\n搴撳唴璇ヨ锛歩d=${row.id} room_id=${row.room_id} bed_no=[${row.bed_no}](len=${row.bed_no_len}, HEX=${row.bed_no_hex}) status=${row.status} doc_id=${row.doc_id} doc_name=${row.doc_name} deleted=${row.deleted}`
+ : '')
+ console.warn('[reportSeatFailure] 宸ヤ綅鐘舵�佽瘖鏂�', data)
+ } catch (e) {
+ console.warn('[reportSeatFailure] 璇婃柇鎺ュ彛璋冪敤澶辫触', e)
+ }
+ await ElMessageBox.alert(
+ `鍏ュ骇鏈垚鍔燂細璇ュ伐浣嶅彲鑳藉凡琚粬浜哄崰鐢紝鎴栫姸鎬佷笉鍏佽锛堝凡鍏抽棴锛夈��${detail}`,
+ '鍏ュ骇澶辫触',
+ { confirmButtonText: '鐭ラ亾浜�', type: 'warning' }
+ )
+}
+
+/**
+ * 鐐广�屽叆搴с�嶆寜閽殑鍏ュ彛銆�
+ *
+ * 銆愭湰娆¢渶姹傘�戜袱鏉¤鍒欙細
+ * 鈶� **涓嶆尋鎺夊埆浜�**锛氬伐浣嶅凡琚粬浜烘搷浣滄椂涓嶈兘鍏ュ骇锛堝師鏉ヤ細鍏堟妸瀵规柟"绂诲骇"鍐嶆姠鍗狅紝
+ * 鏈嶅姟绔凡鏀逛负鍙厑璁告竻鑷繁鐨� doc_id锛岃繖閲岀粰鍑烘槑纭彁绀鸿�屼笉鏄鎺ュ彛鎶ラ敊锛夛紱
+ * 鈶� **涓�浜轰竴宸ヤ綅**锛氭垜宸茬粡鍦ㄥ埆鐨勫伐浣嶆椂锛屽脊纭鍚庡垏鎹紝鍘熷伐浣嶇敱鏈嶅姟绔嚜鍔ㄩ噴鏀俱��
+ *
+ * 鍙︼細鍏ュ骇鍓嶄細**閲嶆柊鎷変竴娆℃渶鏂扮姸鎬�**锛岄伩鍏嶆嬁鍑犲垎閽熷墠鐨勬暟鎹幓鍏ュ骇锛堝埆浜哄彲鑳藉垰鍧愪笂锛夈��
+ */
+const haveSeat = async (bedFromPage: RoomVO) => {
+ // 鈸� 鍏堢敤鏈�鏂版暟鎹牳瀵癸紙杩欎竴姝ユ槸鏈鐜板満"閫変簡鍒汉宸插叆搴х殑宸ヤ綅鈫掓姤閿�"鐨勫鐥囦慨澶嶏級
+ const latest = await findLatestBed(bedFromPage)
+ if (!latest) {
+ ElMessage({
+ message: '璇ュ伐浣嶅凡涓嶅彲鐢紙鍙兘宸茶鍏抽棴锛夛紝鍒楄〃宸插埛鏂帮紝璇烽噸鏂伴�夋嫨',
+ type: 'warning',
+ duration: 4000
+ })
+ getList()
+ return
+ }
+ const newRoomVO = latest
+
+ // 鈶� 宸茶**鍒汉**鍗犵敤 鈫� 涓嶆姠锛屽苟鍒锋柊鍒楄〃璁╁崱鐗囨樉绀�"宸插叆搴э細X"
+ if (newRoomVO.docId != null && String(newRoomVO.docId) !== String(curUser.id)) {
+ ElMessage({
+ message: `璇ュ伐浣嶅凡鐢便��${newRoomVO.docName || '鍏朵粬鍖荤敓'}銆嶆搷浣滀腑锛屼笉鑳藉叆搴э紙涓嶆尋鎺夋鍦ㄦ搷浣滅殑浜猴級`,
+ type: 'warning',
+ duration: 5000
+ })
+ getList()
+ return
+ }
+
+ // 鈶� 灏辨槸鎴戝綋鍓嶈繖涓伐浣� 鈫� 涓嶅繀閲嶅鍏ュ骇锛堥伩鍏嶅寮逛竴娆$‘璁わ級
+ const mySeat = roomStore.getCurrentSeat
+ const alreadyMine = newRoomVO.docId != null && String(newRoomVO.docId) === String(curUser.id)
+ const sameAsMySeat =
+ !!mySeat?.seated &&
+ String(mySeat.roomId) === String(newRoomVO.roomId) &&
+ mySeat.bedNo === newRoomVO.bedNo
+ if (alreadyMine && sameAsMySeat) {
+ ElMessage({
+ message: `鎮ㄥ凡鍏ュ骇銆�${newRoomVO.roomName || ''} / ${newRoomVO.bedNo || ''}銆嶏紝鏃犻渶閲嶅鍏ュ骇`,
+ type: 'info',
+ duration: 3000
+ })
+ await roomStore.fetchMySeat()
+ return
+ }
+
+ // 鈶� 鎴戝凡鍏ュ骇鍏跺畠宸ヤ綅 鈫� 纭鍚庡垏鎹紙鏈嶅姟绔叆搴ф椂浼氳嚜鍔ㄩ��鍑哄師宸ヤ綅锛�
+ const switching =
+ !!mySeat?.seated &&
+ (String(mySeat.roomId) !== String(newRoomVO.roomId) || mySeat.bedNo !== newRoomVO.bedNo)
+ const message = switching
+ ? `鎮ㄥ凡鍦ㄣ��${mySeat?.roomName || ''} / ${mySeat?.bedNo || ''}銆嶅叆搴э紝纭畾鍒囨崲鍒般��${newRoomVO.roomName || ''} / ${newRoomVO.bedNo || ''}銆嶅悧锛燂紙鍘熷伐浣嶄細鑷姩閫�鍑猴級`
+ : '鍏ュ骇, 鏄惁缁х画?'
try {
- // 2. 绛夊緟鐢ㄦ埛鐐瑰嚮纭
await ElMessageBox.confirm(message, '鎻愮ず', {
confirmButtonText: '纭畾',
cancelButtonText: '鍙栨秷',
type: 'warning'
- });
-
- if (newRoomVO.docId != null) {
- await leaveSeatConfirm(newRoomVO);
- }
-
- // 4. 绂诲骇鎴愬姛锛堟垨鍘熸湰灏辨病浜猴級锛屾渶鍚庢墽琛屽叆搴�
- await haveSeatConfirm(newRoomVO);
-
+ })
+ await haveSeatConfirm(newRoomVO)
} catch (err) {
// 鍙湁鐢ㄦ埛涓诲姩鐐瑰嚮鍙栨秷鏃舵墠蹇界暐锛屽叾浠栨姤閿欏彲浠ユ墦鍗板嚭鏉ユ柟渚挎帓鏌�
if (err !== 'cancel') {
- console.error('鍏ュ骇娴佺▼寮傚父:', err);
+ console.error('鍏ュ骇娴佺▼寮傚父:', err)
}
}
}
@@ -276,32 +603,39 @@
// 鍚屾椂鍧愪簡澶氫釜宸ヤ綅鏃讹紝璁惧畾褰撳墠浼氳瘽鐨勫伐浣�
const setCurSeat = (roomVO: RoomVO) => {
- roomStore.setRoomInfoAction( roomVO )
- curSel.value = roomVO
+ // 鎷疯礉涓�浠藉啀鏀捐繘 curSel锛岄伩鍏嶄笌鍒楄〃椤瑰叡鐢ㄥ璞★紙瑙� getList 閲岀殑璇存槑锛�
+ const seat = { ...roomVO }
+ roomStore.setRoomInfoAction( seat )
+ curSel.value = seat
+ // 椤舵爮鏍囩鍚屾锛堜互鏈嶅姟绔负鍑嗭級
+ roomStore.fetchMySeat()
- // curSel.value.opType 0 1 2
- if (roomVO.opType === 0) {
- push({path: "/ecg/doc/routine"})
- }
- else if (roomVO.opType === 1) {
- push({path: "/ecg/doc/dev-ready"})
- }
- else if (roomVO.opType === 2) {
- push({path: "/ecg/doc/dev-install"})
- }
- else {
- push({path: route.redirectedFrom?.fullPath})
- }
+ // 銆愭湰娆¢渶姹傘�戜笉鑷姩鎵撳紑宸ヤ綔鍙伴〉锛堣 gotoAfterSeat 璇存槑锛夛細
+ // 鑻ユ湰娆℃槸琚畧鍗涪杩囨潵鐨勪細鍥炲師鐩爣椤碉紝鍚﹀垯鍋滅暀鍦ㄩ�夊伐浣嶉〉
+ gotoAfterSeat(roomVO.opType, false)
}
+/**
+ * 閲嶇疆"褰撳墠宸ヤ綅"銆�
+ *
+ * 鈿狅笍銆愭湰娆′慨澶嶃�戝繀椤�**璧嬩竴涓柊瀵硅薄**锛屼笉鑳藉氨鍦版竻绌� curSel.value 鐨勫瓧娈碉細
+ * 鍘熷疄鐜帮紙curSel.value.bedNo = null 涔嬬被锛夊湪 curSel 涓庡垪琛ㄩ」鍏辩敤瀵硅薄鏃讹紝
+ * 浼氭妸椤甸潰鍗$墖涓婄殑銆屽伐浣嶇紪鍙� / 璇婂鍚嶇О銆嶄竴璧锋竻鎺� 鈥斺�� 涔熷氨鏄幇鍦哄弽棣堢殑
+ * "鍒囨崲鍒板叾浠栧伐浣嶅悗锛屽師宸ヤ綅鏈夋椂宸ヤ綅缂栧彿娌℃樉绀猴紝鏈夋椂璇婂鍚嶇О涓嶆樉绀�"銆�
+ */
const resetCurSel = () => {
- curSel.value.id = null
- curSel.value.roomId = null
- curSel.value.roomName = null
- curSel.value.bedNo = null
- curSel.value.status = null
- curSel.value.docId = null
- curSel.value.docName = null
+ curSel.value = {
+ id: null,
+ roomId: null,
+ roomName: null,
+ bedNo: null,
+ ip: null,
+ status: null,
+ docId: null,
+ docName: null,
+ checkTypes: [],
+ opType: 0
+ } as RoomVO
}
</script>
@@ -315,6 +649,22 @@
height: 100vh;
padding: 15px;
overflow: hidden;
+
+ /* 閫夋嫨宸ヤ綅妯″紡鎻愮ず鍖猴細璇存槑涓轰粈涔堣瑕佹眰鎵嬪姩閫夊伐浣� */
+ &__hint {
+ flex: none;
+ margin-bottom: 10px;
+ }
+
+ &__ip {
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ gap: 10px;
+ margin-top: 8px;
+ font-size: 13px;
+ color: #606266;
+ }
// 楂樺害闅忓崱鐗囨暟閲忚嚜閫傚簲锛涘崱鐗囧鍒拌涓嶄笅鏃舵墠鍐呴儴婊氬姩锛堥〉闈㈡湰韬缁堜笉婊氬姩锛�
&__scroll {
@@ -345,5 +695,45 @@
padding-top: 12px;
text-align: center;
}
+
+ /*
+ 椤堕儴鏉★紙鏈闇�姹傦級锛氭湰椤垫槸椤跺眰璺敱銆佹病鏈変晶杈硅彍鍗曪紝鍑哄彛鍙兘鑷繁缁欍��
+ 宸︽爣棰� + 鍙炽�岃繑鍥� / IP 璇婃柇 / 閫�鍑虹櫥褰曘�嶃��
+ */
+ &__topbar {
+ flex: none;
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ padding: 4px 0 10px;
+ border-bottom: 1px solid var(--el-border-color-lighter);
+ margin-bottom: 8px;
+ }
+
+ &__title {
+ font-size: 16px;
+ font-weight: 600;
+ color: #303133;
+ }
+
+ &__topbar-right {
+ display: flex;
+ align-items: center;
+ gap: 8px;
+ }
+
+ /* IP 璇婃柇缁撴灉锛氫繚鐣欏師鏍风┖鏍间笌鎹㈣锛屼究浜庨�愰」鏍稿 */
+ &__ip-debug {
+ margin: 0;
+ max-height: 60vh;
+ overflow: auto;
+ padding: 10px 12px;
+ background: var(--el-fill-color-light);
+ border-radius: 4px;
+ font-size: 13px;
+ line-height: 1.8;
+ white-space: pre-wrap;
+ word-break: break-all;
+ }
}
</style>
--
Gitblit v1.9.3