From adecd142412454acbd8f729c7230e9a90b3dcddc Mon Sep 17 00:00:00 2001
From: eight <641137800@qq.com>
Date: 星期一, 18 十一月 2024 14:39:20 +0800
Subject: [PATCH] room store 改为 sessionStorage
---
src/views/ecg/room/RoomLoginSelect.vue | 15 ++-
src/views/ecg/doctor/Routine.vue | 24 +++--
src/hooks/web/useCache.ts | 1
src/views/ecg/doctor/index.vue | 16 ++--
src/store/modules/user.ts | 84 ---------------------
src/store/modules/room.ts | 89 ++++++++++++++++++++++
src/permission.ts | 6 +
7 files changed, 125 insertions(+), 110 deletions(-)
diff --git a/src/hooks/web/useCache.ts b/src/hooks/web/useCache.ts
index 990715e..eb83725 100644
--- a/src/hooks/web/useCache.ts
+++ b/src/hooks/web/useCache.ts
@@ -10,6 +10,7 @@
// 鐢ㄦ埛鐩稿叧
ROLE_ROUTERS: 'roleRouters',
USER: 'user',
+ ROOM: 'room',
// 绯荤粺璁剧疆
IS_DARK: 'isDark',
LANG: 'lang',
diff --git a/src/permission.ts b/src/permission.ts
index b0f6231..d0bfdfd 100644
--- a/src/permission.ts
+++ b/src/permission.ts
@@ -9,6 +9,7 @@
import { useCheckTypeStoreWithOut } from '@/store/modules/checkType'
import { useUserStoreWithOut } from '@/store/modules/user'
import { usePermissionStoreWithOut } from '@/store/modules/permission'
+import { useRoomStoreWithOut } from "@/store/modules/room";
const { start, done } = useNProgress()
@@ -83,6 +84,7 @@
// 鑾峰彇鎵�鏈夊瓧鍏�
const dictStore = useDictStoreWithOut()
const userStore = useUserStoreWithOut()
+ const roomStore = useRoomStoreWithOut()
const checkTypeStore = useCheckTypeStoreWithOut()
const permissionStore = usePermissionStoreWithOut()
if (!dictStore.getIsSetDict) {
@@ -97,7 +99,7 @@
// <<<銆愯瘖瀹ら�夋嫨銆�<<<
if ( to.path !== '/roomselect' &&
userStore.getRoles.includes("doctor") && !userStore.getRoles.includes("super_admin")
- && !userStore.getIsSetRoom ) {
+ && !roomStore.getIsSetRoom ) {
next({path: `/roomselect?redirect=${to.fullPath}`})
return
}
@@ -119,7 +121,7 @@
// <<<銆愯瘖瀹ら�夋嫨銆�<<<
if ( to.path !== '/roomselect' &&
userStore.getRoles.includes("doctor") && !userStore.getRoles.includes("super_admin")
- && !userStore.getIsSetRoom ) {
+ && !roomStore.getIsSetRoom ) {
next({path: `/roomselect?redirect=${to.fullPath}`})
return
}
diff --git a/src/store/modules/room.ts b/src/store/modules/room.ts
new file mode 100644
index 0000000..f3f771b
--- /dev/null
+++ b/src/store/modules/room.ts
@@ -0,0 +1,89 @@
+import { store } from '@/store'
+import { defineStore } from 'pinia'
+import { CACHE_KEY, useCache } from '@/hooks/web/useCache'
+import {RoomVO} from "@/api/ecg/room";
+
+const { wsCache } = useCache("sessionStorage")
+
+interface RoomInfoVO {
+ // 鍖荤敓璇婂閫夋嫨
+ isSetRoom: boolean
+ room: RoomVO
+}
+
+export const useRoomStore = defineStore('current-room', {
+ state: (): RoomInfoVO => ({
+ // 鍖荤敓璇婂閫夋嫨
+ isSetRoom: false,
+ room: {
+ id: null,
+ roomId: null,
+ roomName: null,
+ bedNo: null,
+ ip: null,
+ status: null,
+ docId: null,
+ docName: null,
+ checkTypes: null,
+ opType: null
+ }
+ }),
+ getters: {
+ // 鍖荤敓璇婂閫夋嫨
+ getIsSetRoom(): boolean {
+ return this.isSetRoom
+ },
+ getRoom(): RoomVO | null {
+ return this.room
+ }
+ },
+ actions: {
+ // 鍖荤敓鍏ュ骇
+ async setRoomInfoAction(room: RoomVO) {
+ // 鏇存柊 store
+ this.room!.id = room.id
+ this.room!.roomId = room.roomId
+ this.room!.roomName = room.roomName
+ this.room!.bedNo = room.bedNo
+ this.room!.status = room.status
+ this.room!.docId = room.docId
+ this.room!.docName = room.docName
+ this.room!.checkTypes = room.checkTypes
+ this.room!.opType = room.opType
+ this.isSetRoom = true
+
+ // 鏇存柊 cache
+ const bedInfo = wsCache.get(CACHE_KEY.ROOM)
+ if (bedInfo) {
+ bedInfo.room = room
+ bedInfo.isSetRoom = true
+ wsCache.set(CACHE_KEY.ROOM, bedInfo)
+ }
+ },
+ // 鍖荤敓绂诲骇
+ async clearRoomInfoAction() {
+ // 娓� store
+ this.room.id = null
+ this.room.roomId = null
+ this.room.roomName = null
+ this.room.bedNo = null
+ this.room.status = null
+ this.room.docId = null
+ this.room.docName = null
+
+ this.isSetRoom = false
+
+ // 鏇存柊 cache
+ const roomInfo = wsCache.get(CACHE_KEY.ROOM)
+ if (roomInfo) {
+ roomInfo.room = null
+ roomInfo.isSetRoom = false
+ wsCache.set(CACHE_KEY.ROOM, roomInfo)
+ }
+ },
+ }
+})
+
+export const useRoomStoreWithOut = () => {
+ return useRoomStore(store)
+}
diff --git a/src/store/modules/user.ts b/src/store/modules/user.ts
index ed1f54e..77443e7 100644
--- a/src/store/modules/user.ts
+++ b/src/store/modules/user.ts
@@ -3,7 +3,6 @@
import { getAccessToken, removeToken } from '@/utils/auth'
import { CACHE_KEY, useCache, deleteUserCache } from '@/hooks/web/useCache'
import { getInfo, loginOut } from '@/api/login'
-import {RoomVO} from "@/api/ecg/room";
const { wsCache } = useCache()
@@ -20,10 +19,6 @@
roles: string[]
isSetUser: boolean
user: UserVO
-
- // 鍖荤敓璇婂閫夋嫨
- isSetRoom: boolean
- room: RoomVO
}
export const useUserStore = defineStore('admin-user', {
@@ -37,20 +32,6 @@
nickname: '',
deptId: 0
},
- // 鍖荤敓璇婂閫夋嫨
- isSetRoom: false,
- room: {
- id: null,
- roomId: null,
- roomName: null,
- bedNo: null,
- ip: null,
- status: null,
- docId: null,
- docName: null,
- checkTypes: null,
- opType: null
- }
}),
getters: {
getPermissions(): string[] {
@@ -65,13 +46,6 @@
getUser(): UserVO {
return this.user
},
- // 鍖荤敓璇婂閫夋嫨
- getIsSetRoom(): boolean {
- return this.isSetRoom
- },
- getRoom(): RoomVO | null {
- return this.room
- }
},
actions: {
async setUserInfoAction() {
@@ -90,50 +64,6 @@
wsCache.set(CACHE_KEY.USER, userInfo)
wsCache.set(CACHE_KEY.ROLE_ROUTERS, userInfo.menus)
},
- // 鍖荤敓鍏ュ骇
- async setRoomInfoAction(room: RoomVO) {
- // 鏇存柊 store
- this.room!.id = room.id
- this.room!.roomId = room.roomId
- this.room!.roomName = room.roomName
- this.room!.bedNo = room.bedNo
- this.room!.status = room.status
- this.room!.docId = room.docId
- this.room!.docName = room.docName
- this.room!.checkTypes = room.checkTypes
- this.room!.opType = room.opType
- this.isSetRoom = true
-
- // 鏇存柊 cache
- const userInfo2 = wsCache.get(CACHE_KEY.USER)
- if (userInfo2) {
- userInfo2.room = room
- userInfo2.isSetRoom = true
- wsCache.set(CACHE_KEY.USER, userInfo2)
- }
- },
- // 鍖荤敓绂诲骇
- async clearRoomInfoAction() {
- // 娓� store
- this.room.id = null
- this.room.roomId = null
- this.room.roomName = null
- this.room.bedNo = null
- this.room.status = null
- this.room.docId = null
- this.room.docName = 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)
- }
- },
-
async setUserAvatarAction(avatar: string) {
const userInfo = wsCache.get(CACHE_KEY.USER)
// NOTE: 鏄惁闇�瑕佸儚`setUserInfoAction`涓�鏍峰垽鏂璥userInfo != null`
@@ -163,20 +93,6 @@
avatar: '',
nickname: '',
deptId: 0
- }
- // 鍖荤敓璇婂閫夋嫨
- this.isSetRoom = false
- this.room = {
- id: 0,
- roomId: 0,
- roomName: "",
- bedNo: "",
- ip: "",
- status: null,
- docId: null,
- docName: null,
- checkTypes: null,
- opType: null
}
}
}
diff --git a/src/views/ecg/doctor/Routine.vue b/src/views/ecg/doctor/Routine.vue
index 4f52518..40ea739 100644
--- a/src/views/ecg/doctor/Routine.vue
+++ b/src/views/ecg/doctor/Routine.vue
@@ -2,13 +2,12 @@
import TitlePanel from "@/views/ecg/doctor/components/TitlePanel.vue";
import QueuePanel from "@/views/ecg/doctor/components/QueuePanel.vue";
import {DoctorApi, PatientStatisticVO, RoomBedVO} from '@/api/ecg/doctor';
-import {useUserStore} from "@/store/modules/user";
import {QueueVO} from "@/api/ecg/queue";
import {ElNotification} from "element-plus";
-import DevReadyPanel from "@/views/ecg/doctor/components/DevReadyPanel.vue";
import RoutinePanel from "@/views/ecg/doctor/components/RoutinePanel.vue";
+import {useRoomStore} from "@/store/modules/room";
-const userStore = useUserStore();
+const roomStore = useRoomStore();
const roomBedVO: RoomBedVO = {
roomId: null,
@@ -19,13 +18,16 @@
}
const onStagePatient = ref<QueueVO>({
- bedNo: "", bookCheckType: 0, bookTimeslot: 0, expired: 0, id: 0, jumpFlag: 0, passed: 0,
- patGender: 0, patId: "", patName: "", roomId: 0, roomName: "", seqNum: 0, status: 0
+ id: 0, patId: "", patName: "", patGender: 0,
+ bookTimeslot: 0, bookCheckType: 0, isVip: 0, seqNum: 0, bookSeqNum: 0,
+ passed: 0, expired: 0, jumpFlag: 0,
+ roomId: 0, roomName: "", bedNo: "", status: 0
})
const patientStat = ref<PatientStatisticVO>({
finishedNum: 0,
readyNum: 0,
+ receivedNum: 0,
passedNum: 0,
queuingNum: 0
})
@@ -128,12 +130,12 @@
finishFlag.value = true
passFlag.value = true
- if (userStore.isSetRoom) {
- roomBedVO.roomId = userStore.room!.roomId
- roomBedVO.roomName = userStore.room!.roomName
- roomBedVO.bedNo = userStore.room!.bedNo
- roomBedVO.checkTypes = userStore.room!.checkTypes
- roomBedVO.opType = userStore.room!.opType
+ if (roomStore.isSetRoom) {
+ roomBedVO.roomId = roomStore.room!.roomId
+ roomBedVO.roomName = roomStore.room!.roomName
+ roomBedVO.bedNo = roomStore.room!.bedNo
+ roomBedVO.checkTypes = roomStore.room!.checkTypes
+ roomBedVO.opType = roomStore.room!.opType
timerRunFlag = true
doctorTimer()
diff --git a/src/views/ecg/doctor/index.vue b/src/views/ecg/doctor/index.vue
index e8fd253..b29a0c2 100644
--- a/src/views/ecg/doctor/index.vue
+++ b/src/views/ecg/doctor/index.vue
@@ -3,12 +3,12 @@
import TitlePanel from "@/views/ecg/doctor/components/TitlePanel.vue";
import QueuePanel from "@/views/ecg/doctor/components/QueuePanel.vue";
import {DoctorApi, PatientStatisticVO, RoomBedVO} from '@/api/ecg/doctor';
-import {useUserStore} from "@/store/modules/user";
import {QueueVO} from "@/api/ecg/queue";
import {ElNotification} from "element-plus";
import DevReadyPanel from "@/views/ecg/doctor/components/DevReadyPanel.vue";
+import {useRoomStore} from "@/store/modules/room";
-const userStore = useUserStore();
+const roomStore = useRoomStore();
const roomBedVO: RoomBedVO = {
roomId: null,
@@ -128,12 +128,12 @@
finishFlag.value = true
passFlag.value = true
- if (userStore.isSetRoom) {
- roomBedVO.roomId = userStore.room!.roomId
- roomBedVO.roomName = userStore.room!.roomName
- roomBedVO.bedNo = userStore.room!.bedNo
- roomBedVO.checkTypes = userStore.room!.checkTypes
- roomBedVO.opType = userStore.room!.opType
+ if (roomStore.isSetRoom) {
+ roomBedVO.roomId = roomStore.room!.roomId
+ roomBedVO.roomName = roomStore.room!.roomName
+ roomBedVO.bedNo = roomStore.room!.bedNo
+ roomBedVO.checkTypes = roomStore.room!.checkTypes
+ roomBedVO.opType = roomStore.room!.opType
timerRunFlag = true
doctorTimer()
diff --git a/src/views/ecg/room/RoomLoginSelect.vue b/src/views/ecg/room/RoomLoginSelect.vue
index 00ae7df..b76d0d9 100644
--- a/src/views/ecg/room/RoomLoginSelect.vue
+++ b/src/views/ecg/room/RoomLoginSelect.vue
@@ -21,6 +21,7 @@
import {isStringEmpty} from "@/utils/stringUtil";
import {cloneDeep} from "lodash-es";
import {DoctorApi} from "@/api/ecg/doctor";
+import {useRoomStore} from "@/store/modules/room";
const { push } = useRouter()
defineOptions({ name: 'RoomLoginSelect' })
@@ -28,6 +29,7 @@
const route = useRoute();
const userStore = useUserStore()
+const roomStore = useRoomStore()
const curUser = userStore.getUser
const isEmptyOpeningBed = ref<boolean>(true);
@@ -39,7 +41,10 @@
bedNo: null,
status: null,
docId: null,
- docName: null
+ docName: null,
+ ip: "",
+ checkTypes: [],
+ opType: 0
})
/** 鍒濆鍖� **/
@@ -73,7 +78,7 @@
roomVOArray.forEach((roomVO) => {
if (roomVO.docId === curUser.id) {
curSel.value = roomVO
- userStore.setRoomInfoAction(curSel.value)
+ roomStore.setRoomInfoAction(curSel.value)
}
})
}
@@ -115,7 +120,7 @@
}
resetCurSel()
- userStore.clearRoomInfoAction()
+ await roomStore.clearRoomInfoAction()
const tempRoomVO = cloneDeep(newRoomVO)
tempRoomVO.docId = curUser.id
@@ -130,7 +135,7 @@
return
}
- userStore.setRoomInfoAction(tempRoomVO)
+ await roomStore.setRoomInfoAction(tempRoomVO)
newRoomVO.docId = curUser.id
newRoomVO.docName = curUser.nickname
curSel.value = newRoomVO;
@@ -165,7 +170,7 @@
}
resetCurSel()
- userStore.clearRoomInfoAction()
+ await roomStore.clearRoomInfoAction()
getList()
}
--
Gitblit v1.9.3