Pārlūkot izejas kodu

feat(org): confirmation before deletion

Casper Dai 3 gadi atpakaļ
vecāks
revīzija
0872d48e3f
2 mainītis faili ar 32 papildinājumiem un 22 dzēšanām
  1. 14 9
      src/views/realm/tenant/Group.vue
  2. 18 13
      src/views/realm/tenant/Tenant.vue

+ 14 - 9
src/views/realm/tenant/Group.vue

@@ -132,17 +132,22 @@ export default {
       }
     },
     onDel (group) {
-      const loading = this.$showLoading()
-      unbindDevices(group.path).then(() => {
-        return deleteGroup(group).then(() => {
-          this.$message({
-            type: 'success',
-            message: '删除成功'
+      this.$confirm(
+        `删除 ${group.remark} ?`,
+        { type: 'warning' }
+      ).then(() => {
+        const loading = this.$showLoading()
+        unbindDevices(group.path).then(() => {
+          return deleteGroup(group).then(() => {
+            this.$message({
+              type: 'success',
+              message: '删除成功'
+            })
+            this.$refs.table.decrease(1)
           })
-          this.$refs.table.decrease(1)
+        }).finally(() => {
+          this.$closeLoading(loading)
         })
-      }).finally(() => {
-        this.$closeLoading(loading)
       })
     }
   }

+ 18 - 13
src/views/realm/tenant/Tenant.vue

@@ -150,21 +150,26 @@ export default {
       return addTenant(this.group)
     },
     onDel (group) {
-      const loading = this.$showLoading()
-      unbindDevices(group.path).then(() => {
-        return deleteGroup(group).then(() => {
-          this.$message({
-            type: 'success',
-            message: '删除成功'
+      this.$confirm(
+        `删除 ${group.remark} ?`,
+        { type: 'warning' }
+      ).then(() => {
+        const loading = this.$showLoading()
+        unbindDevices(group.path).then(() => {
+          return deleteGroup(group).then(() => {
+            this.$message({
+              type: 'success',
+              message: '删除成功'
+            })
+            if (group.parentGroup) {
+              this.$refs.table.pageTo()
+            } else {
+              this.$refs.table.decrease(1)
+            }
           })
-          if (group.parentGroup) {
-            this.$refs.table.pageTo()
-          } else {
-            this.$refs.table.decrease(1)
-          }
+        }).finally(() => {
+          this.$closeLoading(loading)
         })
-      }).finally(() => {
-        this.$closeLoading(loading)
       })
     }
   }