Viewer.js 130.3 KB
Newer Older
R
roo00 已提交
1 2 3
MWF.xApplication.query = MWF.xApplication.query || {};
MWF.xApplication.query.Query = MWF.xApplication.query.Query || {};
MWF.require("MWF.widget.Common", null, false);
4
MWF.require("o2.widget.Paging", null, false);
R
roo00 已提交
5
MWF.require("MWF.xScript.Macro", null, false);
6
MWF.xDesktop.requireApp("query.Query", "lp."+o2.language, null, false);
R
roo00 已提交
7 8 9 10 11
MWF.xApplication.query.Query.Viewer = MWF.QViewer = new Class({
    Implements: [Options, Events],
    Extends: MWF.widget.Common,
    options: {
        "style": "default",
U
unknown 已提交
12
        "skin" : null,
R
roo00 已提交
13 14 15 16
        "resizeNode": true,
        "paging" : "scroll",
        "perPageCount" : 50,
        "isload": "true",
U
unknown 已提交
17
        "export": false,
U
unknown 已提交
18
        "lazy": false,
19 20
        "moduleEvents": ["queryLoad", "postLoad", "postLoadPageData", "postLoadPage", "selectRow", "unselectRow",
            "queryLoadItemRow", "postLoadItemRow", "queryLoadCategoryRow", "postLoadCategoryRow"]
U
unknown 已提交
21

R
roo00 已提交
22 23 24 25 26 27 28
        // "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"
    },
U
unknown 已提交
29
    initialize: function(container, json, options, app, parentMacro){
U
unknown 已提交
30 31 32 33 34
        //本类有三种事件,
        //一种是通过 options 传进来的事件,包括 loadView、openDocument、select
        //一种是用户配置的 事件, 在this.options.moduleEvents 中定义的作为类事件
        //还有一种也是用户配置的事件,不在this.options.moduleEvents 中定义的作为 this.node 的DOM事件

R
roo00 已提交
35 36
        this.setOptions(options);

37 38
        this.path = "../x_component_query_Query/$Viewer/";
        this.cssPath = "../x_component_query_Query/$Viewer/"+this.options.style+"/css.wcss";
R
roo00 已提交
39 40 41
        this._loadCss();
        this.lp = MWF.xApplication.query.Query.LP;

U
unknown 已提交
42 43
        this.app = app;

R
roo00 已提交
44 45 46
        this.container = $(container);
        this.json = json;

U
unknown 已提交
47 48
        this.parentMacro = parentMacro;

49 50
        this.originalJson = Object.clone(json);

R
roo00 已提交
51 52 53 54 55 56
        this.viewJson = null;
        this.filterItems = [];
        this.searchStatus = "none"; //none, custom, default


        this.items = [];
U
unknown 已提交
57

R
roo00 已提交
58 59 60 61 62 63 64 65 66 67 68
        this.selectedItems = [];
        this.hideColumns = [];
        this.openColumns = [];

        this.gridJson = null;

        if (this.options.isload){
            this.init(function(){
                this.load();
            }.bind(this));
        }
U
unknown 已提交
69

R
roo00 已提交
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88
    },
    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(){
U
unknown 已提交
89
        this.loadResource( function () {
U
unknown 已提交
90 91 92 93 94 95
            this._loadModuleEvents();
            if (this.fireEvent("queryLoad")){
                this._loadUserInterface();
                //this._loadStyles();
                this._loadDomEvents();
            }
96
        }.bind(this))
U
unknown 已提交
97 98
    },
    _loadUserInterface : function(){
R
roo00 已提交
99
        this.loadLayout();
U
unknown 已提交
100
        this.createActionbarNode();
R
roo00 已提交
101 102 103 104 105 106 107 108 109 110 111
        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);
112
        this.actionbarAreaNode =  new Element("div.actionbarAreaNode", {"styles": this.css.actionbarAreaNode}).inject(this.node);
U
unknown 已提交
113
        //if (this.options.export) this.exportAreaNode = new Element("div", {"styles": this.css.exportAreaNode}).inject(this.node);
R
roo00 已提交
114 115
        this.searchAreaNode = new Element("div", {"styles": this.css.searchAreaNode}).inject(this.node);
        this.viewAreaNode = new Element("div", {"styles": this.css.viewAreaNode}).inject(this.node);
116 117
        // this.viewPageNode = new Element("div", {"styles": this.css.viewPageNode}).inject(this.node);
        this.viewPageAreaNode = new Element("div", {"styles": this.css.viewPageAreaNode}).inject(this.node);
U
unknown 已提交
118 119

        this.fireEvent("loadLayout");
R
roo00 已提交
120
    },
U
unknown 已提交
121 122 123 124 125 126 127 128 129 130 131 132 133 134 135
    loadResource: function( callback ){
        if( this.options.lazy ){
            var loadedIOResource = false;
            var callback2 = function(){
                if( this.Macro && loadedIOResource )callback();
            }.bind(this)
            this.loadMacro( callback2 );
            this.loadIOResource( function(){
                loadedIOResource = true;
                callback2();
            }.bind(this));
        }else{
            this.loadMacro( callback );
        }
    },
U
unknown 已提交
136
    loadMacro: function (callback) {
U
unknown 已提交
137 138
        MWF.require("MWF.xScript.Macro", function () {
            this.Macro = new MWF.Macro.ViewContext(this);
U
unknown 已提交
139
            if (callback) callback();
U
unknown 已提交
140
        }.bind(this));
U
unknown 已提交
141
    },
R
roo00 已提交
142 143 144
    createExportNode: function(){
        if (this.options.export){
            MWF.require("MWF.widget.Toolbar", function(){
U
unknown 已提交
145
                this.toolbar = new MWF.widget.Toolbar(this.actionbarAreaNode, {"style": "simple"}, this); //this.exportAreaNode
R
roo00 已提交
146 147 148 149 150 151 152
                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
U
unknown 已提交
153
                }).inject(this.actionbarAreaNode); //this.exportAreaNode
R
roo00 已提交
154 155 156 157 158 159

                this.toolbar.load();
            }.bind(this));
            //this.exportNode = new Element("button", {"text": this.lp.exportExcel}).inject(this.exportAreaNode);
        }
    },
U
unknown 已提交
160 161 162 163 164 165
    getExportTotalCount: function(){
        return ( this.bundleItems || [] ).length;
    },
    getExportMaxCount: function(){
        return 2000;
    },
R
roo00 已提交
166
    exportView: function(){
167
        var _self = this;
U
unknown 已提交
168 169 170
        var total = this.getExportTotalCount();
        var max = this.getExportMaxCount();

171 172 173 174
        var lp = this.lp.viewExport;
        var node = this.exportExcelDlgNode = new Element("div");
        var html = "<div style=\"line-height: 30px; height: 30px; color: #333333; overflow: hidden;margin-top:20px;\">" + lp.exportRange + "" +
            "   <input class='start' value='" + ( this.exportExcelStart || 1) +  "'><span>"+ lp.to +"</span>" +
U
unknown 已提交
175
            "   <input class='end' value='"+ ( this.exportExcelEnd || Math.min( total, max ) ) +"' ><span>"+lp.item+"</span>" +
176
            "</div>";
U
unknown 已提交
177
        html += "<div style=\"clear:both; max-height: 300px; margin-bottom:10px; margin-top:10px; overflow-y:auto;\">"+( lp.description.replace("{count}", total ))+"</div>";
178 179 180 181 182 183 184
        node.set("html", html);
        var check = function () {
            if(this.value.length == 1){
                this.value = this.value.replace(/[^1-9]/g,'')
            }else{
                this.value = this.value.replace(/\D/g,'')
            }
U
unknown 已提交
185 186
            if( this.value.toInt() > total ){
                this.value = total;
187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219
            }
        }
        node.getElement(".start").addEvent( "keyup", function(){ check.call(this) } );
        node.getElement(".end").addEvent( "keyup", function(){ check.call(this) } );


        var dlg = o2.DL.open({
            "title": this.lp.exportExcel,
            "style": "user",
            "isResize": false,
            "content": node,
            "width": 600,
            "height" : 260,
            "buttonList": [
                {
                    "type": "ok",
                    "text": MWF.LP.process.button.ok,
                    "action": function (d, e) {
                        var start = node.getElement(".start").get("value");
                        var end = node.getElement(".end").get("value");
                        if( !start || !end ){
                            MWF.xDesktop.notice("error", {"x": "left", "y": "top"}, lp.inputIntegerNotice, node, {"x": 0, "y": 85});
                            return false;
                        }
                        start = start.toInt();
                        end = end.toInt();
                        if( end < start ){
                            MWF.xDesktop.notice("error", {"x": "left", "y": "top"}, lp.startLargetThanEndNotice, node, {"x": 0, "y": 85});
                            return false;
                        }
                        debugger;
                        this.exportExcelStart = start;
                        this.exportExcelEnd = end;
U
unknown 已提交
220
                        this._exportView(start, end);
221 222 223 224 225 226 227 228 229 230 231
                        dlg.close();
                    }.bind(this)
                },
                {
                    "type": "cancel",
                    "text": MWF.LP.process.button.cancel,
                    "action": function () { dlg.close(); }
                }
            ]
        });
    },
U
unknown 已提交
232 233 234 235
    _exportView: function(start, end){

        var bundleList = this.bundleItems.slice(start-1, end);
        var excelName = this.json.name + "(" + start + "-" + end + ").xlsx";
236

R
roo00 已提交
237 238 239 240 241 242 243 244
        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));
        }
245 246 247
        var data = {"filterList": filterData};
        if( bundleList )data.bundleList = bundleList;
        if( excelName )data.excelName = excelName;
U
unknown 已提交
248
        data.key = this.bundleKey;
249
        action.exportViewWithQuery(this.json.viewName, this.json.application, data, function(json){
R
roo00 已提交
250 251
            var uri = action.action.actions.getViewExcel.uri;
            uri = uri.replace("{flag}", json.data.id);
252
            uri = o2.filterUrl( action.action.address+uri );
R
roo00 已提交
253 254 255 256 257
            var a = new Element("a", {"href": uri, "target":"_blank"});
            a.click();
            a.destroy();
        }.bind(this));
    },
U
unknown 已提交
258 259 260 261 262 263 264 265 266 267 268
    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;
R
roo00 已提交
269
        }
270
        var pageSize = this.viewPageAreaNode.getComputedSize();
U
unknown 已提交
271
        h = h-pageSize.totalHeight;
U
unknown 已提交
272 273 274 275 276

        var paddingTop = (this.viewAreaNode.getStyle("padding-top") || "0").toInt();
        var paddingBottom = (this.viewAreaNode.getStyle("padding-bottom") || "0").toInt();
        h = h - paddingTop - paddingBottom;

U
unknown 已提交
277
        this.viewAreaNode.setStyle("height", ""+h+"px");
R
roo00 已提交
278
    },
U
unknown 已提交
279 280 281 282 283 284 285
    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...");
R
roo00 已提交
286
    },
U
unknown 已提交
287 288
    createActionbarNode : function(){
        this.actionbarAreaNode.empty();
U
unknown 已提交
289
        if( typeOf(this.json.showActionbar) === "boolean" && this.json.showActionbar !== true )return;
U
unknown 已提交
290 291 292 293 294 295
        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();
R
roo00 已提交
296 297
        }
    },
