浏览代码

修复bug

shaogen1995 4 年之前
父节点
当前提交
dd8a415521
共有 1 个文件被更改,包括 131 次插入102 次删除
  1. 131 102
      src/views/tab1/tab1_edit.vue

+ 131 - 102
src/views/tab1/tab1_edit.vue

@@ -176,7 +176,10 @@
             <!-- 鼠标移上去显示的盒子 -->
             <div class="moveShow" v-show="moveShowIdn === index">
               <i class="el-icon-edit" @click="outEditAntique(item.id)"></i>
-              <i class="el-icon-delete" @click="outDelAntique(index,item.id)"></i>
+              <i
+                class="el-icon-delete"
+                @click="outDelAntique(index, item.id)"
+              ></i>
             </div>
           </div>
           <!-- 点击文物+号新增文物 -->
@@ -355,7 +358,10 @@ export default {
         thumb: '' // 封面
       },
       addRules: {
-        name: [{ required: true, message: '不能为空', trigger: 'blur' }, { max: 50, message: '不能超过50个字', trigger: 'blur' }],
+        name: [
+          { required: true, message: '不能为空', trigger: 'blur' },
+          { max: 50, message: '不能超过50个字', trigger: 'blur' }
+        ],
         url: { required: true, message: '不能为空', trigger: 'blur' }
       },
       // 计数监听数据有没有改变
@@ -653,7 +659,7 @@ export default {
         })
     },
     // 点击保存
