double 5 years ago
parent
commit
a5e5332471
4 changed files with 79 additions and 187 deletions
  1. 20 48
      src/views/menu/index.vue
  2. 19 45
      src/views/optionset/index.vue
  3. 20 48
      src/views/org/index.vue
  4. 20 46
      src/views/role/index.vue

+ 20 - 48
src/views/menu/index.vue

@@ -233,18 +233,11 @@ export default {
         if (valid) {
           this.$api.sysMenu.add(this.temp).then(res => {
             this.dialogVisible = false
-            if (res.code === 200) {
-              this.$message({
-                message: 'Created successfully',
-                type: 'success'
-              })
-              this.$refs.qtable.getData()
-            } else {
-              this.$message({
-                message: 'Failed to create',
-                type: 'error'
-              })
-            }
+            this.$message({
+              message: 'Created successfully',
+              type: 'success'
+            })
+            this.$refs.qtable.getData()
           })
         }
       })
@@ -255,18 +248,11 @@ export default {
           const postData = Object.assign({}, this.temp)
           this.$api.sysMenu.update(postData).then(res => {
             this.dialogVisible = false
-            if (res.code === 200) {
-              this.$message({
-                message: 'modify successfully',
-                type: 'success'
-              })
-              this.$refs.qtable.getData()
-            } else {
-              this.$message({
-                message: 'change failed',
-                type: 'error'
-              })
-            }
+            this.$message({
+              message: 'modify successfully',
+              type: 'success'
+            })
+            this.$refs.qtable.getData()
           })
         }
       })
@@ -282,18 +268,11 @@ export default {
         type: 'warning'
       }).then(() => {
         this.$api.sysMenu.del({ id: row.id }).then(res => {
-          if (res.code === 200) {
-            this.$message({
-              message: 'successfully deleted',
-              type: 'success'
-            })
-            this.$refs.qtable.getData()
-          } else {
-            this.$message({
-              message: 'failed to delete',
-              type: 'error'
-            })
-          }
+          this.$message({
+            message: 'successfully deleted',
+            type: 'success'
+          })
+          this.$refs.qtable.getData()
         })
       })
     },
@@ -306,18 +285,11 @@ export default {
         type: 'warning'
       }).then(() => {
         this.$api.sysMenu.batchDel(ids).then(res => {
-          if (res.code === 200) {
-            this.$refs.qtable.getData()
-            this.$message({
-              message: 'successfully deleted',
-              type: 'success'
-            })
-          } else {
-            this.$message({
-              message: 'failed to delete',
-              type: 'error'
-            })
-          }
+          this.$refs.qtable.getData()
+          this.$message({
+            message: 'successfully deleted',
+            type: 'success'
+          })
         })
       })
     },

+ 19 - 45
src/views/optionset/index.vue

@@ -72,7 +72,7 @@
             </div>
           </div>
           <div type="flex" class="row-bg repair-item" style="float: left; width: 95%; ">
-            <div class="button" @click="addItem">+ 添加</div>
+            <div class="button" @click="addItem">+ {{ $t('common.create') }}</div>
           </div>
         </el-form-item>
       </el-form>
@@ -179,18 +179,11 @@ export default {
           this.temp.value = JSON.stringify(this.maps)
           this.$api.system.AddOptionset(this.temp).then(res => {
             this.dialogVisible = false
-            if (res.code === 200) {
-              this.$message({
-                message: '创建成功',
-                type: 'success'
-              })
-              this.$refs.qtable.getData()
-            } else {
-              this.$message({
-                message: '创建失败',
-                type: 'error'
-              })
-            }
+            this.$message({
+              message: '创建成功',
+              type: 'success'
+            })
+            this.$refs.qtable.getData()
           })
         }
       })
@@ -213,46 +206,27 @@ export default {
     deleteData(row) {
       this.$confirm('确认删除?', '提示', {
         type: 'warning'
-      })
-        .then(() => {
-          this.$api.system.DelOptionset([{ id: row.id }]).then(res => {
-            if (res.code === 200) {
-              this.$refs.qtable.getData()
-              this.$message({
-                message: '删除成功',
-                type: 'success'
-              })
-            } else {
-              this.$message({
-                message: '删除失败',
-                type: 'error'
-              })
-            }
+      }).then(() => {
+        this.$api.system.DelOptionset([{ id: row.id }]).then(res => {
+          this.$refs.qtable.getData()
+          this.$message({
+            message: '删除成功',
+            type: 'success'
           })
         })
-        .catch(() => {})
+      }).catch(() => {})
     },
     deleteBatch() {
-      const ids = []
-      this.$refs.qtable.multipleSelection.forEach(row => {
-        ids.push({ id: row.id })
-      })
+      const ids = this.$refs.qtable.multipleSelection.map(row => ({ id: row.id }))
       this.$confirm('确认批量删除选中数据吗?', '提示', {
         type: 'warning'
       }).then(() => {
         this.$api.system.DelOptionset(ids).then(res => {
-          if (res.code === 200) {
-            this.$refs.qtable.getData()
-            this.$message({
-              message: '删除成功',
-              type: 'success'
-            })
-          } else {
-            this.$message({
-              message: '删除失败',
-              type: 'error'
-            })
-          }
+          this.$refs.qtable.getData()
+          this.$message({
+            message: '删除成功',
+            type: 'success'
+          })
         })
       })
     },

+ 20 - 48
src/views/org/index.vue

@@ -241,18 +241,11 @@ export default {
         if (valid) {
           this.$api.sysOrg.add(this.temp).then(res => {
             this.dialogVisible = false
-            if (res.code === 200) {
-              this.$message({
-                message: 'Created successfully',
-                type: 'success'
-              })
-              this.$refs.qtable.getData()
-            } else {
-              this.$message({
-                message: 'Failed to create',
-                type: 'error'
-              })
-            }
+            this.$message({
+              message: 'Created successfully',
+              type: 'success'
+            })
+            this.$refs.qtable.getData()
           })
         }
       })
@@ -263,18 +256,11 @@ export default {
           const postData = Object.assign({}, this.temp)
           this.$api.sysOrg.update(postData).then(res => {
             this.dialogVisible = false
-            if (res.code === 200) {
-              this.$message({
-                message: 'modify successfully',
-                type: 'success'
-              })
-              this.$refs.qtable.getData()
-            } else {
-              this.$message({
-                message: 'change failed',
-                type: 'error'
-              })
-            }
+            this.$message({
+              message: 'modify successfully',
+              type: 'success'
+            })
+            this.$refs.qtable.getData()
           })
         }
       })
