From 1446994d504819c367e1ff667360eadb314f9ac6 Mon Sep 17 00:00:00 2001
From: yxh <172933527@qq.com>
Date: 星期日, 18 十月 2026 16:52:18 +0800
Subject: [PATCH] 修改了诊室工号
---
src/store/modules/room.ts | 351 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 347 insertions(+), 4 deletions(-)
diff --git a/src/store/modules/room.ts b/src/store/modules/room.ts
index 74fe57b..9ae973d 100644
--- a/src/store/modules/room.ts
+++ b/src/store/modules/room.ts
@@ -1,15 +1,65 @@
import { store } from '@/store'
import { defineStore } from 'pinia'
import { CACHE_KEY, useCache } from '@/hooks/web/useCache'
-import {RoomVO} from "@/api/ecg/room";
+import { RoomApi, RoomVO, RoomSeatResp } from "@/api/ecg/room";
+import { DoctorApi } from "@/api/ecg/doctor";
+import { getConfigKey } from '@/api/infra/config'
+import { useUserStore } from '@/store/modules/user'
const { wsCache } = useCache("sessionStorage")
+/** 鍙傛暟 key锛氶�夋嫨宸ヤ綅妯″紡锛堜笌鍚庣 Constants.ECG_ROOM_SELECT_MODE_KEY 涓�鑷达級 */
+const ROOM_SELECT_MODE_KEY = 'ecg.room.select.mode'
+
+/**
+ * 閫夋嫨宸ヤ綅妯″紡锛�
+ * 0 = 鎸夐渶瑕佸己鍒堕�夋嫨宸ヤ綅锛�=鍘熻涓猴級
+ * 1 = 鐧诲綍IP鍖归厤宸ヤ綅锛堝尮閰嶄笉鍒版寜 0 鎵ц锛�
+ * 2 = 鐧诲綍鏃舵墜鍔ㄩ�夋嫨宸ヤ綅锛屽苟鍐欏叆鏈満IP
+ * 3 = 鎸夌郴缁熼粯璁ゅ鐞嗭紙璇P鏈粦瀹氳繃鈫掓寜2閫変竴娆″苟璁颁綇IP锛涘凡缁戝畾鈫掓寜1鑷姩鍖归厤锛涘尮閰嶄笉鍒扳啋鎸�0锛�
+ */
+export type RoomSelectMode = 0 | 1 | 2 | 3
+
+/** 鑷姩鍖归厤宸ヤ綅鐨勭粨鏋滐紝渚涜矾鐢卞畧鍗垎鏀敤 */
+export interface AutoSeatResult {
+ /** 鏄惁宸叉垚鍔熷叆搴� */
+ seated: boolean
+ /** 鍚庣璇嗗埆鍒扮殑鏈満IP */
+ clientIp: string | null
+ /**
+ * 鏈叆搴у師鍥狅紙seated=true 鏃舵棤鎰忎箟锛夛細
+ * - nomatch锛氳IP娌″尮閰嶅埌宸ヤ綅
+ * - occupied锛氬尮閰嶅埌浣嗗叏琚粬浜哄崰鐢�
+ * - multi锛�**璇P瀵瑰簲澶氫釜鍙�夊伐浣�**锛屾棤娉曞彧鍑璉P纭畾锛岄渶瑕佷汉宸ョ偣閫�
+ * - ip_invalid锛氭湰鏈篒P涓嶅彲鐢紙鍥炵幆 / IPv6 / 鏈寚瀹� / 闈炴硶锛夛紝涓嶈兘浣滀负宸ヤ綅鏍囪瘑
+ * - ip_is_server锛氳瘑鍒埌鐨勬槸**鏈嶅姟鍣ㄨ嚜韬湴鍧�**锛堝湪鏈嶅姟鍣ㄤ笂/杩滅▼妗岄潰閲岃闂紝鎴栦唬鐞嗚鐩栦簡瀹㈡埛绔湴鍧�锛�
+ * - error锛氭帴鍙e紓甯告垨鍏ュ骇鍐欏簱鏈敓鏁�
+ */
+ reason?: 'nomatch' | 'occupied' | 'multi' | 'ip_invalid' | 'ip_is_server' | 'error'
+ /** 琚崰鐢ㄦ椂鐨勫崰鐢ㄤ汉锛屼究浜庢彁绀� */
+ occupiedBy?: string | null
+}
+
interface RoomInfoVO {
- // 鍖荤敓璇婂閫夋嫨
+ // 鍖荤敓璇婂閫夋嫨锛�= 褰撳墠**鏌ョ湅**鐨勫伐浣嶏細鐪嬭嚜宸卞氨鏄嚜宸卞叆搴х殑锛岀湅鍒汉灏辨槸鍥磋瀵硅薄锛�
isSetRoom: boolean
room: RoomVO
+ // 閫夋嫨宸ヤ綅妯″紡锛�-1 琛ㄧず杩樻病鍙栧埌锛�
+ roomSelectMode: number
+ /**
+ * 褰撳墠鐧诲綍浜�**宸插叆搴�**鐨勫伐浣嶏紙绯荤粺椤舵爮鏄剧ず鐢紱鏈叆搴т负 null锛夈��
+ *
+ * 涓� `room` 鐨勫尯鍒細`room` 鏄�"鎴戞鍦ㄧ湅鍝釜宸ヤ綅"锛堝洿瑙傛椂鏄埆浜虹殑宸ヤ綅锛夛紝
+ * 鑰� `currentSeat` 鏄�"鎴戝叆搴у湪鍝釜宸ヤ綅"锛堟湇鍔$ clinic_room.doc_id = 鎴戯級銆�
+ * 涓よ�呯浉鍚� 鈫� 鍙搷浣滐紱涓嶅悓 鈫� 鍙鍥磋銆�
+ */
+ currentSeat: RoomSeatResp | null
+ /** 褰撳墠鏌ョ湅宸ヤ綅鐨勪富浜虹殑濮撳悕锛堝洿瑙傛椂鐢ㄤ簬鎻愮ず"姝e湪鍥磋 X锛堜富浜� 寮犱笁锛�"锛� */
+ viewOwnerName: string | null
+ /** 褰撳墠鏌ョ湅鐨勫伐浣嶇幇鍦ㄦ槸鍚�**鏃犱汉鎿嶄綔**锛堜富浜哄凡绂诲骇锛涘彧鎻愮ず锛屼笉鑷姩鎺ョ锛� */
+ viewTargetVacant: boolean
}
+
export const useRoomStore = defineStore('current-room', {
state: (): RoomInfoVO => ({
@@ -26,7 +76,15 @@
docName: null,
checkTypes: null,
opType: null
- }
+ },
+ // 閫夋嫨宸ヤ綅妯″紡锛�-1 = 灏氭湭浠庡悗绔彇鍒�
+ roomSelectMode: -1,
+ // 褰撳墠鍏ュ骇鐨勫伐浣嶏紙椤舵爮鏄剧ず锛涙湭鍏ュ骇涓� null锛�
+ currentSeat: null,
+ // 姝e湪鏌ョ湅鐨勫伐浣嶇殑涓讳汉濮撳悕锛堝洿瑙傛彁绀虹敤锛�
+ viewOwnerName: null,
+ // 姝e湪鏌ョ湅鐨勫伐浣嶇幇鍦ㄦ槸鍚︽棤浜烘搷浣滐紙涓讳汉宸茬搴� 鈫� 鍙彁绀猴紝涓嶈嚜鍔ㄦ帴绠★級
+ viewTargetVacant: false
}),
getters: {
// 鍖荤敓璇婂閫夋嫨
@@ -35,6 +93,45 @@
},
getRoom(): RoomVO | null {
return this.room
+ },
+ /** 褰撳墠鍏ュ骇鐨勫伐浣嶏紙鍙兘涓� null = 鏈叆搴э級 */
+ getCurrentSeat(): RoomSeatResp | null {
+ return this.currentSeat
+ },
+ /**
+ * 銆愪富/鍥磋銆戝綋鍓嶆槸鍚�**鍙互鎿嶄綔涓氬姟**銆�
+ *
+ * 鍒ゅ畾锛氭垜鍏ュ骇鐨勫伐浣� == 鎴戞鍦ㄧ湅鐨勫伐浣嶏紙鏈嶅姟绔彟鏈変竴閬撶‖鏍¢獙锛歞oc_id 蹇呴』鏄垜锛夈��
+ * 涓� false 鏃跺墠绔簲绂佺敤鎵�鏈夊啓鎿嶄綔鎸夐挳锛岀晫闈㈡樉绀�"鍥磋妯″紡 路 鍙"銆�
+ */
+ getCanOperate(): boolean {
+ const seat = this.currentSeat
+ const view = this.room
+ if (!seat || !seat.seated || !view || view.roomId == null || !view.bedNo) {
+ return false
+ }
+ return String(seat.roomId) === String(view.roomId) && String(seat.bedNo) === String(view.bedNo)
+ },
+ /** 褰撳墠鏄惁鍦�**鍥磋鍒汉鐨勫伐浣�**锛堟湁搴т絾鐪嬬殑涓嶆槸鑷繁閭e骇锛屾垨娌″骇鍙湅鍒汉锛� */
+ getIsViewingOther(): boolean {
+ return this.isSetRoom && !this.getCanOperate
+ },
+ /**
+ * 椤舵爮灞曠ず鏂囨锛歚1鍙烽棬璇� 路 A1`锛涙湭鍏ュ骇杩斿洖绌轰覆锛堢敱缁勪欢鏄剧ず"鏈叆搴�"锛夈��
+ * 璇婂鍚嶄负绌烘椂閫�鍖栦负鍙樉绀哄伐浣嶅彿锛岄伩鍏嶅嚭鐜� `undefined 路 A1`銆�
+ */
+ getSeatText(): string {
+ const seat = this.currentSeat
+ if (!seat || !seat.seated) return ''
+ const name = seat.roomName || `璇婂${seat.roomId ?? ''}`
+ return seat.bedNo ? `${name} 路 ${seat.bedNo}` : name
+ },
+ /** 椤舵爮"褰撳墠鏌ョ湅鐨勫伐浣�"鏂囨锛堝洿瑙傛椂鐢ㄥ畠锛岃�屼笉鏄垜鑷繁鍏ュ骇鐨勫伐浣嶏級 */
+ getViewText(): string {
+ const view = this.room
+ if (!view || view.roomId == null || !view.bedNo) return ''
+ const name = view.roomName || `璇婂${view.roomId}`
+ return `${name} 路 ${view.bedNo}`
}
},
actions: {
@@ -51,6 +148,23 @@
this.room!.checkTypes = room.checkTypes
this.room!.opType = room.opType
this.isSetRoom = true
+ // 銆愪富/鍥磋銆戣繖鏉¤矾寰勯兘鏄�"鎴戝叆搴х殑宸ヤ綅"锛堝叆搴� / 鎭㈠鎴戠殑宸ヤ綅 / 鑷姩鍏ュ骇 / 閫夊伐浣嶉〉鍥炲~锛夛紝
+ // 鍥犳鎶� currentSeat 涓�璧疯涓� 鈥斺�� 鍚﹀垯 getCanOperate 浼氳鍒や负"鏃犲骇鍙"銆�
+ this.currentSeat = {
+ seated: true,
+ id: room.id ?? null,
+ roomId: room.roomId ?? null,
+ roomName: room.roomName ?? null,
+ bedNo: room.bedNo ?? null,
+ ip: room.ip ?? null,
+ status: room.status ?? null,
+ docId: room.docId ?? null,
+ docName: room.docName ?? null,
+ checkTypes: room.checkTypes ?? null,
+ opType: room.opType ?? null
+ } as RoomSeatResp
+ this.viewOwnerName = room.docName ?? null
+ this.viewTargetVacant = false
// 銆愪慨澶嶃�戝啓鍏ョ紦瀛橈紙sessionStorage锛夈��
//
@@ -62,7 +176,47 @@
// 鎵嶅惎鍔ㄥ彇鏁板畾鏃跺櫒 鈬� **椤甸潰涓�鐗囩┖鐧斤紝鐪嬭捣鏉ュ儚"娌″姞杞芥帓闃熺梾浜�"**锛�
// 路 瑙掕壊涓� doctor 鐨勭敤鎴疯繕浼氳璺敱瀹堝崼寮瑰洖 /roomselect 閲嶆柊閫夎瘖瀹ゃ��
// 杩欓噷鏀逛负**鏃犳潯浠跺啓鍏�**锛涙仮澶嶈鏂囦欢鏈熬鐨� setupRoomStorePersistence()銆�
- wsCache.set(CACHE_KEY.ROOM, { isSetRoom: true, room: this.room })
+ wsCache.set(CACHE_KEY.ROOM, { isSetRoom: true, room: this.room, currentSeat: this.currentSeat })
+ },
+ /**
+ * 銆愪富/鍥磋銆戞妸"鎴戞鍦ㄧ湅鐨勫伐浣�"鍒囧埌鍒汉锛堟垨鍒囧洖鑷繁锛夆�斺��**涓嶆敼鎴戠殑鍏ュ骇宸ヤ綅**銆�
+ *
+ * 鍥磋灏辨槸闈犺繖涓姩浣滃疄鐜扮殑锛歚room`锛堢湅璋侊級涓� `currentSeat`锛堟垜鍧愬摢锛夊垎绂伙紝
+ * 涓よ�呬笉鍚屾椂 {@link getCanOperate} 涓� false 鈫� 鐣岄潰鍙锛屾湇鍔$鍙︽湁涓�閬撶‖鏍¢獙銆�
+ *
+ * @param bed 瑕佹煡鐪嬬殑宸ヤ綅锛堟潵鑷伐浣嶅垪琛級
+ * @param ownerName 璇ュ伐浣嶅綋鍓嶄富浜虹殑濮撳悕锛堟棤涓绘椂浼� null锛�
+ */
+ async setViewTargetAction(bed: RoomVO, ownerName?: string | null) {
+ this.room!.id = bed.id ?? null
+ this.room!.roomId = bed.roomId ?? null
+ this.room!.roomName = bed.roomName ?? null
+ this.room!.bedNo = bed.bedNo ?? null
+ this.room!.ip = bed.ip ?? null
+ this.room!.status = bed.status ?? null
+ this.room!.docId = bed.docId ?? null
+ this.room!.docName = bed.docName ?? null
+ this.room!.checkTypes = bed.checkTypes ?? null
+ this.room!.opType = bed.opType ?? null
+ this.isSetRoom = true
+ this.viewOwnerName = ownerName ?? bed.docName ?? null
+ this.viewTargetVacant = bed.docId == null
+ wsCache.set(CACHE_KEY.ROOM, { isSetRoom: true, room: this.room, currentSeat: this.currentSeat })
+ },
+ /**
+ * 銆愪富/鍥磋銆戝埛鏂�"鎴戞鍦ㄧ湅鐨勫伐浣�"鐨勬渶鏂扮姸鎬侊紙鐢ㄤ簬鍙戠幇涓讳汉宸茬搴э級銆�
+ *
+ * 鍙洿鏂� docId/docName 涓� vacant 鏍囪锛屼笉鏀瑰彉"鎴戝湪鐪嬪摢涓伐浣�"銆�
+ * 鎸夌‘璁ゅ彛寰勶細涓讳汉绂诲骇鍚�**鍙彁绀恒�佷笉鑷姩鎺ョ**銆�
+ */
+ refreshViewTargetState(bed: RoomVO) {
+ if (!this.room || String(this.room.roomId) !== String(bed.roomId) || this.room.bedNo !== bed.bedNo) {
+ return
+ }
+ this.room.docId = bed.docId ?? null
+ this.room.docName = bed.docName ?? null
+ this.viewOwnerName = bed.docName ?? null
+ this.viewTargetVacant = bed.docId == null
},
// 鍖荤敓绂诲骇
async clearRoomInfoAction() {
@@ -76,6 +230,10 @@
this.room.docName = null
this.isSetRoom = false
+ // 椤舵爮鏍囩鍚屾娓呯┖锛堢搴у悗鏄剧ず"鏈叆搴�"锛�
+ this.currentSeat = null
+ this.viewOwnerName = null
+ this.viewTargetVacant = false
// 娓呯紦瀛橈紙涓庝笂闈㈢殑鍐欏叆瀵瑰簲锛岄伩鍏嶄笅娆″惎鍔ㄦ妸宸茬搴х殑璇婂鎭㈠鍑烘潵锛�
wsCache.delete(CACHE_KEY.ROOM)
@@ -94,8 +252,193 @@
if (cached?.isSetRoom && cached?.room?.roomId != null && cached?.room?.bedNo != null) {
this.room = { ...this.room, ...cached.room }
this.isSetRoom = true
+ // 銆愪富/鍥磋銆戣繛"鎴戝叆搴х殑宸ヤ綅"涓�璧锋仮澶嶏細鍚﹀垯鍒锋柊鍚� getCanOperate 浼氳鍒や负鍙
+ if (cached?.currentSeat) {
+ this.currentSeat = cached.currentSeat
+ this.viewOwnerName = cached.currentSeat.docName ?? null
+ // 鈿狅笍銆愭湰娆′慨澶嶃��**涓嶆妸"鍥磋瀵硅薄"甯﹀埌涓嬩竴娆℃墦寮�**锛�
+ // 缂撳瓨閲岀殑 room 鑻ヤ笌鎴戝叆搴х殑宸ヤ綅涓嶆槸鍚屼竴涓紝璇存槑涓婃鍦ㄥ洿瑙傚埆浜恒��
+ // 鑻ョ収鍘熸牱鎭㈠锛屽埛鏂板悗宸ヤ綔鍙颁細涓�鐩存樉绀�**鍒汉宸ヤ綅鐨勯槦鍒�**锛堢湅鐫�鍍�"鎮h�呭垪琛ㄧ┖浜�"锛夛紝
+ // 鑰屽尰鐢熶互涓哄湪鐪嬭嚜宸辩殑宸ヤ綅 鈥斺�� 鐜板満鍙嶉鐨�"鍒楄〃鏁翠釜鏄┖鐨�"寰堝彲鑳藉氨鏄繖涓��
+ // 鍥磋鏄�"褰撳墠浼氳瘽閲岀殑涓存椂閫夋嫨"锛屽埛鏂�/閲嶅紑涓�寰嬪洖鍒版垜鑷繁鐨勫伐浣嶃��
+ const seat = cached.currentSeat
+ const cachedIsMine =
+ String(cached.room.roomId) === String(seat.roomId) && cached.room.bedNo === seat.bedNo
+ if (!cachedIsMine) {
+ this.room = {
+ ...this.room,
+ id: seat.id ?? null,
+ roomId: seat.roomId ?? null,
+ roomName: seat.roomName ?? null,
+ bedNo: seat.bedNo ?? null,
+ ip: seat.ip ?? null,
+ status: seat.status ?? null,
+ docId: seat.docId ?? null,
+ docName: seat.docName ?? null,
+ checkTypes: seat.checkTypes ?? null,
+ opType: seat.opType ?? null
+ }
+ this.viewOwnerName = seat.docName ?? null
+ this.viewTargetVacant = false
+ console.info('[room] 涓婃鍦ㄥ洿瑙傚叾浠栧伐浣嶏紝鏈鎵撳紑鍥炲埌鎴戣嚜宸辩殑宸ヤ綅', this.room)
+ }
+ }
}
},
+
+ /* ==================== 閫夋嫨宸ヤ綅妯″紡锛�0/1/2/3锛� ==================== */
+
+ /** 璇诲彇銆岄�夋嫨宸ヤ綅妯″紡銆嶅弬鏁帮細浼氳瘽鍐呭彧鍙栦竴娆★紱鍙栦笉鍒版垨闈炴硶涓�寰嬫寜 0锛堝師琛屼负锛夛紝閬垮厤褰卞搷瀛橀噺閮ㄧ讲 */
+ async loadRoomSelectMode(force = false): Promise<number> {
+ if (!force && this.roomSelectMode >= 0) {
+ return this.roomSelectMode
+ }
+ let mode = 0
+ try {
+ const v = await getConfigKey(ROOM_SELECT_MODE_KEY)
+ const n = Number(v)
+ if ([0, 1, 2, 3].includes(n)) {
+ mode = n
+ }
+ } catch (e) {
+ mode = 0
+ }
+ this.roomSelectMode = mode
+ return mode
+ },
+
+ /**
+ * 妯″紡 1/3锛氭寜鏈満IP鑷姩鍖归厤骞惰嚜鍔ㄥ叆搴с��
+ *
+ * 銆愭湰娆′慨澶嶃�戞敼涓�**璋冪敤鍚庣涓�涓帴鍙�**锛坄POST /clinic/room/auto-seat`锛夊畬鎴�
+ * 銆屽尮閰� 鈫� 鍒ゅ畾 鈫� 钀藉骇銆嶏紝涓嶅啀鐢卞墠绔嫾 `getIpBed 鈫� bindIpToBed 鈫� bedDoctorOn` 涓夋锛�
+ * 鍘熸潵浠讳竴姝ュけ璐ラ兘鍙兘鍥炶惤"鎵嬮�夊伐浣�"锛岀幇鍦鸿〃鐜板氨鏄�"鐧诲綍鍚庢病鏈夎嚜鍔ㄥ叆搴�"涓旂湅涓嶅嚭鍘熷洜銆�
+ * 鐜板湪鍚庣鐩存帴杩斿洖 `reason`锛坕p_invalid / nomatch / multi / occupied / error锛変笌璇嗗埆鍒扮殑 IP銆�
+ *
+ * 鍖归厤绛栫暐锛堝悗绔疄鐜帮紝涓庡師鍓嶇閫昏緫涓�鑷达級锛�
+ * 路 宸茬粡鏄垜鐨勫伐浣� 鈫� 骞傜瓑鎭㈠锛堝埛鏂�/閲嶈繘/涓婃娌℃甯哥搴ч兘璧拌繖鏉★級锛�
+ * 路 绌洪棽鍊欓��**鎭板ソ 1 涓�** 鈫� 鍏ュ骇锛堟湇鍔$鍚屾椂淇濊瘉"涓�涓敤鎴峰彧鍗犱竴涓伐浣�"锛夛紱
+ * 路 绌洪棽鍊欓��**澶氫釜** 鈫� 涓嶆搮鑷叆搴э紙reason='multi'锛夛紝浜や汉宸ョ偣閫夛紱
+ * 路 鍏ㄨ浠栦汉鍗犵敤 鈫� reason='occupied' + 鍗犵敤浜哄鍚嶏紙**涓嶆尋鎺�**宸插湪鎿嶄綔鐨勪汉锛夈��
+ */
+ async tryAutoSeatByIp(): Promise<AutoSeatResult> {
+ try {
+ const resp: any = (await RoomApi.autoSeat()) || {}
+ const clientIp: string | null = resp.clientIp ?? null
+ if (resp.seated) {
+ await this.setRoomInfoAction({
+ id: resp.id ?? null,
+ roomId: resp.roomId ?? null,
+ roomName: resp.roomName ?? null,
+ bedNo: resp.bedNo ?? null,
+ ip: resp.ip ?? null,
+ status: resp.status ?? null,
+ docId: resp.docId ?? null,
+ docName: resp.docName ?? null,
+ checkTypes: resp.checkTypes ?? null,
+ opType: resp.opType ?? null
+ } as RoomVO)
+ // 椤舵爮"褰撳墠宸ヤ綅"鏍囩鐢�
+ this.currentSeat = resp as RoomSeatResp
+ console.info('[room] 鎸塈P鑷姩鍏ュ骇鎴愬姛', resp)
+ return { seated: true, clientIp }
+ }
+ console.info('[room] 鎸塈P鑷姩鍏ュ骇鏈垚鍔燂紝杞汉宸ラ�夊伐浣�', resp)
+ return {
+ seated: false,
+ clientIp,
+ reason: (resp.reason || 'nomatch') as AutoSeatResult['reason'],
+ occupiedBy: resp.ownerName ?? null
+ }
+ } catch (e) {
+ console.error('[tryAutoSeatByIp] 鑷姩鍏ュ骇鎺ュ彛寮傚父', e)
+ return { seated: false, clientIp: null, reason: 'error' }
+ }
+ },
+
+ /**
+ * 鏌ヨ骞惰褰�"褰撳墠鐧诲綍浜哄凡鍏ュ骇鐨勫伐浣�"锛堢郴缁熼《鏍忔樉绀虹敤锛夈��
+ *
+ * 鍦烘櫙锛氬埛鏂伴〉闈� / 鏂板紑鏍囩椤� / 鐩存帴杩涚郴缁燂紝鍐呭瓨閲岀殑 `currentSeat` 鍙兘鏄┖鐨勶紝
+ * 浣嗗悗绔煡閬撴垜鏄摢涓伐浣嶇殑涓讳汉 鈥斺�� 鏌ヤ竴娆″氨鑳借椤舵爮涓庡悇椤甸潰鍙e緞涓�鑷淬��
+ *
+ * 銆愪富/鍥磋銆戞敞鎰忥細**鍙湁鍦ㄦ垜杩樻病閫�"瑕佺湅鐨勫伐浣�"銆佹垨鎴戠湅鐨勫氨鏄嚜宸卞伐浣嶆椂**锛�
+ * 鎵嶆妸鏌ョ湅鐩爣涔熷榻愬埌鎴戠殑宸ヤ綅锛涘惁鍒欎細鎶婃鍦ㄥ洿瑙傜殑瀵硅薄瑕嗙洊鎺夛紙鍥磋灏辨病娉曠敤浜嗭級銆�
+ */
+ async fetchMySeat(): Promise<RoomSeatResp | null> {
+ try {
+ const resp: any = (await RoomApi.getMySeat()) || {}
+ if (!resp.seated) {
+ this.currentSeat = null
+ return null
+ }
+ this.currentSeat = resp as RoomSeatResp
+ const noViewTarget = !this.isSetRoom || this.room.roomId == null || !this.room.bedNo
+ const viewingMyself =
+ !noViewTarget &&
+ String(this.room.roomId) === String(resp.roomId) &&
+ String(this.room.bedNo) === String(resp.bedNo)
+ if (!noViewTarget && !viewingMyself) {
+ // 姝e湪鍥磋鍒汉 鈫� 鍙洿鏂�"鎴戝叆搴х殑宸ヤ綅"锛屼笉鍔ㄦ煡鐪嬬洰鏍�
+ console.info('[room] 鏌ヨ鍒版垜鍏ュ骇鐨勫伐浣嶏紙褰撳墠姝e湪鍥磋浠栦汉锛屼笉鍒囨崲鏌ョ湅鐩爣锛�', resp)
+ return this.currentSeat
+ }
+ await this.setRoomInfoAction({
+ id: resp.id ?? null,
+ roomId: resp.roomId ?? null,
+ roomName: resp.roomName ?? null,
+ bedNo: resp.bedNo ?? null,
+ ip: resp.ip ?? null,
+ status: resp.status ?? null,
+ docId: resp.docId ?? null,
+ docName: resp.docName ?? null,
+ checkTypes: resp.checkTypes ?? null,
+ opType: resp.opType ?? null
+ } as RoomVO)
+ console.info('[room] 鏌ヨ鍒板綋鍓嶅叆搴у伐浣�', resp)
+ return this.currentSeat
+ } catch (e) {
+ console.error('[fetchMySeat] 鏌ヨ褰撳墠宸ヤ綅澶辫触', e)
+ return null
+ }
+ },
+
+ /**
+ * 鍏ュ骇锛坆ed-doctor-on锛�+ 鍐欏叆浼氳瘽銆傛娊鍑烘潵缁欍�屾墜鍔ㄩ�夋嫨銆嶅拰銆屾寜IP鑷姩鍖归厤銆嶅叡鐢ㄣ��
+ * @returns 鏄惁鍏ュ骇鎴愬姛
+ */
+ async seatRoom(bed: Partial<RoomVO>): Promise<boolean> {
+ const userStore = useUserStore()
+ const curUser: any = userStore.getUser || {}
+ const tempRoomVO: RoomVO = {
+ id: bed.id ?? null,
+ roomId: bed.roomId ?? null,
+ roomName: bed.roomName ?? null,
+ bedNo: bed.bedNo ?? null,
+ ip: bed.ip ?? null,
+ status: bed.status ?? null,
+ docId: curUser.id ?? null,
+ docName: curUser.nickname ?? null,
+ checkTypes: bed.checkTypes ?? null,
+ opType: bed.opType ?? null
+ }
+ const data = await DoctorApi.bedDoctorOn(tempRoomVO)
+ if (data !== 0) {
+ console.warn('[seatRoom] bedDoctorOn 杩斿洖闈� 0锛�', data)
+ return false
+ }
+ await this.setRoomInfoAction(tempRoomVO)
+ return true
+ },
+
+ /**
+ * 妯″紡 2/3锛氭妸鏈満IP鍐欏埌鎸囧畾宸ヤ綅銆�
+ * @returns { code, conflict, msg } 鈥斺�� code=409 琛ㄧず璇P宸茬粦鍦ㄥ埆鐨勫伐浣嶏紙conflict=true锛夛紝闇�纭鍚庡甫 force 閲嶈皟
+ */
+ async bindCurrentIp(bedId: number, force = false): Promise<any> {
+ const resp: any = await RoomApi.bindIpToBed(bedId, force)
+ return resp || {}
+ }
}
})
--
Gitblit v1.9.3