Просмотр исходного кода

表单人员选择添加事件,添加只有左侧内容的选项

unknown 5 лет назад
Родитель
Сommit
5d9762a6c3

+ 27 - 19
o2web/source/x_component_Selector/Person.js

@@ -27,6 +27,7 @@ MWF.xApplication.Selector.Person = new Class({
         "hasShuttle" : false, //穿梭按钮
         "searchbarInTopNode" : true, //搜索框在标题上还是另起一行
         "hasSelectedSearchbar" : false, //已选是不是有搜索框
+        "noSelectedContainer" : true, //是否有已选项
         "contentUrl" : "", //和默认的页面布局不一样的话,可以传入页面布局HTML URL
         "injectToBody" : false, //当传入HTML URL的时候是否插入到document.body, false的时候插入到this.container
 
@@ -196,7 +197,7 @@ MWF.xApplication.Selector.Person = new Class({
 
             //  this.container.setStyle("z-index", this.options.zIndex);
             this.node = new Element("div", {
-                "styles": this.css.containerNode, //(this.options.count.toInt()===1) ? this.css.containerNodeSingle : this.css.containerNode,
+                "styles": this.options.noSelectedContainer ? this.css.containerNodeSingle : this.css.containerNode, //(this.options.count.toInt()===1)
                 "events": {
                     "click": function(e){e.stopPropagation();},
                     "mousedown": function(e){e.stopPropagation();},
@@ -337,7 +338,7 @@ MWF.xApplication.Selector.Person = new Class({
 
         if (this.selectNode) this.selectNode.setStyles(this.css.selectNodeMobile);
         if (this.searchInputDiv) this.searchInputDiv.setStyles(this.css.searchInputDiv);
-        if (this.searchInput) this.searchInput.setStyles( (this.options.count.toInt()===1) ? this.css.searchInputSingle : this.css.searchInput );
+        if (this.searchInput) this.searchInput.setStyles( (this.options.count.toInt()===1 || this.options.noSelectedContainer) ? this.css.searchInputSingle : this.css.searchInput );
         if (this.letterAreaNode) this.letterAreaNode.setStyles(this.css.letterAreaNode);
         if (this.itemAreaScrollNode) this.itemAreaScrollNode.setStyles(this.css.itemAreaScrollNode);
         if (this.itemAreaNode) this.itemAreaNode.setStyles(this.css.itemAreaNode);
@@ -571,7 +572,7 @@ MWF.xApplication.Selector.Person = new Class({
             "styles": this.css.searchInputDiv
         }).inject(this.selectNode);
         this.searchInput = new Element("input.searchInput", {
-            "styles": (this.options.count.toInt()===1) ? this.css.searchInputSingle : this.css.searchInput,
+            "styles": (this.options.count.toInt()===1 || this.options.noSelectedContainer) ? this.css.searchInputSingle : this.css.searchInput,
             "type": "text"
         }).inject(this.searchInputDiv);
         var width = size.x-20-18;
@@ -925,6 +926,10 @@ MWF.xApplication.Selector.Person = new Class({
             "styles": this.css.selectedContainerNode
         }).inject(this.contentNode);
 
+        if( this.options.noSelectedContainer ){
+            this.selectedContainerNode.hide();
+        }
+
         //if( this.options.embedded && this.options.count.toInt()!==1 ){
         if( this.options.hasTop ){
             this.selectedTopNode = new Element("div",{
@@ -1354,6 +1359,7 @@ MWF.xApplication.Selector.Person = new Class({
         }
     },
     setSize : function(){
+
         if( !this.options.width && !this.options.height )return;
 
         var getOffsetX = function(node){
@@ -1417,7 +1423,9 @@ MWF.xApplication.Selector.Person = new Class({
 
             //if (this.options.count.toInt() !== 1){
             var width = nodeWidth - getOffsetX(this.selectNode) - getOffsetX(this.selectedContainerNode);
-            var halfWidth = Math.floor(width / 2);
+
+            var halfWidth = this.options.noSelectedContainer ? width : Math.floor(width / 2);
+
             this.selectNode.setStyle("width", halfWidth);
             //this.searchInput.setStyle("width", halfWidth - 6);
             if(this.letterAreaNode ){
@@ -1657,7 +1665,7 @@ MWF.xApplication.Selector.Person.Item = new Class({
         this.actionNode = new Element("div", {
             "styles": this.selector.css.selectorItemActionNode
         }).inject(this.node);
-        if( this.selector.options.count.toInt() === 1 && this.selector.css.selectorItemActionNode_single  ){
+        if( ( this.selector.options.count.toInt() === 1 || this.selector.options.noSelectedContainer ) && this.selector.css.selectorItemActionNode_single  ){
             this.actionNode.setStyles( this.selector.css.selectorItemActionNode_single );
         }
 
@@ -1726,7 +1734,7 @@ MWF.xApplication.Selector.Person.Item = new Class({
         this.checkTextNodeIndent( this.textNode, this.selector.css.selectorItemTextNode_selected );
 
         this.actionNode.setStyles(this.selector.css.selectorItemActionNode_selected);
-        if( this.selector.options.count.toInt() === 1 && this.selector.css.selectorItemActionNode_single_selected  ){
+        if( ( this.selector.options.count.toInt() === 1 || this.selector.options.noSelectedContainer ) && this.selector.css.selectorItemActionNode_single_selected  ){
             this.actionNode.setStyles( this.selector.css.selectorItemActionNode_single_selected );
         }
     },
@@ -1763,7 +1771,7 @@ MWF.xApplication.Selector.Person.Item = new Class({
         }
         if (!this.isSelected){
             this.actionNode.setStyles(this.selector.css.selectorItemActionNode_over);
-            if( this.selector.options.count.toInt() === 1 && this.selector.css.selectorItemActionNode_single_over  ){
+            if( ( this.selector.options.count.toInt() === 1 || this.selector.options.noSelectedContainer ) && this.selector.css.selectorItemActionNode_single_over  ){
                 this.actionNode.setStyles( this.selector.css.selectorItemActionNode_single_over );
             }
         }else if( this.selector.css.selectorItemActionNode_over_force ){
@@ -1778,12 +1786,12 @@ MWF.xApplication.Selector.Person.Item = new Class({
         }
         if (!this.isSelected){
             this.actionNode.setStyles(this.selector.css.selectorItemActionNode);
-            if( this.selector.options.count.toInt() === 1 && this.selector.css.selectorItemActionNode_single  ){
+            if( ( this.selector.options.count.toInt() === 1 || this.selector.options.noSelectedContainer ) && this.selector.css.selectorItemActionNode_single  ){
                 this.actionNode.setStyles( this.selector.css.selectorItemActionNode_single );
             }
         }else if( this.selector.css.selectorItemActionNode_over_force ){
             this.actionNode.setStyles(this.selector.css.selectorItemActionNode_selected);
-            if( this.selector.options.count.toInt() === 1 && this.selector.css.selectorItemActionNode_single_selected  ){
+            if( ( this.selector.options.count.toInt() === 1 || this.selector.options.noSelectedContainer ) && this.selector.css.selectorItemActionNode_single_selected  ){
                 this.actionNode.setStyles( this.selector.css.selectorItemActionNode_single_selected );
             }
         }
@@ -1801,7 +1809,7 @@ MWF.xApplication.Selector.Person.Item = new Class({
                 this.checkTextNodeIndent( this.textNode, this.selector.css.selectorItemTextNode_selected );
 
                 this.actionNode.setStyles(this.selector.css.selectorItemActionNode_selected);
-                if( this.selector.options.count.toInt() === 1 && this.selector.css.selectorItemActionNode_single_selected  ){
+                if( ( this.selector.options.count.toInt() === 1 || this.selector.options.noSelectedContainer ) && this.selector.css.selectorItemActionNode_single_selected  ){
                     this.actionNode.setStyles( this.selector.css.selectorItemActionNode_single_selected );
                 }
 
@@ -1825,7 +1833,7 @@ MWF.xApplication.Selector.Person.Item = new Class({
         this.checkTextNodeIndent( this.textNode, this.selector.css.selectorItemTextNode );
 
         this.actionNode.setStyles(this.selector.css.selectorItemActionNode);
-        if( this.selector.options.count.toInt() === 1 && this.selector.css.selectorItemActionNode_single  ){
+        if( ( this.selector.options.count.toInt() === 1 || this.selector.options.noSelectedContainer ) && this.selector.css.selectorItemActionNode_single  ){
             this.actionNode.setStyles( this.selector.css.selectorItemActionNode_single );
         }
         this.selector.fireEvent("unselectItem",[this])
@@ -1846,7 +1854,7 @@ MWF.xApplication.Selector.Person.Item = new Class({
                 this.checkTextNodeIndent( this.textNode, this.selector.css.selectorItemTextNode_selected );
 
                 this.actionNode.setStyles(this.selector.css.selectorItemActionNode_selected);
-                if( this.selector.options.count.toInt() === 1 && this.selector.css.selectorItemActionNode_single_selected  ){
+                if( ( this.selector.options.count.toInt() === 1 || this.selector.options.noSelectedContainer ) && this.selector.css.selectorItemActionNode_single_selected  ){
                     this.actionNode.setStyles( this.selector.css.selectorItemActionNode_single_selected );
                 }
             }
@@ -1868,7 +1876,7 @@ MWF.xApplication.Selector.Person.Item = new Class({
             this.checkTextNodeIndent( this.textNode, this.selector.css.selectorItemTextNode );
 
             this.actionNode.setStyles(this.selector.css.selectorItemActionNode);
-            if( this.selector.options.count.toInt() === 1 && this.selector.css.selectorItemActionNode_single  ){
+            if( ( this.selector.options.count.toInt() === 1 || this.selector.options.noSelectedContainer ) && this.selector.css.selectorItemActionNode_single  ){
                 this.actionNode.setStyles( this.selector.css.selectorItemActionNode_single );
             }
         }
@@ -1895,7 +1903,7 @@ MWF.xApplication.Selector.Person.Item = new Class({
                     this.checkTextNodeIndent( itemSearch.textNode, this.selector.css.selectorItemTextNode );
 
                     itemSearch.actionNode.setStyles(this.selector.css.selectorItemActionNode);
-                    if( this.selector.options.count.toInt() === 1 && this.selector.css.selectorItemActionNode_single  ){
+                    if( ( this.selector.options.count.toInt() === 1 || this.selector.options.noSelectedContainer ) && this.selector.css.selectorItemActionNode_single  ){
                         itemSearch.actionNode.setStyles( this.selector.css.selectorItemActionNode_single );
                     }
                 }
@@ -1914,7 +1922,7 @@ MWF.xApplication.Selector.Person.Item = new Class({
                     this.checkTextNodeIndent( item.textNode, this.selector.css.selectorItemTextNode );
 
                     item.actionNode.setStyles(this.selector.css.selectorItemActionNode);
-                    if( this.selector.options.count.toInt() === 1 && this.selector.css.selectorItemActionNode_single  ){
+                    if( ( this.selector.options.count.toInt() === 1 || this.selector.options.noSelectedContainer ) && this.selector.css.selectorItemActionNode_single  ){
                         item.actionNode.setStyles( this.selector.css.selectorItemActionNode_single );
                     }
                 }
@@ -1963,7 +1971,7 @@ MWF.xApplication.Selector.Person.ItemSelected = new Class({
     postLoad : function(){
         if( this.selector.css.selectorSelectedItemActionNode ){
             this.actionNode.setStyles( this.selector.css.selectorSelectedItemActionNode );
-            if( this.selector.options.count.toInt() === 1 && this.selector.css.selectorSelectedItemActionNode_single  ){
+            if( ( this.selector.options.count.toInt() === 1 || this.selector.options.noSelectedContainer ) && this.selector.css.selectorSelectedItemActionNode_single  ){
                 this.actionNode.setStyles( this.selector.css.selectorSelectedItemActionNode_single );
             }
         }
@@ -2000,7 +2008,7 @@ MWF.xApplication.Selector.Person.ItemSelected = new Class({
                 this.node.setStyles(this.selector.css.selectorItem_over);
             }
             this.actionNode.setStyles(this.selector.css.selectorItemActionNode_selected_over);
-            if( this.selector.options.count.toInt() === 1 && this.selector.css.selectorItemActionNode_single_selected_over  ){
+            if( ( this.selector.options.count.toInt() === 1 || this.selector.options.noSelectedContainer ) && this.selector.css.selectorItemActionNode_single_selected_over  ){
                 this.actionNode.setStyles( this.selector.css.selectorItemActionNode_single_selected_over );
             }
         }
@@ -2015,13 +2023,13 @@ MWF.xApplication.Selector.Person.ItemSelected = new Class({
         if (!this.isSelected){
             var styles = this.selector.css.selectorSelectedItemActionNode || this.selector.css.selectorItemActionNode;
             this.actionNode.setStyles(styles);
-            if( this.selector.options.count.toInt() === 1 &&
+            if( ( this.selector.options.count.toInt() === 1 || this.selector.options.noSelectedContainer ) &&
                 ( this.selector.css.selectorSelectedItemActionNode_single || this.selector.css.selectorItemActionNode_single )  ){
                 this.actionNode.setStyles( this.selector.css.selectorSelectedItemActionNode_single || this.selector.css.selectorItemActionNode_single );
             }
         }else if( this.selector.css.selectorItemActionNode_over_force ){
             this.actionNode.setStyles(this.selector.css.selectorItemActionNode_selected);
-            if( this.selector.options.count.toInt() === 1 && this.selector.css.selectorItemActionNode_single_selected  ){
+            if( ( this.selector.options.count.toInt() === 1 || this.selector.options.noSelectedContainer ) && this.selector.css.selectorItemActionNode_single_selected  ){
                 this.actionNode.setStyles( this.selector.css.selectorItemActionNode_single_selected );
             }
         }

+ 1 - 1
o2web/source/x_component_Selector/Unit.js

@@ -195,7 +195,7 @@ MWF.xApplication.Selector.Unit.Item = new Class({
         this.actionNode = new Element("div", {
             "styles": this.selector.css.selectorItemActionNode
         }).inject(this.node);
-        if( this.selector.options.count.toInt() === 1 && this.selector.css.selectorItemActionNode_single  ){
+        if( ( this.selector.options.count.toInt() === 1 || this.selector.options.noSelectedContainer ) && this.selector.css.selectorItemActionNode_single  ){
             this.actionNode.setStyles( this.selector.css.selectorItemActionNode_single );
         }
 

+ 0 - 1
o2web/source/x_component_Template/Selector/Custom.js

@@ -68,7 +68,6 @@ MWF.xApplication.Template.Selector.Custom = new Class({
         this.categorys = [];
     },
     loadSelectItems: function (addToNext) {
-
         debugger;
         if (!this.options.category) {
             this.options.selectableItems.each(function (it) {

+ 40 - 0
o2web/source/x_component_process_FormDesigner/Module/Org/template.json

@@ -92,6 +92,46 @@
 		"blur": {
 			"code": "",
 			"html": ""
+		},
+		"queryLoadSelector" : {
+			"code": "",
+			"html": ""
+		},
+		"postLoadSelector" : {
+			"code": "",
+			"html": ""
+		},
+		"queryLoadCategory" : {
+			"code": "",
+			"html": ""
+		},
+		"postLoadCategory" : {
+			"code": "",
+			"html": ""
+		},
+		"selectCategory": {
+			"code": "",
+			"html": ""
+		},
+		"unselectCategory": {
+			"code": "",
+			"html": ""
+		},
+		"queryLoadItem" : {
+			"code": "",
+			"html": ""
+		},
+		"postLoadItem" : {
+			"code": "",
+			"html": ""
+		},
+		"selectItem" : {
+			"code": "",
+			"html": ""
+		},
+		"unselectItem" : {
+			"code": "",
+			"html": ""
 		}
 	},
 	"properties": {},

+ 44 - 7
o2web/source/x_component_process_Xform/Org.js

@@ -6,6 +6,8 @@ MWF.xApplication.process.Xform.Org = MWF.APPOrg =  new Class({
     Extends: MWF.APP$Input,
     options: {
         "moduleEvents": ["load", "queryLoad", "postLoad", "change", "select"],
+        "selectorEvents" : ["queryLoadSelector","postLoadSelector","postLoadContent","queryLoadCategory","postLoadCategory",
+            "selectCategory", "unselectCategory","queryLoadItem","postLoadItem","selectItem", "unselectItem","change"],
         "readonly": true
     },
 
@@ -141,6 +143,8 @@ MWF.xApplication.process.Xform.Org = MWF.APPOrg =  new Class({
 
     getOptions: function(){
 
+        var _self = this;
+
         if( this.selectTypeList.length === 0 )return false;
 
         var values = this.getInputData();
@@ -215,6 +219,30 @@ MWF.xApplication.process.Xform.Org = MWF.APPOrg =  new Class({
         //    }
         //}
 
+        var defaultOpt = {};
+
+        if( this.json.events && typeOf(this.json.events) === "object" ){
+            Object.each(this.json.events, function(e, key){
+                if (e.code){
+                    if (this.options.selectorEvents.indexOf(key)!==-1){
+                        if( key === "postLoadSelector" ) {
+                            this.addEvent("loadSelector", function (selector) {
+                                return this.form.Macro.fire(e.code, selector);
+                            }.bind(this))
+                        }else if( key === "queryLoadSelector"){
+                            defaultOpt["onQueryLoad"] = function(target){
+                                return this.form.Macro.fire(e.code, target);
+                            }.bind(this)
+                        }else{
+                            defaultOpt["on"+key.capitalize()] = function(target){
+                                return this.form.Macro.fire(e.code, target);
+                            }.bind(this)
+                        }
+                    }
+                }
+            }.bind(this));
+        }
+
         if( this.selectTypeList.length === 1 ){
             return Object.merge( {
                 "type": this.selectTypeList[0],
@@ -222,9 +250,13 @@ MWF.xApplication.process.Xform.Org = MWF.APPOrg =  new Class({
                     this.selectOnComplete(items);
                 }.bind(this),
                 "onCancel": this.selectOnCancel.bind(this),
-                "onLoad": this.selectOnLoad.bind(this),
+                // "onLoad": this.selectOnLoad.bind(this),
+                "onLoad": function(){
+                    //this 为 selector
+                    _self.selectOnLoad(this, this.selector );
+                },
                 "onClose": this.selectOnClose.bind(this)
-            }, identityOpt || unitOpt || groupOpt )
+            }, defaultOpt, identityOpt || unitOpt || groupOpt )
         }else if( this.selectTypeList.length > 1 ){
             var options = {
                 "type" : "",
@@ -233,15 +265,19 @@ MWF.xApplication.process.Xform.Org = MWF.APPOrg =  new Class({
                     this.selectOnComplete(items);
                 }.bind(this),
                 "onCancel": this.selectOnCancel.bind(this),
-                "onLoad": this.selectOnLoad.bind(this),
+                // "onLoad": this.selectOnLoad.bind(this),
+                "onLoad": function(){
+                    //this 为 selector
+                    _self.selectOnLoad(this)
+                },
                 "onClose": this.selectOnClose.bind(this)
             };
             if( this.form.json.selectorStyle ){
                 options = Object.merge( options, this.form.json.selectorStyle );
             }
-            if( identityOpt )options.identityOptions = identityOpt;
-            if( unitOpt )options.unitOptions = unitOpt;
-            if( groupOpt )options.groupOptions = groupOpt;
+            if( identityOpt )options.identityOptions = Object.merge( {}, defaultOpt, identityOpt );
+            if( unitOpt )options.unitOptions =  Object.merge( {}, defaultOpt, unitOpt );
+            if( groupOpt )options.groupOptions = Object.merge( {}, defaultOpt, groupOpt );
             return options;
         }
 
@@ -288,8 +324,9 @@ MWF.xApplication.process.Xform.Org = MWF.APPOrg =  new Class({
     selectOnCancel: function(){
         this.validation();
     },
-    selectOnLoad: function(){
+    selectOnLoad: function( selector ){
         if (this.descriptionNode) this.descriptionNode.setStyle("display", "none");
+        this.fireEvent("loadSelector", [selector])
     },
     selectOnClose: function(){
         v = this._getBusinessData();