n20-common-lib 1.2.16 → 1.2.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "n20-common-lib",
3
- "version": "1.2.16",
3
+ "version": "1.2.19",
4
4
  "private": false,
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -30,6 +30,7 @@
30
30
  "axios": "^0.21.4",
31
31
  "dayjs": "^1.10.6",
32
32
  "js-cookie": "^3.0.1",
33
+ "jsonwebtoken": "^8.5.1",
33
34
  "normalize.css": "^8.0.1",
34
35
  "numerify": "^1.2.9",
35
36
  "resize-detector": "^0.3.0",
@@ -14,12 +14,10 @@
14
14
  font-weight: 500;
15
15
  &::after {
16
16
  content: '';
17
- position: absolute;
18
- left: 0;
19
- bottom: 0;
20
- height: 2px;
21
- width: 100%;
22
- background-color: $--color-primary;
17
+ height: 6px;
18
+ background-color: #007aff;
19
+ display: block;
20
+ margin-top: -1px;
23
21
  }
24
22
  }
25
23
  &.is-disabled {
@@ -177,6 +177,7 @@
177
177
  </template>
178
178
 
179
179
  <script>
180
+ import decode from 'jsonwebtoken/decode'
180
181
  import axios from '../../utils/axios'
181
182
  import auth from '../../utils/auth'
182
183
  import qrCode from './qrcode.vue'
@@ -223,6 +224,7 @@ export default {
223
224
  accountPthon: '账户密码验证码登录'
224
225
  },
225
226
  theType: this.loginTypes[0],
227
+ userNo: undefined,
226
228
  form: {
227
229
  username: '',
228
230
  password: '',
@@ -243,7 +245,8 @@ export default {
243
245
  ]
244
246
  },
245
247
  fPwV: false,
246
- codeNum: '验证码'
248
+ codeNum: '验证码',
249
+ getAzCount: 0
247
250
  }
248
251
  },
249
252
  methods: {
@@ -321,22 +324,41 @@ export default {
321
324
  })
322
325
  },
323
326
  // 获取加密参数
