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
50
51
52
| // initial state
| const state = {
| user: {
| sexEnum: [{ key: 1, value: '男' }, { key: 2, value: '女' }],
| statusEnum: [{ key: 1, value: '启用' }, { key: 2, value: '禁用' }],
| levelEnum: [{ key: 1, value: '一部门' }],
| roleEnum: [{ key: 1, value: '学生' }, { key: 2, value: '教师' }, { key: 3, value: '管理员' }],
| statusTag: [{ key: 1, value: 'success' }, { key: 2, value: 'danger' }],
| statusBtn: [{ key: 1, value: '禁用' }, { key: 2, value: '启用' }]
| },
| exam: {
| examPaper: {
| paperTypeEnum: [{ key: 1, value: '固定试卷' }, { key: 4, value: '时段试卷' }, { key: 6, value: '任务试卷' }]
| },
| question: {
| typeEnum: [{ key: 1, value: '单选题' }, { key: 2, value: '多选题' }, { key: 3, value: '判断题' }],
| editUrlEnum: [{ key: 1, value: '/exam/question/edit/singleChoice', name: '单选题' },
| { key: 2, value: '/exam/question/edit/multipleChoice', name: '多选题' },
| { key: 3, value: '/exam/question/edit/trueFalse', name: '判断题' }]
| }
| }
| }
|
| // getters
| const getters = {
| enumFormat: (state) => (arrary, key) => {
| return format(arrary, key)
| }
| }
|
| // actions
| const actions = {}
|
| // mutations
| const mutations = {}
|
| const format = function (array, key) {
| for (let item of array) {
| if (item.key === key) {
| return item.value
| }
| }
| return null
| }
|
| export default {
| namespaced: true,
| state,
| getters,
| actions,
| mutations
| }
|
|