Explorar el Código

调整选人组件的回调

unknown hace 5 años
padre
commit
0407bca42e
Se han modificado 1 ficheros con 20 adiciones y 27 borrados
  1. 20 27
      o2web/source/x_component_Selector/Identity.js

+ 20 - 27
o2web/source/x_component_Selector/Identity.js

@@ -19,6 +19,7 @@ MWF.xApplication.Selector.Identity = new Class({
         "selectAllEnable" : true //分类是否允许全选下一层
         "selectAllEnable" : true //分类是否允许全选下一层
     },
     },
     loadSelectItems: function(addToNext){
     loadSelectItems: function(addToNext){
+	    var afterLoadSelectItemFun = this.afterLoadSelectItem.bind(this);
         if( this.options.resultType === "person" ){
         if( this.options.resultType === "person" ){
             if( this.titleTextNode ){
             if( this.titleTextNode ){
                 this.titleTextNode.set("text", MWF.xApplication.Selector.LP.selectPerson );
                 this.titleTextNode.set("text", MWF.xApplication.Selector.LP.selectPerson );
@@ -27,33 +28,24 @@ MWF.xApplication.Selector.Identity = new Class({
             }
             }
         }
         }
         if(this.options.noUnit){
         if(this.options.noUnit){
-            this.loadInclude();
+            this.loadInclude(afterLoadSelectItemFun);
         }else if (this.options.units.length){
         }else if (this.options.units.length){
-            // var units = [];
-            // this.options.units.each(function(u){
-            //     if (typeOf(u)==="string"){
-            //         units.push(u);
-            //     }else{
-            //         units.push(u.distinguishedName)
-            //     }
-            // });
-            // this.org2Action.listUnit({"unitList":units}, function(json){
-            //     json.data.each(function(d){
-            //         var category = this._newItemCategory("ItemUnitCategory", d, this, this.itemAreaNode);
-            //         this.subCategorys.push( category );
-            //     }.bind(this));
-            // }.bind(this));
+            var unitLoaded = 0;
+            var loadUnitSuccess = function () {
+                unitLoaded++;
+                if( unitLoaded === this.options.units.length ){
+                    this.loadInclude( afterLoadSelectItemFun );
+                }
+            }.bind(this);
+            var loadUnitFailure = loadUnitSuccess;
             this.options.units.each(function(unit){
             this.options.units.each(function(unit){
                 if (typeOf(unit)==="string"){
                 if (typeOf(unit)==="string"){
-
-
                     this.orgAction.getUnit(unit, function(json){
                     this.orgAction.getUnit(unit, function(json){
                         if (json.data){
                         if (json.data){
-
                             var category = this._newItemCategory("ItemUnitCategory", json.data, this, this.itemAreaNode);
                             var category = this._newItemCategory("ItemUnitCategory", json.data, this, this.itemAreaNode);
                             this.subCategorys.push( category );
                             this.subCategorys.push( category );
                         }
                         }
-                        this.loadInclude();
+                        loadUnitSuccess();
                     }.bind(this), function(){
                     }.bind(this), function(){
                         this.orgAction.listUnitByKey(function(json){
                         this.orgAction.listUnitByKey(function(json){
                             if (json.data.length){
                             if (json.data.length){
@@ -62,8 +54,8 @@ MWF.xApplication.Selector.Identity = new Class({
                                     this.subCategorys.push( category );
                                     this.subCategorys.push( category );
                                 }.bind(this))
                                 }.bind(this))
                             }
                             }
-                            this.loadInclude();
-                        }.bind(this), null, unit);
+                            loadUnitSuccess();
+                        }.bind(this), loadUnitFailure, unit);
                     }.bind(this));
                     }.bind(this));
                 }else{
                 }else{
                     this.orgAction.getUnit(function(json){
                     this.orgAction.getUnit(function(json){
@@ -71,8 +63,8 @@ MWF.xApplication.Selector.Identity = new Class({
                             var category = this._newItemCategory("ItemUnitCategory", json.data, this, this.itemAreaNode);
                             var category = this._newItemCategory("ItemUnitCategory", json.data, this, this.itemAreaNode);
                             this.subCategorys.push( category );
                             this.subCategorys.push( category );
                         }
                         }
-                        this.loadInclude();
-                    }.bind(this), null, unit.distinguishedName);
+                        loadUnitSuccess();
+                    }.bind(this), loadUnitFailure, unit.distinguishedName);
                     //var category = this._newItemCategory("ItemCategory", unit, this, this.itemAreaNode);
                     //var category = this._newItemCategory("ItemCategory", unit, this, this.itemAreaNode);
                 }
                 }
 
 
@@ -85,17 +77,18 @@ MWF.xApplication.Selector.Identity = new Class({
                         this.subCategorys.push( category );
                         this.subCategorys.push( category );
                     }
                     }
                 }.bind(this));
                 }.bind(this));
-                this.loadInclude();
-            }.bind(this));
+                loadUnitSuccess();
+            }.bind(this), loadUnitFailure);
         }
         }
     },
     },
 
 
-    loadInclude: function() {
+    loadInclude: function(afterLoadFun) {
         if (!this.includeObject){
         if (!this.includeObject){
             this.includeObject = new MWF.xApplication.Selector.Identity.Include(this, this.itemAreaNode, {
             this.includeObject = new MWF.xApplication.Selector.Identity.Include(this, this.itemAreaNode, {
                 "include": this.options.include, //增加的可选项
                 "include": this.options.include, //增加的可选项
                 "resultType": this.options.resultType, //可以设置成个人,那么结果返回个人
                 "resultType": this.options.resultType, //可以设置成个人,那么结果返回个人
-                "expandSubEnable": this.options.expandSubEnable //是否允许展开下一层
+                "expandSubEnable": this.options.expandSubEnable, //是否允许展开下一层
+                "onAfterLoad" : afterLoadFun
             });
             });
         }
         }
         this.includeObject.load();
         this.includeObject.load();