argooo/Todos — comment on commit c198239d0026dfb2a888a2ea6e97de29b1e87584
File:  line 0
By argooo:

function MsgShow(msg,icon){
Ext.Msg.show({
title:'提示',
width:63,
height:26,
msg:msg,
buttons:Ext.Msg.OK,
icon:icon
});
};
function getRootPath(){

var pathArray = window.location.pathname.split('/');
var path =window.location.protocol.concat("//").concat(window.location.host).concat("/").concat(pathArray[1]);
//项目根路径 http://ip:port/project

return path;
}
function Rest(_cfg)
{
var request = $.ajax({
type: _cfg.type || "GET",
cache: true,
url: _cfg.url,
data: _cfg.data,
timeout: 25000,
success: function(data,status,jqXHR)
{
var jsonObj = eval("("+jqXHR.responseText+")");
if(jsonObj.result==0 || jsonObj.result==60000002 || jsonObj.result == 60000018 || jsonObj.result==60000001 || jsonObj.result == 60000003 || jsonObj.result == 60000004)
{
delete jsonObj;
_cfg.success(data,status,jqXHR);
}
else if (jsonObj.result==71254)
{
var errorCodeDesc = "";
$.each( data.items , function(index,item){
errorCodeDesc += item.errorCodeDesc + "
";
});
MsgShow(errorCodeDesc,Ext.Msg.INFO);
}
else if (jsonObj.result==70253)
{
var errorCodeDesc = "";
$.each( data.items , function(index,item){
if (item.errorCode != "0")
{
errorCodeDesc += item.instanceId + "虚拟机绑定或解绑定" + item.volumeId + "磁盘失败:"+item.errorCodeDesc+"
";
}

});
MsgShow(errorCodeDesc,Ext.Msg.INFO);
}
else if (jsonObj.result==30521 || jsonObj.result== "30521")
{
var errorCodeDesc = "";
$.each( data.items , function(index,item){
errorCodeDesc += item.IPSANName +","+ item.lunName + " : " + item.errorCodeDesc + "
";
});
MsgShow(errorCodeDesc,Ext.Msg.INFO);
}
else if(jsonObj.result == 60000042 || jsonObj.result == "60000042"){
MsgShow("会话超时，请重新登录！",Ext.Msg.INFO);
setTimeout(function(){
//对于会话过期错误码的判断
parent.window.location = getRootPath();
},2000);
}
else
{
//处理错误问题
if(jsonObj.errorCodeDesc){
if(_cfg.mask){
_cfg.mask.hide();
}
MsgShow(jsonObj.errorCodeDesc,Ext.Msg.INFO);
}
else{
_cfg.success(data,status,jqXHR);
}

delete jsonObj;
}
},
error: _cfg.error
});
return request;
}
function _Rest(_cfg)
{
var request = $.ajax({
type: _cfg.type || "GET",
cache: true,
url: _cfg.url,
data: _cfg.data,
// timeout: 25000,
success: function(data,status,jqXHR)
{
var jsonObj = eval("("+jqXHR.responseText+")");
if(jsonObj.result == 60000042 || jsonObj.result == "60000042"){
MsgShow("会话超时，请重新登录！",Ext.Msg.INFO);
setTimeout(function(){
//对于会话过期错误码的判断
parent.window.location = getRootPath();
},2000);
}
if(_cfg.success){
_cfg.success(data,status,jqXHR);
}
},
error: _cfg.error
});
return request;
}
//加载Ext所需要的文件。
(function() {
var path = getRootPath();
document.write('');
document.write('');
document.write('');
document.write('');
document.write('');
document.write('');
})();