更新ctx获取

This commit is contained in:
smallchill 2017-08-14 10:42:37 +08:00
parent efc0700c2d
commit 0bffea4939
6 changed files with 21 additions and 23 deletions

View File

@ -25,12 +25,7 @@
<script src="${ctxPath}/static/layer/layer.js"></script> <script src="${ctxPath}/static/layer/layer.js"></script>
<!-- blade通用工具类 --> <!-- blade通用工具类 -->
<script src="${ctxPath}/static/blade/js/blade-toolbox.js" type="text/javascript" ></script> <script src="${ctxPath}/static/blade/js/blade-toolbox.js" type="text/javascript" ></script>
<script src="${ctxPath}/static/blade/js/blade-ajax.js" type="text/javascript" ></script> <script src="${ctxPath}/static/blade/js/blade-ajax.js" type="text/javascript" ></script>
<script type="text/javascript">
$(function(){
BladeApp.addCtx("${ctxPath}");
});
</script>
</head> </head>
<body class="no-skin"> <body class="no-skin">
<div class="main-container" id="main-container"> <div class="main-container" id="main-container">

View File

@ -11,7 +11,6 @@
<script src="${ctxPath}/static/blade/js/blade-ajax.js" type="text/javascript"></script> <script src="${ctxPath}/static/blade/js/blade-ajax.js" type="text/javascript"></script>
<script type="text/javascript"> <script type="text/javascript">
$(function(){ $(function(){
BladeApp.addCtx("${ctxPath}");
if(self != top){ if(self != top){
var url = window.location.href; var url = window.location.href;
parent.window.location.href = url; parent.window.location.href = url;

View File

@ -7,7 +7,7 @@ var exwhere;
this.name = btnjson.name; this.name = btnjson.name;
this.pname = btnjson.pname; this.pname = btnjson.pname;
this.alias = btnjson.alias; this.alias = btnjson.alias;
this.url = this.isEmpty(BladeApp.ctxPath) + btnjson.url; this.url = this.isEmpty(BladeApp.getCtx()) + btnjson.url;
this.div = this.isEmpty(btnjson.icon.split('|')[0]); this.div = this.isEmpty(btnjson.icon.split('|')[0]);
this.li = this.isEmpty(btnjson.icon.split('|')[1]); this.li = this.isEmpty(btnjson.icon.split('|')[1]);
this.area=this.isEmpty(btnjson.tips); this.area=this.isEmpty(btnjson.tips);
@ -144,7 +144,7 @@ var exwhere;
return; return;
} }
var _this = this; var _this = this;
$.post(BladeApp.ctxPath + "/role/getPowerById", { id: ids }, function (data) { $.post(BladeApp.getCtx() + "/role/getPowerById", { id: ids }, function (data) {
if (data.code === 0) { if (data.code === 0) {
var roleName = rowData.name; var roleName = rowData.name;
_this.open(_this.url + "?roleId=" + ids + "&roleName=" + roleName); _this.open(_this.url + "?roleId=" + ids + "&roleName=" + roleName);
@ -251,7 +251,7 @@ var exwhere;
if (this.alias == "audit" || this.alias == "recycle") { if (this.alias == "audit" || this.alias == "recycle") {
var code = this.id; var code = this.id;
if (stage.all[code] == undefined) { if (stage.all[code] == undefined) {
$.post(BladeApp.ctxPath + "/cache/getChildBtn", { code: code }, function (data) { $.post(BladeApp.getCtx() + "/cache/getChildBtn", { code: code }, function (data) {
if (data.code === 0) { if (data.code === 0) {
btnjsons = data.data; btnjsons = data.data;
var _btn_child_stage = new btn_child_stage(); var _btn_child_stage = new btn_child_stage();
@ -268,7 +268,7 @@ var exwhere;
else { else {
stage.all[code].btn.bind(toolbar); stage.all[code].btn.bind(toolbar);
} }
exwhere = this.url.replace(BladeApp.ctxPath, "");//修复未发布在tomcat根目录下带有项目路径导致不能搜索的问题 exwhere = this.url.replace(BladeApp.getCtx(), "");//修复未发布在tomcat根目录下带有项目路径导致不能搜索的问题
isAutoPage = false;//自动跳转到第一页 isAutoPage = false;//自动跳转到第一页
searchGrid(); searchGrid();
return; return;
@ -482,7 +482,7 @@ var exwhere;
// 根据模块code生成每个工具条上面的 btn // 根据模块code生成每个工具条上面的 btn
function initMenuBtn(obj, code) { function initMenuBtn(obj, code) {
var ajax = new Ajax(BladeApp.ctxPath + "/cache/getBtn", function (data) { var ajax = new Ajax(BladeApp.getCtx() + "/cache/getBtn", function (data) {
if (data.code === 0) { if (data.code === 0) {
toolbar = obj; toolbar = obj;
btnjsons = data.data; btnjsons = data.data;

View File

@ -53,7 +53,7 @@ $.extend({
var postdata = $(gridtbl) var postdata = $(gridtbl)
.jqGrid('getGridParam', 'postData'); .jqGrid('getGridParam', 'postData');
var source = (typeof (export_source) == "undefined") ? (code + ".list") : export_source; var source = (typeof (export_source) == "undefined") ? (code + ".list") : export_source;
$.post(BladeApp.ctxPath + "/excel/preExport", { $.post(BladeApp.getCtx() + "/excel/preExport", {
code : code, code : code,
colnames : JSON.stringify(colnames), colnames : JSON.stringify(colnames),
colmodel : JSON.stringify(colmodel), colmodel : JSON.stringify(colmodel),
@ -61,7 +61,7 @@ $.extend({
source : source source : source
}, function(data) { }, function(data) {
if (data.code === 0) { if (data.code === 0) {
window.top.location.href = BladeApp.ctxPath + "/excel/export?code=" + data.data; window.top.location.href = BladeApp.getCtx() + "/excel/export?code=" + data.data;
} else { } else {
layer.alert(data.message, { layer.alert(data.message, {
icon : 2, icon : 2,

View File

@ -1,13 +1,17 @@
/****************** 基本信息 ***************/ /****************** 基本信息 ***************/
var BladeApp = { var BladeApp = {
ctxPath : "", ctx : "",
addCtx: function (ctx) { getCtx: function () {
if (this.ctxPath == "") { if (this.ctx == "") {
this.ctxPath = ctx; var pathName = window.top.document.location.pathname;
} var index = pathName.substr(1).indexOf("/");
} var result = pathName.substr(0, index + 1);
}; this.ctx = result;
}
return this.ctx;
}
};
/****************** 公共工具类 ***************/ /****************** 公共工具类 ***************/
var BladeTool = { var BladeTool = {

View File

@ -49,7 +49,7 @@ $(function () {
var ajax = new Ajax($form.attr("action"), function(data){ var ajax = new Ajax($form.attr("action"), function(data){
if (data.code === 0) { if (data.code === 0) {
layer.msg(data.message, {shift: 1}); layer.msg(data.message, {shift: 1});
setTimeout(function(){window.location.href = BladeApp.ctxPath + "/";}, 1200); setTimeout(function(){window.location.href = BladeApp.getCtx() + "/";}, 1200);
return false; return false;
} else { } else {
layer.msg(data.message, {shift: 6}); layer.msg(data.message, {shift: 6});