IdentityWidthDutyCategoryByUnit.js 24.9 KB
Newer Older
R
roo00 已提交
1 2 3
MWF.xApplication.Selector = MWF.xApplication.Selector || {};
MWF.xDesktop.requireApp("Selector", "IdentityWidthDuty", null, false);
MWF.xApplication.Selector.IdentityWidthDutyCategoryByUnit = new Class({
4
    Extends: MWF.xApplication.Selector.IdentityWidthDuty,
R
roo00 已提交
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
    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" : [],
20 21
        "dutyUnitLevelBy" : "duty", //组织层级是按身份所在群组还是职务,
        "selectType" : "identity"
R
roo00 已提交
22
    },
U
unknown 已提交
23 24 25 26
    _init : function(){
        this.selectType = "identity";
        this.className = "IdentityWidthDutyCategoryByUnit";
    },
R
roo00 已提交
27 28 29 30 31 32 33 34 35
    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;
            }
        }
U
unknown 已提交
36 37 38 39
        if( this.options.disabled ){
            this.afterLoadSelectItem();
            return;
        }
R
roo00 已提交
40 41

        if (this.options.dutys.length){
42 43 44 45 46 47
            this.loadInclude( function () {
                this.includeLoaded = true;
                if( this.dutyLoaded ){
                    this.afterLoadSelectItem();
                }
            }.bind(this));
R
roo00 已提交
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100
            if( this.options.units.length ){

                var units = [];
                for( var i=0 ;i<this.options.units.length; i++ ){
                    var unit = this.options.units[i];
                    if( typeOf( unit ) === "string" ){
                        units.push( unit )
                    }else{
                        units.push( unit.distinguishedName || unit.unique || unit.id || unit.levelName )
                    }
                }
                this.unitStringList = units;

                var getAllIdentity = function( unitList ){
                    o2.Actions.load("x_organization_assemble_express").UnitDutyAction.listIdentityWithUnitWithNameObject({
                        nameList : this.options.dutys,
                        unitList : unitList
                    }, function( json ){
                        this._loadSelectItems( json.data )
                    }.bind(this))
                }.bind(this);

                if( this.options.expandSubEnable ){
                    o2.Actions.load("x_organization_assemble_express").UnitAction.listWithUnitSubNested({
                        unitList : units
                    }, function( json ){
                        getAllIdentity( units.combine( json.data ? json.data.unitList : [] ));
                    }.bind(this))
                }else{
                    getAllIdentity( units );
                }
            }else{
                var identityList = [];
                var count = 0;
                this.options.dutys.each( function( d ){
                    this.orgAction.listIdentityWithDuty(function(json){
                        count++;
                        identityList = identityList.combine( json.data );
                        if( this.options.dutys.length === count )this._loadSelectItems( identityList );
                    }.bind(this), function(){
                        count++;
                        if( this.options.dutys.length === count )this._loadSelectItems( identityList );
                    }.bind(this), d );
                }.bind(this));
            }
            //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);
            //}.bind(this));
        }
    },
    _loadSelectItems : function( identityList ){
NoSubject's avatar
NoSubject 已提交
101
        //this.listAllIdentityInUnitObject( identityList );
R
roo00 已提交
102
        var unitTree = this.listNestedUnitByIdentity( identityList );
U
unknown 已提交
103
        this.uniqueIdentity( unitTree );
R
roo00 已提交
104
        if( this.options.dutyUnitLevelBy === "duty" ){
105 106 107 108 109
            this.level1Container = [];
            if( this.options.units && this.options.units.length ){
                var div = new Element( "div" ).inject(this.itemAreaNode);
                this.level1Container.push(div);
            }
R
roo00 已提交
110 111 112 113
            this._loadSelectItemsByDutyUnit(unitTree);
        }else{
            this._loadSelectItemsByIdentityUnit(unitTree);
        }
114 115 116 117 118

        this.dutyLoaded = true;
        if( this.includeLoaded ){
            this.afterLoadSelectItem();
        }
R
roo00 已提交
119 120 121 122 123 124
    },
    _loadSelectItemsByIdentityUnit : function( unitTree ){
        if( !unitTree.unitList )return;
        this.sortUnit( unitTree.unitList );
        for( var i=0; i< unitTree.unitList.length; i++ ){
            var unit = unitTree.unitList[i];
U
unknown 已提交
125
            // if( !this.isExcluded( unit ) ) {
R
roo00 已提交
126 127
                var category = this._newItemCategory("ItemCategory",unit, this, this.itemAreaNode);
                this.subCategorys.push(category);
U
unknown 已提交
128
            // }
R
roo00 已提交
129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153
        }
    },
    sortUnit : function( unitList ){
        if( this.options.dutyUnitLevelBy === "duty" ){
            if( this.options.units ){
                unitList.sort( function(a, b){
                    var idxA = this.getIndexFromUnitOption( a );
                    var idxB = this.getIndexFromUnitOption( b );
                    idxA = idxA === -1 ? 9999999 + (a.orderNumber || 9999999) : idxA;
                    idxB = idxB === -1 ? 9999999 + (b.orderNumber || 9999999) : idxB;
                    return idxA - idxB;
                }.bind(this))
            }else{
                unitList.sort( function(a, b){
                    return (a.orderNumber || 9999999) - (b.orderNumber || 9999999);
                }.bind(this))
            }
        }else{
            unitList.sort( function(a, b){
                return (a.orderNumber || 9999999) - (b.orderNumber || 9999999);
            }.bind(this))
        }
    },
    _loadSelectItemsByDutyUnit : function( unitTree ){
        if( !unitTree.unitList )return;
154
        // this.sortUnit( unitTree.unitList );
R
roo00 已提交
155 156 157
        for( var i=0; i< unitTree.unitList.length; i++ ){
            var unit = unitTree.unitList[i];
            if( this.isUnitContain( unit ) ){
U
unknown 已提交
158
                // if( !this.isExcluded( unit ) ) {
159 160 161 162 163 164
                    var container = this.itemAreaNode;
                    if( this.level1Container && this.level1Container.length ){
                        var index = this.getIndexFromUnitOption( unit );
                        if( index > -1 && (this.level1Container.length > index) && this.level1Container[i] )container = this.level1Container[i];
                    }
                    var category = this._newItemCategory("ItemCategory",unit, this, container );
R
roo00 已提交
165
                    this.subCategorys.push(category);
U
unknown 已提交
166
                // }
R
roo00 已提交
167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195
            }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 ] );
    },
