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
48
import { defineStore } from 'pinia'
export const useStore = defineStore('chronic', {
state: () => {
return {
// 字典
dict: [],
//登录医生相关基本信息
authInfo: {},
// 刷新标记
refreshMark: 1,
// 页面是否处于隐藏状态
documentHidden: false
}
},
getters: {},
actions: {
getDict(dict) {
if (!dict) return []
return this.dict[dict] || []
},
getDictValue(dict, value) {
let array = []
if (typeof dict === 'string') {
array = this.dict[dict]
} else {
array = dict
}
if (!array || !array.length) {
return ''
}
if (value instanceof Array) {
return value.map(v => {
let temp = array.find(e => e.value == v) || {}
return temp.name || ''
}).filter(e => e).join('、')
}
let temp = array.find(e => e.value == value) || {}
return temp.name || ''
},
onRefreshMark() {
this.refreshMark++
},
onDocumentHidden(value) {
this.documentHidden = value
}
}
})