提交 3c85301f 编写于 作者: U unknown

优化人员选择指定组织时的加载速度

上级 8c636b75
......@@ -32,15 +32,10 @@ MWF.xApplication.Selector.Identity = new Class({
if(this.options.noUnit){
this.loadInclude(afterLoadSelectItemFun);
}else if (this.options.units.length){
var unitLoaded = 0;
var loadUnitSuccess = function () {
unitLoaded++;
if( unitLoaded === this.options.units.length ){
this.unitLoaded = true;
if( this.includeLoaded ){
afterLoadSelectItemFun();
}
this.unitLoaded = true;
if( this.includeLoaded ){
afterLoadSelectItemFun();
}
}.bind(this);
var loadUnitFailure = loadUnitSuccess;
......@@ -52,41 +47,78 @@ MWF.xApplication.Selector.Identity = new Class({
}
}.bind(this));
this.options.units.each(function(unit){
var container = new Element("div").inject( this.itemAreaNode );
if (typeOf(unit)==="string"){
this.orgAction.getUnit(unit, function(json){
if (json.data){
var category = this._newItemCategory("ItemUnitCategory", json.data, this, container);
this.subCategorys.push( category );
}
loadUnitSuccess();
}.bind(this), function(){
this.orgAction.listUnitByKey(function(json){
if (json.data.length){
json.data.each(function(data){
var category = this._newItemCategory("ItemUnitCategory", data, this, container);
this.subCategorys.push( category );
}.bind(this))
}
loadUnitSuccess();
}.bind(this), loadUnitFailure, unit);
var unitList = [];
for( var i=0 ; i<this.options.units.length; i++ ){
var unit = this.options.units[i];
if( typeOf( unit ) === "string" ){
unitList.push(unit);
}else if( typeOf(unit)==="object"){
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){
var category = this._newItemCategory("ItemUnitCategory", data, this, this.itemAreaNode );
this.subCategorys.push(category);
}.bind(this));
}else{
this.orgAction.getUnit(function(json){
if (json.data){
var category = this._newItemCategory("ItemUnitCategory", json.data, this, container);
this.subCategorys.push( category );
}
loadUnitSuccess();
}.bind(this), loadUnitFailure, unit.distinguishedName);
//var category = this._newItemCategory("ItemCategory", unit, this, this.itemAreaNode);
}
loadUnitSuccess();
}.bind(this), loadUnitFailure );
}.bind(this));
// var unitLoaded = 0;
//
// var loadUnitSuccess = function () {
// unitLoaded++;
// if( unitLoaded === this.options.units.length ){
// this.unitLoaded = true;
// if( this.includeLoaded ){
// afterLoadSelectItemFun();
// }
// }
// }.bind(this);
// var loadUnitFailure = loadUnitSuccess;
//
// this.loadInclude( function () {
// this.includeLoaded = true;
// if( this.unitLoaded ){
// afterLoadSelectItemFun();
// }
// }.bind(this));
// this.options.units.each(function(unit){
//
// var container = new Element("div").inject( this.itemAreaNode );
//
// if (typeOf(unit)==="string"){
// this.orgAction.getUnit(unit, function(json){
// if (json.data){
// var category = this._newItemCategory("ItemUnitCategory", json.data, this, container);
// this.subCategorys.push( category );
// }
// loadUnitSuccess();
// }.bind(this), function(){
// this.orgAction.listUnitByKey(function(json){
// if (json.data.length){
// json.data.each(function(data){
// var category = this._newItemCategory("ItemUnitCategory", data, this, container);
// this.subCategorys.push( category );
// }.bind(this))
// }
// loadUnitSuccess();
// }.bind(this), loadUnitFailure, unit);
// }.bind(this));
// }else{
// this.orgAction.getUnit(function(json){
// if (json.data){
// var category = this._newItemCategory("ItemUnitCategory", json.data, this, container);
// this.subCategorys.push( category );
// }
// loadUnitSuccess();
// }.bind(this), loadUnitFailure, unit.distinguishedName);
// }
//
// }.bind(this));
}else{
// this.loadInclude( function () {
// this.includeLoaded = true;
......
......@@ -20,79 +20,100 @@ MWF.xApplication.Selector.Unit = new Class({
var afterLoadSelectItemFun = this.afterLoadSelectItem.bind(this);
if (this.options.units.length){
var unitLoaded = 0;
var loadUnitSuccess = function () {
unitLoaded++;
if( unitLoaded === this.options.units.length ){
afterLoadSelectItemFun();
var unitList = [];
for( var i=0 ; i<this.options.units.length; i++ ){
var unit = this.options.units[i];
if( typeOf( unit ) === "string" ){
unitList.push(unit);
}else if( typeOf(unit)==="object"){
unitList.push(unit.id || unit.distinguishedName || unit.unique || unit.levelName);
}
}.bind(this);
var loadUnitFailure = loadUnitSuccess;
this.options.units.each(function(unit){
var container = new Element("div").inject( this.itemAreaNode );
// this.action.listUnitByKey(function(json){
// if (json.data.length){
// json.data.each(function(data){
// if (data.subDirectUnitCount) var category = this._newItemCategory("ItemCategory", data, this, this.itemAreaNode);
// }.bind(this));
// }
// }.bind(this), null, comp);
if (typeOf(unit)==="string"){
// this.orgAction.listUnitByKey(function(json){
// if (json.data.length){
// json.data.each(function(data){
// if (data.subDirectUnitCount) var category = this._newItemCategory("ItemCategory", data, this, this.itemAreaNode);
// }.bind(this));
// }
// }.bind(this), null, unit);
this.orgAction.getUnit(function(json){
json.data = typeOf( json.data ) == "object" ? [json.data] : json.data;
if (json.data.length){
json.data.each( function(data){
if( this.options.expandSubEnable ){
if (data.subDirectUnitCount){
var category = this._newItemCategory("ItemCategory", data, this, container );
this.subCategorys.push(category);
}
}else{
var item = this._newItem( data, this, container );
this.items.push( item );
this.subItems.push(item);
}
}.bind(this));
}
loadUnitSuccess();
}.bind(this), loadUnitFailure, unit);
}else{
this.orgAction.getUnit(function(json){
json.data = typeOf( json.data ) == "object" ? [json.data] : json.data;
if (json.data.length){
json.data.each( function(data){
if( this.options.expandSubEnable ) {
if (data.subDirectUnitCount){
var category = this._newItemCategory("ItemCategory", data, this, container );
this.subCategorys.push(category);
}
}else{
var item = this._newItem(data, this, container );
this.items.push( item );
this.subItems.push(item);
}
}.bind(this));
}
o2.Actions.load("x_organization_assemble_express").UnitAction.listObject( {"unitList" : unitList} , function (json) {
debugger;
if (json.data.length){
json.data.each( function(data){
if( this.options.expandSubEnable ) {
if (data.subDirectUnitCount){
var category = this._newItemCategory("ItemCategory", data, this, this.itemAreaNode );
this.subCategorys.push(category);
}
}else{
var item = this._newItem(data, this, this.itemAreaNode );
this.items.push( item );
this.subItems.push(item);
}
loadUnitSuccess();
}.bind(this), loadUnitFailure, unit.id);
//if (unit.subDirectUnitCount) var category = this._newItemCategory("ItemCategory", unit, this, this.itemAreaNode);
}.bind(this));
}
}.bind(this));
afterLoadSelectItemFun();
}.bind(this), afterLoadSelectItemFun )
// var unitLoaded = 0;
//
// var loadUnitSuccess = function () {
// unitLoaded++;
// if( unitLoaded === this.options.units.length ){
// afterLoadSelectItemFun();
// }
// }.bind(this);
// var loadUnitFailure = loadUnitSuccess;
//
// this.options.units.each(function(unit){
//
// var container = new Element("div").inject( this.itemAreaNode );
//
// // this.action.listUnitByKey(function(json){
// // if (json.data.length){
// // json.data.each(function(data){
// // if (data.subDirectUnitCount) var category = this._newItemCategory("ItemCategory", data, this, this.itemAreaNode);
// // }.bind(this));
// // }
// // }.bind(this), null, comp);
//
// if (typeOf(unit)==="string"){
// this.orgAction.getUnit(function(json){
// json.data = typeOf( json.data ) == "object" ? [json.data] : json.data;
// if (json.data.length){
// json.data.each( function(data){
// if( this.options.expandSubEnable ){
// if (data.subDirectUnitCount){
// var category = this._newItemCategory("ItemCategory", data, this, container );
// this.subCategorys.push(category);
// }
// }else{
// var item = this._newItem( data, this, container );
// this.items.push( item );
// this.subItems.push(item);
// }
// }.bind(this));
// }
// loadUnitSuccess();
// }.bind(this), loadUnitFailure, unit);
//
//
// }else{
// this.orgAction.getUnit(function(json){
// json.data = typeOf( json.data ) == "object" ? [json.data] : json.data;
// if (json.data.length){
// json.data.each( function(data){
// if( this.options.expandSubEnable ) {
// if (data.subDirectUnitCount){
// var category = this._newItemCategory("ItemCategory", data, this, container );
// this.subCategorys.push(category);
// }
// }else{
// var item = this._newItem(data, this, container );
// this.items.push( item );
// this.subItems.push(item);
// }
// }.bind(this));
// }
// loadUnitSuccess();
// }.bind(this), loadUnitFailure, unit.id);
// //if (unit.subDirectUnitCount) var category = this._newItemCategory("ItemCategory", unit, this, this.itemAreaNode);
// }
//
// }.bind(this));
}else{
this.orgAction.listTopUnit(function(json){
json.data.each(function(data){
......
......@@ -1557,13 +1557,13 @@ MWF.APPOrg.UnitOptions = new Class({
if (typeOf(v)!=="array") v = (v) ? [v.toString()] : [];
v.each(function(d){
if (d){
if (typeOf(d)==="string"){
var data;
this.orgAction.getUnit(function(json){ data = json.data }.bind(this), null, d, false);
rangeValues.push(data);
}else{
// if (typeOf(d)==="string"){
// var data;
// this.orgAction.getUnit(function(json){ data = json.data }.bind(this), null, d, false);
// rangeValues.push(data);
// }else{
rangeValues.push(d);
}
// }
}
}.bind(this));
}.bind(this));
......@@ -1573,13 +1573,13 @@ MWF.APPOrg.UnitOptions = new Class({
if (typeOf(v)!=="array") v = (v) ? [v.toString()] : [];
v.each(function(d){
if (d){
if (typeOf(d)==="string"){
var data;
this.orgAction.getUnit(function(json){ data = json.data }.bind(this), null, d, false);
rangeValues.push(data);
}else{
// if (typeOf(d)==="string"){
// var data;
// this.orgAction.getUnit(function(json){ data = json.data }.bind(this), null, d, false);
// rangeValues.push(data);
// }else{
rangeValues.push(d);
}
// }
}
}.bind(this));
}
......@@ -1748,13 +1748,13 @@ MWF.APPOrg.IdentityOptions = new Class({
if (typeOf(v)!=="array") v = (v) ? [v.toString()] : [];
v.each(function(d){
if (d){
if (typeOf(d)==="string"){
var data;
this.orgAction.getUnit(function(json){ data = json.data }.bind(this), null, d, false);
rangeValues.push(data);
}else{
// if (typeOf(d)==="string"){
// var data;
// this.orgAction.getUnit(function(json){ data = json.data }.bind(this), null, d, false);
// rangeValues.push(data);
// }else{
rangeValues.push(d);
}
// }
}
}.bind(this));
}.bind(this));
......@@ -1764,13 +1764,13 @@ MWF.APPOrg.IdentityOptions = new Class({
if (typeOf(v)!=="array") v = (v) ? [v.toString()] : [];
v.each(function(d){
if (d){
if (typeOf(d)==="string"){
var data;
this.orgAction.getUnit(function(json){ data = json.data }.bind(this), null, d, false);
rangeValues.push(data);
}else{
// if (typeOf(d)==="string"){
// var data;
// this.orgAction.getUnit(function(json){ data = json.data }.bind(this), null, d, false);
// rangeValues.push(data);
// }else{
rangeValues.push(d);
}
// }
}
}.bind(this));
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册