n20-common-lib 2.8.35 → 2.8.37

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": "2.8.35",
3
+ "version": "2.8.37",
4
4
  "private": false,
5
5
  "scripts": {
6
6
  "serve": "vue-cli-service serve",
@@ -13,8 +13,10 @@
13
13
 
14
14
  <script>
15
15
  import axios from '../../utils/axios'
16
+ import list2tree from '../../utils/list2tree'
17
+
16
18
  window._china_area_tree_ = undefined
17
- import cloneDeep from 'lodash/cloneDeep'
19
+
18
20
  export default {
19
21
  name: 'CascaderArea',
20
22
  props: {
@@ -30,15 +32,10 @@ export default {
30
32
  type: Boolean,
31
33
  default: true
32
34
  },
33
-
34
35
  isUrban: {
35
36
  type: Boolean,
36
37
  default: false
37
38
  },
38
- isStreet: {
39
- type: Boolean,
40
- default: false
41
- },
42
39
  labelSort: {
43
40
  type: Boolean,
44
41
  default: false
@@ -63,8 +60,7 @@ export default {
63
60
  value: 'regionNo',
64
61
  label: 'regionName',
65
62
  children: 'children',
66
- expandTrigger: 'hover',
67
- checkStrictly: this.isUrban ? false : true
63
+ expandTrigger: 'hover'
68
64
  }
69
65
  return Object.assign(_prop, this.props)
70
66
  },
@@ -73,44 +69,46 @@ export default {
73
69
  },
74
70
  urbanKey() {
75
71
  return this.countryId === 'CHN' ? '_china_urban_tree_' : `_${this.countryId}_urban_tree_`
76
- },
77
- streetKey() {
78
- return this.countryId === 'CHN' ? '_china_street_tree_' : `_${this.countryId}_street_tree_`
79
72
  }
80
73
  },
81
74
  mounted() {
82
75
  if (!window[this.areaKey]) {
83
76
  this.getAreaTree()
84
77
  } else {
85
- this.areaTree = this.isUrban
86
- ? window[this.urbanKey]
87
- : this.isStreet
88
- ? window[this.streetKey]
89
- : window[this.areaKey]
78
+ this.areaTree = this.isUrban ? window[this.urbanKey] : window[this.areaKey]
90
79
  }
91
80
  },
92
81
  methods: {
93
82
  getAreaTree() {
94
83
  axios
95
- .get(
96
- `/bems/1.0/area?t=${Math.random()}`,
97
- { countryId: this.countryId, isEnable: '1', resultType: 2, queryLeave4: this.isStreet },
98
- { loading: false, noMsg: true }
99
- )
84
+ .get('/bems/1.0/area', { countryId: this.countryId, isEnable: '1' }, { loading: false, noMsg: true })
100
85
  .then(({ data }) => {
101
- if (data) {
102
- let result = cloneDeep(data)
103
- if (this.isUrban) {
104
- window[this.urbanKey] = isUrbanFn(result)
105
- this.areaTree = window[this.urbanKey]
106
- } else if (this.isStreet) {
107
- window[this.streetKey] = treeFn(result)
108
- this.areaTree = window[this.streetKey]
109
- } else {
110
- window[this.areaKey] = treeFn(result)
111
- this.areaTree = window[this.areaKey]
112
- }
86
+ let dataAr = JSON.parse(JSON.stringify(data))
87
+ let dataUb = JSON.parse(JSON.stringify(data))
88
+
89
+ let areaTree = list2tree(
90
+ dataAr,
91
+ 'regionNo',
92
+ 'fatherNo',
93
+ 'children',
94
+ this.labelSort ? 'regionName' : 'regionNo'
95
+ )
96
+ let noAreaTree = areaTree.filter((a) => a.regionLevel !== '1')
97
+ if (noAreaTree.length > 0) {
98
+ console.warn('这些区域找不到父级节点:', noAreaTree)
113
99
  }
100
+ window[this.areaKey] = areaTree.filter((a) => a.regionLevel === '1')
101
+
102
+ let urbanTree = list2tree(
103
+ dataUb.filter((d) => d.regionLevel !== '3'),
104
+ 'regionNo',
105
+ 'fatherNo',
106
+ 'children',
107
+ this.labelSort ? 'regionName' : 'regionNo'
108
+ )
109
+
110
+ window[this.urbanKey] = urbanTree.filter((a) => a.regionLevel === '1')
111
+ this.areaTree = this.isUrban ? window[this.urbanKey] : window[this.areaKey]
114
112
  })
115
113
  },
116
114
  updateArea() {
@@ -118,30 +116,4 @@ export default {
118
116
  }
119
117
  }
120
118
  }
121
-
122
- const treeFn = (data) => {
123
- return data?.map((res) => {
124
- if (!['3', '4', '5'].includes(res.regionLevel)) {
125
- res.disabled = true
126
- }
127
-
128
- if (!res.children?.length) {
129
- res.children = null
130
- } else {
131
- res.children = treeFn(res.children)
132
- }
133
- return res
134
- })
135
- }
136
-
137
- const isUrbanFn = (data) => {
138
- return data?.map((res) => {
139
- if (res.regionLevel === '2') {
140
- res.children = null
141
- } else {
142
- res.children = isUrbanFn(res.children)
143
- }
144
- return res
145
- })
146
- }
147
119
  </script>
@@ -501,7 +501,9 @@ export default {
501
501
  this.hideTheme = _layoutData.hideTheme
502
502
  this.showNavigation = _layoutData.showNavigation
503
503
  this.systemChange = _layoutData.systemChange
504
-
504
+ if (this.langMap?.lang?.length) {
505
+ window.localStorage.setItem('pageLang', this.jsonData?.lang[0])
506
+ }
505
507
  if (_loginSetting !== 'JSON') {
506
508
  this.headerTitle = sessionStorage.getItem('headerTitle') || this.headerTitle
507
509
  }
@@ -459,6 +459,9 @@ export default {
459
459
  const { _layoutData = {}, loginSetting, screenInspect } = await getJsonc('/server-config.jsonc')
460
460
  let _loginSetting = loginSetting || _layoutData.loginSetting
461
461
  this.jsonData = _layoutData
462
+ if (this.jsonData?.lang?.length) {
463
+ window.localStorage.setItem('pageLang', this.jsonData?.lang[0])
464
+ }
462
465
  if (_loginSetting !== 'JSON' && this.jsonData.showSystem) {
463
466
  await this.getSysSet()
464
467
  }