MWF.xApplication.query = MWF.xApplication.query || {}; MWF.xApplication.query.Query = MWF.xApplication.query.Query || {}; MWF.xDesktop.requireApp("query.Query", "Viewer", null, false); MWF.xApplication.query.Query.Statement = MWF.QStatement = new Class({ Extends: MWF.QViewer, options: { }, initialize: function(container, json, options, app, parentMacro){ //本类有三种事件, //一种是通过 options 传进来的事件,包括 loadView、openDocument、select //一种是用户配置的 事件, 在this.options.moduleEvents 中定义的作为类事件 //还有一种也是用户配置的事件,不在this.options.moduleEvents 中定义的作为 this.node 的DOM事件 this.setOptions(options); this.path = "../x_component_query_Query/$Viewer/"; this.cssPath = "../x_component_query_Query/$Viewer/"+this.options.style+"/css.wcss"; this._loadCss(); this.lp = MWF.xApplication.query.Query.LP; this.app = app; this.container = $(container); this.json = json; this.parentMacro = parentMacro; this.originalJson = Object.clone(json); this.viewJson = null; this.filterItems = []; this.searchStatus = "none"; //none, custom, default this.items = []; this.selectedItems = []; this.hideColumns = []; this.openColumns = []; this.gridJson = null; if (this.options.isload){ this.init(function(){ this.load(); }.bind(this)); } }, init: function(callback){ if (this.json.view){ this.viewJson = JSON.decode(this.json.view); if (callback) callback(); }else{ this.getView(callback); } }, loadMacro: function (callback) { MWF.require("MWF.xScript.Macro", function () { this.Macro = new MWF.Macro.ViewContext(this); if (callback) callback(); }.bind(this)); }, createActionbarNode : function(){ this.actionbarAreaNode.empty(); if( typeOf(this.json.showActionbar) === "boolean" && this.json.showActionbar !== true )return; if( typeOf( this.viewJson.actionbarHidden ) === "boolean" ){ if( this.viewJson.actionbarHidden === true || !this.viewJson.actionbarList || !this.viewJson.actionbarList.length )return; this.actionbar = new MWF.xApplication.query.Query.Statement.Actionbar(this.actionbarAreaNode, this.viewJson.actionbarList[0], this, {}); this.actionbar.load(); } }, _loadPageNode : function(){ this.viewPageAreaNode.empty(); if( !this.paging ){ var json; if( !this.viewJson.pagingList || !this.viewJson.pagingList.length ){ json = { "firstPageText": this.lp.firstPage, "lastPageText": this.lp.lastPage }; }else{ json = this.viewJson.pagingList[0]; } this.paging = new MWF.xApplication.query.Query.Statement.Paging(this.viewPageAreaNode, json, this, {}); this.paging.load(); }else{ this.paging.reload(); } }, _initPage: function(){ this.count = this.bundleItems.length; var i = this.count/this.json.pageSize; this.pages = (i.toInt()1){ this.viewTable.deleteRow(-1); } //this.createLoadding(); this.loadViewRes = this.lookupAction.loadView(this.json.name, this.json.application, d, function(json){ this.viewData = json.data; this.fireEvent("postLoadPageData"); if (this.viewJson.group.column){ this.gridJson = json.data.groupGrid; // this.loadGroupData(); }else{ this.gridJson = json.data.grid; this.loadData(); } if (this.gridJson.length) this._loadPageNode(); if (this.loadingAreaNode){ this.loadingAreaNode.destroy(); this.loadingAreaNode = null; } this.pageloading = false; this.fireEvent("loadView"); //options 传入的事件 this.fireEvent("postLoadPage"); if(callback)callback(); }.bind(this), null, async === false ? false : true ); }, loadData: function(){ if (this.gridJson.length){ // if( !this.options.paging ){ this.gridJson.each(function(line, i){ this.items.push(new MWF.xApplication.query.Query.Statement.Item(this, line, null, i)); }.bind(this)); // }else{ // this.loadPaging(); // } }else{ if (this.viewPageAreaNode) this.viewPageAreaNode.empty(); } }, loadDataByPaging : function(){ if( this.isItemsLoading )return; if( !this.isItemsLoaded ){ var from = Math.min( this.pageNumber * this.options.perPageCount , this.gridJson.length); var to = Math.min( ( this.pageNumber + 1 ) * this.options.perPageCount + 1 , this.gridJson.length); this.isItemsLoading = true; for( var i = from; i