zjf
2023-03-03 26e972196ed6046bcb7fb341be86241c8300fd2b
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
import {
  oaMessageNumAPI
} from '@/api/oamanagement/workbench'
import {
  objDeepCopy
} from '@/utils'
 
/**
 * 消息记录
 */
const oa = {
  state: {
    // 待办事项消息
    messageOANum: {
      eventNum: 0,
      taskNum: 0,
      announcementNum: 0,
      logNum: 0,
      examineNum: 0
    }
  },
 
  mutations: {
    /**
     * 更改待办事项
     */
    SET_MESSAGEOANUM: (state, messageOANum) => {
      state.messageOANum = messageOANum
    }
  },
 
  actions: {
    /**
     * 获取待办消息数
     * @param {*} param
     */
    GetOAMessageNum({
      state,
      commit
    }, type) {
      return new Promise((resolve, reject) => {
        const params = {}
        if (type) {
          params.type = type
        }
        oaMessageNumAPI(params)
          .then(response => {
            if (type) {
              const copyNum = objDeepCopy(state.messageOANum)
              copyNum[type + 'Num'] = response.data[type + 'Num'] || 0
              commit('SET_MESSAGEOANUM', copyNum)
            } else {
              commit('SET_MESSAGEOANUM', response.data)
            }
            if (resolve) {
              resolve(response)
            }
          })
          .catch(error => {
            if (reject) {
              reject(error)
            }
          })
      })
    }
 
  }
}
 
export default oa