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
| import { mapGetters } from 'vuex'
|
| export default {
| data() {
| return {
| // 字典选项数据
| dictOptions: {}
| }
| },
| computed: {
| ...mapGetters('dict', ['getDictByType', 'dictLoaded'])
| },
| methods: {
| // 初始化指定类型的字典 - 直接从 Vuex 获取,不再发起请求
| // 字典数据已在登录时预加载到 Vuex 和 localStorage
| initDictTypes(dictTypes) {
| dictTypes.forEach(type => {
| this.$set(this.dictOptions, type, this.getDictByType(type))
| })
| },
|
| // 获取指定类型的字典选项
| getDictOptions(dictType) {
| return this.dictOptions[dictType] || []
| }
| }
| }
|
|