Browse Source

补方法

es6
guy 8 years ago
parent
commit
4a7d4dcc76
  1. 6
      bi/base.js
  2. 228
      bi/core.js
  3. 8
      bi/widget.css
  4. 6
      dist/base.js
  5. 228
      dist/core.js
  6. 8
      dist/widget.css
  7. 52
      src/core/alias.js

6
bi/base.js

@ -2368,11 +2368,7 @@ BI.Bubbles = new BI.BubblesController();
BI.Tooltips = new BI.TooltipsController();
BI.Popovers = new BI.FloatBoxController();
BI.Broadcasts = new BI.BroadcastController();
BI.StyleLoaders = new BI.StyleLoaderManager();
BI.servletURL = "dist/";
BI.resourceURL = "dist/resource/";
BI.i18n = {};/**
BI.StyleLoaders = new BI.StyleLoaderManager();/**
* canvas绘图
*
* Created by GUY on 2015/11/18.

228
bi/core.js

@ -2971,28 +2971,7 @@ if (!window.BI) {
//encode
encodeBIParam(option.data);
var async = true;
if (BI.isNotNull(option.async)) {
async = option.async;
}
if (BI.isNull(loading)) {
loading = BI.createWidget({
type: "bi.request_loading"
});
}
if (BI.isNull(timeoutToast)) {
timeoutToast = BI.createWidget({
type: "bi.timeout_toast"
});
timeoutToast.setCallback(function (op) {
decodeBIParam(op.data);
BI.ajax(op);
});
}
timeoutToast.addReq(option);
var async = option.async;
option.data = BI.cjkEncodeDO(option.data);
@ -3002,68 +2981,14 @@ if (!window.BI) {
type: "POST",
data: option.data,
async: async,
error: function () {
if (!timeoutToast.hasReq(option)) {
return;
}
timeoutToast.removeReq(option);
//失败 取消、重新加载
loading.setCallback(function () {
decodeBIParam(option.data);
BI.ajax(option);
});
loading.showError();
},
error: option.error,
complete: function (res, status) {
if (!timeoutToast.hasReq(option)) {
return;
}
timeoutToast.removeReq(option);
//登录超时
if (BI.isNotNull(res.responseText) &&
res.responseText.indexOf("fs-login-content") > -1 &&
res.responseText.indexOf("fs-login-input-password-confirm") === -1) {
if (BI.Popovers.isVisible(BI.LoginTimeOut.POPOVER_ID)) {
return;
}
if (BI.isNotNull(BI.Popovers.get(BI.LoginTimeOut.POPOVER_ID))) {
BI.Popovers.open(BI.LoginTimeOut.POPOVER_ID);
return;
}
var loginTimeout = BI.createWidget({
type: "bi.login_timeout"
});
loginTimeout.on(BI.LoginTimeOut.EVENT_LOGIN, function () {
decodeBIParam(option.data);
BI.ajax(option);
BI.Popovers.remove(BI.LoginTimeOut.POPOVER_ID);
});
BI.Popovers.create(BI.LoginTimeOut.POPOVER_ID, loginTimeout, {
width: 600,
height: 400
}).open(BI.LoginTimeOut.POPOVER_ID);
} else if (BI.isNotNull(res.responseText) &&
res.responseText.indexOf("script") > -1 &&
res.responseText.indexOf("Session Timeout...") > -1) {
//登录失效
loading.setCallback(function () {
location.reload();
});
loading.showError();
} else if (status === "success" && BI.isFunction(option.success)) {
option.success(BI.jsonDecode(res.responseText));
}
if (BI.isFunction(option.complete)) {
option.complete(BI.jsonDecode(res.responseText), status);
}
}
});
return function cancel() {
timeoutToast.removeReq(option);
};
function encodeBIParam(data) {
for (var key in data) {
if (_.isObject(data[key])) {
@ -3083,102 +3008,7 @@ if (!window.BI) {
}
}
}
})(),
/**
* 异步ajax请求
* @param {String} op op参数
* @param {String} cmd cmd参数
* @param {JSON} data ajax请求的参数
* @param {Function} callback 回调函数
* @param {Function} complete 回调
*/
requestAsync: function (op, cmd, data, callback, complete) {
data = data || {};
if (!BI.isKey(op)) {
op = 'fr_bi_dezi';
}
if (op === "fr_bi_dezi" || op === "fr_bi_configure") {
data.sessionID = Data.SharingPool.get("sessionID");
}
var url = BI.servletURL + '?op=' + op + '&cmd=' + cmd + "&_=" + Math.random();
return (BI.ajax)({
url: url,
type: 'POST',
data: data,
error: function () {
// BI.Msg.toast(BI.i18nText("BI-Ajax_Error"));
},
success: function (res) {
if (BI.isFunction(callback)) {
callback(res);
}
},
complete: function (res, status) {
if (BI.isFunction(complete)) {
complete(res);
}
}
});
},
/**
* 同步ajax请求
* @param {String} op op参数
* @param {String} cmd cmd参数
* @param {JSON} data ajax请求的参<EFBFBD>?
* @returns {Object} ajax同步请求返回的JSON对象
*/
requestSync: function (op, cmd, data) {
data = data || {};
if (!BI.isKey(op)) {
op = 'fr_bi_dezi';
}
if (op === "fr_bi_dezi") {
data.sessionID = Data.SharingPool.get("sessionID");
}
var url = BI.servletURL + '?op=' + op + '&cmd=' + cmd + "&_=" + Math.random();
var result = {};
(BI.ajax)({
url: url,
type: 'POST',
async: false,
data: data,
error: function () {
BI.Msg.toast(BI.i18nText("BI-Ajax_Error"));
},
complete: function (res, status) {
if (status === 'success') {
result = res;
}
}
});
return result;
},
/**
* 请求方法
* @param cmd 命令
* @param data 数据
* @param extend 参数
* @returns {*}
*/
request: function (cmd, data, extend) {
extend = extend || {};
data = data || {};
var op = extend.op;
if (!BI.isKey(op)) {
op = 'fr_bi_dezi';
}
if (op === "fr_bi_dezi") {
data.sessionID = Data.SharingPool.get("sessionID");
}
if (extend.async === true) {
BI.requestAsync(op, cmd, data, extend.complete || extend.success);
} else {
return BI.requestSync(op, cmd, data);
}
}
})()
});
})(jQuery);;(function () {
function isEmpty(value) {
@ -3320,6 +3150,58 @@ if (!window.BI) {
}
};
BI.jsonDecode = function (text) {
try {
// 注意0啊
//var jo = $.parseJSON(text) || {};
var jo = $.parseJSON(text);
if (jo == null) {
jo = {};
}
} catch (e) {
/*
* richie:浏览器只支持标准的JSON字符串转换而jQuery会默认调用浏览器的window.JSON.parse()函数进行解析
* 比如var str = "{'a':'b'}",这种形式的字符串转换为JSON就会抛异常
*/
try {
jo = new Function("return " + text)() || {};
} catch (e) {
//do nothing
}
if (jo == null) {
jo = [];
}
}
if (!_hasDateInJson(text)) {
return jo;
}
function _hasDateInJson(json) {
if (!json || typeof json !== "string") {
return false;
}
return json.indexOf("__time__") != -1;
}
return (function (o) {
if (typeof o === "string") {
return o;
}
if (o && o.__time__ != null) {
return new Date(o.__time__);
}
for (var a in o) {
if (o[a] == o || typeof o[a] == 'object' || $.isFunction(o[a])) {
break;
}
o[a] = arguments.callee(o[a]);
}
return o;
})(jo);
}
BI.contentFormat = function (cv, fmt) {
if (isEmpty(cv)) {
//原值为空,返回空字符

8
bi/widget.css

@ -634,14 +634,6 @@
/****添加计算宽度的--运算符直接需要space****/
/****** common color(常用颜色,可用于普遍场景) *****/
/**** custom color(自定义颜色,用于特定场景) ****/
.bi-responsive-table > div.bottom-left > div > div > table > * > * > td.last-col,
.bi-responsive-table > div.bottom-right > div > div > table > * > * > td.last-col,
.bi-responsive-table > div > div > table > * > * > td.last-col {
min-width: 80px;
}
/****添加计算宽度的--运算符直接需要space****/
/****** common color(常用颜色,可用于普遍场景) *****/
/**** custom color(自定义颜色,用于特定场景) ****/
.bi-sequence-table-dynamic-number .sequence-table-title-cell {
overflow: hidden;
overflow-x: hidden;

6
dist/base.js vendored

@ -2368,11 +2368,7 @@ BI.Bubbles = new BI.BubblesController();
BI.Tooltips = new BI.TooltipsController();
BI.Popovers = new BI.FloatBoxController();
BI.Broadcasts = new BI.BroadcastController();
BI.StyleLoaders = new BI.StyleLoaderManager();
BI.servletURL = "dist/";
BI.resourceURL = "dist/resource/";
BI.i18n = {};/**
BI.StyleLoaders = new BI.StyleLoaderManager();/**
* canvas绘图
*
* Created by GUY on 2015/11/18.

228
dist/core.js vendored

@ -13987,28 +13987,7 @@ if (!window.BI) {
//encode
encodeBIParam(option.data);
var async = true;
if (BI.isNotNull(option.async)) {
async = option.async;
}
if (BI.isNull(loading)) {
loading = BI.createWidget({
type: "bi.request_loading"
});
}
if (BI.isNull(timeoutToast)) {
timeoutToast = BI.createWidget({
type: "bi.timeout_toast"
});
timeoutToast.setCallback(function (op) {
decodeBIParam(op.data);
BI.ajax(op);
});
}
timeoutToast.addReq(option);
var async = option.async;
option.data = BI.cjkEncodeDO(option.data);
@ -14018,68 +13997,14 @@ if (!window.BI) {
type: "POST",
data: option.data,
async: async,
error: function () {
if (!timeoutToast.hasReq(option)) {
return;
}
timeoutToast.removeReq(option);
//失败 取消、重新加载
loading.setCallback(function () {
decodeBIParam(option.data);
BI.ajax(option);
});
loading.showError();
},
error: option.error,
complete: function (res, status) {
if (!timeoutToast.hasReq(option)) {
return;
}
timeoutToast.removeReq(option);
//登录超时
if (BI.isNotNull(res.responseText) &&
res.responseText.indexOf("fs-login-content") > -1 &&
res.responseText.indexOf("fs-login-input-password-confirm") === -1) {
if (BI.Popovers.isVisible(BI.LoginTimeOut.POPOVER_ID)) {
return;
}
if (BI.isNotNull(BI.Popovers.get(BI.LoginTimeOut.POPOVER_ID))) {
BI.Popovers.open(BI.LoginTimeOut.POPOVER_ID);
return;
}
var loginTimeout = BI.createWidget({
type: "bi.login_timeout"
});
loginTimeout.on(BI.LoginTimeOut.EVENT_LOGIN, function () {
decodeBIParam(option.data);
BI.ajax(option);
BI.Popovers.remove(BI.LoginTimeOut.POPOVER_ID);
});
BI.Popovers.create(BI.LoginTimeOut.POPOVER_ID, loginTimeout, {
width: 600,
height: 400
}).open(BI.LoginTimeOut.POPOVER_ID);
} else if (BI.isNotNull(res.responseText) &&
res.responseText.indexOf("script") > -1 &&
res.responseText.indexOf("Session Timeout...") > -1) {
//登录失效
loading.setCallback(function () {
location.reload();
});
loading.showError();
} else if (status === "success" && BI.isFunction(option.success)) {
option.success(BI.jsonDecode(res.responseText));
}
if (BI.isFunction(option.complete)) {
option.complete(BI.jsonDecode(res.responseText), status);
}
}
});
return function cancel() {
timeoutToast.removeReq(option);
};
function encodeBIParam(data) {
for (var key in data) {
if (_.isObject(data[key])) {
@ -14099,102 +14024,7 @@ if (!window.BI) {
}
}
}
})(),
/**
* 异步ajax请求
* @param {String} op op参数
* @param {String} cmd cmd参数
* @param {JSON} data ajax请求的参数
* @param {Function} callback 回调函数
* @param {Function} complete 回调
*/
requestAsync: function (op, cmd, data, callback, complete) {
data = data || {};
if (!BI.isKey(op)) {
op = 'fr_bi_dezi';
}
if (op === "fr_bi_dezi" || op === "fr_bi_configure") {
data.sessionID = Data.SharingPool.get("sessionID");
}
var url = BI.servletURL + '?op=' + op + '&cmd=' + cmd + "&_=" + Math.random();
return (BI.ajax)({
url: url,
type: 'POST',
data: data,
error: function () {
// BI.Msg.toast(BI.i18nText("BI-Ajax_Error"));
},
success: function (res) {
if (BI.isFunction(callback)) {
callback(res);
}
},
complete: function (res, status) {
if (BI.isFunction(complete)) {
complete(res);
}
}
});
},
/**
* 同步ajax请求
* @param {String} op op参数
* @param {String} cmd cmd参数
* @param {JSON} data ajax请求的参<EFBFBD>?
* @returns {Object} ajax同步请求返回的JSON对象
*/
requestSync: function (op, cmd, data) {
data = data || {};
if (!BI.isKey(op)) {
op = 'fr_bi_dezi';
}
if (op === "fr_bi_dezi") {
data.sessionID = Data.SharingPool.get("sessionID");
}
var url = BI.servletURL + '?op=' + op + '&cmd=' + cmd + "&_=" + Math.random();
var result = {};
(BI.ajax)({
url: url,
type: 'POST',
async: false,
data: data,
error: function () {
BI.Msg.toast(BI.i18nText("BI-Ajax_Error"));
},
complete: function (res, status) {
if (status === 'success') {
result = res;
}
}
});
return result;
},
/**
* 请求方法
* @param cmd 命令
* @param data 数据
* @param extend 参数
* @returns {*}
*/
request: function (cmd, data, extend) {
extend = extend || {};
data = data || {};
var op = extend.op;
if (!BI.isKey(op)) {
op = 'fr_bi_dezi';
}
if (op === "fr_bi_dezi") {
data.sessionID = Data.SharingPool.get("sessionID");
}
if (extend.async === true) {
BI.requestAsync(op, cmd, data, extend.complete || extend.success);
} else {
return BI.requestSync(op, cmd, data);
}
}
})()
});
})(jQuery);/**
* 客户端观察者主要处理事件的添加删除执行等
@ -19998,6 +19828,58 @@ BI.PopoverSection.EVENT_CLOSE = "EVENT_CLOSE";;(function () {
}
};
BI.jsonDecode = function (text) {
try {
// 注意0啊
//var jo = $.parseJSON(text) || {};
var jo = $.parseJSON(text);
if (jo == null) {
jo = {};
}
} catch (e) {
/*
* richie:浏览器只支持标准的JSON字符串转换而jQuery会默认调用浏览器的window.JSON.parse()函数进行解析
* 比如var str = "{'a':'b'}",这种形式的字符串转换为JSON就会抛异常
*/
try {
jo = new Function("return " + text)() || {};
} catch (e) {
//do nothing
}
if (jo == null) {
jo = [];
}
}
if (!_hasDateInJson(text)) {
return jo;
}
function _hasDateInJson(json) {
if (!json || typeof json !== "string") {
return false;
}
return json.indexOf("__time__") != -1;
}
return (function (o) {
if (typeof o === "string") {
return o;
}
if (o && o.__time__ != null) {
return new Date(o.__time__);
}
for (var a in o) {
if (o[a] == o || typeof o[a] == 'object' || $.isFunction(o[a])) {
break;
}
o[a] = arguments.callee(o[a]);
}
return o;
})(jo);
}
BI.contentFormat = function (cv, fmt) {
if (isEmpty(cv)) {
//原值为空,返回空字符

8
dist/widget.css vendored

@ -634,14 +634,6 @@
/****添加计算宽度的--运算符直接需要space****/
/****** common color(常用颜色,可用于普遍场景) *****/
/**** custom color(自定义颜色,用于特定场景) ****/
.bi-responsive-table > div.bottom-left > div > div > table > * > * > td.last-col,
.bi-responsive-table > div.bottom-right > div > div > table > * > * > td.last-col,
.bi-responsive-table > div > div > table > * > * > td.last-col {
min-width: 80px;
}
/****添加计算宽度的--运算符直接需要space****/
/****** common color(常用颜色,可用于普遍场景) *****/
/**** custom color(自定义颜色,用于特定场景) ****/
.bi-sequence-table-dynamic-number .sequence-table-title-cell {
overflow: hidden;
overflow-x: hidden;

52
src/core/alias.js

@ -138,6 +138,58 @@
}
};
BI.jsonDecode = function (text) {
try {
// 注意0啊
//var jo = $.parseJSON(text) || {};
var jo = $.parseJSON(text);
if (jo == null) {
jo = {};
}
} catch (e) {
/*
* richie:浏览器只支持标准的JSON字符串转换而jQuery会默认调用浏览器的window.JSON.parse()函数进行解析
* 比如var str = "{'a':'b'}",这种形式的字符串转换为JSON就会抛异常
*/
try {
jo = new Function("return " + text)() || {};
} catch (e) {
//do nothing
}
if (jo == null) {
jo = [];
}
}
if (!_hasDateInJson(text)) {
return jo;
}
function _hasDateInJson(json) {
if (!json || typeof json !== "string") {
return false;
}
return json.indexOf("__time__") != -1;
}
return (function (o) {
if (typeof o === "string") {
return o;
}
if (o && o.__time__ != null) {
return new Date(o.__time__);
}
for (var a in o) {
if (o[a] == o || typeof o[a] == 'object' || $.isFunction(o[a])) {
break;
}
o[a] = arguments.callee(o[a]);
}
return o;
})(jo);
}
BI.contentFormat = function (cv, fmt) {
if (isEmpty(cv)) {
//原值为空,返回空字符

Loading…
Cancel
Save