internship.js
2.8 KB
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
const state = () => ({
schoolForm: {},
schoolList: [],
departmentList: [],
professionalList: [],
schoolTermList: [],
classList: [],
})
// getters
const getters = {
}
// actions
const actions = {
async getSchoolList({
commit,
dispatch,
state
}, params) {
const result = await uni.$u.api.getSchoolListApi(params);
if (result) {
commit('setSchoolList', result);
}
},
async getDepartmentList({
commit,
dispatch,
state
}, params) {
const result = await uni.$u.api.getDepartmentListApi(params);
if (result) {
commit('setDepartmentList', result);
}
},
async getProfessionalList({
commit,
dispatch,
state
}, params) {
const result = await uni.$u.api.getProfessionalListApi(params);
if (result) {
commit('setProfessionalList', result);
}
},
async getSchoolTermList({
commit,
dispatch,
state
}, params) {
const result = await uni.$u.api.getSchoolTermListApi(params);
if (result) {
commit('setSchoolTermList', result);
}
},
async getClassList({
commit,
dispatch,
state
}, params) {
const result = await uni.$u.api.getClassListApi(params);
if (result) {
commit('setClassList', result);
}
},
}
// mutations
const mutations = {
updateSchoolForm(state, params) {
state.schoolForm = params;
},
clearSchoolList(state, result) {
state.schoolList = [];
},
clearDepartmentList(state, result) {
state.departmentList = [];
},
clearProfessionalList(state, result) {
state.professionalList = [];
},
clearClassList(state, result) {
state.classList = [];
},
setSchoolList(state, result) {
state.schoolList = result.records;
},
setDepartmentList(state, result) {
const {records=[]} = result
let departmentList = [];
if(records.length > 0) {
records.map((item, index) => {
departmentList.push({
value:item.id,
label:item.name,
})
})
}
state.departmentList = departmentList;
},
setProfessionalList(state, result) {
const {records=[]} = result
let professionalList = [];
if(records.length > 0) {
records.map((item, index) => {
professionalList.push({
value:item.id,
label:item.name,
})
})
}
state.professionalList = professionalList;
},
setSchoolTermList(state, result) {
const {records=[]} = result
let schoolTermList = [];
if(records.length > 0) {
records.map((item, index) => {
schoolTermList.push({
value:item.id,
label:item.year,
})
})
}
state.schoolTermList = schoolTermList;
},
setClassList(state, result) {
const {records=[]} = result
let classList = [];
if(records.length > 0) {
records.map((item, index) => {
classList.push({
value:item.id,
label:item.name,
})
})
}
state.classList = classList;
},
}
export default {
namespaced: true,
state,
getters,
actions,
mutations
}