NoSubject's avatar
NoSubject 已提交
196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213
    listAllIdentityInUnitObject : function(){
        var unitArray = [];
        for( var i=0; i<identityList.length; i++ ){
            unitArray.push( identityList[i].unit || identityList[i].unitLevelName );
        }
        o2.Actions.load("x_organization_assemble_express").UnitAction.listObject({
            unitList : unitArray
        }, function(json){
            this.allIdentityInUnitObject = {};
            json.data.each( function( u ){
                this.allIdentityInUnitObject[u.levelName] = u;
            }.bind(this));
            if(callback)callback();
        }.bind(this), null, false)
    },
    getUnitOrderNumber : function( unit ){
        return this.allIdentityInUnitObject[unit.levelName].orderNumber;
    },
R
roo00 已提交
214 215 216 217 218 219 220 221 222 223 224
    listAllUnitObject: function( identityList, callback ){
        var key = this.options.dutyUnitLevelBy === "duty" ? "matchUnitLevelName" : "unitLevelName";
        var unitArray = [];
        for( var i=0; i<identityList.length; i++ ){
            var levelNames = identityList[i][key];
            //if( !levelNames && key === "matchUnitLevelName" )levelNames = identityList[i].unitLevelName;
            var unitLevelNameList = levelNames.split("/");
            var nameList = [];
            for( var j=0; j<unitLevelNameList.length; j++ ){
                nameList.push( unitLevelNameList[j] );
                var name = nameList.join("/");
NoSubject's avatar
NoSubject 已提交
225 226 227
                if( !unitArray.contains( name ) ){
                    unitArray.push( name );
                }
R
roo00 已提交
228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250
            }
        }
        o2.Actions.load("x_organization_assemble_express").UnitAction.listObject({
            unitList : unitArray
        }, function(json){
            this.allUnitObject = {};
            json.data.each( function( u ){
                this.allUnitObject[u.levelName] = u;
            }.bind(this));
            if(callback)callback();
        }.bind(this), null, false)
    },
    listNestedUnitByIdentity : function( identityList ){
        this.listAllUnitObject( identityList);
        return this._listNestedUnitByIdentity( identityList );
    },
    _listNestedUnitByIdentity : function( identityList ){
        debugger;
        //identityList = Array.unique(identityList);
        var key = this.options.dutyUnitLevelBy === "duty" ? "matchUnitLevelName" : "unitLevelName";
        //根据unitLevelName整合成组织树
        var unitTree = {};
        for( var i=0; i<identityList.length; i++ ){
U
unknown 已提交
251 252 253
            var flag = true;
            if( this.isExcluded( identityList[i] ) )continue;

R
roo00 已提交
254 255 256 257 258 259 260 261 262
            var levelNames = identityList[i][key];
            //if( !levelNames && key === "matchUnitLevelName" )levelNames = identityList[i].unitLevelName;
            var unitLevelNameList = levelNames.split("/");
            var nameList = [];
            var tree = unitTree;
            for( var j=0; j<unitLevelNameList.length; j++ ){
                nameList.push( unitLevelNameList[j] );
                var name = nameList.join("/");

U
unknown 已提交
263 264 265 266 267
                if( this.isExcluded( this.allUnitObject[name] || {} ) ){
                    flag = false;
                    break;
                }

R
roo00 已提交
268 269 270 271 272 273 274 275 276 277
                if( !tree.unitList )tree.unitList = [];
                var found = false;
                for( var k=0; k<tree.unitList.length; k++ ){
                    if( tree.unitList[k].levelName == name ){
                        tree = tree.unitList[k];
                        found = true;
                        break;
                    }
                }
                if( !found ){
U
unknown 已提交
278 279 280
                    // var obj = {};
                    var obj = this.allUnitObject[name] || {};
                    obj.matchLevelName = name;
R
roo00 已提交
281 282 283
                    tree.unitList.push( obj );
                    tree = obj;
                }
U
unknown 已提交
284 285 286
                // if( !tree.distinguishedName ){
                //     tree = Object.merge( tree, this.allUnitObject[name] );
                // }
R
roo00 已提交
287
                if( !tree.identityList )tree.identityList = [];
U
unknown 已提交
288

R
roo00 已提交
289
            }
U
unknown 已提交
290
            if(flag)tree.identityList.push( identityList[i] );
R
roo00 已提交
291 292 293
        }
        return unitTree;
    },