298
    createViewNode: function(data, callback){
U
unknown 已提交
299
        this.viewAreaNode.empty();
U
unknown 已提交
300

301 302
        this.selectedItems = [];

U
unknown 已提交
303 304 305 306 307
        var viewStyles = this.viewJson.viewStyles;

        this.contentAreaNode = new Element("div", {"styles":
                (viewStyles && viewStyles["container"]) ? viewStyles["container"] : this.css.contentAreaNode
        }).inject(this.viewAreaNode);
R
roo00 已提交
308

U
unknown 已提交
309 310
        this.loadObserver();

U
unknown 已提交
311 312 313 314 315 316
        this.viewTable = new Element("table", {
            "styles": this.css.viewTitleTableNode,
            "border": "0px",
            "cellPadding": "0",
            "cellSpacing": "0"
        }).inject(this.contentAreaNode);
U
unknown 已提交
317 318 319 320 321
        if( viewStyles ){
            if( viewStyles["tableProperties"] )this.viewTable.set(viewStyles["tableProperties"]);
            if( viewStyles["table"] )this.viewTable.setStyles(viewStyles["table"]);
        }

U
unknown 已提交
322
        this.createLoadding();
R
roo00 已提交
323

U
unknown 已提交
324
        var viewTitleCellNode = (viewStyles && viewStyles["titleTd"]) ? viewStyles["titleTd"] : this.css.viewTitleCellNode;
U
unknown 已提交
325
        if (this.json.isTitle!=="no"){
U
unknown 已提交
326
            this.viewTitleLine = new Element("tr.viewTitleLine", {
U
unknown 已提交
327 328
                "styles": (viewStyles && viewStyles["titleTr"]) ? viewStyles["titleTr"] : this.css.viewTitleLineNode
            }).inject(this.viewTable);
R
roo00 已提交
329

U
unknown 已提交
330
            //if (this.json.select==="single" || this.json.select==="multi") {
331
            this.selectTitleCell = new Element("td.selectTitleCell", {
U
unknown 已提交
332
                "styles": viewTitleCellNode
U
unknown 已提交
333 334 335 336
            }).inject(this.viewTitleLine);
            this.selectTitleCell.setStyle("width", "10px");
            if (this.json.titleStyles) this.selectTitleCell.setStyles(this.json.titleStyles);
            //}
337 338 339 340
            if( this.isSelectTdHidden() ){
                this.selectTitleCell.hide();
            }

U
unknown 已提交
341
            if( this.getSelectFlag( true ) !== "multi" || !this.viewJson.allowSelectAll ){
U
unknown 已提交
342 343 344
                this.expandTitleCell = this.selectTitleCell;
            }

R
roo00 已提交
345

U
unknown 已提交
346 347 348
            //序号
            if (this.viewJson.isSequence==="yes"){
                this.sequenceTitleCell = new Element("td", {
U
unknown 已提交
349
                    "styles": viewTitleCellNode
U
unknown 已提交
350 351 352
                }).inject(this.viewTitleLine);
                this.sequenceTitleCell.setStyle("width", "10px");
                if (this.json.titleStyles) this.sequenceTitleCell.setStyles(this.json.titleStyles);
U
unknown 已提交
353
                if( !this.expandTitleCell )this.expandTitleCell = this.sequenceTitleCell;
R
roo00 已提交
354 355
            }

U
unknown 已提交
356
            this.entries = {};
U
unknown 已提交
357
            debugger;
U
unknown 已提交
358 359 360 361
            this.viewJson.selectList.each(function(column){
                this.entries[column.column] = column;
                if (!column.hideColumn){
                    var viewCell = new Element("td", {
U
unknown 已提交
362
                        "styles": viewTitleCellNode,
U
unknown 已提交
363 364
                        "text": column.displayName
                    }).inject(this.viewTitleLine);
U
unknown 已提交
365
                    var size = MWF.getTextSize(column.displayName, viewTitleCellNode);
U
unknown 已提交
366 367
                    viewCell.setStyle("min-width", ""+size.x+"px");
                    if (this.json.titleStyles) viewCell.setStyles(this.json.titleStyles);
368

U
unknown 已提交
369 370
                    if( column.groupEntry && !this.expandTitleCell )this.expandTitleCell = viewCell;

371 372
                    if( typeOf(column.titleStyles) === "object" )viewCell.setStyles(column.titleStyles);
                    if( typeOf(column.titleProperties) === "object" )viewCell.setProperties(column.titleProperties);
373 374 375 376 377

                    if( column.events && column.events.loadTitle && column.events.loadTitle.code ){
                        var code = column.events.loadTitle.code;
                        this.Macro.fire( code, {"node" : viewCell, "json" : column, "data" : column.displayName, "view" : this});
                    }
U
unknown 已提交
378 379 380
                }else{
                    this.hideColumns.push(column.column);
                }
381

U
unknown 已提交
382 383
                if (column.allowOpen) this.openColumns.push(column.column);
            }.bind(this));
384
            this.lookup(data, callback);
U
unknown 已提交
385
        }else{
U
unknown 已提交
386
            this.entries = {};
U
unknown 已提交
387
            this.viewJson.selectList.each(function(column){
U
unknown 已提交
388
                this.entries[column.column] = column;
U
unknown 已提交
389 390 391
                if (column.hideColumn) this.hideColumns.push(column.column);
                if (!column.allowOpen) this.openColumns.push(column.column);
            }.bind(this));
392
            this.lookup(data, callback);
U
unknown 已提交
393
        }
R
roo00 已提交
394
    },
U
unknown 已提交
395 396 397 398 399 400
    getExpandFlag : function(){
        if( this.options && this.options.isExpand )return this.options.isExpand;
        if( this.json && this.json.isExpand )return this.json.isExpand;
        if( this.viewJson && this.viewJson.isExpand )return this.viewJson.isExpand;
        return "no";
    },
U
unknown 已提交
401 402
    getSelectFlag : function( ignoreSelectEnable ){
        if( !ignoreSelectEnable && !this.viewSelectedEnable )return "none";
U
unknown 已提交
403 404 405 406 407 408
        if( this.options && this.options.select )return this.options.select;
        if( this.json && this.json.select )return this.json.select;
        if( this.viewJson && this.viewJson.select )return this.viewJson.select;
        // if( this.json.select === "single" || this.json.select === "multi" )return this.json.select;
        // if( this.viewJson.select === "single" || this.viewJson.select === "multi" )return this.viewJson.select;
        // if( this.options.select === "single" || this.options.select === "multi"  )return this.options.select;
U
unknown 已提交
409 410
        return "none";
    },
411
    isSelectTdHidden :function(){
412 413 414
        if( !this.viewJson.firstTdHidden ){
            return false;
        }
U
unknown 已提交
415
        if( this.viewJson.group && this.viewJson.group.column ){
416 417
            return false;
        }
U
unknown 已提交
418
        if( this.json.defaultSelectedScript || this.viewJson.defaultSelectedScript ){
419 420
            return false;
        }
U
unknown 已提交
421 422 423
        // if( !this.viewSelectedEnable ){
        //     return true;
        // }
U
unknown 已提交
424
        if( this.options && this.options.select ){
425
            return  this.options.select === "none" || this.options.select === "no";
426
        }
U
unknown 已提交
427
        if( this.json && this.json.select ){
428
            return  this.json.select === "none" || this.json.select === "no";
U
unknown 已提交
429 430
        }
        if( this.viewJson && this.viewJson.select ){
431
            return  this.viewJson.select === "none" || this.viewJson.select === "no";
432 433
        }
        return true;
U
unknown 已提交
434 435 436 437 438 439 440 441 442 443 444 445 446
        // if( this.json.select === "single" || this.json.select === "multi" || this.json.defaultSelectedScript || this.viewJson.defaultSelectedScript ){
        //     return false;
        // }
        // if( this.options.select === "single" || this.options.select === "multi"  ){
        //     return false;
        // }
        // if( this.viewJson.select === "single" || this.viewJson.select === "multi"  ){
        //     return false;
        // }
        // if( this.viewJson.group && this.viewJson.group.column ){
        //     return false;
        // }
        // return true;
447
    },
U
unknown 已提交
448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519
    // _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();
U
unknown 已提交
520 521 522 523 524 525 526 527 528 529 530 531 532 533 534
        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.Viewer.Paging(this.viewPageAreaNode, json, this, {});
            this.paging.load();
        }else{
            this.paging.reload();
        }
R
roo00 已提交
535
    },
U
unknown 已提交
536 537 538 539 540
    _initPage: function(){
        this.count = this.bundleItems.length;

        var i = this.count/this.json.pageSize;
        this.pages = (i.toInt()<i) ? i.toInt()+1 : i;
U
unknown 已提交
541 542
        this.currentPage = this.options.defaultPage || 1;
        this.options.defaultPage = null;
543 544 545

        this.exportExcelStart = null;
        this.exportExcelEnd = null;
R
roo00 已提交
546
    },
547
    lookup: function(data, callback){
548 549
        if( this.lookuping )return;
        this.lookuping = true;
U
unknown 已提交
550 551 552 553 554 555 556
        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;
557
                    this.bundleKey = json.data.key;
U
unknown 已提交
558 559 560

                    this._initPage();
                    if (this.bundleItems.length){
561
                        if( this.noDataTextNode )this.noDataTextNode.destroy();
U
unknown 已提交
562 563
                        this.loadCurrentPageData( function () {
                            this.fireEvent("postLoad"); //用户配置的事件
564
                            this.lookuping = false;
565
                            if(callback)callback(this);
U
unknown 已提交
566 567 568 569
                        }.bind(this));
                    }else{
                        //this._loadPageNode();
                        this.viewPageAreaNode.empty();
570 571 572 573 574 575 576 577 578 579
                        if( this.viewJson.noDataText ){
                            var noDataTextNodeStyle = this.css.noDataTextNode;
                            if( this.viewJson.viewStyles && this.viewJson.viewStyles["noDataTextNode"] ){
                                noDataTextNodeStyle = this.viewJson.viewStyles["noDataTextNode"];
                            }
                            this.noDataTextNode = new Element( "div", {
                                "styles": noDataTextNodeStyle,
                                "text" : this.viewJson.noDataText
                            }).inject( this.contentAreaNode );
                        }
U
unknown 已提交
580 581 582 583 584
                        if (this.loadingAreaNode){
                            this.loadingAreaNode.destroy();
                            this.loadingAreaNode = null;
                        }
                        this.fireEvent("postLoad"); //用户配置的事件
585
                        this.lookuping = false;
586
                        if(callback)callback(this);
U
unknown 已提交
587 588 589
                    }
                }.bind(this));
            }
R
roo00 已提交
590 591
        }.bind(this));
    },
