首页 > 代码库 > cxselect联动下拉菜单 所需数据格式封住

cxselect联动下拉菜单 所需数据格式封住

具体前端就看:http://code.ciaoca.com/jquery/cxSelect/

后台数据封装代码

//查询区
        List<Vrc_zgz_areaPO> areaPO = addressExtendDao.getAreaPO();
        //查询市
        List<Vrc_zgz_citysPO> citysPO = addressExtendDao.getCitysPO();
        //查询省
        List<Vrc_zgz_provincesPO> provincesPO = addressExtendDao.getProvincesPO();

 

public static String Getprovinces(List<Vrc_zgz_provincesPO> provincesPO,List<Vrc_zgz_citysPO> citysPO,List<Vrc_zgz_areaPO> areaPO){
        //
        List<Map<String, Object>> ProvoinList = new ArrayList<Map<String, Object>>();
        for(Vrc_zgz_provincesPO provinces : provincesPO){
            Map<String,Object> shen =new HashMap<String,Object>();
            List<Map<String, Object>> shis=geiShiList(provinces.getProvinceid(),citysPO,areaPO);
            if(shis.size()>0){
                shen.put("s", shis);
            }
            shen.put("n",provinces.getProvince());
            ProvoinList.add(shen);
        }
        String json = JsonUtils.objectToJson(ProvoinList);
        
        return json;
    }
    
    /**
     * 封装
     * @param provinceid
     * @param citysPO
     * @return
     */
    private static List<Map<String, Object>> geiShiList(String provinceid, List<Vrc_zgz_citysPO> citysPO,List<Vrc_zgz_areaPO> areaPO) {
        List<Map<String, Object>> list=new ArrayList<Map<String, Object>>();
        for(Vrc_zgz_citysPO citys:citysPO){
                if(citys.getProvinceid().equals(Integer.valueOf(provinceid))){
                    Map<String,Object> map =new HashMap<String,Object>();
                    map.put("n",citys.getCityname());
                    List<Map<String, Object>>  qus=geiquList(citys.getCityid(),areaPO);
                    if(qus.size()>0){
                        map.put("s",qus);
                    }
                list.add(map);
                }
            }
        
        return list;
    }

    /**
     * @param cityid
     * @param areaPO
     * @return
     */
    private static List<Map<String, Object>>  geiquList(Integer cityid, List<Vrc_zgz_areaPO> areaPO) {
        List<Map<String, Object>> list=new ArrayList<Map<String, Object>>();
        for(Vrc_zgz_areaPO area : areaPO){
            if(area.getCityid().equals(cityid)){
                Map<String,Object> map =new HashMap<String,Object>();
                map.put("n", area.getAreaname());
                list.add(map);
            }
        }
        return list;
    }

 

cxselect联动下拉菜单 所需数据格式封住