当先锋百科网

首页 1 2 3 4 5 6 7
 "dept": [
            {
                "deptId": 86, 
                "parentId": 0, 
                "ancestors": null, 
                "deptName": "总公司", 
                "orderNum": 86, 
                "leader": "测试86", 
                "phone": "13932387559", 
                "email": "[email protected]", 
                "status": "0", 
                "delFlag": "0", 
                "createBy": "1", 
                "createTime": [
                    2022, 
                    9, 
                    30, 
                    10, 
                    48, 
                    18
                ], 
                "updateBy": "1", 
                "updateTime": [
                    2022, 
                    9, 
                    30, 
                    10, 
                    48, 
                    18
                ], 
                "children": [
                    {
                        "deptId": 8612, 
                        "parentId": 86, 
                        "ancestors": null, 
                        "deptName": "天津", 
                        "orderNum": 8612, 
                        "leader": "测试8612", 
                        "phone": "13932387559", 
                        "email": "[email protected]", 
                        "status": "0", 
                        "delFlag": "0", 
                        "createBy": "1", 
                        "createTime": [
                            2022, 
                            9, 
                            30, 
                            10, 
                            48, 
                            18
                        ], 
                        "updateBy": "1", 
                        "updateTime": [
                            2022, 
                            9, 
                            30, 
                            10, 
                            48, 
                            18
                        ], 
                        "children": [
                            {
                                "deptId": 861201, 
                                "parentId": 8612, 
                                "ancestors": null, 
                                "deptName": "天津分公司本部", 
                                "orderNum": 861201, 
                                "leader": "测试861201", 
                                "phone": "13932387559", 
                                "email": "[email protected]", 
                                "status": "0", 
                                "delFlag": "0", 
                                "createBy": "1", 
                                "createTime": [
                                    2022, 
                                    9, 
                                    30, 
                                    10, 
                                    48, 
                                    18
                                ], 
                                "updateBy": "1", 
                                "updateTime": [
                                    2022, 
                                    9, 
                                    30, 
                                    10, 
                                    48, 
                                    18
                                ], 
                                "children": [
                                    {
                                        "deptId": 86120100, 
                                        "parentId": 861201, 
                                        "ancestors": null, 
                                        "deptName": "天津分公司本部营业部", 
                                        "orderNum": 86120100, 
                                        "leader": "测试86120100", 
                                        "phone": "13932387559", 
                                        "email": "[email protected]", 
                                        "status": "0", 
                                        "delFlag": "0", 
                                        "createBy": "1", 
                                        "createTime": [
                                            2022, 
                                            9, 
                                            30, 
                                            10, 
                                            48, 
                                            18
                                        ], 
                                        "updateBy": "1", 
                                        "updateTime": [
                                            2022, 
                                            9, 
                                            30, 
                                            10, 
                                            48, 
                                            18
                                        ], 
                                        "children": [ ]
                                    }
                                ]
                            }
                        ]
                    }, 
                    {
                        "deptId": 8613, 
                        "parentId": 86, 
                        "ancestors": null, 
                        "deptName": "河北", 
                        "orderNum": 8613, 
                        "leader": "测试8613", 
                        "phone": "13932387559", 
                        "email": "[email protected]", 
                        "status": "0", 
                        "delFlag": "0", 
                        "createBy": "1", 
                        "createTime": [
                            2022, 
                            9, 
                            30, 
                            10, 
                            48, 
                            18
                        ], 
                        "updateBy": "1", 
                        "updateTime": [
                            2022, 
                            9, 
                            30, 
                            10, 
                            48, 
                            18
                        ], 
                        "children": [
                            {
                                "deptId": 861301, 
                                "parentId": 8613, 
                                "ancestors": null, 
                                "deptName": "石家庄中心支公司(筹)", 
                                "orderNum": 861301, 
                                "leader": "测试861301", 
                                "phone": "13932387559", 
                                "email": "[email protected]", 
                                "status": "0", 
                                "delFlag": "0", 
                                "createBy": "1", 
                                "createTime": [
                                    2022, 
                                    9, 
                                    30, 
                                    10, 
                                    48, 
                                    18
                                ], 
                                "updateBy": "1", 
                                "updateTime": [
                                    2022, 
                                    9, 
                                    30, 
                                    10, 
                                    48, 
                                    18
                                ], 
                                "children": [
                                    {
                                        "deptId": 86130100, 
                                        "parentId": 861301, 
                                        "ancestors": null, 
                                        "deptName": "石家庄中心支公司营业部", 
                                        "orderNum": 86130100, 
                                        "leader": "测试86130100", 
                                        "phone": "13932387559", 
                                        "email": "[email protected]", 
                                        "status": "0", 
                                        "delFlag": "0", 
                                        "createBy": "1", 
                                        "createTime": [
                                            2022, 
                                            9, 
                                            30, 
                                            10, 
                                            48, 
                                            18
                                        ], 
                                        "updateBy": "1", 
                                        "updateTime": [
                                            2022, 
                                            9, 
                                            30, 
                                            10, 
                                            48, 
                                            18
                                        ], 
                                        "children": [ ]
                                    }
                                ]
                            }
                        ]
                    }, 
                    {
                        "deptId": 8651, 
                        "parentId": 86, 
                        "ancestors": null, 
                        "deptName": "四川", 
                        "orderNum": 8651, 
                        "leader": "测试8651", 
                        "phone": "13932387559", 
                        "email": "[email protected]", 
                        "status": "0", 
                        "delFlag": "0", 
                        "createBy": "1", 
                        "createTime": [
                            2022, 
                            9, 
                            30, 
                            10, 
                            48, 
                            18
                        ], 
                        "updateBy": "1", 
                        "updateTime": [
                            2022, 
                            9, 
                            30, 
                            10, 
                            48, 
                            18
                        ], 
                        "children": [
                            {
                                "deptId": 865100, 
                                "parentId": 8651, 
                                "ancestors": null, 
                                "deptName": "四川分公司(筹)", 
                                "orderNum": 865100, 
                                "leader": "测试865100", 
                                "phone": "13932387559", 
                                "email": "[email protected]", 
                                "status": "0", 
                                "delFlag": "0", 
                                "createBy": "1", 
                                "createTime": [
                                    2022, 
                                    9, 
                                    30, 
                                    10, 
                                    48, 
                                    18
                                ], 
                                "updateBy": "1", 
                                "updateTime": [
                                    2022, 
                                    9, 
                                    30, 
                                    10, 
                                    48, 
                                    18
                                ], 
                                "children": [
                                    {
                                        "deptId": 86510000, 
                                        "parentId": 865100, 
                                        "ancestors": null, 
                                        "deptName": "四川分公司本部营业部", 
                                        "orderNum": 86510000, 
                                        "leader": "测试86510000", 
                                        "phone": "13932387559", 
                                        "email": "[email protected]", 
                                        "status": "0", 
                                        "delFlag": "0", 
                                        "createBy": "1", 
                                        "createTime": [
                                            2022, 
                                            9, 
                                            30, 
                                            10, 
                                            48, 
                                            18
                                        ], 
                                        "updateBy": "1", 
                                        "updateTime": [
                                            2022, 
                                            9, 
                                            30, 
                                            10, 
                                            48, 
                                            18
                                        ], 
                                        "children": [ ]
                                    }
                                ]
                            }, 
                            {
                                "deptId": 865107, 
                                "parentId": 8651, 
                                "ancestors": null, 
                                "deptName": "绵阳中支", 
                                "orderNum": 865107, 
                                "leader": "测试865107", 
                                "phone": "13932387559", 
                                "email": "[email protected]", 
                                "status": "0", 
                                "delFlag": "0", 
                                "createBy": "1", 
                                "createTime": [
                                    2022, 
                                    9, 
                                    30, 
                                    10, 
                                    48, 
                                    18
                                ], 
                                "updateBy": "1", 
                                "updateTime": [
                                    2022, 
                                    9, 
                                    30, 
                                    10, 
                                    48, 
                                    18
                                ], 
                                "children": [ ]
                            }
                        ]
                    }, 
                    {
                        "deptId": 8665, 
                        "parentId": 86, 
                        "ancestors": null, 
                        "deptName": "新疆", 
                        "orderNum": 8665, 
                        "leader": "测试8665", 
                        "phone": "13932387559", 
                        "email": "[email protected]", 
                        "status": "0", 
                        "delFlag": "0", 
                        "createBy": "1", 
                        "createTime": [
                            2022, 
                            9, 
                            30, 
                            10, 
                            48, 
                            18
                        ], 
                        "updateBy": "1", 
                        "updateTime": [
                            2022, 
                            9, 
                            30, 
                            10, 
                            48, 
                            18
                        ], 
                        "children": [
                            {
                                "deptId": 866500, 
                                "parentId": 8665, 
                                "ancestors": null, 
                                "deptName": "新疆分公司乌鲁木齐中心支公司", 
                                "orderNum": 866500, 
                                "leader": "测试866500", 
                                "phone": "13932387559", 
                                "email": "[email protected]", 
                                "status": "0", 
                                "delFlag": "0", 
                                "createBy": "1", 
                                "createTime": [
                                    2022, 
                                    9, 
                                    30, 
                                    10, 
                                    48, 
                                    18
                                ], 
                                "updateBy": "1", 
                                "updateTime": [
                                    2022, 
                                    9, 
                                    30, 
                                    10, 
                                    48, 
                                    18
                                ], 
                                "children": [
                                    {
                                        "deptId": 86650001, 
                                        "parentId": 866500, 
                                        "ancestors": null, 
                                        "deptName": "新疆分公司乌鲁木齐中心支公司天山区营销服务部", 
                                        "orderNum": 86650001, 
                                        "leader": "测试86650001", 
                                        "phone": "13932387559", 
                                        "email": "[email protected]", 
                                        "status": "0", 
                                        "delFlag": "0", 
                                        "createBy": "1", 
                                        "createTime": [
                                            2022, 
                                            9, 
                                            30, 
                                            10, 
                                            48, 
                                            18
                                        ], 
                                        "updateBy": "1", 
                                        "updateTime": [
                                            2022, 
                                            9, 
                                            30, 
                                            10, 
                                            48, 
                                            18
                                        ], 
                                        "children": [ ]
                                    }
                                ]
                            }, 
                            {
                                "deptId": 866501, 
                                "parentId": 8665, 
                                "ancestors": null, 
                                "deptName": "乌鲁木齐中支", 
                                "orderNum": 866501, 
                                "leader": "测试866501", 
                                "phone": "13932387559", 
                                "email": "[email protected]", 
                                "status": "0", 
                                "delFlag": "0", 
                                "createBy": "1", 
                                "createTime": [
                                    2022, 
                                    9, 
                                    30, 
                                    10, 
                                    48, 
                                    18
                                ], 
                                "updateBy": "1", 
                                "updateTime": [
                                    2022, 
                                    9, 
                                    30, 
                                    10, 
                                    48, 
                                    18
                                ], 
                                "children": [
                                    {
                                        "deptId": 86650100, 
                                        "parentId": 866501, 
                                        "ancestors": null, 
                                        "deptName": "乌鲁木齐中支本部", 
                                        "orderNum": 86650100, 
                                        "leader": "测试86650100", 
                                        "phone": "13932387559", 
                                        "email": "[email protected]", 
                                        "status": "0", 
                                        "delFlag": "0", 
                                        "createBy": "1", 
                                        "createTime": [
                                            2022, 
                                            9, 
                                            30, 
                                            10, 
                                            48, 
                                            18
                                        ], 
                                        "updateBy": "1", 
                                        "updateTime": [
                                            2022, 
                                            9, 
                                            30, 
                                            10, 
                                            48, 
                                            18
                                        ], 
                                        "children": [ ]
                                    }, 
                                    {
                                        "deptId": 86650101, 
                                        "parentId": 866501, 
                                        "ancestors": null, 
                                        "deptName": "乌鲁木齐中支北京路支公司", 
                                        "orderNum": 86650101, 
                                        "leader": "测试86650101", 
                                        "phone": "13932387559", 
                                        "email": "[email protected]", 
                                        "status": "0", 
                                        "delFlag": "0", 
                                        "createBy": "1", 
                                        "createTime": [
                                            2022, 
                                            9, 
                                            30, 
                                            10, 
                                            48, 
                                            18
                                        ], 
                                        "updateBy": "1", 
                                        "updateTime": [
                                            2022, 
                                            9, 
                                            30, 
                                            10, 
                                            48, 
                                            18
                                        ], 
                                        "children": [ ]
                                    }
                                ]
                            }, 
                            {
                                "deptId": 866531, 
                                "parentId": 8665, 
                                "ancestors": null, 
                                "deptName": "喀什中支", 
                                "orderNum": 866531, 
                                "leader": "测试866531", 
                                "phone": "13932387559", 
                                "email": "[email protected]", 
                                "status": "0", 
                                "delFlag": "0", 
                                "createBy": "1", 
                                "createTime": [
                                    2022, 
                                    9, 
                                    30, 
                                    10, 
                                    48, 
                                    18
                                ], 
                                "updateBy": "1", 
                                "updateTime": [
                                    2022, 
                                    9, 
                                    30, 
                                    10, 
                                    48, 
                                    18
                                ], 
                                "children": [
                                    {
                                        "deptId": 86653100, 
                                        "parentId": 866531, 
                                        "ancestors": null, 
                                        "deptName": "喀什中支本部", 
                                        "orderNum": 86653100, 
                                        "leader": "测试86653100", 
                                        "phone": "13932387559", 
                                        "email": "[email protected]", 
                                        "status": "0", 
                                        "delFlag": "0", 
                                        "createBy": "1", 
                                        "createTime": [
                                            2022, 
                                            9, 
                                            30, 
                                            10, 
                                            48, 
                                            18
                                        ], 
                                        "updateBy": "1", 
                                        "updateTime": [
                                            2022, 
                                            9, 
                                            30, 
                                            10, 
                                            48, 
                                            18
                                        ], 
                                        "children": [ ]
                                    }
                                ]
                            }, 
                            {
                                "deptId": 866540, 
                                "parentId": 8665, 
                                "ancestors": null, 
                                "deptName": "伊犁中支", 
                                "orderNum": 866540, 
                                "leader": "测试866540", 
                                "phone": "13932387559", 
                                "email": "[email protected]", 
                                "status": "0", 
                                "delFlag": "0", 
                                "createBy": "1", 
                                "createTime": [
                                    2022, 
                                    9, 
                                    30, 
                                    10, 
                                    48, 
                                    18
                                ], 
                                "updateBy": "1", 
                                "updateTime": [
                                    2022, 
                                    9, 
                                    30, 
                                    10, 
                                    48, 
                                    18
                                ], 
                                "children": [
                                    {
                                        "deptId": 86654000, 
                                        "parentId": 866540, 
                                        "ancestors": null, 
                                        "deptName": "伊犁中支本部", 
                                        "orderNum": 86654000, 
                                        "leader": "测试86654000", 
                                        "phone": "13932387559", 
                                        "email": "[email protected]", 
                                        "status": "0", 
                                        "delFlag": "0", 
                                        "createBy": "1", 
                                        "createTime": [
                                            2022, 
                                            9, 
                                            30, 
                                            10, 
                                            48, 
                                            18
                                        ], 
                                        "updateBy": "1", 
                                        "updateTime": [
                                            2022, 
                                            9, 
                                            30, 
                                            10, 
                                            48, 
                                            18
                                        ], 
                                        "children": [ ]
                                    }
                                ]
                            }
                        ]
                    }, 
                    {
                        "deptId": 8611, 
                        "parentId": 86, 
                        "ancestors": null, 
                        "deptName": "北京", 
                        "orderNum": 8611, 
                        "leader": "测试", 
                        "phone": "13932387559", 
                        "email": "[email protected]", 
                        "status": "0", 
                        "delFlag": "0", 
                        "createBy": "1", 
                        "createTime": [
                            2022, 
                            9, 
                            30, 
                            10, 
                            48, 
                            18
                        ], 
                        "updateBy": "2", 
                        "updateTime": [
                            2022, 
                            9, 
                            30, 
                            10, 
                            50, 
                            46
                        ], 
                        "children": [
                            {
                                "deptId": 861100, 
                                "parentId": 8611, 
                                "ancestors": null, 
                                "deptName": "北京分公司本部", 
                                "orderNum": 861100, 
                                "leader": "测试", 
                                "phone": "13932387559", 
                                "email": "[email protected]", 
                                "status": "0", 
                                "delFlag": "0", 
                                "createBy": "1", 
                                "createTime": [
                                    2022, 
                                    9, 
                                    30, 
                                    10, 
                                    48, 
                                    18
                                ], 
                                "updateBy": "2", 
                                "updateTime": [
                                    2022, 
                                    9, 
                                    30, 
                                    10, 
                                    50, 
                                    58
                                ], 
                                "children": [
                                    {
                                        "deptId": 86110001, 
                                        "parentId": 861100, 
                                        "ancestors": null, 
                                        "deptName": "北京分公司本部第一营业区", 
                                        "orderNum": 86110001, 
                                        "leader": "测试86110001", 
                                        "phone": "13932387559", 
                                        "email": "[email protected]", 
                                        "status": "0", 
                                        "delFlag": "0", 
                                        "createBy": "1", 
                                        "createTime": [
                                            2022, 
                                            9, 
                                            30, 
                                            10, 
                                            48, 
                                            18
                                        ], 
                                        "updateBy": "1", 
                                        "updateTime": [
                                            2022, 
                                            9, 
                                            30, 
                                            10, 
                                            48, 
                                            18
                                        ], 
                                        "children": [ ]
                                    }
                                ]
                            }
                        ]
                    }
                ]
            }
        ]
     var newArr = []; // 用于存放转换后的数组
      var newObj = {};// 用于存放转换后的对象
      function arrOfOneDimension(arr) {
        arr.forEach((item) => {
          if (Array.isArray(item.children)) {
            newArr.push(item.deptName);
            newObj[item.deptId] = item.deptName;
            arrOfOneDimension(item.children); // // 如果还是数组继续递归调用
          }
        });
       
        // return newArr;
        return newObj;
      }
      arrOfOneDimension(dept);