n20-common-lib 1.2.18 → 1.2.21

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.
@@ -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
package/src/index.js CHANGED
@@ -71,6 +71,7 @@ import { linkPush, linkGo } from './utils/urlToGo'
71
71
  import forEachs from './utils/forEachs'
72
72
  import list2tree from './utils/list2tree'
73
73
  import { has as isHas } from './directives/VHas/index.js'
74
+ import { hasG as isHasG } from './directives/VHas/index.js'
74
75
 
75
76
  /** 国际化 */
76
77
  import i18n from './utils/i18n'
@@ -164,12 +165,21 @@ export default {
164
165
  }
165
166
  export {
166
167
  version,
167
- axios,
168
+ // 方法
168
169
  auth,
170
+ axios,
169
171
  getJsonc,
170
172
  downloadBlob,
171
173
  forEachs,
172
174
  list2tree,
175
+ repairEl,
176
+ linkPush,
177
+ linkGo,
178
+ isHas,
179
+ isHasG,
180
+ dayjs,
181
+ numerify,
182
+ // 组件
173
183
  ContentLoading,
174
184
  ContentNull,
175
185
  NavMenu,
@@ -215,11 +225,5 @@ export {
215
225
  AnchorItem,
216
226
  FlowStep,
217
227
  CascaderArea,
218
- FileExportAsync,
219
- repairEl,
220
- linkPush,
221
- linkGo,
222
- isHas,
223
- dayjs,
224
- numerify
228
+ FileExportAsync
225
229
  }
@@ -1,8 +1,6 @@
1
1
  import locale from 'element-ui/lib/locale'
2
2
  import langEn from 'element-ui/lib/locale/lang/en'
3
3
  import langTw from 'element-ui/lib/locale/lang/zh-TW'
4
- import langCN from 'element-ui/lib/locale/lang/zh-CN'
5
- langCN?.el?.pagination?.goto && (langCN.el.pagination.goto = '到第')
6
4
 
7
5
  import zhHk from './cn2hk.json' // 简体繁体映射
8
6
  // 语言枚举
@@ -40,8 +38,6 @@ directive.install = (Vue, map = {}) => {
40
38
  locale.use(langEn)
41
39
  } else if (pageLang === 'zh-hk') {
42
40
  locale.use(langTw)
43
- } else {
44
- locale.use(langCN)
45
41
  }
46
42
 
47
43
  $i18n_map_root = map
@@ -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))