|
@@ -11,7 +11,7 @@ function getParam (name) {
|
|
|
r = null;
|
|
|
return context == null || context == '' || context == 'undefined' ? '' : context;
|
|
|
}
|
|
|
- // 需要结合area-three-sidebar-template.js使用
|
|
|
+// 需要结合area-three-sidebar-template.js使用
|
|
|
function getRandomString (len) {
|
|
|
let randomString = ''
|
|
|
if (len) {
|
|
@@ -290,8 +290,8 @@ var areaThreeSidebarComponent = {
|
|
|
}
|
|
|
} else if (cities.ProRemark === '直辖市') {
|
|
|
// 直辖市,将区县放置到第二级
|
|
|
- if(cities.city && Array.isArray(cities?.city)) {
|
|
|
- var orgDistrict = cities?.city[0].area || []
|
|
|
+ if(cities.city && Array.isArray(cities.city)) {
|
|
|
+ var orgDistrict = cities.city[0].area || []
|
|
|
// 将区县数据取出,处理成新数组,放入城市
|
|
|
let districtChildren = orgDistrict.map(dItem => {
|
|
|
return {
|
|
@@ -302,7 +302,7 @@ var areaThreeSidebarComponent = {
|
|
|
}
|
|
|
})
|
|
|
provinceExp.children.push({
|
|
|
- city: provinceExp.name?.indexOf('市') > -1 ? provinceExp.name : provinceExp.name + '市',
|
|
|
+ city: (provinceExp.name && provinceExp.name.indexOf('市') > -1) ? provinceExp.name : provinceExp.name + '市',
|
|
|
selected: false,
|
|
|
canSelected: true,
|
|
|
id: `ac-${getRandomString(8).toLowerCase()}`,
|
|
@@ -445,7 +445,7 @@ var areaThreeSidebarComponent = {
|
|
|
// 所有二级市区遍历
|
|
|
for(let refKey in this.secondRefNameObj) {
|
|
|
var refName = this.secondRefNameObj[refKey]
|
|
|
- var renderList = this.$refs[refName]?.renderList || []
|
|
|
+ var renderList = (this.$refs[refName] && this.$refs[refName].renderList) || []
|
|
|
|
|
|
for (let i = 0; i < renderList.length; i++) {
|
|
|
var parent = renderList[i]
|
|
@@ -530,7 +530,7 @@ var areaThreeSidebarComponent = {
|
|
|
this.resetSelect()
|
|
|
if (typeof state === 'object' && Object.keys(state).length > 0) {
|
|
|
this.setSidebarState(state)
|
|
|
- this.$refs[this.allCountryRefName]?.setParentLevel0State(false)
|
|
|
+ this.$refs[this.allCountryRefName] && this.$refs[this.allCountryRefName].setParentLevel0State(false)
|
|
|
}
|
|
|
// 重新计算parent数据统计
|
|
|
firstSidebar.refreshAllChildrenState()
|
|
@@ -631,9 +631,10 @@ var areaThreeSidebarComponent = {
|
|
|
}
|
|
|
// 将全国选择重置掉
|
|
|
if(this.allCountryRefName) {
|
|
|
- this.$refs[this.allCountryRefName]?.setParentLevel0State(false)
|
|
|
+ this.$refs[this.allCountryRefName] && this.$refs[this.allCountryRefName].setParentLevel0State(false)
|
|
|
}
|
|
|
- var selectedNum = renderList?.filter(temp => temp._children_selectedCount > 0)?.length || 0
|
|
|
+ var tempList = renderList || []
|
|
|
+ var selectedNum = tempList.filter(temp => temp._children_selectedCount > 0).length || 0
|
|
|
var result = {
|
|
|
_children_selectedCount: selectedNum,
|
|
|
_children_count: renderList.length - 1
|