o2oa api: x-游戏厅捕鱼达人

source

mwf.xapplication.query = mwf.xapplication.query || {};
mwf.xapplication.query.query = mwf.xapplication.query.query || {};
mwf.require("mwf.widget.common", null, false);
mwf.require("o2.widget.paging", null, false);
mwf.require("mwf.xscript.macro", null, false);
mwf.xdesktop.requireapp("query.query", "lp." o2.language, null, false);
/** @classdesc view 数据中心的视图。本章节的脚本上下文请看{@link module:queryview|queryview}。
 * @class
 * @o2cn 视图
 * @o2category queryview
 * @o2range {queryview}
 * @hideconstructor
 * @example
 * //在视图的事件中获取该类
 * var view = this.target;
 * @example
 * //在视图的条目中,操作条组件中,分页事件中获取该类
 * var view = this.target.view;
 * @example
 * //调用api进行提示
 * this.queryview.notice("this is my information", "info");
 * */
mwf.xapplication.query.query.viewer = mwf.qviewer = new class(
    /** @lends mwf.xapplication.query.query.viewer# */
    {
    implements: [options, events],
    extends: mwf.widget.common,
    options: {
        "style": "default",
        "skin" : null,
        "resizenode": true,
        "paging" : "scroll",
        "perpagecount" : 50,
        "isload": "true",
        "isloadtitle": true,
        "isloadcontent": true,
        "isloadactionbar": true,
        "isloadsearchbar": true,
        "export": false,
        "lazy": false,
        "defaultbundles": [],
        "moduleevents": [
            /**
             * 加载前触发。可通过this.target获取当前对象。
             * @event mwf.xapplication.query.query.viewer#queryload
             */
            "queryload",
            /**
             * 视图界面和当前页数据加载后执行。需注意,翻页也会执行本事件。可通过this.target获取当前对象。
             * @event mwf.xapplication.query.query.viewer#postload
             */
            "postload",
            /**
             * 加载当前页数据后,渲染界面前执行,翻页后也会执行本事件。可通过this.target获取当前对象。
             * @event mwf.xapplication.query.query.viewer#postloadpagedata
             */
            "postloadpagedata",
            /**
             * 渲染当前页内容后执行,翻页后也会执行本事件。可通过this.target获取当前对象。
             * @event mwf.xapplication.query.query.viewer#postloadpage
             */
            "postloadpage",
            /**
             * 选择行后执行。可通过this.target获取视图对象,通过this.event获取行对象。
             * @event mwf.xapplication.query.query.viewer#selectrow
             */
            "selectrow",
            /**
             * 取消选择行后执行。可通过this.target获取视图对象,通过this.event获取行对象。
             * @event mwf.xapplication.query.query.viewer#unselectrow
             */
            "unselectrow",
            /**
             * 加载每行之前执行(非分类行)。可通过this.target获取视图对象,通过this.event获取行对象。
             * @event mwf.xapplication.query.query.viewer#queryloaditemrow
             */
            "queryloaditemrow",
            /**
             * 加载每行之后执行(非分类行)。可通过this.target获取视图对象,通过this.event获取行对象。
             * @event mwf.xapplication.query.query.viewer#postloaditemrow
             */
            "postloaditemrow",
            /**
             * 加载分类行之前执行。可通过this.target获取视图对象,通过this.event获取行对象。
             * @event mwf.xapplication.query.query.viewer#queryloadcategoryrow
             */
            "queryloadcategoryrow",
            /**
             * 加载分类行后执行。可通过this.target获取视图对象,通过this.event获取行对象。
             * @event mwf.xapplication.query.query.viewer#postloadcategoryrow
             */
            "postloadcategoryrow"
         ]
        // "actions": {
        //     "lookup": {"uri": "/jaxrs/view/flag/{view}/query/{application}/execute", "method":"put"},
        //     "getview": {"uri": "/jaxrs/view/flag/{view}/query/{application}"}
        //
        // },
        // "actionroot": "x_query_assemble_surface"
    },
    initialize: function(container, json, options, app, parentmacro){
        //本类有三种事件,
        //一种是通过 options 传进来的事件,包括 loadview、opendocument、select、unselect
        //一种是用户配置的 事件, 在this.options.moduleevents 中定义的作为类事件
        //还有一种也是用户配置的事件,不在this.options.moduleevents 中定义的作为 this.node 的dom事件
        this.setoptions(options);
        this.path = "../x_component_query_query/$viewer/";
        this.csspath = "../x_component_query_query/$viewer/" this.options.style "/css.wcss";
        this._loadcss();
        this.lp = mwf.xapplication.query.query.lp;
        this.app = app;
        this.container = $(container);
        this.json = json;
        this.parentmacro = parentmacro;
        this.originaljson = object.clone(json);
        /**
         * @summary 视图的详细配置信息,比如条目的选择类型等.
         * @member {object}
         * @example
         *  //可以在视图脚本中获取视图基本信息(视图事件中)
         * var json = this.target.viewjson; //视图配置信息
         * var name = json.selectlist; //视图的列配置
         * @example
         *  //可以在视图的组件中获取视图基本信息(在视图的操作条组件中,分页事件中)
         * var json = this.target.view.viewjson; //视图配置信息
         * var name = json.selectlist; //视图的列配置
         */
        this.viewjson = null;
        this.filteritems = [];
        this.searchstatus = "none"; //none, custom, default
        /**
         * @summary 视图当前页的所有行对象数组.
         * @member {array}
         * @example
         * //获取视图当前页的所有行对象数组
         * var itemlist = this.target.items;
         */
        this.items = [];
        /**
         * @summary 视图选中行的对象数组.
         * @member {array}
         * @example
         * //获取视图选中行的对象数组
         * var itemlist = this.target.selecteditems;
         * itemlist.each(function(item){
         *      //取消选中
         *     item.unselected()
         * })
         */
        this.selecteditems = [];
        this.hidecolumns = [];
        this.opencolumns = [];
        this.gridjson = null;
        if (this.options.isload){
            this.init(function(){
                if( this.json.istitle==="no" )this.options.isloadtitle = false;
                this.load();
            }.bind(this));
        }
    },
    loadview: function( callback ){
        if (this.viewjson){
            this.reload( callback );
        }else{
            this.init(function(){
                if( this.json.istitle==="no" )this.options.isloadtitle = false;
                this.load( callback );
            }.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( callback ){
        this.loadresource(function () {
            this.loadlanguage( function () {
                this._loadmoduleevents();
                if (this.fireevent("queryload")){
                    this._loaduserinterface( callback );
                    //this._loadstyles();
                    this._loaddomevents();
                }
            }.bind(this))
        }.bind(this));
    },
    _loaduserinterface: function( callback ){
        this.viewjson = this.bindlp( this.viewjson );
        var defaultselectedscript, selectedablescript;
        if( typeof(this.json.defaultselectedscript) === "function" )defaultselectedscript = this.json.defaultselectedscript;
        if( typeof(this.json.selectedablescript) === "function" )selectedablescript = this.json.selectedablescript;
        this.json = this.bindlp( this.json );
        if(defaultselectedscript)this.json.defaultselectedscript = defaultselectedscript;
        if(selectedablescript)this.json.selectedablescript = selectedablescript;
        this.loadlayout();
        if( this.options.isloadactionbar )this.createactionbarnode();
        if( this.options.isloadsearchbar )this.createsearchnode();
        this.createviewnode({"filterlist": this.json.filter  ? this.json.filter.clone() : null}, callback);
        if (this.options.resizenode){
            this.setcontentheightfun = this.setcontentheight.bind(this);
            this.container.addevent("resize", this.setcontentheightfun);
            this.setcontentheightfun();
        }
    },
    loadlayout: function(){
        /**
         * @summary 视图的节点,mootools封装过的dom对象,可以直接使用原生的js和moootools方法访问和操作该对象。
         * @see https://mootools.net/core/docs/1.6.0/element/element
         * @member {element}
         * @example
         *  //可以在视图脚本中获取视图的dom
         * var node = this.target.node;
         * @example
         *  //可以在视图的组件中获取视图的dom(在视图的操作条组件中,分页事件中)
         * var node = this.target.view.node;
         */
        this.node = new element("div", {"styles": this.css.node}).inject(this.container);
        /**
         * @summary 操作组件容器
         * @member {element}
         */
        this.actionbarareanode =  new element("div.actionbarareanode", {"styles": this.css.actionbarareanode}).inject(this.node);
        //if (this.options.export) this.exportareanode = new element("div", {"styles": this.css.exportareanode}).inject(this.node);
        /**
         * @summary 搜索界面容器
         * @member {element}
         */
        this.searchareanode = new element("div", {"styles": this.css.searchareanode}).inject(this.node);
        /**
         * @summary 表头和条目容器,
         * @member {element}
         */
        this.viewareanode = new element("div", {"styles": this.css.viewareanode}).inject(this.node);
        // this.viewpagenode = new element("div", {"styles": this.css.viewpagenode}).inject(this.node);
        /**
         * @summary 分页组件容器,
         * @member {element}
         */
        this.viewpageareanode = new element("div", {"styles": this.css.viewpageareanode}).inject(this.node);
        this.fireevent("loadlayout");
    },
    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 );
        }
    },
    loadmacro: function (callback) {
        mwf.require("mwf.xscript.macro", function () {
            this.macro = new mwf.macro.viewcontext(this);
            if (callback) callback();
        }.bind(this));
    },
    loadlanguage: function(callback){
        if (this.viewjson.languagetype!=="script"){
            if (callback) callback();
            return true;
        }
        var language = mwf.xapplication.query.query.lp.form;
        var languagejson = null;
        if (this.viewjson.languagetype=="script"){
            if (this.viewjson.languagescript ){
                languagejson = this.macro.exec(this.viewjson.languagescript, this);
            }
        }
        if (languagejson){
            if (languagejson.then && o2.typeof(languagejson.then)=="function"){
                languagejson.then(function(json) {
                    if (!json.data){
                        var o = object.clone(json);
                        json.data = o;
                    }
                    mwf.xapplication.query.query.lp.form = object.merge(mwf.xapplication.query.query.lp.form, json);
                    if (callback) callback(true);
                }, function(){
                    if (callback) callback(true);
                })
            }else{
                mwf.xapplication.query.query.lp.form = object.merge(mwf.xapplication.query.query.lp.form, languagejson);
                if (callback) callback(true);
            }
        }else{
            if (callback) callback(true);
        }
    },
    createexportnode: function(){
        if (this.options.export){
            mwf.require("mwf.widget.toolbar", function(){
                this.toolbar = new mwf.widget.toolbar(this.actionbarareanode, {"style": "simple"}, this); //this.exportareanode
                var actionnode = new element("div", {
                    "id": "",
                    "mwfnodetype": "mwftoolbarbutton",
                    "mwfbuttonimage": this.path "" this.options.style "/icon/export.png",
                    "title": this.lp.exportexcel,
                    "mwfbuttonaction": "exportview",
                    "mwfbuttontext": this.lp.exportexcel
                }).inject(this.actionbarareanode); //this.exportareanode
                this.toolbar.load();
            }.bind(this));
            //this.exportnode = new element("button", {"text": this.lp.exportexcel}).inject(this.exportareanode);
        }
    },
    getexporttotalcount: function(){
        return ( this.bundleitems || [] ).length;
    },
    getexportmaxcount: function(){
        return 2000;
    },
    exportview: function(){
        var _self = this;
        var total = this.getexporttotalcount();
        var max = this.getexportmaxcount();
        var lp = this.lp.viewexport;
        var node = this.exportexceldlgnode = new element("div");
        var html = "
" lp.filename ":" " " "
"; html = "
" lp.exportrange ":" " " lp.to "" " " lp.item "" "
"; html = "
" ( lp.description.replace("{count}", total )) "
"; 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,'') } if( this.value.toint() > total ){ this.value = total; } } 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"); var filename = node.getelement(".filename").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; } this.exportexcelstart = start; this.exportexcelend = end; this._exportview(start, end, filename); dlg.close(); }.bind(this) }, { "type": "cancel", "text": mwf.lp.process.button.cancel, "action": function () { dlg.close(); } } ] }); }, _exportview: function(start, end, filename){ var bundlelist = this.bundleitems.slice(start-1, end); var excelname = filename || (this.json.name "(" start "-" end ").xlsx"); 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)); } var data = {"filterlist": filterdata}; if( bundlelist )data.bundlelist = bundlelist; if( excelname )data.excelname = excelname; data.key = this.bundlekey; action.exportviewwithquery(this.json.viewname, this.json.application, data, function(json){ var uri = action.action.actions.getviewexcel.uri; uri = uri.replace("{flag}", json.data.id); uri = o2.filter; var a = new element("a", {"href": uri, "target":"_blank"}); a.click(); a.destroy(); }.bind(this)); }, setcontentheight: function(){ var size; if( !this.node.offsetparent === null ){ size = this.node.getstyle("height"); }else{ size = this.node.getsize() } var searchsize = this.searchareanode.getcomputedsize(); var h = size.y-searchsize.totalheight; //if (this.exportareanode){ // var exportsize = this.exportareanode.getcomputedsize(); // h = h-exportsize.totalheight; //} if( this.actionbarareanode ){ var exportsize = this.actionbarareanode.getcomputedsize(); h = h-exportsize.totalheight; } var pagesize = this.viewpageareanode.getcomputedsize(); h = h-pagesize.totalheight; var paddingtop = (this.viewareanode.getstyle("padding-top") || "0").toint(); var paddingbottom = (this.viewareanode.getstyle("padding-bottom") || "0").toint(); h = h - paddingtop - paddingbottom; this.viewareanode.setstyle("height", "" h "px"); }, createloadding: function(){ this.loadingareanode = new element("div", {"styles": this.css.viewloadingareanode}).inject(this.contentareanode); new element("div", {"styles": {"height": "5px"}}).inject(this.loadingareanode); var loadingnode = new element("div", {"styles": this.css.viewloadingnode}).inject(this.loadingareanode); new element("div", {"styles": this.css.viewloadingiconnode}).inject(loadingnode); var loadingtextnode = new element("div", {"styles": this.css.viewloadingtextnode}).inject(loadingnode); loadingtextnode.set("text", "loading..."); }, createactionbarnode : function(){ this.actionbarareanode.empty(); if( typeof(this.json.showactionbar) === "boolean" && this.json.showactionbar !== true )return; if( typeof( this.viewjson.actionbarhidden ) === "boolean" ){ if( this.viewjson.actionbarhidden === true || !this.viewjson.actionbarlist || !this.viewjson.actionbarlist.length )return; /** * @summary 视图的操作条对象. * @member {object} * @example * var actionbar = this.target.actionbar; */ this.actionbar = new mwf.xapplication.query.query.viewer.actionbar(this.actionbarareanode, this.viewjson.actionbarlist[0], this, {}); this.actionbar.load(); }else{ //兼容以前的exportnode this.createexportnode(); } }, createviewnode: function(data, callback){ this.viewareanode.empty(); this.selecteditems = []; var viewstyles = this.viewjson.viewstyles; this.contentareanode = new element("div", {"styles": (viewstyles && viewstyles["container"]) ? viewstyles["container"] : this.css.contentareanode }).inject(this.viewareanode); this.loadobserver(); this.viewtable = new element("table", { "styles": this.css.viewtitletablenode, "border": "0px", "cellpadding": "0", "cellspacing": "0" }).inject(this.contentareanode); if( viewstyles ){ if( viewstyles["tableproperties"] )this.viewtable.set(viewstyles["tableproperties"]); if( viewstyles["table"] )this.viewtable.setstyles(viewstyles["table"]); } if( this.options.isloadcontent )this.createloadding(); var viewtitlecellnode = (viewstyles && viewstyles["titletd"]) ? viewstyles["titletd"] : this.css.viewtitlecellnode; if (this.options.isloadtitle){ this.viewtitleline = new element("tr.viewtitleline", { "styles": (viewstyles && viewstyles["titletr"]) ? viewstyles["titletr"] : this.css.viewtitlelinenode }).inject(this.viewtable); //if (this.json.select==="single" || this.json.select==="multi") { this.selecttitlecell = new element("td.selecttitlecell", { "styles": viewtitlecellnode }).inject(this.viewtitleline); this.selecttitlecell.setstyle("width", "10px"); if (this.json.titlestyles) this.selecttitlecell.setstyles(this.json.titlestyles); //} if( this.isselecttdhidden() ){ this.selecttitlecell.hide(); } if( this.getselectflag( true ) !== "multi" || !this.viewjson.allowselectall ){ this.expandtitlecell = this.selecttitlecell; } //序号 if (this.viewjson.issequence==="yes"){ this.sequencetitlecell = new element("td", { "styles": viewtitlecellnode, "text": this.lp.sequence }).inject(this.viewtitleline); this.sequencetitlecell.setstyles({ "width": "30px", "text-align": "center" }); if (this.json.titlestyles) this.sequencetitlecell.setstyles(this.json.titlestyles); if( !this.expandtitlecell )this.expandtitlecell = this.sequencetitlecell; } this.entries = {}; this.viewjson.selectlist.each(function(column){ this.entries[column.column] = column; if (!column.hidecolumn){ var viewcell = new element("td", { "styles": viewtitlecellnode, "text": column.displayname }).inject(this.viewtitleline); var size = mwf.gettextsize(column.displayname, viewtitlecellnode); viewcell.setstyle("min-width", "" size.x "px"); if (this.json.titlestyles) viewcell.setstyles(this.json.titlestyles); if( column.groupentry && !this.expandtitlecell )this.expandtitlecell = viewcell; if( typeof(column.titlestyles) === "object" )viewcell.setstyles(column.titlestyles); if( typeof(column.titleproperties) === "object" )viewcell.setproperties(column.titleproperties); 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}); } }else{ this.hidecolumns.push(column.column); } if (column.allowopen) this.opencolumns.push(column.column); }.bind(this)); if( this.options.isloadcontent )this.lookup(data, callback); }else{ this.entries = {}; this.viewjson.selectlist.each(function(column){ this.entries[column.column] = column; if (column.hidecolumn) this.hidecolumns.push(column.column); if (column.allowopen) this.opencolumns.push(column.column); }.bind(this)); if( this.options.isloadcontent )this.lookup(data, callback); } }, 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"; }, getselectflag : function( ignoreselectenable ){ if( !ignoreselectenable && !this.viewselectedenable )return "none"; 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; return "none"; }, isselecttdhidden :function(){ if( !this.viewjson.firsttdhidden ){ return false; } if( this.viewjson.group && this.viewjson.group.column ){ return false; } if( this.json.defaultselectedscript || this.viewjson.defaultselectedscript ){ return false; } // if( !this.viewselectedenable ){ // return true; // } if( this.options && this.options.select ){ return this.options.select === "none" || this.options.select === "no"; } if( this.json && this.json.select ){ return this.json.select === "none" || this.json.select === "no"; } if( this.viewjson && this.viewjson.select ){ return this.viewjson.select === "none" || this.viewjson.select === "no"; } return true; // 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; }, // _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(); if( this.viewjson.pagingbarhidden === true ){ return; } 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]; // var jsonstr = json.stringify(json); // jsonstr = o2.bindjson(jsonstr, {"lp": mwf.xapplication.query.query.lp.form}); // json = json.parse(jsonstr); } /** * @summary 视图的分页组件对象. * @member {object} * @example * var paging = this.target.paging; */ this.paging = new mwf.xapplication.query.query.viewer.paging(this.viewpageareanode, json, this, {}); this.paging.load(); }else{ this.paging.reload(); } }, _initpage: function(){ this.count = this.bundleitems.length; var i = this.count/this.json.pagesize; this.pages = (i.toint()1){ this.viewtable.deleterow(-1); } if( this.viewtable.rows.length>0 && !this.viewtable.rows[0].hasclass("viewtitleline") ){ this.viewtable.deleterow(0); } this.contentareanode.scrollto(0, 0); //this.createloadding(); this.loadviewres = this.lookupaction.loadview(this.json.name, this.json.application, d, function(json){ this.viewdata = json.data; this.fireevent("postloadpagedata"); if (this.viewjson.group.column){ this.gridjson = json.data.groupgrid; this.setselectedableflag(); this.loadgroupdata(); }else{ this.gridjson = json.data.grid; this.setselectedableflag(); this.loaddata(); } if (this.gridjson.length) this._loadpagenode(); if (this.loadingareanode){ this.loadingareanode.destroy(); this.loadingareanode = null; } this.pageloading = false; this.fireevent("loadview"); //options 传入的事件 this.fireevent("postloadpage"); if(callback)callback(); }.bind(this), null, async === false ? false : true ); }, showassociateddocumentresult: function(failurelist, successlist){ debugger; var fl = []; failurelist.each(function( f ){ if( f.properties.view === this.json.id )fl.push( f.targetbundle ); }.bind(this)); var sl = []; successlist.each(function( f ){ if( f.properties.view === this.json.id )sl.push( f.targetbundle ); }.bind(this)); var d = {}; d.bundlelist = fl.concat( sl ); d.key = this.bundlekey; if( d.bundlelist.length ){ this.lookupaction.loadview(this.json.name, this.json.application, d, function(json){ var resultjson, viewdata = json.data; if (this.viewjson.group.column){ resultjson = []; json.data.groupgrid.each(function (g) { resultjson = resultjson.concat( g.list ); }) }else{ resultjson = json.data.grid; } this._showassociateddocumentresult( resultjson, failurelist, successlist ); }.bind(this), null, true ); }else{ this._showassociateddocumentresult( [], failurelist, successlist ); } }, _showassociateddocumentresult: function(resultjson, failurelist, successlist){ this.entries.$result = { "id": "$result", "column": "$result", "events": {}, "allowopen": false, "numberorder": false, "groupentry": false, "hidecolumn": false, "isname": false, "ishtml": false, "path": "$result" }; var viewstyles = this.viewjson.viewstyles; if (this.options.isloadtitle && this.selecttitlecell){ //if (this.json.select==="single" || this.json.select==="multi") { var titlecell = new element("td.titlecell", { "styles": (viewstyles && viewstyles["titletd"]) ? viewstyles["titletd"] : this.css.viewtitlecellnode, "text": this.lp.associationresult }).inject(this.viewtitleline); if (this.json.titlestyles) titlecell.setstyles(this.json.titlestyles); } if(this.expandallnode){ this.expandallnode.hide(); } while (this.viewtable.rows.length>1){ this.viewtable.deleterow(-1); } if( this.viewtable.rows.length>0 && !this.viewtable.rows[0].hasclass("viewtitleline") ){ this.viewtable.deleterow(0); } this.contentareanode.scrollto(0, 0); this.gridjson = resultjson.map(function (item) { var flag = true; if( !item.data )item.data = {}; failurelist.each(function (d) { if( item.bundle === d.bundle ){ item.$failure = true; item.data.$result = d.$result || this.lp.nopermission; flag = false; } }.bind(this)); if( flag ){ item.data.$result = this.lp.associationsuccess; } item.$selectedenable = false; return item; }.bind(this)); //if( this.paging )this.paging.hide(); if(this.actionbarareanode)this.actionbarareanode.hide(); if(this.searchareanode)this.searchareanode.hide(); if(this.viewpageareanode)this.viewpageareanode.hide(); //this.selecteditems = []; if(this.selectallnode){ this.clearselectallstyle(); } if (this.gridjson.length){ this.gridjson.each(function(line, i){ new mwf.xapplication.query.query.viewer.associatedresultitem(this, line, null, i, null, false); }.bind(this)); }else{ if (this.viewpageareanode) this.viewpageareanode.empty(); } }, 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 ){ switch (typeof(selectedablescript)) { case "string": if( selectedablescript ){ v.$selectedenable = this.macro.exec( selectedablescript, { "data" : v, "groupdata" : d ,"view": this }); }else{ v.$selectedenable = true; } break; case "function": v.$selectedenable = selectedablescript({ "data" : v, "groupdata" : d ,"view": this }); break; default: v.$selectedenable = true; } if( v.$selectedenable ){ d.$selectedenable = true; this.viewselectedenable = true; } }.bind(this)) }.bind(this)) }else{ this.gridjson.each( function( v ){ switch (typeof(selectedablescript)) { case "string": if( selectedablescript ){ v.$selectedenable = this.macro.exec( selectedablescript, { "data" : v, "view": this }); }else{ v.$selectedenable = true; } break; case "function": v.$selectedenable = selectedablescript({ "data" : v, "view": this }); break; default: v.$selectedenable = true; } if( v.$selectedenable )this.viewselectedenable = true; }.bind(this)) } }, getmode: function(){ return this.viewjson.group.column ? "group" : "item"; }, 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( "" "" ) // this.selectallnode = new element("div",{ // html : "" "", // 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); } } }, loaddata: function(){ if( this.getselectflag() === "multi" && this.viewjson.allowselectall ) { if(this.selecttitlecell && this.selecttitlecell.retrieve("selectallloaded")){ this.setunselectallstyle(); }else{ this.createselectallnode(); } }else if(this.selectallnode){ this.clearselectallstyle(); } if (this.gridjson.length){ // if( !this.options.paging ){ this.gridjson.each(function(line, i){ this.items.push(new mwf.xapplication.query.query.viewer.item(this, line, null, i, null, this.options.lazy)); }.bind(this)); // }else{ // this.loadpaging(); // } }else{ if (this.viewpageareanode) this.viewpageareanode.empty(); } }, loadpaging : function(){ this.isitemsloading = false; this.pagenumber = 0; this.isitemsloaded = false; this.issetedscroll = false; this.setscroll(); this.loaddatabypaging() }, setscroll : function(){ if( this.options.paging && !this.issetedscroll ){ this.contentareanode.setstyle("overflow","auto"); this.scrollcontainerfun = function(){ var scrollsize = this.contentareanode.getscrollsize(); var clientsize = this.contentareanode.getsize(); var scrollheight = scrollsize.y - clientsize.y; //alert( "clientsize.y=" clientsize.y " scrollsize.y=" scrollsize.y " this.contentareanode.scrolltop=" this.contentareanode.scrolltop); if (this.contentareanode.scrolltop 150 > scrollheight ) { if (!this.isitemsloaded) this.loaddatabypaging(); } }.bind(this); this.issetedscroll = true; this.contentareanode.addevent("scroll", this.scrollcontainerfun ) } }, loaddatabypaging : function(){ if( this.isitemsloading )return; if( !this.isitemsloaded ){ var from = math.min( this.pagenumber * this.options.perpagecount , this.gridjson.length); var to = math.min( ( this.pagenumber 1 ) * this.options.perpagecount 1 , this.gridjson.length); this.isitemsloading = true; for( var i = from; i" "" ""); this.expandallnode = new element("span",{ html : "" "", style : "font-family: webdings" }).inject( this.expandtitlecell, "top" ); } this.expandtitlecell.setstyle("cursor", "pointer"); this.expandtitlecell.addevent("click", this.expandorcollapseall.bind(this)); this.expandtitlecell.store("expandloaded", true); }else if( this.getexpandflag() !=="yes" ){ this.setcollapseallstyle(); } } // this.isallexpanded = false; if (this.gridjson.length){ var i = 0; this.gridjson.each(function(data){ this.items.push(new mwf.xapplication.query.query.viewer.itemcategory(this, data, i)); i = data.list.length; }.bind(this)); if (this.getexpandflag()=="yes") this.expandorcollapseall(); }else{ if (this.viewpageareanode) this.viewpageareanode.empty(); } }, getview: function(callback){ this.getlookupaction(function(){ if (this.json.application){ this.getviewres = this.lookupaction.getview(this.json.viewname, this.json.application, function(json){ this.viewjson = json.decode(json.data.data); this.json = object.merge(this.json, json.data); if (callback) callback(); }.bind(this)); // this.lookupaction.invoke({"name": "getview","async": true, "parameter": {"view": this.json.viewname, "application": this.json.application},"success": function(json){ // this.viewjson = json.decode(json.data.data); // this.json = object.merge(this.json, json.data); // //var viewdata = json.decode(json.data.data); // if (callback) callback(); // }.bind(this)}); }else{ this.getviewres = this.lookupaction.getviewbyid(this.json.viewid, function(json){ this.viewjson = json.decode(json.data.data); this.json.application = json.data.query; this.json = object.merge(this.json, json.data); if (callback) callback(); }.bind(this)); } }.bind(this)); }, bindlp: function( json ){ var jsonstr = json.stringify( json ); jsonstr = o2.bindjson(jsonstr, {"lp": mwf.xapplication.query.query.lp.form}); return json.parse(jsonstr); }, 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"); }, /** * @summary 刷新视图。 * @param {function} [callback] - 可选,刷新视图后的回调. * @example * this.target.reload(); */ reload: function( callback ){ if( this.lookuping || this.pageloading )return; this.node.setstyle("display", "block"); if (this.loadingareanode) this.loadingareanode.setstyle("display", "block"); this.filteritems.each(function(filter){ filter.destroy(); }.bind(this)); this.filteritems = []; if (this.viewsearchinputnode) this.viewsearchinputnode.set("text", this.lp.searchkeywork); this.closecustomsearch(); this.viewareanode.empty(); this.createviewnode({"filterlist": this.json.filter ? this.json.filter.clone() : null}, callback); }, getfilter: function(){ var filterdata = []; if (this.searchstatus==="custom"){ if (this.filteritems.length){ this.filteritems.each(function(filter){ filterdata.push(filter.data); }.bind(this)); } } if (this.searchstatus==="default"){ var key = this.viewsearchinputnode.get("value"); if (key && key!==this.lp.searchkeywork){ this.viewjson.customfilterlist.each(function(entry){ if (entry.formattype==="textvalue"){ var d = { "path": entry.path, "value": key, "formattype": entry.formattype, "logic": "or", "comparison": "like" }; filterdata.push(d); } if (entry.formattype==="numbervalue"){ var v = key.tofloat(); if (!isnan(v)){ var d = { "path": entry.path, "value": v, "formattype": entry.formattype, "logic": "or", "comparison": "like" }; filterdata.push(d); } } }.bind(this)); } } return (filterdata.length) ? filterdata : null; }, getdata: function(){ if (this.selecteditems.length){ var arr = []; this.selecteditems.each(function(item){ arr.push(item.data); }); return arr; }else{ return []; } }, _loadmoduleevents : function(){ object.each(this.viewjson.events, function(e, key){ if (e.code){ if (this.options.moduleevents.indexof(key)!==-1){ this.addevent(key, function(event, target){ return this.macro.fire(e.code, target || this, event); }.bind(this)); } } }.bind(this)); }, _loaddomevents: function(){ object.each(this.viewjson.events, function(e, key){ if (e.code){ if (this.options.moduleevents.indexof(key)===-1){ this.node.addevent(key, function(event){ return this.macro.fire(e.code, this, event); }.bind(this)); } } }.bind(this)); }, //搜索相关开始 createsearchnode: function(){ if( this.viewjson.searchbarhidden === true ){ return; } if (this.viewjson.customfilterlist && this.viewjson.customfilterlist.length){ this.searchstatus = "default"; this.loadfiltersearch(); }else{ this.loadsimplesearch(); } }, loadsimplesearch: function(){ return false; this.searchsimplenode = new element("div", {"styles": this.css.searchsimplenode}).inject(this.searchareanode); this.searchsimplebuttonnode = new element("div", {"styles": this.css.searchsimplebuttonnode}).inject(this.searchsimplenode); this.searchsimpleinputnode = new element("input", {"type":"text", "styles": this.css.searchsimpleinputnode, "value": this.lp.searchkeywork}).inject(this.searchsimplenode); this.searchsimplebuttonnode.addevent("click", function(){ this.search(); }.bind(this)); this.searchsimpleinputnode.addevents({ "focus": function(){ if (this.searchsimpleinputnode.get("value")===this.lp.searchkeywork) this.searchsimpleinputnode.set("value", ""); }.bind(this), "blur": function(){if (!this.searchsimpleinputnode.get("value")) this.searchsimpleinputnode.set("value", this.lp.searchkeywork);}.bind(this), "keydown": function(e){ if (e.code===13) this.search(); }.bind(this) }); }, search: function(){ if (this.gridjson){ var key = this.searchsimpleinputnode.get("value"); var rows = this.viewtable.rows; var first = (this.options.isloadtitle) ? 1 : 0; for (var i = first; i 0 ){ this.loadviewserchcustomselectbyscript(selectablelist) }else{ this.loadviewsearchcustomvaluenumberinput(); } break; case "datetimevalue": this.loadcomparisonselect(this.lp.datetimefilter); if( selectablelist.length > 0 ){ this.loadviewserchcustomselectbyscript(selectablelist) }else { this.loadviewsearchcustomvaluedatetimeinput(); } break; case "datevalue": this.loadcomparisonselect(this.lp.datefilter); if( selectablelist.length > 0 ){ this.loadviewserchcustomselectbyscript(selectablelist) }else { this.loadviewsearchcustomvaluedateinput(); } break; case "timevalue": this.loadcomparisonselect(this.lp.datetimefilter); if( selectablelist.length > 0 ){ this.loadviewserchcustomselectbyscript(selectablelist) }else { this.loadviewsearchcustomvaluetimeinput(); } break; case "booleanvalue": this.loadcomparisonselect(this.lp.booleanfilter); if( selectablelist.length > 0 ){ this.loadviewserchcustomselectbyscript(selectablelist) }else { this.loadviewsearchcustomvaluebooleaninput(); } break; default: this.loadcomparisonselect(this.lp.textfilter); if( selectablelist.length > 0 ){ this.loadviewserchcustomselectbyscript(selectablelist) }else { this.loadviewsearchcustomvaluetextinput(); } } } }, getcustomselectscriptresult : function( entry ){ var scriptresult = []; if( entry.valuetype === "script" ){ if( entry.valuescript && entry.valuescript.code ){ var result = this.macro.exec(entry.valuescript.code, this); var array = typeof( result ) === "array" ? result : [result]; for( var i=0; i -1 ){ var arr = array[i].split("|"); scriptresult.push({ "text" : arr[0], "value" : arr[1] }) }else{ scriptresult.push({ "text" : array[i], "value" : array[i] }) } } } } return scriptresult; }, loadviewserchcustomselectbyscript: function( array ){ this.viewsearchcustomvaluecontentnode.empty(); this.viewsearchcustomvaluenode = new element("select", { "styles": this.css.viewfiltersearchcustomcomparisonlistnode, "multiple": true }).inject(this.viewsearchcustomvaluecontentnode); array.each(function( v ){ var option = new element("option", { "style": this.css.viewfiltersearchoptionnode, "value": v.value, "text": v.text, "selected" : array.length === 1 }).inject(this.viewsearchcustomvaluenode); }.bind(this)); }, loadviewsearchcustomvaluenumberinput: function(){ this.viewsearchcustomvaluecontentnode.empty(); this.viewsearchcustomvaluenode = new element("input", { "styles": this.css.viewfiltersearchcustomvaluenode, "type": "number" }).inject(this.viewsearchcustomvaluecontentnode); }, loadviewsearchcustomvaluedatetimeinput: function(){ this.viewsearchcustomvaluecontentnode.empty(); this.viewsearchcustomvaluenode = new element("input", { "styles": this.css.viewfiltersearchcustomvaluenode, "type": "text", "readonly": true }).inject(this.viewsearchcustomvaluecontentnode); mwf.require("mwf.widget.calendar", function(){ this.calendar = new mwf.widget.calendar(this.viewsearchcustomvaluenode, { "style": "xform", "istime": true, "secondenable" : true, "target": this.app ? this.app.content : this.container, "format": "db" }); }.bind(this)); }, loadviewsearchcustomvaluedateinput: function(){ this.viewsearchcustomvaluecontentnode.empty(); this.viewsearchcustomvaluenode = new element("input", { "styles": this.css.viewfiltersearchcustomvaluenode, "type": "text", "readonly": true }).inject(this.viewsearchcustomvaluecontentnode); mwf.require("mwf.widget.calendar", function(){ this.calendar = new mwf.widget.calendar(this.viewsearchcustomvaluenode, { "style": "xform", "istime": false, "target": this.app ? this.app.content : this.container, "format": "%y-%m-%d" }); }.bind(this)); }, loadviewsearchcustomvaluetimeinput: function(){ this.viewsearchcustomvaluecontentnode.empty(); this.viewsearchcustomvaluenode = new element("input", { "styles": this.css.viewfiltersearchcustomvaluenode, "type": "text", "readonly": true }).inject(this.viewsearchcustomvaluecontentnode); mwf.require("mwf.widget.calendar", function(){ this.calendar = new mwf.widget.calendar(this.viewsearchcustomvaluenode, { "style": "xform", "timeonly": true, "target": this.app ? this.app.content : this.container, "format": "%h:%m:%s" }); }.bind(this)); }, loadviewsearchcustomvaluebooleaninput: function(){ this.viewsearchcustomvaluecontentnode.empty(); this.viewsearchcustomvaluenode = new element("select", { "styles": this.css.viewfiltersearchcustomvalueselectnode, "multiple": true }).inject(this.viewsearchcustomvaluecontentnode); new element("option", {"value": "true","text": this.lp.yes}).inject(this.viewsearchcustomvaluenode); new element("option", {"value": "false","text": this.lp.no}).inject(this.viewsearchcustomvaluenode); }, loadviewsearchcustomvaluetextinput: function(){ this.viewsearchcustomvaluecontentnode.empty(); this.viewsearchcustomvaluenode = new element("textarea", { "styles": this.css.viewfiltersearchcustomvaluenode }).inject(this.viewsearchcustomvaluecontentnode); }, loadcomparisonselect:function(obj){ this.viewsearchcustomcomparisonlistnode.empty(); object.each(obj, function(v, k){ var option = new element("option", {"value": k,"text": v}).inject(this.viewsearchcustomcomparisonlistnode); }.bind(this)); }, closecustomsearch: function(){ if (this.viewsearchcustomcontentnode && this.viewsearchcustomcontentnode.getstyle("display")==="block"){ this.viewsearchcustomcloseactionnode.setstyle("display", "none"); this.viewsearchcustomcontentnode.setstyle("display", "none"); var x = this.viewsearchinputareanode.getparent().getsize().x; x1 = x-2-10-90; this.css.viewfiltersearchinputareanode.width = "" x1 "px"; var x1 = this.viewsearchinputareanode.getsize().x-2; this.viewsearchinputareanode.setstyle("width", "" x1 "px"); if (!this.searchmorph) this.searchmorph = new fx.morph(this.viewsearchinputareanode); this.searchmorph.start(this.css.viewfiltersearchinputareanode).chain(function(){ this.searchstatus = "default"; this.css.viewfiltersearchinputareanode.width = "auto"; this.viewsearchinputareanode.setstyle("margin-right", "90px"); this.viewsearchiconnode.setstyle("display", "block"); this.viewsearchinputboxnode.setstyle("display", "block"); this.viewsearchcustomactionnode.setstyle("display", "block"); if(this.setcontentheightfun)this.setcontentheightfun(); }.bind(this)); this.lastfilteritems = this.filteritems; this.createviewnode({"filterlist": this.json.filter ? this.json.filter.clone() : null}); } }, viewsearchcustomaddtofilter: function(){ var pathidx = this.viewsearchcustompathlistnode.selectedindex; var comparisonidx = this.viewsearchcustomcomparisonlistnode.selectedindex; if (pathidx===-1){ mwf.xdesktop.notice("error", {"x": "left", "y": "top"}, this.lp.filtererrortitle, this.viewsearchcustompathlistnode, {"x": 0, "y": 85}); return false; } if (comparisonidx===-1){ mwf.xdesktop.notice("error", {"x": "left", "y": "top"}, this.lp.filtererrorcomparison, this.viewsearchcustomcomparisonlistnode, {"x": 0, "y": 85}); return false; } var pathoption = this.viewsearchcustompathlistnode.options[pathidx]; var entry = pathoption.retrieve("entry"); if (entry){ var pathtitle = entry.title; var path = entry.path; var comparison = this.viewsearchcustomcomparisonlistnode.options[comparisonidx].get("value"); var comparisontitle = this.viewsearchcustomcomparisonlistnode.options[comparisonidx].get("text"); var value = ""; if( entry.valuetype === "script" && entry.valuescript && entry.valuescript.code ){ var idx = this.viewsearchcustomvaluenode.selectedindex; if (idx!==-1){ var v = this.viewsearchcustomvaluenode.options[idx].get("value"); value = entry.formattype === "booleanvalue" ? (v==="true") : v; } }else{ switch (entry.formattype){ case "numbervalue": value = this.viewsearchcustomvaluenode.get("value"); break; case "datetimevalue": value = this.viewsearchcustomvaluenode.get("value"); break; case "booleanvalue": var idx = this.viewsearchcustomvaluenode.selectedindex; if (idx!==-1){ var v = this.viewsearchcustomvaluenode.options[idx].get("value"); value = (v==="true"); } break; default: value = this.viewsearchcustomvaluenode.get("value"); } } if (value===""){ mwf.xdesktop.notice("error", {"x": "left", "y": "top"}, this.lp.filtererrorvalue, this.viewsearchcustomvaluecontentnode, {"x": 0, "y": 85}); return false; } this.filteritems.push(new mwf.xapplication.query.query.viewer.filter(this, { "logic": "and", "path": path, "title": pathtitle, "comparison": comparison, "comparisontitle": comparisontitle, "value": value, "formattype": (entry.formattype=="datetimevalue") ? "datetimevalue": entry.formattype }, this.viewsearchcustomfiltercontentnode)); this.searchcustomview(); } }, searchviewremovefilter: function(filter){ this.filteritems.erase(filter); filter.destroy(); this.searchcustomview() }, //搜索相关结束 //api 使用 开始 /** * @summary 如果当前视图是嵌入在表单或者页面中,使用该方法获取表单或页面的上下文。 * @see {@link module:queryview.getparentenvironment|详情查看 this.queryviewer.getparentenvironment} * @return {object} * @example * this.target.getparentenvironment(); */ getparentenvironment : function(){ return this.parentmacro ? this.parentmacro.environment : null; }, /** * @summary 获取视图的配置信息。 * @see {@link module:queryview.getviewinfor|详情查看 this.queryviewer.getviewinfor} * @return {object} * @example * this.target.getviewinfor(); */ getviewinfor : function(){ return this.json; }, /** * @summary 获取视图当前页的基本信息。 * @see {@link module:queryview.getpageinfor|详情查看 this.queryviewer.getpageinfor} * @return {object} * @example * this.target.getpageinfor(); */ getpageinfor : function(){ return { pages : this.pages, perpagecount : this.options.perpagecount, currentpagenumber : this.currentpage }; }, /** * @summary 获取当前页的数据。 * @see {@link module:queryview.getpagedata|详情查看 this.queryviewer.getpagedata} * @return {object} * @example * this.target.getpagedata(); */ getpagedata : function () { return this.gridjson; }, /** * @summary 跳转到指定的页面。 * @see {@link module:queryview.topage|详情查看 this.queryviewer.topage} * @param {number} pagenumber 需要跳转的页码 * @param {function} callback 跳转的页面数据加载完成以后的回调方法。 * @example * // 跳转到第2页并且获取该页的数据。 * this.target.topage( 2, function(){ * var data = this.target.getpagedata(); * }.bind(this) ) */ topage : function( pagenumber, callback ){ this.currentpage = pagenumber; this.loadcurrentpagedata( callback ); }, /** * 获取选中的条目的数据。 * @method getselecteddata * @see {@link module:queryview.getselecteddata|详情查看 this.queryviewer.getselecteddata} * @memberof module:queryview * @static * @return {object[]} 选中的条目的数据。 *
格式如下:
*

     * [
     {
        "bundle": "099ed3c9-dfbc-4094-a8b7-5bfd6c5f7070", //cms 的 documentid, process 的 jobid
        "data": {  //视图中配置的数据
          "title": "考勤管理-配置-统计周期设置", //列名称及列值
          "time": "2018-08-25 11:29:45"
        }
      },
     ...
     * ]
     
* @o2syntax * var data = this.target.getselecteddata(); */ getselecteddata : function(){ return this.getdata(); }, getselectallstatus : function(){ if( this.getselectflag()!=="multi")return; if( !this.items.length )return "none"; var allflag = true, noneflag = true; for( var i=0; i"); } }, 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", ""); } }, 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", ""); // }.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", ""); // }.bind(this)); // this.isallexpanded = true; // } // } }, /** * @summary 设置视图的过滤条件,该方法不能修改视图中默认的过滤条件(在开发视图的时候添加的过滤条件),而是在这上面新增。 * @see {@link module:queryview.setfilter|详情查看 this.queryviewer.setfilter} * @param {(viewfilter[]|viewfilter|null)} [filter] 过滤条件 * @param {function} callback 过滤完成并重新加载数据后的回调方法。 */ setfilter : function( filter, callback ){ if( this.lookuping || this.pageloading )return; if( !filter )filter = []; if( typeof( filter ) === "object" )filter = [ filter ]; this.json.filter = filter; if( this.viewareanode ){ this.createviewnode({"filterlist": this.json.filter ? this.json.filter.clone() : null}, callback); } }, /** * @summary 把当前视图切换成另外一个视图。 * @see {@link module:queryview.switchview|详情查看 this.queryviewer.switchview} * @param {(viewfilter[]|viewfilter|null)} [filter] 过滤条件 * @param {object} options 需要跳转的参数配置 */ 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; this.paging = null; var newjson = object.merge( object.clone(this.originaljson), json ); this.container.empty(); this.initialize( this.container, newjson, object.clone(this.options), this.app, this.parentmacro); }, confirm: function (type, e, title, text, width, height, ok, cancel, callback, mask, style) { this.app.confirm(type, e, title, text, width, height, ok, cancel, callback, mask, style) }, alert: function (type, title, text, width, height) { this.app.alert(type, "center", title, text, width, height); }, notice: function (content, type, target, where, offset, option) { this.app.notice(content, type, target, where, offset, option) }, //api 使用 结束 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)); } } }); /** @classdesc vieweritem 数据中心的视图条目。本章节的脚本上下文请看{@link module:queryview|queryview}。 * @class * @o2cn 视图条目(行) * @o2category queryview * @o2range {queryview} * @hideconstructor * @example * //在视图中获取行 * var item = this.target.items[0]; */ mwf.xapplication.query.query.viewer.item = new class( /** @lends mwf.xapplication.query.query.viewer.item# */ { initialize: function(view, data, prev, i, category, lazy){ /** * 加载对应列的每个单元格后触发。可通过this.target获取以下对象: *
{
         *  "json ": {}, //当前行配置
         *  "data": "",  //当前单元格数据,可能是字符串、数组、布尔值。
         *  "node": td, //当前单元格
         *  "view": view, //当前视图对象
         *  "row": {} //当前行的平台类对象
         * }
