递归总结

[{"code":"PT","name":"专利","child":[{"code":"PT001","name":"涉外专利"},{"code":"PT002","name":"专利申请/代理"},{"code":"PT003","name":"专利诉讼"},{"code":"PT004","name":"专利其他"},{"code":"PT005","name":"专利其他"}]},{"code":"PD","name":"政策","child":[{"code":"PD001","name":"高新技术企业-申报"},{"code":"PD002","name":"专精特新-申报"},{"code":"PD003","name":"首台套-申报"},{"code":"PD004","name":"企业技术中心-申报"},{"code":"PD005","name":"省工-申报"},{"code":"PD006","name":"两化融合-认证"},{"code":"PD007","name":"DCMM-认证"},{"code":"PD008","name":"绿色工厂-认证"},{"code":"PD009","name":"绿色设计产品-认证"},{"code":"PD010","name":"CMMI-认证"},{"code":"PD011","name":"浙江制造-认证"},{"code":"PD012","name":"CMMM-认证"},{"code":"PD013","name":"企业标准-认证"},{"code":"PD014","name":"团体标准-认证"},{"code":"PD015","name":"BIM-工程"},{"code":"PD016","name":"工法-工程"},{"code":"PD017","name":"工程创优-工程"},{"code":"PD018","name":"科技进步奖-荣誉奖项"},{"code":"PD019","name":"政府质量奖-荣誉奖项"},{"code":"PD020","name":"加计扣除-财税"},{"code":"PD021","name":"政策其他"}]}]

["PT","PT003"]
    detailData(arr, options, str = []) {
      let first = arr.shift()
      if (arr.length) {
        let name = options.find(item => {
          return item.code === first
        })
        str.push(name.name)
        this.detailData(arr, name.child, str)
        return str
      } else {
        let name = options.find(item => {
          return item.code === first
        })
        str.push(name.name)
        return str
      }
    },

