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); debugger; 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.parameter = {}; 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); this.statementJson = this.json; 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(){ // var i = this.count/this.json.pageSize; // this.pages = (i.toInt() -1 ){ var user = layout.user; switch ( f.value ) { case "@person": value = user.distinguishedName; break; case "@identityList": value = user.identityList.map( function (d) { return d.distinguishedName; }); break; case "@unitList": o2.Actions.load("x_organization_assemble_express").UnitAction.listWithPerson({ "personList" : [user.distinguishedName] }, function (json) { value = json.unitList; }, null, false); break; case "@unitAllList": o2.Actions.load("x_organization_assemble_express").UnitAction.listWithIdentitySupNested({ "personList" : [user.distinguishedName] }, function (json) { value = json.unitList; }, null, false); break; case "@year": value = (new Date().getFullYear()).toString(); break; case "@season": var m = new Date().format("%m"); if( ["01","02","03"].contains(m) ){ value = "1" }else if( ["04","05","06"].contains(m) ){ value = "2" }else if( ["07","08","09"].contains(m) ){ value = "3" }else{ value = "4" } break; case "@month": value = new Date().format("%Y-%m"); break; case "@time": value = new Date().format("db"); break; case "@date": value = new Date().format("%Y-%m-%d"); break; default: } } if( f.formatType === "dateTimeValue" || f.formatType === "datetimeValue"){ value = "{ts '"+value+"'}" }else if( f.formatType === "dateValue" ){ value = "{d '"+value+"'}" }else if( f.formatType === "timeValue" ){ value = "{t '"+value+"'}" } this.parameter[ f.parameter ] = value; }.bind(this)) }, loadCurrentPageData: function( callback, async, type ){ //是否需要在翻页的时候清空之前的items ? debugger; if( this.pageloading )return; this.pageloading = true; this.items = []; var p = this.currentPage; var d = { "filterList" : this.filterList, "parameter" : this.parameter }; while (this.viewTable.rows.length>1){ this.viewTable.deleteRow(-1); } //this.createLoadding(); this.loadViewRes = o2.Actions.load("x_query_assemble_surface").StatementAction.executeV2( this.options.statementId || this.options.statementName || this.json.statementId || this.json.statementName, type || "data", p, this.json.pageSize, d, function(json){ if( type === "all" || type === "count" ){ if( typeOf(json.count) === "number" ){ this.count = json.count; var i = this.count/this.json.pageSize; this.pages = (i.toInt()