MWF.xApplication.Selector = MWF.xApplication.Selector || {}; MWF.xDesktop.requireApp("Selector", "IdentityWidthDuty", null, false); MWF.xApplication.Selector.IdentityWidthDutyCategoryByUnit = new Class({ Extends: MWF.xApplication.Selector.IdentityWidthDuty, options: { "style": "default", "count": 0, "title": MWF.xApplication.Selector.LP.selectIdentity, "dutys": [], "units": [], "values": [], "zIndex": 1000, "expand": false, "noUnit" : false, "include" : [], //增加的可选项 "resultType" : "", //可以设置成个人,那么结果返回个人 "expandSubEnable": true, "selectAllEnable" : true, //分类是否允许全选下一层 "exclude" : [], "dutyUnitLevelBy" : "duty", //组织层级是按身份所在群组还是职务, "selectType" : "identity" }, loadSelectItems: function(addToNext){ //根据组织分类展现职务 if( this.options.resultType === "person" ){ if( this.titleTextNode ){ this.titleTextNode.set("text", MWF.xApplication.Selector.LP.selectPerson ); }else{ this.options.title = MWF.xApplication.Selector.LP.selectPerson; } } if (this.options.dutys.length){ this.loadInclude( function () { this.includeLoaded = true; if( this.dutyLoaded ){ this.afterLoadSelectItem(); } }.bind(this)); if( this.options.units.length ){ var units = []; for( var i=0 ;i -1 && (this.level1Container.length > index) && this.level1Container[i] )container = this.level1Container[i]; } var category = this._newItemCategory("ItemCategory",unit, this, container ); this.subCategorys.push(category); } }else{ this._loadSelectItemsByDutyUnit( unit ); } } }, getIndexFromUnitOption : function( unit ){ if( !this.unitStringList || !this.unitStringList.length )return -1; var idx = -1; if(idx == -1 && unit.distinguishedName)idx = this.unitStringList.indexOf( unit.distinguishedName ); if(idx == -1 && unit.id)idx = this.unitStringList.indexOf( unit.id ); if(idx == -1 && unit.unique)idx = this.unitStringList.indexOf( unit.unique ); if(idx == -1 && unit.levelName)idx = this.unitStringList.indexOf( unit.levelName ); return idx }, isUnitContain : function( d ){ if( this.options.units.length === 0 )return true; if( !this.unitFlagMap ){ this.unitFlagMap = {}; this.options.units.each( function( e ){ if( !e )return; this.unitFlagMap[ typeOf( e ) === "string" ? e : ( e.distinguishedName || e.id || e.unique || e.employee || e.levelName) ] = true; }.bind(this)); } var map = this.unitFlagMap; return ( d.distinguishedName && map[ d.distinguishedName ] ) || ( d.levelName && map[ d.levelName ] ) || ( d.id && map[ d.id ] ) || ( d.unique && map[ d.unique ] ); }, listAllIdentityInUnitObject : function(){ var unitArray = []; for( var i=0; i0 ){ 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 ) ){ 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)) } 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.loadSub() } }.bind(this)); } this.loaded = true; if (callback) callback( ); }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; this.itemLoaded = true; if (callback) callback( ); }else{ if (callback) callback( ); } }, loadItemChildren: function(callback){ if (!this.itemLoaded){ if( this.data.identityList && this.data.identityList.length>0 ){ 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 ) ){ 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; if (callback) callback( ); }else{ if (callback) callback( ); } }, _hasChild: function(){ return (this.data.unitList && this.data.unitList.length > 0) || (this.data.identityList && this.data.identityList.length > 0); }, _hasChildCategory : function(){ return (this.data.unitList && this.data.unitList.length > 0); }, _hasChildItem: function(){ return this.data.identityList && this.data.identityList.length > 0; } }); MWF.xApplication.Selector.IdentityWidthDutyCategoryByUnit.ItemUnitCategory = new Class({ Extends: MWF.xApplication.Selector.IdentityWidthDuty.ItemUnitCategory }); MWF.xApplication.Selector.IdentityWidthDutyCategoryByUnit.ItemGroupCategory = new Class({ Extends: MWF.xApplication.Selector.IdentityWidthDuty.ItemGroupCategory }); MWF.xApplication.Selector.IdentityWidthDutyCategoryByUnit.Filter = new Class({ Extends: MWF.xApplication.Selector.IdentityWidthDuty.Filter });