U
unknown 已提交
294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315
    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;

U
unknown 已提交
316
        if( this.options.isCheckStatus ){
U
unknown 已提交
317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334
            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] );
            }
        }
    },
R
roo00 已提交
335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369
    //listNestedUnitByIdentity : function( identityList ){
    //    debugger;
    //    this.unitArray = [];
    //    var key = this.options.dutyUnitLevelBy === "duty" ? "matchUnitLevelName" : "unitLevelName";
    //    //根据unitLevelName整合成组织树
    //    var unitTree = {};
    //    for( var i=0; i<identityList.length; i++ ){
    //        var levelNames = identityList[i][key];
    //        //if( !levelNames && key === "matchUnitLevelName" )levelNames = identityList[i].unitLevelName;
    //        var unitLevelNameList = levelNames.split("/");
    //        var nameList = [];
    //        var tree = unitTree;
    //        for( var j=0; j<unitLevelNameList.length; j++ ){
    //            nameList.push( unitLevelNameList[j] );
    //            var name = nameList.join("/");
    //            if( !tree[ name ] ){
    //                tree[ name ] = {
    //                    name : unitLevelNameList[j],
    //                    levelName : name,
    //                    identityList : []
    //                };
    //                this.unitArray.push( name );
    //            }
    //            tree =  tree[name];
    //        }
    //        tree.identityList.push( identityList[i] );
    //    }
    //    return unitTree;
    //},
    _scrollEvent: function(y){
        return true;
    },
    _getChildrenItemIds: function(){
        return null;
    },
