更新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>
<!-- blade通用工具类 -->
<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 type="text/javascript">
$(function(){
BladeApp.addCtx("${ctxPath}");
});
</script>
<script src="${ctxPath}/static/blade/js/blade-ajax.js" type="text/javascript" ></script>
</head>
<body class="no-skin">
<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 type="text/javascript">
$(function(){
BladeApp.addCtx("${ctxPath}");
if(self != top){
var url = window.location.href;
parent.window.location.href = url;

View File

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

View File

@ -53,7 +53,7 @@ $.extend({
var postdata = $(gridtbl)
.jqGrid('getGridParam', 'postData');
var source = (typeof (export_source) == "undefined") ? (code + ".list") : export_source;
$.post(BladeApp.ctxPath + "/excel/preExport", {
$.post(BladeApp.getCtx() + "/excel/preExport", {
code : code,
colnames : JSON.stringify(colnames),
colmodel : JSON.stringify(colmodel),
@ -61,7 +61,7 @@ $.extend({
source : source
}, function(data) {
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 {
layer.alert(data.message, {
icon : 2,

View File

@ -1,13 +1,17 @@
/****************** 基本信息 ***************/
var BladeApp = {
ctxPath : "",
addCtx: function (ctx) {
if (this.ctxPath == "") {
this.ctxPath = ctx;
}
}
};
var BladeApp = {
ctx : "",
getCtx: function () {
if (this.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 = {

View File

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