|
|
@ -11028,14 +11028,26 @@ if (window.BI == null) { |
|
|
|
* @class BI.Factory |
|
|
|
* @class BI.Factory |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
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){ |
|
|
|
createView : function(url, viewFunc, mData, vData, context){ |
|
|
|
var modelFunc = viewFunc.replace(/View/, "Model"); |
|
|
|
var modelFunc = viewFunc.replace(/View/, "Model"); |
|
|
|
if(modelFunc === viewFunc || !_.isFunction(eval(modelFunc))){ |
|
|
|
modelFunc = this.parsePath(modelFunc)(window); |
|
|
|
console.warn("没有对应的Model:" + modelFunc + "使用默认的Model方式"); |
|
|
|
if(!_.isFunction(modelFunc)){ |
|
|
|
modelFunc = "BI.Model"; |
|
|
|
modelFunc = BI.Model; |
|
|
|
} |
|
|
|
} |
|
|
|
// try {
|
|
|
|
// try {
|
|
|
|
var model = new (eval(modelFunc))(_.extend({}, mData, { |
|
|
|
var model = new (modelFunc)(_.extend({}, mData, { |
|
|
|
parent: context && context.model, |
|
|
|
parent: context && context.model, |
|
|
|
rootURL: url |
|
|
|
rootURL: url |
|
|
|
}), {silent: true}); |
|
|
|
}), {silent: true}); |
|
|
|