NoSubject's avatar
NoSubject 已提交
370 371
    _newItemCategory: function(type, data, selector, item, level, category, delay){
        return new MWF.xApplication.Selector.IdentityWidthDutyCategoryByUnit[type](data, selector, item, level, category, delay)
R
roo00 已提交
372 373 374 375 376 377 378 379 380
    },

    _listItemByKey: function(callback, failure, key){
        if (this.options.units.length) key = {"key": key, "unitList": this.options.units};
        this.orgAction.listIdentityByKey(function(json){
            if (callback) callback.apply(this, [json]);
        }.bind(this), failure, key);
    },
    _getItem: function(callback, failure, id, async){
381 382 383 384 385 386 387
        if( typeOf(id) === "string" ){
            this.orgAction.getIdentity(function(json){
               if (callback) callback.apply(this, [json]);
            }.bind(this), failure, ((typeOf(id)==="string") ? id : id.distinguishedName), async);
        }else{
            if (callback) callback.apply(this, [id]);
        }
R
roo00 已提交
388 389 390 391
        //this.orgAction.getIdentity(function(json){
        //    if (callback) callback.apply(this, [json]);
        //}.bind(this), failure, ((typeOf(id)==="string") ? id : id.distinguishedName), async);
    },
392 393
    _newItemSelected: function(data, selector, item, selectedNode){
        return new MWF.xApplication.Selector.IdentityWidthDutyCategoryByUnit.ItemSelected(data, selector, item, selectedNode)
R
roo00 已提交
394 395 396 397 398 399 400
    },
    _listItemByPinyin: function(callback, failure, key){
        if (this.options.units.length) key = {"key": key, "unitList": this.options.units};
        this.orgAction.listIdentityByPinyin(function(json){
            if (callback) callback.apply(this, [json]);
        }.bind(this), failure, key);
    },
U
unknown 已提交
401 402
    _newItem: function(data, selector, container, level, category, delay){
        return new MWF.xApplication.Selector.IdentityWidthDutyCategoryByUnit.Item(data, selector, container, level, category, delay);
R
roo00 已提交
403 404 405 406 407 408 409 410 411 412 413
    },
    _newItemSearch: function(data, selector, container, level){
        return new MWF.xApplication.Selector.IdentityWidthDutyCategoryByUnit.SearchItem(data, selector, container, level);
    }
    //_listItemNext: function(last, count, callback){
    //    this.action.listRoleNext(last, count, function(json){
    //        if (callback) callback.apply(this, [json]);
    //    }.bind(this));
    //}
});
MWF.xApplication.Selector.IdentityWidthDutyCategoryByUnit.Item = new Class({
414
    Extends: MWF.xApplication.Selector.IdentityWidthDuty.Item
R
roo00 已提交
415 416 417 418 419 420
});
MWF.xApplication.Selector.IdentityWidthDutyCategoryByUnit.SearchItem = new Class({
    Extends: MWF.xApplication.Selector.IdentityWidthDuty.SearchItem
});

MWF.xApplication.Selector.IdentityWidthDutyCategoryByUnit.ItemSelected = new Class({
421
    Extends: MWF.xApplication.Selector.IdentityWidthDuty.ItemSelected
R
roo00 已提交
422 423 424 425
});