592
    loadCurrentPageData: function( callback, async ){
U
unknown 已提交
593
        //是否需要在翻页的时候清空之前的items ?
594 595 596 597

        if( this.pageloading )return;
        this.pageloading = true;

U
unknown 已提交
598 599 600 601 602 603
        if( this.io ){
            this.items.each(function(item){
                this.io.unobserve(item.node);
            }.bind(this))
        }

U
unknown 已提交
604
        this.items = [];
R
roo00 已提交
605

U
unknown 已提交
606 607 608 609
        var p = this.currentPage;
        var d = {};
        var valueList = this.bundleItems.slice((p-1)*this.json.pageSize,this.json.pageSize*p);
        d.bundleList = valueList;
610 611
        d.key = this.bundleKey;

U
unknown 已提交
612 613 614
        while (this.viewTable.rows.length>1){
            this.viewTable.deleteRow(-1);
        }
U
unknown 已提交
615 616 617 618 619 620
        if( this.viewTable.rows.length>0 && !this.viewTable.rows[0].hasClass("viewTitleLine") ){
            this.viewTable.deleteRow(0);
        }

        this.contentAreaNode.scrollTo(0, 0);

U
unknown 已提交
621
        //this.createLoadding();
R
roo00 已提交
622

U
unknown 已提交
623 624
        this.loadViewRes = this.lookupAction.loadView(this.json.name, this.json.application, d, function(json){
            this.viewData = json.data;
R
roo00 已提交
625

U
unknown 已提交
626
            this.fireEvent("postLoadPageData");
R
roo00 已提交
627

U
unknown 已提交
628 629
            if (this.viewJson.group.column){
                this.gridJson = json.data.groupGrid;
U
unknown 已提交
630
                this.setSelectedableFlag();
U
unknown 已提交
631 632 633
                this.loadGroupData();
            }else{
                this.gridJson = json.data.grid;
U
unknown 已提交
634
                this.setSelectedableFlag();
U
unknown 已提交
635
                this.loadData();
R
roo00 已提交
636
            }
U
unknown 已提交
637 638 639 640
            if (this.gridJson.length) this._loadPageNode();
            if (this.loadingAreaNode){
                this.loadingAreaNode.destroy();
                this.loadingAreaNode = null;
R
roo00 已提交
641 642
            }

643
            this.pageloading = false;
R
roo00 已提交
644

645
            this.fireEvent("loadView"); //options 传入的事件
U
unknown 已提交
646 647 648
            this.fireEvent("postLoadPage");

            if(callback)callback();
649
        }.bind(this), null, async === false ? false : true );
U
unknown 已提交
650
    },
U
unknown 已提交
651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678
    setSelectedableFlag : function(){
        this.viewSelectedEnable = false;
        var selectedAbleScript = this.json.selectedAbleScript || this.viewJson.selectedAbleScript;
        if (this.viewJson.group.column){
            this.gridJson.each( function( d ){
                d.list.each( function( v ){
                    if( selectedAbleScript ){
                        v.$selectedEnable = this.Macro.exec( selectedAbleScript, { "data" : v, "groupData" : d ,"view": this });
                    }else{
                        v.$selectedEnable = true;
                    }
                    if( v.$selectedEnable ){
                        d.$selectedEnable = true;
                        this.viewSelectedEnable = true;
                    }
                }.bind(this))
            }.bind(this))
        }else{
            this.gridJson.each( function( v ){
                if( selectedAbleScript ){
                    v.$selectedEnable = this.Macro.exec( selectedAbleScript, { "data" : v, "view": this });
                }else{
                    v.$selectedEnable = true;
                }
                if( v.$selectedEnable )this.viewSelectedEnable = true;
            }.bind(this))
        }
    },
U
unknown 已提交
679
    getMode: function(){
U
unknown 已提交
680 681
        return this.viewJson.group.column ? "group" : "item";
    },
U
unknown 已提交
682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709
    createSelectAllNode: function(){
        if( this.getSelectFlag() === "multi" && this.viewJson.allowSelectAll ){
            if (this.selectTitleCell && !this.selectTitleCell.retrieve("selectAllLoaded") ){
                if( this.viewJson.viewStyles && this.viewJson.viewStyles["checkboxNode"] ){
                    this.selectAllNode = this.selectTitleCell;
                    this.selectAllNode.setStyles( this.viewJson.viewStyles["checkboxNode"] );
                    // this.selectAllNode = new Element("div", {
                    //     styles : this.viewJson.viewStyles["checkboxNode"]
                    // }).inject( this.selectTitleCell );
                }else{
                    this.selectAllNode.html( "<img src='../x_component_query_Query/$Viewer/"+this.options.style+"/icon/checkbox.png'/>"+"</span>" )
                    // this.selectAllNode = new Element("div",{
                    //     html : "<img src='../x_component_query_Query/$Viewer/"+this.options.style+"/icon/checkbox.png'/>"+"</span>",
                    //     style : "font-family: Webdings"
                    // }).inject( this.selectTitleCell );
                }
                this.selectTitleCell.setStyle("cursor", "pointer");
                this.selectTitleCell.addEvent("click", function () {
                    if( this.getSelectAllStatus() === "all" ){
                        this.unSelectAll("view")
                    }else{
                        this.selectAll("view");
                    }
                }.bind(this));
                this.selectTitleCell.store("selectAllLoaded", true);
            }
        }
    },
U
unknown 已提交
710
    loadData: function(){
U
unknown 已提交
711 712 713 714 715 716
        if( this.getSelectFlag() === "multi" && this.viewJson.allowSelectAll ) {
            if(this.selectTitleCell && this.selectTitleCell.retrieve("selectAllLoaded")){
                this.setUnSelectAllStyle();
            }else{
                this.createSelectAllNode();
            }
U
unknown 已提交
717 718
        }else if(this.selectAllNode){
            this.clearSelectAllStyle();
U
unknown 已提交
719 720
        }

U
unknown 已提交
721 722 723
        if (this.gridJson.length){
            // if( !this.options.paging ){
            this.gridJson.each(function(line, i){
U
unknown 已提交
724
                this.items.push(new MWF.xApplication.query.Query.Viewer.Item(this, line, null, i, null, this.options.lazy));
U
unknown 已提交
725 726 727 728 729 730
            }.bind(this));
            // }else{
            //     this.loadPaging();
            // }
        }else{
            if (this.viewPageAreaNode) this.viewPageAreaNode.empty();
R
roo00 已提交
731 732
        }
    },
U
unknown 已提交
733 734 735 736 737 738 739
    loadPaging : function(){
        this.isItemsLoading = false;
        this.pageNumber = 0;
        this.isItemsLoaded = false;
        this.isSetedScroll = false;
        this.setScroll();
        this.loadDataByPaging()
R
roo00 已提交
740
    },
U
unknown 已提交
741 742 743 744 745 746 747 748 749 750 751 752 753 754
    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 )
NoSubject's avatar
NoSubject 已提交
755
        }
R
roo00 已提交
756
    },
U
unknown 已提交
757 758 759 760 761 762 763
    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++ ){
U
unknown 已提交
764
                this.items.push(new MWF.xApplication.query.Query.Viewer.Item(this, this.gridJson[i], null, i, null, this.options.lazy));
U
unknown 已提交
765 766 767 768 769
            }
            this.isItemsLoading = false;
            this.pageNumber ++;
            if( to == this.gridJson.length )this.isItemsLoaded = true;
        }
R
roo00 已提交
770
    },
U
unknown 已提交
771
    loadGroupData: function(){
U
unknown 已提交
772 773 774 775 776 777
        if( this.getSelectFlag() === "multi" && this.viewJson.allowSelectAll ) {
            if(this.selectTitleCell && this.selectTitleCell.retrieve("selectAllLoaded")){
                this.setUnSelectAllStyle();
            }else{
                this.createSelectAllNode();
            }
U
unknown 已提交
778 779
        }else if( this.selectAllNode ){
            this.clearSelectAllStyle();
U
unknown 已提交
780 781 782 783 784 785 786 787
        }

        if( this.expandTitleCell ){
            if ( !this.expandTitleCell.retrieve("expandLoaded") ){
                if( this.viewJson.viewStyles && this.viewJson.viewStyles["groupCollapseNode"] ){
                    this.expandAllNode = new Element("span", {
                        styles : this.viewJson.viewStyles["groupCollapseNode"]
                    }).inject( this.expandTitleCell, "top" );
U
unknown 已提交
788 789
                    // this.selectTitleCell.setStyle("cursor", "pointer");
                }else{
U
unknown 已提交
790 791 792
                    // this.selectTitleCell.set("html", "<span style='font-family: Webdings'>"+"<img src='../x_component_query_Query/$Viewer/"+this.options.style+"/icon/expand.png'/>"+"</span>");
                    this.expandAllNode = new Element("span",{
                        html : "<img src='../x_component_query_Query/$Viewer/"+this.options.style+"/icon/expand.png'/>"+"</span>",
U
unknown 已提交
793
                        style : "font-family: Webdings"
U
unknown 已提交
794
                    }).inject( this.expandTitleCell, "top" );
U
unknown 已提交
795
                }
U
unknown 已提交
796 797 798
                this.expandTitleCell.setStyle("cursor", "pointer");
                this.expandTitleCell.addEvent("click", this.expandOrCollapseAll.bind(this));
                this.expandTitleCell.store("expandLoaded", true);
U
unknown 已提交
799
            }else if( this.getExpandFlag() !=="yes" ){
U
unknown 已提交
800
                this.setCollapseAllStyle();
U
unknown 已提交
801 802 803 804
            }
        }


U
unknown 已提交
805
        // this.isAllExpanded = false;
U
unknown 已提交
806 807 808 809 810 811 812 813

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

U
unknown 已提交
814
            if (this.getExpandFlag()=="yes") this.expandOrCollapseAll();
U
unknown 已提交
815 816
        }else{
            if (this.viewPageAreaNode) this.viewPageAreaNode.empty();
U
unknown 已提交
817 818
        }
    },
U
unknown 已提交
819 820 821 822 823 824 825 826
    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));
R
roo00 已提交
827

U
unknown 已提交
828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864
                // 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(){
865
        if( this.lookuping || this.pageloading )return;
U
unknown 已提交
866 867
        this.node.setStyle("display", "block");
        if (this.loadingAreaNode) this.loadingAreaNode.setStyle("display", "block");
R
roo00 已提交
868

U
unknown 已提交
869 870 871 872 873
        this.filterItems.each(function(filter){
            filter.destroy();
        }.bind(this));
        this.filterItems = [];
        if (this.viewSearchInputNode) this.viewSearchInputNode.set("text", this.lp.searchKeywork);
R
roo00 已提交
874

U
unknown 已提交
875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916
        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));
R
roo00 已提交
917
            }
U
unknown 已提交
918 919 920 921 922 923 924 925 926 927
        }
        return (filterData.length) ? filterData : null;
    },
    getData: function(){
        if (this.selectedItems.length){
            var arr = [];
            this.selectedItems.each(function(item){
                arr.push(item.data);
            });
            return arr;
R
roo00 已提交
928
        }else{
U
unknown 已提交
929
            return [];
R
roo00 已提交
930 931
        }
    },
U
unknown 已提交
932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974
    _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", "");
U
unknown 已提交
975
            }.bind(this),
U
unknown 已提交
976 977 978
            "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();
979 980
            }.bind(this)
        });
NoSubject's avatar
NoSubject 已提交
981
    },
U
unknown 已提交
982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000
    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();
        }
