Bladeren bron

Merge branch 'feature/Selector.add_category_status' into 'wrdp'

Merge of feature/Selector.add_category_status 身份选择的分类允许显示选择数字和选择状态 to wrdp

See merge request o2oa/o2oa!1777
胡起 5 jaren geleden
bovenliggende
commit
e557037b99
34 gewijzigde bestanden met toevoegingen van 1043 en 269 verwijderingen
  1. 6 0
      o2web/source/x_component_Selector/$Selector/blue_flat/css.wcss
  2. BIN
      o2web/source/x_component_Selector/$Selector/blue_flat/icon/checked_some.png
  3. 7 0
      o2web/source/x_component_Selector/$Selector/blue_flat_mobile/css.wcss
  4. BIN
      o2web/source/x_component_Selector/$Selector/blue_flat_mobile/icon/checked_some@2x.png
  5. 7 0
      o2web/source/x_component_Selector/$Selector/red_flat_mobile/css.wcss
  6. BIN
      o2web/source/x_component_Selector/$Selector/red_flat_mobile/icon/checked_some@2x.png
  7. 4 1
      o2web/source/x_component_Selector/Application.js
  8. 4 1
      o2web/source/x_component_Selector/CMSApplication.js
  9. 4 1
      o2web/source/x_component_Selector/CMSCategory.js
  10. 4 0
      o2web/source/x_component_Selector/CMSFormField.js
  11. 4 1
      o2web/source/x_component_Selector/CMSView.js
  12. 4 0
      o2web/source/x_component_Selector/Dictionary.js
  13. 4 1
      o2web/source/x_component_Selector/Duty.js
  14. 4 1
      o2web/source/x_component_Selector/FormField.js
  15. 4 0
      o2web/source/x_component_Selector/FormStyle.js
  16. 4 0
      o2web/source/x_component_Selector/Group.js
  17. 498 78
      o2web/source/x_component_Selector/Identity.js
  18. 189 84
      o2web/source/x_component_Selector/IdentityWidthDuty.js
  19. 129 37
      o2web/source/x_component_Selector/IdentityWidthDutyCategoryByUnit.js
  20. 92 33
      o2web/source/x_component_Selector/Person.js
  21. 4 1
      o2web/source/x_component_Selector/Portal.js
  22. 4 1
      o2web/source/x_component_Selector/PortalFile.js
  23. 4 1
      o2web/source/x_component_Selector/Process.js
  24. 4 1
      o2web/source/x_component_Selector/ProcessFile.js
  25. 4 1
      o2web/source/x_component_Selector/Query.js
  26. 4 1
      o2web/source/x_component_Selector/QueryStat.js
  27. 4 0
      o2web/source/x_component_Selector/QueryTable.js
  28. 4 1
      o2web/source/x_component_Selector/QueryView.js
  29. 4 1
      o2web/source/x_component_Selector/Role.js
  30. 4 0
      o2web/source/x_component_Selector/Script.js
  31. 23 17
      o2web/source/x_component_Selector/Unit.js
  32. 6 3
      o2web/source/x_component_Selector/UnitWithType.js
  33. 4 1
      o2web/source/x_component_Selector/View.js
  34. 2 2
      o2web/source/x_component_Selector/package.js

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

@@ -485,6 +485,12 @@
 	  "float": "left",
 	  "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": {
 		"height": "26px",

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


+ 7 - 0
o2web/source/x_component_Selector/$Selector/blue_flat_mobile/css.wcss

@@ -444,6 +444,13 @@
 	  "background": "url(../x_component_Selector/$Selector/blue_flat_mobile/icon/checked@2x.png) no-repeat left center",
 	  "background-size" : "16px 16px"
 	},
+	"selectorItemCategoryActionNode_selectsome_selected": {
+		"width": "16px",
+		"height": "44px",
+		"float": "right",
+		"background": "url(../x_component_Selector/$Selector/blue_flat_mobile/icon/checked_some@2x.png) no-repeat left center",
+		"background-size" : "16px 16px"
+	},
 
 	"selectorItemTextNode": {
 		"height": "44px",

BIN
o2web/source/x_component_Selector/$Selector/blue_flat_mobile/icon/checked_some@2x.png


+ 7 - 0
o2web/source/x_component_Selector/$Selector/red_flat_mobile/css.wcss

@@ -445,6 +445,13 @@
 	  "background": "url(../x_component_Selector/$Selector/red_flat_mobile/icon/checked@2x.png) no-repeat left center",
 	  "background-size" : "16px 16px"
 	},
