SOURCE

let dataList = [{ "type": "start", "level": 1, "thisId": "start_1", "departments": [], "examineGroups": [], "formPermission": { "radio_9": 1, "number_7": 1, "checkbox_10": 1, "instruction_11": 2 } }, { "type": "check", "field": null, "level": 1, "scope": 1, "matrix": null, "roleId": "", "status": 5, "thisId": "check_2", "isEmpty": 0, "roleIds": [2740], "activity": 1, "fieldName": null, "isCheckbox": 1, "matrixName": null, "memberNames": [], "roleIdsName": [{ "id": 2740, "nums": 0, "sort": 999, "orgId": 1519, "remark": "", "orgName": "", "purpose": 1, "memberVO": null, "roleName": "流程审批测试", "roleType": 2, "companyId": 1619 }], "approveAlert": 0, "examineGroups": [], "formPermission": { "radio_9": 2, "number_7": 2, "checkbox_10": 2, "instruction_11": 2 }, "approveAlertContent": null }, { "type": "branch", "level": 1, "thisId": "branch_5", "conditions": [[{ "type": "term", "level": 2, "thisId": "term_6", "priority": 1, "expression": [["number_7", ">=", 9, "number"], ["radio_9", "in", ["选项2"], "radio"]] }, { "type": "check", "field": null, "level": 2, "scope": 1, "matrix": null, "roleId": "", "status": 5, "thisId": "check_8", "isEmpty": 0, "roleIds": [2740], "activity": 1, "fieldName": null, "isCheckbox": 1, "matrixName": null, "memberNames": [], "roleIdsName": [{ "id": 2740, "nums": 0, "sort": 999, "orgId": 1519, "remark": "", "orgName": "", "purpose": 1, "memberVO": null, "roleName": "流程审批测试", "roleType": 2, "companyId": 1619 }], "approveAlert": 0, "examineGroups": [], "formPermission": { "radio_9": 2, "number_7": 2, "checkbox_10": 2, "instruction_11": 2 }, "approveAlertContent": null }, { "type": "branch", "level": 2, "thisId": "branch_11", "conditions": [[{ "type": "term", "level": 3, "thisId": "term_12", "priority": 1, "expression": [["amount_14", ">=", 0, "amount"]] }, { "type": "check", "field": null, "level": 3, "scope": 1, "matrix": null, "roleId": null, "status": 5, "thisId": "check_10", "isEmpty": 0, "roleIds": [3588], "activity": 1, "fieldName": null, "isCheckbox": 1, "matrixName": null, "memberNames": [], "roleIdsName": [{ "id": 3588, "nums": 0, "sort": 999, "orgId": 1519, "remark": "", "orgName": "", "purpose": 1, "memberVO": null, "roleName": "流程引擎测试关联审批单", "roleType": 2, "companyId": 1619 }], "approveAlert": 0, "examineGroups": [], "formPermission": { "radio_9": 2, "number_7": 2, "checkbox_10": 2, "instruction_11": 2 }, "approveAlertContent": null }], [{ "type": "term", "level": 3, "thisId": "term_13", "priority": 2, "expression": [["number_7", ">=", 12, "number"], ["amount_14", ">=", 100, "amount"]] }]] }], [{ "type": "term", "level": 2, "thisId": "term_7", "priority": 2, "expression": [["number_7", ">=", 99, "number"]] }, { "type": "check", "field": null, "level": 2, "scope": 1, "matrix": null, "roleId": "", "status": 5, "thisId": "check_9", "isEmpty": 0, "roleIds": [3286], "activity": 1, "fieldName": null, "isCheckbox": 1, "matrixName": null, "memberNames": [], "roleIdsName": [{ "id": 3286, "nums": 0, "sort": 999, "orgId": 1519, "remark": "", "orgName": "", "purpose": 1, "memberVO": null, "roleName": "公司认证审核", "roleType": 2, "companyId": 1619 }], "approveAlert": 0, "examineGroups": [], "formPermission": { "radio_9": 2, "number_7": 2, "checkbox_10": 2, "instruction_11": 2 }, "approveAlertContent": null }]] }, { "type": "event", "level": 1, "thisId": "event_4" }]
// console.log(dataList)
// 递归上面dataList
console.log('*******************************************************************************************')
let termList = []
let termListArr = []
function filterData(type, arr) {
    for (const item of arr) {
        if (item.type == type) {
            for (let i = 0; i < item.conditions.length; i++) {
                for (let j = 0; j < item.conditions[i].length; j++) {
                    if (item.conditions[i][j].type == 'term') {
                        for (let k = 0; k < item.conditions[i][j].expression.length; k++) {
                            termListArr.push(item.conditions[i][j].expression[k][0])
                        }
                    }
                    if (item.conditions[i][j].type == type) {
                        filterData(type, item.conditions[i])
                    }
                }
            }
        }
    }
}
filterData('branch', dataList)
console.log(termList)
console.log(termListArr)
// 简单递归
let num = 1
function fun() {
    console.log('---')
    if (num == 9) {
        return
    }
    num++
    fun()
}
fun()
console 命令行工具 X clear

                    
>
console