From 73705282d3c310c8030893cd2ebe5d83e21c1625 Mon Sep 17 00:00:00 2001 From: "hong.yang" Date: Wed, 11 Oct 2023 17:41:29 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E5=9C=B0=E5=9B=BE?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E8=87=AA=E5=8A=A8=E8=A7=A3=E6=9E=90=E4=B8=8B?= =?UTF-8?q?=E4=B8=80=E7=BA=A7=E6=97=B6=EF=BC=8C=E4=B8=8B=E4=B8=80=E7=BA=A7?= =?UTF-8?q?=E7=9A=84GeoJSON=E6=98=BE=E7=A4=BA=E4=B8=BAnull=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../packages/MapDataManagement/src/EditForm.vue | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/data-room-ui/packages/MapDataManagement/src/EditForm.vue b/data-room-ui/packages/MapDataManagement/src/EditForm.vue index 53d00a6f..aa77b010 100644 --- a/data-room-ui/packages/MapDataManagement/src/EditForm.vue +++ b/data-room-ui/packages/MapDataManagement/src/EditForm.vue @@ -173,7 +173,7 @@ export default { computed: { autoParseNextLevelShow () { // 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() { return `级别${this.mapForm.level + 1}`; @@ -264,6 +264,8 @@ export default { this.mapForm = _.cloneDeep(map) if (!this.isWhitespace(this.mapForm.geoJson)) { this.mapForm.geoJson = JSON.parse(this.mapForm.geoJson) + } else { + this.mapForm.geoJson = {} } }, handleClose () { @@ -275,7 +277,7 @@ export default { return false } let geoJson - // 如果geoJson是空的,包括空字符串,纯空格、空对象,空数组,都不允许提交 + // 如果geoJson是空的,包括空字符串,纯空格、空对象,空数组,都置为空字符串 if (this.isWhitespace(this.mapForm.geoJson) || this.mapForm.geoJson === '{}' || this.mapForm.geoJson === '[]') { geoJson = '' } else { @@ -300,6 +302,15 @@ export default { } 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 () { this.$refs.geoJsonFile.click() },