-    async outBtnOk () {
+    async outBtnOk (index) {
       if (this.topTabInd === 0) {
         // console.log('项目详情保存')
         if (this.ruleForm.name.trim() === '') {
@@ -727,7 +733,7 @@ export default {
       } else if (this.topTabInd === 4) {
         // console.log('文物保存')
         const temp = []
-        this.saveAntiqueArr.forEach(v => {
+        this.saveAntiqueArr.forEach((v) => {
           temp.push(v.id)
         })
         const obj = {
@@ -738,10 +744,21 @@ export default {
         const res = await editGoods(obj)
         if (res.code === 0) {
           this.$message.success('文物编辑成功')
-          this.$router.push('/layout/tab1')
+          // this.$router.push('/layout/tab1')
         } else this.$message.warning(res.msg)
         // console.log(999, res)
       }
+      this.$nextTick(() => {
+        setTimeout(() => {
+          this.topTabInd = index
+          this.cuontChange1 =
+                this.cuontChange2 =
+                this.cuontChange3 =
+                this.cuontChange4 =
+                this.cuontChange5 =
+                  1
+        }, 100)
+      })
     },
     // 封装获取详情方法
     async getDetail () {
@@ -758,22 +775,34 @@ export default {
     tabCut (index) {
       if (index === this.topTabInd) return
       // console.log(999, index)
-      if (this.cuontChange1 > 1 || this.cuontChange2 > 1 || this.cuontChange3 > 1 || this.cuontChange4 > 1 || this.cuontChange5 > 1) {
-        this.$confirm('本次编辑未保存,是否继续跳转页面', '提示', {
+      if (
+        this.cuontChange1 > 1 ||
+        this.cuontChange2 > 1 ||
+        this.cuontChange3 > 1 ||
+        this.cuontChange4 > 1 ||
+        this.cuontChange5 > 1
+      ) {
+        this.$confirm('本次编辑未保存,是否 保存 并跳转页面', '提示', {
           confirmButtonText: '确定',
           cancelButtonText: '取消',
           type: 'warning'
         })
           .then(() => {
+            this.outBtnOk(index)
+          })
+          .catch(() => {
+            // this.$message.info('已取消!')
             this.topTabInd = index
             this.getDetail()
             setTimeout(() => {
-              this.cuontChange1 = this.cuontChange2 = this.cuontChange3 = this.cuontChange4 = this.cuontChange5 = 1
+              this.cuontChange1 =
+                this.cuontChange2 =
+                this.cuontChange3 =
+                this.cuontChange4 =
+                this.cuontChange5 =
+                  1
             }, 100)
           })
-          .catch(() => {
-            this.$message.info('已取消!')
-          })
       } else this.topTabInd = index
       // ---------------分割
     }
@@ -824,111 +853,111 @@ export default {
 }
 .template {
   .upImg {
-  width: 135px;
-  height: 135px;
-  display: flex;
-  justify-content: center;
-  align-items: center;
-  & > i {
-    font-size: 50px;
-    color: #ccc;
-  }
-}
-  .lookImg {
-  padding-top: 15px;
-  display: flex;
-  justify-content: center;
-  left: 0;
-  top: 0;
-  width: 100vw;
-  height: 100vh;
-  position: fixed;
-  z-index: 9999;
-  background-color: rgba(0, 0, 0, 0.7);
-  img {
-    max-width: 80vw;
-    max-height: 80vh;
-  }
-  .imgBtnX {
-    cursor: pointer;
-    width: 100px;
-    height: 30px;
-    position: absolute;
-    left: 50%;
-    transform: translateX(-50%);
-    bottom: 20px;
-    background-color: #fff;
-    border-radius: 8px;
-    color: black;
+    width: 135px;
+    height: 135px;
     display: flex;
     justify-content: center;
     align-items: center;
+    & > i {
+      font-size: 50px;
+      color: #ccc;
+    }
   }
-}
-  .myImgBox {
-  /deep/.el-form-item__content {
-    display: flex;
-    flex-wrap: wrap;
-  }
-  /deep/.el-upload-dragger {
-    width: 135px;
-    height: 135px;
-    border: 1px solid #ccc;
-  }
-}
-.upImgBox {
-  display: flex;
-  .active {
-    border: 2px solid #dc3545;
-  }
-}
-.imgdiv {
-  position: relative;
-  margin: 0 10px 10px 0;
-  border: 1px solid #ccc;
-  width: 135px;
-  height: 135px;
-  & > img {
-    width: 100%;
-    height: 100%;
-    object-fit: contain;
-  }
-  .imgIcon {
-    justify-content: space-around;
-    align-items: center;
+  .lookImg {
+    padding-top: 15px;
     display: flex;
-    position: absolute;
-    width: 100%;
-    height: 100%;
+    justify-content: center;
     left: 0;
     top: 0;
-    background-color: rgba(0, 0, 0, 0.6);
-    i {
-      color: #fff;
-      font-size: 24px;
-      cursor: pointer;
+    width: 100vw;
+    height: 100vh;
+    position: fixed;
+    z-index: 9999;
+    background-color: rgba(0, 0, 0, 0.7);
+    img {
+      max-width: 80vw;
+      max-height: 80vh;
     }
-    a {
-      i {
-        margin-top: 10px;
-      }
-    }
-    i:hover {
-      color: #dc3545;
-    }
-    & > span {
+    .imgBtnX {
       cursor: pointer;
-      color: #fff;
+      width: 100px;
+      height: 30px;
       position: absolute;
-      bottom: 0px;
       left: 50%;
       transform: translateX(-50%);
+      bottom: 20px;
+      background-color: #fff;
+      border-radius: 8px;
+      color: black;
+      display: flex;
+      justify-content: center;
+      align-items: center;
     }
-    & > span:hover {
-      color: #dc3545;
+  }
+  .myImgBox {
+    /deep/.el-form-item__content {
+      display: flex;
+      flex-wrap: wrap;
+    }
+    /deep/.el-upload-dragger {
+      width: 135px;
+      height: 135px;
+      border: 1px solid #ccc;
+    }
+  }
+  .upImgBox {
+    display: flex;
+    .active {
+      border: 2px solid #dc3545;
+    }
+  }
+  .imgdiv {
+    position: relative;
+    margin: 0 10px 10px 0;
+    border: 1px solid #ccc;
+    width: 135px;
+    height: 135px;
+    & > img {
+      width: 100%;
+      height: 100%;
+      object-fit: contain;
+    }
+    .imgIcon {
+      justify-content: space-around;
+      align-items: center;
+      display: flex;
+      position: absolute;
+      width: 100%;
+      height: 100%;
+      left: 0;
+      top: 0;
+      background-color: rgba(0, 0, 0, 0.6);
+      i {
+        color: #fff;
+        font-size: 24px;
+        cursor: pointer;
+      }
+      a {
+        i {
+          margin-top: 10px;
+        }
+      }
+      i:hover {
+        color: #dc3545;
+      }
+      & > span {
+        cursor: pointer;
+        color: #fff;
+        position: absolute;
+        bottom: 0px;
+        left: 50%;
+        transform: translateX(-50%);
+      }
+      & > span:hover {
+        color: #dc3545;
+      }
     }
   }
-}
   position: relative;
   padding: 0px 30px;
   .top {
@@ -951,7 +980,7 @@ export default {
     .txt {
       font-weight: 700;
       height: 40px;
-      border-bottom: 1px solid #A3A2A9;
+      border-bottom: 1px solid #a3a2a9;
     }
     .search {
       position: relative;