瀏覽代碼

add error handle

Michael Wang 6 年之前
父節點
當前提交
112e38a424

+ 31 - 75
src/modules/basic/view/campus.vue

@@ -431,7 +431,7 @@ export default {
         this.pageSize +
         "?" +
         param;
-      this.$http.get(url).then(response => {
+      this.$httpWithMsg.get(url).then(response => {
         this.tableData = response.data.list;
         this.total = response.data.total;
         this.loading = false;
@@ -458,24 +458,13 @@ export default {
           type: "warning"
         }).then(() => {
           var url = CORE_API + "/org/enable/" + this.orgIds;
-          this.$http
-            .put(url)
-            .then(() => {
-              this.$notify({
-                type: "success",
-                message: "启用成功!"
-              });
-              this.searchForm();
-            })
-            .catch(response => {
-              if (response.status == 500) {
-                this.$notify({
-                  showClose: true,
-                  message: response.data.desc,
-                  type: "error"
-                });
-              }
+          this.$httpWithMsg.put(url).then(() => {
+            this.$notify({
+              type: "success",
+              message: "启用成功!"
             });
+            this.searchForm();
+          });
         });
       }
     },
@@ -492,24 +481,13 @@ export default {
           type: "warning"
         }).then(() => {
           var url = CORE_API + "/org/disable/" + this.orgIds;
-          this.$http
-            .put(url, {})
-            .then(() => {
-              this.$notify({
-                type: "success",
-                message: "禁用成功!"
-              });
-              this.searchForm();
-            })
-            .catch(response => {
-              if (response.status == 500) {
-                this.$notify({
-                  showClose: true,
-                  message: response.data.desc,
-                  type: "error"
-                });
-              }
+          this.$httpWithMsg.put(url, {}).then(() => {
+            this.$notify({
+              type: "success",
+              message: "禁用成功!"
             });
+            this.searchForm();
+          });
         });
       }
     },
@@ -530,49 +508,27 @@ export default {
         if (valid) {
           if (null != this.campusForm.id) {
             url = CORE_API + "/org/updateSubOrg";
-            this.$http.put(url, this.campusForm).then(
-              () => {
-                this.$notify({
-                  type: "success",
-                  message: "修改成功!"
-                });
-                this.searchForm();
-                this.resetForm();
-                this.campusDialog = false;
-              },
-              response => {
-                if (response.status == 500) {
-                  this.$notify({
-                    showClose: true,
-                    message: response.data.desc,
-                    type: "error"
-                  });
-                }
-              }
-            );
+            this.$httpWithMsg.put(url, this.campusForm).then(() => {
+              this.$notify({
+                type: "success",
+                message: "修改成功!"
+              });
+              this.searchForm();
+              this.resetForm();
+              this.campusDialog = false;
+            });
           } else {
             //新增
             var url = CORE_API + "/org/addSubOrg";
-            this.$http.post(url, this.campusForm).then(
-              () => {
-                this.$notify({
-                  type: "success",
-                  message: "新增成功!"
-                });
-                this.searchForm();
-                this.resetForm();
-                this.campusDialog = false;
-              },
-              response => {
-                if (response.status == 500) {
-                  this.$notify({
-                    showClose: true,
-                    message: response.data.desc,
-                    type: "error"
-                  });
-                }
-              }
-            );
+            this.$httpWithMsg.post(url, this.campusForm).then(() => {
+              this.$notify({
+                type: "success",
+                message: "新增成功!"
+              });
+              this.searchForm();
+              this.resetForm();
+              this.campusDialog = false;
+            });
           }
         } else {
           console.log("error submit!");

+ 72 - 182
src/modules/basic/view/course.vue

@@ -662,49 +662,27 @@ export default {
         specialtyId: specialtyId
       });
       var url = CORE_API + "/courseSpeciatlyRelation/delete?" + param;
-      this.$http
-        .delete(url)
-        .then(() => {
-          this.$notify({
-            type: "success",
-            message: "取消关联成功!"
-          });
-          this.searchSpecialtyPage();
-        })
-        .catch(response => {
-          if (response.status == 500) {
-            this.$notify({
-              showClose: true,
-              message: response.data.desc,
-              type: "error"
-            });
-          }
+      this.$httpWithMsg.delete(url).then(() => {
+        this.$notify({
+          type: "success",
+          message: "取消关联成功!"
         });
+        this.searchSpecialtyPage();
+      });
     },
     submitAddRelationForm() {
       this.$refs.addRelationForm.validate(valid => {
         if (valid) {
           var param = new URLSearchParams(this.addRelationForm);
           var url = CORE_API + "/courseSpeciatlyRelation/add?" + param;
-          this.$http.post(url, this.speciallyForm).then(
-            () => {
-              this.$notify({
-                type: "success",
-                message: "添加成功!"
-              });
-              this.searchSpecialtyPage();
-              this.addRelationDialog = false;
-            },
-            response => {
-              if (response.status == 500) {
-                this.$notify({
-                  showClose: true,
-                  message: response.data.desc,
-                  type: "error"
-                });
-              }
-            }
-          );
+          this.$httpWithMsg.post(url, this.speciallyForm).then(() => {
+            this.$notify({
+              type: "success",
+              message: "添加成功!"
+            });
+            this.searchSpecialtyPage();
+            this.addRelationDialog = false;
+          });
         } else {
           console.log("error submit!");
           return false;
@@ -713,7 +691,7 @@ export default {
     },
     getSpecialtyList4AddRelation(query) {
       this.specialtyLoading4AddRelation = true;
-      this.$http
+      this.$httpWithMsg
         .get(CORE_API + "/specialty/query?name=" + query)
         .then(response => {
           this.specialtyList4AddRelation = response.data;
@@ -742,7 +720,7 @@ export default {
         this.pageSize +
         "?" +
         param;
-      this.$http.get(url).then(response => {
+      this.$httpWithMsg.get(url).then(response => {
         this.specialtyTableData = response.data.content;
         this.specialtyTotal = response.data.totalElements;
       });
@@ -768,7 +746,7 @@ export default {
     },
     getSpecialtyList4Search(query) {
       this.specialtyLoading4Search = true;
-      this.$http
+      this.$httpWithMsg
         .get(CORE_API + "/specialty/query?name=" + query)
         .then(response => {
           this.specialtyList4Search = response.data;
@@ -789,7 +767,7 @@ export default {
         this.pageSize +
         "?" +
         param;
-      this.$http.get(url).then(response => {
+      this.$httpWithMsg.get(url).then(response => {
         this.tableData = response.data.content;
         this.total = response.data.totalElements;
       });
@@ -862,26 +840,15 @@ export default {
         //修改
         this.$refs.courseForm.validate(valid => {
           if (valid) {
-            this.$http.put(url, this.courseForm).then(
-              () => {
-                this.$notify({
-                  type: "success",
-                  message: "修改成功!"
-                });
-                this.searchForm();
-                this.resetForm();
-                this.courseDialog = false;
-              },
-              response => {
-                if (response.status == 500) {
-                  this.$notify({
-                    showClose: true,
-                    message: response.data.desc,
-                    type: "error"
-                  });
-                }
-              }
-            );
+            this.$httpWithMsg.put(url, this.courseForm).then(() => {
+              this.$notify({
+                type: "success",
+                message: "修改成功!"
+              });
+              this.searchForm();
+              this.resetForm();
+              this.courseDialog = false;
+            });
           } else {
             console.log("error submit!");
             return false;
@@ -890,26 +857,15 @@ export default {
       } else {
         this.$refs.courseForm.validate(valid => {
           if (valid) {
-            this.$http.post(url, this.courseForm).then(
-              () => {
-                this.$notify({
-                  type: "success",
-                  message: "添加成功"
-                });
-                this.searchForm();
-                this.resetForm();
-                this.courseDialog = false;
-              },
-              response => {
-                if (response.status == 500) {
-                  this.$notify({
-                    showClose: true,
-                    message: response.data.desc,
-                    type: "error"
-                  });
-                }
-              }
-            );
+            this.$httpWithMsg.post(url, this.courseForm).then(() => {
+              this.$notify({
+                type: "success",
+                message: "添加成功"
+              });
+              this.searchForm();
+              this.resetForm();
+              this.courseDialog = false;
+            });
           } else {
             console.log("error submit!");
             return false;
@@ -939,24 +895,13 @@ export default {
         type: "warning"
       }).then(() => {
         var url = CORE_API + "/course/" + row.id;
-        this.$http
-          .delete(url)
-          .then(() => {
-            this.$notify({
-              type: "success",
-              message: "删除成功!"
-            });
-            this.searchForm();
-          })
-          .catch(response => {
-            if (response.status == 500) {
-              this.$notify({
-                showClose: true,
-                message: response.data.desc,
-                type: "error"
-              });
-            }
+        this.$httpWithMsg.delete(url).then(() => {
+          this.$notify({
+            type: "success",
+            message: "删除成功!"
           });
+          this.searchForm();
+        });
       });
     },
     //删除多条数据
@@ -973,24 +918,13 @@ export default {
           type: "error"
         }).then(() => {
           var url = CORE_API + "/course/" + this.courseIds;
-          this.$http
-            .delete(url)
-            .then(() => {
-              this.$notify({
-                type: "success",
-                message: "删除成功!"
-              });
-              this.searchForm();
-            })
-            .catch(response => {
-              if (response.status == 500) {
-                this.$notify({
-                  showClose: true,
-                  message: response.data.desc,
-                  type: "error"
-                });
-              }
+          this.$httpWithMsg.delete(url).then(() => {
+            this.$notify({
+              type: "success",
+              message: "删除成功!"
             });
+            this.searchForm();
+          });
         });
       }
     },
@@ -1008,24 +942,13 @@ export default {
           type: "warning"
         }).then(() => {
           var url = CORE_API + "/course/enable/" + this.courseIds;
-          this.$http
-            .put(url, {})
-            .then(() => {
-              this.$notify({
-                type: "success",
-                message: "开启成功!"
-              });
-              this.searchForm();
-            })
-            .catch(response => {
-              if (response.status == 500) {
-                this.$notify({
-                  showClose: true,
-                  message: response.data.desc,
-                  type: "error"
-                });
-              }
+          this.$httpWithMsg.put(url, {}).then(() => {
+            this.$notify({
+              type: "success",
+              message: "开启成功!"
             });
+            this.searchForm();
+          });
         });
       }
     },
@@ -1036,24 +959,13 @@ export default {
         type: "warning"
       }).then(() => {
         var url = CORE_API + "/course/enable/" + row.id;
-        this.$http
-          .put(url, {})
-          .then(() => {
-            this.$notify({
-              type: "success",
-              message: "开启成功!"
-            });
-            this.searchForm();
-          })
-          .catch(response => {
-            if (response.status == 500) {
-              this.$notify({
-                showClose: true,
-                message: response.data.desc,
-                type: "error"
-              });
-            }
+        this.$httpWithMsg.put(url, {}).then(() => {
+          this.$notify({
+            type: "success",
+            message: "开启成功!"
           });
+          this.searchForm();
+        });
       });
     },
     //禁用
@@ -1070,24 +982,13 @@ export default {
           type: "error"
         }).then(() => {
           var url = CORE_API + "/course/disable/" + this.courseIds;
-          this.$http
-            .put(url, {})
-            .then(() => {
-              this.$notify({
-                type: "success",
-                message: "禁用成功!"
-              });
-              this.searchForm();
-            })
-            .catch(response => {
-              if (response.status == 500) {
-                this.$notify({
-                  showClose: true,
-                  message: response.data.desc,
-                  type: "error"
-                });
-              }
+          this.$httpWithMsg.put(url, {}).then(() => {
+            this.$notify({
+              type: "success",
+              message: "禁用成功!"
             });
+            this.searchForm();
+          });
         });
       }
     },
@@ -1099,24 +1000,13 @@ export default {
         type: "error"
       }).then(() => {
         var url = CORE_API + "/course/disable/" + row.id;
-        this.$http
-          .put(url, {})
-          .then(() => {
-            this.$notify({
-              type: "success",
-              message: "禁用成功!"
-            });
-            this.searchForm();
-          })
-          .catch(response => {
-            if (response.status == 500) {
-              this.$notify({
-                showClose: true,
-                message: response.data.desc,
-                type: "error"
-              });
-            }
+        return this.$httpWithMsg.put(url, {}).then(() => {
+          this.$notify({
+            type: "success",
+            message: "禁用成功!"
           });
+          return this.searchForm();
+        });
       });
     },
     //导入

+ 35 - 90
src/modules/basic/view/exam_site.vue

@@ -297,7 +297,7 @@ export default {
         this.pageSize +
         "?" +
         param;
-      this.$http.get(url).then(response => {
+      this.$httpWithMsg.get(url).then(response => {
         this.tableData = response.data.content;
         this.total = response.data.totalElements;
         this.loading = false;
@@ -320,47 +320,25 @@ export default {
         if (valid) {
           var url = CORE_API + "/examSite";
           if (this.examSiteForm.id) {
-            this.$http.put(url, this.examSiteForm).then(
-              () => {
-                this.$notify({
-                  type: "success",
-                  message: "修改成功!"
-                });
-                this.searchForm();
-                this.resetForm();
-                this.examSiteDialog = false;
-              },
-              response => {
-                if (response.status == 500) {
-                  this.$notify({
-                    showClose: true,
-                    message: response.data.desc,
-                    type: "error"
-                  });
-                }
-              }
-            );
+            this.$httpWithMsg.put(url, this.examSiteForm).then(() => {
+              this.$notify({
+                type: "success",
+                message: "修改成功!"
+              });
+              this.searchForm();
+              this.resetForm();
+              this.examSiteDialog = false;
+            });
           } else {
-            this.$http.post(url, this.examSiteForm).then(
-              () => {
-                this.$notify({
-                  type: "success",
-                  message: "新增成功!"
-                });
-                this.searchForm();
-                this.resetForm();
-                this.examSiteDialog = false;
-              },
-              response => {
-                if (response.status == 500) {
-                  this.$notify({
-                    showClose: true,
-                    message: response.data.desc,
-                    type: "error"
-                  });
-                }
-              }
-            );
+            this.$httpWithMsg.post(url, this.examSiteForm).then(() => {
+              this.$notify({
+                type: "success",
+                message: "新增成功!"
+              });
+              this.searchForm();
+              this.resetForm();
+              this.examSiteDialog = false;
+            });
           }
         } else {
           console.log("error submit!");
@@ -403,24 +381,13 @@ export default {
         type: "warning"
       }).then(() => {
         var url = CORE_API + "/examSite/" + row.id;
-        this.$http
-          .delete(url)
-          .then(() => {
-            this.$notify({
-              type: "success",
-              message: "删除成功!"
-            });
-            this.searchForm();
-          })
-          .catch(response => {
-            if (response.status == 500) {
-              this.$notify({
-                showClose: true,
-                message: response.data.desc,
-                type: "error"
-              });
-            }
+        this.$httpWithMsg.delete(url).then(() => {
+          this.$notify({
+            type: "success",
+            message: "删除成功!"
           });
+          this.searchForm();
+        });
       });
     },
     //删除多条数据
@@ -437,44 +404,22 @@ export default {
           type: "error"
         }).then(() => {
           var url = CORE_API + "/examSite/" + this.examSiteIds;
-          this.$http
-            .delete(url)
-            .then(() => {
-              this.$notify({
-                type: "success",
-                message: "删除成功!"
-              });
-              this.searchForm();
-            })
-            .catch(response => {
-              if (response.status == 500) {
-                this.$notify({
-                  showClose: true,
-                  message: response.data.desc,
-                  type: "error"
-                });
-              }
+          this.$httpWithMsg.delete(url).then(() => {
+            this.$notify({
+              type: "success",
+              message: "删除成功!"
             });
+            this.searchForm();
+          });
         });
       }
     },
     init() {
       var url = CORE_API + "/org/subOrg/" + this.orgId;
-      this.$http
-        .get(url)
-        .then(response => {
-          this.orgName = response.data.name;
-          this.searchForm();
-        })
-        .catch(response => {
-          if (response.status == 500) {
-            this.$notify({
-              showClose: true,
-              message: response.data.desc,
-              type: "error"
-            });
-          }
-        });
+      this.$httpWithMsg.get(url).then(response => {
+        this.orgName = response.data.name;
+        this.searchForm();
+      });
     }
   },
   created() {

+ 1 - 10
src/modules/basic/view/index.vue

@@ -121,7 +121,7 @@ export default {
   },
   created() {
     var url = CORE_API + "/rolePrivilege/getUserPrivileges";
-    this.$http
+    this.$httpWithMsg
       .post(
         url,
         {
@@ -132,15 +132,6 @@ export default {
       )
       .then(response => {
         this.menuList = response.data;
-      })
-      .catch(response => {
-        if (response.status == 500) {
-          this.$notify({
-            showClose: true,
-            message: response.data.desc,
-            type: "error"
-          });
-        }
       });
   }
 };

+ 1 - 1
src/modules/basic/view/privilege_group_list.vue

@@ -41,7 +41,7 @@ export default {
   methods: {
     async queryAppList() {
       var url = CORE_API + "/rolePrivilege/getPrivilegeGroupList";
-      const response = await this.$http.get(url);
+      const response = await this.$httpWithMsg.get(url);
       this.privilegeGroupList = response.data;
     },
     editPrivilege(row) {

+ 6 - 39
src/modules/basic/view/privilege_tree.vue

@@ -388,7 +388,7 @@ export default {
                     return;
                 }
                 var url = CORE_API + '/rolePrivilege/addPrivilege';
-                this.$http.post(url, this.addingDialog.privilege).then((response) => {
+                this.$httpWithMsg.post(url, this.addingDialog.privilege).then((response) => {
                     this.$notify({
                         message: '添加成功',
                         type: 'success'
@@ -399,15 +399,7 @@ export default {
                         label: this.addingDialog.privilege.name,
                         children: []
                     }, this.data);
-                }).catch((response) => {
-                    if (response.status == 500) {
-                        this.$notify({
-                            showClose: true,
-                            message: response.data.desc,
-                            type: 'error'
-                        });
-                    }
-                });
+                })
                 this.addingDialog.show = false;
             });
         },
@@ -416,23 +408,14 @@ export default {
                 if (!valid) {
                     return;
                 }
-                console.log(this.updateDialog.privilege);
                 var url = CORE_API + '/rolePrivilege/updatePrivilege';
-                this.$http.put(url, this.updateDialog.privilege).then(() => {
+                this.$httpWithMsg.put(url, this.updateDialog.privilege).then(() => {
                     this.$notify({
                         message: '修改成功',
                         type: 'success'
                     });
                     this.data.label = this.updateDialog.privilege.name;
-                }).catch((response) => {
-                    if (response.status == 500) {
-                        this.$notify({
-                            showClose: true,
-                            message: response.data.desc,
-                            type: 'error'
-                        });
-                    }
-                });
+                })
                 this.updateDialog.show = false;
             });
         },
@@ -451,7 +434,7 @@ export default {
         },
         getPrivilege(id, type) {
             var url = CORE_API + '/rolePrivilege/getPrivilege/' + id;
-            this.$http.get(url).then((response) => {
+            this.$httpWithMsg.get(url).then((response) => {
                 var resp = response.data;
 
                 this.updateDialog.privilege.id = resp.id;
@@ -486,14 +469,6 @@ export default {
                 else if ("for-show" == type) {
                     this.showDialog.show = true;
                 }
-            }).catch((response) => {
-                if (response.status == 500) {
-                    this.$notify({
-                        showClose: true,
-                        message: response.data.desc,
-                        type: 'error'
-                    });
-                }
             });
         },
 
@@ -504,20 +479,12 @@ export default {
                 type: 'warning'
             }).then(() => {
                 var url = CORE_API + '/rolePrivilege/deletePrivilege/' + data.id;
-                this.$http.delete(url).then(() => {
+                return this.$httpWithMsg.delete(url).then(() => {
                     this.$notify({
                         message: '删除成功',
                         type: 'success'
                     });
                     store.remove(data);
-                }).catch((response) => {
-                    if (response.status == 500) {
-                        this.$notify({
-                            showClose: true,
-                            message: response.data.desc,
-                            type: 'error'
-                        });
-                    }
                 });
             }).catch(() => {
                 this.$message({

+ 17 - 36
src/modules/basic/view/role_privilege_settings.vue

@@ -159,15 +159,16 @@ export default {
       var url2 =
         CORE_API + "/rolePrivilege/getPrivilegeIdList/" + orgId + "/" + roleId;
 
-      Promise.all([this.$http.get(url1), this.$http.get(url2)]).then(
-        ([resp1, resp2]) => {
-          console.log("initTree(). treeData:", resp1.data.children);
-          console.log("initTree(). checkedKeys:", resp2.data);
-          this.treeData = resp1.data.children;
-          this.checkedKeys = resp2.data;
-          this.completed = true;
-        }
-      );
+      Promise.all([
+        this.$httpWithMsg.get(url1),
+        this.$httpWithMsg.get(url2)
+      ]).then(([resp1, resp2]) => {
+        console.log("initTree(). treeData:", resp1.data.children);
+        console.log("initTree(). checkedKeys:", resp2.data);
+        this.treeData = resp1.data.children;
+        this.checkedKeys = resp2.data;
+        this.completed = true;
+      });
     },
     /*change事件*/
     change() {
@@ -190,23 +191,12 @@ export default {
         CORE_API +
         "/rolePrivilege/getRoles?includeSuperAdmin=false&rootOrgId=" +
         this.form.orgId;
-      this.$http
-        .post(url)
-        .then(response => {
-          this.roleList = response.data;
-          if (0 < this.roleList.length) {
-            this.form.roleId = this.roleList[0].roleId;
-          }
-        })
-        .catch(response => {
-          if (response.status == 500) {
-            this.$notify({
-              showClose: true,
-              message: response.data.desc,
-              type: "error"
-            });
-          }
-        });
+      this.$httpWithMsg.post(url).then(response => {
+        this.roleList = response.data;
+        if (0 < this.roleList.length) {
+          this.form.roleId = this.roleList[0].roleId;
+        }
+      });
 
       this.initTree(
         this.form.orgId,
@@ -250,7 +240,7 @@ export default {
     save() {
       console.log("save(). checkedKeys:", this.checkedKeys);
       var url = CORE_API + "/rolePrivilege/updateRolePrivilegeRelations";
-      this.$http
+      this.$httpWithMsg
         .post(url, {
           rootOrgId: this.form.orgId,
           roleId: this.form.roleId,
@@ -263,15 +253,6 @@ export default {
             type: "success"
           });
           this.treeChanged = false;
-        })
-        .catch(response => {
-          if (response.status == 500) {
-            this.$notify({
-              showClose: true,
-              message: response.data.desc,
-              type: "error"
-            });
-          }
         });
     }
   },

+ 36 - 88
src/modules/basic/view/school.vue

@@ -443,7 +443,7 @@ export default {
         this.pageSize +
         "?" +
         param;
-      this.$http.get(url).then(response => {
+      this.$httpWithMsg.get(url).then(response => {
         this.tableData = response.data.list;
         this.total = response.data.total;
         this.loading = false;
@@ -463,24 +463,13 @@ export default {
           type: "warning"
         }).then(() => {
           var url = CORE_API + "/org/enable/" + this.orgIds;
-          this.$http
-            .put(url)
-            .then(() => {
-              this.$notify({
-                type: "success",
-                message: "启用成功!"
-              });
-              this.searchForm();
-            })
-            .catch(response => {
-              if (response.status == 500) {
-                this.$notify({
-                  showClose: true,
-                  message: response.data.desc,
-                  type: "error"
-                });
-              }
+          this.$httpWithMsg.put(url).then(() => {
+            this.$notify({
+              type: "success",
+              message: "启用成功!"
             });
+            this.searchForm();
+          });
         });
       }
     },
@@ -497,24 +486,13 @@ export default {
           type: "warning"
         }).then(() => {
           var url = CORE_API + "/org/disable/" + this.orgIds;
-          this.$http
-            .put(url, {})
-            .then(() => {
-              this.$notify({
-                type: "success",
-                message: "禁用成功!"
-              });
-              this.searchForm();
-            })
-            .catch(response => {
-              if (response.status == 500) {
-                this.$notify({
-                  showClose: true,
-                  message: response.data.desc,
-                  type: "error"
-                });
-              }
+          this.$$httpWithMsg.put(url, {}).then(() => {
+            this.$notify({
+              type: "success",
+              message: "禁用成功!"
             });
+            this.searchForm();
+          });
         });
       }
     },
@@ -536,47 +514,25 @@ export default {
           if (null != this.schoolForm.id) {
             //修改
             url = CORE_API + "/org/updateRootOrg";
-            this.$http.put(url, this.schoolForm).then(
-              () => {
-                this.$notify({
-                  type: "success",
-                  message: "修改成功!"
-                });
-                this.searchForm();
-                this.schoolDialog = false;
-              },
-              response => {
-                if (response.status == 500) {
-                  this.$notify({
-                    showClose: true,
-                    message: response.data.desc,
-                    type: "error"
-                  });
-                }
-              }
-            );
+            this.$httpWithMsg.put(url, this.schoolForm).then(() => {
+              this.$notify({
+                type: "success",
+                message: "修改成功!"
+              });
+              this.searchForm();
+              this.schoolDialog = false;
+            });
           } else {
             //新增
             var url = CORE_API + "/org/addRootOrg";
-            this.$http.post(url, this.schoolForm).then(
-              () => {
-                this.$notify({
-                  type: "success",
-                  message: "新增成功!"
-                });
-                this.searchForm();
-                this.schoolDialog = false;
-              },
-              response => {
-                if (response.status == 500) {
-                  this.$notify({
-                    showClose: true,
-                    message: response.data.desc,
-                    type: "error"
-                  });
-                }
-              }
-            );
+            this.$httpWithMsg.post(url, this.schoolForm).then(() => {
+              this.$notify({
+                type: "success",
+                message: "新增成功!"
+              });
+              this.searchForm();
+              this.schoolDialog = false;
+            });
           }
         } else {
           console.log("error submit!");
@@ -609,21 +565,13 @@ export default {
       this.schoolForm.enable = row.enable ? "true" : "false";
 
       var url = CORE_API + "/org/allProperties/" + row.id;
-      this.$http.get(url).then(
-        response => {
-          this.schoolForm.properties = Object.assign(
-            this.schoolForm.properties,
-            response.data
-          );
-          this.schoolDialog = true;
-        },
-        response => {
-          this.$notify({
-            type: "error",
-            message: response.data.desc
-          });
-        }
-      );
+      this.$httpWithMsg.get(url).then(response => {
+        this.schoolForm.properties = Object.assign(
+          this.schoolForm.properties,
+          response.data
+        );
+        this.schoolDialog = true;
+      });
     },
     //设置产品
     saveOrgFunction() {},

+ 35 - 102
src/modules/basic/view/specially.vue

@@ -502,31 +502,20 @@ export default {
         specialtyId: specialtyId
       });
       var url = CORE_API + "/courseSpeciatlyRelation/delete?" + param;
-      this.$http
-        .delete(url)
-        .then(() => {
-          this.$notify({
-            type: "success",
-            message: "取消关联成功!"
-          });
-          this.searchCoursePage();
-        })
-        .catch(response => {
-          if (response.status == 500) {
-            this.$notify({
-              showClose: true,
-              message: response.data.desc,
-              type: "error"
-            });
-          }
+      this.$httpWithMsg.delete(url).then(() => {
+        this.$notify({
+          type: "success",
+          message: "取消关联成功!"
         });
+        return this.searchCoursePage();
+      });
     },
     submitAddRelationForm() {
       this.$refs.addRelationForm.validate(valid => {
         if (valid) {
           var param = new URLSearchParams(this.addRelationForm);
           var url = CORE_API + "/courseSpeciatlyRelation/add?" + param;
-          this.$http.post(url, this.speciallyForm).then(
+          this.$httpWithMsg.post(url, this.speciallyForm).then(
             () => {
               this.$notify({
                 type: "success",
@@ -535,16 +524,7 @@ export default {
               this.searchCoursePage();
               this.addRelationDialog = false;
             },
-            response => {
-              if (response.status == 500) {
-                this.$notify({
-                  showClose: true,
-                  message: response.data.desc,
-                  type: "error"
-                });
-              }
-              this.addRelationDialog = false;
-            }
+            () => (this.addRelationDialog = false)
           );
         } else {
           console.log("error submit!");
@@ -568,7 +548,7 @@ export default {
         this.pageSize +
         "?" +
         param;
-      this.$http.get(url).then(response => {
+      this.$httpWithMsg.get(url).then(response => {
         console.log(response);
         this.courseTableData = response.data.content;
         this.courseTotal = response.data.totalElements;
@@ -576,7 +556,7 @@ export default {
     },
     getCourses(query) {
       this.courseLoading = true;
-      this.$http
+      this.$httpWithMsg
         .get(CORE_API + "/course/query?name=" + query)
         .then(response => {
           this.courseList4Search = response.data;
@@ -585,7 +565,7 @@ export default {
     },
     getCourses4AddRelation(query) {
       this.courseLoading4AddRelation = true;
-      this.$http
+      this.$httpWithMsg
         .get(CORE_API + "/course/query?name=" + query)
         .then(response => {
           this.courseList4AddRelation = response.data;
@@ -607,22 +587,11 @@ export default {
         this.pageSize +
         "?" +
         param;
-      this.$http
-        .get(url)
-        .then(response => {
-          console.log("response :", response);
-          this.tableData = response.data.content;
-          this.total = response.data.totalElements;
-        })
-        .catch(response => {
-          if (response.status == 500) {
-            this.$notify({
-              showClose: true,
-              message: response.data.desc,
-              type: "error"
-            });
-          }
-        });
+      this.$httpWithMsg.get(url).then(response => {
+        console.log("response :", response);
+        this.tableData = response.data.content;
+        this.total = response.data.totalElements;
+      });
     },
     handleCurrentChange(val) {
       this.currentPage = val;
@@ -647,7 +616,7 @@ export default {
         this.loading = true;
         var vm = this;
         var url = CORE_API;
-        vm.$http.delete(url).then(() => {
+        vm.$httpWithMsg.delete(url).then(() => {
           this.loading = false;
           this.$notify({
             type: "success",
@@ -664,7 +633,7 @@ export default {
           var url = CORE_API + "/specialty";
           //修改
           if (null != this.speciallyForm.id) {
-            this.$http.put(url, this.speciallyForm).then(
+            this.$httpWithMsg.put(url, this.speciallyForm).then(
               () => {
                 this.$notify({
                   type: "success",
@@ -673,14 +642,7 @@ export default {
                 this.searchForm();
                 this.speciallyDialog = false;
               },
-              response => {
-                if (response.status == 500) {
-                  this.$notify({
-                    showClose: true,
-                    message: response.data.desc,
-                    type: "error"
-                  });
-                }
+              () => {
                 this.searchForm();
                 this.speciallyDialog = false;
               }
@@ -688,7 +650,7 @@ export default {
           }
           //新增
           else {
-            this.$http.post(url, this.speciallyForm).then(
+            this.$httpWithMsg.post(url, this.speciallyForm).then(
               () => {
                 this.$notify({
                   type: "success",
@@ -697,16 +659,9 @@ export default {
                 this.speciallyDialog = false;
                 this.searchForm();
               },
-              response => {
-                if (response.status == 500) {
-                  this.$notify({
-                    showClose: true,
-                    message: response.data.desc,
-                    type: "error"
-                  });
-                }
+              () => {
                 this.speciallyDialog = false;
-                this.searchForm();
+                return this.searchForm();
               }
             );
           }
@@ -746,24 +701,13 @@ export default {
         type: "error"
       }).then(() => {
         var url = CORE_API + "/specialty/" + row.id;
-        this.$http
-          .delete(url)
-          .then(() => {
-            this.$notify({
-              type: "success",
-              message: "删除成功!"
-            });
-            this.searchForm();
-          })
-          .catch(response => {
-            if (response.status == 500) {
-              this.$notify({
-                showClose: true,
-                message: response.data.desc,
-                type: "error"
-              });
-            }
+        this.$httpWithMsg.delete(url).then(() => {
+          this.$notify({
+            type: "success",
+            message: "删除成功!"
           });
+          this.searchForm();
+        });
       });
     },
     //删除多条信息
@@ -784,24 +728,13 @@ export default {
             ids.push(this.multipleSelection[i].id);
           }
           var url = CORE_API + "/specialty/" + ids;
-          this.$http
-            .delete(url)
-            .then(() => {
-              this.$notify({
-                type: "success",
-                message: "删除成功!"
-              });
-              this.searchForm();
-            })
-            .catch(response => {
-              if (response.status == 500) {
-                this.$notify({
-                  showClose: true,
-                  message: response.data.desc,
-                  type: "error"
-                });
-              }
+          this.$httpWithMsg.delete(url).then(() => {
+            this.$notify({
+              type: "success",
+              message: "删除成功!"
             });
+            this.searchForm();
+          });
         });
       }
     },
@@ -826,7 +759,7 @@ export default {
     saveCourse() {
       //debugger;
       var url = CORE_API + "/CourseSpeciatly/addCourse/" + this.speciatlyId;
-      this.$http.post(url, this.courseList).then(
+      this.$httpWithMsg.post(url, this.courseList).then(
         () => {
           this.$notify({
             type: "success",

+ 68 - 190
src/modules/basic/view/user.vue

@@ -630,20 +630,9 @@ export default {
         true +
         "&rootOrgId=" +
         this.searchForm.rootOrgId;
-      this.$http
-        .post(url)
-        .then(response => {
-          this.roleList4Search = response.data;
-        })
-        .catch(response => {
-          if (response.status == 500) {
-            this.$notify({
-              showClose: true,
-              message: response.data.desc,
-              type: "error"
-            });
-          }
-        });
+      this.$httpWithMsg.post(url).then(response => {
+        this.roleList4Search = response.data;
+      });
     },
     rootOrgChanged4InsertOrUpdate() {
       this.orgList4InsertOrUpdate = [];
@@ -654,21 +643,10 @@ export default {
         true +
         "&rootOrgId=" +
         this.userForm.rootOrgId;
-      this.$http
-        .post(url)
-        .then(response => {
-          this.roleList4InsertOrUpdate = response.data;
-          this.rolesChanged();
-        })
-        .catch(response => {
-          if (response.status == 500) {
-            this.$notify({
-              showClose: true,
-              message: response.data.desc,
-              type: "error"
-            });
-          }
-        });
+      this.$httpWithMsg.post(url).then(response => {
+        this.roleList4InsertOrUpdate = response.data;
+        this.rolesChanged();
+      });
     },
     getOrgList4InsertOrUpdate(query) {
       this.orgLoading4InsertOrUpdate = true;
@@ -679,20 +657,13 @@ export default {
           name: query,
           rootOrgId: this.userForm.rootOrgId
         });
-      this.$http
+      this.$httpWithMsg
         .get(url)
         .then(response => {
           this.orgList4InsertOrUpdate = response.data;
           this.orgLoading4InsertOrUpdate = false;
         })
-        .catch(response => {
-          if (response.status == 500) {
-            this.$notify({
-              showClose: true,
-              message: response.data.desc,
-              type: "error"
-            });
-          }
+        .catch(() => {
           this.orgLoading4InsertOrUpdate = false;
         });
     },
@@ -727,7 +698,7 @@ export default {
         this.pageSize +
         "?" +
         param;
-      this.$http.get(url).then(response => {
+      this.$httpWithMsg.get(url).then(response => {
         console.log(response);
         this.tableData = response.data.list;
         this.total = response.data.total;
@@ -804,22 +775,14 @@ export default {
       this.$refs.addingForm.validate(valid => {
         if (valid) {
           this.userForm.enable = this.enableStr == "true";
-          this.$http.post(url, this.userForm).then(
-            () => {
-              this.$notify({
-                type: "success",
-                message: "添加成功"
-              });
-              this.search();
-              this.addingDialog = false;
-            },
-            resp => {
-              this.$notify({
-                type: "error",
-                message: resp.body.desc
-              });
-            }
-          );
+          this.$httpWithMsg.post(url, this.userForm).then(() => {
+            this.$notify({
+              type: "success",
+              message: "添加成功"
+            });
+            this.search();
+            this.addingDialog = false;
+          });
         } else {
           return false;
         }
@@ -831,22 +794,14 @@ export default {
       this.$refs.updateForm.validate(valid => {
         if (valid) {
           this.userForm.enable = this.enableStr == "true";
-          this.$http.put(url, this.userForm).then(
-            () => {
-              this.$notify({
-                type: "success",
-                message: "添加成功"
-              });
-              this.search();
-              this.updateDialog = false;
-            },
-            resp => {
-              this.$notify({
-                type: "error",
-                message: resp.body.desc
-              });
-            }
-          );
+          this.$httpWithMsg.put(url, this.userForm).then(() => {
+            this.$notify({
+              type: "success",
+              message: "添加成功"
+            });
+            this.search();
+            this.updateDialog = false;
+          });
         } else {
           return false;
         }
@@ -861,24 +816,13 @@ export default {
       })
         .then(() => {
           var url = CORE_API + "/user/resetPass/" + row.id;
-          this.$http
-            .put(url)
-            .then(() => {
-              this.$notify({
-                type: "success",
-                message: "重置成功!"
-              });
-              this.search();
-            })
-            .catch(response => {
-              if (response.status == 500) {
-                this.$notify({
-                  showClose: true,
-                  message: response.data.desc,
-                  type: "error"
-                });
-              }
+          this.$httpWithMsg.put(url).then(() => {
+            this.$notify({
+              type: "success",
+              message: "重置成功!"
             });
+            return this.search();
+          });
         })
         .catch(e => console.log(e));
     },
@@ -890,24 +834,13 @@ export default {
         type: "warning"
       }).then(() => {
         var url = CORE_API + "/user/" + row.id;
-        this.$http
-          .delete(url)
-          .then(() => {
-            this.$notify({
-              type: "success",
-              message: "删除成功!"
-            });
-            this.search();
-          })
-          .catch(response => {
-            if (response.status == 500) {
-              this.$notify({
-                showClose: true,
-                message: response.data.desc,
-                type: "error"
-              });
-            }
+        this.$httpWithMsg.delete(url).then(() => {
+          this.$notify({
+            type: "success",
+            message: "删除成功!"
           });
+          return this.search();
+        });
       });
     },
     //删除多条数据
@@ -924,24 +857,13 @@ export default {
           type: "error"
         }).then(() => {
           var url = CORE_API + "/user/" + this.userIds;
-          this.$http
-            .delete(url)
-            .then(() => {
-              this.$notify({
-                type: "success",
-                message: "删除成功!"
-              });
-              this.search();
-            })
-            .catch(response => {
-              if (response.status == 500) {
-                this.$notify({
-                  showClose: true,
-                  message: response.data.desc,
-                  type: "error"
-                });
-              }
+          this.$httpWithMsg.delete(url).then(() => {
+            this.$notify({
+              type: "success",
+              message: "删除成功!"
             });
+            this.search();
+          });
         });
       }
     },
@@ -959,24 +881,13 @@ export default {
           type: "warning"
         }).then(() => {
           var url = CORE_API + "/user/enable/" + this.userIds;
-          this.$http
-            .put(url, {})
-            .then(() => {
-              this.$notify({
-                type: "success",
-                message: "开启成功!"
-              });
-              this.search();
-            })
-            .catch(response => {
-              if (response.status == 500) {
-                this.$notify({
-                  showClose: true,
-                  message: response.data.desc,
-                  type: "error"
-                });
-              }
+          this.$httpWithMsg.put(url, {}).then(() => {
+            this.$notify({
+              type: "success",
+              message: "开启成功!"
             });
+            return this.search();
+          });
         });
       }
     },
@@ -987,24 +898,13 @@ export default {
         type: "warning"
       }).then(() => {
         var url = CORE_API + "/user/enable/" + row.id;
-        this.$http
-          .put(url, {})
-          .then(() => {
-            this.$notify({
-              type: "success",
-              message: "开启成功!"
-            });
-            this.search();
-          })
-          .catch(response => {
-            if (response.status == 500) {
-              this.$notify({
-                showClose: true,
-                message: response.data.desc,
-                type: "error"
-              });
-            }
+        this.$httpWithMsg.put(url, {}).then(() => {
+          this.$notify({
+            type: "success",
+            message: "开启成功!"
           });
+          this.search();
+        });
       });
     },
     //禁用
@@ -1021,24 +921,13 @@ export default {
           type: "error"
         }).then(() => {
           var url = CORE_API + "/user/disable/" + this.userIds;
-          this.$http
-            .put(url, {})
-            .then(() => {
-              this.$notify({
-                type: "success",
-                message: "禁用成功!"
-              });
-              this.search();
-            })
-            .catch(response => {
-              if (response.status == 500) {
-                this.$notify({
-                  showClose: true,
-                  message: response.data.desc,
-                  type: "error"
-                });
-              }
+          this.$httpWithMsg.put(url, {}).then(() => {
+            this.$notify({
+              type: "success",
+              message: "禁用成功!"
             });
+            this.search();
+          });
         });
       }
     },
@@ -1050,24 +939,13 @@ export default {
         type: "error"
       }).then(() => {
         var url = CORE_API + "/user/disable/" + row.id;
-        this.$http
-          .put(url, {})
-          .then(() => {
-            this.$notify({
-              type: "success",
-              message: "禁用成功!"
-            });
-            this.search();
-          })
-          .catch(response => {
-            if (response.status == 500) {
-              this.$notify({
-                showClose: true,
-                message: response.data.desc,
-                type: "error"
-              });
-            }
+        this.$httpWithMsg.put(url, {}).then(() => {
+          this.$notify({
+            type: "success",
+            message: "禁用成功!"
           });
+          this.search();
+        });
       });
     },
 

+ 2 - 2
src/modules/portal/views/home/Home.vue

@@ -2,10 +2,10 @@
   <el-container>
     <el-header style="padding: 0;">
       <el-menu class="el-menu" mode="horizontal">
-        <el-menu-item index="1" style=" width: 200px;">
+        <el-menu-item index="1" style="width: 200px;">
           <router-link
             to="/home/overview"
-            style="font-size: 20px; line-height: 24px; width: 100%; text-decoration-line: none"
+            style="display: inline-block; font-size: 20px; line-height: 48px; width: 100%; text-decoration-line: none"
             title="回到主页"
           >
             云平台主页

+ 24 - 11
src/plugins/axios.js

@@ -2,6 +2,8 @@ import Vue from "vue";
 import axios from "axios";
 import router from "../router";
 
+const ERROR_MSG_CONFIG = require("./errorMsgConfig").default;
+
 // Full config:  https://github.com/axios/axios#request-config
 // axios.defaults.baseURL = process.env.baseURL || process.env.apiUrl || '';
 // axios.defaults.headers.common['Authorization'] = AUTH_TOKEN;
@@ -145,18 +147,29 @@ _axios.interceptors.response.use(
 
     if (status != 200) {
       const data = error.response.data;
-      if (data && data.desc) {
-        Vue.prototype.$notify({
-          showClose: true,
-          message: data.desc,
-          type: "error"
-        });
+      if (ERROR_MSG_CONFIG.map(v => v.code).includes(data.code)) {
+        const MSG = ERROR_MSG_CONFIG.find(v => v.code === data.code);
+        if (MSG.display) {
+          Vue.prototype.$notify({
+            showClose: true,
+            message: MSG.message,
+            type: "error"
+          });
+        }
       } else {
-        Vue.prototype.$notify({
-          showClose: true,
-          message: "未定义异常: " + JSON.stringify(data, 2),
-          type: "error"
-        });
+        if (data && data.desc) {
+          Vue.prototype.$notify({
+            showClose: true,
+            message: data.desc,
+            type: "error"
+          });
+        } else {
+          Vue.prototype.$notify({
+            showClose: true,
+            message: "未定义异常: " + JSON.stringify(data, 2),
+            type: "error"
+          });
+        }
       }
       return Promise.reject(error);
     }

+ 7 - 0
src/plugins/errorMsgConfig.js

@@ -0,0 +1,7 @@
+export default [
+  {
+    code: "B-001-example",
+    display: false,
+    message: ""
+  }
+];