From 4a7d4dcc76276436a2d738df784884a31b740549 Mon Sep 17 00:00:00 2001 From: guy Date: Thu, 30 Mar 2017 16:23:15 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A1=A5=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bi/base.js | 6 +- bi/core.js | 228 +++++++++++----------------------------------- bi/widget.css | 8 -- dist/base.js | 6 +- dist/core.js | 228 +++++++++++----------------------------------- dist/widget.css | 8 -- src/core/alias.js | 52 +++++++++++ 7 files changed, 164 insertions(+), 372 deletions(-) diff --git a/bi/base.js b/bi/base.js index 959a0defc..8f157d02a 100644 --- a/bi/base.js +++ b/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. diff --git a/bi/core.js b/bi/core.js index 29b81c77f..a39580f0c 100644 --- a/bi/core.js +++ b/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请求的参�? - * @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)) { //原值为空,返回空字符 diff --git a/bi/widget.css b/bi/widget.css index a048dd5bc..39a07dbd6 100644 --- a/bi/widget.css +++ b/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; diff --git a/dist/base.js b/dist/base.js index 959a0defc..8f157d02a 100644 --- a/dist/base.js +++ b/dist/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. diff --git a/dist/core.js b/dist/core.js index 870551ae6..f1b2417b3 100644 --- a/dist/core.js +++ b/dist/core.js @@ -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请求的参�? - * @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)) { //原值为空,返回空字符 diff --git a/dist/widget.css b/dist/widget.css index a048dd5bc..39a07dbd6 100644 --- a/dist/widget.css +++ b/dist/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; diff --git a/src/core/alias.js b/src/core/alias.js index b507b66f1..26d5c2a12 100644 --- a/src/core/alias.js +++ b/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)) { //原值为空,返回空字符