var DetailPage = Talent.Layout.extend({ //空白模板 template: _.template('') //详情页 ,className: "standard-detail" //渲染区域 ,regions: { "standardBtn" : ".standard-btn" ,"standardForm" : ".standard-form" } ,initialize: function(options){ var self = this; //获取url上的信息 Talent.app.request("history:getQueryObject").done(function(obj) { self.id = obj.id; self.pageState = obj.pageState; self.pageName = obj.pageName; }); } ,onShow: function(){ var self = this; if (!this.options.wrappers) { //模型里面是没有数据的进行fetch获取服务器最新数据 //(model, response, options) this.model.fetch({ data: { id: this.id ,metaObjName: this.options.metaObjName ,pageType: 2 } ,url: "/MultiTenant/GetPageView" }).done(function(resp){ self.trigger("fetchDataComplete", resp); self.buildPage(); }); } else { this.model.set(this.options); this.buildPage(); } } //构建页面 ,buildPage: function(){ var self = this; this.modules = []; //获取属性值 var pageData = this.model.get("wrappers").contentWrap; //遍历属性值 _.each(pageData, function(item1, index1) { //扩展参数,在module里不同view需要 _.extend(item1, { searchParams: { "pageView": self.model.get("name") ,"dataid": self.model.get("dataid") } ,metaObjName: self.options.metaObjName ,pageName: self.pageName ,pageState: self.pageState ,formMode:self.options.formMode||'advance' }); if(_.isEmpty(item1.pageModules)) { return null; } //定义模块 var module = new PageModule(item1); //模块集合 self.modules.push(module); //定义模块渲染区 var moduleRegion = $('<div class="mod mod-' + index1 + ' clearfix"></div>'); //把模型渲染区加入el moduleRegion.appendTo(self.$el); var region = {}; region['mod-' + index1 + '-region'] = '.mod-' + index1; self.addRegions(region); self['mod-' + index1 + '-region'].show(module); }); } });