Kaynağa Gözat

身份选择显示分类状态及选择数量

unknown 5 yıl önce
ebeveyn
işleme
25b057e504

+ 6 - 0
o2web/source/x_component_Selector/$Selector/blue_flat/css.wcss

@@ -485,6 +485,12 @@
 	  "float": "left",
 	  "float": "left",
 	  "background": "url(../x_component_Selector/$Selector/blue_flat/icon/checked2.png) no-repeat left center"
 	  "background": "url(../x_component_Selector/$Selector/blue_flat/icon/checked2.png) no-repeat left center"
 	},
 	},
+	"selectorItemCategoryActionNode_selectsome_selected": {
+		"width": "26px",
+		"height": "26px",
+		"float": "left",
+		"background": "url(../x_component_Selector/$Selector/blue_flat/icon/checked_some.png) no-repeat left center"
+	},
 
 
 	"selectorItemTextNode": {
 	"selectorItemTextNode": {
 		"height": "26px",
 		"height": "26px",

BIN
o2web/source/x_component_Selector/$Selector/blue_flat/icon/checked_some.png


+ 55 - 11
o2web/source/x_component_Selector/Identity.js

@@ -778,7 +778,7 @@ MWF.xApplication.Selector.Identity.ItemSelected = new Class({
                 items.each(function(item){
                 items.each(function(item){
                     item.selectedItem = this;
                     item.selectedItem = this;
                     item.setSelected();
                     item.setSelected();
-                    if( this.selector.options.showSelectedCount && this.selector.selectType == "identity" ){
+                    if( this.selector.selectType == "identity" && ( this.selector.options.showSelectedCount || this.selector.options.isCheckStatus ) ){
                         if(item.category && item.category._addSelectedCount )item.category._addSelectedCount( 1, true );
                         if(item.category && item.category._addSelectedCount )item.category._addSelectedCount( 1, true );
                     }
                     }
                 }.bind(this));
                 }.bind(this));
@@ -795,17 +795,50 @@ MWF.xApplication.Selector.Identity.ItemCategory = new Class({
             "title" : this._getTtiteText()
             "title" : this._getTtiteText()
         }).inject(this.container);
         }).inject(this.container);
     },
     },
-    _getShowName: function(){
-        if( this._getTotalCount && this._getSelectedCount ){
-            return "" + this._getTotalCount() + "-" + this._getSelectedCount() + "-" + this.data.name ;
-        }else{
-            return this.data.name;
+    _addSelectedCount : function( count, nested ){
+        var c = ( this._getSelectedCount() || 0 ) + count;
+        this.selectedCount = c;
+        this.checkCountAndStatus( c );
+        if( nested && this.category && this.category._addSelectedCount ){
+            this.category._addSelectedCount(count, nested);
+        }
+    },
+    checkCountAndStatus: function( count ){
+        if( this.selector.options.showSelectedCount ){
+            this.selectedCountNode.set("text", count ? "(" + count + ")" : "" );
+        }
+        if( this.selector.options.isCheckStatus && this.selectAllNode ){
+            var total = this._getTotalCount();
+            if( total ){
+                var styles;
+                if( count >= total ){
+                    styles = this.selector.css.selectorItemCategoryActionNode_selectAll_selected;
+                    this.isSelectedSome = false;
+                    this.isSelectedAll = true;
+                }else if( count > 0 ){
+                    styles = this.selector.css.selectorItemCategoryActionNode_selectsome_selected;
+                    this.isSelectedSome = true;
+                    this.isSelectedAll = false;
+                }else{
+                    styles = this.selector.css.selectorItemCategoryActionNode_selectAll;
+                    this.isSelectedSome = false;
+                    this.isSelectedAll = false;
+                }
+                this.selectAllNode.setStyles( styles );
+            }
         }
         }
     },
     },
