fix:加载后台报错处理

This commit is contained in:
wangwenrui
2020-05-28 18:13:11 +08:00
parent 47c23b89c9
commit 2b8c406551
2 changed files with 36 additions and 29 deletions

View File

@@ -15,7 +15,7 @@ export default {
/*this.$http.get("config.json").then((result)=>{ /*this.$http.get("config.json").then((result)=>{
this.$axios.defaults.baseURL = result.body.baseUrl; this.$axios.defaults.baseURL = result.body.baseUrl;
});*/ });*/
this.$axios.defaults.baseURL = 'http://192.168.40.42:8080/nz-admin'; this.$axios.defaults.baseURL = 'http://192.168.40.41:8080/nz-admin';
} }
} }
</script> </script>

View File

@@ -571,7 +571,9 @@ export default {
}else{ }else{
step='30m'; step='30m';
} }
if(this.$refs.messageChart){
this.$refs.messageChart.startLoading(); this.$refs.messageChart.startLoading();
}
let axiosArr=[]; let axiosArr=[];
let paramStr = JSON.stringify(this.promQueryParamConvert(this.currentMsg)); let paramStr = JSON.stringify(this.promQueryParamConvert(this.currentMsg));
axiosArr.push(axios.get("/prom/api/v1/query_range?query="+paramStr.substring(1, paramStr.length-1).replace(/\+/g, "%2B").replace(/ /g, "%20").replace(/\\/g, "")+"&start="+this.$stringTimeParseToUnix(start)+"&end="+this.$stringTimeParseToUnix(end)+"&step="+step)); axiosArr.push(axios.get("/prom/api/v1/query_range?query="+paramStr.substring(1, paramStr.length-1).replace(/\+/g, "%2B").replace(/ /g, "%20").replace(/\\/g, "")+"&start="+this.$stringTimeParseToUnix(start)+"&end="+this.$stringTimeParseToUnix(end)+"&step="+step));
@@ -667,6 +669,7 @@ export default {
this.storedTableData.forEach((item) => { this.storedTableData.forEach((item) => {
item.labels = JSON.parse(item.labels); item.labels = JSON.parse(item.labels);
let paramStr = JSON.stringify(this.promQueryParamConvert(item)); let paramStr = JSON.stringify(this.promQueryParamConvert(item));
if(paramStr&& paramStr !=''){
this.$get('/prom/api/v1/query?query=' + paramStr.substring(1, paramStr.length-1).replace(/\+/g, "%2B").replace(/ /g, "%20").replace(/\\/g, "")).then(response2 => { this.$get('/prom/api/v1/query?query=' + paramStr.substring(1, paramStr.length-1).replace(/\+/g, "%2B").replace(/ /g, "%20").replace(/\\/g, "")).then(response2 => {
let current = []; let current = [];
if (response2.data && response2.data.result && response2.data.result.length > 0) { if (response2.data && response2.data.result && response2.data.result.length > 0) {
@@ -680,6 +683,7 @@ export default {
} }
this.$set(item, "current", current); this.$set(item, "current", current);
}); });
}
}); });
this.pageObj.total = response.data.total; this.pageObj.total = response.data.total;
this.isError = false; this.isError = false;
@@ -695,6 +699,7 @@ export default {
}); });
}, },
promQueryParamConvert(obj) { promQueryParamConvert(obj) {
if(obj){
return "(" + obj.alertRule.expr + ") and (" + function(){ return "(" + obj.alertRule.expr + ") and (" + function(){
let q = "{"; let q = "{";
for (let k in obj.labels) { for (let k in obj.labels) {
@@ -710,6 +715,8 @@ export default {
q += "}"; q += "}";
return q; return q;
}() + ")"; }() + ")";
}
return '';
}, },
elementsetShow(s, e) { elementsetShow(s, e) {
var eventfixed = { var eventfixed = {