fix: 修复地图数据自动解析下一级时,下一级的GeoJSON显示为null的问题

main
hong.yang 1 year ago
parent a4b897a703
commit 73705282d3

@ -173,7 +173,7 @@ export default {
computed: { computed: {
autoParseNextLevelShow () { autoParseNextLevelShow () {
// geoJson // geoJson
return !this.isWhitespace(this.mapForm.geoJson) && this.mapForm.uploadedGeoJson === 0 return !this.isWhitespace(this.mapForm.geoJson) && !this.isEmpty(this.mapForm.geoJson) && this.mapForm.uploadedGeoJson === 0
}, },
outRangeLabel() { outRangeLabel() {
return `级别${this.mapForm.level + 1}`; return `级别${this.mapForm.level + 1}`;
@ -264,6 +264,8 @@ export default {
this.mapForm = _.cloneDeep(map) this.mapForm = _.cloneDeep(map)
if (!this.isWhitespace(this.mapForm.geoJson)) { if (!this.isWhitespace(this.mapForm.geoJson)) {
this.mapForm.geoJson = JSON.parse(this.mapForm.geoJson) this.mapForm.geoJson = JSON.parse(this.mapForm.geoJson)
} else {
this.mapForm.geoJson = {}
} }
}, },
handleClose () { handleClose () {
@ -275,7 +277,7 @@ export default {
return false return false
} }
let geoJson let geoJson
// geoJson // geoJson
if (this.isWhitespace(this.mapForm.geoJson) || this.mapForm.geoJson === '{}' || this.mapForm.geoJson === '[]') { if (this.isWhitespace(this.mapForm.geoJson) || this.mapForm.geoJson === '{}' || this.mapForm.geoJson === '[]') {
geoJson = '' geoJson = ''
} else { } else {
@ -300,6 +302,15 @@ export default {
} }
return /^\s*$/.test(str) return /^\s*$/.test(str)
}, },
isEmpty (obj) {
if (typeof obj === 'object') {
return Object.keys(obj).length === 0 && obj.constructor === Object
}
if (typeof obj === 'string') {
return /^\s*$/.test(obj)
}
return Array.isArray(obj) && obj.length === 0
},
upload () { upload () {
this.$refs.geoJsonFile.click() this.$refs.geoJsonFile.click()
}, },

Loading…
Cancel
Save