guy 7 years ago
parent
commit
4e1a694785
  1. 20
      dist/core.js
  2. 9
      index.js
  3. 20
      src/core/mvc/factory/factory.js

20
dist/core.js vendored

@ -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});

9
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,

20
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});

Loading…
Cancel
Save