NoSubject's avatar
NoSubject 已提交
1001
    },
U
unknown 已提交
1002 1003 1004
    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);
NoSubject's avatar
NoSubject 已提交
1005

U
unknown 已提交
1006 1007 1008
        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);
NoSubject's avatar
NoSubject 已提交
1009

U
unknown 已提交
1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026
        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(){
U
unknown 已提交
1027
        debugger;
U
unknown 已提交
1028 1029 1030
        if (this.viewJson.customFilterList) {
            var key = this.viewSearchInputNode.get("value");
            if (key && key !== this.lp.searchKeywork) {
1031
                var filterData = [];
U
unknown 已提交
1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056
                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});
NoSubject's avatar
NoSubject 已提交
1057 1058
                        }
                    }
R
roo00 已提交
1059
                }.bind(this));
U
unknown 已提交
1060

1061 1062 1063 1064 1065 1066
                if( this.json.filter ){
                    this.json.filter.clone().each(function(f){
                        filterData.push(f);
                    })
                }

U
unknown 已提交
1067 1068
                this.createViewNode({"filterList": filterData});
            }else{
1069
                this.filterItems = [];
U
unknown 已提交
1070 1071
                var filterData = this.json.filter ? this.json.filter.clone() : [];
                this.createViewNode( {"filterList": filterData} );
R
roo00 已提交
1072
            }
U
unknown 已提交
1073
        }
R
roo00 已提交
1074
    },
U
unknown 已提交
1075 1076 1077 1078 1079 1080
    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));
NoSubject's avatar
NoSubject 已提交
1081

U
unknown 已提交
1082 1083 1084
            this.createViewNode({"filterList": filterData});
        }else{
            this.createViewNode({"filterList": this.json.filter ? this.json.filter.clone() : null});
NoSubject's avatar
NoSubject 已提交
1085
        }
U
unknown 已提交
1086 1087
    },
    loadCustomSearch: function(){
1088 1089 1090 1091 1092
        if( this.lastFilterItems ){
            this.filterItems = this.lastFilterItems;
        }else{
            this.filterItems = [];
        }
U
unknown 已提交
1093
        debugger;
U
unknown 已提交
1094 1095 1096
        this.viewSearchIconNode.setStyle("display", "none");
        this.viewSearchInputBoxNode.setStyle("display", "none");
        this.viewSearchCustomActionNode.setStyle("display", "none");
NoSubject's avatar
NoSubject 已提交
1097

U
unknown 已提交
1098 1099 1100
        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";
U
unknown 已提交
1101

U
unknown 已提交
1102 1103 1104 1105 1106 1107
        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");
U
unknown 已提交
1108

U
unknown 已提交
1109 1110 1111
            if (this.viewSearchCustomContentNode){
                this.viewSearchCustomCloseActionNode.setStyle("display", "block");
                this.viewSearchCustomContentNode.setStyle("display", "block");
NoSubject's avatar
NoSubject 已提交
1112
            }else{
U
unknown 已提交
1113
                this.loadCustomSearchContent();
NoSubject's avatar
NoSubject 已提交
1114
            }
1115

U
unknown 已提交
1116
            if(this.setContentHeightFun)this.setContentHeightFun();
NoSubject's avatar
NoSubject 已提交
1117
        }.bind(this));
U
unknown 已提交
1118
        this.searchCustomView();
NoSubject's avatar
NoSubject 已提交
1119
    },
U
unknown 已提交
1120 1121 1122
    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);
NoSubject's avatar
NoSubject 已提交
1123

U
unknown 已提交
1124 1125 1126 1127 1128 1129
        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);
NoSubject's avatar
NoSubject 已提交
1130

U
unknown 已提交
1131
        this.loadViewSearchCustomList();
R
roo00 已提交
1132

U
unknown 已提交
1133 1134 1135 1136 1137 1138
        this.viewSearchCustomCloseActionNode.addEvents({
            "click": function(){this.closeCustomSearch();}.bind(this)
        });
        this.viewSearchCustomAddIconNode.addEvents({
            "click": function(){this.viewSearchCustomAddToFilter();}.bind(this)
        });
R
roo00 已提交
1139
    },
U
unknown 已提交
1140 1141 1142 1143 1144 1145 1146 1147 1148
    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);
R
roo00 已提交
1149

U
unknown 已提交
1150 1151 1152 1153 1154 1155 1156 1157
        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));
R
roo00 已提交
1158

U
unknown 已提交
1159 1160 1161 1162 1163 1164 1165 1166 1167
        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){
1168
            var selectableList = this.getCustomSelectScriptResult(entry);
U
unknown 已提交
1169 1170 1171
            switch (entry.formatType){
                case "numberValue":
                    this.loadComparisonSelect(this.lp.numberFilter);
1172 1173 1174 1175 1176
                    if( selectableList.length > 0 ){
                        this.loadViewSerchCustomSelectByScript(selectableList)
                    }else{
                        this.loadViewSearchCustomValueNumberInput();
                    }
U
unknown 已提交
1177 1178 1179
                    break;
                case "dateTimeValue":
                    this.loadComparisonSelect(this.lp.dateFilter);
1180 1181 1182 1183 1184
                    if( selectableList.length > 0 ){
                        this.loadViewSerchCustomSelectByScript(selectableList)
                    }else {
                        this.loadViewSearchCustomValueDateTimeInput();
                    }
U
unknown 已提交
1185 1186 1187
                    break;
                case "dateValue":
                    this.loadComparisonSelect(this.lp.dateFilter);
1188 1189 1190 1191 1192
                    if( selectableList.length > 0 ){
                        this.loadViewSerchCustomSelectByScript(selectableList)
                    }else {
                        this.loadViewSearchCustomValueDateInput();
                    }
U
unknown 已提交
1193 1194 1195
                    break;
                case "timeValue":
                    this.loadComparisonSelect(this.lp.dateFilter);
1196 1197 1198 1199 1200
                    if( selectableList.length > 0 ){
                        this.loadViewSerchCustomSelectByScript(selectableList)
                    }else {
                        this.loadViewSearchCustomValueTimeInput();
                    }
U
unknown 已提交
1201 1202 1203
                    break;
                case "booleanValue":
                    this.loadComparisonSelect(this.lp.booleanFilter);
1204 1205 1206 1207 1208
                    if( selectableList.length > 0 ){
                        this.loadViewSerchCustomSelectByScript(selectableList)
                    }else {
                        this.loadViewSearchCustomValueBooleanInput();
                    }
U
unknown 已提交
1209 1210 1211
                    break;
                default:
                    this.loadComparisonSelect(this.lp.textFilter);
1212 1213 1214 1215 1216
                    if( selectableList.length > 0 ){
                        this.loadViewSerchCustomSelectByScript(selectableList)
                    }else {
                        this.loadViewSearchCustomValueTextInput();
                    }
R
roo00 已提交
1217
            }
U
unknown 已提交
1218 1219
        }
    },
1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233
    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] })
                    }
                }
R
roo00 已提交
1234
            }
U
unknown 已提交
1235
        }
1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251
        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));
U
unknown 已提交
1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270
    },
    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,
1271
                "secondEnable" : true,
U
unknown 已提交
1272 1273 1274
                "target": this.container,
                "format": "db"
            });
R
roo00 已提交
1275 1276
        }.bind(this));
    },
U
unknown 已提交
1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291
    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));
R
roo00 已提交
1292
    },
U
unknown 已提交
1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307
    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));
R
roo00 已提交
1308
    },
U
unknown 已提交
1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327
    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);
R
roo00 已提交
1328
        }.bind(this));
U
unknown 已提交
1329 1330 1331 1332 1333
    },
    closeCustomSearch: function(){
        if (this.viewSearchCustomContentNode && this.viewSearchCustomContentNode.getStyle("display")==="block"){
            this.viewSearchCustomCloseActionNode.setStyle("display", "none");
            this.viewSearchCustomContentNode.setStyle("display", "none");
R
roo00 已提交
1334

U
unknown 已提交
1335 1336 1337
            var x = this.viewSearchInputAreaNode.getParent().getSize().x;
            x1 = x-2-10-90;
            this.css.viewFilterSearchInputAreaNode.width = ""+x1+"px";
R
roo00 已提交
1338

U
unknown 已提交
1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351
            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");

U
unknown 已提交
1352
                if(this.setContentHeightFun)this.setContentHeightFun();
U
unknown 已提交
1353
            }.bind(this));
1354
            this.lastFilterItems = this.filterItems;
U
unknown 已提交
1355 1356
            this.createViewNode({"filterList": this.json.filter ? this.json.filter.clone() : null});
        }
R
roo00 已提交
1357
    },
U
unknown 已提交
1358 1359 1360 1361 1362 1363
    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;
R
roo00 已提交
1364
        }
U
unknown 已提交
1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377
        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 = "";

1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401
            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");
                }
R
roo00 已提交
1402
            }
1403

U
unknown 已提交
1404 1405 1406
            if (value===""){
                MWF.xDesktop.notice("error", {"x": "left", "y": "top"}, this.lp.filterErrorValue, this.viewSearchCustomValueContentNode, {"x": 0, "y": 85});
                return false;
U
unknown 已提交
1407
            }
U
unknown 已提交
1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420

            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();
        }
U
unknown 已提交
1421
    },
U
unknown 已提交
1422 1423 1424 1425
    searchViewRemoveFilter: function(filter){
        this.filterItems.erase(filter);
        filter.destroy();
        this.searchCustomView()
1426
    },
U
unknown 已提交
1427
    //搜索相关结束
1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449

    //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 );
    },
U
unknown 已提交
1450 1451 1452
    getSelectedData : function(){
        return this.getData();
    },
U
unknown 已提交
1453 1454 1455 1456 1457 1458 1459
    getSelectAllStatus : function(){
        if( this.getSelectFlag()!=="multi")return;
        if( !this.items.length )return "none";
        var allFlag = true, noneFlag = true;
        for( var i=0; i<this.items.length; i++ ){
            var item = this.items[i];
            if( item.clazzType === "item" ){
U
unknown 已提交
1460 1461 1462
                if( item.data.$selectedEnable ){
                    item.isSelected ? ( noneFlag = false ) : (allFlag = false);
                }
U
unknown 已提交
1463
            }else{
U
unknown 已提交
1464 1465 1466 1467 1468 1469 1470 1471 1472 1473
                if( item.data.$selectedEnable ) {
                    var f = item.getSelectAllStatus();
                    if (f === "none") {
                        allFlag = false;
                    } else if (f === "all") {
                        noneFlag = false;
                    } else if (f === "some") {
                        allFlag = false;
                        noneFlag = false;
                    }
U
unknown 已提交
1474 1475 1476 1477 1478
                }
            }
            if( !allFlag && !noneFlag )return "some"
        }
        if( noneFlag )return "none";
U
unknown 已提交
1479
        if( allFlag )return "all";
U
unknown 已提交
1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508
        return "some";
    },
    checkSelectAllStatus : function(){
        if(!this.selectAllNode)return;
       var status = this.getSelectAllStatus();
       if( status === "all" ){
           this.setSelectAllStyle()
       }else{
           this.setUnSelectAllStyle()
       }
    },
    setSelectAllStyle : function () {
        if(!this.selectAllNode)return;
        if( this.viewJson.viewStyles && this.viewJson.viewStyles["checkedCheckboxNode"] ){
            this.selectAllNode.setStyles( this.viewJson.viewStyles["checkedCheckboxNode"] );
        }else {
            this.selectAllNode.getElement("img").set("src",
                '../x_component_query_Query/$Viewer/" + this.options.style + "/icon/checkbox_checked.png' )
        }
    },
    setUnSelectAllStyle : function () {
        if(!this.selectAllNode)return;
        if( this.viewJson.viewStyles && this.viewJson.viewStyles["checkboxNode"] ){
            this.selectAllNode.setStyles( this.viewJson.viewStyles["checkboxNode"] );
        }else {
            this.selectAllNode.getElement("img").set("src",
                '../x_component_query_Query/$Viewer/" + this.options.style + "/icon/checkbox.png' )
        }
    },
