Browse Source

fix:完善细节

jinx 4 years ago
parent
commit
9e3fe3d4bc
1 changed files with 71 additions and 19 deletions
  1. 71 19
      components/upload-titlemap/index.js

+ 71 - 19
components/upload-titlemap/index.js

@@ -50,7 +50,7 @@
                                 </label>
 
 
-                                <input type="file" accept=".zip"  id="files" @change="uploadPic">
+                                <input type="file" accept=".zip" ref="files"  id="files" @change="uploadPic">
                             </div>
 
                         </div>
@@ -83,7 +83,17 @@
             downloadMap() {
                 axios.get(`/indoor/${sceneNum}/api/tiled_maps/download`).then(res => {
                     console.log(this.downloadUrl + res.data.msg)
-                    window.location.href = this.downloadUrl + res.data.msg
+
+                    if (res.data.code == 0) {
+                        window.location.href = this.downloadUrl + res.data.msg
+                    } else {
+                        this.$message({
+                            message: res.data.msg,
+                            type: 'error',
+                            duration: 2000,
+                        });
+                    }
+
                 }).catch(err => {
                     this.$message({
                         message: err.data.msg,
@@ -98,8 +108,17 @@
                 this.$parent.showLoading('更新中...')
                 axios.get(`/indoor/${sceneNum}/api/tiled_maps/init`).then(res => {
                     this.$parent.hideLoading()
-                    this.getDetaile()
-                    IV.api.AuthenticationService.sendAuthenticationChanged()
+                    if (res.data.code == 0) {
+                        this.getDetaile()
+                        IV.api.AuthenticationService.sendAuthenticationChanged()
+                    } else {
+                        this.$message({
+                            message: res.data.msg,
+                            type: 'error',
+                            duration: 2000,
+                        });
+                    }
+
                 }).catch(err => {
                     this.$parent.hideLoading()
                     this.$message({
@@ -120,7 +139,17 @@
                 this.$parent.showLoading('切换中...')
                 axios.get(`/indoor/${sceneNum}/api/tiled_maps/updateDisplay/${this.info.display}`).then(res => {
                     this.$parent.hideLoading()
-                    IV.api.AuthenticationService.sendAuthenticationChanged()
+                    if (res.data.code == 0) {
+                        IV.api.AuthenticationService.sendAuthenticationChanged()
+                    } else {
+                        this.$message({
+                            message: res.data.msg,
+                            type: 'error',
+                            duration: 2000,
+                        });
+                    }
+
+
                 }).catch(err => {
                     this.$parent.hideLoading()
                     this.$message({
@@ -154,18 +183,32 @@
                 this.$parent.showLoading('上传中...')
 
                 axios.post(`/indoor/${sceneNum}/api/tiled_maps/upload`, params).then(res => {
-                    this.$message({
-                        message: '上传成功',
-                        type: 'success',
-                        duration: 2000,
-                    });
                     this.$parent.hideLoading()
-                    this.getDetaile()
-                    IV.api.AuthenticationService.sendAuthenticationChanged()
+                    let file = this.$refs.files
+                    file.value = ''
+                    if (res.data.code == 0) {
+                        this.$message({
+                            message: '上传成功',
+                            type: 'success',
+                            duration: 2000,
+                        });
+                        this.getDetaile()
+                        IV.api.AuthenticationService.sendAuthenticationChanged()
+                    } else {
+                        this.$parent.hideLoading()
+                        this.$message({
+                            message: res.data.msg,
+                            type: 'error',
+                            duration: 2000,
+                        });
+                    }
+
                 }).catch(err => {
+                    let file = this.$refs.file
+                    file.value = ''
                     this.$parent.hideLoading()
                     this.$message({
-                        message: '上传失败',
+                        message: err.data.msg,
                         type: 'error',
                         duration: 2000,
                     });
@@ -178,14 +221,23 @@
             },
             getDetaile() {
                 axios.get(`/indoor/${sceneNum}/api/tiled_maps/detail`).then(res => {
-                    console.log(res.data.data)
-                    this.info = res.data.data
-                    this.type = this.info.status || 0
-                    if (this.info.display) {
-                        this.showMapPic = true
+                    if (res.data.code == 0) {
+                        console.log(res.data.data)
+                        this.info = res.data.data
+                        this.type = this.info.status || 0
+                        if (this.info.display) {
+                            this.showMapPic = true
+                        } else {
+                            this.showMapPic = false
+                        }
                     } else {
-                        this.showMapPic = false
+                        this.$message({
+                            message: res.data.msg,
+                            type: 'error',
+                            duration: 1000,
+                        });
                     }
+
                 }).catch(err => {
                     this.$message({
                         message: err.data.msg,