From 4e1a6947850506063a60f6a45cf8cc462089b47b Mon Sep 17 00:00:00 2001 From: guy Date: Tue, 14 Mar 2017 14:53:14 +0800 Subject: [PATCH] add --- dist/core.js | 20 ++++++++++++++++---- index.js | 9 ++++----- src/core/mvc/factory/factory.js | 20 ++++++++++++++++---- 3 files changed, 36 insertions(+), 13 deletions(-) diff --git a/dist/core.js b/dist/core.js index 43655a20a..7ec970a23 100644 --- a/dist/core.js +++ b/dist/core.js @@ -11028,14 +11028,26 @@ if (window.BI == null) { * @class BI.Factory */ BI.Factory = { + parsePath: function parsePath (path) { + var segments = path.split('.'); + return function (obj) { + for (var i = 0; i < segments.length; i++) { + if (!obj) { + return; + } + obj = obj[segments[i]]; + } + return obj; + } + }, createView : function(url, viewFunc, mData, vData, context){ var modelFunc = viewFunc.replace(/View/, "Model"); - if(modelFunc === viewFunc || !_.isFunction(eval(modelFunc))){ - console.warn("没有对应的Model:" + modelFunc + "使用默认的Model方式"); - modelFunc = "BI.Model"; + modelFunc = this.parsePath(modelFunc)(window); + if(!_.isFunction(modelFunc)){ + modelFunc = BI.Model; } // try { - var model = new (eval(modelFunc))(_.extend({}, mData, { + var model = new (modelFunc)(_.extend({}, mData, { parent: context && context.model, rootURL: url }), {silent: true}); diff --git a/index.js b/index.js index 0f20b90e6..2c480d1d7 100644 --- a/index.js +++ b/index.js @@ -26,17 +26,16 @@ $(function(){ type: "bi.resizable_table", el: { type: "bi.collection_table", - isNeedMerge: true, - mergeCols: [0, 1], - mergeRule: function (col1, col2) { - return BI.isEqual(col1, col2); - } }, width: 600, height: 500, isResizeAdapt: true, isNeedResize: true, isNeedMerge: true, + mergeCols: [0, 1], + mergeRule: function (col1, col2) { + return BI.isEqual(col1, col2); + }, isNeedFreeze: true, freezeCols: [0, 1], columnSize: columnSize, diff --git a/src/core/mvc/factory/factory.js b/src/core/mvc/factory/factory.js index 1e484b2f8..83ee2a938 100644 --- a/src/core/mvc/factory/factory.js +++ b/src/core/mvc/factory/factory.js @@ -4,14 +4,26 @@ * @class BI.Factory */ BI.Factory = { + parsePath: function parsePath (path) { + var segments = path.split('.'); + return function (obj) { + for (var i = 0; i < segments.length; i++) { + if (!obj) { + return; + } + obj = obj[segments[i]]; + } + return obj; + } + }, createView : function(url, viewFunc, mData, vData, context){ var modelFunc = viewFunc.replace(/View/, "Model"); - if(modelFunc === viewFunc || !_.isFunction(eval(modelFunc))){ - console.warn("没有对应的Model:" + modelFunc + "使用默认的Model方式"); - modelFunc = "BI.Model"; + modelFunc = this.parsePath(modelFunc)(window); + if(!_.isFunction(modelFunc)){ + modelFunc = BI.Model; } // try { - var model = new (eval(modelFunc))(_.extend({}, mData, { + var model = new (modelFunc)(_.extend({}, mData, { parent: context && context.model, rootURL: url }), {silent: true});