diff --git a/src/views/system/stationAvatar/index.vue b/src/views/system/stationAvatar/index.vue index 19235f7..185d0d5 100644 --- a/src/views/system/stationAvatar/index.vue +++ b/src/views/system/stationAvatar/index.vue @@ -217,19 +217,23 @@ export default { // 上传图片 uploadImg() { let formData = new FormData(); - formData.append("file", this.previews.data); - formData.append("type", this.types); - updateNurseStationHeads(formData).then((response) => { - this.options.img = baseurl + response.imgUrl; - this.$emit("imgUrl", response.imgUrl); - console.log(this.items); - console.log(this.types); - if (this.types == "attributePitureUrl") { - this.items.attributePitureUrl = response.imgUrl; - this.$emit("item", JSON.stringify(this.items)); - } + if (this.previews.data) { + formData.append("file", this.previews.data); + formData.append("type", this.types); + updateNurseStationHeads(formData).then((response) => { + this.options.img = baseurl + response.imgUrl; + this.$emit("imgUrl", response.imgUrl); + console.log(this.items); + console.log(this.types); + if (this.types == "attributePitureUrl") { + this.items.attributePitureUrl = response.imgUrl; + this.$emit("item", JSON.stringify(this.items)); + } + this.openimg = false; + }); + } else { this.openimg = false; - }); + } }, // 实时预览 realTime(data) {