省市区三级联动(ssm+vue.js+bootstrap+mysql)

忘是亡心i 2021-09-28 23:24 398阅读 0赞

1、数据库表

https://download.csdn.net/download/m0_37987151/11233695

2、xml

实体类、Dao层跳过

service、serviceImpl层

List<类名> queryByParentId(Object value);

实现方法

@Override
public List queryByParentId(Object value) {
return baseMapper.queryByParentId(value);
}

controller层

@Autowired
private 实体Service xxservice;

  1. /\*\*
  2. \* 列表
  3. \*/
  4. @RequestMapping("/queryByParentId")
  5. public R queryByParentId(String parentId)\{
  6. if(parentId==null||"".equals(parentId))\{
  7. return R.error("参数为空");
  8. \}
  9. List<CityRegionEntity> resultList=xxservice.queryByParentId(parentId);
  10. return R.ok().put("data", resultList);
  11. \}

前端

html


归属地



  

  


vue.js

var vm = new Vue({
el:’#rrapp’,
data:{
showList: true,
title: null,
dept:{
},
//区域
provinceList4: [],
cityList4: [],
areaList4: [],
region4: {
provinceCode4: ‘’,
cityCode4: ‘’,
areaCode4: ‘’
}
},

methods: {
getRegionInfo4: function (code, type, oldCode) {
$.get(baseURL + “equipment/cityregion/queryByParentId”, {parentId: code}, function (r) {
if (r && r.code == 0) {
if (type == 1) {
vm.provinceList4 = r.data;
} else if (type == 2) {
vm.cityList4 = r.data;
setTimeout(function () {
if (oldCode) {
vm.$set(vm.region4, ‘cityCode’, oldCode);
}
}, 500);
} else {
vm.areaList4 = r.data;
setTimeout(function () {
if (oldCode) {
vm.$set(vm.region4, ‘areaCode’, oldCode);
}
}, 500);
}
}
});
},
onChangeRegion4: function (ele,type) {
var val=$(ele.target).val();
if(val&&type){
this.getRegionInfo4(val,type);
}else if(type){
if(type==2){
vm.cityList4=[];
vm.areaList4=[];
}else {
vm.areaList4=[];
}
}
if (type == 2) {
vm.region4.cityCode4 = “”;
vm.region4.areaCode4 = “”;
} else {
vm.region4.areaCode4 = “”;
}

  1. \}

},

mounted: function () {
this.getRegionInfo4(0,1);
},

});

20190610152902631.pngwatermark_type_ZmFuZ3poZW5naGVpdGk_shadow_10_text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L20wXzM3OTg3MTUx_size_16_color_FFFFFF_t_70

20190610153306938.png

发表评论

表情:
评论列表 (有 0 条评论,398人围观)

还没有评论,来说两句吧...

相关阅读

    相关 ajax三级联动

    本文思路页面加载时通过ajax向后台请求省级数据,通过onchange事件,根据选择的省向后台请求市级数据,同样添加onchange事件,根据市向后台请求区级数据。 htm

    相关 python三级联动

    目前个人主要从事java开发,也想学习一下python,个人学习python初级阶段,上网找些练习题自己学习一下,在网上看了一道题目有关省市区多级菜单的题目,也附加的有代码,注