+    _getShowName: function(){
+        // if( this._getTotalCount && this._getSelectedCount ){
+        //     return "" + this._getTotalCount() + "-" + this._getSelectedCount() + "-" + this.data.name ;
+        // }else{
+        return this.data.name;
+        // }
+    },
     _getTotalCount : function(){
     _getTotalCount : function(){
-        if( !this.selector.allUnitObject )return "n";
+        if( !this.selector.allUnitObject )return 0;
         var unit =  this.selector.allUnitObject[this.data.levelName];
         var unit =  this.selector.allUnitObject[this.data.levelName];
-        var count = unit ? unit.subNestedIdentityCount : "n";
+        var count = unit ? unit.subNestedIdentityCount : 0;
         return count;
         return count;
     },
     },
     _getSelectedCount : function(){
     _getSelectedCount : function(){
@@ -887,6 +920,11 @@ MWF.xApplication.Selector.Identity.ItemCategory = new Class({
         }
         }
     },
     },
     loadSub: function(callback){
     loadSub: function(callback){
+        this._loadSub( function( firstLoad ) {
+            if(callback)callback();
+        }.bind(this))
+    },
+    _loadSub: function(callback){
         if (!this.loaded){
         if (!this.loaded){
             // if (this.selector.options.dutys && this.selector.options.dutys.length){
             // if (this.selector.options.dutys && this.selector.options.dutys.length){
             //     var ids = [];
             //     var ids = [];
@@ -943,11 +981,11 @@ MWF.xApplication.Selector.Identity.ItemCategory = new Class({
                                 }
                                 }
                             }.bind(this));
                             }.bind(this));
                             this.loaded = true;
                             this.loaded = true;
-                            if (callback) callback();
+                            if (callback) callback( true );
                         }.bind(this), null, this.data.distinguishedName);
                         }.bind(this), null, this.data.distinguishedName);
                     }else{
                     }else{
                         this.loaded = true;
                         this.loaded = true;
-                        if (callback) callback();
+                        if (callback) callback( true );
                     }
                     }
                 }.bind(this), null, this.data.distinguishedName);
                 }.bind(this), null, this.data.distinguishedName);
             // }
             // }
@@ -966,7 +1004,13 @@ MWF.xApplication.Selector.Identity.ItemCategory = new Class({
     _hasChildItem: function(){
     _hasChildItem: function(){
         return (this.data.subDirectIdentityCount) ? this.data.subDirectIdentityCount : 0;
         return (this.data.subDirectIdentityCount) ? this.data.subDirectIdentityCount : 0;
     },
     },
-
+    afterLoad: function(){
+        if (this.level===1) this.clickItem();
+        if( this.selector.options.showSelectedCount || this.selector.options.isCheckStatus ){
+            var count = this._getSelectedCount();
+            this.checkCountAndStatus( count );
+        }
+    },
 
 
     //for flat category start
     //for flat category start
     clickFlatCategoryItem: function( callback, hidden ){
     clickFlatCategoryItem: function( callback, hidden ){

+ 12 - 16
o2web/source/x_component_Selector/IdentityWidthDuty.js

@@ -253,26 +253,22 @@ MWF.xApplication.Selector.IdentityWidthDuty.ItemCategory = new Class({
     },
     },
     _addSelectedCount : function(){
     _addSelectedCount : function(){
         var count = this._getSelectedCount();
         var count = this._getSelectedCount();
-        this.selectedCountNode.set("text", count ? "(" + count + ")" : "");
+        this.checkCountAndStatus(count);
+    },
+    _getTotalCount : function(){
+        return this.subItems.length;
     },
     },
     _getSelectedCount : function(){
     _getSelectedCount : function(){
         var list = this.subItems.filter( function (item) { return item.isSelected; });
         var list = this.subItems.filter( function (item) { return item.isSelected; });
         return list.length;
         return list.length;
-    },
-    _getNestItemCount : function(){
-      return this.subItems.length;
-    },
-    _checkStatus : function(){
-
     },
     },
     loadSub : function(callback){
     loadSub : function(callback){
-        this._loadSub( function() {
-            if( this.selector.options.showSelectedCount ){
-                var count = this._getSelectedCount();
-                this.selectedCountNode.set("text", count ? "(" + count + ")" : "" )
-            }
-            if( this.selector.options.isCheckStatus ){
-
+        this._loadSub( function( firstLoad ) {
+            if(firstLoad){
+                if( this.selector.options.showSelectedCount || this.selector.options.isCheckStatus ){
+                    var count = this._getSelectedCount();
+                    this.checkCountAndStatus(count);
+                }
             }
             }
             if(callback)callback();
             if(callback)callback();
         }.bind(this))
         }.bind(this))
@@ -301,7 +297,7 @@ MWF.xApplication.Selector.IdentityWidthDuty.ItemCategory = new Class({
                         this.loaded = true;
                         this.loaded = true;
                         this.loadingsub = false;
                         this.loadingsub = false;
                         this.itemLoaded = true;
                         this.itemLoaded = true;
-                        if (callback) callback();
+                        if (callback) callback( true );
                     }
                     }
 
 
                 }.bind(this), null, false);
                 }.bind(this), null, false);
@@ -390,7 +386,7 @@ MWF.xApplication.Selector.IdentityWidthDuty.ItemCategory = new Class({
                     }.bind(this));
                     }.bind(this));
                     this.loaded = true;
                     this.loaded = true;
                     this.loadingsub = false;
                     this.loadingsub = false;
