SOURCE

const data =[
    {
        "id": "1435210096893272064",
        "url": null,
        "name": "e进销存",
        "flag": 1,
        "parentId": null,
        "menuIcon": "opfont opicon-a-oms",
        "children": [
            {
                "id": "1514069360842448897",
                "url": null,
                "name": "采购管理",
                "flag": 1,
                "parentId": "1435210096893272064",
                "menuIcon": null,
                "children": [
                    {
                        "id": "1514069519420694530",
                        "url": "/oms/purchase/apply",
                        "name": "采购申请",
                        "flag": 1,
                        "parentId": "1514069360842448897",
                        "menuIcon": null,
                        "children": null
                    },
                    {
                        "id": "1514069690430857218",
                        "url": "/oms/purchase/order",
                        "name": "采购订单",
                        "flag": 1,
                        "parentId": "1514069360842448897",
                        "menuIcon": null,
                        "children": null
                    },
                    {
                        "id": "1514069808882196482",
                        "url": "/oms/purchase/warehousing",
                        "name": "采购入库",
                        "flag": 1,
                        "parentId": "1514069360842448897",
                        "menuIcon": null,
                        "children": null
                    },
                    {
                        "id": "1514069971189178370",
                        "url": "/oms/purchase/returnOrder",
                        "name": "采购退货",
                        "flag": 1,
                        "parentId": "1514069360842448897",
                        "menuIcon": null,
                        "children": null
                    }
                ]
            },
            {
                "id": "1514061519792463874",
                "url": null,
                "name": "销售管理",
                "flag": 1,
                "parentId": "1435210096893272064",
                "menuIcon": null,
                "children": [
                    {
                        "id": "1514061896583569409",
                        "url": "/oms/sales/orderList",
                        "name": "销售订单",
                        "flag": 1,
                        "parentId": "1514061519792463874",
                        "menuIcon": null,
                        "children": null
                    },
                    {
                        "id": "1514061959795924993",
                        "url": "/oms/sales/deliveryList",
                        "name": "销售出库",
                        "flag": 1,
                        "parentId": "1514061519792463874",
                        "menuIcon": null,
                        "children": null
                    },
                    {
                        "id": "1514062008047198210",
                        "url": "/oms/sales/returnList",
                        "name": "销售退货",
                        "flag": 1,
                        "parentId": "1514061519792463874",
                        "menuIcon": null,
                        "children": null
                    }
                ]
            },
            {
                "id": "1513797610024026113",
                "url": null,
                "name": "库存管理",
                "flag": 1,
                "parentId": "1435210096893272064",
                "menuIcon": null,
                "children": [
                    {
                        "id": "1513798746382614530",
                        "url": "/oms/stoke/productPicking",
                        "name": "生产领料",
                        "flag": 1,
                        "parentId": "1513797610024026113",
                        "menuIcon": null,
                        "children": null
                    },
                    {
                        "id": "1513800688416669698",
                        "url": "/oms/stoke/productReturn",
                        "name": "生产退料",
                        "flag": 1,
                        "parentId": "1513797610024026113",
                        "menuIcon": null,
                        "children": null
                    },
                    {
                        "id": "1513797850701578242",
                        "url": "/oms/stoke/enterWarehouse",
                        "name": "生产入库",
                        "flag": 1,
                        "parentId": "1513797610024026113",
                        "menuIcon": null,
                        "children": null
                    },
                    {
                        "id": "1514791457948520450",
                        "url": "/oms/stoke/backWarehouse",
                        "name": "生产退库",
                        "flag": 1,
                        "parentId": "1513797610024026113",
                        "menuIcon": null,
                        "children": null
                    },
                    {
                        "id": "1514075035408605185",
                        "url": "/oms/stoke/TransferReceipt",
                        "name": "调拨入库",
                        "flag": 1,
                        "parentId": "1513797610024026113",
                        "menuIcon": null,
                        "children": null
                    },
                    {
                        "id": "1514113279756148738",
                        "url": "/oms/stoke/TransferIssue",
                        "name": "调拨出库",
                        "flag": 1,
                        "parentId": "1513797610024026113",
                        "menuIcon": null,
                        "children": null
                    },
                    {
                        "id": "1514125093155995649",
                        "url": "/oms/stoke/otherReceipt",
                        "name": "其他入库",
                        "flag": 1,
                        "parentId": "1513797610024026113",
                        "menuIcon": null,
                        "children": null
                    },
                    {
                        "id": "1514132327441203202",
                        "url": "/oms/stoke/otherIssue",
                        "name": "其他出库",
                        "flag": 1,
                        "parentId": "1513797610024026113",
                        "menuIcon": null,
                        "children": null
                    },
                    {
                        "id": "1516398080470048770",
                        "url": "/oms/stoke/inventoryQuery/index",
                        "name": "库存查询",
                        "flag": 1,
                        "parentId": "1513797610024026113",
                        "menuIcon": null,
                        "children": null
                    }
                ]
            }
        ]
    },
    {
        "id": "1435210096922632193",
        "url": null,
        "name": "e工单",
        "flag": 1,
        "parentId": null,
        "menuIcon": "opfont opicon-a-riFill-device-fillCopy2",
        "children": [
            {
                "id": "1479055894951002114",
                "url": null,
                "name": "生产计划",
                "flag": 1,
                "parentId": "1435210096922632193",
                "menuIcon": null,
                "children": [
                    {
                        "id": "1479056119589535746",
                        "url": "/workerorder/prdorder/list",
                        "name": "生产订单",
                        "flag": 1,
                        "parentId": "1479055894951002114",
                        "menuIcon": null,
                        "children": null
                    },
                    {
                        "id": "1506436532586725378",
                        "url": "/workerorder/prdDisPatch",
                        "name": "派工平台",
                        "flag": 1,
                        "parentId": "1479055894951002114",
                        "menuIcon": null,
                        "children": null
                    }
                ]
            },
            {
                "id": "1475736718208499714",
                "url": null,
                "name": "生产执行",
                "flag": 1,
                "parentId": "1435210096922632193",
                "menuIcon": null,
                "children": [
                    {
                        "id": "1475736822395011074",
                        "url": "/productionaction/prdprocess",
                        "name": "工序任务",
                        "flag": 1,
                        "parentId": "1475736718208499714",
                        "menuIcon": null,
                        "children": null
                    },
                    {
                        "id": "1506512806218878978",
                        "url": "/productionaction/dispatchOrder",
                        "name": "派工单",
                        "flag": 1,
                        "parentId": "1475736718208499714",
                        "menuIcon": null,
                        "children": null
                    },
                    {
                        "id": "1475737222871351297",
                        "url": "/productionaction/prdstart",
                        "name": "开工记录",
                        "flag": 1,
                        "parentId": "1475736718208499714",
                        "menuIcon": null,
                        "children": null
                    },
                    {
                        "id": "1475737307692761090",
                        "url": "/productionaction/reportrecord",
                        "name": "汇报记录",
                        "flag": 1,
                        "parentId": "1475736718208499714",
                        "menuIcon": null,
                        "children": null
                    }
                ]
            },
            {
                "id": "1475737399543824385",
                "url": null,
                "name": "委外管理",
                "flag": 1,
                "parentId": "1435210096922632193",
                "menuIcon": null,
                "children": [
                    {
                        "id": "1475737484096798722",
                        "url": "/out/plan/list",
                        "name": "委外计划",
                        "flag": 1,
                        "parentId": "1475737399543824385",
                        "menuIcon": null,
                        "children": null
                    },
                    {
                        "id": "1475737588853735426",
                        "url": "/out/sendout",
                        "name": "委外发出",
                        "flag": 1,
                        "parentId": "1475737399543824385",
                        "menuIcon": null,
                        "children": null
                    },
                    {
                        "id": "1475737677663928321",
                        "url": "/out/receive",
                        "name": "委外接收",
                        "flag": 1,
                        "parentId": "1475737399543824385",
                        "menuIcon": null,
                        "children": null
                    }
                ]
            },
            {
                "id": "1475737751945052161",
                "url": null,
                "name": "生产检验",
                "flag": 1,
                "parentId": "1435210096922632193",
                "menuIcon": null,
                "children": [
                    {
                        "id": "1475737851501051905",
                        "url": "/productioncheck/list",
                        "name": "生产检验",
                        "flag": 1,
                        "parentId": "1475737751945052161",
                        "menuIcon": null,
                        "children": null
                    },
                    {
                        "id": "1475737943792517122",
                        "url": "/out/check/list",
                        "name": "委外检验",
                        "flag": 1,
                        "parentId": "1475737751945052161",
                        "menuIcon": null,
                        "children": null
                    }
                ]
            },
            {
                "id": "1475738548233666561",
                "url": null,
                "name": "数量调整",
                "flag": 1,
                "parentId": "1435210096922632193",
                "menuIcon": null,
                "children": [
                    {
                        "id": "1475738644320976897",
                        "url": "/quantityadjust/productionstart",
                        "name": "数量调整",
                        "flag": 1,
                        "parentId": "1475738548233666561",
                        "menuIcon": null,
                        "children": null
                    },
                    {
                        "id": "1475738747047870466",
                        "url": "/quantityadjust/adjustrecord",
                        "name": "调整记录",
                        "flag": 1,
                        "parentId": "1475738548233666561",
                        "menuIcon": null,
                        "children": null
                    }
                ]
            },
            {
                "id": "1475738831642787841",
                "url": null,
                "name": "报表统计",
                "flag": 1,
                "parentId": "1435210096922632193",
                "menuIcon": null,
                "children": [
                    {
                        "id": "1475738917919621121",
                        "url": "/reportStatics/output",
                        "name": "产量统计",
                        "flag": 1,
                        "parentId": "1475738831642787841",
                        "menuIcon": null,
                        "children": null
                    },
                    {
                        "id": "1475738881378844674",
                        "url": "/reportStatics/class",
                        "name": "班次报工",
                        "flag": 1,
                        "parentId": "1475738831642787841",
                        "menuIcon": null,
                        "children": null
                    },
                    {
                        "id": "1475738966594519041",
                        "url": "/edevice/badness",
                        "name": "不良统计",
                        "flag": 1,
                        "parentId": "1475738831642787841",
                        "menuIcon": null,
                        "children": null
                    },
                    {
                        "id": "1475739024958259202",
                        "url": "/reportStatics/achievements",
                        "name": "人员绩效",
                        "flag": 1,
                        "parentId": "1475738831642787841",
                        "menuIcon": null,
                        "children": null
                    },
                    {
                        "id": "1475739024958259203",
                        "url": "/reportStatics/reportWorks",
                        "name": "报工统计",
                        "flag": 1,
                        "parentId": "1475738831642787841",
                        "menuIcon": null,
                        "children": null
                    }
                ]
            },
            {
                "id": "1506177377196113921",
                "url": null,
                "name": "文档管理",
                "flag": 1,
                "parentId": "1435210096922632193",
                "menuIcon": null,
                "children": [
                    {
                        "id": "1506177593588645890",
                        "url": "/document/sop",
                        "name": "文档清单",
                        "flag": 1,
                        "parentId": "1506177377196113921",
                        "menuIcon": null,
                        "children": null
                    },
                    {
                        "id": "1506177670256328705",
                        "url": "/document/classify",
                        "name": "文档类别",
                        "flag": 1,
                        "parentId": "1506177377196113921",
                        "menuIcon": null,
                        "children": null
                    }
                ]
            },
            {
                "id": "1506434548954136578",
                "url": null,
                "name": "产品追溯",
                "flag": 1,
                "parentId": "1435210096922632193",
                "menuIcon": null,
                "children": [
                    {
                        "id": "1506434789220646914",
                        "url": "/productTraceability/finishedProduct",
                        "name": "成品追溯",
                        "flag": 1,
                        "parentId": "1506434548954136578",
                        "menuIcon": null,
                        "children": null
                    }
                ]
            },
            {
                "id": "1530011871512969218",
                "url": null,
                "name": "质量管理",
                "flag": 1,
                "parentId": "1435210096922632193",
                "menuIcon": null,
                "children": [
                    {
                        "id": "1530011965347938305",
                        "url": "/qualityAssurance/inspectionTask",
                        "name": "检验方案",
                        "flag": 1,
                        "parentId": "1530011871512969218",
                        "menuIcon": null,
                        "children": null
                    },
                    {
                        "id": "1531082789197312002",
                        "url": "/qualityAssurance/testTask",
                        "name": "检验任务",
                        "flag": 1,
                        "parentId": "1530011871512969218",
                        "menuIcon": null,
                        "children": null
                    },
                    {
                        "id": "1530012084772356098",
                        "url": "/qualityAssurance/rejectshandle",
                        "name": "不良品处理",
                        "flag": 1,
                        "parentId": "1530011871512969218",
                        "menuIcon": null,
                        "children": null
                    }
                ]
            },
            {
                "id": "2000000000000000001",
                "url": null,
                "name": "大屏看板",
                "flag": 1,
                "parentId": "1435210096922632193",
                "menuIcon": null,
                "children": [
                    {
                        "id": "2000000000000000011",
                        "url": "/kanban/pre?billNo=AUTO-2022052701",
                        "name": "工单进度大屏",
                        "flag": 1,
                        "parentId": "2000000000000000001",
                        "menuIcon": null,
                        "children": null
                    },
                    {
                        "id": "2000000000000000012",
                        "url": "/kanban/pre?billNo=AUTO-2022052502",
                        "name": "产量监控大屏",
                        "flag": 1,
                        "parentId": "2000000000000000001",
                        "menuIcon": null,
                        "children": null
                    },
                    {
                        "id": "2000000000000000013",
                        "url": "/kanban/pre?billNo=AUTO-2022052702",
                        "name": "质量监控大屏",
                        "flag": 1,
                        "parentId": "2000000000000000001",
                        "menuIcon": null,
                        "children": null
                    },
                    {
                        "id": "2000000000000000014",
                        "url": "/kanban/pre?billNo=AUTO-2022052703",
                        "name": "人员绩效大屏",
                        "flag": 1,
                        "parentId": "2000000000000000001",
                        "menuIcon": null,
                        "children": null
                    }
                ]
            }
        ]
    },
];
const name="采购申请"
clone(data)
    function clone(o) {
        var temp = {}
        for (var key in o) {
            if (typeof o[key] == 'object') {
                // console.log(o)
                temp[key] = clone(o[key])

            } else {
                if(o[key]==name) {
                    console.log(o.id)
                }
                temp[key] = o[key]
            }
        }
        return temp
    }
const data2 = [{}]
console 命令行工具 X clear

                    
>
console