dataease-dm/frontend/src/utils/webMsg.js

25 lines
702 B
JavaScript
Raw Normal View History

2021-07-09 18:37:07 +08:00
import { allTypes } from '@/api/system/msg'
import store from '@/store'
export const loadMsgTypes = value => {
let msgTypes = store.getters.msgTypes
if (!msgTypes || Object.keys(msgTypes).length === 0) {
allTypes().then(res => {
msgTypes = res.data
const defaultType = { msgTypeId: -1, pid: 0, typeName: '全部类型' }
msgTypes.splice(0, 0, defaultType)
store.dispatch('msg/setMsgTypes', msgTypes)
})
}
}
2021-07-02 19:19:38 +08:00
export const getTypeName = value => {
2021-07-09 18:37:07 +08:00
const msgTypes = store.getters.msgTypes
2021-07-02 19:19:38 +08:00
for (let index = 0; index < msgTypes.length; index++) {
const element = msgTypes[index]
2021-07-09 18:37:07 +08:00
if (element.msgTypeId === value) {
return element.typeName
2021-07-02 19:19:38 +08:00
}
}
}