Explorar o código

选择身份时检查状态

unknown %!s(int64=5) %!d(string=hai) anos
pai
achega
8bc7a19573

+ 10 - 2
o2web/source/x_component_Selector/Identity.js

@@ -749,6 +749,9 @@ MWF.xApplication.Selector.Identity.ItemSelected = new Class({
                 items.each(function(item){
                     item.selectedItem = this;
                     item.setSelected();
+                    if( this.selector.options.showSelectedCount ){
+                        if(item.category)item.category._addSelectedCount( 1, true );
+                    }
                 }.bind(this));
             }
         }
@@ -773,9 +776,11 @@ MWF.xApplication.Selector.Identity.ItemCategory = new Class({
         return count;
     },
     _getSelectedCount : function(){
+        if( typeOf(this.selectedCount) === "number" )return this.selectedCount;
         if( !this.selector.allUnitObject )return 0;
         var unit =  this.selector.allUnitObject[this.data.levelName];
         var count = unit ? unit.selectedNestedIdentityCount : 0;
+        this.selectedCount = count;
         return count;
     },
     _setIcon: function(){
@@ -1039,17 +1044,20 @@ MWF.xApplication.Selector.Identity.ItemGroupCategory = new Class({
         this.iconNode.setStyle("background-image", "url("+"../x_component_Selector/$Selector/"+style+"/icon/groupicon.png)");
     },
     _getTotalCount : function(){
-        if( !this.selector.allGroupObjectByDn )return "n";
+        if( !this.selector.allGroupObjectByDn )return 0;
         var group = this.selector.allGroupObjectByDn[this.data.distinguishedName];
-        var count = group ? group.subNestedIdentityCount : "n";
+        var count = group ? group.subNestedIdentityCount : 0;
         return count;
     },
     _getSelectedCount : function(){
+        if( typeOf(this.selectedCount) === "number" )return this.selectedCount;
         if( !this.selector.allGroupObjectByDn )return 0;
         var group = this.selector.allGroupObjectByDn[this.data.distinguishedName];
         var count = group ? group.selectedNestedIdentityCount : 0;
+        this.selectedCount = count;
         return count;
     },
+
     loadSub: function(callback){
         if (!this.loaded){
             var personContainer, identityContainer, groupContainer, unitContainer;

+ 22 - 1
o2web/source/x_component_Selector/Person.js

@@ -2012,6 +2012,7 @@ MWF.xApplication.Selector.Person.Item = new Class({
         if( checkValid )this.selector.fireEvent("valid", [this.selector, this]);
     },
     selected: function( checkValid, callback, selectedNode ){
+        debugger;
         var count = this.selector.options.maxCount || this.selector.options.count;
         count = count.toInt();
         if (!count) count = 0;
@@ -2032,7 +2033,7 @@ MWF.xApplication.Selector.Person.Item = new Class({
                 }
             }
             this.selectedItem = this.selector._newItemSelected(this.data, this.selector, this, selectedNode);
-            this.selectedItem.check();
+            // this.selectedItem.check();
             this.selector.selectedItems.push(this.selectedItem);
 
             // if( this.category ){
@@ -2105,6 +2106,9 @@ MWF.xApplication.Selector.Person.Item = new Class({
                         item.actionNode.setStyles( this.selector.css.selectorItemActionNode_single );
                     }
                 }
+                if( this.selector.options.showSelectedCount ){
+                    if(item.category)item.category._addSelectedCount( -1, true );
+                }
             }.bind(this));
 
             this.selectedItem.destroy();
@@ -2221,6 +2225,7 @@ MWF.xApplication.Selector.Person.ItemSelected = new Class({
         if (this.items.indexOf(item)===-1) this.items.push(item);
     },
     check: function(){
+        debugger;
         if (this.selector.items.length){
             var items = this.selector.items.filter(function(item, index){
                 return item.data.distinguishedName === this.data.distinguishedName;
@@ -2230,6 +2235,9 @@ MWF.xApplication.Selector.Person.ItemSelected = new Class({
                 items.each(function(item){
                     item.selectedItem = this;
                     item.setSelected();
+                    // if( this.selector.options.showSelectedCount ){
+                    //     if(item.category)item.category._addSelectedCount( 1, true );
+                    // }
                 }.bind(this));
             }
         }
@@ -2434,6 +2442,10 @@ MWF.xApplication.Selector.Person.ItemCategory = new Class({
         var m = this.textNode.getStyle("margin-left").toFloat()+indent;
         this.textNode.setStyle("margin-left", ""+m+"px");
 
+        this.selectedCountNode = new Element("span", {
+            "text": this._getSelectedCount()
+        }).inject(this.textNode);
+
         this.children = new Element("div.children", {
             "styles": this.selector.css.selectorItemCategoryChildrenNode
         }).inject(this.node, "after");
@@ -2484,6 +2496,15 @@ MWF.xApplication.Selector.Person.ItemCategory = new Class({
             "title" : this._getTtiteText()
         }).inject(this.container);
     },
+    _addSelectedCount : function( count, nested ){
+        debugger;
+        var c = ( this._getSelectedCount() || 0 ) + count;
+        this.selectedCount = c;
+        this.selectedCountNode.set("text", c);
+        if( nested && this.category ){
+            this.category._addSelectedCount(count, nested);
+        }
+    },
     isSelectAllEnable : function(){
 
     },