liuxiaolong
2019-05-06 770c069996e1d2979c1170c1639c18b02d07e72f
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
/* import router from '@/router'
import * as types from './types.js' */
import { getOrgTree, getIdentityDict, getDeviceDict } from '@/server/common.js'
import { refreshToken } from '@/server/common/httpFetch'
export default {
  /* isLoginAction(context, info) {
    // context.commit(IS_LOGIN, info)
  }, */
  openNewWindowtab(context, params) {
    let urlStr = params.urlStr
    let isblank = params.isblank
    if (typeof params === 'string') {
      urlStr = params
    }
    if (!urlStr) {
      return false
    }
    refreshToken().then(result => {
      if (
        sessionStorage.getItem('userInfo') &&
        result.loginedInfo &&
        result.expires_in
      ) {
        /* 登陆用户重要信息 */
        let userInfo =
          sessionStorage.getItem('userInfo') !== '' &&
          JSON.parse(sessionStorage.getItem('userInfo'))
        let basicUserInfo = {}
        basicUserInfo.officeId = userInfo.officeId
        basicUserInfo.orgId = userInfo.orgId
        basicUserInfo.username = userInfo.username
        /* 信息拼接 */
        urlStr +=
          '?loginedInfo=' +
          JSON.stringify(result.loginedInfo) +
          '&expires_in=' +
          JSON.stringify(result.expires_in)
        /* +
                 '&basicUserInfo=' +
                 JSON.stringify(basicUserInfo) */
      }
      if (!isblank) {
        window.open(urlStr, '_blank')
      } else {
        window.open(urlStr, '_self')
        // window.location.href = 'http://' + urlStr
      }
    })
  },
  /* 常用字典 */
  async _initTreeData({ commit, state }, params) {
    console.log(params, 'params')
    let res = await getOrgTree(params)
    if (res) {
      commit('_INIT_TREE_DATA', { data: res })
    }
  },
  async _initIdentityDict(context, params) {
    let res = await getIdentityDict(params)
    if (res && res.code === '0' && res.data) {
      context.commit('_INIT_IDENTITY_DICT', {
        data: [...res.data]
      })
    }
  },
  async _initDevicDict(context) {
    let res = await getDeviceDict({})
    if (res) {
      context.commit('_INIT_DEVIC_DICT', {
        data: [...res]
      })
    }
  }
}