eight
2024-08-28 2bc74ebfec4a30beddc66fd55be4947e5f7cf498
src/store/modules/user.ts
@@ -23,7 +23,7 @@
  // 医生诊室选择
  isSetRoom: boolean
  room: RoomVO
  room: RoomVO | null
}
export const useUserStore = defineStore('admin-user', {
@@ -44,7 +44,9 @@
      roomId: 0,
      roomName: "",
      bedNo: "",
      onstage: true
      status: null,
      docId: null,
      docName: null
    }
  }),
  getters: {
@@ -64,7 +66,7 @@
    getIsSetRoom(): boolean {
      return this.isSetRoom
    },
    getRoom(): RoomVO {
    getRoom(): RoomVO | null {
      return this.room
    }
  },
@@ -85,13 +87,8 @@
      wsCache.set(CACHE_KEY.USER, userInfo)
      wsCache.set(CACHE_KEY.ROLE_ROUTERS, userInfo.menus)
    },
    // 医生诊室选择
    // 医生入座
    async setRoomInfoAction(room: RoomVO) {
      if (!getAccessToken()) {
        this.resetState()
        return null
      }
      // 更新 store
      this.room = room
      this.isSetRoom = true
@@ -101,6 +98,20 @@
      if (userInfo2) {
        userInfo2.room = room
        userInfo2.isSetRoom = true
        wsCache.set(CACHE_KEY.USER, userInfo2)
      }
    },
    // 医生离座
    async clearRoomInfoAction() {
      // 清 store
      this.room = null
      this.isSetRoom = false
      // 更新 cache
      const userInfo2 = wsCache.get(CACHE_KEY.USER)
      if (userInfo2) {
        userInfo2.room = null
        userInfo2.isSetRoom = false
        wsCache.set(CACHE_KEY.USER, userInfo2)
      }
    },
@@ -142,7 +153,9 @@
        roomId: 0,
        roomName: "",
        bedNo: "",
        onstage: true
        status: null,
        docId: null,
        docName: null
      }
    }
  }