department.js 29 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 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 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 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 154 155 156 157 158 159 160 161 162 163 164 165 166 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 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 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 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794
/**
 * Created by DEV005 on 2017/3/28.
 */
(function () {
    "user strict";
    var departmentIndexController = function ($scope, $modal, tutorialService, dialogService) {
        $scope.$emit('navShow', 0);
        $scope.$emit('subNavShow', 0);

        /*
         * pageNumber:当前页数
         * pageSize:页面显示个数
         * */
        $scope.vm = {
            pageSize: 0,
            isLoading:false
        };


        //页面绑定的树结构
        $scope.trees=[];

        //整个平级的树结构存储
        $scope.allTrees=[];

        /**/
        $scope.collapsed=false;

        /*一级树处理
        *   firstLevel
        * @param   list :array 未处理的原始数据
        * @param  allTrees:  将要生成的平级树结构
        *  row 一级栏目奇偶行
        *  level:等级
        *  visable  :是否显示
        *  childState:是否有子集
        *  collapsed: 图标是否打开
        * */
        function initTree (list,allTrees) {
            if(list.length > 0){
                /*一级树处理*/
                var rowNumber=0;
                angular.forEach(list,function(item){
                    //如果 parentId==null 则为一级树
                    if(item.parentId ==null){
                        if(rowNumber%2==0){
                            item.row="even";
                        }else{
                            item.row="odd";
                        }
                        rowNumber++;
                        item.level = 0;                             //等级
                        item.visable=true;                         //显示
                        allTrees.push(item);
                        //查询树的子集
                        getTreeChild(item.id,list,allTrees,0);
                    }
                });

                //判断每个树是否有子集
                hasChild(allTrees);
            }
        }


        /**
         * getTreeChild  获取树的子集
         * 递归查找下一级
         * @param pid  父级id
         * @param list :array 未处理的原始数据
         *  @param  allTrees:  将要生成的平级树结构
         * @param level     层级数
         */
        var getTreeChild = function(pid,list,allTrees,level){
            level ++;
            angular.forEach(list,function(item){
                if(item.parentId === pid){
                    item.level = level;
                    item.visable=false;
                    allTrees.push(item);

                    //递归查询树的子集
                    getTreeChild(item.id,list,allTrees,level);
                }
            });
        };

       /*
       * hasChild  通过相邻两个数据判断后面一条数据是否是前面一条数据的子集
       *            childState:为是否含有子集,true为有,false为没有
       *            collapsed:树接头前面的图标是否是打开状态  true为“+”未打开,false为 “-” 打开
       *
        * @param  allTrees:  完整是平级树结构生成
       * */
        function hasChild (allTrees) {
            for( var i=0; i< allTrees.length-1;i++){
                if(allTrees[i].id == allTrees[i+1].parentId){
                    allTrees[i].childState=true;
                    allTrees[i].collapsed=true;
                }else{
                    allTrees[i].childState=false;
                    allTrees[i].collapsed=false;
                }
            }

            //最后一条数据处理  -
            allTrees[allTrees.length-1].childState=false;
        }


        var getParent = function(pId,orgList){
            angular.forEach($scope.allTrees,function(org){
                if(org.id === pId){
                    orgList.push(org);
                    getParent(org.parentId,orgList);
                }
            });
        };


        var countChild = function(pid,orgList){
            angular.forEach($scope.allTrees,function(org){
                if(org.parentId === pid){
                    orgList.push(org);
                    countChild(org.id,orgList);
                }
            });
        };

        /*
        * getTree  获取树的基本数据 一次性获取
        * */
        function getTree() {
            $scope.vm.isLoading=true;
            tutorialService.searchDepartment($scope.vm).success(function(data){
                $scope.vm.isLoading=false;
                if(data.errors === null || data.errors.length > 0){
                    dialogService.tip(data.errors);
                }else{
                    //数据处理
                    initTree(data.result,$scope.allTrees);

                    //将处理完成的数据负值给页面上的树
                    angular.extend($scope.trees,$scope.allTrees);
                }
            });
        }
        getTree();


        $scope.collapseTree = function(tree,parent){
            angular.forEach(tree,function(organization) {
                if(organization.parentId === parent.id){
                    organization.visable = (!parent.collapsed && parent.visable);
                    $scope.collapseTree(tree,organization);
                }
            });
        };
        $scope.toggle = function(i) {
            $scope.trees[i].collapsed=! $scope.trees[i].collapsed;
            $scope.collapseTree($scope.trees,$scope.trees[i]);

        };

        

        //删除树
        $scope.delete = function(tree) {
            var dialogDefaults = {
                size:"sm"
            };
            var dialogOptions = {
                closeButtonText: "取消",
                actionButtonText: "确定删除",
                headerText: "继续....?",
                bodyText: "您确定要删除组织吗?",
                callback: function () {
                    tutorialService.deleteDepartment({id:tree.id}).success(function(data){
                        if(data.errors === null || data.errors.length > 0){
                            dialogService.tip(data.errors);
                        }else{
                            /**
                             * 获取树的值在数组中的位置
                             * @param data 当前数据
                             * @returns {number} 返回位置
                             */
                            var location = function(data,dataList){
                                for(var i=0; i < dataList.length; i++){
                                    if(dataList[i].id===data.id){
                                        return  i;
                                    }
                                }
                            };

                            /**
                             * 查找兄弟的个数
                             * @param data       当前数据
                             * @param dataList    查询的数组
                             * @returns {number}  返回兄弟和自己的个数
                             */

                            var brothers = function(data,dataList){
                                var number = 0;
                                for(var i=0; i < dataList.length; i++){
                                    if(dataList[i].parentId===data.parentId){
                                        number++;
                                    }
                                }
                                return number;
                            };

                            /**
                             * 查找父级别位置
                             * @param data
                             * @param dataList
                             * @returns {number}
                             */

                            var locationParent = function(data,dataList){
                                for(var i=0; i < dataList.length; i++){
                                    if(dataList[i].id ===data.parentId){
                                        return i;
                                    }
                                }
                            };
                            if( brothers(tree,$scope.trees)===1){
                                if(locationParent(tree,$scope.trees)!=null){
                                    $scope.trees[locationParent(tree,$scope.trees)].childState = false;
                                }
                            }

                            if( brothers(tree,$scope.allTrees)===1){
                                if(locationParent(tree,$scope.allTrees)!=null){
                                    $scope.allTrees[locationParent(tree,$scope.allTrees)].childState = false;
                                }
                            }

                            $scope.trees.splice(location(tree,$scope.trees),1);
                            $scope.allTrees.splice(location(tree,$scope.allTrees),1);

                            /*一级判断基偶数*/
                            var rowNumber=0;
                            angular.forEach($scope.trees,function(tree){
                                if(tree.level == 0){
                                    if(rowNumber%2==0){
                                        tree.row="even";
                                    }else{
                                        tree.row="odd";
                                    }
                                    rowNumber++;
                                }
                            });

                            dialogService.tip([{"message":"删除成功!" }]);
                        }
                    });
                }
            };
            dialogService.confirm(dialogDefaults, dialogOptions);

        };

        //树编辑
        $scope.edit = function (tree) {
            var item=angular.copy(tree);

            //弹出窗口
            var modalInstance = $modal.open({
                templateUrl: "eidtTree.html",
                controller:EidtTree,
                size:"",
                resolve: {
                    items: function () {
                        return item;
                    }
                }
            });
            modalInstance.result.then(function (data){

                /**
                 * 获取树的值在数组中的位置
                 * @param data 当前数据
                 * @returns
                 * {number} 返回位置
                 */
               var location = function(data,dataList){
                     for(var i=0; i < dataList.length; i++){
                         if(dataList[i].id==data.id){
                             return i;
                         }
                     }
                 };

               /* *
                *数据新加字段提取
                row 一级栏目奇偶行
                *  level:等级
                *  visable  :是否显示
                *  childState:是否有子集
                *  collapsed: 图标是否打开*/

                var treesIndex=location(data,$scope.trees);
                var allTreesIndex=location(data,$scope.allTrees);

                /*对应的新字段*/
                var treesItem=angular.extend($scope.trees[treesIndex],data);
                var allTreesItem=angular.extend($scope.allTrees[allTreesIndex],data);

                   //数据替换
                 $scope.trees.splice(treesIndex,1,treesItem);
                 $scope.allTrees.splice(allTreesIndex,1,allTreesItem);
            });
        };

        //新建树节点
        $scope.addTree = function (tree) {
            var item={};
            if(tree != null){
                item = {
                    parentName  :tree.name,
                    parentId :tree.id
                };
            }else{
                item = {
                    parentName  :"",
                    parentId :""
                };
            }

            //弹出窗口
            var modalInstance = $modal.open({
                templateUrl: "eidtTree.html",
                controller:EidtTree,
                size:"",
                resolve: {
                    items: function () {
                        return item;
                    }
                }
            });
            modalInstance.result.then(function (data) {
                //获取父级位置
                var location = function(data,dataList){
                    for(var i=0; i < dataList.length; i++){
                        if(dataList[i].id==data.parentId){
                            return  i;
                        }
                    }
                };

                // 从后向前查找子节点最后一个的位置

                var locationEndChild=function(index,treeList){
                    for(var i=treeList.length-1;i>=0; i--){
                        if(treeList[index].id==treeList[i].parentId){
                            return locationEndChild(i,treeList);
                        }
                    }
                    return index;
                };

                if(data.parentId==""){
                    //增加顶级树
                    data.childState = false;   //没有子集
                    data.collapsed = false;     //"-"号
                    data.visable = true;        //显示
                    data.level=0;                  //层级为0
                    $scope.trees.push(data);
                    $scope.allTrees.push(data);


                    /*一级判断基偶数*/
                    var rowNumber=0;
                    angular.forEach($scope.trees,function(tree){
                        if(tree.level == 0){
                            if(rowNumber%2==0){
                                tree.row="even";
                            }else{
                                tree.row="odd";
                            }
                            rowNumber++;
                        }
                    });
                }else{
                    //父级数据
                    var parentItem=$scope.trees[location(data,$scope.trees)];
                    //增加子级树
                    parentItem.childState = true;   //父级子集为有
                    parentItem.collapsed = false;   //图标为“-”

                    //改变兄弟节点的所以状态   显示出来
                    for(var i=0;i<$scope.trees.length; i++){
                        if($scope.trees[i].parentId===data.parentId){
                            $scope.trees[i].visable=true;
                        }
                    }

                    data.childState = false;         //没有子集
                    data.collapsed = false;          //”-“
                    data.visable = true;               //显示
                    data.level =  parentItem.level+1;  //等级

                    $scope.trees.splice(locationEndChild(location(data,$scope.trees),$scope.trees)+1,0,data);
                    $scope.allTrees.splice(locationEndChild(location(data,$scope.allTrees),$scope.allTrees)+1,0,data);
                }
            });
        };

        $scope.sortUp=function(tree){
            $scope.sortRequestList=[];
            $scope.beforeDomList=[];
            $scope.afterDomList=[];
            $scope.org={};
            $scope.orgUp={};
            //复制
            angular.extend($scope.org ,tree);
            var findIndex=0;
            for( var i=0; i< $scope.trees.length;i++){
                if($scope.org.id==$scope.trees[i].id){
                    findIndex++;
                }
                if($scope.org.parentId==$scope.trees[i].parentId){//无上级
                    if(findIndex==0){
                        var object={
                            id:$scope.trees[i].id,
                            orderIndex:0,
                            rowVersion:$scope.trees[i].rowVersion
                        }
                        $scope.beforeDomList.push(object);
                    }
                    if(findIndex==1&&$scope.org.id!=$scope.trees[i].id){
                        var object={
                            id:$scope.trees[i].id,
                            orderIndex:0,
                            rowVersion:$scope.trees[i].rowVersion
                        }
                        $scope.afterDomList.push(object);
                    }

                }
            }

            if($scope.beforeDomList.length==0){
                dialogService.error("已排序至第一位置,请检查数据");
                return;
            }
            $scope.sort={
                id:$scope.org.id,
                orderIndex:0,
                rowVersion:$scope.org.rowVersion
            }
            $scope.sortRequestList.push($scope.sort);

            $scope.sortUp={
                id:$scope.beforeDomList[$scope.beforeDomList.length-1].id,
                orderIndex:1,
                rowVersion:$scope.beforeDomList[$scope.beforeDomList.length-1].rowVersion
            }
            $scope.sortRequestList.push($scope.sortUp);

            var beforeOrderIndex=-1;
            if($scope.beforeDomList.length!=0){
                for( var i=$scope.beforeDomList.length-2; i>=0;i--){
                    var sort={
                        id:$scope.beforeDomList[i].id,
                        orderIndex:beforeOrderIndex,
                        rowVersion:$scope.beforeDomList[i].rowVersion
                    }
                    $scope.sortRequestList.push(sort);
                    beforeOrderIndex--;
                }
            }


            if($scope.afterDomList.length!=0){
                for( var i=0; i<$scope.afterDomList.length;i++){
                    var sort={
                        id:$scope.afterDomList[i].id,
                        orderIndex:2+i,
                        rowVersion:$scope.afterDomList[i].rowVersion
                    }
                    $scope.sortRequestList.push(sort);
                }
            }



            console.info($scope.org);
            console.info($scope.orgUp);

            HrService.apiHROrgListSort({sortRequestList:$scope.sortRequestList}).success(function(data){
                if(data.errors === null || data.errors.length > 0){
                    dialogService.tip(data.errors);
                }else{
                    dialogService.tip([{"message": "排序成功!"}],"/master/organization/index.htm",1000);
                    //清空数据
                    $scope.org={};
                }
            }) ;
        };

        /*排序处理*/
        $scope.sortDown=function(tree){
            $scope.sortRequestList=[];
            $scope.beforeDomList=[];
            $scope.afterDomList=[];
            $scope.item={};
            $scope.itemDown={};
            //复制
            angular.extend($scope.item ,tree);
            var findIndex=0;
            for( var i=0; i< $scope.trees.length;i++){
                if($scope.item.id==$scope.trees[i].id){
                    findIndex++;
                }
                if($scope.item.parentId==$scope.trees[i].parentId){//无上级
                    if(findIndex==0){
                        var object={
                            id:$scope.trees[i].id,
                            orderIndex:0,
                            rowVersion:$scope.trees[i].rowVersion
                        }
                        $scope.beforeDomList.push(object);
                    }
                    if(findIndex==1&&$scope.item.id!=$scope.trees[i].id){
                        var object={
                            id:$scope.trees[i].id,
                            orderIndex:0,
                            rowVersion:$scope.trees[i].rowVersion
                        }
                        $scope.afterDomList.push(object);
                    }

                }
            }

            if($scope.afterDomList.length==0){
                dialogService.error("已排序至最后位置,请检查数据");
                return;
            }

            $scope.sort={
                id:$scope.item.id,
                orderIndex:1,
                rowVersion:$scope.item.rowVersion
            }
            $scope.sortRequestList.push($scope.sort);

            $scope.sortDown={
                id:$scope.afterDomList[0].id,
                orderIndex:0,
                rowVersion:$scope.afterDomList[0].rowVersion
            }
            $scope.sortRequestList.push($scope.sortDown);

            var beforeOrderIndex=-1;
            if($scope.beforeDomList.length!=0){
                for( var i=$scope.beforeDomList.length-1; i>=0;i--){
                    var sort={
                        id:$scope.beforeDomList[i].id,
                        orderIndex:beforeOrderIndex,
                        rowVersion:$scope.beforeDomList[i].rowVersion
                    }
                    $scope.sortRequestList.push(sort);
                    beforeOrderIndex--;
                }
            }


            if($scope.afterDomList.length!=0){
                for( var i=1; i<$scope.afterDomList.length;i++){
                    var sort={
                        id:$scope.afterDomList[i].id,
                        orderIndex:1+i,
                        rowVersion:$scope.afterDomList[i].rowVersion
                    }
                    $scope.sortRequestList.push(sort);
                }
            }

            console.info($scope.item);
            console.info($scope.itemDown);


            tutorialService.searchDepartment({sortRequestList:$scope.sortRequestList}).success(function(data){
                if(data.errors === null || data.errors.length > 0){
                    dialogService.tip(data.errors);
                }else{
                    dialogService.tip([{"message": "排序成功!"}],"/master/organization/index.htm",1000);
                    //清空数据
                    $scope.item={};
                }
            }) ;
        };
        
        //树搜索
        $scope.treeSearch = function () {
            $scope.treeSearchList = [];
            if($scope.keyword != null){
                $scope.SearchName($scope.allTrees,$scope.keyword);
            } else{
                angular.extend($scope.treeSearchList,$scope.allTrees);
            }
            $scope.trees = $scope.treeSearchList;
        };

        $scope.SearchName = function (data,searchText) {
            var searchLength = searchText.length;
            var jsonArray = data;
            for(var i=0 ;i<jsonArray.length ; i++ ){
                var jsonObject = jsonArray[i];
                var name = jsonObject.name;
                var nameLength = name.length;
                var flag = false;
                for(var temp=0;temp< (nameLength-searchLength+1);temp++){
                    if(searchText == name.substring(temp,temp+searchLength)){
                        flag = true;
                        break;
                    }
                }
                if(flag){
                    var j = 0 ;
                    if(jsonObject.parentId != null){
                        var parentList = [];
                        getParent(jsonObject.parentId,parentList)
                        for(j = parentList.length-1; j >= 0 ;j--){
                            parentList[j].collapsed = false;
                            parentList[j].visable = true;
                            $scope.treeSearchList.push(parentList[j]);
                        }
                    }
                    var tempObj = {};
                    angular.extend(tempObj,jsonObject);
                    var childList = [];
                    countChild(jsonObject.id,childList);
                    if(childList.length == 0){
                        tempObj.collapsed = false;
                        tempObj.visable = true;
                        $scope.treeSearchList.push(tempObj);
                    } else {
                        tempObj.collapsed = true;
                        tempObj.visable = true;
                        $scope.treeSearchList.push(tempObj);
                        for(j = 0; j < childList.length ;j++){
                            $scope.treeSearchList.push(childList[j]);
                        }
                        i =  i + childList.length;
                    }
                }
            }
        };



        /*批量导入*/
        $scope.import = {
            title:"部门导入",
            uploadMethod:"api.inv.item.adjustment.import",
            downLoadUrl:"/inventory/api.do",
            downLoadMethod:"api.inventory.adjustment.output.template"
        };
    };


    var EidtTree = ["$scope","$modalInstance","items","tutorialService","dialogService",
        function ($scope, $modalInstance, items,tutorialService,dialogService) {
            $scope.vm = items;
            if($scope.vm.id){
                // 编辑
                /*获取新数据*/
                tutorialService.getDepartment($scope.vm).success(function(data){
                    if(data.errors === null || data.errors.length > 0){
                        dialogService.tip(data.errors);
                    }else{
                        $scope.vm=data.department;
                        var ownerEmployee={
                            id:data.department.ownerEmployeeId,
                            name:data.department.ownerEmployeeName
                        };
                        /*负责人赋值*/
                        $scope.ownerEmployee=ownerEmployee;

                        $scope.vm.title ="部门编辑";
                    }
                });
            } else {
                // 创建
                $scope.vm.title = "创建部门";
            }

            //数据加载
            $scope.getOwnerEmployee=function(backdata){
                var param={
                    isResign:false,
                    keyword:backdata.data.keyword,
                    pageNumber: backdata.data.pageNumber,
                    pageSize: backdata.data.pageSize
                };
                tutorialService.searchEmployee(param).success(function(data){
                    if (data.errors == null || data.errors.length > 0) {
                        dialogService.tip(data.errors);
                    }
                    else {
                        backdata.deferred.resolve({itemList:data.result,totalCount:data.totalCount});
                    }
                });
            };


            //数据提交
            $scope.doSave = function () {

                //负责人验证
                if(angular.isObject($scope.ownerEmployee)){
                    $scope.vm.ownerEmployeeId=$scope.ownerEmployee.id;
                    $scope.vm.ownerEmployeeName=$scope.ownerEmployee.name;
                }else {
                    $scope.vm.ownerEmployeeId=null;
                    $scope.vm.ownerEmployeeName=null;
                }

                if($scope.vm.id == null){
                    //新建
                    tutorialService.createDepartment($scope.vm).success(function(data){
                        if(data.errors === null || data.errors.length > 0){
                            dialogService.tip(data.errors);
                        }else{
                            //返回id
                            $scope.vm.id = data.id;

                            dialogService.tip([{"message": "保存成功!"}]);

                            //关闭
                            $modalInstance.close($scope.vm);

                            //清空数据
                            $scope.vm={};
                        }
                    }) ;
                } else {
                    //编辑
                    tutorialService.updateDepartment($scope.vm).success(function(data){
                        if(data.errors === null || data.errors.length > 0){
                            dialogService.tip(data.errors);
                        }else{
                            dialogService.tip([{"message": "保存成功!"}]);
                            //关闭
                            $modalInstance.close($scope.vm);
                            //清空数据
                            $scope.vm={};
                        }
                    }) ;
                }
            };

            /*取消*/
            $scope.clean = function () {
                $scope.org = {};
                $modalInstance.dismiss('cancel');
            };

            /*关闭错误*/
            $scope.closeAlert = function (index,form) {
                form.splice(index,1);
            };
        }];

    var xnPage = angular.module("xn.page", ["xn.directive.form"])
        .config(["xnValidatorProvider", function (xnValidatorProvider) {
        // 全局配置
        xnValidatorProvider.config({
            blurTrig   : false,
            showError  : false,
            removeError: false
        });
        xnValidatorProvider.setRules({
            name:{
                required: "名称不能为空!",
                maxlength:"名称长度不能超过50"
            },
            code:{
                required: "代码不能为空!",
                maxlength:"编码长度不能超过50"
            },
            type:{
                required: "类型不能为空!",
                maxlength:"类型长度不能超过50"
            }
        });

    }])
        .controller("DepartmentIndexController", ["$scope", "$modal", "tutorialService", "dialogService", departmentIndexController])

})();