324
- async authorizationCode(username, password, code) {
327
+ authorizationCode(username, password, code) {
328
+ this.getAzCount = this.getAzCount + 1
329
+
325
330
  let pwdArr = code ? [username, password, code] : [username, password]
326
331
  let pwd = pwdArr.join('@@')
327
332
 
328
- let { data = {} } = await axios.get(
329
- '/bems/prod_1.0/uas/api/authorization/authorizationCode',
330
- {},
331
- { loading: false }
332
- )
333
- try {
334
- pwd = encode(pwd, data.authorizationValue)
335
- } catch (error) {
336
- this.loadingV = false
337
- // this.$message.warning('密码加密错误')
338
- }
339
- this.pwd = pwd + '@@' + data.authorizationKey
333
+ return new Promise((resolve, reject) => {
334
+ if (this.getAzCount <= 3) {
335
+ axios
336
+ .get(
337
+ '/bems/prod_1.0/uas/api/authorization/authorizationCode',
338
+ {},
339
+ { loading: false }
340
+ )
341
+ .then(({ data = {} }) => {
342
+ try {
343
+ pwd = encode(pwd, data.authorizationValue)
344
+ this.pwd = pwd + '@@' + data.authorizationKey
345
+
346
+ this.getAzCount = 0
347
+ resolve()
348
+ } catch (error) {
349
+ console.error('密码加密错误:' + JSON.stringify(data))
350
+ this.authorizationCode(username, password, code) // 再次请求
351
+ .then(resolve)
352
+ .catch(reject)
353
+ }
354
+ })
355
+ } else {
356
+ // 当重新请求大于3次,抛出错误
357
+ this.$message.warning(`登录失败,请重新登录!`)
358
+ this.getAzCount = 0
359
+ reject()
360
+ }
361
+ })
340
362
  },
341
363
  // 账号/密码登录
342
364
  async passwordLogin() {
@@ -467,6 +489,14 @@ export default {
467
489
  // 登录成功后
468
490
  loginAfter(data) {
469
491
  auth.setToken(data.accessToken)
492
+ try {
493
+ let tokenObj = decode(data.accessToken)
494
+ let userInfo = JSON.parse(tokenObj.user_name)
495
+ this.userNo = userInfo.userNo
496
+ } catch (error) {
497
+ console.error('accessToken解析错误:' + data.accessToken)
498
+ }
499
+
470
500
  Promise.all([
471
501
  this.getUserInfo(),
472
502
  this.getMicroAppsInfo(),
@@ -483,7 +513,7 @@ export default {
483
513
  },
484
514
  // 获取用户基本信息
485
515
  async getUserInfo() {
486
- let username = this.form.username
516
+ let username = this.userNo
487
517
  let { data } = await axios.get(
488
518
  // '/bems/prod_1.0/user/api/userController/userCltAdDep/' + username
489
519
  '/bems/prod_1.0/user/api/userController/userCltAdRole/' + username
@@ -517,7 +547,7 @@ export default {
517
547
  axios
518
548
  .post(
519
549
  '/bems/prod_1.0/user/api/userController/qryBusyInfoNo',
520
- { uno: this.form.username },
550
+ { uno: this.userNo },
521
551
  { loading: false, noMsg: true }
522
552
  )
523
553
  .then(({ data: cltrelaMap = [] }) => {
@@ -14,6 +14,20 @@ export function has(vals, clt) {
14
14
  }
15
15
  }
16
16
 
17
+ export function hasG(vals, clt) {
18
+ let relaNos = []
19
+ if (clt) {
20
+ relaNos = getCltRela(clt)
21
+ } else {
22
+ relaNos = getRela().relaNosGlobal
23
+ }
24
+ if (typeof vals === 'string') {
25
+ return relaNos.includes(vals)
26
+ } else if (Array.isArray(vals)) {
27
+ return vals.some((val) => relaNos.includes(val))
28
+ }
29
+ }
30
+
17
31
  const directive = {}
18
32
  directive.install = (Vue) => {
19
33
  Vue.prototype.$has = has
@@ -27,6 +41,18 @@ directive.install = (Vue) => {
27
41
  !has(binding.value, binding.arg) && el.parentNode.removeChild(el)
28
42
  }
29
43
  })
44
+ // 全局查找
45
+ Vue.prototype.$hasG = hasG
46
+
47
+ Vue.filter('isHasG', hasG)
48
+
49
+ Vue.filter('noHasG', (v, arg) => !hasG(v, arg))
50
+
51
+ Vue.directive('hasG', {
52
+ inserted(el, binding) {
53
+ !hasG(binding.value, binding.arg) && el.parentNode.removeChild(el)
54
+ }
55
+ })
30
56
  }
31
57
 
32
58
  export default directive
@@ -3,8 +3,10 @@ import Tooltip from './tooltip.vue'
3
3
  let timer = undefined
4
4
 
5
5
  function tipShow(el, tip) {
6
+ let _input = el.querySelector('.el-input__inner')
7
+ if (_input && !el.$tooltipTitle) el.$tooltipTitle = _input.value
6
8
  if (el.$tooltipTitle) {
7
- let _el = el.querySelector('.el-input__inner') || el
9
+ let _el = _input || el
8
10
  if (!el.$tooltipTitleOverflow || _el.clientWidth < _el.scrollWidth) {
9
11
  tip.title = el.$tooltipTitle
10
12
  tip.$refs['title-pop'].referenceElm = el
@@ -20,6 +20,12 @@ export function setRela(name) {
20
20
  relaNos.find((r) => r.appNo === name)
21
21
  )
22
22
  console.log(relaObj, 'has权限列表')
23
+
24
+ let relaNosGlobal = []
25
+ relaNos.forEach((item) => {
26
+ relaNosGlobal.push.apply(relaNosGlobal, item.relaNos)
27
+ })
28
+ relaObj.relaNosGlobal = relaNosGlobal
23
29
  return
24
30
  }
25
31
  /* 兼容旧门户 */
@@ -31,6 +37,7 @@ export function setRela(name) {
31
37
  relaNos.push(item.relaNo)
32
38
  })
33
39
  relaObj.relaNos = relaNos
40
+ relaObj.relaNosGlobal = relaNos
34
41
  }
35
42
  }
36
43
 
@@ -61,7 +68,7 @@ export function getCltRela(clt) {
61
68
  }
62
69
 
63
70
  function aandb(a = [], b = []) {
64
- if (a.length === 0 || a.length === 0) {
71
+ if (a.length === 0 || b.length === 0) {
65
72
  return []
66
73
  } else {
67
74
  return a.filter((ai) => b.includes(ai))