| 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
49
 | | import Vue from 'vue' |  | import store from '@/store' |  | import DataDict from '@/utils/dict' |  | import { getDicts as getDicts } from '@/api/system/dict/data' |  |   |  | function searchDictByKey(dict, key) { |  |   if (key == null && key == "") { |  |     return null |  |   } |  |   try { |  |     for (let i = 0; i < dict.length; i++) { |  |       if (dict[i].key == key) { |  |         return dict[i].value |  |       } |  |     } |  |   } catch (e) { |  |     return null |  |   } |  | } |  |   |  | function install() { |  |   Vue.use(DataDict, { |  |     metas: { |  |       '*': { |  |         labelField: 'dictLabel', |  |         valueField: 'dictValue', |  |         request(dictMeta) { |  |           const storeDict = searchDictByKey(store.getters.dict, dictMeta.type) |  |           if (storeDict) { |  |             return new Promise(resolve => { resolve(storeDict) }) |  |           } else { |  |             return new Promise((resolve, reject) => { |  |               getDicts(dictMeta.type).then(res => { |  |                 store.dispatch('dict/setDict', { key: dictMeta.type, value: res.data }) |  |                 resolve(res.data) |  |               }).catch(error => { |  |                 reject(error) |  |               }) |  |             }) |  |           } |  |         }, |  |       }, |  |     }, |  |   }) |  | } |  |   |  | export default { |  |   install, |  | } | 
 |