U
unknown 已提交
1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520
    clearSelectAllStyle : function(){
        debugger;
        if(!this.selectAllNode)return;
        var viewStyles = this.viewJson.viewStyles;
        var viewTitleCellNode = (viewStyles && viewStyles["titleTd"]) ? viewStyles["titleTd"] : this.css.viewTitleCellNode;
        if( !viewTitleCellNode["background"] || !viewTitleCellNode["background-image"] || !viewTitleCellNode["background-color"] ){
            viewTitleCellNode["background"] = "inherit";
        }
        this.selectAllNode.setStyles( viewTitleCellNode );
        var img = this.selectAllNode.getElement("img");
        if( img )img.set("src", '../x_component_query_Query/$Viewer/" + this.options.style + "/icon/blank.png')
    },
1521
    selectAll : function(){
U
unknown 已提交
1522 1523
        // var flag = this.json.select || this.viewJson.select ||  "none";
        if ( this.getSelectFlag()==="multi"){
1524
            this.items.each( function (item) {
U
unknown 已提交
1525 1526 1527 1528 1529 1530
                if( item.data.$selectedEnable ){
                    if( item.clazzType === "item" ){
                        item.selected("view");
                    }else{
                        item.selectAll("view");
                    }
1531 1532
                }
            })
U
unknown 已提交
1533 1534 1535
            if( this.viewJson.allowSelectAll ) {
                this.setSelectAllStyle();
            }
1536 1537 1538
        }
    },
    unSelectAll : function(){
U
unknown 已提交
1539 1540
        // var flag = this.json.select || this.viewJson.select ||  "none";
        if ( this.getSelectFlag()==="multi"){
1541
            this.items.each( function (item) {
U
unknown 已提交
1542 1543 1544 1545 1546 1547
                if( item.data.$selectedEnable ) {
                    if (item.clazzType === "item") {
                        item.unSelected("view");
                    } else {
                        item.unSelectAll("view");
                    }
1548 1549
                }
            })
U
unknown 已提交
1550 1551 1552
            if( this.viewJson.allowSelectAll ) {
                this.setUnSelectAllStyle();
            }
1553 1554
        }
    },
U
unknown 已提交
1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647

    getExpandAllStatus: function(){
        if( !this.items.length )return "none";
        var allFlag = true, noneFlag = true;
        for( var i=0; i<this.items.length; i++ ){
            var item = this.items[i];
            item.expanded ? ( noneFlag = false ) : (allFlag = false);
            if( !allFlag && !noneFlag )return "some"
        }
        if( allFlag )return "all";
        if( noneFlag )return "none";
        return "some";
    },
    checkExpandAllStatus: function(){
        if(!this.expandAllNode)return;
        var status = this.getExpandAllStatus();
        if( status === "all" ){
            this.setExpandAllStyle()
        }else{
            this.setCollapseAllStyle()
        }
    },
    setExpandAllStyle: function(){
        if(!this.expandAllNode)return;
        if( this.viewJson.viewStyles && this.viewJson.viewStyles["groupExpandNode"] ){
            this.expandAllNode.setStyles( this.viewJson.viewStyles["groupExpandNode"] );
        }else{
            this.expandAllNode.set("html", "<img src='../x_component_query_Query/$Viewer/"+this.options.style+"/icon/expand.png'/>");
        }
    },
    setCollapseAllStyle : function(){
        if(!this.expandAllNode)return;
        if( this.viewJson.viewStyles && this.viewJson.viewStyles["groupCollapseNode"] ){
            this.expandAllNode.setStyles( this.viewJson.viewStyles["groupCollapseNode"] );
        }else{
            this.expandAllNode.set("html", "<img src='../x_component_query_Query/$Viewer/"+this.options.style+"/icon/down.png'/>");
        }
    },
    expandAll: function(){
        this.items.each(function(item, i){
            window.setTimeout(function(){
                item.expand( "view" );
            }.bind(this), 10*i+5);
        }.bind(this));
        this.setExpandAllStyle();
    },
    collapseAll: function(){
        this.items.each(function(item){
            item.collapse( "view" );
        }.bind(this));
        this.setCollapseAllStyle();
    },
    expandOrCollapseAll: function(){
        this.getExpandAllStatus() === "all" ? this.collapseAll() : this.expandAll();
        // if( this.viewJson.viewStyles && this.viewJson.viewStyles["groupCollapseNode"] ){
        //     var span = this.expandAllNode; //this.selectTitleCell.getElement("span");
        //     if( this.isAllExpanded ){
        //         this.items.each(function(item){
        //             item.collapse();
        //             span.setStyles( this.viewJson.viewStyles["groupCollapseNode"] );
        //         }.bind(this));
        //         this.isAllExpanded = false;
        //     }else{
        //         this.items.each(function(item, i){
        //             window.setTimeout(function(){
        //                 item.expand();
        //             }.bind(this), 10*i+5);
        //
        //             span.setStyles( this.viewJson.viewStyles["groupExpandNode"] );
        //             this.isAllExpanded = true;
        //         }.bind(this));
        //     }
        // }else{
        //     var icon = this.expandAllNode; //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));
        //         this.isAllExpanded = false;
        //     }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));
        //         this.isAllExpanded = true;
        //     }
        // }
    },

1648
    setFilter : function( filter, callback ){
1649
        if( this.lookuping || this.pageloading )return;
1650 1651 1652
        if( !filter )filter = [];
        if( typeOf( filter ) === "object" )filter = [ filter ];
        this.json.filter = filter;
1653
        if( this.viewAreaNode ){
1654
            this.createViewNode({"filterList": this.json.filter  ? this.json.filter.clone() : null}, callback);
1655
        }
1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686
    },
    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)
U
unknown 已提交
1687
    },
1688
    //api 使用 结束
U
unknown 已提交
1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729

    loadObserver: function(){
        debugger;
        if( this.io ){
            this.io.disconnect();
            this.io = null;
        }
        if( !this.options.lazy )return;
        if (typeof window !== 'undefined' && window.IntersectionObserver) {
            this.io = new IntersectionObserver( function (entries, observer) {
                entries.forEach(function (entry) {
                    if (entry.intersectionRatio > 0 || entry.isIntersecting) {
                        var item = entry.target.retrieve("item");
                        if( item && !item.loading && !item.loaded){ //已经加载完成
                            item.active();
                        }
                        observer.unobserve(entry.target);
                    }
                })
            }, {
                root: this.contentAreaNode,
                rootMargin: "10px 0px 0px 0px"
            });
        }
    },
    loadIOResource: function (callback) {
        if( !this.options.lazy ){
            callback();
            return;
        }
        var observerPath = "../o2_lib/IntersectionObserver/intersection-observer.min.js";
        var observerPath_ie11 = "../o2_lib/IntersectionObserver/polyfill_ie11.min.js";
        if( window.IntersectionObserver && window.MutationObserver) {
            if(callback)callback();
        }else if( !!window.MSInputMethodContext && !!document.documentMode ){ //ie11
            o2.load(observerPath_ie11, function () { callback(); }.bind(this));
        }else{
            o2.load([observerPath, observerPath_ie11], function () { callback(); }.bind(this));
        }
    }

R
roo00 已提交
1730 1731 1732
});

