Переглянути джерело

视图增加自定义功能

unknown 5 роки тому
батько
коміт
c417ac4d28

+ 5 - 5
o2web/source/x_component_query_Query/$Viewer/default/css.wcss

@@ -164,7 +164,7 @@
         "border": "1px solid #cccccc",
         "float": "none",
         "margin": "10px",
-        "border-radius": "5px",
+        "border-radius": "5px"
     },
     "viewFilterSearchCustomActionNode": {
         "height": "24px",
@@ -249,16 +249,16 @@
     "viewFilterSearchCustomPathListNode": {
         "border": "0px",
         "border-radius": "5px",
-        "height": "80px",
+        "height": "74px",
         "padding": "3px",
-        "width": "99px",
+        "width": "93px",
         "font-size": "12px"
     },
     "viewFilterSearchCustomComparisonListNode": {
         "border": "0px",
-        "height": "80px",
+        "height": "74px",
         "padding": "3px",
-        "width": "99px",
+        "width": "93px",
         "font-size": "12px"
     },
     "viewFilterSearchOptionNode": {

+ 393 - 49
o2web/source/x_component_query_Query/Viewer.js

@@ -12,7 +12,9 @@ MWF.xApplication.query.Query.Viewer = MWF.QViewer = new Class({
         "paging" : "scroll",
         "perPageCount" : 50,
         "isload": "true",
-        "export": false
+        "export": false,
+        "moduleEvents": ["queryLoad", "postLoadData", "postLoad", "queryLoadRow", "postLoadRow", "selectRow", "unselectRow"]
+
         // "actions": {
         //     "lookup": {"uri": "/jaxrs/view/flag/{view}/query/{application}/execute", "method":"PUT"},
         //     "getView": {"uri": "/jaxrs/view/flag/{view}/query/{application}"}
@@ -21,6 +23,11 @@ MWF.xApplication.query.Query.Viewer = MWF.QViewer = new Class({
         // "actionRoot": "x_query_assemble_surface"
     },
     initialize: function(container, json, options){
+        //本类有三种事件,
+        //一种是通过 options 传进来的事件,包括 loadView、openDocument、select
+        //一种是用户配置的 事件, 在this.options.moduleEvents 中定义的作为类事件
+        //还有一种也是用户配置的事件,不在this.options.moduleEvents 中定义的作为 this.node 的DOM事件
+
         this.setOptions(options);
 
         this.path = "/x_component_query_Query/$Viewer/";
@@ -67,8 +74,16 @@ MWF.xApplication.query.Query.Viewer = MWF.QViewer = new Class({
         }
     },
     load: function(){
+        this._loadModuleEvents();
+        if (this.fireEvent("queryLoad")){
+            this._loadUserInterface();
+            //this._loadStyles();
+            this._loadDomEvents();
+        }
+    },
+    _loadUserInterface : function(){
         this.loadLayout();
-        this.createExportNode();
+        this.createActionbarNode();
         this.createSearchNode();
         this.createViewNode({"filterList": this.json.filter  ? this.json.filter.clone() : null});
 
@@ -80,7 +95,8 @@ MWF.xApplication.query.Query.Viewer = MWF.QViewer = new Class({
     },
     loadLayout: function(){
         this.node = new Element("div", {"styles": this.css.node}).inject(this.container);
-        if (this.options.export) this.exportAreaNode = new Element("div", {"styles": this.css.exportAreaNode}).inject(this.node);
+        this.actionbarAreaNode =  new Element("div", {"styles": this.css.actionbarAreaNode}).inject(this.node);
+        //if (this.options.export) this.exportAreaNode = new Element("div", {"styles": this.css.exportAreaNode}).inject(this.node);
         this.searchAreaNode = new Element("div", {"styles": this.css.searchAreaNode}).inject(this.node);
         this.viewAreaNode = new Element("div", {"styles": this.css.viewAreaNode}).inject(this.node);
         this.viewPageNode = new Element("div", {"styles": this.css.viewPageNode}).inject(this.node);
@@ -89,7 +105,7 @@ MWF.xApplication.query.Query.Viewer = MWF.QViewer = new Class({
     createExportNode: function(){
         if (this.options.export){
             MWF.require("MWF.widget.Toolbar", function(){
-                this.toolbar = new MWF.widget.Toolbar(this.exportAreaNode, {"style": "simple"}, this);
+                this.toolbar = new MWF.widget.Toolbar(this.actionbarAreaNode, {"style": "simple"}, this); //this.exportAreaNode
                 var actionNode = new Element("div", {
                     "id": "",
                     "MWFnodetype": "MWFToolBarButton",
@@ -97,7 +113,7 @@ MWF.xApplication.query.Query.Viewer = MWF.QViewer = new Class({
                     "title": this.lp.exportExcel,
                     "MWFButtonAction": "exportView",
                     "MWFButtonText": this.lp.exportExcel
-                }).inject(this.exportAreaNode);
+                }).inject(this.actionbarAreaNode); //this.exportAreaNode
 
                 this.toolbar.load();
             }.bind(this));
@@ -513,8 +529,12 @@ MWF.xApplication.query.Query.Viewer = MWF.QViewer = new Class({
         var size = this.node.getSize();
         var searchSize = this.searchAreaNode.getComputedSize();
         var h = size.y-searchSize.totalHeight;
-        if (this.exportAreaNode){
-            var exportSize = this.exportAreaNode.getComputedSize();
+        //if (this.exportAreaNode){
+        //    var exportSize = this.exportAreaNode.getComputedSize();
+        //    h = h-exportSize.totalHeight;
+        //}
+        if( this.actionbarAreaNode ){
+            var exportSize = this.actionbarAreaNode.getComputedSize();
             h = h-exportSize.totalHeight;
         }
         var pageSize = this.viewPageNode.getComputedSize();
@@ -529,6 +549,16 @@ MWF.xApplication.query.Query.Viewer = MWF.QViewer = new Class({
         var loadingTextNode = new Element("div", {"styles": this.css.viewLoadingTextNode}).inject(loadingNode);
         loadingTextNode.set("text", "loading...");
     },
+    createActionbarNode : function(){
+        this.actionbarAreaNode.empty();
+        if( typeOf( this.viewJson.actionbarHidden ) === "boolean" ){
+            if( this.viewJson.actionbarHidden === true || !this.viewJson.actionbarList || !this.viewJson.actionbarList.length )return;
+            this.actionbar = new MWF.xApplication.query.Query.Viewer.Actionbar(this.actionbarAreaNode, this.viewJson.actionbarList[0], this, {});
+            this.actionbar.load();
+        }else{ //兼容以前的ExportNode
+            this.createExportNode();
+        }
+    },
     createViewNode: function(data){
         this.viewAreaNode.empty();
         this.contentAreaNode = new Element("div", {"styles": this.css.contentAreaNode}).inject(this.viewAreaNode);
@@ -545,11 +575,11 @@ MWF.xApplication.query.Query.Viewer = MWF.QViewer = new Class({
             this.viewTitleLine = new Element("tr", {"styles": this.css.viewTitleLineNode}).inject(this.viewTable);
 
             //if (this.json.select==="single" || this.json.select==="multi") {
-                this.selectTitleCell = new Element("td", {
-                    "styles": this.css.viewTitleCellNode
-                }).inject(this.viewTitleLine);
-                this.selectTitleCell.setStyle("width", "10px");
-                if (this.json.titleStyles) this.selectTitleCell.setStyles(this.json.titleStyles);
+            this.selectTitleCell = new Element("td", {
+                "styles": this.css.viewTitleCellNode
+            }).inject(this.viewTitleLine);
+            this.selectTitleCell.setStyle("width", "10px");
+            if (this.json.titleStyles) this.selectTitleCell.setStyles(this.json.titleStyles);
             //}
 
             //序号
@@ -702,6 +732,9 @@ MWF.xApplication.query.Query.Viewer = MWF.QViewer = new Class({
 
         this.loadViewRes = this.lookupAction.loadView(this.json.name, this.json.application, d, function(json){
             this.viewData = json.data;
+
+            this.fireEvent("postLoadData");
+
             if (this.viewJson.group.column){
                 this.gridJson = json.data.groupGrid;
                 this.loadGroupData();
@@ -714,7 +747,9 @@ MWF.xApplication.query.Query.Viewer = MWF.QViewer = new Class({
                 this.loadingAreaNode.destroy();
                 this.loadingAreaNode = null;
             }
-            this.fireEvent("loadView");
+            this.fireEvent("loadView"); //options 传入的事件
+
+            this.fireEvent("postLoad"); //用户配置的事件
         }.bind(this));
     },
 
@@ -722,9 +757,9 @@ MWF.xApplication.query.Query.Viewer = MWF.QViewer = new Class({
     loadData: function(){
         if (this.gridJson.length){
             // if( !this.options.paging ){
-                this.gridJson.each(function(line, i){
-                    this.items.push(new MWF.xApplication.query.Query.Viewer.Item(this, line, null, i));
-                }.bind(this));
+            this.gridJson.each(function(line, i){
+                this.items.push(new MWF.xApplication.query.Query.Viewer.Item(this, line, null, i));
+            }.bind(this));
             // }else{
             //     this.loadPaging();
             // }
@@ -917,6 +952,28 @@ MWF.xApplication.query.Query.Viewer = MWF.QViewer = new Class({
         }else{
             return [];
         }
+    },
+    _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));
     }
 });
 
@@ -932,6 +989,8 @@ MWF.xApplication.query.Query.Viewer.Item = new Class({
     },
     load: function(){
         debugger;
+        this.view.fireEvent("queryLoadRow", [this]);
+
         this.node = new Element("tr", {"styles": this.css.viewContentTrNode});
         if (this.prev){
             this.node.inject(this.prev.node, "after");
@@ -940,9 +999,9 @@ MWF.xApplication.query.Query.Viewer.Item = new Class({
         }
 
         //if (this.view.json.select==="single" || this.view.json.select==="multi"){
-            this.selectTd = new Element("td", {"styles": this.css.viewContentTdNode}).inject(this.node);
-            this.selectTd.setStyles({"cursor": "pointer"});
-            if (this.view.json.itemStyles) this.selectTd.setStyles(this.view.json.itemStyles);
+        this.selectTd = new Element("td", {"styles": this.css.viewContentTdNode}).inject(this.node);
+        this.selectTd.setStyles({"cursor": "pointer"});
+        if (this.view.json.itemStyles) this.selectTd.setStyles(this.view.json.itemStyles);
         //}
 
         //序号
@@ -958,22 +1017,22 @@ MWF.xApplication.query.Query.Viewer.Item = new Class({
             var cell = this.data.data[k];
             if (cell === undefined) cell = "";
             //if (cell){
-                if (this.view.hideColumns.indexOf(k)===-1){
-                    var td = new Element("td", {"styles": this.css.viewContentTdNode}).inject(this.node);
-                    if (k!== this.view.viewJson.group.column){
-                        //var v = (this.view.entries[k].code) ? MWF.Macro.exec(this.view.entries[k].code, {"value": cell, "gridData": this.view.gridJson, "data": this.view.viewData, "entry": this.data}) : cell;
-                        var v = cell;
-                        if (c.isHtml){
-                            td.set("html", v);
-                        }else{
-                            td.set("text", v);
-                        }
-                    }
-                    if (this.view.openColumns.indexOf(k)!==-1){
-                        this.setOpenWork(td, c)
+            if (this.view.hideColumns.indexOf(k)===-1){
+                var td = new Element("td", {"styles": this.css.viewContentTdNode}).inject(this.node);
+                if (k!== this.view.viewJson.group.column){
+                    //var v = (this.view.entries[k].code) ? MWF.Macro.exec(this.view.entries[k].code, {"value": cell, "gridData": this.view.gridJson, "data": this.view.viewData, "entry": this.data}) : cell;
+                    var v = cell;
+                    if (c.isHtml){
+                        td.set("html", v);
+                    }else{
+                        td.set("text", v);
                     }
-                    if (this.view.json.itemStyles) td.setStyles(this.view.json.itemStyles);
                 }
+                if (this.view.openColumns.indexOf(k)!==-1){
+                    this.setOpenWork(td, c)
+                }
+                if (this.view.json.itemStyles) td.setStyles(this.view.json.itemStyles);
+            }
             //}
         }.bind(this));
 
@@ -992,6 +1051,8 @@ MWF.xApplication.query.Query.Viewer.Item = new Class({
         // }.bind(this));
 
         this.setEvent();
+
+        this.view.fireEvent("postLoadRow", [this]);
     },
     setOpenWork: function(td, column){
         debugger;
@@ -1004,20 +1065,28 @@ MWF.xApplication.query.Query.Viewer.Item = new Class({
                 }.bind(this), false);
             }
             td.addEvent("click", function( ev ){
-                return this.view.Macro.fire(column.clickCode, this, ev);
+                var result = this.view.Macro.fire(column.clickCode, this, ev);
+                ev.stopPropagation();
+                return result;
             }.bind(this));
         }else{
             if (this.view.json.type==="cms"){
-                td.addEvent("click", this.openCms.bind(this));
+                td.addEvent("click", function(ev){
+                    this.openCms(ev)
+                    ev.stopPropagation();
+                }.bind(this));
             }else{
-                td.addEvent("click", this.openWorkAndCompleted.bind(this));
+                td.addEvent("click", function(ev){
+                    this.openWorkAndCompleted(ev)
+                    ev.stopPropagation();
+                }.bind(this));
             }
         }
 
     },
     openCms: function(e){
         var options = {"documentId": this.data.bundle};
-        this.view.fireEvent("openDocument", [options, this]);
+        this.view.fireEvent("openDocument", [options, this]); //options 传入的事件
         layout.desktop.openApplication(e, "cms.Document", options);
     },
     openWorkAndCompleted: function(e){
@@ -1137,22 +1206,23 @@ MWF.xApplication.query.Query.Viewer.Item = new Class({
     },
     openWork: function(id, e){
         var options = {"workId": id};
-        this.view.fireEvent("openDocument", [options, this]);
+        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]);
+        this.view.fireEvent("openDocument", [options, this]); //options 传入的事件
         layout.desktop.openApplication(e, "process.Work", options);
     },
 
     setEvent: function(){
-        if (this.view.json.select==="single" || this.view.json.select==="multi"){
+        var flag = this.view.json.select || this.view.viewJson.select ||  "none";
+        if ( flag ==="single" || flag==="multi"){
             this.node.addEvents({
                 "mouseover": function(){
                     if (!this.isSelected){
                         var iconName = "checkbox";
-                        if (this.view.json.select==="single") iconName = "radiobox";
+                        if (flag==="single") iconName = "radiobox";
                         this.selectTd.setStyles({"background": "url("+"/x_component_query_Query/$Viewer/default/icon/"+iconName+".png) center center no-repeat"});
                     }
                 }.bind(this),
@@ -1165,20 +1235,21 @@ MWF.xApplication.query.Query.Viewer.Item = new Class({
     },
 
     select: function(){
+        var flag = this.view.json.select || this.view.viewJson.select ||  "none";
         if (this.isSelected){
-            if (this.view.json.select==="single"){
+            if (flag==="single"){
                 this.unSelectedSingle();
             }else{
                 this.unSelected();
             }
         }else{
-            if (this.view.json.select==="single"){
+            if (flag==="single"){
                 this.selectedSingle();
             }else{
                 this.selected();
             }
         }
-        this.view.fireEvent("select");
+        this.view.fireEvent("select"); //options 传入的事件
     },
 
     selected: function(){
@@ -1186,12 +1257,14 @@ MWF.xApplication.query.Query.Viewer.Item = new Class({
         this.selectTd.setStyles({"background": "url("+"/x_component_query_Query/$Viewer/default/icon/checkbox_checked.png) center center no-repeat"});
         this.node.setStyles(this.css.viewContentTrNode_selected);
         this.isSelected = true;
+        this.view.fireEvent("selectRow", [this]);
     },
     unSelected: function(){
         this.view.selectedItems.erase(this);
         this.selectTd.setStyles({"background": "transparent"});
         this.node.setStyles(this.css.viewContentTrNode);
         this.isSelected = false;
+        this.view.fireEvent("unselectRow", [this]);
     },
     selectedSingle: function(){
         if (this.view.currentSelectedItem) this.view.currentSelectedItem.unSelectedSingle();
@@ -1200,6 +1273,7 @@ MWF.xApplication.query.Query.Viewer.Item = new Class({
         this.selectTd.setStyles({"background": "url("+"/x_component_query_Query/$Viewer/default/icon/radiobox_checked.png) center center no-repeat"});
         this.node.setStyles(this.css.viewContentTrNode_selected);
         this.isSelected = true;
+        this.view.fireEvent("selectRow", [this]);
     },
     unSelectedSingle: function(){
         this.view.selectedItems = [];
@@ -1207,6 +1281,7 @@ MWF.xApplication.query.Query.Viewer.Item = new Class({
         this.selectTd.setStyles({"background": "transparent"});
         this.node.setStyles(this.css.viewContentTrNode);
         this.isSelected = false;
+        this.view.fireEvent("unselectRow", [this]);
     }
 });
 
@@ -1221,10 +1296,12 @@ MWF.xApplication.query.Query.Viewer.ItemCategory = new Class({
         this.load();
     },
     load: function(){
+        this.view.fireEvent("queryLoadRow", [this]);
+
         this.node = new Element("tr", {"styles": this.css.viewContentTrNode}).inject(this.view.viewTable);
         //if (this.view.json.select==="single" || this.view.json.select==="multi"){
-            this.selectTd = new Element("td", {"styles": this.css.viewContentCategoryTdNode}).inject(this.node);
-            if (this.view.json.itemStyles) this.selectTd.setStyles(this.view.json.itemStyles);
+        this.selectTd = new Element("td", {"styles": this.css.viewContentCategoryTdNode}).inject(this.node);
+        if (this.view.json.itemStyles) this.selectTd.setStyles(this.view.json.itemStyles);
         //}
         this.categoryTd = new Element("td", {
             "styles": this.css.viewContentCategoryTdNode,
@@ -1249,12 +1326,14 @@ MWF.xApplication.query.Query.Viewer.ItemCategory = new Class({
         if (this.view.json.itemStyles) this.categoryTd.setStyles(this.view.json.itemStyles);
 
         this.setEvent();
+
+        this.view.fireEvent("postLoadRow", [this]);
     },
     setEvent: function(){
         //if (this.selectTd){
-            this.node.addEvents({
-                "click": function(){this.expandOrCollapse();}.bind(this)
-            });
+        this.node.addEvents({
+            "click": function(){this.expandOrCollapse();}.bind(this)
+        });
         //}
     },
     expandOrCollapse: function(){
@@ -1356,3 +1435,268 @@ MWF.xApplication.query.Query.Viewer.Filter = new Class({
         MWF.release(this);
     }
 });
+
+
+
+MWF.xApplication.query.Query.Viewer.Actionbar = new Class({
+    Implements: [Events],
+    options: {
+        "style" : "default",
+        "moduleEvents": ["load", "queryLoad", "postLoad", "afterLoad"]
+    },
+    initialize: function(node, json, form, options){
+
+        this.node = $(node);
+        this.node.store("module", this);
+        this.json = json;
+        this.form = form;
+        this.view = form;
+    },
+    hide: function(){
+        var dsp = this.node.getStyle("display");
+        if (dsp!=="none") this.node.store("mwf_display", dsp);
+        this.node.setStyle("display", "none");
+    },
+    show: function(){
+        var dsp = this.node.retrieve("mwf_display", dsp);
+        this.node.setStyle("display", dsp);
+    },
+    load: function(){
+
+        this._loadModuleEvents();
+        if (this.fireEvent("queryLoad")){
+            //this._queryLoaded();
+            this._loadUserInterface();
+            this._loadStyles();
+            this._loadDomEvents();
+            //this._loadEvents();
+
+            //this._afterLoaded();
+            this.fireEvent("postLoad");
+            this.fireEvent("load");
+        }
+    },
+
+    _loadStyles: function(){
+        if (this.json.styles) Object.each(this.json.styles, function(value, key){
+            if ((value.indexOf("x_processplatform_assemble_surface")!=-1 || value.indexOf("x_portal_assemble_surface")!=-1 || value.indexOf("x_cms_assemble_control")!=-1)){
+                var host1 = MWF.Actions.getHost("x_processplatform_assemble_surface");
+                var host2 = MWF.Actions.getHost("x_portal_assemble_surface");
+                var host3 = MWF.Actions.getHost("x_cms_assemble_control");
+                if (value.indexOf("/x_processplatform_assemble_surface")!==-1){
+                    value = value.replace("/x_processplatform_assemble_surface", host1+"/x_processplatform_assemble_surface");
+                }else if (value.indexOf("x_processplatform_assemble_surface")!==-1){
+                    value = value.replace("x_processplatform_assemble_surface", host1+"/x_processplatform_assemble_surface");
+                }
+                if (value.indexOf("/x_portal_assemble_surface")!==-1){
+                    value = value.replace("/x_portal_assemble_surface", host2+"/x_portal_assemble_surface");
+                }else if (value.indexOf("x_portal_assemble_surface")!==-1){
+                    value = value.replace("x_portal_assemble_surface", host2+"/x_portal_assemble_surface");
+                }
+                if (value.indexOf("/x_cms_assemble_control")!==-1){
+                    value = value.replace("/x_cms_assemble_control", host3+"/x_cms_assemble_control");
+                }else if (value.indexOf("x_cms_assemble_control")!==-1){
+                    value = value.replace("x_cms_assemble_control", host3+"/x_cms_assemble_control");
+                }
+            }
+            this.node.setStyle(key, value);
+        }.bind(this));
+
+        // if (["x_processplatform_assemble_surface", "x_portal_assemble_surface"].indexOf(root.toLowerCase())!==-1){
+        //     var host = MWF.Actions.getHost(root);
+        //     return (flag==="/") ? host+this.json.template : host+"/"+this.json.template
+        // }
+        //if (this.json.styles) this.node.setStyles(this.json.styles);
+    },
+    _loadModuleEvents : function(){
+        Object.each(this.json.events, function(e, key){
+            if (e.code){
+                if (this.options.moduleEvents.indexOf(key)!==-1){
+                    this.addEvent(key, function(event){
+                        return this.form.Macro.fire(e.code, this, event);
+                    }.bind(this));
+                }
+            }
+        }.bind(this));
+    },
+    _loadDomEvents: function(){
+        Object.each(this.json.events, function(e, key){
+            if (e.code){
+                if (this.options.moduleEvents.indexOf(key)===-1){
+                    this.node.addEvent(key, function(event){
+                        return this.form.Macro.fire(e.code, this, event);
+                    }.bind(this));
+                }
+            }
+        }.bind(this));
+    },
+    _loadEvents: function(){
+        Object.each(this.json.events, function(e, key){
+            if (e.code){
+                if (this.options.moduleEvents.indexOf(key)!==-1){
+                    this.addEvent(key, function(event){
+                        return this.form.Macro.fire(e.code, this, event);
+                    }.bind(this));
+                }else{
+                    this.node.addEvent(key, function(event){
+                        return this.form.Macro.fire(e.code, this, event);
+                    }.bind(this));
+                }
+            }
+        }.bind(this));
+    },
+    addModuleEvent: function(key, fun){
+        if (this.options.moduleEvents.indexOf(key)!==-1){
+            this.addEvent(key, function(event){
+                return (fun) ? fun(this, event) : null;
+            }.bind(this));
+        }else{
+            this.node.addEvent(key, function(event){
+                return (fun) ? fun(this, event) : null;
+            }.bind(this));
+        }
+    },
+    _loadUserInterface: function(){
+        // if (this.form.json.mode == "Mobile"){
+        //     this.node.empty();
+        // }else if (COMMON.Browser.Platform.isMobile){
+        //     this.node.empty();
+        // }else{
+        this.toolbarNode = this.node.getFirst("div");
+        if( !this.toolbarNode ){
+            this.toolbarNode = new Element("div").inject( this.node );
+        }
+        this.toolbarNode.empty();
+
+        MWF.require("MWF.widget.Toolbar", function(){
+            this.toolbarWidget = new MWF.widget.Toolbar(this.toolbarNode, {
+                "style": this.json.style,
+                "onPostLoad" : function(){
+                    this.fireEvent("afterLoad");
+                }.bind(this)
+            }, this);
+            if (this.json.actionStyles) this.toolbarWidget.css = this.json.actionStyles;
+            //alert(this.readonly)
+
+            if (this.json.hideSystemTools){
+                this.setCustomToolbars(this.json.tools, this.toolbarNode);
+                this.toolbarWidget.load();
+            }else{
+                if (this.json.defaultTools){
+                    this.setToolbars(this.json.defaultTools, this.toolbarNode, this.readonly);
+                    this.setCustomToolbars(this.json.tools, this.toolbarNode);
+                    this.toolbarWidget.load();
+                }else{
+                    MWF.getJSON(this.form.path+"toolbars.json", function(json){
+                        this.setToolbars(json, this.toolbarNode, this.readonly, true);
+                        this.setCustomToolbars(this.json.tools, this.toolbarNode);
+                        this.toolbarWidget.load();
+                    }.bind(this), null);
+                }
+            }
+
+        }.bind(this));
+        // }
+    },
+
+    setCustomToolbars: function(tools, node){
+        var path = "/x_component_process_FormDesigner/Module/Actionbar/";
+        var iconPath = "";
+        if( this.json.customIconStyle ){
+            iconPath = this.json.customIconStyle+"/";
+        }
+        tools.each(function(tool){
+            var flag = true;
+            if (this.readonly){
+                flag = tool.readShow;
+            }else{
+                flag = tool.editShow;
+            }
+            if (flag){
+                flag = true;
+                if (tool.control){
+                    flag = this.form.businessData.control[tool.control]
+                }
+                if (tool.condition){
+                    var hideFlag = this.form.Macro.exec(tool.condition, this);
+                    flag = !hideFlag;
+                }
+                if (flag){
+                    var actionNode = new Element("div", {
+                        "id": tool.id,
+                        "MWFnodetype": tool.type,
+                        "MWFButtonImage": path+""+this.form.options.style+"/custom/"+iconPath+tool.img,
+                        "title": tool.title,
+                        "MWFButtonAction": "runCustomAction",
+                        "MWFButtonText": tool.text
+                    }).inject(node);
+                    if( this.json.customIconOverStyle ){
+                        actionNode.set("MWFButtonImageOver" , path+""+this.form.options.style +"/custom/"+this.json.customIconOverStyle+ "/" +tool.img );
+                    }
+                    if( tool.properties ){
+                        actionNode.set(tool.properties);
+                    }
+                    if (tool.actionScript){
+                        actionNode.store("script", tool.actionScript);
+                    }
+                    if (tool.sub){
+                        var subNode = node.getLast();
+                        this.setCustomToolbars(tool.sub, subNode);
+                    }
+                }
+            }
+        }.bind(this));
+    },
+
+    setToolbarItem: function(tool, node, readonly, noCondition){
+        //var path = "/x_component_process_FormDesigner/Module/Actionbar/";
+        var path = "/x_component_query_ViewDesigner/$View/";
+        var flag = true;
+        if (tool.control){
+            flag = this.form.businessData.control[tool.control]
+        }
+        if (!noCondition) if (tool.condition){
+            var hideFlag = this.form.Macro.exec(tool.condition, this);
+            flag = flag && (!hideFlag);
+        }
+        if (readonly) if (!tool.read) flag = false;
+        if (flag){
+            var actionNode = new Element("div", {
+                "id": tool.id,
+                "MWFnodetype": tool.type,
+                //"MWFButtonImage": this.form.path+""+this.form.options.style+"/actionbar/"+tool.img,
+                //"MWFButtonImage": path+(this.options.style||"default") +"/tools/"+ (this.json.style || "default") +"/"+tool.img,
+                "MWFButtonImage": path+this.options.style+"/actionbar/"+tool.img,
+                "title": tool.title,
+                "MWFButtonAction": tool.action,
+                "MWFButtonText": tool.text
+            }).inject(node);
+            if( this.json.iconOverStyle ){
+                actionNode.set("MWFButtonImageOver" , path+""+this.options.style+"/actionbar/"+this.json.iconOverStyle+"/"+tool.img );
+                //actionNode.set("MWFButtonImageOver" , path+""+(this.options.style||"default")+"/tools/"+( this.json.iconOverStyle || "default" )+"/"+tool.img );
+            }
+            if( tool.properties ){
+                actionNode.set(tool.properties);
+            }
+            if (tool.sub){
+                var subNode = node.getLast();
+                this.setToolbars(tool.sub, subNode, readonly, noCondition);
+            }
+        }
+    },
+    setToolbars: function(tools, node, readonly, noCondition){
+        tools.each(function(tool){
+            this.setToolbarItem(tool, node, readonly, noCondition);
+        }.bind(this));
+    },
+    runCustomAction: function(bt){
+        var script = bt.node.retrieve("script");
+        this.form.Macro.exec(script, this);
+    },
+    exportView : function(){
+        this.form.exportView();
+    },
+    deleteWork: function(){
+        this.form.deleteWork();
+    }
+});

+ 32 - 1
o2web/source/x_component_query_ViewDesigner/$View/default/css.wcss

@@ -1,8 +1,11 @@
 {
+    "actionbarNode" : {
+        "overflow": "hidden"
+    },
     "viewAreaNode": {
         "overflow": "hidden"
     },
-	"viewTitleNode": {
+    "viewTitleNode": {
         "height": "40px",
         "background-color": "#EEE",
         "border-bottom": "1px solid #999",
@@ -316,5 +319,33 @@
         "position": "relative",
         "margin-right": "8px",
         "top": "-38px"
+    },
+
+    "toolbarWarpNode": {
+        "border": "1px dashed #999",
+        "height": "auto",
+        "overflow": "hidden",
+        "margin": "auto",
+        "display": "block",
+        "-webkit-user-select": "none",
+        "-moz-user-select": "none",
+        "position": "static",
+        "opacity": 1,
+        "width": "auto",
+        "margin": "3px 3px",
+        "background-color": "#999",
+        "cursor": "pointer"
+    },
+    "toolbarWarpNode_selected": {
+        "background-color": "#FFF",
+        //        "height": "38px",
+        "border": "1px solid red",
+        "white-space": "nowrap"
+    },
+    "toolbarWarpNode_over": {
+        "background-color": "#F9F9F9",
+        //        "height": "38px",
+        "border": "1px dotted blue",
+        "white-space": "nowrap"
     }
 }

+ 24 - 0
o2web/source/x_component_query_ViewDesigner/$View/view.html

@@ -46,6 +46,27 @@
                 <td class="editTableTitle">每页行数:</td>
                 <td class="editTableValue"><input type="number" name="pageSize" value="text{$.pageSize || 20}" class="editTableInput"/></td>
             </tr>
+            <tr>
+                <td class="editTableTitle">视图样式:</td>
+                <td class="editTableValue">
+                    <select class="MWFViewStyle" name="viewStyleType"></select>
+                </td>
+            </tr>
+            <tr>
+                <td class="editTableTitle">隐藏操作条:</td>
+                <td class="editTableValue">
+                    <input class="editTableRadio" name="data.actionbarHidden" text{($.data.actionbarHidden!==false)?'checked':''} type="radio" value="true"/>是
+                    <input class="editTableRadio" name="data.actionbarHidden" text{($.data.actionbarHidden===false)?'checked':''} type="radio" value="false"/>否
+                </td>
+            </tr>
+            <tr>
+                <td class="editTableTitle">选择:</td>
+                <td class="editTableValue">
+                    <input class="editTableRadio" name="data.select" text{($.data.select!=='single' || $.data.select!=='multi' )?'checked':''} type="radio" value="none"/>无
+                    <input class="editTableRadio" name="data.select" text{($.data.select==='single')?'checked':''} type="radio" value="single"/>单选
+                    <input class="editTableRadio" name="data.select" text{($.data.select==='multi')?'checked':''} type="radio" value="multi"/>多选
+                </td>
+            </tr>
             <!--<tr>-->
             <!--<td class="editTableTitle">最大行数:</td>-->
             <!--<td class="editTableValue"><input type="text" name="max" value="text{$.max}" class="editTableInput"/></td>-->
@@ -561,6 +582,9 @@
         </div>
     </div>
 
+    <div title="事件"  class="MWFTab">
+        <div class="MWFEventsArea" name="data.events"></div>
+    </div>
 
     <div title="JSON"  class="MWFTab">
         <div class="MWFJSONArea" style="font-family: Verdana, Geneva, sans-serif; font-size:14px"></div>

+ 31 - 1
o2web/source/x_component_query_ViewDesigner/$View/view.json

@@ -39,7 +39,37 @@
     "calculate": {},
     "afterGridScriptText": "",
     "afterGroupGridScriptText": "",
-    "afterCalculateGridScriptText": ""
+    "afterCalculateGridScriptText": "",
+    "events": {
+      "queryLoad" : {
+        "code": "",
+        "html": ""
+      },
+      "postLoadData" : {
+        "code": "",
+        "html": ""
+      },
+      "postLoad": {
+        "code": "",
+        "html": ""
+      },
+      "queryLoadRow": {
+        "code": "",
+        "html": ""
+      },
+      "postLoadRow": {
+        "code": "",
+        "html": ""
+      },
+      "selectRow" : {
+        "code": "",
+        "html": ""
+      },
+      "unselectRow" : {
+        "code": "",
+        "html": ""
+      }
+    }
   },
   "availableIdentityList": [],
   "availableUnitList": []

+ 279 - 152
o2web/source/x_component_query_ViewDesigner/Property.js

@@ -1,38 +1,38 @@
 MWF.require("MWF.widget.Common", null, false);
 MWF.require("MWF.widget.JsonTemplate", null, false);
 MWF.xApplication.query.ViewDesigner.Property = MWF.FVProperty = new Class({
-	Extends: MWF.widget.Common,
-	Implements: [Options, Events],
-	options: {
-		"style": "default",
-		"path": "/x_component_query_FormDesigner/property/property.html"
-	},
-	
-	initialize: function(module, propertyNode, designer, options){
-		this.setOptions(options);
-		this.module = module;
-		this.view = module.view;
-		this.data = module.json;
+    Extends: MWF.widget.Common,
+    Implements: [Options, Events],
+    options: {
+        "style": "default",
+        "path": "/x_component_query_FormDesigner/property/property.html"
+    },
+
+    initialize: function(module, propertyNode, designer, options){
+        this.setOptions(options);
+        this.module = module;
+        this.view = module.view;
+        this.data = module.json;
         this.data.vid = this.view.json.id;
         this.data.vtype = this.view.json.type;
-		this.data.pid = this.view.json.id+this.data.id;
-		this.htmlPath = this.options.path;
-		this.designer = designer;
-		
-		this.propertyNode = propertyNode;
-	},
-
-	load: function(){
-		if (this.fireEvent("queryLoad")){
-			MWF.getRequestText(this.htmlPath, function(responseText, responseXML){
-				this.htmlString = responseText;
+        this.data.pid = this.view.json.id+this.data.id;
+        this.htmlPath = this.options.path;
+        this.designer = designer;
+
+        this.propertyNode = propertyNode;
+    },
+
+    load: function(){
+        if (this.fireEvent("queryLoad")){
+            MWF.getRequestText(this.htmlPath, function(responseText, responseXML){
+                this.htmlString = responseText;
                 this.fireEvent("postLoad");
-			}.bind(this));
-		}
+            }.bind(this));
+        }
         this.propertyNode.addEvent("keydown", function(e){e.stopPropagation();});
-	},
-	editProperty: function(td){
-	},
+    },
+    editProperty: function(td){
+    },
     getHtmlString: function(callback){
         if (!this.htmlString){
             MWF.getRequestText(this.htmlPath, function(responseText, responseXML){
@@ -43,7 +43,7 @@ MWF.xApplication.query.ViewDesigner.Property = MWF.FVProperty = new Class({
             if (callback) callback();
         }
     },
-	show: function(){
+    show: function(){
         if (!this.propertyContent){
             this.getHtmlString(function(){
                 if (this.htmlString){
@@ -62,23 +62,27 @@ MWF.xApplication.query.ViewDesigner.Property = MWF.FVProperty = new Class({
                     this.loadColumnExportEditor();
 
                     this.loadJSONArea();
+
+                    this.loadEventsEditor();
+                    this.loadActionStylesArea();
+                    this.loadActionArea();
                 }
             }.bind(this));
         }else{
             this.propertyContent.setStyle("display", "block");
         }
 
-		
 
-	},
-	hide: function(){
-		//this.JsonTemplate = null;
-		//this.propertyNode.set("html", "");
+
+    },
+    hide: function(){
+        //this.JsonTemplate = null;
+        //this.propertyNode.set("html", "");
         if (this.propertyContent) this.propertyContent.setStyle("display", "none");
-	},
+    },
 
-	loadJSONArea: function(){
-		var jsonNode = this.propertyContent.getElement(".MWFJSONArea");
+    loadJSONArea: function(){
+        var jsonNode = this.propertyContent.getElement(".MWFJSONArea");
 
         if (jsonNode){
             this.propertyTab.pages.each(function(page){
@@ -95,39 +99,39 @@ MWF.xApplication.query.ViewDesigner.Property = MWF.FVProperty = new Class({
                 }
             }.bind(this));
         }
-	},
-	loadPropertyTab: function(){
-		var tabNodes = this.propertyContent.getElements(".MWFTab");
-		if (tabNodes.length){
-			var tmpNode = this.propertyContent.getFirst();
-			var tabAreaNode = new Element("div", {
-				"styles": this.view.css.propertyTabNode
-			}).inject(tmpNode, "before");
-			
-			MWF.require("MWF.widget.Tab", function(){
-				var tab = new MWF.widget.Tab(tabAreaNode, {"style": "formPropertyList"});
-				tab.load();
-				var tabPages = [];
-				tabNodes.each(function(node){
-					var page = tab.addTab(node, node.get("title"), false);
-					tabPages.push(page);
-					this.setScrollBar(page.contentNodeArea, "small", null, null);
-				}.bind(this));
-				tabPages[0].showTab();
-				
-				this.propertyTab = tab;
-				
-				this.designer.resizeNode();
-			}.bind(this), false);
-		}
-	},
-	
-	setEditNodeEvent: function(){
-		var property = this;
-	//	var inputs = this.process.propertyListNode.getElements(".editTableInput");
-		var inputs = this.propertyContent.getElements("input");
-		inputs.each(function(input){
-			var jsondata = input.get("name");
+    },
+    loadPropertyTab: function(){
+        var tabNodes = this.propertyContent.getElements(".MWFTab");
+        if (tabNodes.length){
+            var tmpNode = this.propertyContent.getFirst();
+            var tabAreaNode = new Element("div", {
+                "styles": this.view.css.propertyTabNode
+            }).inject(tmpNode, "before");
+
+            MWF.require("MWF.widget.Tab", function(){
+                var tab = new MWF.widget.Tab(tabAreaNode, {"style": "formPropertyList"});
+                tab.load();
+                var tabPages = [];
+                tabNodes.each(function(node){
+                    var page = tab.addTab(node, node.get("title"), false);
+                    tabPages.push(page);
+                    this.setScrollBar(page.contentNodeArea, "small", null, null);
+                }.bind(this));
+                tabPages[0].showTab();
+
+                this.propertyTab = tab;
+
+                this.designer.resizeNode();
+            }.bind(this), false);
+        }
+    },
+
+    setEditNodeEvent: function(){
+        var property = this;
+        //	var inputs = this.process.propertyListNode.getElements(".editTableInput");
+        var inputs = this.propertyContent.getElements("input");
+        inputs.each(function(input){
+            var jsondata = input.get("name");
             if (jsondata && jsondata.substr(0,1)!="_"){
                 if (this.module){
                     var id = this.module.json.id;
@@ -180,36 +184,36 @@ MWF.xApplication.query.ViewDesigner.Property = MWF.FVProperty = new Class({
                     }
                 }
             }
-		}.bind(this));
-		
-		var selects = this.propertyContent.getElements("select");
-		selects.each(function(select){
-			var jsondata = select.get("name");
-			if (jsondata){
-				select.addEvent("change", function(e){
-					property.setSelectValue(jsondata, this);
-				});
+        }.bind(this));
+
+        var selects = this.propertyContent.getElements("select");
+        selects.each(function(select){
+            var jsondata = select.get("name");
+            if (jsondata){
+                select.addEvent("change", function(e){
+                    property.setSelectValue(jsondata, this);
+                });
                 //property.setSelectValue(jsondata, select);
-			}
-		});
-		
-		var textareas = this.propertyContent.getElements("textarea");
-		textareas.each(function(input){
-			var jsondata = input.get("name");
-			if (jsondata){
-				input.addEvent("change", function(e){
-					property.setValue(jsondata, this.value);
-				});
-				input.addEvent("blur", function(e){
-					property.setValue(jsondata, this.value);
-				});
+            }
+        });
+
+        var textareas = this.propertyContent.getElements("textarea");
+        textareas.each(function(input){
+            var jsondata = input.get("name");
+            if (jsondata){
+                input.addEvent("change", function(e){
+                    property.setValue(jsondata, this.value);
+                });
+                input.addEvent("blur", function(e){
+                    property.setValue(jsondata, this.value);
+                });
                 input.addEvent("keydown", function(e){
                     e.stopPropagation();
                 });
-			}
-		}.bind(this));
-		
-	},
+            }
+        }.bind(this));
+
+    },
     loadCalendar: function(node, jsondata){
         MWF.require("MWF.widget.Calendar", function(){
             this.calendar = new MWF.widget.Calendar(node, {
@@ -245,14 +249,14 @@ MWF.xApplication.query.ViewDesigner.Property = MWF.FVProperty = new Class({
         }.bind(this));
         o[key[len]] = value;
     },
-	setRadioValue: function(name, input){
-		if (input.checked){
+    setRadioValue: function(name, input){
+        if (input.checked){
             var i = name.indexOf("*");
             var names = (i==-1) ? name.split(".") : name.substr(i+1, name.length).split(".");
 
             var value = input.value;
-			if (value=="false") value = false;
-			if (value=="true") value = true;
+            if (value=="false") value = false;
+            if (value=="true") value = true;
 
             var oldValue = this.data;
             for (var idx = 0; idx<names.length; idx++){
@@ -264,32 +268,32 @@ MWF.xApplication.query.ViewDesigner.Property = MWF.FVProperty = new Class({
                 }
             }
 
-			//var oldValue = this.data[name];
-			this.changeJsonDate(names, value);
+            //var oldValue = this.data[name];
+            this.changeJsonDate(names, value);
             this.changeData(name, input, oldValue);
-		}
-	},
-	setCheckboxValue: function(name, input){
+        }
+    },
+    setCheckboxValue: function(name, input){
         var id = this.module.json.id;
         var checkboxList = $$("input[name='"+id+name+"']");
-		var values = [];
-		checkboxList.each(function(checkbox){
-			if (checkbox.get("checked")){
-				values.push(checkbox.value);
-			}
-		});
-		var oldValue = this.data[name];
-		//this.data[name] = values;
+        var values = [];
+        checkboxList.each(function(checkbox){
+            if (checkbox.get("checked")){
+                values.push(checkbox.value);
+            }
+        });
+        var oldValue = this.data[name];
+        //this.data[name] = values;
         this.changeJsonDate(name, values);
         this.changeData(name, input, oldValue);
-	},
-	setSelectValue: function(name, select){
-		var idx = select.selectedIndex;
-		var options = select.getElements("option");
-		var value = "";
-		if (options[idx]){
-			value = options[idx].get("value");
-		}
+    },
+    setSelectValue: function(name, select){
+        var idx = select.selectedIndex;
+        var options = select.getElements("option");
+        var value = "";
+        if (options[idx]){
+            value = options[idx].get("value");
+        }
 
         var i = name.indexOf("*");
         var names = (i==-1) ? name.split(".") : name.substr(i+1, name.length).split(".");
@@ -305,13 +309,13 @@ MWF.xApplication.query.ViewDesigner.Property = MWF.FVProperty = new Class({
             }
         }
 
-		//var oldValue = this.data[name];
-		//this.data[name] = value;
+        //var oldValue = this.data[name];
+        //this.data[name] = value;
         this.changeJsonDate(names, value);
         this.changeData(name, select, oldValue);
-	},
-	
-	setValue: function(name, value, obj){
+    },
+
+    setValue: function(name, value, obj){
         var names = name.split(".");
         var oldValue = this.data;
         for (var idx = 0; idx<names.length; idx++){
@@ -323,23 +327,23 @@ MWF.xApplication.query.ViewDesigner.Property = MWF.FVProperty = new Class({
             }
         }
 
-		//var oldValue = this.data[name];
-		//this.data[name] = value;
+        //var oldValue = this.data[name];
+        //this.data[name] = value;
         this.changeJsonDate(names, value);
         this.changeData(name, obj, oldValue);
-	},
-	setEditNodeStyles: function(node){
-		var nodes = node.getChildren();
-		if (nodes.length){
-			nodes.each(function(el){
-				var cName = el.get("class");
-				if (cName){
-					if (this.view.css[cName]) el.setStyles(this.view.css[cName]);
-				}
-				this.setEditNodeStyles(el);
-			}.bind(this));
-		}
-	},
+    },
+    setEditNodeStyles: function(node){
+        var nodes = node.getChildren();
+        if (nodes.length){
+            nodes.each(function(el){
+                var cName = el.get("class");
+                if (cName){
+                    if (this.view.css[cName]) el.setStyles(this.view.css[cName]);
+                }
+                this.setEditNodeStyles(el);
+            }.bind(this));
+        }
+    },
     loadScriptArea: function(){
         var scriptAreas = this.propertyContent.getElements(".MWFScriptArea");
         var formulaAreas = this.propertyContent.getElements(".MWFFormulaArea");
@@ -703,6 +707,129 @@ MWF.xApplication.query.ViewDesigner.Property = MWF.FVProperty = new Class({
         this.data.filterList.push(op);
         var filter = new MWF.xApplication.query.ViewDesigner.Property.Filter(op, table, this);
         filter.editMode();
+    },
+    loadActionStylesArea: function(){
+        var _self = this;
+        var actionAreas = this.propertyContent.getElements(".MWFActionStylesArea");
+        actionAreas.each(function(node){
+            var name = node.get("name");
+            var actionStyles = this.data[name];
+            MWF.require("MWF.widget.Maplist", function(){
+                var maps = [];
+                Object.each(actionStyles, function(v, k){
+                    var mapNode = new Element("div").inject(node);
+                    mapNode.empty();
+
+                    var maplist = new MWF.widget.Maplist(mapNode, {
+                        "title": k,
+                        "collapse": true,
+                        "onChange": function(){
+                            var oldData = _self.data[name];
+                            maps.each(function(o){
+                                _self.data[name][o.key] = o.map.toJson();
+                            }.bind(this));
+                            _self.changeData(name, node, oldData);
+                        }
+                    });
+                    maps.push({"key": k, "map": maplist});
+                    maplist.load(v);
+                }.bind(this));
+            }.bind(this));
+
+
+        }.bind(this));
+    },
+    loadEventsEditor: function(){
+        MWF.xApplication.process = MWF.xApplication.process || {};
+        MWF.APPFD = MWF.xApplication.process.FormDesigner = MWF.xApplication.process.FormDesigner || {};
+        MWF.xDesktop.requireApp("process.FormDesigner", "lp."+o2.language, null, false);
+
+        var events = this.propertyContent.getElement(".MWFEventsArea");
+        if (events){
+            var name = events.get("name");
+            var eventsObj = this.data;
+            Array.each( name.split("."), function(n){
+                if(eventsObj)eventsObj = eventsObj[n];
+            })
+            MWF.xDesktop.requireApp("process.FormDesigner", "widget.EventsEditor", function(){
+                var eventsEditor = new MWF.xApplication.process.FormDesigner.widget.EventsEditor(events, this.designer, {
+                    //"maxObj": this.propertyNode.parentElement.parentElement.parentElement,
+                    "maxObj": this.designer.contentNode
+                });
+                eventsEditor.load(eventsObj, this.data, name);
+            }.bind(this));
+        }
+    },
+    loadActionArea: function(){
+        MWF.xApplication.process = MWF.xApplication.process || {};
+        MWF.APPFD = MWF.xApplication.process.FormDesigner = MWF.xApplication.process.FormDesigner || {};
+        MWF.xDesktop.requireApp("process.FormDesigner", "lp."+o2.language, null, false);
+
+        var actionAreas = this.propertyContent.getElements(".MWFActionArea");
+        actionAreas.each(function(node){
+            var name = node.get("name");
+            var actionContent = this.data[name];
+            MWF.xDesktop.requireApp("process.FormDesigner", "widget.ActionsEditor", function(){
+
+                // debugger;
+                // var actionEditor = new MWF.xApplication.process.FormDesigner.widget.ActionsEditor(node, this.designer, {
+                //     "maxObj": this.propertyNode.parentElement.parentElement.parentElement,
+                //     "noCreate": true,
+                //     "noDelete": true,
+                //     "noCode": true,
+                //     "onChange": function(){
+                //         this.data[name] = actionEditor.data;
+                //     }.bind(this)
+                // });
+                // actionEditor.load(this.module.defaultToolBarsData);
+
+                var actionEditor = new MWF.xApplication.process.FormDesigner.widget.ActionsEditor(node, this.designer, this.data, {
+                    "maxObj": this.propertyNode.parentElement.parentElement.parentElement,
+                    "noEditShow" : true,
+                    "noReadShow" : true,
+                    "onChange": function(){
+                        this.data[name] = actionEditor.data;
+                        this.changeData(name);
+                    }.bind(this)
+                });
+                actionEditor.load(actionContent);
+            }.bind(this));
+
+        }.bind(this));
+
+        var actionAreas = this.propertyContent.getElements(".MWFDefaultActionArea");
+        actionAreas.each(function(node){
+            var name = node.get("name");
+            var actionContent = this.data[name] || this.module.defaultToolBarsData;
+            MWF.xDesktop.requireApp("process.FormDesigner", "widget.ActionsEditor", function(){
+
+                var actionEditor = new MWF.xApplication.process.FormDesigner.widget.ActionsEditor(node, this.designer, this.data, {
+                    "maxObj": this.propertyNode.parentElement.parentElement.parentElement,
+                    "isSystemTool" : true,
+                    "systemToolsAddress" : "/x_component_query_ViewDesigner/$View/toolbars.json",
+                    "noCreate": true,
+                    "noDelete": false,
+                    "noCode": true,
+                    "noReadShow": true,
+                    "noEditShow": true,
+                    "onChange": function(){
+                        this.data[name] = actionEditor.data;
+                        this.changeData(name);
+                    }.bind(this)
+                });
+                actionEditor.load(actionContent);
+
+                // var actionEditor = new MWF.xApplication.process.FormDesigner.widget.ActionsEditor(node, this.designer, {
+                //     "maxObj": this.propertyNode.parentElement.parentElement.parentElement,
+                //     "onChange": function(){
+                //         this.data[name] = actionEditor.data;
+                //     }.bind(this)
+                // });
+                // actionEditor.load(actionContent);
+            }.bind(this));
+
+        }.bind(this));
+
     }
     //initWhereEntryData: function(){
     //    if (!this.data.data.restrictWhereEntry) this.data.data.restrictWhereEntry = {
@@ -1011,26 +1138,26 @@ MWF.xApplication.query.ViewDesigner.Property.Filter = new Class({
         switch (this.property.data.type){
             case "text":
                 html += "<option value=''></option><option value='==' "+((this.data.comparison=="==") ? "selected": "")+">等于(==)</option>" +
-                "<option value='!=' "+((this.data.comparison=="!=") ? "selected": "")+">不等于(!=)</option>" +
-                "<option value='@' "+((this.data.comparison=="@") ? "selected": "")+">包含(@)</option>";
+                    "<option value='!=' "+((this.data.comparison=="!=") ? "selected": "")+">不等于(!=)</option>" +
+                    "<option value='@' "+((this.data.comparison=="@") ? "selected": "")+">包含(@)</option>";
                 break;
             case "date":
                 html += "<option value=''></option><option value='&gt;' "+((this.data.comparison==">") ? "selected": "")+">大于(&gt;)</option>" +
-                "<option value='&lt;' "+((this.data.comparison=="<") ? "selected": "")+">小于(&lt;)</option>" +
-                "<option value='&gt;=' "+((this.data.comparison==">=") ? "selected": "")+">大于等于(&gt;=)</option>" +
-                "<option value='&lt;=' "+((this.data.comparison=="<=") ? "selected": "")+">小于等于(&lt;=)</option>";
+                    "<option value='&lt;' "+((this.data.comparison=="<") ? "selected": "")+">小于(&lt;)</option>" +
+                    "<option value='&gt;=' "+((this.data.comparison==">=") ? "selected": "")+">大于等于(&gt;=)</option>" +
+                    "<option value='&lt;=' "+((this.data.comparison=="<=") ? "selected": "")+">小于等于(&lt;=)</option>";
                 break;
             case "number":
                 html += "<option value=''></option><option value='==' "+((this.data.comparison=="==") ? "selected": "")+">等于(==)</option>" +
-                "<option value='!=' "+((this.data.comparison=="!=") ? "selected": "")+">不等于(!=)</option>" +
-                "<option value='&gt;' "+((this.data.comparison==">") ? "selected": "")+">大于(&gt;)</option>" +
-                "<option value='&lt;' "+((this.data.comparison=="<") ? "selected": "")+">小于(&lt;)</option>" +
-                "<option value='&gt;=' "+((this.data.comparison==">=") ? "selected": "")+">大于等于(&gt;=)</option>" +
-                "<option value='&lt;=' "+((this.data.comparison=="<=") ? "selected": "")+">小于等于(&lt;=)</option>";
+                    "<option value='!=' "+((this.data.comparison=="!=") ? "selected": "")+">不等于(!=)</option>" +
+                    "<option value='&gt;' "+((this.data.comparison==">") ? "selected": "")+">大于(&gt;)</option>" +
+                    "<option value='&lt;' "+((this.data.comparison=="<") ? "selected": "")+">小于(&lt;)</option>" +
+                    "<option value='&gt;=' "+((this.data.comparison==">=") ? "selected": "")+">大于等于(&gt;=)</option>" +
+                    "<option value='&lt;=' "+((this.data.comparison=="<=") ? "selected": "")+">小于等于(&lt;=)</option>";
                 break;
             case "boolean":
                 html += "<option value=''></option><option value='==' "+((this.data.comparison=="==") ? "selected": "")+">等于(==)</option>" +
-                "<option value='!=' "+((this.data.comparison=="!=") ? "selected": "")+">不等于(!=)</option>";
+                    "<option value='!=' "+((this.data.comparison=="!=") ? "selected": "")+">不等于(!=)</option>";
                 break;
         }
         comparisonSelect.set("html", html);

+ 713 - 11
o2web/source/x_component_query_ViewDesigner/View.js

@@ -69,6 +69,20 @@ MWF.xApplication.query.ViewDesigner.View = new Class({
     },
     parseData: function(){
         this.json = this.data;
+        if( !this.json.data.events ){
+            var url = "/x_component_query_ViewDesigner/$View/view.json";
+            MWF.getJSON(url, {
+                "onSuccess": function(obj){
+                    this.json.data.events = obj.data.events;
+                }.bind(this),
+                "onerror": function(text){
+                    this.notice(text, "error");
+                }.bind(this),
+                "onRequestFailure": function(xhr){
+                    this.notice(xhr.responseText, "error");
+                }.bind(this)
+            },false);
+        }
     },
 
     showProperty: function(){
@@ -107,6 +121,8 @@ MWF.xApplication.query.ViewDesigner.View = new Class({
 
         this.domListNode = new Element("div", {"styles": {"overflow": "hidden"}}).inject(this.designer.propertyDomArea);
 
+        this.loadActionbar();
+
         this.loadView();
 
         this.selected();
@@ -140,6 +156,7 @@ MWF.xApplication.query.ViewDesigner.View = new Class({
 
                 this.designer.actions.loadView(this.data.id, null,function(json){
                     var entries = {};
+
                     json.data.selectList.each(function(entry){entries[entry.column] = entry;}.bind(this));
 
                     if (this.json.data.group.column){
@@ -154,7 +171,7 @@ MWF.xApplication.query.ViewDesigner.View = new Class({
 
                             json.data.groupGrid.each(function(line, idx){
                                 var groupTr = new Element("tr", {"styles": this.css.viewContentTrNode}).inject(this.viewContentTableNode);
-                                var colSpan = this.items.length;
+                                var colSpan = this.items.length + 1 ;
                                 var td = new Element("td", {"styles": this.css.viewContentGroupTdNode, "colSpan": colSpan}).inject(groupTr);
                                 var groupAreaNode = new Element("div", {"styles": this.css.viewContentTdGroupNode}).inject(td);
                                 var groupIconNode = new Element("div", {"styles": this.css.viewContentTdGroupIconNode}).inject(groupAreaNode);
@@ -172,6 +189,9 @@ MWF.xApplication.query.ViewDesigner.View = new Class({
                                 line.list.each(function(entry){
                                     var tr = new Element("tr", {"styles": this.css.viewContentTrNode}).inject(this.viewContentTableNode);
                                     tr.setStyle("display", "none");
+
+                                    //this.createViewCheckboxTd( tr );
+
                                     var td = new Element("td", {"styles": this.css.viewContentTdNode}).inject(tr);
 
                                     Object.each(entries, function(c, k){
@@ -228,6 +248,8 @@ MWF.xApplication.query.ViewDesigner.View = new Class({
                             json.data.grid.each(function(line, idx){
                                 var tr = new Element("tr", {"styles": this.css.viewContentTrNode}).inject(this.viewContentTableNode);
 
+                                //this.createViewCheckboxTd( tr );
+
                                 Object.each(entries, function(c, k){
                                     var d = line.data[k];
                                     if (d!=undefined){
@@ -401,7 +423,8 @@ MWF.xApplication.query.ViewDesigner.View = new Class({
     setContentHeight: function(){
         var size = this.areaNode.getSize();
         var titleSize = this.viewTitleNode.getSize();
-        var height = size.y-titleSize.y-2;
+        var actionbarSize = this.actionbarNode ? this.actionbarNode.getSize() : {x:0, y:0};
+        var height = size.y-titleSize.y-actionbarSize.y-2;
 
         this.viewContentScrollNode.setStyle("height", height);
 
@@ -415,20 +438,72 @@ MWF.xApplication.query.ViewDesigner.View = new Class({
     },
 
     loadViewColumns: function(){
-    //    for (var i=0; i<10; i++){
+        //    for (var i=0; i<10; i++){
         if (this.json.data.selectList) {
             this.json.data.selectList.each(function (json) {
                 this.items.push(new MWF.xApplication.query.ViewDesigner.View.Column(json, this));
 
             }.bind(this));
         }
-    //    }
+        //    }
+    },
+    loadViewSelectAllNode : function(){
+        var _self = this;
+        var td = new Element("td.viewTitleCheckboxTd",{ "styles": this.css.viewTitleColumnAreaNode }).inject( this.viewTitleTrNode );
+        td.setStyles({
+            "width":"30px", "text-align" : "center",
+            "display" : this.json.data.selectAllEnable ? "table-cell" : "none"
+        });
+        new Element("input",{
+            "type" : "checkbox",
+            "events" : {
+                "change" : function(){
+                    _self.viewContentTableNode.getElements(".viewContentCheckbox").set("checked", this.checked )
+                }
+            }
+        }).inject(td);
+    },
+    createViewCheckboxTd : function( tr ){
+        var td = new Element("td.viewContentCheckboxTd", {"styles": this.css.viewContentTdNode}).inject(tr, "top");
+        td.setStyles({
+            "width":"30px", "text-align" : "center",
+            "display" : this.json.data.selectAllEnable ? "table-cell" : "none"
+        });
+        new Element("input.viewContentCheckbox",{
+            "type" : "checkbox"
+        }).inject(td);
     },
     loadView: function(){
         this.loadViewNodes();
+        //this.loadViewSelectAllNode();
         this.loadViewColumns();
 //        this.addTopItemNode.addEvent("click", this.addTopItem.bind(this));
     },
+    loadActionbar: function(){
+        this.actionbarNode = new Element("div#actionbarNode", {"styles": this.css.actionbarNode}).inject(this.areaNode);
+        this.actionbarList = [];
+        if( !this.json.data.actionbarHidden ){
+            this.showActionbar( true );
+        }
+    },
+    hideActionbar : function(){
+        this.actionbarNode.hide();
+        this.setContentHeight();
+    },
+    showActionbar : function( noSetHeight ){
+        this.actionbarNode.show();
+        if( !this.json.data.actionbarList )this.json.data.actionbarList = [];
+        if( !this.actionbarList || this.actionbarList.length == 0 ){
+            if( this.json.data.actionbarList.length ){
+                this.json.data.actionbarList.each( function(json){
+                    this.actionbarList.push( new MWF.xApplication.query.ViewDesigner.View.Actionbar( json, this.json.data.actionbarList, this) )
+                }.bind(this));
+            }else{
+                this.actionbarList.push( new MWF.xApplication.query.ViewDesigner.View.Actionbar( null, this.json.data.actionbarList, this) )
+            }
+        }
+        if( !noSetHeight )this.setContentHeight();
+    },
     setViewWidth: function(){
         this.viewAreaNode.setStyle("width", "auto");
         this.viewTitleNode.setStyle("width", "auto");
@@ -494,10 +569,10 @@ MWF.xApplication.query.ViewDesigner.View = new Class({
     },
     save: function(callback){
         //if (this.designer.tab.showPage==this.page){
-            if (!this.data.name){
-                this.designer.notice(this.designer.lp.notice.inputName, "error");
-                return false;
-            }
+        if (!this.data.name){
+            this.designer.notice(this.designer.lp.notice.inputName, "error");
+            return false;
+        }
         //}
         this.designer.actions.saveView(this.data, function(json){
             this.designer.notice(this.designer.lp.notice.save_success, "success", this.node, {"x": "left", "y": "bottom"});
@@ -528,6 +603,22 @@ MWF.xApplication.query.ViewDesigner.View = new Class({
                 }
             }.bind(this));
         }
+        if( name=="data.actionbarHidden" ){
+            if( this.json.data.actionbarHidden ){
+                this.hideActionbar()
+            }else{
+                this.showActionbar()
+            }
+        }
+        if( name=="data.selectAllEnable" ){
+            if( this.json.data.selectAllEnable ){
+                this.viewTitleTrNode.getElement(".viewTitleCheckboxTd").setStyle("display","table-cell");
+                this.viewContentTableNode.getElements(".viewContentCheckboxTd").setStyle("display","table-cell");
+            }else{
+                this.viewTitleTrNode.getElement(".viewTitleCheckboxTd").setStyle("display","none");
+                this.viewContentTableNode.getElements(".viewContentCheckboxTd").setStyle("display","none");
+            }
+        }
     },
 
     saveAs: function(){
@@ -594,16 +685,16 @@ MWF.xApplication.query.ViewDesigner.View = new Class({
 
 
 MWF.xApplication.query.ViewDesigner.View.Column = new Class({
-	initialize: function(json, view, next){
+    initialize: function(json, view, next){
         this.propertyPath = "/x_component_query_ViewDesigner/$View/column.html";
-		this.view = view;
+        this.view = view;
         this.json = json;
         this.next = next;
         this.css = this.view.css;
         this.content = this.view.viewTitleTrNode;
         this.domListNode = this.view.domListNode;
         this.load();
-	},
+    },
     load: function(){
         this.areaNode = new Element("td", {"styles": this.css.viewTitleColumnAreaNode});
         this.areaNode.store("column", this);
@@ -966,4 +1057,615 @@ MWF.xApplication.query.ViewDesigner.View.Column = new Class({
 
 });
 
+MWF.require("MWF.widget.Toolbar", null, false);
+MWF.xApplication.query.ViewDesigner.View.Actionbar = new Class({
+    Implements: [Options, Events],
+    options : {
+        "style" : "default",
+        "customImageStyle" : "default"
+    },
+    initialize: function(json, jsonList, view, options){
+        this.setOptions( options );
+        this.propertyPath = "/x_component_query_ViewDesigner/$View/actionbar.html";
+        this.path = "/x_component_query_ViewDesigner/$View/";
+        this.imagePath_default = "/x_component_query_ViewDesigner/$View/";
+        this.imagePath_custom = "/x_component_process_FormDesigner/Module/Actionbar/";
+        this.cssPath = "/x_component_query_ViewDesigner/$View/"+this.options.style+"/actionbar.wcss";
+
+        this.view = view;
+        this.json = json;
+        this.jsonList = jsonList;
+        this.css = this.view.css;
+        this.container = this.view.actionbarNode;
+        this.load();
+    },
+    load: function(){
+        this.systemTools = [];
+        this.customTools = [];
+        if( !this.json ){
+            this.loadDefaultJson(function(){
+                this._load()
+            }.bind(this));
+        }else{
+            this._load()
+        }
+    },
+    _load : function(){
+        this._createNode();
+        //this._createIconAction();
+        //if (!this.json.export) this.hideMode();
+        this.setEvent();
+    },
+    loadDefaultJson: function(callback){
+        var url = this.path+"actionbar.json";
+        MWF.getJSON(url, {
+            "onSuccess": function(obj){
+                this.view.designer.actions.getUUID(function(id){
+                    obj.id=id;
+                    //obj.isNewView = true;
+                    //obj.application = this.view.designer.application.id;
+                    this.json = obj;
+                    this.jsonList.push( this.json );
+                    if (callback) callback(obj);
+                }.bind(this));
+            }.bind(this),
+            "onerror": function(text){
+                this.view.designer.notice(text, "error");
+            }.bind(this),
+            "onRequestFailure": function(xhr){
+                this.view.designer.notice(xhr.responseText, "error");
+            }.bind(this)
+        });
+    },
+    setEvent: function(){
+        this.node.addEvents({
+            "click": function(e){this.selected(); e.stopPropagation();}.bind(this),
+            "mouseover": function(){if (!this.isSelected) this.node.setStyles(this.css.toolbarWarpNode_over)}.bind(this),
+            "mouseout": function(){if (!this.isSelected) this.node.setStyles(this.css.toolbarWarpNode) }.bind(this)
+        });
+    },
+    //_createIconAction: function(){
+    //    if (!this.actionArea){
+    //        this.actionArea = new Element("div", {"styles": this.css.actionAreaNode}).inject(this.container, "after");
+    //
+    //        //this._createAction({
+    //        //    "name": "move",
+    //        //    "icon": "move1.png",
+    //        //    "event": "mousedown",
+    //        //    "action": "move",
+    //        //    "title": MWF.APPDVD.LP.action.move
+    //        //});
+    //        //this._createAction({
+    //        //    "name": "add",
+    //        //    "icon": "add.png",
+    //        //    "event": "click",
+    //        //    "action": "addColumn",
+    //        //    "title": MWF.APPDVD.LP.action.add
+    //        //});
+    //        this._createAction({
+    //            "name": "delete",
+    //            "icon": "delete1.png",
+    //            "event": "click",
+    //            "action": "delete",
+    //            "title": MWF.APPDVD.LP.action["delete"]
+    //        });
+    //    }
+    //},
+    //_createAction: function(action){
+    //    var actionNode = new Element("div", {
+    //        "styles": this.css.actionNodeStyles,
+    //        "title": action.title
+    //    }).inject(this.actionArea);
+    //    actionNode.setStyle("background", "url("+this.view.path+this.view.options.style+"/action/"+action.icon+") no-repeat left center");
+    //    actionNode.addEvent(action.event, function(e){
+    //        this[action.action](e);
+    //    }.bind(this));
+    //    actionNode.addEvents({
+    //        "mouseover": function(e){
+    //            e.target.setStyle("border", "1px solid #999");
+    //        }.bind(this),
+    //        "mouseout": function(e){
+    //            e.target.setStyle("border", "1px solid #F1F1F1");
+    //        }.bind(this)
+    //    });
+    //},
+    //_setActionAreaPosition: function(){
+    //    var p = this.node.getPosition(this.view.areaNode.getOffsetParent());
+    //    var y = p.y-25;
+    //    var x = p.x;
+    //    this.actionArea.setPosition({"x": x, "y": y});
+    //},
+    //_showActions: function(){
+    //    if (this.actionArea){
+    //        this._setActionAreaPosition();
+    //        this.actionArea.setStyle("display", "block");
+    //    }
+    //},
+    //_hideActions: function(){
+    //    if (this.actionArea) this.actionArea.setStyle("display", "none");
+    //},
+
+    selected: function(){
+        if (this.view.currentSelectedModule){
+            if (this.view.currentSelectedModule==this){
+                return true;
+            }else{
+                this.view.currentSelectedModule.unSelected();
+            }
+        }
+        this.node.setStyles(this.css.toolbarWarpNode_selected);
+        //this.listNode.setStyles(this.css.cloumnListNode_selected);
+        new Fx.Scroll(this.view.areaNode, {"wheelStops": false, "duration": 100}).toElementEdge(this.node);
+        //new Fx.Scroll(this.view.designer.propertyDomArea, {"wheelStops": false, "duration": 100}).toElement(this.listNode);
+
+        this.view.currentSelectedModule = this;
+        this.isSelected = true;
+        //this._showActions();
+        this.showProperty();
+    },
+    unSelected: function(){
+        this.view.currentSelectedModule = null;
+        this.node.setStyles(this.css.toolbarWarpNode)
+
+        //this.listNode.setStyles(this.css.cloumnListNode);
+        this.isSelected = false;
+        //this._hideActions();
+        this.hideProperty();
+    },
+
+    showProperty: function(){
+        if (!this.property){
+            this.property = new MWF.xApplication.query.ViewDesigner.Property(this, this.view.designer.propertyContentArea, this.view.designer, {
+                "path": this.propertyPath,
+                "onPostLoad": function(){
+                    this.property.show();
+                    //var processDiv = this.property.propertyContent.getElements("#"+this.json.id+"dataPathSelectedProcessArea");
+                    //var cmsDiv = this.property.propertyContent.getElements("#"+this.json.id+"dataPathSelectedCMSArea");
+                    //
+                    //if (this.view.json.type=="cms"){
+                    //    processDiv.setStyle("display", "none");
+                    //    cmsDiv.setStyle("display", "block");
+                    //}else{
+                    //    processDiv.setStyle("display", "block");
+                    //    cmsDiv.setStyle("display", "none");
+                    //}
+                }.bind(this)
+            });
+            this.property.load();
+        }else{
+            this.property.show();
+        }
+    },
+    hideProperty: function(){
+        if (this.property) this.property.hide();
+    },
+
+    resetTextNode: function(){
+        var listText = (this.json.selectType=="attribute") ? (this.json.attribute || "") : (this.json.path || "");
+        if (!listText) listText = "unnamed";
+
+        this.textNode.set("text", this.json.displayName);
+        this.listNode.getLast().set("text", this.json.displayName+"("+listText+")");
+    },
+    //"delete": function(e){
+    //    var _self = this;
+    //    if (!e) e = this.node;
+    //    this.view.designer.confirm("warn", e, MWF.APPDVD.LP.notice.deleteColumnTitle, MWF.APPDVD.LP.notice.deleteColumn, 300, 120, function(){
+    //        _self.destroy();
+    //
+    //        this.close();
+    //    }, function(){
+    //        this.close();
+    //    }, null);
+    //},
+    //destroy: function(){
+    //    if (this.view.currentSelectedModule==this) this.view.currentSelectedModule = null;
+    //    if (this.actionArea) this.actionArea.destroy();
+    //    if (this.listNode) this.listNode.destroy();
+    //    if (this.property) this.property.propertyContent.destroy();
+    //
+    //    var idx = this.view.items.indexOf(this);
+    //
+    //    if (this.view.viewContentTableNode){
+    //        var trs = this.view.viewContentTableNode.getElements("tr");
+    //        trs.each(function(tr){
+    //            tr.deleteCell(idx);
+    //        }.bind(this));
+    //    }
+    //
+    //    if (this.view.json.data.selectList) this.view.json.data.selectList.erase(this.json);
+    //    if (this.view.json.data.calculate) if (this.view.json.data.calculate.calculateList) this.view.json.data.calculate.calculateList.erase(this.json);
+    //    this.view.items.erase(this);
+    //    if (this.view.property) this.view.property.loadStatColumnSelect();
+    //
+    //    this.areaNode.destroy();
+    //    this.view.selected();
+    //
+    //    this.view.setViewWidth();
+    //
+    //    MWF.release(this);
+    //    delete this;
+    //},
+
+    //move: function(e){
+    //    this._createMoveNode();
+    //
+    //    //this._setNodeMove(columnNodes, e);
+    //},
+    //_createMoveNode: function(){
+    //    this.moveNode = new Element("div", {"text": this.node.get("text")});
+    //    this.moveNode.inject(this.view.designer.content);
+    //    this.moveNode.setStyles({
+    //        "border": "2px dashed #ffa200",
+    //        "opacity": 0.7,
+    //        "height": "30px",
+    //        "line-height": "30px",
+    //        "padding": "0px 10px",
+    //        "position": "absolute"
+    //    });
+    //},
+    //_setMoveNodePosition: function(e){
+    //    var x = e.page.x+2;
+    //    var y = e.page.y+2;
+    //    this.moveNode.positionTo(x, y);
+    //},
+    //createMoveFlagNode: function(){
+    //    this.moveFlagNode = new Element("td", {"styles": this.css.moveFlagNode});
+    //},
+    //_setNodeMove: function(droppables, e){
+    //    this._setMoveNodePosition(e);
+    //    var movePosition = this.moveNode.getPosition();
+    //    var moveSize = this.moveNode.getSize();
+    //    var contentPosition = this.content.getPosition();
+    //    var contentSize = this.content.getSize();
+    //
+    //    var nodeDrag = new Drag.Move(this.moveNode, {
+    //        "droppables": droppables,
+    //        "limit": {
+    //            "x": [contentPosition.x, contentPosition.x+contentSize.x],
+    //            "y": [movePosition.y, movePosition.y+moveSize.y]
+    //        },
+    //        "onEnter": function(dragging, inObj){
+    //            if (!this.moveFlagNode) this.createMoveFlagNode();
+    //            this.moveFlagNode.inject(inObj, "before");
+    //        }.bind(this),
+    //        "onLeave": function(dragging, inObj){
+    //            if (this.moveFlagNode){
+    //                this.moveFlagNode.dispose();
+    //            }
+    //        }.bind(this),
+    //        "onDrop": function(dragging, inObj){
+    //            if (inObj){
+    //                this.areaNode.inject(inObj, "before");
+    //                var column = inObj.retrieve("column");
+    //                this.listNode.inject(column.listNode, "before");
+    //                var idx = this.view.json.data.selectList.indexOf(column.json);
+    //
+    //                this.view.json.data.selectList.erase(this.json);
+    //                this.view.items.erase(this);
+    //
+    //                this.view.json.data.selectList.splice(idx, 0, this.json);
+    //                this.view.items.splice(idx, 0, this);
+    //
+    //                if (this.moveNode) this.moveNode.destroy();
+    //                if (this.moveFlagNode) this.moveFlagNode.destroy();
+    //                this._setActionAreaPosition();
+    //            }else{
+    //                if (this.moveNode) this.moveNode.destroy();
+    //                if (this.moveFlagNode) this.moveFlagNode.destroy();
+    //            }
+    //        }.bind(this),
+    //        "onCancel": function(dragging){
+    //            if (this.moveNode) this.moveNode.destroy();
+    //            if (this.moveFlagNode) this.moveFlagNode.destroy();
+    //        }.bind(this)
+    //    });
+    //    nodeDrag.start(e);
+    //},
+
+    deletePropertiesOrStyles: function(name, key){
+        if (name=="properties"){
+            try{
+                this.node.removeProperty(key);
+            }catch(e){}
+        }
+    },
+    setPropertiesOrStyles: function(name){
+        if (name=="styles"){
+            try{
+                this.setCustomStyles();
+            }catch(e){}
+        }
+        if (name=="properties"){
+            try{
+                this.node.setProperties(this.json.properties);
+            }catch(e){}
+        }
+    },
+    setCustomNodeStyles: function(node, styles){
+        var border = node.getStyle("border");
+        node.clearStyles();
+        //node.setStyles(styles);
+        node.setStyle("border", border);
+
+        Object.each(styles, function(value, key){
+            var reg = /^border\w*/ig;
+            if (!key.test(reg)){
+                node.setStyle(key, value);
+            }
+        }.bind(this));
+    },
+    setCustomStyles: function(){
+        var border = this.node.getStyle("border");
+        this.node.clearStyles();
+        this.node.setStyles(this.css.moduleNode);
+
+        if (this.initialStyles) this.node.setStyles(this.initialStyles);
+        this.node.setStyle("border", border);
+
+        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)){
+                var host1 = MWF.Actions.getHost("x_processplatform_assemble_surface");
+                var host2 = MWF.Actions.getHost("x_portal_assemble_surface");
+                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");
+                }
+            }
+
+            var reg = /^border\w*/ig;
+            if (!key.test(reg)){
+                if (key){
+                    if (key.toString().toLowerCase()==="display"){
+                        if (value.toString().toLowerCase()==="none"){
+                            this.node.setStyle("opacity", 0.3);
+                        }else{
+                            this.node.setStyle("opacity", 1);
+                            this.node.setStyle(key, value);
+                        }
+                    }else{
+                        this.node.setStyle(key, value);
+                    }
+                }
+            }
+            //this.node.setStyle(key, value);
+        }.bind(this));
+    },
+
+    _setEditStyle: function(name, obj, oldValue){
+        var title = "";
+        var text = "";
+        if (name==="name"){
+            title = this.json.name || this.json.id;
+            text = this.json.type.substr(this.json.type.lastIndexOf("$")+1, this.json.type.length);
+            this.treeNode.setText("<"+text+"> "+title);
+        }
+        if (name==="id"){
+            title = this.json.name || this.json.id;
+            if (!this.json.name){
+                text = this.json.type.substr(this.json.type.lastIndexOf("$")+1, this.json.type.length);
+                this.treeNode.setText("<"+text+"> "+this.json.id);
+            }
+            this.treeNode.setTitle(this.json.id);
+            this.node.set("id", this.json.id);
+        }
+
+        this._setEditStyle_custom(name, obj, oldValue);
+    },
+    reloadMaplist: function(){
+        if (this.property) Object.each(this.property.maplists, function(map, name){ map.reload(this.json[name]);}.bind(this));
+    },
+
+    getHtml: function(){
+        var copy = this.node.clone(true, true);
+        copy.clearStyles(true);
+
+        var html = copy.outerHTML;
+        copy.destroy();
+
+        return html;
+    },
+    getJson: function(){
+        var json = Object.clone(this.json);
+        var o = {};
+        o[json.id] = json;
+        return o;
+    },
+
+
+    _createNode: function(callback){
+        this.node = new Element("div", {
+            "id": this.json.id,
+            "MWFType": "actionbar",
+            "styles": this.css.toolbarWarpNode,
+            "events": {
+                "selectstart": function(e){
+                    e.preventDefault();
+                }
+            }
+
+        }).inject(this.container );
+
+        this.toolbarNode = new Element("div").inject(this.node);
+
+        this.toolbarWidget = new MWF.widget.Toolbar(this.toolbarNode, {"style": this.json.style}, this);
+        if (!this.json.actionStyles){
+            this.json.actionStyles = Object.clone(this.toolbarWidget.css);
+        }
+
+        //MWF.getJSON(this.path+"toolbars.json", function(json){
+        //    this.json.defaultTools = json;
+        //    this.setToolbars(json, this.toolbarNode);
+        //    debugger;
+        //    this.toolbarWidget.load();
+        //}.bind(this), false);
+        if (this.json.defaultTools){
+            var json = Array.clone(this.json.defaultTools);
+            //if (this.json.tools) json.append(this.json.tools);
+            this.setToolbars(json, this.toolbarNode);
+            if (this.json.tools){
+                this.setCustomToolbars(Array.clone(this.json.tools), this.toolbarNode);
+            }
+            this.toolbarWidget.load();
+            this._setEditStyle_custom("hideSystemTools");
+            //json = null;
+        }else{
+            MWF.getJSON(this.path+"toolbars.json", function(json){
+                this.json.defaultTools = json;
+                var json = Array.clone(this.json.defaultTools);
+                //if (this.json.tools) json.append(this.json.tools);
+                this.setToolbars(json, this.toolbarNode);
+                if (this.json.tools){
+                    this.setCustomToolbars(Array.clone(this.json.tools), this.toolbarNode);
+                }
+                this.toolbarWidget.load();
+                this._setEditStyle_custom("hideSystemTools");
+                //json = null;
+            }.bind(this), false);
+        }
+    },
+
+    _refreshActionbar: function(){
+        //if (this.form.options.mode == "Mobile"){
+        //    this.node.set("text", MWF.APPFD.LP.notice.notUseModuleInMobile+"("+this.moduleName+")");
+        //    this.node.setStyles({"height": "24px", "line-height": "24px", "background-color": "#999"});
+        //}else{
+        this.toolbarNode = this.node.getFirst("div");
+        this.toolbarNode.empty();
+        this.toolbarWidget = new MWF.widget.Toolbar(this.toolbarNode, {"style": this.json.style}, this);
+        if (!this.json.actionStyles) this.json.actionStyles = Object.clone(this.toolbarWidget.css);
+        this.toolbarWidget.css = this.json.actionStyles;
+
+        if (this.json.defaultTools){
+            var json = Array.clone(this.json.defaultTools);
+            //if (this.json.tools) json.append(this.json.tools);
+            this.setToolbars(json, this.toolbarNode);
+            if (this.json.tools){
+                this.setCustomToolbars(Array.clone(this.json.tools), this.toolbarNode);
+            }
+            this.toolbarWidget.load();
+            //json = null;
+        }else{
+            MWF.getJSON(this.path+"toolbars.json", function(json){
+                this.json.defaultTools = json;
+                var json = Array.clone(this.json.defaultTools);
+                //if (this.json.tools) json.append(this.json.tools);
+                this.setToolbars(json, this.toolbarNode);
+                if (this.json.tools){
+                    this.setCustomToolbars(Array.clone(this.json.tools), this.toolbarNode);
+                }
+                this.toolbarWidget.load();
+                //json = null;
+            }.bind(this), false);
+        }
+        //}
+
+    },
+    _resetActionbar: function(){
+        //if (this.form.options.mode == "Mobile"){
+        //    this.node.set("text", MWF.APPFD.LP.notice.notUseModuleInMobile+"("+this.moduleName+")");
+        //    this.node.setStyles({"height": "24px", "line-height": "24px", "background-color": "#999"});
+        //}else{
+        this.toolbarNode = this.node.getFirst("div");
+        this.toolbarNode.empty();
+        this.toolbarWidget = new MWF.widget.Toolbar(this.toolbarNode, {"style": this.json.style}, this);
+        if (!this.json.actionStyles){
+            this.json.actionStyles = Object.clone(this.toolbarWidget.css);
+        }else{
+            this.toolbarWidget.css = Object.merge( Object.clone(this.json.actionStyles), this.toolbarWidget.css );
+            this.json.actionStyles = Object.clone(this.toolbarWidget.css);
+        }
+
+        if (this.json.defaultTools){
+            var json = Array.clone(this.json.defaultTools);
+            //if (this.json.tools) json.append(this.json.tools);
+            this.setToolbars(json, this.toolbarNode);
+            if (this.json.tools){
+                this.setCustomToolbars(Array.clone(this.json.tools), this.toolbarNode);
+            }
+            this.toolbarWidget.load();
+            //json = null;
+        }else{
+            MWF.getJSON(this.path+"toolbars.json", function(json){
+                this.json.defaultTools = json;
+                var json = Array.clone(this.json.defaultTools);
+                //if (this.json.tools) json.append(this.json.tools);
+                this.setToolbars(json, this.toolbarNode);
+                if (this.json.tools){
+                    this.setCustomToolbars(Array.clone(this.json.tools), this.toolbarNode);
+                }
+                this.toolbarWidget.load();
+                //json = null;
+            }.bind(this), false);
+        }
+        //}
+    },
+    setToolbars: function(tools, node){
+        tools.each(function(tool){
+            var actionNode = new Element("div", {
+                "MWFnodetype": tool.type,
+                "MWFButtonImage": this.imagePath_default+""+this.options.style+"/actionbar/"+tool.img,
+                "title": tool.title,
+                "MWFButtonAction": tool.action,
+                "MWFButtonText": tool.text
+            }).inject(node);
+            if( this.json.iconOverStyle ){
+                actionNode.set("MWFButtonImageOver" , this.imagePath_default+""+this.options.style+"/actionbar/"+this.json.iconOverStyle+"/"+tool.img );
+            }
+            this.systemTools.push(actionNode);
+            if (tool.sub){
+                var subNode = node.getLast();
+                this.setToolbars(tool.sub, subNode);
+            }
+        }.bind(this));
+    },
+    setCustomToolbars: function(tools, node){
+        //var style = (this.json.style || "default").indexOf("red") > -1 ? "red" : "blue";
+        var path = "";
+        if( this.json.customIconStyle ){
+            path = this.json.customIconStyle+ "/";
+        }
+
+        tools.each(function(tool){
+            var actionNode = new Element("div", {
+                "MWFnodetype": tool.type,
+                "MWFButtonImage": this.imagePath_custom+""+this.options.customImageStyle +"/custom/"+path+tool.img,
+                "title": tool.title,
+                "MWFButtonAction": tool.action,
+                "MWFButtonText": tool.text
+            }).inject(node);
+            if( this.json.customIconOverStyle ){
+                actionNode.set("MWFButtonImageOver" , this.imagePath_custom+""+this.options.customImageStyle +"/custom/"+this.json.customIconOverStyle+ "/" +tool.img );
+            }
+            this.customTools.push(actionNode);
+            if (tool.sub){
+                var subNode = node.getLast();
+                this.setToolbars(tool.sub, subNode);
+            }
+        }.bind(this));
+    },
+    _setEditStyle_custom: function(name){
+        if (name=="hideSystemTools"){
+            if (this.json.hideSystemTools){
+                this.systemTools.each(function(tool){
+                    tool.setStyle("display", "none");
+                });
+            }else{
+                this.systemTools.each(function(tool){
+                    tool.setStyle("display", "block");
+                });
+            }
+        }
+        if (name=="defaultTools" || name=="tools" || name==="actionStyles"){
+            this._refreshActionbar();
+        }
+
+    }
 
+});

+ 18 - 0
o2web/source/x_component_query_ViewDesigner/lp/zh-cn.js

@@ -50,6 +50,24 @@ MWF.xApplication.query.ViewDesigner.LP = {
         "inputName": "请输入视图名称",
         "noModifyName": "不能修改名称或者别名"
     },
+    "actionbar": {
+        "readhide": "设置阅读时是否显示",
+        "edithide": "设置编辑时是否显示",
+        "hideCondition": "设置隐藏条件",
+        "title": "标题",
+        "img": "图标",
+        "action": "操作",
+        "condition": "显示条件",
+        "editScript": "操作脚本编辑",
+        "editCondition": "隐藏条件编辑(返回true隐藏操作)",
+        "up" : "上移",
+        "property" : "属性",
+        "addCustomTool" : "添加自定义操作",
+        "delete" : "删除",
+        "setProperties" : "设置操作属性",
+        "restoreDefaultTool" : "恢复删除的系统操作",
+        "selectDefaultTool" : "选择系统操作"
+    },
     "mastInputPath": "请输入数据路径",
     "mastInputTitle": "请输入标题",
     "filter": {