|
@@ -0,0 +1,50 @@
|
|
|
+import {getDeptList} from "@/api/modules/dept";
|
|
|
+
|
|
|
+const state = {
|
|
|
+ deptList: [],
|
|
|
+ deptMap: new Map()
|
|
|
+}
|
|
|
+
|
|
|
+const getters = {
|
|
|
+}
|
|
|
+
|
|
|
+const mutations = {
|
|
|
+ SET_DEPT (state: any, data: Array<any>) {
|
|
|
+ const list: any = []
|
|
|
+ const map = new Map()
|
|
|
+ data.forEach(v => {
|
|
|
+ v.dictLabel = v.organizationName
|
|
|
+ v.dictValue = v.id
|
|
|
+ list.push(v)
|
|
|
+ })
|
|
|
+ state.deptList = list
|
|
|
+ state.deptMap = map
|
|
|
+ },
|
|
|
+}
|
|
|
+
|
|
|
+const actions = {
|
|
|
+ LOAD_DEPT ({ commit }: any, refresh = false) {
|
|
|
+ return new Promise((resolve, reject) => {
|
|
|
+ if (refresh || state.deptList?.length === 0) {
|
|
|
+ getDeptList().then((res) => {
|
|
|
+ if (res.code === 200) {
|
|
|
+ commit('SET_DEPT', res.data)
|
|
|
+ resolve(res.data)
|
|
|
+ } else {
|
|
|
+ reject(res.message)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ resolve(state.deptList)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+}
|
|
|
+
|
|
|
+export default {
|
|
|
+ namespaced: true,
|
|
|
+ state,
|
|
|
+ getters,
|
|
|
+ mutations,
|
|
|
+ actions
|
|
|
+}
|