MWF.xApplication.query.Query.Viewer.Item = new Class({
U
unknown 已提交
1733
    initialize: function(view, data, prev, i, category, lazy){
R
roo00 已提交
1734 1735 1736 1737
        this.view = view;
        this.data = data;
        this.css = this.view.css;
        this.isSelected = false;
U
unknown 已提交
1738
        this.category = category;
R
roo00 已提交
1739
        this.prev = prev;
R
roo00 已提交
1740
        this.idx = i;
1741
        this.clazzType = "item";
U
unknown 已提交
1742
        this.lazy = lazy;
R
roo00 已提交
1743 1744 1745
        this.load();
    },
    load: function(){
U
unknown 已提交
1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759
        if( this.lazy && this.view.io ){
            this.view.fireEvent("queryLoadItemRow", [null, this]);
            this.loadNode();
            this.view.io.observe( this.node );
        }else{
            this._load();
        }
    },
    active: function(){
        if( !this.loaded && !this.loading ){
            this._load();
        }
    },
    loadNode: function(){
U
unknown 已提交
1760
        var viewStyles = this.view.viewJson.viewStyles;
U
unknown 已提交
1761
        var trStyle = ( viewStyles && viewStyles["contentTr"] ) ? viewStyles["contentTr"] : this.css.viewContentTrNode;
U
unknown 已提交
1762 1763

        this.node = new Element("tr", {
U
unknown 已提交
1764
            "styles": trStyle
U
unknown 已提交
1765
        });
R
roo00 已提交
1766 1767 1768 1769 1770
        if (this.prev){
            this.node.inject(this.prev.node, "after");
        }else{
            this.node.inject(this.view.viewTable);
        }
U
unknown 已提交
1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787
        this.node.store("item", this);
        if( this.lazy && this.view.io ) {
            var viewContentTdNode = ( viewStyles && viewStyles["contentTd"] ) ? viewStyles["contentTd"] : this.css.viewContentTdNode;
            this.placeholderTd = new Element("td", {
                "styles": viewContentTdNode
            }).inject(this.node)
        }
    },
    _load: function(){
        this.loading = true;

        if(!this.node)this.view.fireEvent("queryLoadItemRow", [null, this]);

        var viewStyles = this.view.viewJson.viewStyles;
        var viewContentTdNode = ( viewStyles && viewStyles["contentTd"] ) ? viewStyles["contentTd"] : this.css.viewContentTdNode;

        if(!this.node)this.loadNode();
R
roo00 已提交
1788 1789

        //if (this.view.json.select==="single" || this.view.json.select==="multi"){
U
unknown 已提交
1790
        this.selectTd = new Element("td", { "styles": viewContentTdNode }).inject(this.node);
U
unknown 已提交
1791 1792
        this.selectTd.setStyles({"cursor": "pointer"});
        if (this.view.json.itemStyles) this.selectTd.setStyles(this.view.json.itemStyles);
U
unknown 已提交
1793 1794 1795

        //var selectFlag = this.view.json.select || this.view.viewJson.select ||  "none";
        var selectFlag = this.view.getSelectFlag();
U
unknown 已提交
1796
        if ( this.data.$selectedEnable && ["multi","single"].contains(selectFlag) && this.view.viewJson.selectBoxShow==="always") {
U
unknown 已提交
1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810
            var viewStyles = this.view.viewJson.viewStyles;
            if (viewStyles) {
                if (selectFlag === "single") {
                    this.selectTd.setStyles(viewStyles["radioNode"]);
                } else {
                    this.selectTd.setStyles(viewStyles["checkboxNode"]);
                }
            } else {
                var iconName = "checkbox";
                if (selectFlag === "single") iconName = "radiobox";
                this.selectTd.setStyles({"background": "url(" + "../x_component_query_Query/$Viewer/default/icon/" + iconName + ".png) center center no-repeat"});
            }
        }

1811 1812 1813
        if( this.view.isSelectTdHidden() ){
            this.selectTd.hide();
        }
R
roo00 已提交
1814 1815
        //}

R
roo00 已提交
1816
        //序号
1817 1818
        var sequence = 1+this.view.json.pageSize*(this.view.currentPage-1)+this.idx;
        this.data["$sequence"] = sequence;
R
roo00 已提交
1819
        if (this.view.viewJson.isSequence==="yes"){
U
unknown 已提交
1820
            this.sequenceTd = new Element("td", {"styles": viewContentTdNode}).inject(this.node);
R
roo00 已提交
1821
            this.sequenceTd.setStyle("width", "10px");
1822
            this.sequenceTd.set("text", sequence);
R
roo00 已提交
1823 1824
        }

R
roo00 已提交
1825 1826 1827 1828
        Object.each(this.view.entries, function(c, k){
            var cell = this.data.data[k];
            if (cell === undefined) cell = "";
            //if (cell){
U
unknown 已提交
1829
            if (this.view.hideColumns.indexOf(k)===-1){
U
unknown 已提交
1830
                var td = new Element("td", {"styles": viewContentTdNode}).inject(this.node);
U
unknown 已提交
1831 1832 1833 1834 1835 1836 1837
                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);
U
unknown 已提交
1838
                    }
1839
                    if( typeOf(c.contentProperties) === "object" )td.setProperties(c.contentProperties);
1840 1841 1842 1843 1844 1845 1846 1847 1848
                    if (this.view.json.itemStyles) td.setStyles(this.view.json.itemStyles);
                    if( typeOf(c.contentStyles) === "object" )td.setStyles(c.contentStyles);
                }else{
                    if (this.view.json.itemStyles) td.setStyles(this.view.json.itemStyles);
                }

                if (this.view.openColumns.indexOf(k)!==-1){
                    this.setOpenWork(td, c)
                }
1849

1850
                if (k!== this.view.viewJson.group.column){
1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865
                    Object.each( c.events || {}, function (e , key) {
                        if(e.code){
                            if( key === "loadContent" ){
                                this.view.Macro.fire( e.code,
                                    {"node" : td, "json" : c, "data" : v, "view": this.view, "row" : this});
                            }else if( key !== "loadTitle" ){
                                td.addEvent(key, function(event){
                                    return this.view.Macro.fire(
                                        e.code,
                                        {"node" : td, "json" : c, "data" : v, "view": this.view, "row" : this},
                                        event
                                    );
                                }.bind(this));
                            }
                        }
1866
                    }.bind(this));
U
unknown 已提交
1867 1868
                }
            }
R
roo00 已提交
1869 1870 1871
            //}
        }.bind(this));

U
unknown 已提交
1872 1873 1874 1875
        if(this.placeholderTd){
            this.placeholderTd.destroy();
            this.placeholderTd = null;
        }
U
unknown 已提交
1876

1877
        //默认选中
1878
        var selectedFlag;
1879 1880 1881 1882 1883 1884
        var defaultSelectedScript = this.view.json.defaultSelectedScript || this.view.viewJson.defaultSelectedScript;
        if( !this.isSelected && defaultSelectedScript ){
            // var flag = this.view.json.select || this.view.viewJson.select ||  "none";
            // if ( flag ==="single" || flag==="multi"){
            //
            // }
1885
            selectedFlag = this.view.Macro.exec( defaultSelectedScript,
1886
                {"node" : this.node, "data" : this.data, "view": this.view, "row" : this});
1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904
        }
        //判断是不是在selectedItems中,用户手工选择
        if( !this.isSelected && this.view.selectedItems.length ){
            for(var i=0; i<this.view.selectedItems.length; i++){
                if( this.view.selectedItems[i].data.bundle === this.data.bundle ){
                    selectedFlag = "true";
                    break;
                }
            }
        }

        if( selectedFlag ){
            if( selectedFlag === "multi" || selectedFlag === "single" ){
                this.select( selectedFlag );
            }else if( selectedFlag.toString() === "true" ){
                var f = this.view.json.select || this.view.viewJson.select ||  "none";
                if ( f ==="single" || f==="multi"){
                    this.select();
1905 1906 1907 1908
                }
            }
        }

R
roo00 已提交
1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923
        // 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();
U
unknown 已提交
1924

1925
        this.view.fireEvent("postLoadItemRow", [null, this]);
U
unknown 已提交
1926 1927 1928

        this.loading = false;
        this.loaded = true;
R
roo00 已提交
1929
    },
R
roo00 已提交
1930
    setOpenWork: function(td, column){
R
roo00 已提交
1931
        td.setStyle("cursor", "pointer");
R
roo00 已提交
1932
        if( column.clickCode ){
U
unknown 已提交
1933 1934 1935 1936 1937 1938
            // 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);
            // }
R
roo00 已提交
1939
            td.addEvent("click", function( ev ){
U
unknown 已提交
1940 1941 1942
                var result = this.view.Macro.fire(column.clickCode, this, ev);
                ev.stopPropagation();
                return result;
R
roo00 已提交
1943
            }.bind(this));
NoSubject's avatar
NoSubject 已提交
1944
        }else{
R
roo00 已提交
1945
            if (this.view.json.type==="cms"){
U
unknown 已提交
1946 1947 1948 1949
                td.addEvent("click", function(ev){
                    this.openCms(ev)
                    ev.stopPropagation();
                }.bind(this));
R
roo00 已提交
1950
            }else{
U
unknown 已提交
1951 1952 1953 1954
                td.addEvent("click", function(ev){
                    this.openWorkAndCompleted(ev)
                    ev.stopPropagation();
                }.bind(this));
R
roo00 已提交
1955
            }
NoSubject's avatar
NoSubject 已提交
1956 1957 1958 1959 1960
        }

    },
    openCms: function(e){
        var options = {"documentId": this.data.bundle};
U
unknown 已提交
1961
        this.view.fireEvent("openDocument", [options, this]); //options 传入的事件
NoSubject's avatar
NoSubject 已提交
1962
        layout.desktop.openApplication(e, "cms.Document", options);
R
roo00 已提交
1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009
    },
    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){
NoSubject's avatar
NoSubject 已提交
2010
            json.data.each(function(task){
R
roo00 已提交
2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025
                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();
NoSubject's avatar
NoSubject 已提交
2026
            var id = e.target.retrieve("workId");
R
roo00 已提交
2027
            worksAreaNode.destroy();
NoSubject's avatar
NoSubject 已提交
2028
            this.openWorkCompleted(id, e);
R
roo00 已提交
2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039
        }.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(){
2040 2041 2042 2043 2044
        var cssWorksArea = this.css.worksAreaNode
        if (layout.mobile) {
            cssWorksArea = this.css.worksAreaNodeMobile;
        }
        var worksAreaNode = new Element("div", {"styles": cssWorksArea});
R
roo00 已提交
2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055
        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){
R
roo00 已提交
2056
        MWF.require("MWF.widget.Mask", null, false);
R
roo00 已提交
2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084
        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};
U
unknown 已提交
2085
        this.view.fireEvent("openDocument", [options, this]); //options 传入的事件
R
roo00 已提交
2086 2087 2088 2089
        layout.desktop.openApplication(e, "process.Work", options);
    },
    openWorkCompleted: function(id, e){
        var options = {"workCompletedId": id};
U
unknown 已提交
2090
        this.view.fireEvent("openDocument", [options, this]); //options 传入的事件
R
roo00 已提交
2091 2092 2093 2094
        layout.desktop.openApplication(e, "process.Work", options);
    },

    setEvent: function(){
U
unknown 已提交
2095
        var flag = this.view.getSelectFlag();
U
unknown 已提交
2096
        if ( this.data.$selectedEnable && (flag ==="single" || flag==="multi")){
R
roo00 已提交
2097 2098
            this.node.addEvents({
                "mouseover": function(){
U
unknown 已提交
2099
                    if (!this.isSelected && this.view.viewJson.selectBoxShow !=="always" ){
U
unknown 已提交
2100 2101 2102 2103 2104 2105 2106 2107 2108 2109
                        var viewStyles = this.view.viewJson.viewStyles;
                        if( viewStyles ){
                            if( flag === "single" ){
                                this.selectTd.setStyles( viewStyles["radioNode"] );
                            }else{
                                this.selectTd.setStyles( viewStyles["checkboxNode"] );
                            }
                        }else{
                            var iconName = "checkbox";
                            if (flag==="single") iconName = "radiobox";
2110
                            this.selectTd.setStyles({"background": "url("+"../x_component_query_Query/$Viewer/default/icon/"+iconName+".png) center center no-repeat"});
U
unknown 已提交
2111
                        }
R
roo00 已提交
2112 2113 2114
                    }
                }.bind(this),
                "mouseout": function(){
U
unknown 已提交
2115
                    if (!this.isSelected && this.view.viewJson.selectBoxShow !=="always") this.selectTd.setStyles({"background": "transparent"});
R
roo00 已提交
2116 2117 2118 2119 2120 2121
                }.bind(this),
                "click": function(){this.select();}.bind(this)
            });
        }
    },

2122
    select: function(  force ){
2123
        debugger
U
unknown 已提交
2124 2125
        // var flag = force || this.view.json.select || this.view.viewJson.select ||  "none";
        var flag = force || this.view.getSelectFlag();
R
roo00 已提交
2126
        if (this.isSelected){
U
unknown 已提交
2127
            if (flag==="single"){
R
roo00 已提交
2128 2129 2130 2131 2132
                this.unSelectedSingle();
            }else{
                this.unSelected();
            }
        }else{
U
unknown 已提交
2133
            if (flag==="single"){
R
roo00 已提交
2134 2135 2136 2137 2138
                this.selectedSingle();
            }else{
                this.selected();
            }
        }
U
unknown 已提交
2139
        this.view.fireEvent("select"); //options 传入的事件
R
roo00 已提交
2140 2141
    },

U
unknown 已提交
2142
    selected: function( from ){
2143 2144 2145 2146 2147 2148 2149
        for(var i=0; i<this.view.selectedItems.length; i++){
            var item = this.view.selectedItems[i];
            if( item.data.bundle === this.data.bundle ){
                this.view.selectedItems.erase(item);
                break;
            }
        }
R
roo00 已提交
2150
        this.view.selectedItems.push(this);
U
unknown 已提交
2151 2152 2153 2154 2155
        var viewStyles = this.view.viewJson.viewStyles;
        if( viewStyles ){
            this.selectTd.setStyles( viewStyles["checkedCheckboxNode"] );
            this.node.setStyles( viewStyles["contentSelectedTr"] );
        }else{
2156
            this.selectTd.setStyles({"background": "url("+"../x_component_query_Query/$Viewer/default/icon/checkbox_checked.png) center center no-repeat"});
U
unknown 已提交
2157 2158
            this.node.setStyles(this.css.viewContentTrNode_selected);
        }
R
roo00 已提交
2159
        this.isSelected = true;
U
unknown 已提交
2160 2161 2162 2163
        if( from !== "view" && from !=="category" && this.view.viewJson.allowSelectAll ){
            this.view.checkSelectAllStatus();
            if( this.category )this.category.checkSelectAllStatus();
        }
U
unknown 已提交
2164
        this.view.fireEvent("selectRow", [this]);
R
roo00 已提交
2165
    },
U
unknown 已提交
2166
    unSelected: function( from ){
2167 2168 2169 2170 2171 2172 2173
        for(var i=0; i<this.view.selectedItems.length; i++){
            var item = this.view.selectedItems[i];
            if( item.data.bundle === this.data.bundle ){
                this.view.selectedItems.erase(item);
                break;
            }
        }
U
unknown 已提交
2174
        var viewStyles = this.view.viewJson.viewStyles;
U
unknown 已提交
2175 2176 2177 2178 2179 2180 2181 2182 2183
        if( this.view.viewJson.selectBoxShow !=="always" ){
            this.selectTd.setStyles({"background": "transparent"});
        }else{
            if (viewStyles) {
                this.selectTd.setStyles(viewStyles["checkboxNode"]);
            }else{
                this.selectTd.setStyles({"background": "url(" + "../x_component_query_Query/$Viewer/default/icon/checkbox.png) center center no-repeat"});
            }
        }
U
unknown 已提交
2184 2185 2186
        if( viewStyles ){
            this.node.setStyles( viewStyles["contentTr"] );
        }else{
2187
            this.node.setStyles(this.css.viewContentTrNode);
U
unknown 已提交
2188
        }
R
roo00 已提交
2189
        this.isSelected = false;
U
unknown 已提交
2190 2191 2192 2193
        if( from !== "view" && from !=="category" && this.view.viewJson.allowSelectAll ){
            this.view.checkSelectAllStatus();
            if( this.category )this.category.checkSelectAllStatus();
        }
U
unknown 已提交
2194
        this.view.fireEvent("unselectRow", [this]);
R
roo00 已提交
2195 2196 2197 2198 2199
    },
    selectedSingle: function(){
        if (this.view.currentSelectedItem) this.view.currentSelectedItem.unSelectedSingle();
        this.view.selectedItems = [this];
        this.view.currentSelectedItem = this;
U
unknown 已提交
2200 2201 2202 2203 2204
        var viewStyles = this.view.viewJson.viewStyles;
        if( viewStyles ){
            this.selectTd.setStyles( viewStyles["checkedRadioNode"] );
            this.node.setStyles( viewStyles["contentSelectedTr"] );
        }else {
2205
            this.selectTd.setStyles({"background": "url(" + "../x_component_query_Query/$Viewer/default/icon/radiobox_checked.png) center center no-repeat"});
U
unknown 已提交
2206 2207
            this.node.setStyles(this.css.viewContentTrNode_selected);
        }
R
roo00 已提交
2208
        this.isSelected = true;
U
unknown 已提交
2209
        this.view.fireEvent("selectRow", [this]);
R
roo00 已提交
2210 2211 2212 2213
    },
    unSelectedSingle: function(){
        this.view.selectedItems = [];
        this.view.currentSelectedItem = null;
U
unknown 已提交
2214
        var viewStyles = this.view.viewJson.viewStyles;
U
unknown 已提交
2215 2216 2217 2218 2219 2220 2221 2222 2223
        if( this.view.viewJson.selectBoxShow !=="always" ){
            this.selectTd.setStyles({"background": "transparent"});
        }else{
            if (viewStyles) {
                this.selectTd.setStyles(viewStyles["radioNode"]);
            }else{
                this.selectTd.setStyles({"background": "url(" + "../x_component_query_Query/$Viewer/default/icon/radiobox.png) center center no-repeat"});
            }
        }
U
unknown 已提交
2224 2225 2226 2227 2228
        if( viewStyles ){
            this.node.setStyles( viewStyles["contentTr"] );
        }else{
            this.node.setStyles(this.css.viewContentTrNode);
        }
R
roo00 已提交
2229
        this.isSelected = false;
U
unknown 已提交
2230
        this.view.fireEvent("unselectRow", [this]);
R
roo00 已提交
2231 2232 2233 2234
    }
});