-                    if (callback) callback();
+                    if (callback) callback( true );
                 }.bind(this), null, this.data.name);
                 }.bind(this), null, this.data.name);
             }
             }
         }else{
         }else{

+ 24 - 20
o2web/source/x_component_Selector/IdentityWidthDutyCategoryByUnit.js

@@ -426,7 +426,8 @@ MWF.xApplication.Selector.IdentityWidthDutyCategoryByUnit.ItemCategory = new Cla
         debugger;
         debugger;
         var c = (this._getSelectedCount() || 0) + count;
         var c = (this._getSelectedCount() || 0) + count;
         this.selectedCount = c;
         this.selectedCount = c;
-        this.selectedCountNode.set("text", c ? "(" + c + ")" : "");
+        this.checkCountAndStatus(c);
+
         if( nested && this.category && this.category._addSelectedCount ){
         if( nested && this.category && this.category._addSelectedCount ){
             this.category._addSelectedCount(count, nested);
             this.category._addSelectedCount(count, nested);
         }
         }
@@ -435,6 +436,9 @@ MWF.xApplication.Selector.IdentityWidthDutyCategoryByUnit.ItemCategory = new Cla
     //     var list = this.subItems.filter( function (item) { return item.isSelected; });
     //     var list = this.subItems.filter( function (item) { return item.isSelected; });
     //     return list.length;
     //     return list.length;
     // },
     // },
+    _getTotalCount : function(){
+        return this.data.subNestedIdentityCount;
+    },
     _getSelectedCount : function(){
     _getSelectedCount : function(){
         debugger;
         debugger;
         if( typeOf( this.selectedCount ) === "number" ){
         if( typeOf( this.selectedCount ) === "number" ){
@@ -443,9 +447,6 @@ MWF.xApplication.Selector.IdentityWidthDutyCategoryByUnit.ItemCategory = new Cla
             return 0;
             return 0;
         }
         }
     },
     },
-    _getNestItemCount : function(){
-        return this.data.subNestedIdentityCount;
-    },
     _checkStatus : function(){
     _checkStatus : function(){
 
 
     },
     },
@@ -472,7 +473,24 @@ MWF.xApplication.Selector.IdentityWidthDutyCategoryByUnit.ItemCategory = new Cla
             return false;
             return false;
         }
         }
     },
     },
