emis-sapp/store/modules/common.js
2024-08-31 14:13:02 +08:00

53 lines
1.2 KiB
JavaScript

import { COMMONKEY } from "../actionKey"
import {
setSessionXToken,
getSessionXToken,
setSessionUserInfo,
getSessionUserInfo
} from "@/session"
import * as apiService from "@/common/api"
import { goto } from "@/common/untool"
import { transListKeyTitle } from "@/common/util"
export default {
state: {
dicData: {}
},
mutations: {
[COMMONKEY.GETDIC](state, provider) {
state.dicData = provider
},
},
getters: {
// packInfo(state) {
// return state.user
// }
},
actions: {
async [COMMONKEY.GETDIC]({
dispatch,
commit,
state,
rootState
}, options) {
const resInfo = await apiService.getDicDataJson()
let data = {}
// 转换接口返回的数据字典
resInfo?.data?.map?.((item)=> {
let key = Object.keys(item).filter(i=> i != 'desc')[0]
if(key) {
let list = []
if(['emis_signs_remark', 'emis_express_code', 'emis_order_remark_list', 'emis_complaints_type'].indexOf(key) > -1) {
// 特殊枚举值, label、value一致
list = transListKeyTitle({ valKey:'label', titleKey: 'label', list: item[key] })
} else {
list = transListKeyTitle({ valKey:'value', titleKey: 'label', list: item[key] })
}
data[key] = list
}
})
commit(COMMONKEY.GETDIC, data)
},
}
}