* @event mwf.xapplication.query.query.viewer.item#loadcontent */ /** * 加载对应列的每个单元格后触发。可通过this.target获取以下对象: *
{
         *  "json ": {}, //当前行配置
         *  "data": "",  //当前单元格数据,可能是字符串、数组、布尔值。
         *  "node": td, //当前单元格
         *  "view": view, //当前视图对象
         *  "row": {} //当前行的平台类对象
         * }
* @event mwf.xapplication.query.query.viewer.item#click */ /** * @summary 行所属视图. * @member {object} */ this.view = view; /** * @summary 行数据. * @member {object} */ this.data = data; this.css = this.view.css; /** * @summary 行是否被选中. * @member {boolean} */ this.isselected = false; /** * @summary 如果视图有分类,获取分类对象。 * @member {object} */ this.category = category; this.prev = prev; this.idx = i; this.clazztype = "item"; this.lazy = lazy; this.load(); }, load: function(){ if( this.lazy && this.view.io ){ this.view.fireevent("queryloaditemrow", [this]); this.loadnode(); this.view.io.observe( this.node ); }else{ this._load(); } }, active: function(){ if( !this.loaded && !this.loading ){ this._load(); } }, loadnode: function(){ var viewstyles = this.view.viewjson.viewstyles; var trstyle = ( viewstyles && viewstyles["contenttr"] ) ? viewstyles["contenttr"] : this.css.viewcontenttrnode; this.node = new element("tr", { "styles": trstyle }); if (this.prev){ this.node.inject(this.prev.node, "after"); }else{ this.node.inject(this.view.viewtable); } 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", [this]); var viewstyles = this.view.viewjson.viewstyles; var viewcontenttdnode = ( viewstyles && viewstyles["contenttd"] ) ? viewstyles["contenttd"] : this.css.viewcontenttdnode; if(!this.node)this.loadnode(); //if (this.view.json.select==="single" || this.view.json.select==="multi"){ this.selecttd = new element("td", { "styles": viewcontenttdnode }).inject(this.node); this.selecttd.setstyles({"cursor": "pointer"}); if (this.view.json.itemstyles) this.selecttd.setstyles(this.view.json.itemstyles); //var selectflag = this.view.json.select || this.view.viewjson.select || "none"; var selectflag = this.view.getselectflag(); if ( this.data.$selectedenable && ["multi","single"].contains(selectflag) && this.view.viewjson.selectboxshow==="always") { 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": " center center no-repeat"}); } } if( this.view.isselecttdhidden() ){ this.selecttd.hide(); } //} //序号 var sequence = 1 this.view.json.pagesize*(this.view.currentpage-1) this.idx; this.data["$sequence"] = sequence; if (this.view.viewjson.issequence==="yes"){ this.sequencetd = new element("td", {"styles": viewcontenttdnode}).inject(this.node); this.sequencetd.setstyles({ "width": "30px", "text-align": "center" }); this.sequencetd.set("text", sequence); } object.each(this.view.entries, function(c, k){ var cell = this.data.data[k]; if (cell === undefined) cell = ""; //if (cell){ if (this.view.hidecolumns.indexof(k)===-1){ var td = new element("td", {"styles": viewcontenttdnode}).inject(this.node); if (k!== this.view.viewjson.group.column){ //var v = (this.view.entries[k].code) ? mwf.macro.exec(this.view.entries[k].code, {"value": cell, "griddata": this.view.gridjson, "data": this.view.viewdata, "entry": this.data}) : cell; var v = cell; if (c.ishtml){ td.set("html", v); }else{ td.set("text", v); } if( typeof(c.contentproperties) === "object" )td.setproperties(c.contentproperties); 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) } if (k!== this.view.viewjson.group.column){ 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)); } } }.bind(this)); } } //} }.bind(this)); if(this.placeholdertd){ this.placeholdertd.destroy(); this.placeholdertd = null; } //默认选中 debugger; var selectedflag; 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"){ // // } switch (typeof(defaultselectedscript)) { case "string": selectedflag = this.view.macro.exec( defaultselectedscript, {"node" : this.node, "data" : this.data, "view": this.view, "row" : this}); break; case "function": selectedflag = defaultselectedscript({"node" : this.node, "data" : this.data, "view": this.view, "row" : this}); break; } } //判断是不是在selecteditems中,用户手工选择 if( !this.isselected && this.view.selecteditems.length ){ for(var i=0; i1){ // var worksareanode = this.createworksarea(); // json.data.workcompletedlist.each(function(work){ // this.createworkcompletednode(work, worksareanode); // }.bind(this)); // json.data.worklist.each(function(work){ // this.createworknode(work, worksareanode); // }.bind(this)); // this.showworksarea(worksareanode, e); // }else{ // // } // }.bind(this)); }, createworknode: function(work, worksareanode){ var worksareacontentnode = worksareanode.getlast(); var node = new element("div", {"styles": this.css.workareanode}).inject(worksareacontentnode); var actionnode = new element("div", {"styles": this.css.workareaactionnode, "text": this.view.lp.open}).inject(node); actionnode.store("workid", work.id); actionnode.addevent("click", function(e){ this.openwork(e.target.retrieve("workid"), e); this.mask.hide(); worksareanode.destroy(); }.bind(this)); var areanode = new element("div", {"styles": this.css.workarealeftnode}).inject(node); var titlenode = new element("div", {"styles": this.css.workareatitlenode, "text": work.title}).inject(areanode); var contentnode = new element("div", {"styles": this.css.workareacontentnode}).inject(areanode); new element("div", {"styles": this.css.workareacontenttitlenode, "text": this.view.lp.activity ": "}).inject(contentnode); new element("div", {"styles": this.css.workareacontenttextnode, "text": work.activityname}).inject(contentnode); var taskusers = []; mwf.actions.get("x_processplatform_assemble_surface").listtaskbywork(work.id, function(json){ json.data.each(function(task){ taskusers.push(mwf.name.cn(task.person)); }.bind(this)); new element("div", {"styles": this.css.workareacontenttitlenode, "text": this.view.lp.taskpeople ": "}).inject(contentnode); new element("div", {"styles": this.css.workareacontenttextnode, "text": taskusers.join(", ")}).inject(contentnode); }.bind(this)); }, createworkcompletednode: function(work, worksareanode){ var worksareacontentnode = worksareanode.getlast(); var node = new element("div", {"styles": this.css.workareanode}).inject(worksareacontentnode); var actionnode = new element("div", {"styles": this.css.workareaactionnode, "text": this.view.lp.open}).inject(node); actionnode.store("workid", work.id); actionnode.addevent("click", function(e){ this.mask.hide(); var id = e.target.retrieve("workid"); worksareanode.destroy(); this.openworkcompleted(id, e); }.bind(this)); var areanode = new element("div", {"styles": this.css.workarealeftnode}).inject(node); var titlenode = new element("div", {"styles": this.css.workareatitlenode, "text": work.title}).inject(areanode); var contentnode = new element("div", {"styles": this.css.workareacontentnode}).inject(areanode); new element("div", {"styles": this.css.workareacontenttitlenode, "text": this.view.lp.activity ": "}).inject(contentnode); new element("div", {"styles": this.css.workareacontenttextnode, "text": this.view.lp.processcompleted}).inject(contentnode); }, createworksarea: function(){ var cssworksarea = this.css.worksareanode if (layout.mobile) { cssworksarea = this.css.worksareanodemobile; } var worksareanode = new element("div", {"styles": cssworksarea}); var worksareatitlenode = new element("div", {"styles": this.css.worksareatitlenode}).inject(worksareanode); var worksareatitleclosenode = new element("div", {"styles": this.css.worksareatitleclosenode}).inject(worksareatitlenode); worksareatitleclosenode.addevent("click", function(e){ this.mask.hide(); e.target.getparent().getparent().destroy(); }.bind(this)); var worksareacontentnode = new element("div", {"styles": this.css.worksareacontentnode}).inject(worksareanode); return worksareanode; }, showworksarea: function(node, e){ mwf.require("mwf.widget.mask", null, false); this.mask = new mwf.widget.mask({"style": "desktop", "loading": false}); this.mask.loadnode(this.view.container); node.inject(this.view.node); this.setworksareaposition(node, e.target); }, setworksareaposition: function(node, td){ var p = td.getposition(this.view.container); var containers = this.view.container.getsize(); var containerp = this.view.container.getposition(this.view.container.getoffsetparent()); var s = node.getsize(); var offx = p.x s.x-containers.x; offx = (offx>0) ? offx 20 : 0; var offy = p.y s.y-containers.y; offy = (offy>0) ? offy 5 : 0; node.position({ "relativeto": td, "position": "lefttop", "edge": "lefttop", "offset": { "x": 0-offx, "y": 0-offy } }); }, openwork: function(id, e){ var options = {"workid": id}; this.view.fireevent("opendocument", [options, this]); //options 传入的事件 layout.desktop.openapplication(e, "process.work", options); }, openworkcompleted: function(id, e){ var options = {"workcompletedid": id}; this.view.fireevent("opendocument", [options, this]); //options 传入的事件 layout.desktop.openapplication(e, "process.work", options); }, setevent: function(){ var flag = this.view.getselectflag(); if ( this.data.$selectedenable && (flag ==="single" || flag==="multi")){ this.node.addevents({ "mouseover": function(){ if (!this.isselected && this.view.viewjson.selectboxshow !=="always" ){ 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"; this.selecttd.setstyles({"background": " center center no-repeat"}); } } }.bind(this), "mouseout": function(){ if (!this.isselected && this.view.viewjson.selectboxshow !=="always") this.selecttd.setstyles({"background": "transparent"}); }.bind(this), "click": function(){this.select();}.bind(this) }); } }, select: function( force ){ // var flag = force || this.view.json.select || this.view.viewjson.select || "none"; var flag = force || this.view.getselectflag(); if (this.isselected){ if (flag==="single"){ this.unselectedsingle(); }else{ this.unselected(); } }else{ if (flag==="single"){ this.selectedsingle(); }else{ this.selected(); } } }, /** * @summary 选中(多选)。 * @example * item = this.target.items[0]; * item.selected(); */ selected: function( from ){ for(var i=0; i" "" ) // this.selectallnode = new element("span",{ // html : "" "", // style : "font-family: webdings" // }).inject( this.selecttd ); } this.selectallnode.setstyle("cursor", "pointer"); this.selectallnode.addevent("click", function (ev) { if( this.getselectallstatus() === "all" ){ this.unselectall("category") }else{ this.selectall("category"); } ev.stoppropagation(); }.bind(this)); } // if( this.view.isselecttdhidden() ){ // this.selecttd.hide(); // } //} this.categorytd = new element("td", { "styles": viewcontentcategorytdnode, "colspan": this.view.viewjson.selectlist.length 1 }).inject(this.node); this.groupcolumn = null; for (var c = 0; c " text); } this.expanded = false; if (this.view.json.itemstyles) this.categorytd.setstyles(this.view.json.itemstyles); 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); } this.setevent(); 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)); } } }.bind(this)); this.view.fireevent("postloadcategoryrow", [this]); }, 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.expanded = false; if( from !== "view" ){ this.view.checkexpandallstatus(); } }, expand: function( from ){ this.items.each(function(item){ item.node.setstyle("display", "table-row"); }.bind(this)); if( this.expandnode ){ this.expandnode.setstyles( this.view.viewjson.viewstyles["groupexpandnode"] ) }else{ this.node.getelement("span").set("html", ""); } this.expanded = true; if (!this.loadchild){ //window.settimeout(function(){ this.data.list.each(function(line, i){ var s = this.idx i; this.lastitem = new mwf.xapplication.query.query.viewer.item(this.view, line, (this.lastitem || this), s, this, this.view.options.lazy); this.items.push(this.lastitem); }.bind(this)); this.loadchild = true; //}.bind(this), 10); } if( from !== "view" ){ this.view.checkexpandallstatus(); } } }); 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); } }); /** @class actionbar 视图操作条组件。 * @o2cn 视图操作条 * @example * //可以在视图中获取该组件 * var actionbar = this.target.actionbar; //在视图中获取操作条 * //方法2 * var actionbar = this.target; //在操作条和操作本身的事件脚本中获取 * @o2category queryview * @o2range {queryview} * @hideconstructor */ mwf.xapplication.query.query.viewer.actionbar = new class( /** @lends mwf.xapplication.query.query.viewer.actionbar# */ { implements: [events], options: { "style" : "default", "moduleevents": [ /** * 视图操作条加载前触发。 * @event mwf.xapplication.query.query.viewer.actionbar#queryload */ "queryload", /** * 视图加载时触发。 * @event mwf.xapplication.query.query.viewer.actionbar#load */ "load", /** * 视图操作条加载后事件.由于加载过程中有异步处理,这个时候操作条有可能还未生成。 * @event mwf.xapplication.query.query.viewer.actionbar#postload */ "postload", /** * 视图操作条加载后事件。这个时候操作条已生成。 * @event mwf.xapplication.query.query.viewer.actionbar#afterload */ "afterload" ] }, initialize: function(node, json, form, options){ /** * @summary 操作条组件容器. * @member {element} */ this.node = $(node); this.node.store("module", this); /** * @summary 操作条组件配置数据. * @member {object} */ this.json = json; this.form = form; /** * @summary 操作条组件所属视图. * @member {object} */ this.view = form; }, /** * @summary 隐藏操作条。 */ hide: function(){ var dsp = this.node.getstyle("display"); if (dsp!=="none") this.node.store("mwf_display", dsp); this.node.setstyle("display", "none"); }, /** * @summary 显示操作条。 */ 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"); } value = o2.filter; } this.node.setstyle(key, value); }.bind(this)); // if (["x_processplatform_assemble_surface", "x_portal_assemble_surface"].indexof(root.tolowercase())!==-1){ // var host = mwf.actions.gethost(root); // return (flag==="/") ? host this.json.template : host "/" this.json.template // } //if (this.json.styles) this.node.setstyles(this.json.styles); }, _loadmoduleevents : function(){ object.each(this.json.events, function(e, key){ if (e.code){ if (this.options.moduleevents.indexof(key)!==-1){ this.addevent(key, function(event){ return this.form.macro.fire(e.code, this, event); }.bind(this)); } } }.bind(this)); }, _loaddomevents: function(){ object.each(this.json.events, function(e, key){ if (e.code){ if (this.options.moduleevents.indexof(key)===-1){ this.node.addevent(key, function(event){ return this.form.macro.fire(e.code, this, event); }.bind(this)); } } }.bind(this)); }, _loadevents: function(){ object.each(this.json.events, function(e, key){ if (e.code){ if (this.options.moduleevents.indexof(key)!==-1){ this.addevent(key, function(event){ return this.form.macro.fire(e.code, this, event); }.bind(this)); }else{ this.node.addevent(key, function(event){ return this.form.macro.fire(e.code, this, event); }.bind(this)); } } }.bind(this)); }, addmoduleevent: function(key, fun){ if (this.options.moduleevents.indexof(key)!==-1){ this.addevent(key, function(event){ return (fun) ? fun(this, event) : null; }.bind(this)); }else{ this.node.addevent(key, function(event){ return (fun) ? fun(this, event) : null; }.bind(this)); } }, _loaduserinterface: function(){ // if (this.form.json.mode == "mobile"){ // this.node.empty(); // }else if (common.browser.platform.ismobile){ // this.node.empty(); // }else{ this.toolbarnode = this.node.getfirst("div"); if( !this.toolbarnode ){ this.toolbarnode = new element("div").inject( this.node ); } this.toolbarnode.empty(); mwf.require("mwf.widget.toolbar", function(){ this.toolbarwidget = new mwf.widget.toolbar(this.toolbarnode, { "style": this.json.style, "onpostload" : function(){ this.fireevent("afterload"); }.bind(this) }, this); if (this.json.actionstyles) this.toolbarwidget.css = this.json.actionstyles; //alert(this.readonly) if( this.json.multitools ){ // var jsonstr = json.stringify(this.json.multitools); // jsonstr = o2.bindjson(jsonstr, {"lp": mwf.xapplication.query.query.lp.form}); // this.json.multitools = json.parse(jsonstr); 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)); this.toolbarwidget.load(); }else{ if (this.json.hidesystemtools){ this.setcustomtoolbars(this.json.tools, this.toolbarnode); this.toolbarwidget.load(); }else{ if (this.json.defaulttools){ this.settoolbars(this.json.defaulttools, this.toolbarnode, this.readonly); this.setcustomtoolbars(this.json.tools, this.toolbarnode); this.toolbarwidget.load(); }else{ mwf.getjson(this.form.path "toolbars.json", function(json){ this.settoolbars(json, this.toolbarnode, this.readonly, true); this.setcustomtoolbars(this.json.tools, this.toolbarnode); this.toolbarwidget.load(); }.bind(this), null); } } } }.bind(this)); // } }, setcustomtoolbars: function(tools, node){ var path = "../x_component_process_formdesigner/module/actionbar/"; var iconpath = ""; if( this.json.customiconstyle ){ iconpath = this.json.customiconstyle "/"; } tools.each(function(tool){ var flag = true; if (this.readonly){ flag = tool.readshow; }else{ flag = tool.editshow; } if (flag){ flag = true; // if (tool.control){ // flag = this.form.businessdata.control[tool.control] // } if (tool.condition){ var hideflag = this.form.macro.exec(tool.condition, this); flag = !hideflag; } if (flag){ var actionnode = new element("div", { "id": tool.id, "mwfnodetype": tool.type, "mwfbuttonimage": path "" this.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.options.style "/custom/" this.json.customiconoverstyle "/" tool.img ); } if( tool.properties ){ actionnode.set(tool.properties); } if (tool.actionscript){ actionnode.store("script", tool.actionscript); } if (tool.sub){ var subnode = node.getlast(); this.setcustomtoolbars(tool.sub, subnode); } } } }.bind(this)); }, settoolbaritem: function(tool, node, readonly, nocondition){ //var path = "../x_component_process_formdesigner/module/actionbar/"; var path = "../x_component_query_viewdesigner/$view/"; var flag = true; // if (tool.control){ // flag = this.form.businessdata.control[tool.control] // } if (!nocondition) if (tool.condition){ var hideflag = this.form.macro.exec(tool.condition, this); flag = flag && (!hideflag); } if (readonly) if (!tool.read) flag = false; if (flag){ var actionnode = new element("div", { "id": tool.id, "mwfnodetype": tool.type, //"mwfbuttonimage": this.form.path "" this.form.options.style "/actionbar/" tool.img, //"mwfbuttonimage": path (this.options.style||"default") "/tools/" (this.json.style || "default") "/" tool.img, "mwfbuttonimage": path this.options.style "/actionbar/" ( this.json.iconstyle || "default" ) "/" tool.img, "title": tool.title, "mwfbuttonaction": tool.action, "mwfbuttontext": tool.text }).inject(node); if( this.json.iconoverstyle ){ actionnode.set("mwfbuttonimageover" , path "" this.options.style "/actionbar/" this.json.iconoverstyle "/" tool.img ); //actionnode.set("mwfbuttonimageover" , path "" (this.options.style||"default") "/tools/" ( this.json.iconoverstyle || "default" ) "/" tool.img ); } if( tool.properties ){ actionnode.set(tool.properties); } if (tool.sub){ var subnode = node.getlast(); this.settoolbars(tool.sub, subnode, readonly, nocondition); } } }, settoolbars: function(tools, node, readonly, nocondition){ tools.each(function(tool){ this.settoolbaritem(tool, node, readonly, nocondition); }.bind(this)); }, runcustomaction: function(bt){ var script = bt.node.retrieve("script"); this.form.macro.exec(script, this); }, exportview : function(){ this.form.exportview(); }, deletework: function(){ this.form.deletework(); } }); /** @class actionbar 视图分页组件。 * @o2cn 视图分页组件 * @example * //可以在视图中获取该组件 * var actionbar = this.target.paging; //在视图中获取操作条 * //方法2 * var actionbar = this.target; //在分页组件本身的事件脚本中获取 * @o2category queryview * @o2range {queryview} * @hideconstructor */ mwf.xapplication.query.query.viewer.paging = new class( /** @lends mwf.xapplication.query.query.viewer.paging# */ { implements: [options, events], options: { "style" : "default", "usemaincolor": false, "moduleevents": [ /** * 分页加载前触发。 * @event mwf.xapplication.query.query.viewer.paging#queryload */ "queryload", /** * 分页加载时触发。 * @event mwf.xapplication.query.query.viewer.paging#load */ "load", /** * 分页加载后事件.由于加载过程中有异步处理,这个时候分页组件有可能还未生成。 * @event mwf.xapplication.query.query.viewer.paging#postload */ "postload", /** * 分页加载后事件。这个时候分页界面已生成。 * @event mwf.xapplication.query.query.viewer.paging#afterload */ "afterload", /** * 跳页或者分页后执行。 * @event mwf.xapplication.query.query.viewer.paging#jump */ "jump" ] }, initialize: function(node, json, form, options){ this.setoptions(options); /** * @summary 分页组件容器. * @member {element} */ this.node = $(node); this.node.store("module", this); /** * @summary 分页组件所属视图. * @member {object} */ this.json = json; this.form = form; /** * @summary 分页所属视图. * @member {object} */ this.view = form; }, /** * @summary 隐藏分页。 */ hide: function(){ var dsp = this.node.getstyle("display"); if (dsp!=="none") this.node.store("mwf_display", dsp); this.node.setstyle("display", "none"); }, /** * @summary 显示分页。 */ 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"); } value = o2.filter; } 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 ){ // 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, { //style : this.options.skin && this.options.skin.pagingbar ? this.options.skin.pagingbar : "default", countperpage: this.view.json.pagesize || this.view.options.perpagecount, visiblepages: layout.mobile?5:(this.json.visiblepages ? this.json.visiblepages.toint() : 9), 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, 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), hiddenwithdisable: false, hiddenwithnoitem: true, hasinfor: this.json.showpaginginfor, inforposition: this.json.pagingposition, infortextstyle: this.json.textstyle, usemaincolor: this.options.usemaincolor, 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"); this.view.loadcurrentpagedata( null, false ); }.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(); } }); mwf.xapplication.query.query.viewer.associatedresultitem = new class({ extends: mwf.xapplication.query.query.viewer.item, _load: function(){ this.loading = true; if(!this.node)this.view.fireevent("queryloaditemrow", [this]); var viewstyles = this.view.viewjson.viewstyles; var viewcontenttdnode = ( viewstyles && viewstyles["contenttd"] ) ? viewstyles["contenttd"] : this.css.viewcontenttdnode; if(!this.node)this.loadnode(); //if (this.view.json.select==="single" || this.view.json.select==="multi"){ this.selecttd = new element("td", { "styles": viewcontenttdnode }).inject(this.node); if (this.view.json.itemstyles) this.selecttd.setstyles(this.view.json.itemstyles); this.selecttd.setstyles({"cursor": "default"}); if( this.data.$failure ){ this.selecttd.setstyles({"background": " center center no-repeat"}); }else{ this.selecttd.setstyles({"background": " center center no-repeat"}); } //序号 var sequence = 1 this.idx; this.data["$sequence"] = sequence; if (this.view.viewjson.issequence==="yes"){ this.sequencetd = new element("td", {"styles": viewcontenttdnode}).inject(this.node); this.sequencetd.setstyles({ "width": "30px", "text-align": "center" }); this.sequencetd.set("text", sequence); } object.each(this.view.entries, function(c, k){ var cell = this.data.data[k]; if (cell === undefined) cell = ""; //if (cell){ if (this.view.hidecolumns.indexof(k)===-1){ var td = new element("td", {"styles": viewcontenttdnode}).inject(this.node); //if (k!== this.view.viewjson.group.column){ var v = cell; if (c.ishtml){ td.set("html", v); }else{ td.set("text", v); } if( typeof(c.contentproperties) === "object" )td.setproperties(c.contentproperties); 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) } if (k!== this.view.viewjson.group.column){ 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)); } } }.bind(this)); } } //} }.bind(this)); if(this.placeholdertd){ this.placeholdertd.destroy(); this.placeholdertd = null; } //默认选中 //判断是不是在selecteditems中,用户手工选择 this.setevent(); this.view.fireevent("postloaditemrow", [this]); this.loading = false; this.loaded = true; }, })
网站地图