Pārlūkot izejas kodu

增加文物编辑确定功能

shaogen1995 4 gadi atpakaļ
vecāks
revīzija
adbfef998a
1 mainītis faili ar 58 papildinājumiem un 15 dzēšanām
  1. 58 15
      src/views/tab1/tab1_edit.vue

+ 58 - 15
src/views/tab1/tab1_edit.vue

@@ -357,13 +357,50 @@ export default {
       addRules: {
         name: [{ required: true, message: '不能为空', trigger: 'blur' }, { max: 50, message: '不能超过50个字', trigger: 'blur' }],
         url: { required: true, message: '不能为空', trigger: 'blur' }
-      }
+      },
+      // 计数监听数据有没有改变
+      cuontChange1: 0,
+      cuontChange2: 0,
+      cuontChange3: 0,
+      cuontChange4: 0,
+      cuontChange5: 0
     }
   },
   // 监听属性 类似于data概念
   computed: {},
   // 监控data中的数据变化
-  watch: {},
+  watch: {
+    ruleForm: {
+      handler (newv) {
+        this.cuontChange1++
+      },
+      deep: true
+    },
+    tab1Arr: {
+      handler (newv) {
+        this.cuontChange2++
+      },
+      deep: true
+    },
+    tab2Arr: {
+      handler (newv) {
+        this.cuontChange3++
+      },
+      deep: true
+    },
+    fuJianArr: {
+      handler (newv) {
+        this.cuontChange4++
+      },
+      deep: true
+    },
+    saveAntiqueArr: {
+      handler (newv) {
+        this.cuontChange5++
+      },
+      deep: true
+    }
+  },
   // 方法集合
   methods: {
     // ----------------文物弹窗里面---------------
@@ -719,19 +756,25 @@ export default {
     },
     // 上面的tab栏切换
     tabCut (index) {
-      // this.$confirm('请确定当前页面数据已保存', '提示', {
-      //   confirmButtonText: '确定',
-      //   cancelButtonText: '取消',
-      //   type: 'warning'
-      // })
-      //   .then(() => {
-      //     this.getDetail()
-      this.topTabInd = index
-      //   this.$message.success('切换成功!')
-      // })
-      // .catch(() => {
-      //   this.$message.info('已取消!')
-      // })
+      // console.log(999, index)
+      if (this.cuontChange1 > 1 || this.cuontChange2 > 1 || this.cuontChange3 > 1 || this.cuontChange4 > 1 || this.cuontChange5 > 1) {
+        this.$confirm('本次编辑未保存,是否继续跳转页面', '提示', {
+          confirmButtonText: '确定',
+          cancelButtonText: '取消',
+          type: 'warning'
+        })
+          .then(() => {
+            this.topTabInd = index
+            this.getDetail()
+            setTimeout(() => {
+              this.cuontChange1 = this.cuontChange2 = this.cuontChange3 = this.cuontChange4 = this.cuontChange5 = 1
+            }, 100)
+          })
+          .catch(() => {
+            this.$message.info('已取消!')
+          })
+      } else this.topTabInd = index
+      // ---------------分割
     }
   },
   // 生命周期 - 创建完成(可以访问当前this实例)