精华内容
下载资源
问答
  • 主要是传给前端进行树状结构操作比较好,这样可以关联上下四级选择项,所以需要把表中的数据List转成一个树状结构。 1、数据库数据是静态的四级目录 数据是这样的四级目录,没有特别明确的id进行关联的,存储数据...

     前言:

    主要是传给前端进行树状结构操作比较好,这样可以关联上下四级选择项,所以需要把表中的数据List转成一个树状结构。

    1、数据库数据是静态的四级目录

    数据是这样的四级目录,没有特别明确的id进行关联的,存储数据的是静态的。需要对下面数据进行关联起来!

     2、新建俩个实体类,组装成树状结构Model

    1、返回前端的一个List<树状结构>就可以的

    
    /********************************************
     * 模块名称:
     *   主要功能是做  四级菜单主表详情里面范围-宏观行业四级标签建立树状选择模型
     * @author  
     * @date 2021/7/22  9:59
     * @version 2021/7/22  9:59-01    v1.0.0.0
     *******************************************/
    @Data
    public class EventCategory {
    
    
        /***
         * 孩子,下一级节点
         */
        private List<Children> childrenList;
        /***
         * 层级
         */
        private Integer level;
        /***
         * 编码-事件编码
         */
        private String code;
        /***
         * 名称-对应事件名称
         */
        private String name;
    
    
    }

    3、实现子孩子节点的实体类创建

    
    /********************************************
     * 模块名称:
     *   主要功能是做  四级菜单主表详情里面范围-宏观行业四级标签建立树状选择模型 ,孩子模型,递归
     * @author  
     * @date 2021/7/22  10:00
     * @version 2021/7/22  10:00-01    v1.0.0.0
     *******************************************/
    @Data
    public class Children {
    
        /**
         * 孩子,下一级节点
         */
        private List<Children> childrenList;
        /***
         * 层级
         */
        private Integer level;
        /****
         * 编码-事件编码
         */
        private String code;
        /***
         * 名称-对应事件名称
         */
        private String name;
    }

    4、通过java建立关联关系对实体类转换,建立起树状结构

    @Override
        public List<EventCategory> getEventCategoryList() throws ApiException {
            List<EventCategory> resultEventCategorys = new ArrayList<>();
            List<TbmNewsRangeConfig> tbmNewsRangeConfigList = tbmNewsRangeConfigDao.getAllNewsRangeConfig();
            Map<String, List<TbmNewsRangeConfig>> firstLevelListMap = tbmNewsRangeConfigList.stream().collect(Collectors.groupingBy(TbmNewsRangeConfig::getFirstLevelCode, LinkedHashMap::new, Collectors.toList()));
            if(MapUtils.isNotEmpty(firstLevelListMap)){
                firstLevelListMap.keySet().forEach(firstLevelKey -> {
                    //一级事件菜单作为主菜单
                    List<TbmNewsRangeConfig> firstRangeList = firstLevelListMap.get(firstLevelKey);
                    EventCategory eventCategory = new EventCategory();
                    eventCategory.setLevel(1);
                    eventCategory.setCode(firstRangeList.get(0).getFirstLevelCode());
                    eventCategory.setName(firstRangeList.get(0).getFirstLevelName());
                    Map<String, List<TbmNewsRangeConfig>> secondLevelListMap = firstRangeList.stream().collect(Collectors.groupingBy(TbmNewsRangeConfig::getSecondLevelCode, LinkedHashMap::new, Collectors.toList()));
                    //二级菜单
                    List<Children> secondChildrenList = new ArrayList<>();
                    secondLevelListMap.keySet().forEach(secondLevelKey -> {
                        //二级事件的菜单
                        List<TbmNewsRangeConfig> secondRangeList = secondLevelListMap.get(secondLevelKey);
                        Children   secondChildren=new Children();
                        secondChildren.setLevel(2);
                        secondChildren.setCode(secondRangeList.get(0).getSecondLevelCode());
                        secondChildren.setName(secondRangeList.get(0).getSecondLevelName());
                        secondChildrenList.add(secondChildren);
                        //三级菜单
                        List<Children> thirdChildrenList = new ArrayList<>();
                        Map<String, List<TbmNewsRangeConfig>> thirdLevelListMap = secondRangeList.stream().collect(Collectors.groupingBy(TbmNewsRangeConfig::getThirdLevelCode, LinkedHashMap::new, Collectors.toList()));
                        thirdLevelListMap.keySet().forEach(thirdLevelKey -> {
                            //三级事件的菜单
                            List<TbmNewsRangeConfig> thirdRangeList = thirdLevelListMap.get(thirdLevelKey);
                            Children   thirdChildren=new Children();
                            thirdChildren.setLevel(3);
                            thirdChildren.setCode(thirdRangeList.get(0).getThirdLevelCode());
                            thirdChildren.setName(thirdRangeList.get(0).getThirdLevelName());
                            thirdChildrenList.add(thirdChildren);
                            //四级菜单需要重新实现
                            List<Children> fourthChildrenList = new ArrayList<>();
                            thirdRangeList.forEach(itemThird->{
                                if(itemThird.getThirdLevelCode().equals(thirdLevelKey)){
                                    Children fourthChildren = new Children();
                                    fourthChildren.setCode(itemThird.getFourthLevelCode());
                                    fourthChildren.setName(itemThird.getFourthLevelName());
                                    fourthChildren.setLevel(4);
                                    fourthChildrenList.add(fourthChildren);
                                }
                            });
                            thirdChildren.setChildrenList(fourthChildrenList);
                        });
                        secondChildren.setChildrenList(thirdChildrenList);
                    });
                    eventCategory.setChildrenList(secondChildrenList);
                    resultEventCategorys.add(eventCategory);
                });
            }
            return resultEventCategorys;
        }

    5、最终的结果演示如下:

     6、主要的资源数据已经上传CSDN

    参考-->

    CSDN所有实现的数据源码

    https://download.csdn.net/download/m0_59252007/20618621

     7、附件返回的JSON字符串

    System.out.println(JSON.toJSON(resultEventCategorys));

    [{"code":"FBT0000000ZR","level":1,"name":"货币政策","childrenList":[{"code":"FBT0000000ZV","level":2,"name":"利率","childrenList":[{"code":"FBT00000010G","level":3,"name":"加息及预期","childrenList":[{"code":"FBT00000013I","level":4,"name":"央行加息"},{"code":"FBT00000013J","level":4,"name":"央行预计加息"},{"code":"FBT00000013K","level":4,"name":"央行加息预期增强"},{"code":"FBT00000013L","level":4,"name":"央行加息预期减弱"}]},{"code":"FBT00000010H","level":3,"name":"降息及预期","childrenList":[{"code":"FBT00000013M","level":4,"name":"央行降息"},{"code":"FBT00000013N","level":4,"name":"央行预计降息"},{"code":"FBT00000013O","level":4,"name":"央行降息预期增强"},{"code":"FBT00000013P","level":4,"name":"央行降息预期减弱"}]},{"code":"FBT00000010I","level":3,"name":"中国央行不加息","childrenList":[{"code":"FBT00000013Q","level":4,"name":"央行不加息"}]},{"code":"FBT00000010J","level":3,"name":"美国加息","childrenList":[{"code":"FBT00000013R","level":4,"name":"美联储加息"}]},{"code":"FBT00000010K","level":3,"name":"美国不加息","childrenList":[{"code":"FBT00000013S","level":4,"name":"美联储不加息"}]},{"code":"FBT00000010L","level":3,"name":"美国降息","childrenList":[{"code":"FBT00000013T","level":4,"name":"美联储降息"}]},{"code":"FBT00000010M","level":3,"name":"央行逆回购操作","childrenList":[{"code":"FBT00000013U","level":4,"name":"开展逆回购"},{"code":"FBT00000013V","level":4,"name":"不开展逆回购"}]},{"code":"FBT00000010N","level":3,"name":"央行开展SLF","childrenList":[{"code":"FBT00000013W","level":4,"name":"开展常备借贷便利操作"}]},{"code":"FBT00000010O","level":3,"name":"央行开展MLF或TMLF","childrenList":[{"code":"FBT00000013X","level":4,"name":"开展中期借贷便利操作"}]},{"code":"FBT00000010P","level":3,"name":"宽松货币政策","childrenList":[{"code":"FBT00000013Y","level":4,"name":"扩张性货币政策"}]},{"code":"FBT00000010Q","level":3,"name":"稳健货币政策","childrenList":[{"code":"FBT00000013Z","level":4,"name":"稳健型货币政策"}]},{"code":"FBT00000010R","level":3,"name":"紧缩货币政策","childrenList":[{"code":"FBT000000140","level":4,"name":"紧缩性货币政策"}]},{"code":"FBT00000010S","level":3,"name":"央行加准","childrenList":[{"code":"FBT000000141","level":4,"name":"上调存款准备金率"}]},{"code":"FBT00000010T","level":3,"name":"降准","childrenList":[{"code":"FBT000000142","level":4,"name":"央行降准"}]},{"code":"FBT00000010U","level":3,"name":"SHIBOR波动","childrenList":[{"code":"FBT000000143","level":4,"name":"同业拆借利率上升"},{"code":"FBT000000144","level":4,"name":"同业拆借利率下跌"}]},{"code":"FBT00000010V","level":3,"name":"利率水平稳定","childrenList":[{"code":"FBT000000145","level":4,"name":"利率稳定"}]},{"code":"FBT00000010W","level":3,"name":"收益率波动","childrenList":[{"code":"FBT000000146","level":4,"name":"收益率上升"},{"code":"FBT000000147","level":4,"name":"收益率下降"},{"code":"FBT000000148","level":4,"name":"收益率调整"}]},{"code":"FBT00000010X","level":3,"name":"银行调整利率","childrenList":[{"code":"FBT000000149","level":4,"name":"存款利率上涨"},{"code":"FBT00000014A","level":4,"name":"存款利率下跌"},{"code":"FBT00000014B","level":4,"name":"贷款利率上涨"},{"code":"FBT00000014C","level":4,"name":"贷款利率下跌"}]},{"code":"FBT00000010Y","level":3,"name":"货币政策工具(其他)","childrenList":[{"code":"FBT00000014D","level":4,"name":"其他货币政策工具"}]}]},{"code":"FBT0000000ZW","level":2,"name":"货币供应","childrenList":[{"code":"FBT00000010Z","level":3,"name":"货币供应量","childrenList":[{"code":"FBT00000014E","level":4,"name":"货币供应量增长"},{"code":"FBT00000014F","level":4,"name":"货币供应量减少"},{"code":"FBT00000014G","level":4,"name":"货币供应量超预期"},{"code":"FBT00000014H","level":4,"name":"货币供应量低于预期"}]}]},{"code":"FBT0000000ZX","level":2,"name":"汇率","childrenList":[{"code":"FBT000000110","level":3,"name":"汇率走势","childrenList":[{"code":"FBT00000014I","level":4,"name":"人民币贬值"},{"code":"FBT00000014J","level":4,"name":"人民币升值"},{"code":"FBT00000014K","level":4,"name":"人民币汇率持稳"},{"code":"FBT00000014L","level":4,"name":"人民币汇率波动"}]},{"code":"FBT000000111","level":3,"name":"外汇占款变动","childrenList":[{"code":"FBT00000014M","level":4,"name":"外汇占款增加"},{"code":"FBT00000014N","level":4,"name":"外汇占款减少"}]},{"code":"FBT000000112","level":3,"name":"央行数字货币","childrenList":[{"code":"FBT00000014O","level":4,"name":"央行数字货币发行"}]}]}]},{"code":"FBT0000000ZS","level":1,"name":"财政政策","childrenList":[{"code":"FBT0000000ZY","level":2,"name":"财政收入","childrenList":[{"code":"FBT000000113","level":3,"name":"财政赤字变动","childrenList":[{"code":"FBT00000014P","level":4,"name":"财政赤字削减"},{"code":"FBT00000014Q","level":4,"name":"财政赤字增加"}]},{"code":"FBT000000114","level":3,"name":"财政收入变动","childrenList":[{"code":"FBT00000014R","level":4,"name":"财政收入减少"},{"code":"FBT00000014S","level":4,"name":"财政收入增加"}]},{"code":"FBT000000115","level":3,"name":"预算报告","childrenList":[{"code":"FBT00000014T","level":4,"name":"财政预算报告"}]},{"code":"FBT000000116","level":3,"name":"财政支出变动","childrenList":[{"code":"FBT00000014U","level":4,"name":"财政支出减少"},{"code":"FBT00000014V","level":4,"name":"财政支出增加"}]},{"code":"FBT000000117","level":3,"name":"转移支付","childrenList":[{"code":"FBT00000014W","level":4,"name":"财政转移支付"}]}]},{"code":"FBT0000000ZZ","level":2,"name":"财政手段","childrenList":[{"code":"FBT000000118","level":3,"name":"紧缩财政政策","childrenList":[{"code":"FBT00000014X","level":4,"name":"紧缩性财政政策"}]},{"code":"FBT000000119","level":3,"name":"扩张财政政策","childrenList":[{"code":"FBT00000014Y","level":4,"name":"扩张性财政政策"}]}]},{"code":"FBT000000100","level":2,"name":"税收政策","childrenList":[{"code":"FBT00000011A","level":3,"name":"税收措施","childrenList":[{"code":"FBT00000014Z","level":4,"name":"出台征税措施"},{"code":"FBT000000150","level":4,"name":"发布计税通知"},{"code":"FBT000000151","level":4,"name":"加强税收征管"}]},{"code":"FBT00000011B","level":3,"name":"税率调整","childrenList":[{"code":"FBT000000152","level":4,"name":"税率综合调整"},{"code":"FBT000000153","level":4,"name":"税率上调"},{"code":"FBT000000154","level":4,"name":"税率下调"}]},{"code":"FBT00000011C","level":3,"name":"调整关税","childrenList":[{"code":"FBT000000155","level":4,"name":"关税豁免"},{"code":"FBT000000156","level":4,"name":"关税调整"},{"code":"FBT000000157","level":4,"name":"关税上调"},{"code":"FBT000000158","level":4,"name":"关税下调"},{"code":"FBT000000159","level":4,"name":"加征关税"},{"code":"FBT00000015A","level":4,"name":"不加征关税"},{"code":"FBT00000015B","level":4,"name":"暂停加征关税"}]},{"code":"FBT00000011D","level":3,"name":"降低税负政策","childrenList":[{"code":"FBT00000015C","level":4,"name":"减税"},{"code":"FBT00000015D","level":4,"name":"降低费率"},{"code":"FBT00000015E","level":4,"name":"清费"},{"code":"FBT00000015F","level":4,"name":"实施退税"},{"code":"FBT00000015G","level":4,"name":"探索实行免税"},{"code":"FBT00000015H","level":4,"name":"推广税收优惠"}]},{"code":"FBT00000011E","level":3,"name":"税收收入变动","childrenList":[{"code":"FBT00000015I","level":4,"name":"税收收入增长"},{"code":"FBT00000015J","level":4,"name":"税收收入下降"}]},{"code":"FBT00000011F","level":3,"name":"增加税负政策","childrenList":[{"code":"FBT00000015K","level":4,"name":"新税出台"},{"code":"FBT00000015L","level":4,"name":"撤销免征税"},{"code":"FBT00000015M","level":4,"name":"应纳税提高"}]}]}]},{"code":"FBT0000000ZT","level":1,"name":"经济运行","childrenList":[{"code":"FBT000000101","level":2,"name":"CPI","childrenList":[{"code":"FBT00000011G","level":3,"name":"CPI目标","childrenList":[{"code":"FBT00000015N","level":4,"name":"CPI目标值"},{"code":"FBT00000015O","level":4,"name":"CPI目标修改"}]},{"code":"FBT00000011H","level":3,"name":"CPI上升","childrenList":[{"code":"FBT00000015P","level":4,"name":"CPI上涨"}]},{"code":"FBT00000011I","level":3,"name":"CPI降低","childrenList":[{"code":"FBT00000015Q","level":4,"name":"CPI下降"}]},{"code":"FBT00000011J","level":3,"name":"预测CPI","childrenList":[{"code":"FBT00000015R","level":4,"name":"CPI预测"},{"code":"FBT00000015S","level":4,"name":"CPI预计上涨"},{"code":"FBT00000015T","level":4,"name":"CPI预计下降"}]},{"code":"FBT00000011K","level":3,"name":"CPI分析","childrenList":[{"code":"FBT00000015U","level":4,"name":"CPI超预期"},{"code":"FBT00000015V","level":4,"name":"CPI低于预期"}]},{"code":"FBT00000011L","level":3,"name":"通缩","childrenList":[{"code":"FBT00000015W","level":4,"name":"通货紧缩"}]},{"code":"FBT00000011M","level":3,"name":"通胀","childrenList":[{"code":"FBT00000015X","level":4,"name":"通货膨胀"}]}]},{"code":"FBT000000102","level":2,"name":"GDP","childrenList":[{"code":"FBT00000011N","level":3,"name":"GDP目标","childrenList":[{"code":"FBT00000015Y","level":4,"name":"GDP目标修改"},{"code":"FBT00000015Z","level":4,"name":"GDP目标值"}]},{"code":"FBT00000011O","level":3,"name":"预测GDP","childrenList":[{"code":"FBT000000160","level":4,"name":"GDP预测"},{"code":"FBT000000161","level":4,"name":"GDP预计下降"},{"code":"FBT000000162","level":4,"name":"GDP预计增长"}]},{"code":"FBT00000011P","level":3,"name":"GDP分析","childrenList":[{"code":"FBT000000163","level":4,"name":"GDP超预期"},{"code":"FBT000000164","level":4,"name":"GDP低于预期"},{"code":"FBT000000165","level":4,"name":"GDP增速分析"}]},{"code":"FBT00000011Q","level":3,"name":"GDP增加","childrenList":[{"code":"FBT000000166","level":4,"name":"GDP增速放缓"},{"code":"FBT000000167","level":4,"name":"GDP增速加快"},{"code":"FBT000000168","level":4,"name":"GDP增长"}]},{"code":"FBT00000011R","level":3,"name":"GDP下行","childrenList":[{"code":"FBT000000169","level":4,"name":"GDP下降"}]}]},{"code":"FBT000000103","level":2,"name":"PMI","childrenList":[{"code":"FBT00000011S","level":3,"name":"PMI上行","childrenList":[{"code":"FBT00000016A","level":4,"name":"PMI上升"}]},{"code":"FBT00000011T","level":3,"name":"PMI下行","childrenList":[{"code":"FBT00000016B","level":4,"name":"PMI下降"}]},{"code":"FBT00000011U","level":3,"name":"PMI分析","childrenList":[{"code":"FBT00000016C","level":4,"name":"PMI超预期"},{"code":"FBT00000016D","level":4,"name":"PMI低于预期"}]},{"code":"FBT00000011V","level":3,"name":"预测PMI","childrenList":[{"code":"FBT00000016E","level":4,"name":"PMI预测"},{"code":"FBT00000016F","level":4,"name":"PMI预计上升"},{"code":"FBT00000016G","level":4,"name":"PMI预计下降"}]}]},{"code":"FBT000000104","level":2,"name":"PPI","childrenList":[{"code":"FBT00000011W","level":3,"name":"PPI增加","childrenList":[{"code":"FBT00000016H","level":4,"name":"PPI上升"}]},{"code":"FBT00000011X","level":3,"name":"PPI减少","childrenList":[{"code":"FBT00000016I","level":4,"name":"PPI下降"}]},{"code":"FBT00000011Y","level":3,"name":"PPI分析","childrenList":[{"code":"FBT00000016J","level":4,"name":"PPI超预期"},{"code":"FBT00000016K","level":4,"name":"PPI低于预期"}]},{"code":"FBT00000011Z","level":3,"name":"预测PPI","childrenList":[{"code":"FBT00000016L","level":4,"name":"PPI预测"},{"code":"FBT00000016M","level":4,"name":"PPI预计下降"},{"code":"FBT00000016N","level":4,"name":"PPI预计增长"}]}]},{"code":"FBT000000105","level":2,"name":"工业生产总值","childrenList":[{"code":"FBT000000120","level":3,"name":"工业增加值正","childrenList":[{"code":"FBT00000016O","level":4,"name":"工业生产加速"},{"code":"FBT00000016P","level":4,"name":"工业生产增速放缓"}]},{"code":"FBT000000121","level":3,"name":"工业增加值负","childrenList":[{"code":"FBT00000016Q","level":4,"name":"工业增加值减少"}]},{"code":"FBT000000122","level":3,"name":"工业能耗增加","childrenList":[{"code":"FBT00000016R","level":4,"name":"工业能耗增长"}]},{"code":"FBT000000123","level":3,"name":"工业能耗减少","childrenList":[{"code":"FBT00000016S","level":4,"name":"工业能耗下降"}]}]},{"code":"FBT000000106","level":2,"name":"固定资产投资","childrenList":[{"code":"FBT000000124","level":3,"name":"投资减少","childrenList":[{"code":"FBT00000016T","level":4,"name":"固定投资减少"}]},{"code":"FBT000000125","level":3,"name":"投资增加","childrenList":[{"code":"FBT00000016U","level":4,"name":"固定投资增加"}]},{"code":"FBT000000126","level":3,"name":"投资增速放缓","childrenList":[{"code":"FBT00000016V","level":4,"name":"固定投资增速放缓"}]}]},{"code":"FBT000000107","level":2,"name":"消费","childrenList":[{"code":"FBT000000127","level":3,"name":"消费上涨","childrenList":[{"code":"FBT00000016W","level":4,"name":"消费品零售总额增速放缓"},{"code":"FBT00000016X","level":4,"name":"消费品零售总额增速加快"},{"code":"FBT00000016Y","level":4,"name":"消费品市场增长"},{"code":"FBT00000016Z","level":4,"name":"消费品市场活跃"},{"code":"FBT000000170","level":4,"name":"消费回暖"},{"code":"FBT000000171","level":4,"name":"消费信心增强"}]},{"code":"FBT000000128","level":3,"name":"消费平稳","childrenList":[{"code":"FBT000000172","level":4,"name":"消费品市场平稳"}]},{"code":"FBT000000129","level":3,"name":"消费下滑","childrenList":[{"code":"FBT000000173","level":4,"name":"消费品零售总额下降"},{"code":"FBT000000174","level":4,"name":"消费信心下降"}]}]},{"code":"FBT000000108","level":2,"name":"就业收入","childrenList":[{"code":"FBT00000012A","level":3,"name":"工资减少","childrenList":[{"code":"FBT000000175","level":4,"name":"平均工资减少"}]},{"code":"FBT00000012B","level":3,"name":"工资增加","childrenList":[{"code":"FBT000000176","level":4,"name":"平均工资增速放缓"},{"code":"FBT000000177","level":4,"name":"平均工资增加"}]},{"code":"FBT00000012C","level":3,"name":"失业率增加","childrenList":[{"code":"FBT000000178","level":4,"name":"失业率上升"}]},{"code":"FBT00000012D","level":3,"name":"失业率降低","childrenList":[{"code":"FBT000000179","level":4,"name":"失业率下降"}]},{"code":"FBT00000012E","level":3,"name":"社会保障","childrenList":[{"code":"FBT00000017A","level":4,"name":"社会保障制度"}]},{"code":"FBT00000012F","level":3,"name":"就业政策","childrenList":[{"code":"FBT00000017B","level":4,"name":"就业政策发布"}]}]},{"code":"FBT000000109","level":2,"name":"经济预测","childrenList":[{"code":"FBT00000012G","level":3,"name":"经济负面","childrenList":[{"code":"FBT00000017C","level":4,"name":"金融危机"},{"code":"FBT00000017D","level":4,"name":"经济泡沫"},{"code":"FBT00000017E","level":4,"name":"经济下行"}]},{"code":"FBT00000012H","level":3,"name":"经济增长","childrenList":[{"code":"FBT00000017F","level":4,"name":"经济加速增长"},{"code":"FBT00000017G","level":4,"name":"经济增速放缓"},{"code":"FBT00000017H","level":4,"name":"经济向好"}]},{"code":"FBT00000012I","level":3,"name":"经济预期","childrenList":[{"code":"FBT00000017I","level":4,"name":"上调经济增长预期"},{"code":"FBT00000017J","level":4,"name":"下调经济增长预期"}]},{"code":"FBT00000012J","level":3,"name":"经济规划","childrenList":[{"code":"FBT00000017K","level":4,"name":"发布经济规划"}]}]},{"code":"FBT00000010A","level":2,"name":"对外经济","childrenList":[{"code":"FBT00000012K","level":3,"name":"贸易顺差","childrenList":[{"code":"FBT00000017L","level":4,"name":"贸易顺差扩大"},{"code":"FBT00000017M","level":4,"name":"贸易顺差收窄"}]},{"code":"FBT00000012L","level":3,"name":"贸易逆差","childrenList":[{"code":"FBT00000017N","level":4,"name":"贸易逆差扩大"},{"code":"FBT00000017O","level":4,"name":"贸易逆差收窄"}]},{"code":"FBT00000012M","level":3,"name":"贸易数据","childrenList":[{"code":"FBT00000017P","level":4,"name":"进出口额数据"}]},{"code":"FBT00000012N","level":3,"name":"外贸","childrenList":[{"code":"FBT00000017Q","level":4,"name":"对外贸易"}]}]},{"code":"FBT00000010B","level":2,"name":"经济运行(其他)","childrenList":[{"code":"FBT00000012O","level":3,"name":"其他经济运行","childrenList":[{"code":"FBT00000017R","level":4,"name":"其他经济运行事件"}]}]}]},{"code":"FBT0000000ZU","level":1,"name":"公共事件","childrenList":[{"code":"FBT00000010C","level":2,"name":"自然灾害","childrenList":[{"code":"FBT00000012P","level":3,"name":"发生地震","childrenList":[{"code":"FBT00000017S","level":4,"name":"地震"}]},{"code":"FBT00000012Q","level":3,"name":"发生滑坡","childrenList":[{"code":"FBT00000017T","level":4,"name":"滑坡"}]},{"code":"FBT00000012R","level":3,"name":"泥石流灾害","childrenList":[{"code":"FBT00000017U","level":4,"name":"泥石流"}]},{"code":"FBT00000012S","level":3,"name":"大气污染问题","childrenList":[{"code":"FBT00000017V","level":4,"name":"大气污染"}]},{"code":"FBT00000012T","level":3,"name":"水污染问题","childrenList":[{"code":"FBT00000017W","level":4,"name":"水污染"}]},{"code":"FBT00000012U","level":3,"name":"土壤污染问题","childrenList":[{"code":"FBT00000017X","level":4,"name":"土壤污染"}]},{"code":"FBT00000012V","level":3,"name":"极端低温事件","childrenList":[{"code":"FBT00000017Y","level":4,"name":"极端低温"}]},{"code":"FBT00000012W","level":3,"name":"极端高温事件","childrenList":[{"code":"FBT00000017Z","level":4,"name":"极端高温"}]},{"code":"FBT00000012X","level":3,"name":"冰雹灾害","childrenList":[{"code":"FBT000000180","level":4,"name":"冰雹"}]},{"code":"FBT00000012Y","level":3,"name":"发生厄尔尼诺","childrenList":[{"code":"FBT000000181","level":4,"name":"厄尔尼诺"}]},{"code":"FBT00000012Z","level":3,"name":"发生干旱","childrenList":[{"code":"FBT000000182","level":4,"name":"干旱"}]},{"code":"FBT000000130","level":3,"name":"洪水灾害","childrenList":[{"code":"FBT000000183","level":4,"name":"洪水"}]},{"code":"FBT000000131","level":3,"name":"发生拉尼娜","childrenList":[{"code":"FBT000000184","level":4,"name":"拉尼娜"}]},{"code":"FBT000000132","level":3,"name":"台风灾害","childrenList":[{"code":"FBT000000185","level":4,"name":"台风"}]},{"code":"FBT000000133","level":3,"name":"发生天文灾害","childrenList":[{"code":"FBT000000186","level":4,"name":"天文灾害"}]},{"code":"FBT000000134","level":3,"name":"发生火灾","childrenList":[{"code":"FBT000000187","level":4,"name":"火灾"}]}]},{"code":"FBT00000010D","level":2,"name":"生物灾害","childrenList":[{"code":"FBT000000135","level":3,"name":"发生蝗灾","childrenList":[{"code":"FBT000000188","level":4,"name":"蝗灾"}]},{"code":"FBT000000136","level":3,"name":"发生病虫灾害","childrenList":[{"code":"FBT000000189","level":4,"name":"病虫灾害"}]}]},{"code":"FBT00000010E","level":2,"name":"疫情灾害","childrenList":[{"code":"FBT000000137","level":3,"name":"发生SARS","childrenList":[{"code":"FBT00000018A","level":4,"name":"SARS"}]},{"code":"FBT000000138","level":3,"name":"肺炎传播","childrenList":[{"code":"FBT00000018B","level":4,"name":"肺炎"}]},{"code":"FBT000000139","level":3,"name":"流感","childrenList":[{"code":"FBT00000018C","level":4,"name":"流感爆发"}]},{"code":"FBT00000013A","level":3,"name":"疫苗","childrenList":[{"code":"FBT00000018D","level":4,"name":"疫苗上市"}]},{"code":"FBT00000013B","level":3,"name":"鼠疫","childrenList":[{"code":"FBT00000018E","level":4,"name":"爆发鼠疫"}]},{"code":"FBT00000013C","level":3,"name":"疯牛病","childrenList":[{"code":"FBT00000018F","level":4,"name":"爆发疯牛病"}]},{"code":"FBT00000013D","level":3,"name":"禽流感","childrenList":[{"code":"FBT00000018G","level":4,"name":"爆发禽流感"}]},{"code":"FBT00000013E","level":3,"name":"猪瘟","childrenList":[{"code":"FBT00000018H","level":4,"name":"爆发猪瘟"}]}]},{"code":"FBT00000010F","level":2,"name":"政治时事","childrenList":[{"code":"FBT00000013F","level":3,"name":"政治事件","childrenList":[{"code":"FBT00000018I","level":4,"name":"国内外政治事件"}]},{"code":"FBT00000013G","level":3,"name":"战争冲突","childrenList":[{"code":"FBT00000018J","level":4,"name":"战争"}]},{"code":"FBT00000013H","level":3,"name":"罢工事件","childrenList":[{"code":"FBT00000018K","level":4,"name":"罢工"}]}]}]}]
     

    展开全文
  • 两个视图的分布可以是左右式,也可以是上下,看各人习惯。今天我终于找到了切换上下或左右的方法,记录如下: 如下图,必须在红框标注的那个黑色小箭头上右击,将出现“Rotate to right”/"Rotate to left"的选项。...

    我使用的是Notepad++ v6.9.1版本。

    Notepad++有个“移动到另一视图”功能,当需要比较两个文件时非常方便。两个视图的分布可以是左右式,也可以是上下,看各人习惯。今天我终于找到了切换上下或左右的方法,记录如下:

    如下图,必须在红框标注的那个黑色小箭头上右击,将出现“Rotate to right”/"Rotate to left"的选项。这两个选项就是调整上下还是左右显示的。


    展开全文
  • 引言 最近要做一个组织机构树的树级菜单展示,UI...先考虑改造Tree控件,这其中不仅需要修改css,还要修改Tree的内部结构 不使用Tree控件直接使用Menu导航菜单,在其上添加所需要的功能 这里采用第二种方案,首先...

    引言

    最近要做一个组织机构树的树级菜单展示,UI框架使用的是Ant Design,这不正好可以使用Tree组件,如图示
    原始图片
    奈何领导说太丑,指明要换成类似Menu形式的树形菜单,如图示
    修改后图片

    于是乎,有两种修改方案

    • 先考虑改造Tree控件,这其中不仅需要修改css,还要修改Tree的内部结构
    • 不使用Tree控件直接使用Menu导航菜单,在其上添加所需要的功能

    这里采用第二种方案,首先确认需要在其上添加的功能,主要包括:
    1. 节点异步加载功能(打开某个部门时,异步加载该部门下的子部门及其成员)
    2. 全局检索功能(在搜索框输入内容时,对菜单执行检索、高亮显示匹配的菜单并自动打开匹配菜单的所有父级菜单),见下图
    3. 右键对本节点菜单进行编辑、子节点的添加、删除(视具体业务逻辑而定)
    搜索图片

    全局代码(未经优化)

    全局状态管理使用mobx,具体可以查看相关文档
    Tree.js

    import React from "react";
    import { inject, observer } from "mobx-react";
    import {addSubmenuSelected, removeSubmenuSelected} from '../utils/common';
    import { Menu, Icon, Input } from "antd";
    import { ContextMenu, MenuItem, ContextMenuTrigger } from "react-contextmenu";
    import '../assets/css/tree.css';
    const SubMenu = Menu.SubMenu;
    
    /*组织节点扁平化列表*/
    let dataList = [];
    
    /* 父节点列表 */
    let parentList = [];
    
    const generateList = (data) => {
        for (let i = 0; i < data.length; i++) {
            const node = data[i];
            const nodeId = node.nodeId;
            dataList.push({nodeId, name: node.name, parentNodeId: node.parentNodeId});
            if (node.children.length > 0) {
                generateList(node.children);
            }
        }
    };
    
    const getParentKey = (nodeId, tree) => {
        let parentKey;
        for (let i = 0; i < tree.length; i++) {
            const node = tree[i];
            if (node.children.length > 0) {
                if (node.children.some(item => item.nodeId === nodeId)) {
                    parentKey = node.nodeId;
                } else if (getParentKey(nodeId, node.children)) {
                    parentKey = getParentKey(nodeId, node.children);
                }
            }
        }
        return parentKey;
    };
    
    const getAllParentKey = (parentIds) => {
        if (parentIds.length === 0) {
            return;
        }
        let ids = [];
        parentIds.forEach(item => {
            if (!parentList.includes(item)) {
                parentList.push(item);
            }
            dataList.forEach(node => {
                if (node.nodeId === item) {
                    if (node.parentNodeId !== null && !ids.includes(node.parentNodeId)) {
                        ids.push(node.parentNodeId);
                    }
                }
            });
        });
        return getAllParentKey(ids);
    };
    
    const getDatasetNode = (currentNode) => {
        let current = currentNode;
        while (current.nodeName !== 'LI') {
            current = current.parentNode;
        }
        return current;
    };
    
    /*节点自增标示*/
    let count = 10;
    
    @inject("rootStore")
    @observer
    class Tree extends React.Component {
        state = {
            searchValue: "",
            selectedKeys: [],
            openKeys: [],
            rightClickNode: null
        };
    
        componentDidMount() {
            document.querySelector('.react-contextmenu-wrapper').addEventListener('contextmenu', this.handleRightClick);
        }
    
        componentWillUnmount() {
            document.querySelector('.react-contextmenu-wrapper').removeEventListener('contextmenu', this.handleRightClick);
        }
    
        renderIcon = (type, flag) => {
            switch (type) {
                case 'ROOT':
                    return (
                        <Icon type="home" style={ flag === 1? {color: '#00EE76'} : {}} />
                    );
                case 'GROUP':
                    return (
                        <Icon type="usergroup-add" style={ flag === 1? {color: '#00EE76'} : {}} />
                    );
                case 'BUSINESS':
                    return (
                        <Icon type="bank" style={ flag === 1? {color: '#00EE76'} : {}} />
                    );
                case 'LOADING':
                return (
                    <Icon type="loading" style={flag === 1? {color: '#00EE76'} : {}}></Icon>
                );
                default:
                    return (
                        <Icon type="team" style={ flag === 1? {color: '#00EE76'} : {}} />
                    );
            }
        };
    
        loop = data => data.map(item => {
            let {searchValue} = this.state;
            const index = item.name.indexOf(searchValue);
            const beforeStr = item.name.substr(0, index);
            const afterStr = item.name.substr(index + searchValue.length);
            const title = index > -1 ? (
                <span>
                    {this.renderIcon(item.nodeType, searchValue? 1 : 2)}
                    {beforeStr}
                    <span style={{color: '#00EE76'}}>{searchValue}</span>
                    {afterStr}
                </span>
            ) : <span>
                    {this.renderIcon(item.nodeType, 2)}
                    <span>{item.name}</span>
                </span>;
            if (item.canDeploy) {
                return (
                    <SubMenu
                        key={item.nodeId}
                        data-id={item.nodeId}
                        data-privilege={item.privilege}
                        onTitleClick={this.handleTitleClick(item)}
                        title={title}
                    >
                        {this.loop(item.children)}
                    </SubMenu>
                );
            }
            return (
                <Menu.Item key={item.nodeId} data-id={item.nodeId} data-privilege={item.privilege}>
                    {title}
                </Menu.Item>
            );
        });
    
        handleChange = (e) => {
            const value = e.target.value;
            let {treeData} = this.props.rootStore.treeStore;
            /* 获取包含搜索内容的所有节点key */
            let openKeys = dataList.map((item) => {
                if (item.name.indexOf(value) > -1) {
                    return getParentKey(item.nodeId, treeData);
                }
                return null;
            }).filter((item, i, self) => item && self.indexOf(item) === i);
            /* 重置需要展开的父节点id */
            parentList = [];
            /* 将所选中的内容的节点id的全部父节点id写入parentList中 */
            getAllParentKey(openKeys);
            openKeys = parentList;
            this.setState({
                openKeys,
                searchValue: value,
            });
        };
    
        handleClick = e => {
            /* 每个menuItem绑定点击事件 */
            console.log("click ", e);
        };
    
        handleOpenChange = (openKeys) => {
            /* 可获取当前所有已经打开面板的key列表 */
            // console.log(openKeys);
            this.setState({
                openKeys
            });
        };
    
        handleAsyncLoadData = (treeNode) => {
            let nodeTypeTemp = treeNode.nodeType;
            treeNode.nodeType = 'LOADING';
            return new Promise((resolve) => {
                if (treeNode.children.length > 0) {
                    treeNode.nodeType = nodeTypeTemp;
                    resolve();
                    return;
                }
                setTimeout(() => {
                    treeNode.nodeType = nodeTypeTemp;
                    treeNode.children = [
                        { name: 'Child' + count, nodeId: (count++ + ''), parentNodeId: treeNode.nodeId, nodeType: 'GROUP', children: [], canDeploy: true, privilege: 7 },
                        { name: 'Child' + count, nodeId: (count++ + ''), parentNodeId: treeNode.nodeId, nodeType: 'GROUP', children: [], canDeploy: false, privilege: 7 },
                    ];
                    resolve();
                }, 2000);
            });
        };
    
        handleTitleClick = (treeNode) => ({key, domEvent}) => {
            // console.log(key);
            addSubmenuSelected(domEvent);
            this.setState({
                selectedKeys: []
            });
            this.handleAsyncLoadData(treeNode);
        };
    
        handleSelect = ({ item, key, selectedKeys }) => {
            /* 只有menuItem才能选中,选中会执行该函数 */
            console.log(item, key, selectedKeys);
            removeSubmenuSelected();
            this.setState({
                selectedKeys
            });
        };
    
        loopAdd = (node, data) => {
            data.forEach((item) => {
                if (node.parentNodeId === item.nodeId) {
                    console.log(item);
                    item.canDeploy = true;
                    item.children.push(node);
                    /* this.setState({
                        openKeys: this.state.openKeys.concat(item.nodeId)
                    }); */
                    return 1;
                } else {
                    if (item.children.length > 0) {
                        return this.loopAdd(node, item.children);
                    }
                }
            });
        };
    
        loopEdit = (node, data) => {
            data.forEach((item) => {
                if (node.nodeId === item.nodeId) {
                    Object.keys(node).forEach(key => {
                        if (key !== 'children') {
                            item[key] = node[key];
                        }
                    });
                    return 1;
                } else {
                    if (item.children.length > 0) {
                        return this.loopEdit(node, item.children);
                    }
                }
            });
        };
    
        loopDelete = (parentId, nodeId, data) => {
            console.log(parentId, nodeId);
            data.forEach((item) => {
                if (parentId === item.nodeId) {
                    let index = 0;
                    item.children.forEach((child, key) => {
                        if (child.nodeId === nodeId) {
                            index = key;
                        }
                    });
                    // this.props.rootStore.accountStore.updateSelectedNode(item);
                    item.children.splice(index, 1);
                    return 1;
                } else {
                    if (item.children.length > 0) {
                        return this.loopDelete(parentId, nodeId, item.children);
                    }
                }
            });
        };
    
        /* 右键点击处理 */
        handleMenuItemClick = (e, data) => {
            e.preventDefault();
            let {treeData} = this.props.rootStore.treeStore;
            console.log(data);
            switch (data.status) {
                case 0:
                    /* 添加节点 */
                    this.loopAdd({
                        name: 'Child' + count,
                        nodeId: (count++ + ''),
                        parentNodeId: data.nodeId, 
                        nodeType: 'GROUP', 
                        children: [],
                        privilege: '1', 
                        canDeploy: true
                    }, treeData);
                    break;
                case 1: 
                    this.loopEdit({
                        name: 'edit' + count,
                        nodeId: data.nodeId,
                        parentNodeId: data.nodeId, 
                        nodeType: 'GROUP', 
                        children: [],
                        privilege: '1', 
                        canDeploy: true
                    }, treeData);
                    break;
                case 2:
                    this.loopDelete('2', data.nodeId, treeData);
                    break;
                default:
                    return;
            }
            // 右键处理完毕后,重置右击节点数据
            this.setState({
                rightClickNode: null
            });
        };
    
        handleRightClick = (event) => {
            // console.log(event.target);
            let dataNode = getDatasetNode(event.target);
            this.setState({
                rightClickNode: dataNode.dataset
            });
            // console.log(dataNode.dataset);
        };
    
        render() {
            let { treeData } = this.props.rootStore.treeStore;
            let {selectedKeys, searchValue, openKeys, rightClickNode} = this.state;
            /* 节点扁平化处理 */
            dataList = [];
            generateList(treeData);
            return (
                <div className="tree">
                    <Input style={{marginBottom: '50px'}} placeholder="search value" value={searchValue} onChange={this.handleChange} />
                    <ContextMenuTrigger id="context-menu" holdToDisplay={1000}>
                        <Menu
                            onClick={this.handleClick}
                            style={{ width: "100%" }}
                            onOpenChange={this.handleOpenChange}
                            mode="inline"
                            theme="dark"
                            openKeys={openKeys}
                            selectedKeys={selectedKeys}
                            onSelect={this.handleSelect}
                        >
                            {this.loop(treeData)}
                        </Menu>
                    </ContextMenuTrigger>
                    <ContextMenu id="context-menu">
                        <MenuItem
                            onClick={this.handleMenuItemClick}
                            disabled={rightClickNode? (['0', '1'].includes(rightClickNode.privilege)) : false}
                            data={{nodeId: rightClickNode? rightClickNode.id : '', status: 0}}
                        >
                            添加
                        </MenuItem>
                        <MenuItem
                            onClick={this.handleMenuItemClick}
                            disabled={rightClickNode? (['0', '1'].includes(rightClickNode.privilege)) : false}
                            data={{nodeId: rightClickNode? rightClickNode.id : '', status: 1}}
                        >
                            编辑
                        </MenuItem>
                        <MenuItem divider />
                        <MenuItem
                            onClick={this.handleMenuItemClick}
                            disabled={rightClickNode? (['0', '1'].includes(rightClickNode.privilege)) : false}
                            data={{nodeId: rightClickNode? rightClickNode.id : '', status: 2}}
                        >
                            删除
                        </MenuItem>
                    </ContextMenu>
                </div>
            );
        }
    }
    
    export default Tree;

    common.js

    export const removeSubmenuSelected = function () {  
        document.querySelectorAll('.submenu-selected').forEach((domNode) => {
            domNode.classList.remove('submenu-selected');
        });
    };
    
    export const addSubmenuSelected = function (domEvent) {  
        document.querySelectorAll('.submenu-selected').forEach((domNode) => {
            domNode.classList.remove('submenu-selected');
        });
        domEvent.currentTarget.classList.add('submenu-selected');
    }

    treeStore.js

    import {observable, action} from 'mobx';
    
    class TreeStore {
        constructor(rootStore) {
            this.rootStore = rootStore;
        }
    
        @observable treeData = [{
            name: 'parent1',
            nodeId: '1',
            nodeType: 'ROOT',
            canDeploy: true,
            privilege: '7',
            parentNodeId: null,
            children: [
                {
                    name: 'parent2',
                    nodeId: '2',
                    nodeType: 'GROUP',
                    canDeploy: true,
                    parentNodeId: '1',
                    privilege: '0',
                    children: [
                        {
                            name: 'leaf1',
                            nodeId: '3',
                            parentNodeId: '2',
                            nodeType: 'GROUP',
                            canDeploy: true,
                            children: [],
                            privilege: '7'
                        },
                        {
                            name: 'leaf2',
                            nodeId: '4',
                            parentNodeId: '2',
                            nodeType: 'BUSINESS',
                            canDeploy: false,
                            children: [],
                            privilege: '7'
                        },
                        {
                            name: 'leaf3',
                            nodeId: '5',
                            parentNodeId: '2',
                            privilege: '7',
                            nodeType: 'TEAM',
                            canDeploy: true,
                            children: []
                        }
                    ]
                },
                {
                    name: 'parent3',
                    nodeId: '6',
                    parentNodeId: '1',
                    nodeType: 'GROUP',
                    canDeploy: true,
                    privilege: '7',
                    children: [
                        {
                            name: 'leaf4',
                            nodeId: '7',
                            parentNodeId: '6',
                            privilege: '7',
                            nodeType: 'GROUP',
                            children: []
                        },
                        {
                            name: 'leaf5',
                            nodeId: '8',
                            parentNodeId: '6',
                            nodeType: 'BUSINESS',
                            privilege: '7',
                            children: []
                        },
                        {
                            name: 'leaf6',
                            nodeId: '9',
                            parentNodeId: '6',
                            nodeType: 'TEAM',
                            privilege: '0',
                            children: []
                        }
                    ]
                },
            ]
        }];
    
        /*更新树,该方法未使用*/
        @action updateTree(treeData) {
            this.treeData = treeData;
        }
    }
    
    export default TreeStore;

    异步节点加载

    1. 节点结构的抽离具体体现在 loop方法,其中直接修改使用了一部分Tree控件的代码,其中有一个重要字段canDeploy,代表当前节点下是否有子节点,是一个分界值。
    2. 当有子节点的话肯定是可以打开的,点击的时候调用handleTitleClick方法,该方法的调用可以直接查看Ant Design官方API文档,接着为当前点击的节点添加激活状态,见common.js,当叶子节点选中时见handleSelect方法,这个时候要修改Menu组件的selectedKeys选项,其中只有叶子节点才有selectedKeys配置。
    3. 调用接口进行异步节点的加载见handleAsyncLoadData方法,该方法在请求过程中以更换Icon的方式来显示loading效果,如果当前节点下面已有子节点列表,说明该节点被打开过,无需再次加载,没有子节点的话,打开后会默认填充假节点数据,填充后即可展示。

    全局检索

    1. 关注搜索框的handleChange方法,其中dataList是将整个树形菜单的数据进行拉平处理的产物,执行遍历找到所有匹配内容的节点的父节点,因为要自动打开匹配内容节点的所有父级节点,所以使用getAllParentKey方法来获取上一步获得的父节点的所有父节点,将这写需要打开的父节点装到parentList里面,将它赋值给Menu配置项openKeys即可实现匹配内容节点的父节点实现自动打开。

    右键编辑、添加、删除

    这里实现右击菜单使用了react-contextmenu,使用方法可自行github查找
    1. 该右击插件并没有提供右击回调函数,导致我们无从捕获当前被右击选择的节点是谁,这里采用绑定事件的方式来进行回调处理,见componentDidMount, componentWillUnmount
    2. 右击时是需要的获取到一些节点的信息的,比如节点ID,节点权限。此时需要注意到在loop方法中,已经为其分发了一些data-*的属性值,查看控制台DOM节点可以看到这些分发的属性都作用在列表的li标签上,接下来就要获取右击选中元素,查看该标签是否为li标签,不是则继续向父级查找,直到找到第一个为止,然后获取其上的data-*的数据。li标签查找方法见getDatasetNode方法,将最后获取的数据赋值给rightClickNode
    3. 添加、编辑、删除处理方法见handleMenuItemClick,该参数接收的data即为rightClickNode中的数据
    4. 添加具体方法见loopAdd方法,这里都是测试使用数据
    5. 编辑具体方法见loopEdit方法
    6. 删除具体方法见loopDelete方法

    码不动了,对比着官方Menu组件和Tree组件,应该可以理解。(有其他的方案也可以在下面进行交流优化)
    展开全文
  • 转发某位大牛的链接 https://blog.csdn.net/Dream_xun/article/details/83116804

    转发某位大牛的链接 https://blog.csdn.net/Dream_xun/article/details/83116804
    分享:我在请求后台返回的数据的时候,自己利用递归遍历封装了方法把后台请求的数据转换成插件需要的数据格式
    这里转换的是对象数组形式

    //封装方法
    function buildTree(data){
          //构建tree的根节点 即超级管理员
           var tree = new Object();
           parseTree(data, tree);
           var list  = new Array();
           list.push(tree);
           return list;
      }
     function parseTree(data, tree) {
          tree.label = data.RoleName;
          tree.id = data.ID;
          //构建子节点
          var subTree = data.listManagerRole;
          if(!subTree || subTree.length === 0) {
              return tree;
          } else {
            var children = new Array();
            for(var i = 0, len = subTree.length;i < len; i++) {
               var child = new Object();
               child = parseTree(subTree[i], child)
               children.push(child)
            }
              tree.children = children;
              return tree;
           }
      }
    

    注意:在使用的使用会出现的错误,绑定的默认值不能是空字符串或数字否则会出现(unknow),只能绑定初始化为null的变量才可以,根据后台返回的值默认选中直接绑定后台返回的value值即可

    展开全文
  • 数据结构思维 前言

    万次阅读 2017-09-02 16:01:35
    本书背后的哲学数据结构和算法是过去 50 年来最重要的发明之一,它们是软件工程师需要了解的基础工具。但是在我看来,这些话题的大部分书籍都过于理论,过于庞大,也是“自底向上”的:过于理论算法的数学分析基于...
  • 中文词语概念上下位图谱项目

    千次阅读 2018-10-07 10:26:40
    HyponymyExtraction ...HyponymyExtraction and Graph based on KB Schema, Baike-kb and online text extract, 基于知识概念体系,百科知识库,以及在线搜索结构化方式的词语上下位抽取. 项目介绍 上下...
  • Tanh激活函数:和sigmoid相似,它会关于x轴上下对应,不至于朝某一方面偏向 Tanh激活函数 ReLU激活函数(修正线性单元):收敛快,求梯度快,但较脆弱,左边的梯度为0 ReLU激活函数 Leaky ReLU激活...
  • 组织结构图 js实现

    万次阅读 2015-12-31 13:49:51
    最近公司需要将原来项目里 机构的树状展示图形添加一个 组织结构图的展示。 在网上找了找代码,感觉这个 http://blog.sina.com.cn/s/blog_6d0c777b01013mwj.html   挺简单,简单的修改运行了起来,测试的时候...
  • 前端结构解析是本学堂新开设的一套系列文章,简介如下。 目的:总结和发现前端设计的各种结构,分析每种结构的优点与不足,说明其适用的场景和内容。...众所周知,汉堡是上下各一层面包片,中间夹着一层层的菜
  • 数据结构思维 第八章 索引器

    万次阅读 2017-09-12 19:37:50
    第八章 索引器 ...在网页搜索的上下文中,索引是一种数据结构,可以查找检索词并找到该词出现的页面。此外,我们想知道每个页面上显示检索词的次数,这将有助于确定与该词最相关的页面。例如,如果用户提交检
  • 软件体系结构期末复习总结

    千次阅读 多人点赞 2020-08-18 21:14:41
    软件体系结构是具有一定形式的结构化元素,抽象的讲,软件体系结构包括构成系统的设计元素的描述,设计元素的交互,设计元素组合的模式,以及在这些模式中的约束。具体的讲,体系结构 = 组件+连接件+约束 组件:...
  • SlidingDrawerLayout上下滑动的菜单控件

    千次阅读 多人点赞 2016-06-24 23:04:55
    有一种控件需求,通过上下滑动来打开上下菜单。这个控件要求自动打开上下两个菜单,而且还要随着手势(注意:多触点)上下滑动菜单。之前Android系统有提供一个叫SlidingDrawer(完整路径:android.widget....
  • 数据结构课程设计——校园导游系统(C语言)

    万次阅读 多人点赞 2020-07-06 12:34:23
    数据结构课程设计——校园导游系统(C语言)欢迎阅读==罡罡同学==的文章(关注不迷路)关于数据结构课程设计程序设计的功能程序源代码总结 欢迎阅读罡罡同学的文章(关注不迷路) (记得点赞关注) 还在为代码无法...
  • HTML5实现的矢量卡片式组织结构

    万次阅读 2015-05-08 16:29:02
    组织结构图(Organization chart)是企业的流程运转、部门设置及职能规划等最基本的结构依据。和客户交流时,不少人都提到需要一个灵活的工具来绘制呈现企业的组织...先来一个经典的上下层级布局: 再来一个
  • Javascript实现的超炫组织结构

    热门讨论 2012-10-19 11:27:01
    Javascript实现的超炫组织结构图 支持动态效果 支持JQuery 支持JSON数据格式 支持动态填充数据 支持拖拽 支持结点展开收缩 支持变换根结点 支持结点形状变换(矩形、椭圆型、圆形、五角星等) 支持线条样式变换 支持...
  • 广义话题结构是汉语篇章中客观存在的结构。它以标点句为基本单位,按照流水模型组织。我们对数十万字多种语体的篇章语料进行了广义话题结构的标注和统计分析,从中进一步发现了一些有意义的语言现象,如:大部分标点...
  • 数据结构思维 第十六章 布尔搜索

    万次阅读 2017-09-25 14:41:39
    在信息检索的上下文中,“相关性分数”用于表示页面多么满足从查询推断出的用户需求。相关性分数的构建有很多种方法,但大部分都基于“检索词频率”,它是搜索词在页面上的显示次数。一种常见的相关性分数称为 TF-...
  • 论文:Learning Transferable Architectures for Scalable Image Recognition ...我们知道现在图像分类、检测算法的优劣很大一部分取决于网络结构的设计,最近今年比较优秀的分类网络结构比如VGG,ResN
  • JQ插件OrgChart实现组织结构

    千次阅读 2018-06-19 14:16:01
    有添加,编辑,删除等功能…随后我就找了一些插件:1、jsMind(脑图): 查看文档jsMind目前有左右伸展的,没有上下伸展。2、JavaScript InfoVis Toolkit:查看文档JavaScript InfoVis Toolkit光看这些展示demos就...
  • 软件体系结构

    万次阅读 2013-06-18 00:50:25
    架构定义:某个软件或计算系统的软件构架是该系统的一个或多个结构,它由软件元素、这些元素的外部可见属性以及这些元素之间的关系组成。 2.含义: •首先,构架定义了软件元素。构架必须省略元素中与其交互无关的...
  • 数据结构与算法之走迷宫

    千次阅读 2017-07-10 20:21:16
    数据结构与算法 Java实现走迷宫
  • IDEA修改创建多级package包结构样式

    千次阅读 2019-07-22 11:44:41
    IDEA修改创建多级package包结构样式 一、场景描述 当连续创建的包为空包时候,默认显示在同一层级。需要显示多层package层级关系怎么搞? 二、修改package包之间的层级关系 1、两个包显示在同一层级。 2、...
  • 比较经典的光学三维测量方法有:双目立体视觉、线激光扫描、格雷码结构光、相移结构光。立体匹配方法误匹配点较多,线激光方法扫描速度慢,相移结构光方法计算效率低,而格雷码方法基本具有以上一个方法的所有优势,...
  • 数据结构思维 第十四章 持久化

    万次阅读 2017-09-23 22:01:54
    在 Redis 的上下文中,第二个键被称为“字段”,这可能有助于保持清晰。所以类似 myhash 的“键”标志一个特定的哈希表,然后类似 word1 的“字段”标识一个哈希表中的值。 对于许多应用程序,Redis 哈希表中的值...
  • (1) 老鼠形象可以辨认,可用键盘操纵老鼠上下左右移动 (2) 迷宫的墙足够结实,老鼠不能穿墙而过 (3) 正确检测结果,若老鼠在规定时间内走到粮仓处,提示成功,并给出一条路径,否则提示失败 (4) 添加编辑...
  • 《语言处理NLP知识结构》 《自然语言处理NLP国内研究方向机构导师》 总共超过20000字,量子位建议先码再看。 自然语言处理技术发展史十大里程碑 文|秦陇纪,参考|黄昌宁、张小凤、Sebatian Ruder...
  • 1、可以生成动态表头,单级,多级都支持,尤其是树形表头(整体思路按照树形结构数据来遍历); 2、数据可配置,支持动态填写数据(一个List结构的数据); 3、读取Excel数据; 设计思路:需要一个含有树形结构的...
  • 如图所示:image跟view标签上下产生了不该存在间隙。 DOM结构如下: 首先看看是不是margin在作祟: 审查元素image标签: view标签: 事实证明跟margin无关; 但是我们发现,image的display是 inline-...
  • 图数据库neo4j存储数据结构分析

    千次阅读 2019-12-02 15:10:41
    一共有上下左右中五条边。SP和SN表示起点的前一条和下一条边,EP和EN表示终点的前一条和下一条边。 先看左边。它的起点为左下点,是第一条边,所以SP为空。其终点左上点有3条边,按照顺时针排序,该边是左...
  • 计算机体系结构

    千次阅读 2017-09-06 09:16:33
    这些操作均发生在前端总线的事务上下文结构(the context of a transaction)中。前端总线事务的执行包含五个阶段:仲裁,请求,侦听,响应,数据操作。在执行事务的过程中,前端总线上的各个部件扮演着不同的角色。...

空空如也

空空如也

1 2 3 4 5 ... 20
收藏数 40,057
精华内容 16,022
关键字:

展是上下结构