@@ -290,18 +276,11 @@ export default {
         type: 'warning'
       }).then(() => {
         this.$api.sysOrg.del({ id: row.id }).then(res => {
-          if (res.code === 200) {
-            this.$message({
-              message: 'successfully deleted',
-              type: 'success'
-            })
-            this.$refs.qtable.getData()
-          } else {
-            this.$message({
-              message: 'failed to delete',
-              type: 'error'
-            })
-          }
+          this.$message({
+            message: 'successfully deleted',
+            type: 'success'
+          })
+          this.$refs.qtable.getData()
         })
       })
     },
@@ -314,18 +293,11 @@ export default {
         type: 'warning'
       }).then(() => {
         this.$api.sysOrg.batchDel(ids).then(res => {
-          if (res.code === 200) {
-            this.$refs.qtable.getData()
-            this.$message({
-              message: 'successfully deleted',
-              type: 'success'
-            })
-          } else {
-            this.$message({
-              message: 'failed to delete',
-              type: 'error'
-            })
-          }
+          this.$refs.qtable.getData()
+          this.$message({
+            message: 'successfully deleted',
+            type: 'success'
+          })
         })
       })
     },

+ 20 - 46
src/views/role/index.vue

@@ -212,7 +212,6 @@ export default {
       Promise.all([this.$api.sysMenu.tree(), this.$api.sysRole.roleMenuTree({ role_id: role_id })]).then(res => {
         this.fromData = res[0].data
         this.selectMenu = res[1].data
-
         this.selectedArray = []
         this.selectMenu.forEach(item => {
           const subSelectId = this.getEndNodes(item)
@@ -322,22 +321,13 @@ export default {
       this.$refs['dataForm'].validate(valid => {
         if (valid) {
           const postData = Object.assign({}, this.temp)
-          console.log(postData)
           this.$api.system.UpdateRole(postData).then(res => {
-            if (res.code === 200) {
-              this.dialogVisible = false
-              this.$message({
-                message: '修改成功',
-                type: 'success'
-              })
-              this.$refs.qtable.getData()
-            } else {
-              this.dialogVisible = false
-              this.$message({
-                message: '修改失败',
-                type: 'error'
-              })
-            }
+            this.dialogVisible = false
+            this.$message({
+              message: '修改成功',
+              type: 'success'
+            })
+            this.$refs.qtable.getData()
           })
         }
       })
@@ -345,23 +335,15 @@ export default {
     deleteData(row) {
       this.$confirm('确认删除?', '提示', {
         type: 'warning'
-      })
-        .then(() => {
-          this.$api.system.DelRole([{ id: row.id }]).then(res => {
-            if (res.code === 200) {
-              this.$refs.qtable.getData()
-              this.$message({
-                message: '删除成功',
-                type: 'success'
-              })
-            } else {
-              this.$message({
-                message: '删除失败',
-                type: 'error'
-              })
-            }
+      }).then(() => {
+        this.$api.system.DelRole([{ id: row.id }]).then(res => {
+          this.$refs.qtable.getData()
+          this.$message({
+            message: '删除成功',
+            type: 'success'
           })
         })
+      })
         .catch(() => {})
     },
     deleteBatch() {
@@ -371,23 +353,15 @@ export default {
       })
       this.$confirm('确认批量删除选中数据吗?', '提示', {
         type: 'warning'
-      })
-        .then(() => {
-          this.$api.system.DelRole(ids).then(res => {
-            if (res.code === 200) {
-              this.$refs.qtable.getData()
-              this.$message({
-                message: '删除成功',
-                type: 'success'
-              })
-            } else {
-              this.$message({
-                message: '删除失败',
-                type: 'error'
-              })
-            }
+      }).then(() => {
+        this.$api.system.DelRole(ids).then(res => {
+          this.$refs.qtable.getData()
+          this.$message({
+            message: '删除成功',
+            type: 'success'
           })
         })
+      })
         .catch(() => {})
     },
     search() {