n20-common-lib 2.8.36 → 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
|
@@ -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
|
-
|
|
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
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
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>
|