递归总结_第1张图片 ​​​​​​

 let select = [
    [1, 4, 10, 23],
    [1, 4, 10, 27],
    [1, 4, 11, 30],
    [1, 4, 11, 31],
    [1, 4, 11, 32],
    [1, 4, 11, 33],
    [1, 5, 14, 38],
    [1, 5, 14, 39],
    [1, 5, 15, 46],
    [1, 5, 59, 60],

    // [2, 6, 16, 49],
    // [2, 6, 16, 50],
    // [2, 7, 17, 56],
  ];
  let options = [
    {
      id: 1,
      name: "线上",
      code: "online",
      remark: "一级",
      level: 1,
      children: [
        {
          id: 4,
          name: "付费",
          code: "on_pay",
          remark: "二级",
          level: 2,
          children: [
            {
              id: 8,
              name: "sem",
              code: "on_pay_sem",
              remark: "三级",
              level: 3,
              children: [
                {
                  id: 18,
                  name: "360",
                  code: "on_pay_sem_360",
                  remark: "四级",
                  level: 4,
                },
                {
                  id: 19,
                  name: "百度",
                  code: "on_pay_sem_baidu",
                  remark: "四级",
                  level: 4,
                },
                {
                  id: 20,
                  name: "神马",
                  code: "on_pay_sem_shenma",
                  remark: "四级",
                  level: 4,
                },
                {
                  id: 21,
                  name: "搜狗",
                  code: "on_pay_sem_sougou",
                  remark: "四级",
                  level: 4,
                },
              ],
            },
            {
              id: 9,
              name: "品牌专区",
              code: "on_pay_brandZone",
              remark: "三级",
              level: 3,
              children: [
                {
                  id: 22,
                  name: "百度",
                  code: "on_pay_brandZone_baidu",
                  remark: "四级",
                  level: 4,
                },
              ],
            },
            {
              id: 10,
              name: "信息流",
              code: "on_pay_infoFlow",
              remark: "三级",
              level: 3,
              children: [
                {
                  id: 23,
                  name: "广点通",
                  code: "on_pay_infoFlow_guangdiantong",
                  remark: "四级",
                  level: 4,
                },
                {
                  id: 24,
                  name: "华为信息流",
                  code: "on_pay_infoFlow_huawei",
                  remark: "四级",
                  level: 4,
                },
                {
                  id: 25,
                  name: "快手",
                  code: "on_pay_infoFlow_kuaishou",
                  remark: "四级",
                  level: 4,
                },
                {
                  id: 26,
                  name: "朋友圈广告",
                  code: "on_pay_infoFlow_moments",
                  remark: "四级",
                  level: 4,
                },
                {
                  id: 27,
                  name: "手机百度信息流",
                  code: "on_pay_infoFlow_baidu",
                  remark: "四级",
                  level: 4,
                },
                {
                  id: 28,
                  name: "字节-抖音",
                  code: "on_pay_infoFlow_douyin",
                  remark: "四级",
                  level: 4,
                },
                {
                  id: 29,
                  name: "字节-头条",
                  code: "on_pay_infoFlow_toutiao",
                  remark: "四级",
                  level: 4,
                },
                {
                  id: 57,
                  name: "朋友圈-亿玛",
                  code: "circle_of_frends_manasseh",
                  remark: "四级",
                  level: 4,
                },
                {
                  id: 58,
                  name: "朋友圈",
                  code: "circle_of_frends",
                  remark: "四级",
                  level: 4,
                },
              ],
            },
            {
              id: 11,
              name: "应用市场",
              code: "on_pay_appMarket",
              remark: "三级",
              level: 3,
              children: [
                {
                  id: 30,
                  name: "IOS-ASA",
                  code: "on_pay_appMarket_IOSASA",
                  remark: "四级",
                  level: 4,
                },
                {
                  id: 31,
                  name: "oppo",
                  code: "on_pay_appMarket_oppo",
                  remark: "四级",
                  level: 4,
                },
                {
                  id: 32,
                  name: "vivo",
                  code: "on_pay_appMarket_vivo",
                  remark: "四级",
                  level: 4,
                },
                {
                  id: 33,
                  name: "华为",
                  code: "on_pay_appMarket_huawei",
                  remark: "四级",
                  level: 4,
                },
              ],
            },
            {
              id: 12,
              name: "其他",
              code: "on_pay_other",
              remark: "三级",
              level: 3,
              children: [
                {
                  id: 34,
                  name: "海贝",
                  code: "on_pay_other_haibei",
                  remark: "四级",
                  level: 4,
                },
                {
                  id: 35,
                  name: "铭山",
                  code: "on_pay_other_mingshan",
                  remark: "四级",
                  level: 4,
                },
                {
                  id: 36,
                  name: "邮件",
                  code: "on_pay_other_mail",
                  remark: "四级",
                  level: 4,
                },
              ],
            },
            {
              id: 13,
              name: "品牌广告",
              code: "on_free_brandAd",
              remark: "三级",
              level: 3,
              children: [
                {
                  id: 37,
                  name: "公众号-新潮",
                  code: "on_free_brandAd_xinchao",
                  remark: "四级",
                  level: 4,
                },
              ],
            },
          ],
        },
        {
          id: 5,
          name: "免费(自然流量)",
          code: "on_free",
          remark: "二级",
          level: 2,
          children: [
            {
              id: 14,
              name: "应用市场",
              code: "on_free_appMarket",
              remark: "三级",
              level: 3,
              children: [
                {
                  id: 38,
                  name: "IOS",
                  code: "on_free_appMarket_ios",
                  remark: "四级",
                  level: 4,
                },
                {
                  id: 39,
                  name: "魅族",
                  code: "on_free_appMarket_meizu",
                  remark: "四级",
                  level: 4,
                },
                {
                  id: 40,
                  name: "三星",
                  code: "on_free_appMarket_samsung",
                  remark: "四级",
                  level: 4,
                },
                {
                  id: 41,
                  name: "小米",
                  code: "on_free_appMarket_xiaomi",
                  remark: "四级",
                  level: 4,
                },
                {
                  id: 42,
                  name: "应用宝",
                  code: "on_free_appMarket_appTreasure",
                  remark: "四级",
                  level: 4,
                },
              ],
            },
            {
              id: 15,
              name: "其他",
              code: "on_free_other",
              remark: "三级",
              level: 3,
              children: [
                {
                  id: 43,
                  name: "公众号",
                  code: "on_free_other_publicAccount",
                  remark: "四级",
                  level: 4,
                },
                {
                  id: 44,
                  name: "落地投放页(含营销页、活动页等)",
                  code: "on_free_other_dropPage",
                  remark: "四级",
                  level: 4,
                },
                {
                  id: 45,
                  name: "朋友圈转发(员工转发)",
                  code: "on_free_other_moments",
                  remark: "四级",
                  level: 4,
                },
                {
                  id: 46,
                  name: "企知道/维正官网",
                  code: "on_free_other_qizhidao",
                  remark: "四级",
                  level: 4,
                },
              ],
            },
            {
              id: 59,
              name: "新媒体平台",
              code: "new_media_platform",
              remark: "三级",
              level: 3,
              children: [
                {
                  id: 60,
                  name: "视频号",
                  code: "video_overlap",
                  remark: "四级",
                  level: 4,
                },
              ],
            },
          ],
        },
      ],
    },
    {
      id: 2,
      name: "线下",
      code: "offline",
      remark: "一级",
      level: 1,
      children: [
        {
          id: 6,
          name: "付费",
          code: "off_pay",
          remark: "二级",
          level: 2,
          children: [
            {
              id: 16,
              name: "品牌广告",
              code: "off_pay_brandAd",
              remark: "三级",
              level: 3,
              children: [
                {
                  id: 47,
                  name: "电梯广告-分众",
                  code: "off_pay_brandAd_fenzhong",
                  remark: "四级",
                  level: 4,
                },
                {
                  id: 48,
                  name: "电梯广告-新潮",
                  code: "off_pay_brandAd_xinchao",
                  remark: "四级",
                  level: 4,
                },
                {
                  id: 49,
                  name: "电梯广告-华语",
                  code: "off_pay_brandAd_huayu",
                  remark: "四级",
                  level: 4,
                },
                {
                  id: 50,
                  name: "电梯广告-城市纵横",
                  code: "off_pay_brandAd_chengshizongheng",
                  remark: "四级",
                  level: 4,
                },
                {
                  id: 51,
                  name: "电梯广告-梯影",
                  code: "off_pay_brandAd_tiying",
                  remark: "四级",
                  level: 4,
                },
                {
                  id: 52,
                  name: "地铁广告-报业",
                  code: "off_pay_brandAd_baoye",
                  remark: "四级",
                  level: 4,
                },
                {
                  id: 53,
                  name: "地铁广告-美狄斯",
                  code: "off_pay_brandAd_meidisi",
                  remark: "四级",
                  level: 4,
                },
                {
                  id: 54,
                  name: "地铁广告-雅仕维",
                  code: "off_pay_brandAd_yasiwei",
                  remark: "四级",
                  level: 4,
                },
                {
                  id: 55,
                  name: "公交广告-经典视线",
                  code: "off_pay_brandAd_jingdianshixian",
                  remark: "四级",
                  level: 4,
                },
              ],
            },
          ],
        },
        {
          id: 7,
          name: "免费(自然流量)",
          code: "off_free",
          remark: "二级",
          level: 2,
          children: [
            {
              id: 17,
              name: "其他",
              code: "off_free_other",
              remark: "三级",
              level: 3,
              children: [
                {
                  id: 56,
                  name: "展会/会销",
                  code: "off_free_other_exhibition",
                  remark: "四级",
                  level: 4,
                },
              ],
            },
          ],
        },
      ],
    },
    {
      id: 3,
      name: "其他(包含但不限于线下地推、维正签单)",
      code: "other",
      remark: "一级",
      level: 1,
    },
  ];
 // // 先把一个数组变为树状
  // function tree(arr = [], result = {}) {
  //   // debugger;
  //   let first = arr.shift(arr);
  //   result.id = first;

  //   if (arr.length) {
  //     result.children = {};
  //     tree(arr, result.children);
  //     return result;
  //   } else {
  //     return result;
  //   }
  // }
  // let a = tree([1, 4, 10, 23]);
  // console.log(a);

  // let selectTest = select.map((item) => {
  //   return tree(item);
  // });

  // //1.找出select 最长的数组
  // function findMax(arr) {
  //   let lengthList = arr.map((item) => {
  //     console.log(item);
  //     return item.length;
  //   });
  //   return lengthList;
  // }
  // let length = findMax(select);
  // // console.log(length);

  // let maxlength = Math.max(...length); //4
  // let arr = [];

  // arr.length = maxlength;
  // console.log(arr);
  // // debugger
  // // for (let i = 0; i < arr.length; i++) {
  // //   let test = [];
  // //   for (let j = 0; j < select.length; j++) {
  // //     console.log([j][i]);
  // //     console.log(select[j][i]);
  // //     arr[i] = test.push(select[i][j]);
  // //     console.log(arr[i]);
  // //   }
  // // }
  // console.log(arr);

  // console.log(maxlength);
  let arr = [];
  for (let i = 0; i < 6; i++) {
    for (let j = 0; j < 5; j++) {
      for (let k = 0; k < 3; k++) {
        console.log(i, "i");
        console.log(j, "j");
        console.log(k, "k");
        arr.push({ i: i, j: j, k: k });
      }
    }
  }
  console.log(arr);

递归总结_第2张图片

你可能感兴趣的:(java,dubbo,开发语言)