ivew使用Cascader级联+后台实现三级联动

1.根据文档写出html中的代码
在这里插入图片描述
2.页面初始化加载时调用获取区域列表

Vue.http.post("../../..",
                    {}).then(function (res) {
                    let data = res.data.data;
                    self.areaList = data;
                });

3.编写后台代码按文档提供返回后端页面数据
文档示例
在这里插入图片描述
代码示例


Map resultMap = new HashMap(16);
        List<Map> returnMap = new ArrayList<Map>();
        Integer level = 1;
        List<AppCity> provinceList = appCityMapper.selectProvinceByLevel(level);
        //省份列表
        for (AppCity appCity:provinceList){
            Map provinceMap = new HashMap(16);
            provinceMap.put(ParameterConstant.VALUE,appCity.getId());
            provinceMap.put(ParameterConstant.LABEL,appCity.getName());
            provinceMap.put(ParameterConstant.CODE,appCity.getCode());
            level = 2;
            Map map = new HashMap(16);
            map.put(ParameterConstant.LEVEL,level);
            map.put(ParameterConstant.PARENT_CODE,appCity.getCode());
            List<AppCity> cityList = appCityMapper.selectCityByLevelAndCode(map);
            List<Map> queryMap = new ArrayList<Map>();
            //城市列表
            for (AppCity appCity1:cityList){
                Map cityMap = new HashMap(16);
                cityMap.put(ParameterConstant.VALUE,appCity1.getId());
                cityMap.put(ParameterConstant.LABEL,appCity1.getName());
                cityMap.put(ParameterConstant.CODE,appCity1.getCode());
                level = 3;
                Map newMap = new HashMap(16);
                newMap.put(ParameterConstant.LEVEL,level);
                newMap.put(ParameterConstant.PARENT_CODE,appCity1.getCode());
                List<AppCity> areaList = appCityMapper.selectAreaByLevelAndCode(newMap);
                List<Map> tempMap = new ArrayList<Map>();
                //区域列表
                for (AppCity appCity2:areaList){
                    Map areaMap = new HashMap(16);
                    areaMap.put(ParameterConstant.VALUE,appCity2.getId());
                    areaMap.put(ParameterConstant.LABEL,appCity2.getName());
                    areaMap.put(ParameterConstant.CODE,appCity2.getCode());
                    tempMap.add(areaMap);
                    cityMap.put("children",tempMap);
                }
                queryMap.add(cityMap);
                provinceMap.put("children",queryMap);
            }
            returnMap.add(provinceMap);
        }
        resultMap.put("cityList",returnMap);
        return BackResultUtil.success(returnMap);

4.按文档写出选中地区后的回执即文档中的format方法

format(labels, selectedData) {
                const index = labels.length - 1;
                const data = selectedData[index];
                if (data && data.code) {
                    self.formData.areaCode = data.code;//将值进行绑定用于传给后台
                    return labels[index] + ' - ' + data.code;
                }
                return labels[index];
            }
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
要搭建一个Spring Boot + iView的项目,可以按照以下步骤进行: 1. 首先,创建一个Spring Boot项目。可以使用Spring Initializer进行快速创建,选择适当的依赖,包括Spring Boot和其他需要用到的库。 2. 下载iView的相关文件,包括CSS和JavaScript等资源。可以从iView官方网站或者GitHub上找到下载链接,然后将这些资源文件保存到项目中的适当位置。 3. 在Spring Boot项目的配置文件中,配置静态资源的访问路径。可以使用Spring Boot提供的默认配置,将静态资源文件夹设置为"classpath:static",这样项目就可以访问到这些资源了。 4. 创建一个Spring MVC的Controller,处理前端请求并返回相应的数据。可以在Controller中使用@Autowired注解来注入需要的服务或组件。根据具体需求,定义不同的请求路径和方法,并编写相应的逻辑。 5. 开发前端页面,可以使用iView提供的UI组件进行页面的搭建。使用HTML、CSS和JavaScript等前端技术来编写页面,并与后端的Controller进行交互。可以通过AJAX或者其他方式向后端发送请求,并将返回的数据展示在页面上。 6. 运行项目,可以使用Maven或者Gradle等构建工具来进行项目的编译和运行。可以使用命令行或者集成开发环境来启动Spring Boot应用,并在浏览器中访问前端页面。 总之,搭建一个Spring Boot + iView的项目主要包括创建Spring Boot项目、配置静态资源、编写后端Controller、开发前端页面等步骤。关键是掌握Spring Boot和iView的相关知识,并熟悉前后端的交互方式。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值