1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
| import { defineStore } from 'pinia'
| import { ref } from 'vue'
| import { Session } from '@/utils/storage'
| export const userInfoStore =defineStore('userInfo',()=>{
| const userInfo=ref({
| id:0,
| userAvatar:'',
| userName:'',
| role:'医生',
| userNo:'',
| userMobile:'',
| userSignPicUrl:'',
| roles:[
| {
| code: '',
| id: 0,
| roleName: '',
| rolePermission: '',
| roleText: '',
| }
| ],
| currentClientInfo:{code:''}})// 初始值
| function setUserInfo(user:any){
| console.log(Session.get('role'),'获取零时的角色')
| const roleName=Session.get('role')===null?'护士':Session.get('role')
| userInfo.value={
| id:user.id,
| userName:user.userName,
| role:roleName,
| userNo:user.userNo,
| userMobile:user.userMobile,
| userSignPicUrl:user.userSignPicUrl,
| roles:user.roles,
| userAvatar:user.userAvatar,
| currentClientInfo:user.currentClientInfo
| }
| }
| /**
| * 更新用户选择角色
| * @param roleText 角色名称
| */
| function setRoleInfo(roleText:any){
| Session.set('role',roleText)
| userInfo.value.role=roleText
| }
| return {userInfo,setUserInfo,setRoleInfo}
| })
|
|