-    loadSub: function(callback){
+    loadSub : function(callback){
+        this._loadSub(function( firstLoad ){
+            if( firstLoad && (this.selector.options.showSelectedCount || this.selector.options.isCheckStatus)){
+                var count = 0;
+                this.subCategorys.each( function (category) {
+                    var l = category.subItems.filter( function (item) { return item.isSelected; });
+                    count = count + l.length;
+                });
+
+                var list = this.subItems.filter( function (item) { return item.isSelected; });
+                this.selectedCount = count+list.length;
+
+                this.checkCountAndStatus(this.selectedCount);
+            }
+            if (callback) callback();
+        }.bind(this))
+    },
+    _loadSub: function(callback){
         if (!this.loaded){
         if (!this.loaded){
             if( this.data.identityList && this.data.identityList.length>0 ){
             if( this.data.identityList && this.data.identityList.length>0 ){
                 this.data.identityList.sort( function(a, b){
                 this.data.identityList.sort( function(a, b){
@@ -505,21 +523,7 @@ MWF.xApplication.Selector.IdentityWidthDutyCategoryByUnit.ItemCategory = new Cla
 
 
             this.loaded = true;
             this.loaded = true;
 
 
-            if( this.selector.options.showSelectedCount ){
-
-                var count = 0;
-                this.subCategorys.each( function (category) {
-                    var l = category.subItems.filter( function (item) { return item.isSelected; });
-                    count = count + l.length;
-                });
-
-                var list = this.subItems.filter( function (item) { return item.isSelected; });
-                this.selectedCount = count+list.length;
-
-                this.selectedCountNode.set("text", this.selectedCount ? "(" + this.selectedCount + ")" : "" );
-            }
-
-            if (callback) callback( );
+            if (callback) callback( true );
         }else{
         }else{
             if (callback) callback( );
             if (callback) callback( );
         }
         }

+ 38 - 35
o2web/source/x_component_Selector/Person.js

@@ -36,7 +36,7 @@ MWF.xApplication.Selector.Person = new Class({
         "flatCategory" : false, //扁平化展现分类,
         "flatCategory" : false, //扁平化展现分类,
         "selectType" : "person",
         "selectType" : "person",
 
 
-        "isCheckStatus" : false,
+        "isCheckStatus" : true,
         "showSelectedCount" : true,
         "showSelectedCount" : true,
 
 
         "itemHeight" : 29,
         "itemHeight" : 29,
@@ -2111,7 +2111,7 @@ MWF.xApplication.Selector.Person.Item = new Class({
                         item.actionNode.setStyles( this.selector.css.selectorItemActionNode_single );
                         item.actionNode.setStyles( this.selector.css.selectorItemActionNode_single );
                     }
                     }
                 }
                 }
-                if( this.selector.options.showSelectedCount && this.selector.selectType == "identity" ){
+                if( this.selector.selectType == "identity" && ( this.selector.options.showSelectedCount || this.selector.options.isCheckStatus ) ){
                     if(item.category && item.category._addSelectedCount )item.category._addSelectedCount( -1, true );
                     if(item.category && item.category._addSelectedCount )item.category._addSelectedCount( -1, true );
                 }
                 }
             }.bind(this));
             }.bind(this));
@@ -2429,11 +2429,11 @@ MWF.xApplication.Selector.Person.ItemCategory = new Class({
             if( this.selector.css.selectorItemCategoryActionNode_selectAll_over ){
             if( this.selector.css.selectorItemCategoryActionNode_selectAll_over ){
                 this.selectAllNode.addEvents( {
                 this.selectAllNode.addEvents( {
                     "mouseover" : function(ev){
                     "mouseover" : function(ev){
-                        if( !this.isSelectedAll )this.selectAllNode.setStyles( this.selector.css.selectorItemCategoryActionNode_selectAll_over );
+                        if( !this.isSelectedAll && !this.isSelectedSome )this.selectAllNode.setStyles( this.selector.css.selectorItemCategoryActionNode_selectAll_over );
                         //ev.stopPropagation();
                         //ev.stopPropagation();
                     }.bind(this),
                     }.bind(this),
                     "mouseout" : function(ev){
                     "mouseout" : function(ev){
-                        if( !this.isSelectedAll )this.selectAllNode.setStyles( this.selector.css.selectorItemCategoryActionNode_selectAll );
+                        if( !this.isSelectedAll && !this.isSelectedSome )this.selectAllNode.setStyles( this.selector.css.selectorItemCategoryActionNode_selectAll );
                         //ev.stopPropagation();
                         //ev.stopPropagation();
                     }.bind(this)
                     }.bind(this)
                 })
                 })
@@ -2447,11 +2447,8 @@ MWF.xApplication.Selector.Person.ItemCategory = new Class({
         var m = this.textNode.getStyle("margin-left").toFloat()+indent;
         var m = this.textNode.getStyle("margin-left").toFloat()+indent;
         this.textNode.setStyle("margin-left", ""+m+"px");
         this.textNode.setStyle("margin-left", ""+m+"px");
 
 
-        if( this.selector.options.showSelectedCount && this.selector.selectType == "identity" && this._getSelectedCount ){
-            var c = this._getSelectedCount();
-            this.selectedCountNode = new Element("span", {
-                "text":  c ? "(" + c + ")" : ""
-            }).inject(this.textNode);
+        if( this.selector.options.showSelectedCount && this.selector.selectType == "identity" ){
+            this.selectedCountNode = new Element("span").inject(this.textNode);
         }
         }
 
 
         this.children = new Element("div.children", {
         this.children = new Element("div.children", {
@@ -2503,36 +2500,34 @@ MWF.xApplication.Selector.Person.ItemCategory = new Class({
             "styles": this.selector.css.selectorItemCategory,
             "styles": this.selector.css.selectorItemCategory,
             "title" : this._getTtiteText()
             "title" : this._getTtiteText()
         }).inject(this.container);
         }).inject(this.container);
-    },
-    _addSelectedCount : function( count, nested ){
-        debugger;
-        var c = ( this._getSelectedCount() || 0 ) + count;
-        this.selectedCount = c;
-        this.selectedCountNode.set("text", c ? "(" + c + ")" : "" );
-        if( nested && this.category && this.category._addSelectedCount ){
-            this.category._addSelectedCount(count, nested);
-        }
-    },
-    isSelectAllEnable : function(){
-
     },
     },
     unselectAll : function(ev, exclude, checkValid ){
     unselectAll : function(ev, exclude, checkValid ){
-        var excludeList = exclude || [];
-        if( exclude && typeOf(exclude) !== "array"  )excludeList = [exclude];
-        ( this.subItems || [] ).each( function(item){
-            if(item.isSelected && !excludeList.contains(item) ){
-                item.unSelected( checkValid );
-            }
-        }.bind(this));
+        var fun = function(){
+            var excludeList = exclude || [];
+            if( exclude && typeOf(exclude) !== "array"  )excludeList = [exclude];
+            ( this.subItems || [] ).each( function(item){
+                if(item.isSelected && !excludeList.contains(item) ){
+                    item.unSelected( checkValid );
+                }
+            }.bind(this));
 
 
-        if( this.selectAllNode ){
-            if( this.selector.isFlatCategory ){
-                this.selectAllNode.setStyles( this.selector.css.flatCategory_selectAll );
-            }else if(this.selector.css.selectorItemCategoryActionNode_selectAll){
-                this.selectAllNode.setStyles( this.selector.css.selectorItemCategoryActionNode_selectAll );
+            if( this.selectAllNode ){
+                if( this.selector.isFlatCategory ){
+                    this.selectAllNode.setStyles( this.selector.css.flatCategory_selectAll );
+                }else if(this.selector.css.selectorItemCategoryActionNode_selectAll){
+                    this.selectAllNode.setStyles( this.selector.css.selectorItemCategoryActionNode_selectAll );
+                }
             }
             }
+            this.isSelectedAll = false;
+        }.bind(this);
+
+        if( this.loaded ){
+            fun();
+        }else{
+            this.clickItem( function(){
+                fun();
+            }.bind(this))
         }
         }
-        this.isSelectedAll = false;
     },
     },
     unselectAllNested : function( ev, exclude, checkValid ){
     unselectAllNested : function( ev, exclude, checkValid ){
         this.unselectAll(ev, exclude, checkValid);
         this.unselectAll(ev, exclude, checkValid);
@@ -2595,7 +2590,15 @@ MWF.xApplication.Selector.Person.ItemCategory = new Class({
                     if( this.selector.isFlatCategory ){
                     if( this.selector.isFlatCategory ){
                         this.selectAllNode.setStyles( this.selector.css.flatCategory_selectAll_selected );
                         this.selectAllNode.setStyles( this.selector.css.flatCategory_selectAll_selected );
                     }else if(this.selector.css.selectorItemCategoryActionNode_selectAll_selected){
                     }else if(this.selector.css.selectorItemCategoryActionNode_selectAll_selected){
-                        this.selectAllNode.setStyles( this.selector.css.selectorItemCategoryActionNode_selectAll_selected );
+
+                        var styles = this.selector.css.selectorItemCategoryActionNode_selectAll_selected;
+
+                        if( this.selector.options.isCheckStatus && this.selector.selectType === "identity" ){
+                            if( this._getSelectedCount() < this._getTotalCount() ){
+                                styles = this.selector.css.selectorItemCategoryActionNode_selectsome_selected;
+                            }
+                        }
+                        this.selectAllNode.setStyles( styles );
                     }
                     }
                 }
                 }
                 this.isSelectedAll = true;
                 this.isSelectedAll = true;