MWF.xApplication.query.Query.Viewer.ItemCategory = new Class({
R
roo00 已提交
2235
    initialize: function(view, data, i){
R
roo00 已提交
2236 2237 2238 2239 2240
        this.view = view;
        this.data = data;
        this.css = this.view.css;
        this.items = [];
        this.loadChild = false;
R
roo00 已提交
2241
        this.idx = i;
2242
        this.clazzType = "category";
R
roo00 已提交
2243 2244 2245
        this.load();
    },
    load: function(){
2246
        this.view.fireEvent("queryLoadCategoryRow", [null, this]);
U
unknown 已提交
2247

U
unknown 已提交
2248 2249 2250 2251 2252 2253 2254
        var viewStyles = this.view.viewJson.viewStyles;

        var viewContentCategoryTdNode = ( viewStyles && viewStyles["contentGroupTd"] ) ? viewStyles["contentGroupTd"] : this.css.viewContentCategoryTdNode;

        this.node = new Element("tr", {
            "styles": (viewStyles && viewStyles["contentTr"]) ? viewStyles["contentTr"] : this.css.viewContentTrNode
        }).inject(this.view.viewTable);
R
roo00 已提交
2255
        //if (this.view.json.select==="single" || this.view.json.select==="multi"){
U
unknown 已提交
2256
        this.selectTd = new Element("td", {"styles": viewContentCategoryTdNode}).inject(this.node);
U
unknown 已提交
2257
        if (this.view.json.itemStyles) this.selectTd.setStyles(this.view.json.itemStyles);
U
unknown 已提交
2258

U
unknown 已提交
2259
        if( this.data.$selectedEnable && this.view.getSelectFlag() === "multi" && this.view.viewJson.allowSelectAll ){
U
unknown 已提交
2260 2261 2262 2263 2264 2265
            this.selectAllNode = this.selectTd;
            if( viewStyles && viewStyles["checkboxNode"] ){
                this.selectAllNode.setStyles( viewStyles["checkboxNode"] )
                // this.selectAllNode = new Element("span", {
                //     styles : viewStyles["checkboxNode"]
                // }).inject( this.selectTd );
U
unknown 已提交
2266
            }else{
U
unknown 已提交
2267 2268 2269 2270 2271
                this.selectAllNode.set( "html", "<img src='../x_component_query_Query/$Viewer/"+this.options.style+"/icon/checkbox.png'/>"+"</span>" )
                // this.selectAllNode = new Element("span",{
                //     html : "<img src='../x_component_query_Query/$Viewer/"+this.options.style+"/icon/checkbox.png'/>"+"</span>",
                //     style : "font-family: Webdings"
                // }).inject( this.selectTd );
U
unknown 已提交
2272 2273
            }
            this.selectAllNode.setStyle("cursor", "pointer");
U
unknown 已提交
2274
            this.selectAllNode.addEvent("click", function (ev) {
U
unknown 已提交
2275 2276 2277 2278 2279
                if( this.getSelectAllStatus() === "all" ){
                    this.unSelectAll("category")
                }else{
                    this.selectAll("category");
                }
U
unknown 已提交
2280
                ev.stopPropagation();
U
unknown 已提交
2281 2282 2283
            }.bind(this));
        }

2284 2285 2286 2287
        // if( this.view.isSelectTdHidden() ){
        //     this.selectTd.hide();
        // }

R
roo00 已提交
2288 2289
        //}
        this.categoryTd = new Element("td", {
U
unknown 已提交
2290
            "styles": viewContentCategoryTdNode,
R
roo00 已提交
2291
            "colspan": this.view.viewJson.selectList.length+1
R
roo00 已提交
2292 2293 2294 2295 2296 2297 2298 2299 2300
        }).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;
            }
        }
2301

R
roo00 已提交
2302 2303 2304 2305 2306 2307 2308
        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;
        }

U
unknown 已提交
2309 2310 2311 2312 2313 2314 2315
        if( viewStyles && viewStyles["groupCollapseNode"] ){
            this.expandNode = new Element("span", {
                styles : viewStyles["groupCollapseNode"]
            }).inject( this.categoryTd );
            new Element("span", { text : text }).inject( this.categoryTd );
            // this.categoryTd.set("text", text );
        }else{
2316
            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);
U
unknown 已提交
2317 2318
        }
        this.expanded = false;
R
roo00 已提交
2319 2320
        if (this.view.json.itemStyles) this.categoryTd.setStyles(this.view.json.itemStyles);

2321 2322 2323 2324 2325
        if( this.groupColumn ){
            if( typeOf(this.groupColumn.contentStyles) === "object" )this.categoryTd.setStyles(this.groupColumn.contentStyles);
            if( typeOf(this.groupColumn.contentProperties) === "object" )this.categoryTd.setProperties(this.groupColumn.contentProperties);
        }

R
roo00 已提交
2326
        this.setEvent();
U
unknown 已提交
2327

2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344
        var column = this.groupColumn;
        var td = this.categoryTd;
        Object.each( column.events || {}, function (e , key) {
            if(e.code){
                if( key === "loadContent" ){
                    this.view.Macro.fire( e.code,
                        {"node" : td, "json" : column, "data" : this.data.group, "view": this.view, "row" : this});
                }else if( key !== "loadTitle" ){
                    td.addEvent(key, function(event){
                        return this.view.Macro.fire(
                            e.code,
                            {"node" : td, "json" : column, "data" : this.data.group, "view": this.view, "row" : this},
                            event
                        );
                    }.bind(this));
                }
            }
2345
        }.bind(this));
2346

2347
        this.view.fireEvent("postLoadCategoryRow", [null, this]);
R
roo00 已提交
2348
    },