MWF.xApplication.Selector.IdentityWidthDutyCategoryByUnit.ItemCategory = new Class({
    Extends: MWF.xApplication.Selector.IdentityWidthDuty.ItemCategory,
U
unknown 已提交
426 427 428
    _getShowName: function(){
        return this.data.name;
    },
U
unknown 已提交
429 430
    _addSelectedCount : function( count, nested ){
        debugger;
U
unknown 已提交
431
        var c = (this._getSelectedCount() || 0) + count;
U
unknown 已提交
432
        this.selectedCount = c;
433 434
        this.checkCountAndStatus(c);

U
unknown 已提交
435 436 437 438 439 440 441 442
        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;
    // },
443 444 445
    _getTotalCount : function(){
        return this.data.subNestedIdentityCount;
    },
U
unknown 已提交
446
    _getSelectedCount : function(){
U
unknown 已提交
447
        debugger;
U
unknown 已提交
448 449 450
        if( typeOf( this.selectedCount ) === "number" ){
            return this.selectedCount;
        }else{
U
unknown 已提交
451
            return 0;
U
unknown 已提交
452
        }
U
unknown 已提交
453 454 455
    },
    _checkStatus : function(){

U
unknown 已提交
456
    },
R
roo00 已提交
457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479
    isExisted : function( d ){
        if( !d )return true;
        if( !this.createdItemObject )this.createdItemObject = {};
        var map = this.createdItemObject;
        if(( d.distinguishedName && map[ d.distinguishedName ] ) ||
            ( d.levelName && map[ d.levelName ] ) ||
            ( d.id && map[ d.id ] ) ||
            ( d.unique && map[ d.unique ] )){
            return true;
        }else{
            //if( typeOf( d ) === "string" ){
            //    this.createdItemObject[ d ] = true;
            //}else{
            //    if( d.distinguishedName )this.createdItemObject[ d.distinguishedName ] = true;
            //    if( d.id )this.createdItemObject[ d.id ] = true;
            //    if( d.unique )this.createdItemObject[ d.unique ] = true;
            //    if( d.employee )this.createdItemObject[ d.employee ] = true;
            //    if( d.levelName )this.createdItemObject[ d.levelName ] = true;
            //}
            this.createdItemObject[ typeOf( d ) === "string" ? d : ( d.distinguishedName || d.id || d.unique || d.employee || d.levelName) ] = true;
            return false;
        }
    },
480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497
    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){
R
roo00 已提交
498
        if (!this.loaded){
499 500 501 502 503 504 505 506 507 508 509 510 511
            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 );
                            // }
U
unknown 已提交
512
                        // }
513 514 515
                    }.bind(this))
                }
                this.itemLoaded = true;
R
roo00 已提交
516 517 518 519 520 521 522
            }

            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 ){
U
unknown 已提交
523
                    // if( !this.selector.isExcluded( subData ) ) {
R
roo00 已提交
524 525 526
                        var category = this.selector._newItemCategory("ItemCategory", subData, this.selector, this.children, this.level + 1, this);
                        this.subCategorys.push( category );
                        category.loadSub()
U
unknown 已提交
527
                    // }
R
roo00 已提交
528 529 530 531
                }.bind(this));
            }

            this.loaded = true;
U
unknown 已提交
532

533
            if (callback) callback( true );
R
roo00 已提交
534 535 536 537
        }else{
            if (callback) callback( );
        }
    },
NoSubject's avatar
NoSubject 已提交
538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556
    loadCategoryChildren: function(callback){
        if (!this.categoryLoaded){
            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 ){
U
unknown 已提交
557 558
                    // if( !this.selector.isExcluded( identity ) ) {
                    //     if( !this.isExisted( identity ) ){
NoSubject's avatar
NoSubject 已提交
559 560 561
                            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 );
U
unknown 已提交
562 563
                        // }
                    // }
NoSubject's avatar
NoSubject 已提交
564 565 566 567 568 569 570 571
                }.bind(this))
            }
            this.itemLoaded = true;
            if (callback) callback( );
        }else{
            if (callback) callback( );
        }
    },
R
roo00 已提交
572 573 574 575
    _hasChild: function(){
        return (this.data.unitList && this.data.unitList.length > 0) ||
            (this.data.identityList && this.data.identityList.length > 0);
    },
NoSubject's avatar
NoSubject 已提交
576 577 578
    _hasChildCategory : function(){
        return (this.data.unitList && this.data.unitList.length > 0);
    },
R
roo00 已提交
579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595
    _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
});