| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929 |
- MWF.xApplication.query = MWF.xApplication.query || {};
- MWF.xApplication.query.Query = MWF.xApplication.query.Query || {};
- MWF.require("MWF.widget.Common", null, false);
- MWF.require("o2.widget.Paging", null, false);
- MWF.require("MWF.xScript.Macro", null, false);
- MWF.xDesktop.requireApp("query.Query", "lp.zh-cn", null, false);
- MWF.xApplication.query.Query.Viewer = MWF.QViewer = new Class({
- Implements: [Options, Events],
- Extends: MWF.widget.Common,
- options: {
- "style": "default",
- "skin" : null,
- "resizeNode": true,
- "paging" : "scroll",
- "perPageCount" : 50,
- "isload": "true",
- "export": false,
- "moduleEvents": ["queryLoad", "postLoad", "postLoadPageData", "postLoadPage", "selectRow", "unselectRow",
- "queryLoadItemRow", "postLoadItemRow", "queryLoadCategoryRow", "postLoadCategoryRow"]
- // "actions": {
- // "lookup": {"uri": "/jaxrs/view/flag/{view}/query/{application}/execute", "method":"PUT"},
- // "getView": {"uri": "/jaxrs/view/flag/{view}/query/{application}"}
- //
- // },
- // "actionRoot": "x_query_assemble_surface"
- },
- 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;
- debugger;
- 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));
- }
- },
- loadView: function(){
- if (this.viewJson){
- this.reload();
- }else{
- this.init(function(){
- this.load();
- }.bind(this));
- }
- },
- init: function(callback){
- if (this.json.data){
- this.viewJson = JSON.decode(this.json.data);
- if (callback) callback();
- }else{
- this.getView(callback);
- }
- },
- load: function(){
- this.loadMacro( function () {
- this._loadModuleEvents();
- if (this.fireEvent("queryLoad")){
- this._loadUserInterface();
- //this._loadStyles();
- this._loadDomEvents();
- }
- }.bind(this))
- },
- _loadUserInterface : function(){
- this.loadLayout();
- this.createActionbarNode();
- this.createSearchNode();
- this.createViewNode({"filterList": this.json.filter ? this.json.filter.clone() : null});
- if (this.options.resizeNode){
- this.setContentHeightFun = this.setContentHeight.bind(this);
- this.container.addEvent("resize", this.setContentHeightFun);
- this.setContentHeightFun();
- }
- },
- loadLayout: function(){
- this.node = new Element("div", {"styles": this.css.node}).inject(this.container);
- this.actionbarAreaNode = new Element("div", {"styles": this.css.actionbarAreaNode}).inject(this.node);
- //if (this.options.export) this.exportAreaNode = new Element("div", {"styles": this.css.exportAreaNode}).inject(this.node);
- this.searchAreaNode = new Element("div", {"styles": this.css.searchAreaNode}).inject(this.node);
- this.viewAreaNode = new Element("div", {"styles": this.css.viewAreaNode}).inject(this.node);
- this.viewPageNode = new Element("div", {"styles": this.css.viewPageNode}).inject(this.node);
- this.viewPageAreaNode = new Element("div", {"styles": this.css.viewPageAreaNode}).inject(this.viewPageNode);
- },
- loadMacro: function (callback) {
- MWF.require("MWF.xScript.Macro", function () {
- this.Macro = new MWF.Macro.ViewContext(this);
- if (callback) callback();
- }.bind(this));
- },
- createExportNode: function(){
- if (this.options.export){
- MWF.require("MWF.widget.Toolbar", function(){
- this.toolbar = new MWF.widget.Toolbar(this.actionbarAreaNode, {"style": "simple"}, this); //this.exportAreaNode
- var actionNode = new Element("div", {
- "id": "",
- "MWFnodetype": "MWFToolBarButton",
- "MWFButtonImage": this.path+""+this.options.style+"/icon/export.png",
- "title": this.lp.exportExcel,
- "MWFButtonAction": "exportView",
- "MWFButtonText": this.lp.exportExcel
- }).inject(this.actionbarAreaNode); //this.exportAreaNode
- this.toolbar.load();
- }.bind(this));
- //this.exportNode = new Element("button", {"text": this.lp.exportExcel}).inject(this.exportAreaNode);
- }
- },
- exportView: function(){
- var action = MWF.Actions.get("x_query_assemble_surface");
- var filterData = this.json.filter ? this.json.filter.clone() : [];
- if (this.filterItems.length){
- this.filterItems.each(function(filter){
- filterData.push(filter.data);
- }.bind(this));
- }
- action.exportViewWithQuery(this.json.viewName, this.json.application, {"filterList": filterData}, function(json){
- var uri = action.action.actions.getViewExcel.uri;
- uri = uri.replace("{flag}", json.data.id);
- uri = action.action.address+uri;
- var a = new Element("a", {"href": uri, "target":"_blank"});
- a.click();
- a.destroy();
- }.bind(this));
- },
- setContentHeight: function(){
- var size = this.node.getSize();
- var searchSize = this.searchAreaNode.getComputedSize();
- var h = size.y-searchSize.totalHeight;
- //if (this.exportAreaNode){
- // var exportSize = this.exportAreaNode.getComputedSize();
- // h = h-exportSize.totalHeight;
- //}
- if( this.actionbarAreaNode ){
- var exportSize = this.actionbarAreaNode.getComputedSize();
- h = h-exportSize.totalHeight;
- }
- var pageSize = this.viewPageNode.getComputedSize();
- h = h-pageSize.totalHeight;
- this.viewAreaNode.setStyle("height", ""+h+"px");
- },
- createLoadding: function(){
- this.loadingAreaNode = new Element("div", {"styles": this.css.viewLoadingAreaNode}).inject(this.contentAreaNode);
- new Element("div", {"styles": {"height": "5px"}}).inject(this.loadingAreaNode);
- var loadingNode = new Element("div", {"styles": this.css.viewLoadingNode}).inject(this.loadingAreaNode);
- new Element("div", {"styles": this.css.viewLoadingIconNode}).inject(loadingNode);
- var loadingTextNode = new Element("div", {"styles": this.css.viewLoadingTextNode}).inject(loadingNode);
- loadingTextNode.set("text", "loading...");
- },
- createActionbarNode : function(){
- this.actionbarAreaNode.empty();
- 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.Viewer.Actionbar(this.actionbarAreaNode, this.viewJson.actionbarList[0], this, {});
- this.actionbar.load();
- }else{ //兼容以前的ExportNode
- this.createExportNode();
- }
- },
- createViewNode: function(data){
- this.viewAreaNode.empty();
- this.contentAreaNode = new Element("div", {"styles": this.css.contentAreaNode}).inject(this.viewAreaNode);
- this.viewTable = new Element("table", {
- "styles": this.css.viewTitleTableNode,
- "border": "0px",
- "cellPadding": "0",
- "cellSpacing": "0"
- }).inject(this.contentAreaNode);
- this.createLoadding();
- if (this.json.isTitle!=="no"){
- this.viewTitleLine = new Element("tr", {"styles": this.css.viewTitleLineNode}).inject(this.viewTable);
- //if (this.json.select==="single" || this.json.select==="multi") {
- this.selectTitleCell = new Element("td", {
- "styles": this.css.viewTitleCellNode
- }).inject(this.viewTitleLine);
- this.selectTitleCell.setStyle("width", "10px");
- if (this.json.titleStyles) this.selectTitleCell.setStyles(this.json.titleStyles);
- //}
- //序号
- if (this.viewJson.isSequence==="yes"){
- this.sequenceTitleCell = new Element("td", {
- "styles": this.css.viewTitleCellNode
- }).inject(this.viewTitleLine);
- this.sequenceTitleCell.setStyle("width", "10px");
- if (this.json.titleStyles) this.sequenceTitleCell.setStyles(this.json.titleStyles);
- }
- this.entries = {};
- this.viewJson.selectList.each(function(column){
- this.entries[column.column] = column;
- if (!column.hideColumn){
- var viewCell = new Element("td", {
- "styles": this.css.viewTitleCellNode,
- "text": column.displayName
- }).inject(this.viewTitleLine);
- var size = MWF.getTextSize(column.displayName, this.css.viewTitleCellNode);
- viewCell.setStyle("min-width", ""+size.x+"px");
- if (this.json.titleStyles) viewCell.setStyles(this.json.titleStyles);
- }else{
- this.hideColumns.push(column.column);
- }
- if (column.allowOpen) this.openColumns.push(column.column);
- }.bind(this));
- this.lookup(data);
- }else{
- this.viewJson.selectList.each(function(column){
- if (column.hideColumn) this.hideColumns.push(column.column);
- if (!column.allowOpen) this.openColumns.push(column.column);
- }.bind(this));
- this.lookup(data);
- }
- },
- // _loadPageCountNode: function(){
- // this.viewPageContentNode.empty();
- //
- // var size = this.viewPageAreaNode.getSize();
- // var w1 = this.viewPageFirstNode.getSize().x*2;
- // var w2 = this.viewPageContentNode.getStyle("margin-left").toInt();
- // var w = size.x-w1-w2;
- //
- // var bw = this.css.viewPageButtonNode.width.toInt()+this.css.viewPageButtonNode["margin-right"].toInt();
- // var count = (w/bw).toInt()-2;
- // if (count>10) count = 10;
- // this.showPageCount = Math.min(count, this.pages);
- //
- // var tmp = this.showPageCount/2;
- // var n = tmp.toInt();
- // var left = this.currentPage-n;
- // if (left<=0) left = 1;
- // var right = this.showPageCount + left-1;
- // if (right>this.pages) right = this.pages;
- // left = right-this.showPageCount+1;
- // if (left<=1) left = 1;
- //
- // this.viewPagePrevNode = new Element("div", {"styles": this.css.viewPagePrevButtonNode}).inject(this.viewPageContentNode);
- // this.loadPageButtonEvent(this.viewPagePrevNode, "viewPagePrevButtonNode_over", "viewPagePrevButtonNode_up", "viewPagePrevButtonNode_down", function(){
- // if (this.currentPage>1) this.currentPage--;
- // this.loadCurrentPageData();
- // }.bind(this));
- //
- // for (i=left; i<=right; i++){
- // var node = new Element("div", {"styles": this.css.viewPageButtonNode, "text": i}).inject(this.viewPageContentNode);
- // if (i==this.currentPage){
- // node.setStyles(this.css.viewPageButtonNode_current);
- // }else{
- // this.loadPageButtonEvent(node, "viewPageButtonNode_over", "viewPageButtonNode_up", "viewPageButtonNode_down", function(e){
- // this.currentPage = e.target.get("text").toInt();
- // this.loadCurrentPageData();
- // }.bind(this));
- // }
- // }
- // this.viewPageNextNode = new Element("div", {"styles": this.css.viewPageNextButtonNode}).inject(this.viewPageContentNode);
- // this.loadPageButtonEvent(this.viewPageNextNode, "viewPageNextButtonNode_over", "viewPageNextButtonNode_up", "viewPageNextButtonNode_down", function(){
- // if (this.currentPage<=this.pages-1) this.currentPage++;
- // this.loadCurrentPageData();
- // }.bind(this));
- // },
- // loadPageButtonEvent: function(node, over, out, down, click){
- // node.addEvents({
- // "mouseover": function(){node.setStyles(this.css[over])}.bind(this),
- // "mouseout": function(){node.setStyles(this.css[out])}.bind(this),
- // "mousedown": function(){node.setStyles(this.css[down])}.bind(this),
- // "mouseup": function(){node.setStyles(this.css[out])}.bind(this),
- // "click": click
- // });
- // },
- // _loadPageNode: function(){
- // this.viewPageAreaNode.empty();
- // this.viewPageFirstNode = new Element("div", {"styles": this.css.viewPageFirstLastNode, "text": this.lp.firstPage}).inject(this.viewPageAreaNode);
- // this.viewPageContentNode = new Element("div", {"styles": this.css.viewPageContentNode}).inject(this.viewPageAreaNode);
- // this.viewPageLastNode = new Element("div", {"styles": this.css.viewPageFirstLastNode, "text": this.lp.lastPage}).inject(this.viewPageAreaNode);
- // this._loadPageCountNode();
- //
- // this.loadPageButtonEvent(this.viewPageFirstNode, "viewPageFirstLastNode_over", "viewPageFirstLastNode_up", "viewPageFirstLastNode_down", function(){
- // this.currentPage = 1;
- // this.loadCurrentPageData();
- // }.bind(this));
- // this.loadPageButtonEvent(this.viewPageLastNode, "viewPageFirstLastNode_over", "viewPageFirstLastNode_up", "viewPageFirstLastNode_down", function(){
- // this.currentPage = this.pages;
- // this.loadCurrentPageData();
- // }.bind(this));
- // },
- _loadPageNode : function(){
- this.viewPageAreaNode.empty();
- this.paging = new o2.widget.Paging(this.viewPageAreaNode, {
- style : this.options.skin && this.options.skin.pagingBar ? this.options.skin.pagingBar : "default",
- countPerPage: this.json.pageSize || this.options.perPageCount,
- visiblePages: this.viewJson.visiblePages ? this.viewJson.visiblePages.toInt() : 9,
- currentPage: this.currentPage,
- itemSize: this.count,
- pageSize: this.pages,
- hasNextPage: typeOf( this.viewJson.hasPreNextPage ) === "boolean" ? this.viewJson.hasPreNextPage : true,
- hasPrevPage: typeOf( this.viewJson.hasPreNextPage ) === "boolean" ? this.viewJson.hasPreNextPage : true,
- hasTruningBar: typeOf( this.viewJson.hasTruningBar ) === "boolean" ? this.viewJson.hasTruningBar : true,
- hasBatchTuring: typeOf( this.viewJson.hasBatchTuring ) === "boolean" ? this.viewJson.hasBatchTuring : true,
- hasFirstPage: typeOf( this.viewJson.hasFirstLastPage ) === "boolean" ? this.viewJson.hasFirstLastPage : true,
- hasLastPage: typeOf( this.viewJson.hasFirstLastPage ) === "boolean" ? this.viewJson.hasFirstLastPage : true,
- hasJumper: typeOf( this.viewJson.hasPageJumper ) === "boolean" ? this.viewJson.hasPageJumper : true,
- hiddenWithDisable: false,
- hiddenWithNoItem: true,
- text: {
- prePage: "",
- nextPage: "",
- firstPage: this.lp.firstPage,
- lastPage: this.lp.lastPage
- },
- onJumpingPage : function( pageNum, itemNum ){
- this.currentPage = pageNum;
- this.loadCurrentPageData();
- }.bind(this),
- onPostLoad : function () {
- if(this.setContentHeightFun)this.setContentHeightFun();
- }.bind(this)
- });
- this.paging.load();
- },
- _initPage: function(){
- this.count = this.bundleItems.length;
- var i = this.count/this.json.pageSize;
- this.pages = (i.toInt()<i) ? i.toInt()+1 : i;
- this.currentPage = 1;
- },
- lookup: function(data){
- this.getLookupAction(function(){
- if (this.json.application){
- var d = data || {};
- d.count = this.json.count;
- this.lookupAction.bundleView(this.json.id, d, function(json){
- this.bundleItems = json.data.valueList;
- this._initPage();
- if (this.bundleItems.length){
- this.loadCurrentPageData( function () {
- this.fireEvent("postLoad"); //用户配置的事件
- }.bind(this));
- }else{
- //this._loadPageNode();
- this.viewPageAreaNode.empty();
- if (this.loadingAreaNode){
- this.loadingAreaNode.destroy();
- this.loadingAreaNode = null;
- }
- this.fireEvent("postLoad"); //用户配置的事件
- }
- }.bind(this));
- }
- }.bind(this));
- },
- loadCurrentPageData: function( callback ){
- //是否需要在翻页的时候清空之前的items ?
- this.items = [];
- var p = this.currentPage;
- var d = {};
- var valueList = this.bundleItems.slice((p-1)*this.json.pageSize,this.json.pageSize*p);
- d.bundleList = valueList;
- while (this.viewTable.rows.length>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.fireEvent("loadView"); //options 传入的事件
- this.fireEvent("postLoadPage");
- if(callback)callback();
- }.bind(this));
- },
- loadData: function(){
- if (this.gridJson.length){
- // if( !this.options.paging ){
- this.gridJson.each(function(line, i){
- this.items.push(new MWF.xApplication.query.Query.Viewer.Item(this, line, null, i));
- }.bind(this));
- // }else{
- // this.loadPaging();
- // }
- }else{
- if (this.viewPageAreaNode) this.viewPageAreaNode.empty();
- }
- },
- loadPaging : function(){
- this.isItemsLoading = false;
- this.pageNumber = 0;
- this.isItemsLoaded = false;
- this.isSetedScroll = false;
- this.setScroll();
- this.loadDataByPaging()
- },
- setScroll : function(){
- if( this.options.paging && !this.isSetedScroll ){
- this.contentAreaNode.setStyle("overflow","auto");
- this.scrollContainerFun = function(){
- var scrollSize = this.contentAreaNode.getScrollSize();
- var clientSize = this.contentAreaNode.getSize();
- var scrollHeight = scrollSize.y - clientSize.y;
- //alert( "clientSize.y=" + clientSize.y + " scrollSize.y="+scrollSize.y + " this.contentAreaNode.scrollTop="+this.contentAreaNode.scrollTop);
- if (this.contentAreaNode.scrollTop + 150 > scrollHeight ) {
- if (!this.isItemsLoaded) this.loadDataByPaging();
- }
- }.bind(this);
- this.isSetedScroll = true;
- this.contentAreaNode.addEvent("scroll", this.scrollContainerFun )
- }
- },
- 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<to; i++ ){
- this.items.push(new MWF.xApplication.query.Query.Viewer.Item(this, this.gridJson[i], null, i));
- }
- this.isItemsLoading = false;
- this.pageNumber ++;
- if( to == this.gridJson.length )this.isItemsLoaded = true;
- }
- },
- loadGroupData: function(){
- if (this.selectTitleCell){
- this.selectTitleCell.set("html", "<span style='font-family: Webdings'>"+"<img src='/x_component_query_Query/$Viewer/"+this.options.style+"/icon/expand.png'/>"+"</span>");
- this.selectTitleCell.setStyle("cursor", "pointer");
- this.selectTitleCell.addEvent("click", this.expandOrCollapseAll.bind(this));
- }
- if (this.gridJson.length){
- var i = 0;
- this.gridJson.each(function(data){
- this.items.push(new MWF.xApplication.query.Query.Viewer.ItemCategory(this, data, i));
- i += data.list.length;
- }.bind(this));
- if (this.json.isExpand=="yes") this.expandOrCollapseAll();
- }else{
- if (this.viewPageAreaNode) this.viewPageAreaNode.empty();
- }
- },
- expandOrCollapseAll: function(){
- var icon = this.selectTitleCell.getElement("span");
- if (icon.get("html").indexOf("expand.png")===-1){
- this.items.each(function(item){
- item.collapse();
- icon.set("html", "<img src='/x_component_query_Query/$Viewer/"+this.options.style+"/icon/expand.png'/>");
- }.bind(this));
- }else{
- this.items.each(function(item, i){
- window.setTimeout(function(){
- item.expand();
- }.bind(this), 10*i+5);
- icon.set("html", "<img src='/x_component_query_Query/$Viewer/"+this.options.style+"/icon/down.png'/>");
- }.bind(this));
- }
- },
- getView: function(callback){
- this.getLookupAction(function(){
- if (this.json.application){
- this.getViewRes = this.lookupAction.getView(this.json.viewName, this.json.application, function(json){
- this.viewJson = JSON.decode(json.data.data);
- this.json = Object.merge(this.json, json.data);
- if (callback) callback();
- }.bind(this));
- // this.lookupAction.invoke({"name": "getView","async": true, "parameter": {"view": this.json.viewName, "application": this.json.application},"success": function(json){
- // this.viewJson = JSON.decode(json.data.data);
- // this.json = Object.merge(this.json, json.data);
- // //var viewData = JSON.decode(json.data.data);
- // if (callback) callback();
- // }.bind(this)});
- }else{
- this.getViewRes = this.lookupAction.getViewById(this.json.viewId, function(json){
- this.viewJson = JSON.decode(json.data.data);
- this.json.application = json.data.query;
- this.json = Object.merge(this.json, json.data);
- if (callback) callback();
- }.bind(this));
- }
- }.bind(this));
- },
- getLookupAction: function(callback){
- if (!this.lookupAction){
- this.lookupAction = MWF.Actions.get("x_query_assemble_surface");
- if (callback) callback();
- // var _self = this;
- // MWF.require("MWF.xDesktop.Actions.RestActions", function(){
- // this.lookupAction = new MWF.xDesktop.Actions.RestActions("", this.options.actionRoot, "");
- // this.lookupAction.getActions = function(actionCallback){
- // this.actions = _self.options.actions;
- // if (actionCallback) actionCallback();
- // };
- // if (callback) callback();
- // }.bind(this));
- }else{
- if (callback) callback();
- }
- },
- hide: function(){
- this.node.setStyle("display", "none");
- },
- reload: function(){
- this.node.setStyle("display", "block");
- if (this.loadingAreaNode) this.loadingAreaNode.setStyle("display", "block");
- this.filterItems.each(function(filter){
- filter.destroy();
- }.bind(this));
- this.filterItems = [];
- if (this.viewSearchInputNode) this.viewSearchInputNode.set("text", this.lp.searchKeywork);
- this.closeCustomSearch();
- this.viewAreaNode.empty();
- this.createViewNode({"filterList": this.json.filter ? this.json.filter.clone() : null});
- },
- getFilter: function(){
- var filterData = [];
- if (this.searchStatus==="custom"){
- if (this.filterItems.length){
- this.filterItems.each(function(filter){
- filterData.push(filter.data);
- }.bind(this));
- }
- }
- if (this.searchStatus==="default"){
- var key = this.viewSearchInputNode.get("value");
- if (key && key!==this.lp.searchKeywork){
- this.viewJson.customFilterList.each(function(entry){
- if (entry.formatType==="textValue"){
- var d = {
- "path": entry.path,
- "value": key,
- "formatType": entry.formatType,
- "logic": "or",
- "comparison": "like"
- };
- filterData.push(d);
- }
- if (entry.formatType==="numberValue"){
- var v = key.toFloat();
- if (!isNaN(v)){
- var d = {
- "path": entry.path,
- "value": v,
- "formatType": entry.formatType,
- "logic": "or",
- "comparison": "like"
- };
- filterData.push(d);
- }
- }
- }.bind(this));
- }
- }
- return (filterData.length) ? filterData : null;
- },
- getData: function(){
- if (this.selectedItems.length){
- var arr = [];
- this.selectedItems.each(function(item){
- arr.push(item.data);
- });
- return arr;
- }else{
- return [];
- }
- },
- _loadModuleEvents : function(){
- Object.each(this.viewJson.events, function(e, key){
- if (e.code){
- if (this.options.moduleEvents.indexOf(key)!==-1){
- this.addEvent(key, function(event, target){
- return this.Macro.fire(e.code, target || this, event);
- }.bind(this));
- }
- }
- }.bind(this));
- },
- _loadDomEvents: function(){
- Object.each(this.viewJson.events, function(e, key){
- if (e.code){
- if (this.options.moduleEvents.indexOf(key)===-1){
- this.node.addEvent(key, function(event){
- return this.Macro.fire(e.code, this, event);
- }.bind(this));
- }
- }
- }.bind(this));
- },
- //搜索相关开始
- createSearchNode: function(){
- if (this.viewJson.customFilterList && this.viewJson.customFilterList.length){
- this.searchStatus = "default";
- this.loadFilterSearch();
- }else{
- this.loadSimpleSearch();
- }
- },
- loadSimpleSearch: function(){
- return false;
- this.searchSimpleNode = new Element("div", {"styles": this.css.searchSimpleNode}).inject(this.searchAreaNode);
- this.searchSimpleButtonNode = new Element("div", {"styles": this.css.searchSimpleButtonNode}).inject(this.searchSimpleNode);
- this.searchSimpleInputNode = new Element("input", {"type":"text", "styles": this.css.searchSimpleInputNode, "value": this.lp.searchKeywork}).inject(this.searchSimpleNode);
- this.searchSimpleButtonNode.addEvent("click", function(){
- this.search();
- }.bind(this));
- this.searchSimpleInputNode.addEvents({
- "focus": function(){
- if (this.searchSimpleInputNode.get("value")===this.lp.searchKeywork) this.searchSimpleInputNode.set("value", "");
- }.bind(this),
- "blur": function(){if (!this.searchSimpleInputNode.get("value")) this.searchSimpleInputNode.set("value", this.lp.searchKeywork);}.bind(this),
- "keydown": function(e){
- if (e.code===13) this.search();
- }.bind(this)
- });
- },
- search: function(){
- if (this.gridJson){
- var key = this.searchSimpleInputNode.get("value");
- var rows = this.viewTable.rows;
- var first = (this.json.isTitle!=="no") ? 1 : 0;
- for (var i = first; i<rows.length; i++){
- var tr = rows[i];
- if (!key || key==this.lp.searchKeywork){
- if (tr.getStyle("display")==="none") tr.setStyle("display", "table-row");
- }else{
- if (tr.get("text").indexOf(key)!==-1){
- if (tr.getStyle("display")==="none") tr.setStyle("display", "table-row");
- }else{
- if (tr.getStyle("display")!=="none") tr.setStyle("display", "none");
- }
- }
- }
- //if (this.viewPageAreaNode) this.viewPageAreaNode.hide();
- }
- },
- loadFilterSearch: function(){
- this.viewSearchCustomActionNode = new Element("div", {"styles": this.css.viewFilterSearchCustomActionNode, "text": this.lp.customSearch}).inject(this.searchAreaNode);
- this.viewSearchInputAreaNode = new Element("div", {"styles": this.css.viewFilterSearchInputAreaNode}).inject(this.searchAreaNode);
- this.viewSearchIconNode = new Element("div", {"styles": this.css.viewFilterSearchIconNode}).inject(this.viewSearchInputAreaNode);
- this.viewSearchInputBoxNode = new Element("div", {"styles": this.css.viewFilterSearchInputBoxNode}).inject(this.viewSearchInputAreaNode);
- this.viewSearchInputNode = new Element("input", {"styles": this.css.viewFilterSearchInputNode, "value": this.lp.searchKeywork}).inject(this.viewSearchInputBoxNode);
- this.viewSearchInputNode.addEvents({
- "focus": function(){
- if (this.viewSearchInputNode.get("value")===this.lp.searchKeywork) this.viewSearchInputNode.set("value", "");
- }.bind(this),
- "blur": function(){if (!this.viewSearchInputNode.get("value")) this.viewSearchInputNode.set("value", this.lp.searchKeywork);}.bind(this),
- "keydown": function(e){
- if (e.code===13) this.searchView();
- }.bind(this)
- });
- this.viewSearchIconNode.addEvents({
- "click": function(){this.searchView();}.bind(this)
- });
- this.viewSearchCustomActionNode.addEvents({
- "click": function(){this.loadCustomSearch();}.bind(this)
- });
- },
- searchView: function(){
- if (this.viewJson.customFilterList) {
- var key = this.viewSearchInputNode.get("value");
- if (key && key !== this.lp.searchKeywork) {
- var filterData = this.json.filter ? this.json.filter : [];
- this.filterItems = [];
- this.viewJson.customFilterList.each(function (entry) {
- if (entry.formatType === "textValue") {
- var d = {
- "path": entry.path,
- "value": key,
- "formatType": entry.formatType,
- "logic": "or",
- "comparison": "like"
- };
- filterData.push(d);
- this.filterItems.push({"data":d});
- }
- if (entry.formatType === "numberValue") {
- var v = key.toFloat();
- if (!isNaN(v)) {
- var d = {
- "path": entry.path,
- "value": v,
- "formatType": entry.formatType,
- "logic": "or",
- "comparison": "like"
- };
- filterData.push(d);
- this.filterItems.push({"data":d});
- }
- }
- }.bind(this));
- this.createViewNode({"filterList": filterData});
- }else{
- this.createViewNode();
- }
- }
- },
- searchCustomView: function(){
- if (this.filterItems.length){
- var filterData = this.json.filter ? this.json.filter.clone() : [];
- this.filterItems.each(function(filter){
- filterData.push(filter.data);
- }.bind(this));
- this.createViewNode({"filterList": filterData});
- }else{
- this.createViewNode({"filterList": this.json.filter ? this.json.filter.clone() : null});
- }
- },
- loadCustomSearch: function(){
- this.viewSearchIconNode.setStyle("display", "none");
- this.viewSearchInputBoxNode.setStyle("display", "none");
- this.viewSearchCustomActionNode.setStyle("display", "none");
- if (!this.searchMorph) this.searchMorph = new Fx.Morph(this.viewSearchInputAreaNode);
- var x = this.viewSearchInputAreaNode.getParent().getSize().x-2-20;
- this.css.viewFilterSearchInputAreaNode_custom.width = ""+x+"px";
- var x1 = this.viewSearchInputAreaNode.getSize().x-2;
- this.viewSearchInputAreaNode.setStyle("width", ""+x1+"px");
- this.searchMorph.start(this.css.viewFilterSearchInputAreaNode_custom).chain(function(){
- this.searchStatus = "custom";
- this.css.viewFilterSearchInputAreaNode_custom.width = "auto";
- this.viewSearchInputAreaNode.setStyle("width", "auto");
- if (this.viewSearchCustomContentNode){
- this.viewSearchCustomCloseActionNode.setStyle("display", "block");
- this.viewSearchCustomContentNode.setStyle("display", "block");
- }else{
- this.loadCustomSearchContent();
- }
- this.setContentHeightFun();
- }.bind(this));
- this.searchCustomView();
- },
- loadCustomSearchContent: function(){
- this.viewSearchCustomCloseActionNode = new Element("div", {"styles": this.css.viewFilterSearchCustomCloseActionNode}).inject(this.viewSearchInputAreaNode);
- this.viewSearchCustomContentNode = new Element("div", {"styles": this.css.viewFilterSearchCustomContentNode}).inject(this.viewSearchInputAreaNode);
- this.viewSearchCustomPathContentNode = new Element("div", {"styles": this.css.viewFilterSearchCustomPathContentNode}).inject(this.viewSearchCustomContentNode);
- this.viewSearchCustomComparisonContentNode = new Element("div", {"styles": this.css.viewFilterSearchCustomComparisonContentNode}).inject(this.viewSearchCustomContentNode);
- this.viewSearchCustomValueContentNode = new Element("div", {"styles": this.css.viewFilterSearchCustomValueContentNode}).inject(this.viewSearchCustomContentNode);
- this.viewSearchCustomAddContentNode = new Element("div", {"styles": this.css.viewFilterSearchCustomAddContentNode}).inject(this.viewSearchCustomContentNode);
- this.viewSearchCustomAddIconNode = new Element("div", {"styles": this.css.viewFilterSearchCustomAddIconNode}).inject(this.viewSearchCustomAddContentNode);
- this.viewSearchCustomFilterContentNode = new Element("div", {"styles": this.css.viewFilterSearchCustomFilterContentNode}).inject(this.viewSearchCustomContentNode);
- this.loadViewSearchCustomList();
- this.viewSearchCustomCloseActionNode.addEvents({
- "click": function(){this.closeCustomSearch();}.bind(this)
- });
- this.viewSearchCustomAddIconNode.addEvents({
- "click": function(){this.viewSearchCustomAddToFilter();}.bind(this)
- });
- },
- loadViewSearchCustomList: function(){
- this.viewSearchCustomPathListNode = new Element("select", {
- "styles": this.css.viewFilterSearchCustomPathListNode,
- "multiple": true
- }).inject(this.viewSearchCustomPathContentNode);
- this.viewSearchCustomComparisonListNode = new Element("select", {
- "styles": this.css.viewFilterSearchCustomComparisonListNode,
- "multiple": true
- }).inject(this.viewSearchCustomComparisonContentNode);
- this.viewJson.customFilterList.each(function(entry){
- var option = new Element("option", {
- "style": this.css.viewFilterSearchOptionNode,
- "value": entry.path,
- "text": entry.title
- }).inject(this.viewSearchCustomPathListNode);
- option.store("entry", entry);
- }.bind(this));
- this.viewSearchCustomPathListNode.addEvent("change", function(){
- this.loadViewSearchCustomComparisonList();
- }.bind(this));
- },
- loadViewSearchCustomComparisonList: function(){
- var idx = this.viewSearchCustomPathListNode.selectedIndex;
- var option = this.viewSearchCustomPathListNode.options[idx];
- var entry = option.retrieve("entry");
- if (entry){
- var selectableList = this.getCustomSelectScriptResult(entry);
- switch (entry.formatType){
- case "numberValue":
- this.loadComparisonSelect(this.lp.numberFilter);
- if( selectableList.length > 0 ){
- this.loadViewSerchCustomSelectByScript(selectableList)
- }else{
- this.loadViewSearchCustomValueNumberInput();
- }
- break;
- case "dateTimeValue":
- this.loadComparisonSelect(this.lp.dateFilter);
- if( selectableList.length > 0 ){
- this.loadViewSerchCustomSelectByScript(selectableList)
- }else {
- this.loadViewSearchCustomValueDateTimeInput();
- }
- break;
- case "dateValue":
- this.loadComparisonSelect(this.lp.dateFilter);
- if( selectableList.length > 0 ){
- this.loadViewSerchCustomSelectByScript(selectableList)
- }else {
- this.loadViewSearchCustomValueDateInput();
- }
- break;
- case "timeValue":
- this.loadComparisonSelect(this.lp.dateFilter);
- if( selectableList.length > 0 ){
- this.loadViewSerchCustomSelectByScript(selectableList)
- }else {
- this.loadViewSearchCustomValueTimeInput();
- }
- break;
- case "booleanValue":
- this.loadComparisonSelect(this.lp.booleanFilter);
- if( selectableList.length > 0 ){
- this.loadViewSerchCustomSelectByScript(selectableList)
- }else {
- this.loadViewSearchCustomValueBooleanInput();
- }
- break;
- default:
- this.loadComparisonSelect(this.lp.textFilter);
- if( selectableList.length > 0 ){
- this.loadViewSerchCustomSelectByScript(selectableList)
- }else {
- this.loadViewSearchCustomValueTextInput();
- }
- }
- }
- },
- getCustomSelectScriptResult : function( entry ){
- var scriptResult = [];
- if( entry.valueType === "script" ){
- if( entry.valueScript && entry.valueScript.code ){
- var result = this.Macro.exec(entry.valueScript.code, this);
- var array = typeOf( result ) === "array" ? result : [result];
- for( var i=0; i<array.length; i++ ){
- if( array[i].indexOf( "|" ) > -1 ){
- var arr = array[i].split("|");
- scriptResult.push({ "text" : arr[0], "value" : arr[1] })
- }else{
- scriptResult.push({ "text" : array[i], "value" : array[i] })
- }
- }
- }
- }
- return scriptResult;
- },
- loadViewSerchCustomSelectByScript: function( array ){
- this.viewSearchCustomValueContentNode.empty();
- this.viewSearchCustomValueNode = new Element("select", {
- "styles": this.css.viewFilterSearchCustomComparisonListNode,
- "multiple": true
- }).inject(this.viewSearchCustomValueContentNode);
- array.each(function( v ){
- var option = new Element("option", {
- "style": this.css.viewFilterSearchOptionNode,
- "value": v.value,
- "text": v.text,
- "selected" : array.length === 1
- }).inject(this.viewSearchCustomValueNode);
- }.bind(this));
- },
- loadViewSearchCustomValueNumberInput: function(){
- this.viewSearchCustomValueContentNode.empty();
- this.viewSearchCustomValueNode = new Element("input", {
- "styles": this.css.viewFilterSearchCustomValueNode,
- "type": "number"
- }).inject(this.viewSearchCustomValueContentNode);
- },
- loadViewSearchCustomValueDateTimeInput: function(){
- this.viewSearchCustomValueContentNode.empty();
- this.viewSearchCustomValueNode = new Element("input", {
- "styles": this.css.viewFilterSearchCustomValueNode,
- "type": "text",
- "readonly": true
- }).inject(this.viewSearchCustomValueContentNode);
- MWF.require("MWF.widget.Calendar", function(){
- this.calendar = new MWF.widget.Calendar(this.viewSearchCustomValueNode, {
- "style": "xform",
- "isTime": true,
- "secondEnable" : true,
- "target": this.container,
- "format": "db"
- });
- }.bind(this));
- },
- loadViewSearchCustomValueDateInput: function(){
- this.viewSearchCustomValueContentNode.empty();
- this.viewSearchCustomValueNode = new Element("input", {
- "styles": this.css.viewFilterSearchCustomValueNode,
- "type": "text",
- "readonly": true
- }).inject(this.viewSearchCustomValueContentNode);
- MWF.require("MWF.widget.Calendar", function(){
- this.calendar = new MWF.widget.Calendar(this.viewSearchCustomValueNode, {
- "style": "xform",
- "isTime": false,
- "target": this.container,
- "format": "%Y-%m-%d"
- });
- }.bind(this));
- },
- loadViewSearchCustomValueTimeInput: function(){
- this.viewSearchCustomValueContentNode.empty();
- this.viewSearchCustomValueNode = new Element("input", {
- "styles": this.css.viewFilterSearchCustomValueNode,
- "type": "text",
- "readonly": true
- }).inject(this.viewSearchCustomValueContentNode);
- MWF.require("MWF.widget.Calendar", function(){
- this.calendar = new MWF.widget.Calendar(this.viewSearchCustomValueNode, {
- "style": "xform",
- "timeOnly": true,
- "target": this.container,
- "format": "%H:%M:%S"
- });
- }.bind(this));
- },
- loadViewSearchCustomValueBooleanInput: function(){
- this.viewSearchCustomValueContentNode.empty();
- this.viewSearchCustomValueNode = new Element("select", {
- "styles": this.css.viewFilterSearchCustomValueSelectNode,
- "multiple": true
- }).inject(this.viewSearchCustomValueContentNode);
- new Element("option", {"value": "true","text": this.lp.yes}).inject(this.viewSearchCustomValueNode);
- new Element("option", {"value": "false","text": this.lp.no}).inject(this.viewSearchCustomValueNode);
- },
- loadViewSearchCustomValueTextInput: function(){
- this.viewSearchCustomValueContentNode.empty();
- this.viewSearchCustomValueNode = new Element("textarea", {
- "styles": this.css.viewFilterSearchCustomValueNode
- }).inject(this.viewSearchCustomValueContentNode);
- },
- loadComparisonSelect:function(obj){
- this.viewSearchCustomComparisonListNode.empty();
- Object.each(obj, function(v, k){
- var option = new Element("option", {"value": k,"text": v}).inject(this.viewSearchCustomComparisonListNode);
- }.bind(this));
- },
- closeCustomSearch: function(){
- if (this.viewSearchCustomContentNode && this.viewSearchCustomContentNode.getStyle("display")==="block"){
- this.viewSearchCustomCloseActionNode.setStyle("display", "none");
- this.viewSearchCustomContentNode.setStyle("display", "none");
- var x = this.viewSearchInputAreaNode.getParent().getSize().x;
- x1 = x-2-10-90;
- this.css.viewFilterSearchInputAreaNode.width = ""+x1+"px";
- var x1 = this.viewSearchInputAreaNode.getSize().x-2;
- this.viewSearchInputAreaNode.setStyle("width", ""+x1+"px");
- if (!this.searchMorph) this.searchMorph = new Fx.Morph(this.viewSearchInputAreaNode);
- this.searchMorph.start(this.css.viewFilterSearchInputAreaNode).chain(function(){
- this.searchStatus = "default";
- this.css.viewFilterSearchInputAreaNode.width = "auto";
- this.viewSearchInputAreaNode.setStyle("margin-right", "90px");
- this.viewSearchIconNode.setStyle("display", "block");
- this.viewSearchInputBoxNode.setStyle("display", "block");
- this.viewSearchCustomActionNode.setStyle("display", "block");
- this.setContentHeightFun();
- }.bind(this));
- this.createViewNode({"filterList": this.json.filter ? this.json.filter.clone() : null});
- }
- },
- viewSearchCustomAddToFilter: function(){
- var pathIdx = this.viewSearchCustomPathListNode.selectedIndex;
- var comparisonIdx = this.viewSearchCustomComparisonListNode.selectedIndex;
- if (pathIdx===-1){
- MWF.xDesktop.notice("error", {"x": "left", "y": "top"}, this.lp.filterErrorTitle, this.viewSearchCustomPathListNode, {"x": 0, "y": 85});
- return false;
- }
- if (comparisonIdx===-1){
- MWF.xDesktop.notice("error", {"x": "left", "y": "top"}, this.lp.filterErrorComparison, this.viewSearchCustomComparisonListNode, {"x": 0, "y": 85});
- return false;
- }
- var pathOption = this.viewSearchCustomPathListNode.options[pathIdx];
- var entry = pathOption.retrieve("entry");
- if (entry){
- var pathTitle = entry.title;
- var path = entry.path;
- var comparison = this.viewSearchCustomComparisonListNode.options[comparisonIdx].get("value");
- var comparisonTitle = this.viewSearchCustomComparisonListNode.options[comparisonIdx].get("text");
- var value = "";
- if( entry.valueType === "script" && entry.valueScript && entry.valueScript.code ){
- var idx = this.viewSearchCustomValueNode.selectedIndex;
- if (idx!==-1){
- var v = this.viewSearchCustomValueNode.options[idx].get("value");
- value = entry.formatType === "booleanValue" ? (v==="true") : v;
- }
- }else{
- switch (entry.formatType){
- case "numberValue":
- value = this.viewSearchCustomValueNode.get("value");
- break;
- case "dateTimeValue":
- value = this.viewSearchCustomValueNode.get("value");
- break;
- case "booleanValue":
- var idx = this.viewSearchCustomValueNode.selectedIndex;
- if (idx!==-1){
- var v = this.viewSearchCustomValueNode.options[idx].get("value");
- value = (v==="true");
- }
- break;
- default:
- value = this.viewSearchCustomValueNode.get("value");
- }
- }
- if (value===""){
- MWF.xDesktop.notice("error", {"x": "left", "y": "top"}, this.lp.filterErrorValue, this.viewSearchCustomValueContentNode, {"x": 0, "y": 85});
- return false;
- }
- this.filterItems.push(new MWF.xApplication.query.Query.Viewer.Filter(this, {
- "logic": "and",
- "path": path,
- "title": pathTitle,
- "comparison": comparison,
- "comparisonTitle": comparisonTitle,
- "value": value,
- "formatType": (entry.formatType=="datetimeValue") ? "dateTimeValue": entry.formatType
- }, this.viewSearchCustomFilterContentNode));
- this.searchCustomView();
- }
- },
- searchViewRemoveFilter: function(filter){
- this.filterItems.erase(filter);
- filter.destroy();
- this.searchCustomView()
- },
- //搜索相关结束
- //api 使用 开始
- getParentEnvironment : function(){
- return this.parentMacro ? this.parentMacro.environment : null;
- },
- getViewInfor : function(){
- return this.json;
- },
- getPageInfor : function(){
- return {
- pages : this.pages,
- perPageCount : this.options.perPageCount,
- currentPageNumber : this.currentPage
- };
- },
- getPageData : function () {
- return this.gridJson;
- },
- toPage : function( pageNumber, callback ){
- this.currentPage = pageNumber;
- this.loadCurrentPageData( callback );
- },
- getSelectedData : function(){
- return this.getData();
- },
- selectAll : function(){
- var flag = this.json.select || this.viewJson.select || "none";
- if ( flag==="multi"){
- this.items.each( function (item) {
- if( item.clazzType === "item" ){
- item.selected();
- }else{
- item.expand();
- if( item.items ){
- item.items.each( function (it) {
- it.selected();
- })
- }
- }
- })
- }
- },
- unSelectAll : function(){
- var flag = this.json.select || this.viewJson.select || "none";
- if ( flag==="multi"){
- this.items.each( function (item) {
- if( item.clazzType === "item" ){
- item.unSelected();
- }else{
- if(item.items){
- item.items.each( function (it) {
- it.unSelected();
- })
- }
- }
- })
- }
- },
- setFilter : function( filter ){
- if( !filter )filter = [];
- if( typeOf( filter ) === "object" )filter = [ filter ];
- this.json.filter = filter;
- if( this.viewAreaNode ){
- this.createViewNode({"filterList": this.json.filter ? this.json.filter.clone() : null});
- }
- },
- switchView : function( json ){
- debugger;
- // json = {
- // "application": application,
- // "viewName": viewName,
- // "isTitle": "yes",
- // "select": "none",
- // "titleStyles": titleStyles,
- // "itemStyles": itemStyles,
- // "isExpand": "no",
- // "filter": filter
- // }
- this.node.setStyle("display", "block");
- if (this.loadingAreaNode) this.loadingAreaNode.setStyle("display", "block");
- this.searchMorph = null;
- this.viewSearchCustomContentNode = null;
- var newJson = Object.merge( Object.clone(this.originalJson), json );
- this.container.empty();
- this.initialize( this.container, newJson, Object.clone(this.options), this.app, this.parentMacro);
- },
- confirm: function (type, e, title, text, width, height, ok, cancel, callback, mask, style) {
- this.app.confirm(type, e, title, text, width, height, ok, cancel, callback, mask, style)
- },
- alert: function (type, title, text, width, height) {
- this.app.alert(type, "center", title, text, width, height);
- },
- notice: function (content, type, target, where, offset, option) {
- this.app.notice(content, type, target, where, offset, option)
- }
- //api 使用 结束
- });
- MWF.xApplication.query.Query.Viewer.Item = new Class({
- initialize: function(view, data, prev, i){
- this.view = view;
- this.data = data;
- this.css = this.view.css;
- this.isSelected = false;
- this.prev = prev;
- this.idx = i;
- this.clazzType = "item";
- this.load();
- },
- load: function(){
- this.view.fireEvent("queryLoadItemRow", [null, this]);
- this.node = new Element("tr", {"styles": this.css.viewContentTrNode});
- if (this.prev){
- this.node.inject(this.prev.node, "after");
- }else{
- this.node.inject(this.view.viewTable);
- }
- //if (this.view.json.select==="single" || this.view.json.select==="multi"){
- this.selectTd = new Element("td", {"styles": this.css.viewContentTdNode}).inject(this.node);
- this.selectTd.setStyles({"cursor": "pointer"});
- if (this.view.json.itemStyles) this.selectTd.setStyles(this.view.json.itemStyles);
- //}
- //序号
- if (this.view.viewJson.isSequence==="yes"){
- this.sequenceTd = new Element("td", {"styles": this.css.viewContentTdNode}).inject(this.node);
- this.sequenceTd.setStyle("width", "10px");
- var s= 1+this.view.json.pageSize*(this.view.currentPage-1)+this.idx;
- this.sequenceTd.set("text", s);
- }
- Object.each(this.view.entries, function(c, k){
- var cell = this.data.data[k];
- if (cell === undefined) cell = "";
- //if (cell){
- if (this.view.hideColumns.indexOf(k)===-1){
- var td = new Element("td", {"styles": this.css.viewContentTdNode}).inject(this.node);
- if (k!== this.view.viewJson.group.column){
- //var v = (this.view.entries[k].code) ? MWF.Macro.exec(this.view.entries[k].code, {"value": cell, "gridData": this.view.gridJson, "data": this.view.viewData, "entry": this.data}) : cell;
- var v = cell;
- if (c.isHtml){
- td.set("html", v);
- }else{
- td.set("text", v);
- }
- }
- if (this.view.openColumns.indexOf(k)!==-1){
- this.setOpenWork(td, c)
- }
- if (this.view.json.itemStyles) td.setStyles(this.view.json.itemStyles);
- }
- //}
- }.bind(this));
- // Object.each(this.data.data, function(cell, k){
- // if (this.view.hideColumns.indexOf(k)===-1){
- // var td = new Element("td", {"styles": this.css.viewContentTdNode}).inject(this.node);
- // if (k!== this.view.viewJson.group.column){
- // var v = (this.view.entries[k].code) ? MWF.Macro.exec(this.view.entries[k].code, {"value": cell, "gridData": this.view.gridJson, "data": this.view.viewData, "entry": this.data}) : cell;
- // td.set("text", v);
- // }
- // if (this.view.openColumns.indexOf(k)!==-1){
- // this.setOpenWork(td)
- // }
- // if (this.view.json.itemStyles) td.setStyles(this.view.json.itemStyles);
- // }
- // }.bind(this));
- this.setEvent();
- this.view.fireEvent("postLoadItemRow", [null, this]);
- },
- setOpenWork: function(td, column){
- td.setStyle("cursor", "pointer");
- if( column.clickCode ){
- // if( !this.view.Macro ){
- // MWF.require("MWF.xScript.Macro", function () {
- // this.view.businessData = {};
- // this.view.Macro = new MWF.Macro.PageContext(this.view);
- // }.bind(this), false);
- // }
- td.addEvent("click", function( ev ){
- var result = this.view.Macro.fire(column.clickCode, this, ev);
- ev.stopPropagation();
- return result;
- }.bind(this));
- }else{
- if (this.view.json.type==="cms"){
- td.addEvent("click", function(ev){
- this.openCms(ev)
- ev.stopPropagation();
- }.bind(this));
- }else{
- td.addEvent("click", function(ev){
- this.openWorkAndCompleted(ev)
- ev.stopPropagation();
- }.bind(this));
- }
- }
- },
- openCms: function(e){
- var options = {"documentId": this.data.bundle};
- this.view.fireEvent("openDocument", [options, this]); //options 传入的事件
- layout.desktop.openApplication(e, "cms.Document", options);
- },
- openWorkAndCompleted: function(e){
- MWF.Actions.get("x_processplatform_assemble_surface").listWorkByJob(this.data.bundle, function(json){
- var workCompletedCount = json.data.workCompletedList.length;
- var workCount = json.data.workList.length;
- var count = workCount+workCompletedCount;
- if (count===1){
- if (workCompletedCount) {
- this.openWorkCompleted(json.data.workCompletedList[0].id, e);
- }else{
- this.openWork(json.data.workList[0].id, e);
- }
- }else if (count>1){
- var worksAreaNode = this.createWorksArea();
- json.data.workCompletedList.each(function(work){
- this.createWorkCompletedNode(work, worksAreaNode);
- }.bind(this));
- json.data.workList.each(function(work){
- this.createWorkNode(work, worksAreaNode);
- }.bind(this));
- this.showWorksArea(worksAreaNode, e);
- }else{
- }
- }.bind(this));
- },
- createWorkNode: function(work, worksAreaNode){
- var worksAreaContentNode = worksAreaNode.getLast();
- var node = new Element("div", {"styles": this.css.workAreaNode}).inject(worksAreaContentNode);
- var actionNode = new Element("div", {"styles": this.css.workAreaActionNode, "text": this.view.lp.open}).inject(node);
- actionNode.store("workId", work.id);
- actionNode.addEvent("click", function(e){
- this.openWork(e.target.retrieve("workId"), e);
- this.mask.hide();
- worksAreaNode.destroy();
- }.bind(this));
- var areaNode = new Element("div", {"styles": this.css.workAreaLeftNode}).inject(node);
- var titleNode = new Element("div", {"styles": this.css.workAreaTitleNode, "text": work.title}).inject(areaNode);
- var contentNode = new Element("div", {"styles": this.css.workAreaContentNode}).inject(areaNode);
- new Element("div", {"styles": this.css.workAreaContentTitleNode, "text": this.view.lp.activity+": "}).inject(contentNode);
- new Element("div", {"styles": this.css.workAreaContentTextNode, "text": work.activityName}).inject(contentNode);
- var taskUsers = [];
- MWF.Actions.get("x_processplatform_assemble_surface").listTaskByWork(work.id, function(json){
- json.data.each(function(task){
- taskUsers.push(MWF.name.cn(task.person));
- }.bind(this));
- new Element("div", {"styles": this.css.workAreaContentTitleNode, "text": this.view.lp.taskPeople+": "}).inject(contentNode);
- new Element("div", {"styles": this.css.workAreaContentTextNode, "text": taskUsers.join(", ")}).inject(contentNode);
- }.bind(this));
- },
- createWorkCompletedNode: function(work, worksAreaNode){
- var worksAreaContentNode = worksAreaNode.getLast();
- var node = new Element("div", {"styles": this.css.workAreaNode}).inject(worksAreaContentNode);
- var actionNode = new Element("div", {"styles": this.css.workAreaActionNode, "text": this.view.lp.open}).inject(node);
- actionNode.store("workId", work.id);
- actionNode.addEvent("click", function(e){
- this.mask.hide();
- var id = e.target.retrieve("workId");
- worksAreaNode.destroy();
- this.openWorkCompleted(id, e);
- }.bind(this));
- var areaNode = new Element("div", {"styles": this.css.workAreaLeftNode}).inject(node);
- var titleNode = new Element("div", {"styles": this.css.workAreaTitleNode, "text": work.title}).inject(areaNode);
- var contentNode = new Element("div", {"styles": this.css.workAreaContentNode}).inject(areaNode);
- new Element("div", {"styles": this.css.workAreaContentTitleNode, "text": this.view.lp.activity+": "}).inject(contentNode);
- new Element("div", {"styles": this.css.workAreaContentTextNode, "text": this.view.lp.processCompleted}).inject(contentNode);
- },
- createWorksArea: function(){
- var worksAreaNode = new Element("div", {"styles": this.css.worksAreaNode});
- var worksAreaTitleNode = new Element("div", {"styles": this.css.worksAreaTitleNode}).inject(worksAreaNode);
- var worksAreaTitleCloseNode = new Element("div", {"styles": this.css.worksAreaTitleCloseNode}).inject(worksAreaTitleNode);
- worksAreaTitleCloseNode.addEvent("click", function(e){
- this.mask.hide();
- e.target.getParent().getParent().destroy();
- }.bind(this));
- var worksAreaContentNode = new Element("div", {"styles": this.css.worksAreaContentNode}).inject(worksAreaNode);
- return worksAreaNode;
- },
- showWorksArea: function(node, e){
- MWF.require("MWF.widget.Mask", null, false);
- this.mask = new MWF.widget.Mask({"style": "desktop", "loading": false});
- this.mask.loadNode(this.view.container);
- node.inject(this.view.node);
- this.setWorksAreaPosition(node, e.target);
- },
- setWorksAreaPosition: function(node, td){
- var p = td.getPosition(this.view.container);
- var containerS = this.view.container.getSize();
- var containerP = this.view.container.getPosition(this.view.container.getOffsetParent());
- var s = node.getSize();
- var offX = p.x+s.x-containerS.x;
- offX = (offX>0) ? offX+20 : 0;
- var offY = p.y+s.y-containerS.y;
- offY = (offY>0) ? offY+5 : 0;
- node.position({
- "relativeTo": td,
- "position": "lefttop",
- "edge": "lefttop",
- "offset": {
- "x": 0-offX,
- "y": 0-offY
- }
- });
- },
- openWork: function(id, e){
- var options = {"workId": id};
- this.view.fireEvent("openDocument", [options, this]); //options 传入的事件
- layout.desktop.openApplication(e, "process.Work", options);
- },
- openWorkCompleted: function(id, e){
- var options = {"workCompletedId": id};
- this.view.fireEvent("openDocument", [options, this]); //options 传入的事件
- layout.desktop.openApplication(e, "process.Work", options);
- },
- setEvent: function(){
- var flag = this.view.json.select || this.view.viewJson.select || "none";
- if ( flag ==="single" || flag==="multi"){
- this.node.addEvents({
- "mouseover": function(){
- if (!this.isSelected){
- var iconName = "checkbox";
- if (flag==="single") iconName = "radiobox";
- this.selectTd.setStyles({"background": "url("+"/x_component_query_Query/$Viewer/default/icon/"+iconName+".png) center center no-repeat"});
- }
- }.bind(this),
- "mouseout": function(){
- if (!this.isSelected) this.selectTd.setStyles({"background": "transparent"});
- }.bind(this),
- "click": function(){this.select();}.bind(this)
- });
- }
- },
- select: function(){
- var flag = this.view.json.select || this.view.viewJson.select || "none";
- if (this.isSelected){
- if (flag==="single"){
- this.unSelectedSingle();
- }else{
- this.unSelected();
- }
- }else{
- if (flag==="single"){
- this.selectedSingle();
- }else{
- this.selected();
- }
- }
- this.view.fireEvent("select"); //options 传入的事件
- },
- selected: function(){
- this.view.selectedItems.push(this);
- this.selectTd.setStyles({"background": "url("+"/x_component_query_Query/$Viewer/default/icon/checkbox_checked.png) center center no-repeat"});
- this.node.setStyles(this.css.viewContentTrNode_selected);
- this.isSelected = true;
- this.view.fireEvent("selectRow", [this]);
- },
- unSelected: function(){
- this.view.selectedItems.erase(this);
- this.selectTd.setStyles({"background": "transparent"});
- this.node.setStyles(this.css.viewContentTrNode);
- this.isSelected = false;
- this.view.fireEvent("unselectRow", [this]);
- },
- selectedSingle: function(){
- if (this.view.currentSelectedItem) this.view.currentSelectedItem.unSelectedSingle();
- this.view.selectedItems = [this];
- this.view.currentSelectedItem = this;
- this.selectTd.setStyles({"background": "url("+"/x_component_query_Query/$Viewer/default/icon/radiobox_checked.png) center center no-repeat"});
- this.node.setStyles(this.css.viewContentTrNode_selected);
- this.isSelected = true;
- this.view.fireEvent("selectRow", [this]);
- },
- unSelectedSingle: function(){
- this.view.selectedItems = [];
- this.view.currentSelectedItem = null;
- this.selectTd.setStyles({"background": "transparent"});
- this.node.setStyles(this.css.viewContentTrNode);
- this.isSelected = false;
- this.view.fireEvent("unselectRow", [this]);
- }
- });
- MWF.xApplication.query.Query.Viewer.ItemCategory = new Class({
- initialize: function(view, data, i){
- this.view = view;
- this.data = data;
- this.css = this.view.css;
- this.items = [];
- this.loadChild = false;
- this.idx = i;
- this.clazzType = "category";
- this.load();
- },
- load: function(){
- this.view.fireEvent("queryLoadCategoryRow", [null, this]);
- this.node = new Element("tr", {"styles": this.css.viewContentTrNode}).inject(this.view.viewTable);
- //if (this.view.json.select==="single" || this.view.json.select==="multi"){
- this.selectTd = new Element("td", {"styles": this.css.viewContentCategoryTdNode}).inject(this.node);
- if (this.view.json.itemStyles) this.selectTd.setStyles(this.view.json.itemStyles);
- //}
- this.categoryTd = new Element("td", {
- "styles": this.css.viewContentCategoryTdNode,
- "colspan": this.view.viewJson.selectList.length+1
- }).inject(this.node);
- this.groupColumn = null;
- for (var c = 0; c<this.view.viewJson.selectList.length; c++){
- if (this.view.viewJson.selectList[c].column === this.view.viewJson.group.column){
- this.groupColumn = this.view.viewJson.selectList[c];
- break;
- }
- }
- if (this.groupColumn){
- //var text = (this.groupColumn.code) ? MWF.Macro.exec(this.groupColumn.code, {"value": this.data.group, "gridData": this.view.gridJson, "data": this.view.viewData, "entry": this.data}) : this.data.group;
- var text = this.data.group;
- }else{
- var text = this.data.group;
- }
- this.categoryTd.set("html", "<span style='font-family: Webdings'><img src='/x_component_query_Query/$Viewer/"+this.view.options.style+"/icon/expand.png'/></span> "+text);
- if (this.view.json.itemStyles) this.categoryTd.setStyles(this.view.json.itemStyles);
- this.setEvent();
- this.view.fireEvent("postLoadCategoryRow", [null, this]);
- },
- setEvent: function(){
- //if (this.selectTd){
- this.node.addEvents({
- "click": function(){this.expandOrCollapse();}.bind(this)
- });
- //}
- },
- expandOrCollapse: function(){
- var t = this.node.getElement("span").get("html");
- if (t.indexOf("expand.png")===-1){
- this.collapse();
- }else{
- this.expand();
- }
- },
- collapse: function(){
- this.items.each(function(item){
- item.node.setStyle("display", "none");
- }.bind(this));
- this.node.getElement("span").set("html", "<img src='/x_component_query_Query/$Viewer/"+this.view.options.style+"/icon/expand.png'/>");
- },
- expand: function(){
- this.items.each(function(item){
- item.node.setStyle("display", "table-row");
- }.bind(this));
- this.node.getElement("span").set("html", "<img src='/x_component_query_Query/$Viewer/"+this.view.options.style+"/icon/down.png'/>");
- if (!this.loadChild){
- //window.setTimeout(function(){
- this.data.list.each(function(line, i){
- var s = this.idx+i;
- this.lastItem = new MWF.xApplication.query.Query.Viewer.Item(this.view, line, (this.lastItem || this), s);
- this.items.push(this.lastItem);
- }.bind(this));
- this.loadChild = true;
- //}.bind(this), 10);
- }
- }
- });
- MWF.xApplication.query.Query.Viewer.Filter = new Class({
- initialize: function(viewer, data, node){
- this.viewer = viewer;
- this.data = data;
- this.css = this.viewer.css;
- this.content = node;
- this.load();
- },
- load: function(){
- this.node = new Element("div", {"styles": this.css.viewSearchFilterNode}).inject(this.content);
- if (this.viewer.filterItems.length){
- this.logicNode = new Element("div", {"styles": this.css.viewSearchFilterSelectAreaNode}).inject(this.node);
- this.logicSelectNode = new Element("div", {
- "styles": this.css.viewSearchFilterSelectNode,
- "text": this.viewer.lp.and,
- "value": "and"
- }).inject(this.logicNode);
- this.logicSelectButtonNode = new Element("div", {"styles": this.css.viewSearchFilterSelectButtonNode}).inject(this.logicNode);
- this.logicNode.addEvents({
- "click": function(){
- var v = this.logicSelectNode.get("value");
- if (v==="and"){
- this.logicSelectButtonNode.setStyle("float", "left");
- this.logicSelectNode.setStyle("float", "right");
- this.logicSelectNode.set({
- "text": this.viewer.lp.or,
- "value": "or"
- });
- this.data.logic = "or";
- }else{
- this.logicSelectButtonNode.setStyle("float", "right");
- this.logicSelectNode.setStyle("float", "left");
- this.logicSelectNode.set({
- "text": this.viewer.lp.and,
- "value": "and"
- });
- this.data.logic = "and";
- }
- this.viewer.searchCustomView();
- }.bind(this)
- });
- }
- this.titleNode = new Element("div", {"styles": this.css.viewSearchFilterTextNode, "text": this.data.title}).inject(this.node);
- this.comparisonTitleNode = new Element("div", {"styles": this.css.viewSearchFilterTextNode, "text": this.data.comparisonTitle}).inject(this.node);
- this.valueNode = new Element("div", {"styles": this.css.viewSearchFilterTextNode, "text": "\""+this.data.value+"\""}).inject(this.node);
- this.deleteNode = new Element("div", {"styles": this.css.viewSearchFilterDeleteNode}).inject(this.node);
- this.node.addEvents({
- "mouseover": function(){
- this.node.setStyles(this.css.viewSearchFilterNode_over);
- this.deleteNode.setStyles(this.css.viewSearchFilterDeleteNode_over);
- }.bind(this),
- "mouseout": function(){
- this.node.setStyles(this.css.viewSearchFilterNode);
- this.deleteNode.setStyles(this.css.viewSearchFilterDeleteNode);
- }.bind(this)
- });
- this.deleteNode.addEvent("click", function(){
- this.viewer.searchViewRemoveFilter(this);
- }.bind(this));
- },
- destroy: function(){
- this.node.destroy();
- MWF.release(this);
- }
- });
- MWF.xApplication.query.Query.Viewer.Actionbar = new Class({
- Implements: [Events],
- options: {
- "style" : "default",
- "moduleEvents": ["load", "queryLoad", "postLoad", "afterLoad"]
- },
- initialize: function(node, json, form, options){
- this.node = $(node);
- this.node.store("module", this);
- this.json = json;
- this.form = form;
- this.view = form;
- },
- hide: function(){
- var dsp = this.node.getStyle("display");
- if (dsp!=="none") this.node.store("mwf_display", dsp);
- this.node.setStyle("display", "none");
- },
- show: function(){
- var dsp = this.node.retrieve("mwf_display", dsp);
- this.node.setStyle("display", dsp);
- },
- load: function(){
- this._loadModuleEvents();
- if (this.fireEvent("queryLoad")){
- //this._queryLoaded();
- this._loadUserInterface();
- this._loadStyles();
- this._loadDomEvents();
- //this._loadEvents();
- //this._afterLoaded();
- this.fireEvent("postLoad");
- this.fireEvent("load");
- }
- },
- _loadStyles: function(){
- if (this.json.styles) Object.each(this.json.styles, function(value, key){
- if ((value.indexOf("x_processplatform_assemble_surface")!=-1 || value.indexOf("x_portal_assemble_surface")!=-1 || value.indexOf("x_cms_assemble_control")!=-1)){
- var host1 = MWF.Actions.getHost("x_processplatform_assemble_surface");
- var host2 = MWF.Actions.getHost("x_portal_assemble_surface");
- var host3 = MWF.Actions.getHost("x_cms_assemble_control");
- if (value.indexOf("/x_processplatform_assemble_surface")!==-1){
- value = value.replace("/x_processplatform_assemble_surface", host1+"/x_processplatform_assemble_surface");
- }else if (value.indexOf("x_processplatform_assemble_surface")!==-1){
- value = value.replace("x_processplatform_assemble_surface", host1+"/x_processplatform_assemble_surface");
- }
- if (value.indexOf("/x_portal_assemble_surface")!==-1){
- value = value.replace("/x_portal_assemble_surface", host2+"/x_portal_assemble_surface");
- }else if (value.indexOf("x_portal_assemble_surface")!==-1){
- value = value.replace("x_portal_assemble_surface", host2+"/x_portal_assemble_surface");
- }
- if (value.indexOf("/x_cms_assemble_control")!==-1){
- value = value.replace("/x_cms_assemble_control", host3+"/x_cms_assemble_control");
- }else if (value.indexOf("x_cms_assemble_control")!==-1){
- value = value.replace("x_cms_assemble_control", host3+"/x_cms_assemble_control");
- }
- }
- this.node.setStyle(key, value);
- }.bind(this));
- // if (["x_processplatform_assemble_surface", "x_portal_assemble_surface"].indexOf(root.toLowerCase())!==-1){
- // var host = MWF.Actions.getHost(root);
- // return (flag==="/") ? host+this.json.template : host+"/"+this.json.template
- // }
- //if (this.json.styles) this.node.setStyles(this.json.styles);
- },
- _loadModuleEvents : function(){
- Object.each(this.json.events, function(e, key){
- if (e.code){
- if (this.options.moduleEvents.indexOf(key)!==-1){
- this.addEvent(key, function(event){
- return this.form.Macro.fire(e.code, this, event);
- }.bind(this));
- }
- }
- }.bind(this));
- },
- _loadDomEvents: function(){
- Object.each(this.json.events, function(e, key){
- if (e.code){
- if (this.options.moduleEvents.indexOf(key)===-1){
- this.node.addEvent(key, function(event){
- return this.form.Macro.fire(e.code, this, event);
- }.bind(this));
- }
- }
- }.bind(this));
- },
- _loadEvents: function(){
- Object.each(this.json.events, function(e, key){
- if (e.code){
- if (this.options.moduleEvents.indexOf(key)!==-1){
- this.addEvent(key, function(event){
- return this.form.Macro.fire(e.code, this, event);
- }.bind(this));
- }else{
- this.node.addEvent(key, function(event){
- return this.form.Macro.fire(e.code, this, event);
- }.bind(this));
- }
- }
- }.bind(this));
- },
- addModuleEvent: function(key, fun){
- if (this.options.moduleEvents.indexOf(key)!==-1){
- this.addEvent(key, function(event){
- return (fun) ? fun(this, event) : null;
- }.bind(this));
- }else{
- this.node.addEvent(key, function(event){
- return (fun) ? fun(this, event) : null;
- }.bind(this));
- }
- },
- _loadUserInterface: function(){
- // if (this.form.json.mode == "Mobile"){
- // this.node.empty();
- // }else if (COMMON.Browser.Platform.isMobile){
- // this.node.empty();
- // }else{
- this.toolbarNode = this.node.getFirst("div");
- if( !this.toolbarNode ){
- this.toolbarNode = new Element("div").inject( this.node );
- }
- this.toolbarNode.empty();
- MWF.require("MWF.widget.Toolbar", function(){
- this.toolbarWidget = new MWF.widget.Toolbar(this.toolbarNode, {
- "style": this.json.style,
- "onPostLoad" : function(){
- this.fireEvent("afterLoad");
- }.bind(this)
- }, this);
- if (this.json.actionStyles) this.toolbarWidget.css = this.json.actionStyles;
- //alert(this.readonly)
- if (this.json.hideSystemTools){
- this.setCustomToolbars(this.json.tools, this.toolbarNode);
- this.toolbarWidget.load();
- }else{
- if (this.json.defaultTools){
- this.setToolbars(this.json.defaultTools, this.toolbarNode, this.readonly);
- this.setCustomToolbars(this.json.tools, this.toolbarNode);
- this.toolbarWidget.load();
- }else{
- MWF.getJSON(this.form.path+"toolbars.json", function(json){
- this.setToolbars(json, this.toolbarNode, this.readonly, true);
- this.setCustomToolbars(this.json.tools, this.toolbarNode);
- this.toolbarWidget.load();
- }.bind(this), null);
- }
- }
- }.bind(this));
- // }
- },
- setCustomToolbars: function(tools, node){
- var path = "/x_component_process_FormDesigner/Module/Actionbar/";
- var iconPath = "";
- if( this.json.customIconStyle ){
- iconPath = this.json.customIconStyle+"/";
- }
- tools.each(function(tool){
- var flag = true;
- if (this.readonly){
- flag = tool.readShow;
- }else{
- flag = tool.editShow;
- }
- if (flag){
- flag = true;
- // if (tool.control){
- // flag = this.form.businessData.control[tool.control]
- // }
- if (tool.condition){
- var hideFlag = this.form.Macro.exec(tool.condition, this);
- flag = !hideFlag;
- }
- if (flag){
- var actionNode = new Element("div", {
- "id": tool.id,
- "MWFnodetype": tool.type,
- "MWFButtonImage": path+""+this.form.options.style+"/custom/"+iconPath+tool.img,
- "title": tool.title,
- "MWFButtonAction": "runCustomAction",
- "MWFButtonText": tool.text
- }).inject(node);
- if( this.json.customIconOverStyle ){
- actionNode.set("MWFButtonImageOver" , path+""+this.form.options.style +"/custom/"+this.json.customIconOverStyle+ "/" +tool.img );
- }
- if( tool.properties ){
- actionNode.set(tool.properties);
- }
- if (tool.actionScript){
- actionNode.store("script", tool.actionScript);
- }
- if (tool.sub){
- var subNode = node.getLast();
- this.setCustomToolbars(tool.sub, subNode);
- }
- }
- }
- }.bind(this));
- },
- setToolbarItem: function(tool, node, readonly, noCondition){
- //var path = "/x_component_process_FormDesigner/Module/Actionbar/";
- var path = "/x_component_query_ViewDesigner/$View/";
- var flag = true;
- // if (tool.control){
- // flag = this.form.businessData.control[tool.control]
- // }
- if (!noCondition) if (tool.condition){
- var hideFlag = this.form.Macro.exec(tool.condition, this);
- flag = flag && (!hideFlag);
- }
- if (readonly) if (!tool.read) flag = false;
- if (flag){
- var actionNode = new Element("div", {
- "id": tool.id,
- "MWFnodetype": tool.type,
- //"MWFButtonImage": this.form.path+""+this.form.options.style+"/actionbar/"+tool.img,
- //"MWFButtonImage": path+(this.options.style||"default") +"/tools/"+ (this.json.style || "default") +"/"+tool.img,
- "MWFButtonImage": path+this.options.style+"/actionbar/"+tool.img,
- "title": tool.title,
- "MWFButtonAction": tool.action,
- "MWFButtonText": tool.text
- }).inject(node);
- if( this.json.iconOverStyle ){
- actionNode.set("MWFButtonImageOver" , path+""+this.options.style+"/actionbar/"+this.json.iconOverStyle+"/"+tool.img );
- //actionNode.set("MWFButtonImageOver" , path+""+(this.options.style||"default")+"/tools/"+( this.json.iconOverStyle || "default" )+"/"+tool.img );
- }
- if( tool.properties ){
- actionNode.set(tool.properties);
- }
- if (tool.sub){
- var subNode = node.getLast();
- this.setToolbars(tool.sub, subNode, readonly, noCondition);
- }
- }
- },
- setToolbars: function(tools, node, readonly, noCondition){
- tools.each(function(tool){
- this.setToolbarItem(tool, node, readonly, noCondition);
- }.bind(this));
- },
- runCustomAction: function(bt){
- var script = bt.node.retrieve("script");
- this.form.Macro.exec(script, this);
- },
- exportView : function(){
- this.form.exportView();
- },
- deleteWork: function(){
- this.form.deleteWork();
- }
- });
|