U
unknown 已提交
2349 2350 2351 2352 2353 2354 2355
    getSelectAllStatus : function(){
        if ( this.view.getSelectFlag()!=="multi")return;
        if( !this.items.length )return "none";
        var flag = "all";
        var allFlag = true, noneFlag = true;
        for( var i=0; i<this.items.length; i++ ){
            var item = this.items[i];
U
unknown 已提交
2356 2357 2358 2359
            if( item.data.$selectedEnable ){
                item.isSelected ? ( noneFlag = false ) : (allFlag = false);
                if( !allFlag && !noneFlag )return "some"
            }
U
unknown 已提交
2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375
        }
        if( allFlag )return "all";
        if( noneFlag )return "none";
        return "some";
    },
    checkSelectAllStatus : function(){
        if( !this.selectAllNode )return;
        var status = this.getSelectAllStatus();
        if( status === "all" ){
            this.setSelectAllStyle()
        }else{
            this.setUnSelectAllStyle()
        }
    },
    setSelectAllStyle : function () {
        if( !this.selectAllNode )return;
U
unknown 已提交
2376 2377
        if( this.view.viewJson.viewStyles && this.view.viewJson.viewStyles["checkedCheckboxNode"] ){
            this.selectAllNode.setStyles( this.view.viewJson.viewStyles["checkedCheckboxNode"] );
U
unknown 已提交
2378 2379 2380 2381 2382 2383 2384
        }else {
            this.selectAllNode.getElement("img").set("src",
                '../x_component_query_Query/$Viewer/" + this.options.style + "/icon/checkbox_checked.png' )
        }
    },
    setUnSelectAllStyle : function () {
        if( !this.selectAllNode )return;
U
unknown 已提交
2385 2386
        if( this.view.viewJson.viewStyles && this.view.viewJson.viewStyles["checkboxNode"] ){
            this.selectAllNode.setStyles( this.view.viewJson.viewStyles["checkboxNode"] );
U
unknown 已提交
2387 2388 2389 2390 2391 2392 2393 2394 2395 2396
        }else {
            this.selectAllNode.getElement("img").set("src",
                '../x_component_query_Query/$Viewer/" + this.options.style + "/icon/checkbox.png' )
        }
    },
    selectAll : function( from ){
        // var flag = this.json.select || this.viewJson.select ||  "none";
        if ( this.view.getSelectFlag()==="multi"){
            this.expand();
            this.items.each( function (item) {
U
unknown 已提交
2397 2398 2399
                if( item.data.$selectedEnable ){
                    item.selected( from );
                }
U
unknown 已提交
2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413
            })
            if( this.view.viewJson.allowSelectAll ){
                this.setSelectAllStyle();
                if( from !== "view" ){
                    this.view.checkSelectAllStatus();
                }
            }
        }

    },
    unSelectAll : function( from ){
        // var flag = this.json.select || this.viewJson.select ||  "none";
        if ( this.view.getSelectFlag()==="multi"){
            this.items.each( function (item) {
U
unknown 已提交
2414 2415 2416
                if( item.data.$selectedEnable ) {
                    item.unSelected(from);
                }
U
unknown 已提交
2417 2418 2419 2420 2421 2422 2423 2424 2425
            })
            if( this.view.viewJson.allowSelectAll ) {
                this.setUnSelectAllStyle();
                if (from !== "view") {
                    this.view.checkSelectAllStatus();
                }
            }
        }
    },
R
roo00 已提交
2426 2427
    setEvent: function(){
        //if (this.selectTd){
U
unknown 已提交
2428 2429 2430
        this.node.addEvents({
            "click": function(){this.expandOrCollapse();}.bind(this)
        });
R
roo00 已提交
2431 2432 2433
        //}
    },
    expandOrCollapse: function(){
U
unknown 已提交
2434 2435 2436 2437 2438 2439 2440
        // var t = this.node.getElement("span").get("html");
        // if (t.indexOf("expand.png")===-1){
        //     this.collapse();
        // }else{
        //     this.expand();
        // }
        if( this.expanded ){
R
roo00 已提交
2441 2442 2443 2444 2445
            this.collapse();
        }else{
            this.expand();
        }
    },
U
unknown 已提交
2446
    collapse: function( from ){
R
roo00 已提交
2447 2448 2449
        this.items.each(function(item){
            item.node.setStyle("display", "none");
        }.bind(this));
U
unknown 已提交
2450 2451 2452
        if( this.expandNode ){
            this.expandNode.setStyles( this.view.viewJson.viewStyles["groupCollapseNode"] )
        }else{
2453
            this.node.getElement("span").set("html", "<img src='../x_component_query_Query/$Viewer/"+this.view.options.style+"/icon/expand.png'/>");
U
unknown 已提交
2454 2455
        }
        this.expanded = false;
U
unknown 已提交
2456 2457 2458
        if( from !== "view" ){
            this.view.checkExpandAllStatus();
        }
R
roo00 已提交
2459
    },
U
unknown 已提交
2460
    expand: function( from ){
R
roo00 已提交
2461 2462 2463
        this.items.each(function(item){
            item.node.setStyle("display", "table-row");
        }.bind(this));
U
unknown 已提交
2464 2465 2466
        if( this.expandNode ){
            this.expandNode.setStyles( this.view.viewJson.viewStyles["groupExpandNode"] )
        }else{
2467
            this.node.getElement("span").set("html", "<img src='../x_component_query_Query/$Viewer/"+this.view.options.style+"/icon/down.png'/>");
U
unknown 已提交
2468 2469
        }
        this.expanded = true;
R
roo00 已提交
2470 2471
        if (!this.loadChild){
            //window.setTimeout(function(){
R
roo00 已提交
2472 2473
            this.data.list.each(function(line, i){
                var s = this.idx+i;
U
unknown 已提交
2474
                this.lastItem = new MWF.xApplication.query.Query.Viewer.Item(this.view, line, (this.lastItem || this), s, this, this.view.options.lazy);
R
roo00 已提交
2475
                this.items.push(this.lastItem);
R
roo00 已提交
2476 2477 2478 2479
            }.bind(this));
            this.loadChild = true;
            //}.bind(this), 10);
        }
U
unknown 已提交
2480 2481 2482
        if( from !== "view" ){
            this.view.checkExpandAllStatus();
        }
R
roo00 已提交
2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551
    }
});

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);
    }
NoSubject's avatar
NoSubject 已提交
2552
});
U
unknown 已提交
2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613

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");
                }
2614
                value = o2.filterUrl(value);
U
unknown 已提交
2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694
            }
            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)

2695 2696 2697 2698 2699 2700 2701 2702 2703 2704
            if( this.json.multiTools ){
                this.json.multiTools.each( function (tool) {
                    if( tool.system ){
                        if( !this.json.hideSystemTools ){
                            this.setToolbars([tool], this.toolbarNode, this.readonly);
                        }
                    }else{
                        this.setCustomToolbars([tool], this.toolbarNode);
                    }
                }.bind(this));
U
unknown 已提交
2705 2706
                this.toolbarWidget.load();
            }else{
2707
                if (this.json.hideSystemTools){
U
unknown 已提交
2708 2709 2710
                    this.setCustomToolbars(this.json.tools, this.toolbarNode);
                    this.toolbarWidget.load();
                }else{
2711 2712
                    if (this.json.defaultTools){
                        this.setToolbars(this.json.defaultTools, this.toolbarNode, this.readonly);
U
unknown 已提交
2713 2714
                        this.setCustomToolbars(this.json.tools, this.toolbarNode);
                        this.toolbarWidget.load();
2715 2716 2717 2718 2719 2720 2721
                    }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);
                    }
U
unknown 已提交
2722 2723 2724 2725 2726 2727 2728 2729
                }
            }

        }.bind(this));
        // }
    },

    setCustomToolbars: function(tools, node){
2730
        var path = "../x_component_process_FormDesigner/Module/Actionbar/";
U
unknown 已提交
2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743
        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;
U
unknown 已提交
2744 2745 2746
                // if (tool.control){
                //     flag = this.form.businessData.control[tool.control]
                // }
U
unknown 已提交
2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778
                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){
2779 2780
        //var path = "../x_component_process_FormDesigner/Module/Actionbar/";
        var path = "../x_component_query_ViewDesigner/$View/";
U
unknown 已提交
2781
        var flag = true;
U
unknown 已提交
2782 2783 2784
        // if (tool.control){
        //     flag = this.form.businessData.control[tool.control]
        // }
U
unknown 已提交
2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795
        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,
U
unknown 已提交
2796
                "MWFButtonImage": path+this.options.style+"/actionbar/"+ ( this.json.iconStyle || "default" ) +"/"+tool.img,
U
unknown 已提交
2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828
                "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();
    }
U
unknown 已提交
2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888
});

MWF.xApplication.query.Query.Viewer.Paging = new Class({
    Implements: [Events],
    options: {
        "style" : "default",
        "moduleEvents": ["load", "queryLoad", "postLoad", "afterLoad","jump"]
    },
    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");
        }
    },

    _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");
                }
2889
                value = o2.filterUrl(value);
U
unknown 已提交
2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959
            }
            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.loadPaging( true )
    },
    reload : function(){
        this.loadPaging( false )
    },
    loadPaging : function( firstLoading ){
2960 2961 2962 2963 2964 2965 2966
        // this.pagingNode = this.node.getFirst("div");
        // if( !this.pagingNode ){
        //     this.pagingNode = new Element("div").inject( this.node );
        // }
        // this.pagingNode.empty();
        this.node.empty();
        this.paging = new o2.widget.Paging(this.node, {
U
unknown 已提交
2967 2968
            //style : this.options.skin && this.options.skin.pagingBar ? this.options.skin.pagingBar : "default",
            countPerPage: this.view.json.pageSize || this.view.options.perPageCount,
2969
            visiblePages: layout.mobile?5:(this.json.visiblePages ? this.json.visiblePages.toInt() : 9),
U
unknown 已提交
2970 2971 2972 2973 2974 2975 2976
            currentPage: this.view.currentPage,
            itemSize: this.view.count,
            pageSize: this.view.pages,
            hasNextPage: typeOf( this.json.hasPreNextPage ) === "boolean" ? this.json.hasPreNextPage : true,
            hasPrevPage: typeOf( this.json.hasPreNextPage ) === "boolean" ? this.json.hasPreNextPage : true,
            hasTruningBar: typeOf( this.json.hasTruningBar ) === "boolean" ? this.json.hasTruningBar : true,
            hasBatchTuring: typeOf( this.json.hasBatchTuring ) === "boolean" ? this.json.hasBatchTuring : true,
2977 2978 2979
            hasFirstPage: typeOf( this.json.hasFirstLastPage ) === "boolean" ? this.json.hasFirstLastPage : (layout.mobile?false:true),
            hasLastPage: typeOf( this.json.hasFirstLastPage ) === "boolean" ? this.json.hasFirstLastPage : (layout.mobile?false:true),
            hasJumper: typeOf( this.json.hasPageJumper ) === "boolean" ? this.json.hasPageJumper : (layout.mobile?false:true),
U
unknown 已提交
2980 2981
            hiddenWithDisable: false,
            hiddenWithNoItem: true,
2982 2983 2984
            hasInfor: this.json.showPagingInfor,
            inforPosition: this.json.pagingPosition,
            inforTextStyle: this.json.textStyle,
U
unknown 已提交
2985 2986 2987 2988 2989 2990 2991 2992 2993
            text: {
                prePage: this.json.prePageText,
                nextPage: this.json.nextPageText,
                firstPage: this.json.firstPageText,
                lastPage: this.json.lastPageText
            },
            onJumpingPage : function( pageNum, itemNum ){
                this.view.currentPage = pageNum;
                this.fireEvent("jump");
2994
                this.view.loadCurrentPageData( null, false );
U
unknown 已提交
2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005
            }.bind(this),
            onPostLoad : function () {
                if( firstLoading ){
                    if(this.view.setContentHeightFun)this.view.setContentHeightFun();
                    this.fireEvent("load");
                }
                this.fireEvent("afterLoad");
            }.bind(this)
        }, this.json.pagingStyles || {});
        this.paging.load();
    }
3006
});