+	"selectorItemCategoryActionNode_selectsome_selected": {
+		"width": "16px",
+		"height": "44px",
+		"float": "right",
+		"background": "url(../x_component_Selector/$Selector/red_flat_mobile/icon/checked_some@2x.png) no-repeat left center",
+		"background-size" : "16px 16px"
+	},
 
 	"selectorItemTextNode": {
 		"height": "44px",

BIN
o2web/source/x_component_Selector/$Selector/red_flat_mobile/icon/checked_some@2x.png


+ 4 - 1
o2web/source/x_component_Selector/Application.js

@@ -10,7 +10,10 @@ MWF.xApplication.Selector.Application = new Class({
         "expand": false,
         "forceSearchInItem" : true
     },
-
+    _init : function(){
+        this.selectType = "application";
+        this.className = "Application"
+    },
     loadSelectItems: function(addToNext){
         this.processAction.listApplications(function(json){
             json.data.each(function(data){

+ 4 - 1
o2web/source/x_component_Selector/CMSApplication.js

@@ -11,7 +11,10 @@ MWF.xApplication.Selector.CMSApplication = new Class({
         "expand": false,
         "forceSearchInItem" : true
     },
-
+    _init : function(){
+        this.selectType = "application";
+        this.className = "CMSApplication"
+    },
     loadSelectItems: function(addToNext){
         this.cmsAction.listCMSApplication(function(json){
             json.data.each(function(data){

+ 4 - 1
o2web/source/x_component_Selector/CMSCategory.js

@@ -11,7 +11,10 @@ MWF.xApplication.Selector.CMSCategory = new Class({
         "expand": false,
         "forceSearchInItem" : true
     },
-
+    _init : function(){
+        this.selectType = "cmscategory";
+        this.className = "CMSCategory"
+    },
     loadSelectItems: function(addToNext){
         this.cmsAction.listCMSApplication(function(json){
             if (json.data.length){

+ 4 - 0
o2web/source/x_component_Selector/CMSFormField.js

@@ -14,6 +14,10 @@ MWF.xApplication.Selector.CMSFormField = new Class({
         "expand": false,
         "forceSearchInItem" : true
     },
+    _init : function(){
+        this.selectType = "formfield";
+        this.className = "CMSFormField";
+    },
     getFields : function(){
         var dataTypes = {
             "string": ["htmledit", "radio", "select", "textarea", "textfield"],

+ 4 - 1
o2web/source/x_component_Selector/CMSView.js

@@ -11,7 +11,10 @@ MWF.xApplication.Selector.CMSView = new Class({
         "expand": false,
         "forceSearchInItem" : true
     },
-
+    _init : function(){
+        this.selectType = "cmsview";
+        this.className = "CMSView";
+    },
     loadSelectItems: function(addToNext){
         this.cmsAction.listCMSApplicationView(function(json){
             if (json.data.length){

+ 4 - 0
o2web/source/x_component_Selector/Dictionary.js

@@ -12,6 +12,10 @@ MWF.xApplication.Selector.Dictionary = new Class({
         "expand": false,
         "forceSearchInItem" : true
     },
+    _init : function(){
+        this.selectType = "dictionary";
+        this.className = "Dictionary";
+    },
     loadSelectItems: function(addToNext){
         var json = {};
         this.options.appType.each( function (type) {

+ 4 - 1
o2web/source/x_component_Selector/Duty.js

@@ -9,7 +9,10 @@ MWF.xApplication.Selector.Duty = new Class({
         "values": [],
         "expand": false
     },
-
+    _init : function(){
+        this.selectType = "duty";
+        this.className = "Duty";
+    },
     loadSelectItems: function(addToNext){
         this.orgAction.listUnitdutyName(function(json){
            json.data.nameList.each(function(data){

+ 4 - 1
o2web/source/x_component_Selector/FormField.js

@@ -13,7 +13,10 @@ MWF.xApplication.Selector.FormField = new Class({
         "expand": false,
         "forceSearchInItem" : true
     },
-
+    _init : function(){
+        this.selectType = "formfield";
+        this.className = "FormField";
+    },
     loadSelectItems: function(addToNext){
         if (this.options.application){
             this.designerAction.listFormField(this.options.application, function(json){

+ 4 - 0
o2web/source/x_component_Selector/FormStyle.js

@@ -12,6 +12,10 @@ MWF.xApplication.Selector.FormStyle = new Class({
         "mode" : "pc",
         "forceSearchInItem" : true
     },
+    _init : function(){
+        this.selectType = "formstyle";
+        this.className = "FormStyle";
+    },
     loadSelectItems: function(addToNext){
         var stylesUrl = "../x_component_process_FormDesigner/Module/Form/skin/config.json";
         MWF.getJSON(stylesUrl,{

+ 4 - 0
o2web/source/x_component_Selector/Group.js

@@ -12,6 +12,10 @@ MWF.xApplication.Selector.Group = new Class({
         "include" : [],
         "selectType" : "group"
     },
+    _init : function(){
+        this.selectType = "group";
+        this.className = "Group";
+    },
     checkLoadSelectItems: function(){
         if( this.options.include && this.options.include.length ){
             this.loadInclude();

+ 498 - 78
o2web/source/x_component_Selector/Identity.js

@@ -16,12 +16,111 @@ MWF.xApplication.Selector.Identity = new Class({
         "exclude" : [], //排除的可选项
         "resultType" : "", //可以设置成个人,那么结果返回个人
         "expandSubEnable" : true, //是否允许展开下一层,
-        "selectAllEnable" : true,  //分类是否允许全选下一层
-        "selectType" : "identity"
+        "selectAllEnable" : true  //分类是否允许全选下一层
     },
-    loadSelectItems: function(addToNext){
-        debugger;
+    _init : function(){
+        this.selectType = "identity";
+        this.className = "Identity";
+    },
+    loadSelectItems : function(){
+        if( this.className === "Identity" && (this.options.isCheckStatus || this.options.showSelectedCount )) {
+
+            var unitList = [];
+            var groupList = [];
+
+            var parseInclude = function () {
+                if (this.options.include.length > 0) {
+                    this.options.include.each(function (d) {
+                        var dn = typeOf(d) === "string" ? d : d.distinguishedName;
+                        var flag = dn.split("@").getLast().toLowerCase();
+                        if (flag === "u") {
+                            unitList.push(dn);
+                        } else if (flag === "g") {
+                            groupList.push(dn)
+                        }
+                    })
+                }
+            }.bind(this);
+
+            var load = function () {
+
+                var unitLoaded, groupLoaded, selectedIdentityLoaded, excludeIdentityLoaded;
+                var unitTree, groupTree;
+                this.unitExcludedIdentityCount = {};
+                this.groupExcludedIdentityCount = {};
+                this.unitSelectedIdentityCount = {};
+                this.groupSelectedIdentityCount = {};
+
+                var caculate = function () {
+                    if (unitLoaded && groupLoaded && selectedIdentityLoaded && excludeIdentityLoaded) {
+                        this.caculateNestedSubCount(unitTree, groupTree, function () {
+                            debugger;
+                            this._loadSelectItems()
+                        }.bind(this))
+
+                    }
+                }.bind(this);
+
+                this.getIdentityCountMap(this.options.values, groupList && groupList.length > 0, function (result) {
+                    this.unitSelectedIdentityCount = result.unitMap;
+                    this.groupSelectedIdentityCount = result.groupMap;
+                    selectedIdentityLoaded = true;
+                    caculate();
+                }.bind(this));
+
+                this.getIdentityCountMap(this.options.exclude, groupList && groupList.length > 0, function (result) {
+                    this.unitExcludedIdentityCount = result.unitMap;
+                    this.groupExcludedIdentityCount = result.groupMap;
+                    excludeIdentityLoaded = true;
+                    caculate();
+                }.bind(this));
+
+                if (unitList && unitList.length > 0) {
+                    o2.Actions.load("x_organization_assemble_express").UnitAction.listWithUnitTree({"unitList": unitList}, function (json) {
+                        unitTree = json.data;
+                        unitLoaded = true;
+                        caculate();
+                    }.bind(this))
+                } else {
+                    unitLoaded = true;
+                    caculate();
+                }
+
+                if (groupList && groupList.length > 0) {
+                    o2.Actions.load("x_organization_assemble_express").GroupAction.listWithGroupTree({"groupList": groupList}, function (json) {
+                        groupTree = json.data;
+                        groupLoaded = true;
+                        caculate();
+                    }.bind(this))
+                } else {
+                    groupLoaded = true;
+                    caculate();
+                }
+            }.bind(this);
 
+            if (this.options.noUnit) {
+                parseInclude();
+                load();
+            } else if (this.options.units.length) {
+                parseInclude();
+                this.options.units.each(function (u) {
+                    unitList.push(typeOf(u) === "string" ? u : (u.distinguishedName || u.id || u.unique || u.levelName))
+                }.bind(this));
+                load();
+            } else {
+                this.orgAction.listTopUnit(function (json) {
+                    this.topUnitObj = json.data;
+                    this.topUnitObj.each(function (u) {
+                        unitList.push(u.distinguishedName)
+                    }.bind(this));
+                    load();
+                }.bind(this))
+            }
+        }else{
+            this._loadSelectItems()
+        }
+    },
+    _loadSelectItems: function(addToNext){
         var afterLoadSelectItemFun = this.afterLoadSelectItem.bind(this);
         if( this.options.resultType === "person" ){
             if( this.titleTextNode ){
@@ -57,6 +156,7 @@ MWF.xApplication.Selector.Identity = new Class({
                     unitList.push(unit.id ||  unit.distinguishedName || unit.unique || unit.levelName);
                 }
             }
+
             o2.Actions.load("x_organization_assemble_express").UnitAction.listObject( {"unitList" : unitList} , function (json) {
                 if (json.data.length){
                     json.data.each( function(data){
@@ -67,7 +167,6 @@ MWF.xApplication.Selector.Identity = new Class({
                 loadUnitSuccess();
             }.bind(this), loadUnitFailure );
 
-
             // var unitLoaded = 0;
             //
             // var loadUnitSuccess = function () {
@@ -128,8 +227,8 @@ MWF.xApplication.Selector.Identity = new Class({
             //     }
             // }.bind(this));
 
-            this.orgAction.listTopUnit(function(json){
-                json.data.each(function(data){
+            var load = function ( topUnit ) {
+                topUnit.each(function(data){
                     if( !this.isExcluded( data ) ){
                         var category = this._newItemCategory("ItemUnitCategory", data, this, this.itemAreaNode);
                         this.subCategorys.push( category );
@@ -140,8 +239,15 @@ MWF.xApplication.Selector.Identity = new Class({
                 // if( this.includeLoaded ){
                 afterLoadSelectItemFun();
                 // }
+            }.bind(this);
 
-            }.bind(this));
+            if( this.topUnitObj ){
+                load( this.topUnitObj );
+            }else{
+                this.orgAction.listTopUnit(function(json){
+                    load( json.data );
+                }.bind(this));
+            }
         }
     },
 
@@ -214,8 +320,8 @@ MWF.xApplication.Selector.Identity = new Class({
     _listItemByPinyin: function(callback, failure, key){
         this._listItem( "pinyin", callback, failure, key );
     },
-    _newItem: function(data, selector, container, level, category){
-        return new MWF.xApplication.Selector.Identity.Item(data, selector, container, level, category);
+    _newItem: function(data, selector, container, level, category, delay){
+        return new MWF.xApplication.Selector.Identity.Item(data, selector, container, level, category, delay);
     },
     _newItemSearch: function(data, selector, container, level){
         return new MWF.xApplication.Selector.Identity.SearchItem(data, selector, container, level);
@@ -265,12 +371,247 @@ MWF.xApplication.Selector.Identity = new Class({
         if( this.dutyDnList.length )keyObj.unitDutyList = this.dutyDnList;
 
         return units.length ? keyObj : key;
-    }
+    },
     //_listItemNext: function(last, count, callback){
     //    this.action.listRoleNext(last, count, function(json){
     //        if (callback) callback.apply(this, [json]);
     //    }.bind(this));
     //}
+
+    getIdentityAllLevelName : function(identityList, byGroup, callback){
+        var result = {
+            unitMap : {},
+            groupMap : {}
+        };
+        this.listIndetityObject( identityList, function ( list, map ) {
+            list.each( function (id) {
+                if(id.unitLevelName){
+                    result.unitMap[ id.unitLevelName ] = ( result.unitMap[ id.unitLevelName ] || 0 )+1;
+                }
+            }.bind(this));
+            if( byGroup ) {
+                this.listLevelNameGroupMap(list, function ( levelNameGroupMap ) {
+                    for( var key in levelNameGroupMap ){
+                        var group = levelNameGroupMap[key]
+                        var identityCount = group["identityList"].length;
+                        if(identityCount)result.groupMap[key] = identityCount;
+                    }
+                    if( callback )callback( result );
+                }.bind(this));
+            }else{
+                if( callback )callback( result );
+            }
+        }.bind(this));
+    },
+    getIdentityCountMap : function( identityList, byGroup, callback ){
+        var result = {
+            unitMap : {},
+            groupMap : {}
+        };
+        this.listIndetityObject( identityList, function ( list, map ) {
+            list.each( function (id) {
+                if(id.unitLevelName){
+                    result.unitMap[ id.unitLevelName ] = ( result.unitMap[ id.unitLevelName ] || 0 )+1;
+                }
+            }.bind(this));
+            if( byGroup ) {
+                this.listLevelNameGroupMap(list, function ( levelNameGroupMap ) {
+                    for( var key in levelNameGroupMap ){
+                        var group = levelNameGroupMap[key]
+                        var identityCount = group["identityList"].length;
+                        if(identityCount)result.groupMap[key] = identityCount;
+                    }
+                   if( callback )callback( result );
+                }.bind(this));
+            }else{
+                if( callback )callback( result );
+            }
+        }.bind(this));
+    },
+    listIndetityObject : function( identityList, callback ){
+        var list = [];
+        identityList.each( function (d) {
+            if( typeOf( d ) === "object"){
+                if( !d.unitLevelName || !d.distinguishedName )list.push( d.distinguishedName || d.id || d.unique )
+            }else{
+                list.push( d )
+            }
+        });
+        if( list.length > 0 ){
+            o2.Actions.load("x_organization_assemble_express").IdentityAction.listObject({ identityList : list }, function (json) {
+                var map = {};
+                json.data.each( function (d) { map[ d.matchKey ] =  d; });
+                var result = [];
+                identityList.each( function (d) {
+                    var key = typeOf( d ) === "object" ? ( d.distinguishedName || d.id || d.unique ) : d;
+                    result.push( map[key] ? map[key] : d );
+                });
+                if( callback )callback( result, map );
+            }.bind(this))
+        }else{
+            if( callback )callback( identityList, {} );
+        }
+    },
+
+    listLevelNameGroupMap : function(identityList, callback, referenceFlag, recursiveOrgFlag){
+        var list = identityList.map( function (d) { return d.distinguishedName; }).clean();
+        if( list.length > 0 ){
+            o2.Actions.load("x_organization_assemble_express").GroupAction.listWithIdentityObject( {
+                recursiveGroupFlag : true, identityList : list, referenceFlag : !!referenceFlag, recursiveOrgFlag : !!recursiveOrgFlag
+            }, function (json) {
+                var map = {};
+                var groupList = json.data;
+                groupList.each( function (d) { map[ d.distinguishedName ] = d; });
+                groupList.each( function (d) {
+                    d.identityList = d.identityList.filter( function (id) { return list.contains(id) });
+                    d.groupObjectList  = [];
+                    d.groupList.each( function (g) { if(map[g])d.groupObjectList.push( map[g] ) })
+                });
+
+                var groupIdentityMap = {};
+                var fun = function ( group, parentName ) {
+                    var levelName = parentName ? ( parentName + "/" + group.name ) : group.name;
+                    groupIdentityMap[ levelName ] = group;
+                    group.groupObjectList.each( function( g ){
+                        fun( g, levelName );
+                    })
+                };
+
+                groupList.each( function (d) { fun(d) });
+
+                if( callback )callback( groupIdentityMap );
+            }.bind(this))
+        }else{
+            if( callback )callback({});
+        }
+    },
+
+    caculateNestedSubCount : function(unitTree, groupTree, callback){
+        if( !this.allUnitObject )this.allUnitObject = {};
+        if( !this.allGroupObject )this.allGroupObject = {};
+        if( !this.allGroupObjectByDn )this.allGroupObjectByDn = {};
+
+        if( groupTree && groupTree.length ){
+            groupTree.each( function ( tree ) {
+                this.caculateGroupNestedCount( tree );
+            }.bind(this) );
+        }
+
+        if( unitTree && unitTree.length ){
+            unitTree.each( function ( tree ) {
+                if( !this.allUnitObject[ tree.levelName ] ){
+                    this.caculateUnitNestedCount( tree );
+                }
+            }.bind(this) );
+        }
+
+        if( this.allGroupObject ){
+            for( var k in this.allGroupObject ){
+                var obj = this.allGroupObject[k];
+                this.allGroupObjectByDn[ obj.distinguishedName ] = obj;
+            }
+        }
+
+        if(callback)callback();
+    },
+    caculateGroupNestedCount : function( tree, parentLevelName ){
+        if( this.isExcluded( tree ) )return;
+        var groupLevelName = parentLevelName ? ( parentLevelName + "/" + tree.distinguishedName.split("@")[0] ) : tree.distinguishedName.split("@")[0];
+        if(!this.allGroupObject[ groupLevelName ]){
+            this.allGroupObject[ groupLevelName ] = tree;
+        }else{
+            return;
+        }
+
+        // tree.subDirectIdentityCount
+        var count = tree.subDirectIdentityCount;
+        if( this.groupExcludedIdentityCount && this.groupExcludedIdentityCount[ groupLevelName ] ){
+            count = (count || 0) - this.groupExcludedIdentityCount[ groupLevelName ];
+        }
+
+        var selectedCount = 0;
+        if( this.groupSelectedIdentityCount && this.groupSelectedIdentityCount[ groupLevelName ] ){
+            selectedCount = this.groupSelectedIdentityCount[ groupLevelName ];
+        }
+
+        var nameList = groupLevelName.split("/");
+        var names = [];
+        nameList.each( function (n) {
+            names.push( n );
+            var levelName = names.join("/");
+            var groupObject = this.allGroupObject[levelName];
+            if( groupObject ){
+                groupObject.subNestedIdentityCount = (groupObject.subNestedIdentityCount || 0) + count;
+                groupObject.selectedNestedIdentityCount = (groupObject.selectedNestedIdentityCount || 0) + selectedCount;
+            }
+        }.bind(this));
+
+        tree.subGroups.each( function (group) {
+            this.caculateGroupNestedCount( group, groupLevelName );
+        }.bind(this));
+
+        tree.subUnits.each( function (unit) {
+            var flag = this.allUnitObject[ unit.levelName ];
+            this.caculateUnitNestedCount( unit, groupLevelName, !!flag )
+        }.bind(this))
+
+    },
+
+    caculateUnitNestedCount : function ( tree, groupLevelName, flag ) {
+        if( this.isExcluded( tree ) )return;
+        var count;
+        var selectedCount;
+        if(!this.allUnitObject[ tree.levelName ]){
+            this.allUnitObject[ tree.levelName ] = tree;
+            count = tree.subDirectIdentityCount;
+            if( this.unitExcludedIdentityCount && this.unitExcludedIdentityCount[ tree.levelName ] ){
+                count = (count || 0) - this.unitExcludedIdentityCount[ tree.levelName ];
+            }
+
+            selectedCount = 0;
+            if( this.unitSelectedIdentityCount && this.unitSelectedIdentityCount[ tree.levelName ] ){
+                selectedCount = this.unitSelectedIdentityCount[ tree.levelName ];
+            }
+        }else if( !flag ){
+            return;
+        }else{
+            count = this.allUnitObject[ tree.levelName ].subNestedIdentityCount || 0;
+            count = this.allUnitObject[ tree.levelName ].selectedNestedIdentityCount || 0;
+        }
+
+        if( groupLevelName ){
+            var groupNameList = groupLevelName.split("/");
+            var groupNames = [];
+            groupNameList.each( function (n) {
+                groupNames.push( n );
+                var levelName = groupNames.join("/");
+                var groupObject = this.allGroupObject[levelName];
+                if( groupObject ){
+                    groupObject.subNestedIdentityCount = (groupObject.subNestedIdentityCount || 0) + count;
+                    groupObject.selectedNestedIdentityCount = (groupObject.selectedNestedIdentityCount || 0) + selectedCount;
+                }
+            }.bind(this));
+        }
+
+        if( !flag ){
+            var nameList = tree.levelName.split("/");
+            var names = [];
+            nameList.each( function (n) {
+                names.push( n );
+                var levelName = names.join("/");
+                var unitObject = this.allUnitObject[levelName];
+                if( unitObject ){
+                    unitObject.subNestedIdentityCount = (unitObject.subNestedIdentityCount || 0) + count;
+                    unitObject.selectedNestedIdentityCount = (unitObject.selectedNestedIdentityCount || 0) + selectedCount;
+                }
+            }.bind(this));
+
+            tree.subUnits.each( function (unit) {
+                this.caculateUnitNestedCount( unit, groupLevelName )
+            }.bind(this))
+        }
+    }
+
 });
 
 
@@ -307,7 +648,7 @@ MWF.xApplication.Selector.Identity.Item = new Class({
                 if (callback) callback();
             }
         }else{
-            if (!this.data.woPerson){
+            if (!this.data.woPerson && (!this.data.personDn || !this.data.personEmployee || !this.data.personUnique)){
                 this.selector.orgAction.getPerson(function(json){
                     this.data.woPerson = json.data;
                     if (callback) callback();
@@ -383,7 +724,7 @@ MWF.xApplication.Selector.Identity.ItemSelected = new Class({
             }else{
                 if (callback) callback();
             }
-        }else if (!this.data.woPerson){
+        }else if (!this.data.woPerson && (!this.data.personDn || !this.data.personEmployee || !this.data.personUnique) ){
             if (this.data.person){
                 this.selector.orgAction.getPerson(function(json){
                     this.data.woPerson = json.data;
@@ -437,6 +778,9 @@ MWF.xApplication.Selector.Identity.ItemSelected = new Class({
                 items.each(function(item){
                     item.selectedItem = this;
                     item.setSelected();
+                    if( this.selector.selectType == "identity" && ( this.selector.options.showSelectedCount || this.selector.options.isCheckStatus ) ){
+                        if(item.category && item.category._addSelectedCount )item.category._addSelectedCount( 1, true );
+                    }
                 }.bind(this));
             }
         }
@@ -451,8 +795,59 @@ MWF.xApplication.Selector.Identity.ItemCategory = new Class({
             "title" : this._getTtiteText()
         }).inject(this.container);
     },
+    _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(){
+        if( !this.selector.allUnitObject )return 0;
+        var unit =  this.selector.allUnitObject[this.data.levelName];
+        var count = unit ? unit.subNestedIdentityCount : 0;
+        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(){
         var style = this.selector.options.style;
@@ -525,43 +920,48 @@ MWF.xApplication.Selector.Identity.ItemCategory = new Class({
         }
     },
     loadSub: function(callback){
+        this._loadSub( function( firstLoad ) {
+            if(callback)callback();
+        }.bind(this))
+    },
+    _loadSub: function(callback){
         if (!this.loaded){
-            if (this.selector.options.dutys && this.selector.options.dutys.length){
-                var ids = [];
-                var object = {};
-                this.selector.options.dutys.each(function(duty){
-                    this.selector.orgAction.listIdentityWidthUnitWithDutyName(this.data.distinguishedName, duty, function(json){
-                        if (json.data && json.data.length){
-                            ids = ids.concat(json.data);
-                        }
-                    }.bind(this), null, false);
-
-                    ids.each(function(idSubData){
-                        if( !this.selector.isExcluded( idSubData ) && !object[ idSubData.id || idSubData.distinguishedName ]) {
-                            var item = this.selector._newItem(idSubData, this.selector, this.children, this.level + 1, this);
-                            this.selector.items.push(item);
-                            if(this.subItems)this.subItems.push( item );
-                            object[ idSubData.id || idSubData.distinguishedName ] = true;
-                        }
-                    }.bind(this));
-                }.bind(this));
-
-                if( this.selector.options.expandSubEnable ){
-                    this.selector.orgAction.listSubUnitDirect(function(json){
-                        json.data.each(function(subData){
-                            if( !this.selector.isExcluded( subData ) ) {
-                                var category = this.selector._newItemCategory("ItemUnitCategory", subData, this.selector, this.children, this.level + 1, this);
-                                this.subCategorys.push( category );
-                            }
-                        }.bind(this));
-                        this.loaded = true;
-                        if(callback)callback();
-                    }.bind(this), null, this.data.distinguishedName);
-                }else{
-                    this.loaded = true;
-                    if(callback)callback();
-                }
-            }else{
+            // if (this.selector.options.dutys && this.selector.options.dutys.length){
+            //     var ids = [];
+            //     var object = {};
+            //     this.selector.options.dutys.each(function(duty){
+            //         this.selector.orgAction.listIdentityWidthUnitWithDutyName(this.data.distinguishedName, duty, function(json){
+            //             if (json.data && json.data.length){
+            //                 ids = ids.concat(json.data);
+            //             }
+            //         }.bind(this), null, false);
+            //
+            //         ids.each(function(idSubData){
+            //             if( !this.selector.isExcluded( idSubData ) && !object[ idSubData.id || idSubData.distinguishedName ]) {
+            //                 var item = this.selector._newItem(idSubData, this.selector, this.children, this.level + 1, this);
+            //                 this.selector.items.push(item);
+            //                 if(this.subItems)this.subItems.push( item );
+            //                 object[ idSubData.id || idSubData.distinguishedName ] = true;
+            //             }
+            //         }.bind(this));
+            //     }.bind(this));
+            //
+            //     if( this.selector.options.expandSubEnable ){
+            //         this.selector.orgAction.listSubUnitDirect(function(json){
+            //             json.data.each(function(subData){
+            //                 if( !this.selector.isExcluded( subData ) ) {
+            //                     var category = this.selector._newItemCategory("ItemUnitCategory", subData, this.selector, this.children, this.level + 1, this);
+            //                     this.subCategorys.push( category );
+            //                 }
+            //             }.bind(this));
+            //             this.loaded = true;
+            //             if(callback)callback();
+            //         }.bind(this), null, this.data.distinguishedName);
+            //     }else{
+            //         this.loaded = true;
+            //         if(callback)callback();
+            //     }
+            // }else{
 
                 this.selector.orgAction.listIdentityWithUnit(function(idJson){
                     idJson.data.each(function(idSubData){
@@ -581,14 +981,14 @@ MWF.xApplication.Selector.Identity.ItemCategory = new Class({
                                 }
                             }.bind(this));
                             this.loaded = true;
-                            if (callback) callback();
+                            if (callback) callback( true );
                         }.bind(this), null, this.data.distinguishedName);
                     }else{
                         this.loaded = true;
-                        if (callback) callback();
+                        if (callback) callback( true );
                     }
                 }.bind(this), null, this.data.distinguishedName);
-            }
+            // }
         }else{
             if (callback) callback( );
         }
@@ -604,7 +1004,13 @@ MWF.xApplication.Selector.Identity.ItemCategory = new Class({
     _hasChildItem: function(){
         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
     clickFlatCategoryItem: function( callback, hidden ){
@@ -658,28 +1064,28 @@ MWF.xApplication.Selector.Identity.ItemCategory = new Class({
     },
     loadItemChildren: function(callback){
         if (!this.itemLoaded){
-            if (this.selector.options.dutys && this.selector.options.dutys.length){
-                var ids = [];
-                var object = {};
-                this.selector.options.dutys.each(function(duty){
-                    this.selector.orgAction.listIdentityWidthUnitWithDutyName(this.data.distinguishedName, duty, function(json){
-                        if (json.data && json.data.length){
-                            ids = ids.concat(json.data);
-                        }
-                    }.bind(this), null, false);
-
-                    ids.each(function(idSubData){
-                        if( !this.selector.isExcluded( idSubData ) && !object[ idSubData.id || idSubData.distinguishedName ]) {
-                            var item = this.selector._newItem(idSubData, this.selector, this.children, this.level + 1, this);
-                            this.selector.items.push(item);
-                            if(this.subItems)this.subItems.push( item );
-                            object[ idSubData.id || idSubData.distinguishedName ] = true;
-                        }
-                        this.itemLoaded = true;
-                    }.bind(this));
-                }.bind(this));
-                if (callback) callback();
-            }else{
+            // if (this.selector.options.dutys && this.selector.options.dutys.length){
+            //     var ids = [];
+            //     var object = {};
+            //     this.selector.options.dutys.each(function(duty){
+            //         this.selector.orgAction.listIdentityWidthUnitWithDutyName(this.data.distinguishedName, duty, function(json){
+            //             if (json.data && json.data.length){
+            //                 ids = ids.concat(json.data);
+            //             }
+            //         }.bind(this), null, false);
+            //
+            //         ids.each(function(idSubData){
+            //             if( !this.selector.isExcluded( idSubData ) && !object[ idSubData.id || idSubData.distinguishedName ]) {
+            //                 var item = this.selector._newItem(idSubData, this.selector, this.children, this.level + 1, this);
+            //                 this.selector.items.push(item);
+            //                 if(this.subItems)this.subItems.push( item );
+            //                 object[ idSubData.id || idSubData.distinguishedName ] = true;
+            //             }
+            //             this.itemLoaded = true;
+            //         }.bind(this));
+            //     }.bind(this));
+            //     if (callback) callback();
+            // }else{
                 this.selector.orgAction.listIdentityWithUnit(function(idJson){
                     idJson.data.each(function(idSubData){
                         if( !this.selector.isExcluded( idSubData ) ) {
@@ -691,7 +1097,7 @@ MWF.xApplication.Selector.Identity.ItemCategory = new Class({
                     }.bind(this));
                     if (callback) callback();
                 }.bind(this), null, this.data.distinguishedName);
-            }
+            // }
         }else{
             if (callback) callback( );
         }
@@ -714,10 +1120,24 @@ MWF.xApplication.Selector.Identity.ItemGroupCategory = new Class({
         var style = this.selector.options.style;
         this.iconNode.setStyle("background-image", "url("+"../x_component_Selector/$Selector/"+style+"/icon/groupicon.png)");
     },
+    _getTotalCount : function(){
+        if( !this.selector.allGroupObjectByDn )return 0;
+        var group = this.selector.allGroupObjectByDn[this.data.distinguishedName];
+        var count = group ? group.subNestedIdentityCount : 0;
+        return count;
+    },
+    _getSelectedCount : function(){
+        debugger;
+        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){
-
-            debugger;
             var personContainer, identityContainer, groupContainer, unitContainer;
             if( this.data.personList )personContainer = new Element("div").inject( this.children );
             if( this.data.identityList )identityContainer = new Element("div").inject( this.children );

+ 189 - 84
o2web/source/x_component_Selector/IdentityWidthDuty.js

@@ -19,6 +19,10 @@ MWF.xApplication.Selector.IdentityWidthDuty = new Class({
         "exclude" : [],
         "selectType" : "identity"
     },
+    _init : function(){
+	    this.selectType = "identity";
+	    this.className = "IdentityWidthDuty"
+    },
     loadSelectItems: function(addToNext){
 
         var afterLoadSelectItemFun = this.afterLoadSelectItem.bind(this);
@@ -50,19 +54,73 @@ MWF.xApplication.Selector.IdentityWidthDuty = new Class({
                 }
             }.bind(this));
 
+            var loadDuty = function () {
+                this.options.dutys.each(function(duty){
+                    var data = {"name": duty, "id":duty};
+                    var category = this._newItemCategory("ItemCategory",data, this, this.itemAreaNode);
+                    this.subCategorys.push(category);
+                    loadDutySuccess();
+                }.bind(this));
+            }.bind(this);
 
-            // this.loadInclude();
-            this.options.dutys.each(function(duty){
-                var data = {"name": duty, "id":duty};
-                var category = this._newItemCategory("ItemCategory",data, this, this.itemAreaNode);
-                this.subCategorys.push(category);
-                //category.loadSub();
-                //category.clickItem();
-                // this.action.getUnitduty(function(dutyData){
-                //     var category = this._newItemCategory("ItemCategory", dutyData.data, this, this.itemAreaNode);
-                // }.bind(this), null, duty);
-                loadDutySuccess();
-            }.bind(this));
+            if( this.options.units.length === 0 ){
+                loadDuty();
+            }else{
+                var unitList = [];
+                this.options.units.each(function(u) {
+                    var unitName = typeOf(u) === "string" ? u : (u.distinguishedName || u.unique || u.id || u.levelName);
+                    if (unitName)unitList.push( unitName )
+                });
+
+                if( !this.options.expandSubEnable ){
+                    this.allUnitNames = unitList;
+                    loadDuty();
+                }else{
+                    var unitObjectList = [];
+                    var loadNestedUnit = function(){
+                        MWF.Actions.get("x_organization_assemble_express").listUnitSubNested({"unitList": unitList }, function(json1){
+                            var unitNames = [];
+                            //排序
+                            if( this.options.units.length === 1 ){
+                                unitNames = unitList.concat( json1.data );
+                            }else{
+                                unitObjectList.each( function ( u ) {
+                                    unitNames.push( u.distinguishedName || u.unique || u.id || u.levelName );
+                                    for( var i=0; i<json1.data.length; i++ ){
+                                        if( json1.data[i].levelName.indexOf(u.levelName) > -1 ){
+                                            unitNames.push( json1.data[i].distinguishedName );
+                                        }
+                                    }
+                                })
+                            }
+                            this.allUnitNames = unitNames;
+                            loadDuty();
+                        }.bind(this), null);
+                    }.bind(this);
+
+
+                    var flag = false; //需要获取层次名用于排序
+                    if( this.options.units.length === 1 ){
+                        loadNestedUnit();
+                    }else{
+                        this.options.units.each(function(u) {
+                            if (typeOf(u) === "string" ) {
+                                u.indexOf("/") === -1 ? (flag = true) : unitObjectList.push( { levelName : u } );
+                            } else {
+                                u.levelName ? unitObjectList.push( u ) : (flag = true);
+                            }
+                        });
+                        if( flag ){ //需要获取层次名来排序
+                            o2.Actions.load("x_organization_assemble_express").UnitActions.listObject( function (json) {
+                                unitObjectList = json.data || [];
+                                loadNestedUnit();
+                            }.bind(this) )
+                        }else{
+                            loadNestedUnit();
+                        }
+                    }
+                }
+            }
         }
     },
 
@@ -132,8 +190,8 @@ MWF.xApplication.Selector.IdentityWidthDuty = new Class({
             if (callback) callback.apply(this, [json]);
         }.bind(this), failure, key);
     },
-    _newItem: function(data, selector, container, level, category){
-        return new MWF.xApplication.Selector.IdentityWidthDuty.Item(data, selector, container, level, category);
+    _newItem: function(data, selector, container, level, category, delay){
+        return new MWF.xApplication.Selector.IdentityWidthDuty.Item(data, selector, container, level, category, delay);
     },
     _newItemSearch: function(data, selector, container, level){
         return new MWF.xApplication.Selector.IdentityWidthDuty.SearchItem(data, selector, container, level);
@@ -193,82 +251,129 @@ MWF.xApplication.Selector.IdentityWidthDuty.ItemCategory = new Class({
         var style = this.selector.options.style;
         this.iconNode.setStyle("background-image", "url("+"../x_component_Selector/$Selector/"+style+"/icon/companyicon.png)");
     },
-    loadSub: function(callback){
+    _addSelectedCount : function(){
+        var count = this._getSelectedCount();
+        this.checkCountAndStatus(count);
+    },
+    _getTotalCount : function(){
+        return this.subItems.length;
+    },
+    _getSelectedCount : function(){
+        var list = this.subItems.filter( function (item) { return item.isSelected; });
+        return list.length;
+    },
+    loadSub : function(callback){
+        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();
+        }.bind(this))
+    },
+    _loadSub: function(callback){
         if (!this.loaded  && !this.loadingsub){
             this.loadingsub = true;
+
             if (this.selector.options.units.length){
-                var action = MWF.Actions.get("x_organization_assemble_express");
-                var data = {"name":this.data.name, "unit":""};
-                var count = this.selector.options.units.length;
-                var i = 0;
+                var data = {
+                    "name":this.data.name,
+                    "unit":"",
+                    "unitList" : this.selector.allUnitNames
+                };
 
-                if (this.selector.options.expandSubEnable) {
-                    this.selector.options.units.each(function(u){
-                        var unitName = "";
-                        if (typeOf(u)==="string"){
-                            unitName = u;
-                        }else{
-                            unitName = u.distinguishedName || u.unique || u.id || u.levelName
+                MWF.Actions.get("x_organization_assemble_express").getDuty(data, function(json){
+                    json.data.each(function(idSubData){
+                        if( !this.selector.isExcluded( idSubData ) ) {
+                            var item = this.selector._newItem(idSubData, this.selector, this.children, this.level + 1, this);
+                            this.selector.items.push(item);
+                            if(this.subItems)this.subItems.push( item );
                         }
-                        if (unitName){
-                            var unitNames;
-                            action.listUnitNameSubNested({"unitList": [unitName]}, function(json){
-                                unitNames = json.data.unitList;
-                            }.bind(this), null, false);
+                    }.bind(this));
 
-                            unitNames.push(unitName);
-                            if (unitNames && unitNames.length){
-                                data.unitList = unitNames;
-                                action.getDuty(data, function(json){
-                                    json.data.each(function(idSubData){
-                                        if( !this.selector.isExcluded( idSubData ) ) {
-                                            var item = this.selector._newItem(idSubData, this.selector, this.children, this.level + 1, this);
-                                            this.selector.items.push(item);
-                                            if(this.subItems)this.subItems.push( item );
-                                        }
-                                    }.bind(this));
-                                }.bind(this), null, false);
-                            }
-                        }
+                    if (!this.loaded) {
+                        this.loaded = true;
+                        this.loadingsub = false;
+                        this.itemLoaded = true;
+                        if (callback) callback( true );
+                    }
 
-                        i++;
-                        if (i>=count){
-                            if (!this.loaded) {
-                                this.loaded = true;
-                                this.loadingsub = false;
-                                this.itemLoaded = true;
-                                if (callback) callback();
-                            }
-                        }
-                    }.bind(this));
-                }else{
-                    this.selector.options.units.each(function(u){
-                        if (typeOf(u)==="string"){
-                            data.unit = u;
-                        }else{
-                            data.unit = u.distinguishedName || u.unique || u.id || u.levelName
-                        }
-                        action.getDuty(data, function(json){
-                            json.data.each(function(idSubData){
-                                if( !this.selector.isExcluded( idSubData ) ) {
-                                    var item = this.selector._newItem(idSubData, this.selector, this.children, this.level + 1, this);
-                                    this.selector.items.push(item);
-                                    if(this.subItems)this.subItems.push( item );
-                                }
-                            }.bind(this));
-                            i++;
-                            if (i>=count){
-                                if (!this.loaded) {
-                                    this.loaded = true;
-                                    this.loadingsub = false;
-                                    this.itemLoaded = true;
-                                    if (callback) callback();
-                                }
-                            }
-                        }.bind(this));
-                    }.bind(this));
-                }
-                // if (callback) callback();
+                }.bind(this), null, false);
+
+            // if (this.selector.options.units.length){
+            //     var action = MWF.Actions.get("x_organization_assemble_express");
+            //     var data = {"name":this.data.name, "unit":""};
+            //     var count = this.selector.options.units.length;
+            //     var i = 0;
+            //
+            //     if (this.selector.options.expandSubEnable) {
+            //         this.selector.options.units.each(function(u){
+            //             var unitName = "";
+            //             if (typeOf(u)==="string"){
+            //                 unitName = u;
+            //             }else{
+            //                 unitName = u.distinguishedName || u.unique || u.id || u.levelName
+            //             }
+            //             if (unitName){
+            //                 var unitNames;
+            //                 action.listUnitNameSubNested({"unitList": [unitName]}, function(json){
+            //                     unitNames = json.data.unitList;
+            //                 }.bind(this), null, false);
+            //
+            //                 unitNames.push(unitName);
+            //                 if (unitNames && unitNames.length){
+            //                     data.unitList = unitNames;
+            //                     action.getDuty(data, function(json){
+            //                         json.data.each(function(idSubData){
+            //                             if( !this.selector.isExcluded( idSubData ) ) {
+            //                                 var item = this.selector._newItem(idSubData, this.selector, this.children, this.level + 1, this);
+            //                                 this.selector.items.push(item);
+            //                                 if(this.subItems)this.subItems.push( item );
+            //                             }
+            //                         }.bind(this));
+            //                     }.bind(this), null, false);
+            //                 }
+            //             }
+            //
+            //             i++;
+            //             if (i>=count){
+            //                 if (!this.loaded) {
+            //                     this.loaded = true;
+            //                     this.loadingsub = false;
+            //                     this.itemLoaded = true;
+            //                     if (callback) callback();
+            //                 }
+            //             }
+            //         }.bind(this));
+            //     }else{
+            //         this.selector.options.units.each(function(u){
+            //             if (typeOf(u)==="string"){
+            //                 data.unit = u;
+            //             }else{
+            //                 data.unit = u.distinguishedName || u.unique || u.id || u.levelName
+            //             }
+            //             action.getDuty(data, function(json){
+            //                 json.data.each(function(idSubData){
+            //                     if( !this.selector.isExcluded( idSubData ) ) {
+            //                         var item = this.selector._newItem(idSubData, this.selector, this.children, this.level + 1, this);
+            //                         this.selector.items.push(item);
+            //                         if(this.subItems)this.subItems.push( item );
+            //                     }
+            //                 }.bind(this));
+            //                 i++;
+            //                 if (i>=count){
+            //                     if (!this.loaded) {
+            //                         this.loaded = true;
+            //                         this.loadingsub = false;
+            //                         this.itemLoaded = true;
+            //                         if (callback) callback();
+            //                     }
+            //                 }
+            //             }.bind(this));
+            //         }.bind(this));
+            //     }
 
             }else{
                 this.selector.orgAction.listIdentityWithDuty(function(json){
@@ -281,7 +386,7 @@ MWF.xApplication.Selector.IdentityWidthDuty.ItemCategory = new Class({
                     }.bind(this));
                     this.loaded = true;
                     this.loadingsub = false;
-                    if (callback) callback();
+                    if (callback) callback( true );
                 }.bind(this), null, this.data.name);
             }
         }else{

+ 129 - 37
o2web/source/x_component_Selector/IdentityWidthDutyCategoryByUnit.js

@@ -20,6 +20,10 @@ MWF.xApplication.Selector.IdentityWidthDutyCategoryByUnit = new Class({
         "dutyUnitLevelBy" : "duty", //组织层级是按身份所在群组还是职务,
         "selectType" : "identity"
     },
+    _init : function(){
+        this.selectType = "identity";
+        this.className = "IdentityWidthDutyCategoryByUnit";
+    },
     loadSelectItems: function(addToNext){
         //根据组织分类展现职务
         if( this.options.resultType === "person" ){
@@ -92,6 +96,7 @@ MWF.xApplication.Selector.IdentityWidthDutyCategoryByUnit = new Class({
     _loadSelectItems : function( identityList ){
         //this.listAllIdentityInUnitObject( identityList );
         var unitTree = this.listNestedUnitByIdentity( identityList );
+        this.uniqueIdentity( unitTree );
         if( this.options.dutyUnitLevelBy === "duty" ){
             this.level1Container = [];
             if( this.options.units && this.options.units.length ){
@@ -113,10 +118,10 @@ MWF.xApplication.Selector.IdentityWidthDutyCategoryByUnit = new Class({
         this.sortUnit( unitTree.unitList );
         for( var i=0; i< unitTree.unitList.length; i++ ){
             var unit = unitTree.unitList[i];
-            if( !this.isExcluded( unit ) ) {
+            // if( !this.isExcluded( unit ) ) {
                 var category = this._newItemCategory("ItemCategory",unit, this, this.itemAreaNode);
                 this.subCategorys.push(category);
-            }
+            // }
         }
     },
     sortUnit : function( unitList ){
@@ -146,7 +151,7 @@ MWF.xApplication.Selector.IdentityWidthDutyCategoryByUnit = new Class({
         for( var i=0; i< unitTree.unitList.length; i++ ){
             var unit = unitTree.unitList[i];
             if( this.isUnitContain( unit ) ){
-                if( !this.isExcluded( unit ) ) {
+                // if( !this.isExcluded( unit ) ) {
                     var container = this.itemAreaNode;
                     if( this.level1Container && this.level1Container.length ){
                         var index = this.getIndexFromUnitOption( unit );
@@ -154,7 +159,7 @@ MWF.xApplication.Selector.IdentityWidthDutyCategoryByUnit = new Class({
                     }
                     var category = this._newItemCategory("ItemCategory",unit, this, container );
                     this.subCategorys.push(category);
-                }
+                // }
             }else{
                 this._loadSelectItemsByDutyUnit( unit );
             }
@@ -239,6 +244,9 @@ MWF.xApplication.Selector.IdentityWidthDutyCategoryByUnit = new Class({
         //根据unitLevelName整合成组织树
         var unitTree = {};
         for( var i=0; i<identityList.length; i++ ){
+            var flag = true;
+            if( this.isExcluded( identityList[i] ) )continue;
+
             var levelNames = identityList[i][key];
             //if( !levelNames && key === "matchUnitLevelName" )levelNames = identityList[i].unitLevelName;
             var unitLevelNameList = levelNames.split("/");
@@ -248,6 +256,11 @@ MWF.xApplication.Selector.IdentityWidthDutyCategoryByUnit = new Class({
                 nameList.push( unitLevelNameList[j] );
                 var name = nameList.join("/");
 
+                if( this.isExcluded( this.allUnitObject[name] || {} ) ){
+                    flag = false;
+                    break;
+                }
+
                 if( !tree.unitList )tree.unitList = [];
                 var found = false;
                 for( var k=0; k<tree.unitList.length; k++ ){
@@ -258,19 +271,63 @@ MWF.xApplication.Selector.IdentityWidthDutyCategoryByUnit = new Class({
                     }
                 }
                 if( !found ){
-                    var obj = {};
+                    // var obj = {};
+                    var obj = this.allUnitObject[name] || {};
+                    obj.matchLevelName = name;
                     tree.unitList.push( obj );
                     tree = obj;
                 }
-                if( !tree.distinguishedName ){
-                    tree = Object.merge( tree, this.allUnitObject[name] );
-                }
+                // if( !tree.distinguishedName ){
+                //     tree = Object.merge( tree, this.allUnitObject[name] );
+                // }
                 if( !tree.identityList )tree.identityList = [];
+
             }
-            tree.identityList.push( identityList[i] );
+            if(flag)tree.identityList.push( identityList[i] );
         }
         return unitTree;
     },
+    uniqueIdentity : function( tree ){
+        var map = {};
+        var isExist = function ( d ) {
+            if(( d.distinguishedName && map[ d.distinguishedName ] ) ||
+                ( d.levelName && map[ d.levelName ] ) ||
+                ( d.id && map[ d.id ] ) ||
+                ( d.unique && map[ d.unique ] )){
+                return true;
+            }else{
+                map[ typeOf( d ) === "string" ? d : ( d.distinguishedName || d.id || d.unique || d.employee || d.levelName) ] = true;
+                return false;
+            }
+        };
+
+        var identityList = [];
+        if( tree.identityList ){
+            for( var i=0; i<tree.identityList.length; i++ ){
+                if( !isExist( tree.identityList[i] ) )identityList.push( tree.identityList[i] );
+            }
+        }
+        tree.identityList = identityList;
+
+        if( this.options.isCheckStatus ){
+            var names = (tree.matchLevelName || tree.levelName || "").split("/");
+            var nameList = [];
+            for( var i=0; i<names.length; i++ ){
+                nameList.push( names[i] );
+                var name = nameList.join("/");
+                var obj = this.allUnitObject[name];
+                if( obj ){
+                    obj.subNestedIdentityCount = ( obj.subNestedIdentityCount || 0 ) + identityList.length;
+                }
+            }
+        }
+
+        if( tree.unitList ){
+            for( var i=0; i<tree.unitList.length; i++ ){
+                this.uniqueIdentity( tree.unitList[i] );
+            }
+        }
+    },
     //listNestedUnitByIdentity : function( identityList ){
     //    debugger;
     //    this.unitArray = [];
@@ -337,8 +394,8 @@ MWF.xApplication.Selector.IdentityWidthDutyCategoryByUnit = new Class({
             if (callback) callback.apply(this, [json]);
         }.bind(this), failure, key);
     },
-    _newItem: function(data, selector, container, level, category){
-        return new MWF.xApplication.Selector.IdentityWidthDutyCategoryByUnit.Item(data, selector, container, level, category);
+    _newItem: function(data, selector, container, level, category, delay){
+        return new MWF.xApplication.Selector.IdentityWidthDutyCategoryByUnit.Item(data, selector, container, level, category, delay);
     },
     _newItemSearch: function(data, selector, container, level){
         return new MWF.xApplication.Selector.IdentityWidthDutyCategoryByUnit.SearchItem(data, selector, container, level);
@@ -362,6 +419,37 @@ MWF.xApplication.Selector.IdentityWidthDutyCategoryByUnit.ItemSelected = new Cla
 
 MWF.xApplication.Selector.IdentityWidthDutyCategoryByUnit.ItemCategory = new Class({
     Extends: MWF.xApplication.Selector.IdentityWidthDuty.ItemCategory,
+    _getShowName: function(){
+        return this.data.name;
+    },
+    _addSelectedCount : function( count, nested ){
+        debugger;
+        var c = (this._getSelectedCount() || 0) + count;
+        this.selectedCount = c;
+        this.checkCountAndStatus(c);
+
+        if( nested && this.category && this.category._addSelectedCount ){
+            this.category._addSelectedCount(count, nested);
+        }
+    },
+    // _getSelectedCount : function(){
+    //     var list = this.subItems.filter( function (item) { return item.isSelected; });
+    //     return list.length;
+    // },
+    _getTotalCount : function(){
+        return this.data.subNestedIdentityCount;
+    },
+    _getSelectedCount : function(){
+        debugger;
+        if( typeOf( this.selectedCount ) === "number" ){
+            return this.selectedCount;
+        }else{
+            return 0;
+        }
+    },
+    _checkStatus : function(){
+
+    },
     isExisted : function( d ){
         if( !d )return true;
         if( !this.createdItemObject )this.createdItemObject = {};
@@ -385,22 +473,38 @@ MWF.xApplication.Selector.IdentityWidthDutyCategoryByUnit.ItemCategory = new Cla
             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.data.identityList && this.data.identityList.length>0 ){
-                debugger;
                 this.data.identityList.sort( function(a, b){
                     //this.selector.getUnitOrderNumber( a.unitLevelName )
                     return (a.orderNumber || 9999999) - (b.orderNumber || 9999999);
                 });
                 this.data.identityList.each( function( identity ){
-                    if( !this.selector.isExcluded( identity ) ) {
-                        if( !this.isExisted( identity ) ){
+                    // if( !this.selector.isExcluded( identity ) ) {
+                    //     if( !this.isExisted( identity ) ){
                             var item = this.selector._newItem(identity, this.selector, this.children, this.level + 1, this);
                             this.selector.items.push(item);
                             if(this.subItems)this.subItems.push( item );
-                        }
-                    }
+                        // }
+                    // }
                 }.bind(this))
             }
 
@@ -409,35 +513,23 @@ MWF.xApplication.Selector.IdentityWidthDutyCategoryByUnit.ItemCategory = new Cla
                     return (a.orderNumber || 9999999) - (b.orderNumber || 9999999);
                 });
                 this.data.unitList.each( function( subData ){
-                    if( !this.selector.isExcluded( subData ) ) {
+                    // if( !this.selector.isExcluded( subData ) ) {
                         var category = this.selector._newItemCategory("ItemCategory", subData, this.selector, this.children, this.level + 1, this);
                         this.subCategorys.push( category );
                         category.loadSub()
-                    }
+                    // }
                 }.bind(this));
             }
 
             this.loaded = true;
-            if (callback) callback( );
+
+            if (callback) callback( true );
         }else{
             if (callback) callback( );
         }
     },
     loadCategoryChildren: function(callback){
         if (!this.categoryLoaded){
-            //if( this.data.unitList && this.data.unitList.length ){
-            //    this.data.unitList.sort( function(a, b){
-            //        return (a.orderNumber || 9999999) - (b.orderNumber || 9999999);
-            //    });
-            //    this.data.unitList.each( function( subData ){
-            //        if( !this.selector.isExcluded( subData ) ) {
-            //            var category = this.selector._newItemCategory("ItemCategory", subData, this.selector, this.children, this.level + 1, this);
-            //            this.subCategorys.push( category );
-            //            category.loadCategoryChildren()
-            //        }
-            //    }.bind(this));
-            //}
-
             this.loadSub();
 
             this.categoryLoaded = true;
@@ -455,13 +547,13 @@ MWF.xApplication.Selector.IdentityWidthDutyCategoryByUnit.ItemCategory = new Cla
                     return (a.orderNumber || 9999999) - (b.orderNumber || 9999999);
                 });
                 this.data.identityList.each( function( identity ){
-                    if( !this.selector.isExcluded( identity ) ) {
-                        if( !this.isExisted( identity ) ){
+                    // if( !this.selector.isExcluded( identity ) ) {
+                    //     if( !this.isExisted( identity ) ){
                             var item = this.selector._newItem(identity, this.selector, this.children, this.level + 1, this);
                             this.selector.items.push(item);
                             if(this.subItems)this.subItems.push( item );
-                        }
-                    }
+                        // }
+                    // }
                 }.bind(this))
             }
             this.itemLoaded = true;

+ 92 - 33
o2web/source/x_component_Selector/Person.js

@@ -36,6 +36,9 @@ MWF.xApplication.Selector.Person = new Class({
         "flatCategory" : false, //扁平化展现分类,
         "selectType" : "person",
 
+        "isCheckStatus" : false,
+        "showSelectedCount" : false,
+
         "itemHeight" : 29,
         "identityItemWidth" : 0, //选项宽度,如果不为0,设置为float:left,
 
@@ -80,6 +83,11 @@ MWF.xApplication.Selector.Person = new Class({
 
         this.subCategorys = []; //直接的分类
         this.subItems = []; //直接的选择项
+        this._init();
+    },
+    _init : function(){
+        this.selectType = "person";
+        this.className = "Person"
     },
     load: function(){
         this.fireEvent("queryLoad",[this]);
@@ -391,6 +399,27 @@ MWF.xApplication.Selector.Person = new Class({
         this.setEvent();
     },
 
+    getUnitIdentityCount : function(){
+
+    },
+    getUnitSelecteIndentityCount : function( unitLevelName ){ //根据组织获取已选身份数
+        var count;
+        this.selectedItems.each( function (item) {
+            if( item.data.unitLevelName.indexOf( unitLevelName ) === 0 )count++;
+        }.bind(this));
+        return count;
+    },
+    getGroupNestCount : function(){
+        // o2.Actions.load("x_organization_assemble_express").
+    },
+    getGroupSelecteIndentityCount : function( groupName ){ //根据组织获取已选身份数
+        var count;
+        this.selectedItems.each( function (item) {
+            if( item.data.unitLevelName.indexOf( unitLevelName ) === 0 )count++;
+        }.bind(this));
+        return count;
+    },
+
     setEvent: function(){
         if (this.titleActionNode){
             this.titleActionNode.addEvent("click", function(){
@@ -1782,7 +1811,7 @@ MWF.xApplication.Selector.Person.Item = new Class({
         }).inject(this.node);
 
 
-        if( this.selector.options.selectType !== "identity" || this.selector.options.identityItemWidth === 0 ) {
+        if( this.selector.selectType !== "identity" || this.selector.options.identityItemWidth === 0 ) {
             var indent = this.selector.options.level1Indent + (this.level - 1) * this.selector.options.indent;
             this.levelNode.setStyle("width", "" + indent + "px");
         }
@@ -1808,7 +1837,7 @@ MWF.xApplication.Selector.Person.Item = new Class({
         var m = this.textNode.getStyle("margin-left").toFloat()+indent;
         this.textNode.setStyle("margin-left", ""+m+"px");
 
-        if( this.selector.options.identityItemWidth && this.selector.options.selectType === "identity"){
+        if( this.selector.options.identityItemWidth && this.selector.selectType === "identity"){
             this.node.setStyles({
                 "float" : "left",
                 "min-width" : this.selector.options.identityItemWidth + "px"
@@ -1987,7 +2016,8 @@ MWF.xApplication.Selector.Person.Item = new Class({
         this.selector.fireEvent("unselectItem",[this]);
         if( checkValid )this.selector.fireEvent("valid", [this.selector, this]);
     },
-    selected: function( checkValid, callback, selectedNode ){
+    selected: function( checkValid, callback, selectedNode, byelectAll ){
+        debugger;
         var count = this.selector.options.maxCount || this.selector.options.count;
         count = count.toInt();
         if (!count) count = 0;
@@ -2008,7 +2038,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 ){
@@ -2081,6 +2111,9 @@ MWF.xApplication.Selector.Person.Item = new Class({
                         item.actionNode.setStyles( this.selector.css.selectorItemActionNode_single );
                     }
                 }
+                if( this.selector.selectType == "identity" && ( this.selector.options.showSelectedCount || this.selector.options.isCheckStatus ) ){
+                    if(item.category && item.category._addSelectedCount )item.category._addSelectedCount( -1, true );
+                }
             }.bind(this));
 
             this.selectedItem.destroy();
@@ -2197,6 +2230,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;
@@ -2206,6 +2240,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));
             }
         }
@@ -2351,7 +2388,7 @@ MWF.xApplication.Selector.Person.ItemCategory = new Class({
             "styles": this.selector.css.selectorItemLevelNode
         }).inject(this.node);
 
-        if(this.selector.options.selectType !== "identity" || this.selector.options.identityItemWidth === 0 ){
+        if(this.selector.selectType !== "identity" || this.selector.options.identityItemWidth === 0 ){
             var indent = this.selector.options.level1Indent + (this.level - 1) * this.selector.options.indent;
             this.levelNode.setStyle("width", "" + indent + "px");
         }else{
@@ -2392,11 +2429,11 @@ MWF.xApplication.Selector.Person.ItemCategory = new Class({
             if( this.selector.css.selectorItemCategoryActionNode_selectAll_over ){
                 this.selectAllNode.addEvents( {
                     "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();
                     }.bind(this),
                     "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();
                     }.bind(this)
                 })
@@ -2410,6 +2447,10 @@ MWF.xApplication.Selector.Person.ItemCategory = new Class({
         var m = this.textNode.getStyle("margin-left").toFloat()+indent;
         this.textNode.setStyle("margin-left", ""+m+"px");
 
+        if( this.selector.options.showSelectedCount && this.selector.selectType == "identity" ){
+            this.selectedCountNode = new Element("span").inject(this.textNode);
+        }
+
         this.children = new Element("div.children", {
             "styles": this.selector.css.selectorItemCategoryChildrenNode
         }).inject(this.node, "after");
@@ -2427,7 +2468,7 @@ MWF.xApplication.Selector.Person.ItemCategory = new Class({
                 this.children.setStyle("height", ""+this.childrenHeight+"px");
             }
 
-            if(this.selector.options.identityItemWidth && this.selector.options.selectType === "identity"){
+            if(this.selector.options.identityItemWidth && this.selector.selectType === "identity"){
                 var indent = this.level === 0 ? this.selector.options.level1Indent : this.selector.options.indent;
                 this.children.setStyles({
                     "padding-left": "" + indent + "px",
@@ -2459,27 +2500,34 @@ MWF.xApplication.Selector.Person.ItemCategory = new Class({
             "styles": this.selector.css.selectorItemCategory,
             "title" : this._getTtiteText()
         }).inject(this.container);
-    },
-    isSelectAllEnable : function(){
-
     },
     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 ){
         this.unselectAll(ev, exclude, checkValid);
@@ -2492,20 +2540,23 @@ MWF.xApplication.Selector.Person.ItemCategory = new Class({
     selectAllNested : function( ev, checkValid, selectedNode ){
         var node;
         if(selectedNode)node = new Element("div.categorySelectedNode").inject( selectedNode );
-        this.selectAll(ev, checkValid, node);
-        if( this.subCategorys && this.subCategorys.length ){
-            this.subCategorys.each( function( category ){
-                if(selectedNode)var node = new Element("div.categorySelectedNode").inject( selectedNode );
-                category.selectAllNested(ev, checkValid, node)
-            })
-        }
+        this.selectAll(ev, checkValid, node, function () {
+            if( this.subCategorys && this.subCategorys.length ){
+                this.subCategorys.each( function( category ){
+                    if(selectedNode)var node = new Element("div.categorySelectedNode").inject( selectedNode );
+                    category.selectAllNested(ev, checkValid, node)
+                })
+            }
+        }.bind(this));
     },
-    selectAll: function(ev, checkValid, selectedNode){
+    selectAll: function(ev, checkValid, selectedNode, callback){
         if( this.loaded || this.selector.isFlatCategory ){
             this._selectAll( ev, checkValid, selectedNode );
+            if(callback)callback();
         }else{
             this.clickItem( function(){
                 this._selectAll( ev, checkValid, selectedNode );
+                if(callback)callback();
                 //this.children.setStyles({
                 //    "display": "none",
                 //    "height": "0px"
@@ -2539,7 +2590,15 @@ MWF.xApplication.Selector.Person.ItemCategory = new Class({
                     if( this.selector.isFlatCategory ){
                         this.selectAllNode.setStyles( this.selector.css.flatCategory_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;

+ 4 - 1
o2web/source/x_component_Selector/Portal.js

@@ -10,7 +10,10 @@ MWF.xApplication.Selector.Portal = new Class({
         "expand": false,
         "forceSearchInItem" : true
     },
-
+    _init : function(){
+        this.selectType = "portal";
+        this.className = "Portal";
+    },
     loadSelectItems: function(addToNext){
         this.portalDesignerAction.listApplication(function(json){
             json.data.each(function(data){

+ 4 - 1
o2web/source/x_component_Selector/PortalFile.js

@@ -13,7 +13,10 @@ MWF.xApplication.Selector.PortalFile = new Class({
         "expand": false,
         "forceSearchInItem" : true
     },
-
+    _init : function(){
+        this.selectType = "file";
+        this.className = "PortalFile";
+    },
     loadSelectItems: function(addToNext){
 	    if (this.options.isImage) this.options.accept = ["png","jpg","bmp","gif","jpeg","jpe"];
         this.portalAction.listApplication(function(json){

+ 4 - 1
o2web/source/x_component_Selector/Process.js

@@ -11,7 +11,10 @@ MWF.xApplication.Selector.Process = new Class({
         "expand": false,
         "forceSearchInItem" : true
     },
-
+    _init : function(){
+        this.selectType = "process";
+        this.className = "Process";
+    },
     loadSelectItems: function(addToNext){
         this.processAction.listApplicationStartable(function(json){
             if (json.data.length){

+ 4 - 1
o2web/source/x_component_Selector/ProcessFile.js

@@ -11,7 +11,10 @@ MWF.xApplication.Selector.ProcessFile = new Class({
         "expand": false,
         "forceSearchInItem" : true
     },
-
+    _init : function(){
+        this.selectType = "file";
+        this.className = "ProcessFile";
+    },
     loadSelectItems: function(addToNext){
         if (this.options.isImage) this.options.accept = ["png","jpg","bmp","gif","jpeg","jpe"];
         this.processAction.listApplication(function(json){

+ 4 - 1
o2web/source/x_component_Selector/Query.js

@@ -11,7 +11,10 @@ MWF.xApplication.Selector.Query = new Class({
         "expand": false,
         "forceSearchInItem" : true
     },
-
+    _init : function(){
+        this.selectType = "query";
+        this.className = "Query";
+    },
     loadSelectItems: function(addToNext){
         this.queryAction.listApplication(function(json){
             if (json.data.length){

+ 4 - 1
o2web/source/x_component_Selector/QueryStat.js

@@ -11,7 +11,10 @@ MWF.xApplication.Selector.QueryStat = new Class({
         "expand": false,
         "forceSearchInItem" : true
     },
-
+    _init : function(){
+        this.selectType = "querystat";
+        this.className = "QueryStat";
+    },
     loadSelectItems: function(addToNext){
         this.queryAction.listApplication(function(json){
             if (json.data.length){

+ 4 - 0
o2web/source/x_component_Selector/QueryTable.js

@@ -11,6 +11,10 @@ MWF.xApplication.Selector.QueryTable = new Class({
         "expand": false,
         "forceSearchInItem" : true
     },
+    _init : function(){
+        this.selectType = "querytable";
+        this.className = "QueryTable";
+    },
     loadSelectItems: function(addToNext){
         this.queryAction.listApplication(function(json){
             if (json.data.length){

+ 4 - 1
o2web/source/x_component_Selector/QueryView.js

@@ -11,7 +11,10 @@ MWF.xApplication.Selector.QueryView = new Class({
         "expand": false,
         "forceSearchInItem" : true
     },
-
+    _init : function(){
+        this.selectType = "queryview";
+        this.className = "QueryView";
+    },
     loadSelectItems: function(addToNext){
         this.queryAction.listApplication(function(json){
             if (json.data.length){

+ 4 - 1
o2web/source/x_component_Selector/Role.js

@@ -11,7 +11,10 @@ MWF.xApplication.Selector.Role = new Class({
         "names": [],
         "selectType" : "role"
     },
-
+    _init : function(){
+        this.selectType = "role";
+        this.className = "Role";
+    },
     _listItemByKey: function(callback, failure, key){
         if (this.options.units.length || this.options.roles.length) key = this.getLikeKey(key);
         this.orgAction.listRoleByKey(function(json){

+ 4 - 0
o2web/source/x_component_Selector/Script.js

@@ -12,6 +12,10 @@ MWF.xApplication.Selector.Script = new Class({
         "expand": false,
         "forceSearchInItem" : true
     },
+    _init : function(){
+        this.selectType = "script";
+        this.className = "Script";
+    },
     loadSelectItems: function(addToNext){
         var json = {};
         this.options.appType.each( function (type) {

+ 23 - 17
o2web/source/x_component_Selector/Unit.js

@@ -16,7 +16,10 @@ MWF.xApplication.Selector.Unit = new Class({
         "selectAllEnable" : true, //分类是否允许全选下一层
         "selectType" : "unit"
     },
-
+    _init : function(){
+        this.selectType = "unit";
+        this.className = "Unit";
+    },
     loadSelectItems: function(addToNext){
         var afterLoadSelectItemFun = this.afterLoadSelectItem.bind(this);
 
@@ -401,26 +404,29 @@ MWF.xApplication.Selector.Unit.Item = new Class({
     selectAllNested : function(ev, checkValid, selectedNode){
         var node;
         if( selectedNode )node = new Element("div.categorySelectedNode").inject( selectedNode );
-        this.selectAll(ev, checkValid, node);
-        if( this.subCategorys && this.subCategorys.length ){
-            this.subCategorys.each( function( category ){
-                if(selectedNode)var node = new Element("div.categorySelectedNode").inject( selectedNode );
-                if(category.selectAllNested)category.selectAllNested(ev, checkValid, node)
-            })
-        }
-        if( this.subItems && this.subItems.length ){
-            this.subItems.each( function( item ){
-                if(selectedNode)var node = new Element("div.categorySelectedNode").inject( selectedNode );
-                if(item.selectAllNested)item.selectAllNested(ev, checkValid, node)
-            })
-        }
+        this.selectAll(ev, checkValid, node, function () {
+            if( this.subCategorys && this.subCategorys.length ){
+                this.subCategorys.each( function( category ){
+                    if(selectedNode)var node = new Element("div.categorySelectedNode").inject( selectedNode );
+                    if(category.selectAllNested)category.selectAllNested(ev, checkValid, node)
+                })
+            }
+            if( this.subItems && this.subItems.length ){
+                this.subItems.each( function( item ){
+                    if(selectedNode)var node = new Element("div.categorySelectedNode").inject( selectedNode );
+                    if(item.selectAllNested)item.selectAllNested(ev, checkValid, node)
+                })
+            }
+        }.bind(this));
     },
-    selectAll: function(ev, checkValid, selectedNode){
+    selectAll: function(ev, checkValid, selectedNode, callback){
         if( this.loaded || this.selector.isFlatCategory ){
-            this._selectAll( ev, checkValid, selectedNode )
+            this._selectAll( ev, checkValid, selectedNode );
+            if(callback)callback();
         }else{
             this.loadSubItems(function(){
-                this._selectAll( ev, checkValid, selectedNode )
+                this._selectAll( ev, checkValid, selectedNode );
+                if(callback)callback();
             }.bind(this));
             this.levelNode.setStyles(this.selector.css.selectorItemLevelNode_expand);
             this.isExpand = true;

+ 6 - 3
o2web/source/x_component_Selector/UnitWithType.js

@@ -16,7 +16,10 @@ MWF.xApplication.Selector.UnitWithType = new Class({
         "expandSubEnable" : true, //是否允许展开下一层
         "selectAllEnable" : true //分类是否允许全选下一层
     },
-
+    _init : function(){
+        this.selectType = "unit";
+        this.className = "UnitWithType";
+    },
     loadSelectItems: function(addToNext){
         var afterLoadSelectItemFun = this.afterLoadSelectItem.bind(this);
 
@@ -59,8 +62,8 @@ MWF.xApplication.Selector.UnitWithType = new Class({
     _getChildrenItemIds: function(){
         return null;
     },
-    _newItemCategory: function(type, data, selector, item, level, category){
-        return new MWF.xApplication.Selector.UnitWithType[type](data, selector, item, level, category)
+    _newItemCategory: function(type, data, selector, item, level, category, delay){
+        return new MWF.xApplication.Selector.UnitWithType[type](data, selector, item, level, category, delay)
     },
 
     _listItemByKey: function(callback, failure, key){

+ 4 - 1
o2web/source/x_component_Selector/View.js

@@ -10,7 +10,10 @@ MWF.xApplication.Selector.View = new Class({
         "names": [],
         "expand": false
     },
-
+    _init : function(){
+        this.selectType = "view";
+        this.className = "View";
+    },
     loadSelectItems: function(addToNext){
         this.designerAction.listView(function(json){
             if (json.data.length){

+ 2 - 2
o2web/source/x_component_Selector/package.js

@@ -43,7 +43,7 @@ MWF.O2Selector = new Class({
                         this.selector.load();
                         this.loading = false;
                     }.bind(this));
-                }else if ((type.toLowerCase()==="identity") && ((this.options.dutys) && this.options.dutys.length) && this.options.categoryType.toLowerCase()==="unit"){
+                }else if ((type.toLowerCase()==="identity") && ((this.options.dutys) && this.options.dutys.length) ){ //&& this.options.categoryType.toLowerCase()==="unit"
                     MWF.xDesktop.requireApp("Selector", "IdentityWidthDutyCategoryByUnit", function(){
                         this.selector = new MWF.xApplication.Selector.IdentityWidthDutyCategoryByUnit(this.container, options);
                         this.selector.load();
@@ -95,7 +95,7 @@ MWF.O2SelectorFilter = new Class({
                     MWF.xDesktop.requireApp("Selector", "IdentityWidthDuty", function(){
                         this.selectFilter = new MWF.xApplication.Selector.IdentityWidthDuty.Filter(this.value, options);
                     }.bind(this), false);
-                }else if ((type.toLowerCase()==="identity") && ((this.options.dutys) && this.options.dutys.length) && this.options.categoryType.toLowerCase()==="unit"){
+                }else if ((type.toLowerCase()==="identity") && ((this.options.dutys) && this.options.dutys.length) ){ //&& this.options.categoryType.toLowerCase()==="unit"
                     MWF.xDesktop.requireApp("Selector", "IdentityWidthDutyCategoryByUnit", function(){
                         this.selectFilter = new MWF.xApplication.Selector.IdentityWidthDutyCategoryByUnit.Filter(this.value, options);
                     }.bind(this));