| | |
| | | * 打开区域选择页面新增 |
| | | */ |
| | | TDriver.areaAdd = function () { |
| | | |
| | | var area = $("#area").val(); |
| | | var areaId = $("#areaId").val(); |
| | | var index = layer.open({ |
| | | type: 2, |
| | | title: '区域选择', |
| | | area: ['1000px', '270px'], //宽高 |
| | | fix: false, //不固定 |
| | | maxmin: true, |
| | | content: Feng.ctxPath + '/tDriver/areaPageAdd' |
| | | content: Feng.ctxPath + '/tDriver/areaPageAdd?area='+area+'&areaId='+areaId |
| | | }); |
| | | this.layerIndex = index; |
| | | } |
| | |
| | | * 查询市 |
| | | */ |
| | | TDriver.areaCity = function () { |
| | | var province = document.getElementById('province'); |
| | | //监听第一个下拉菜单的变动操作 |
| | | $("#province").change(function(){ |
| | | //当第一级下拉列表没选择值时,将二级下拉列表和三级同时设置为空 |
| | | if(this.value==""){ |
| | | $("#city").empty();//二级联动设为空设为空 |
| | | $("#city").append('<option value="">请选择</option>'); |
| | | //region |
| | | $("#district").empty();//三级联动设为空设为空 |
| | | $("#district").append('<option value="">请选择</option>'); |
| | | |
| | | } |
| | | if(this.value!=""){//第一级下拉菜单选择了值 |
| | | $("#city").empty();//先行置空,防止上次选择留下的元素影响效果 |
| | | $("#city").append('<option value="">请选择</option>')//设置初始选项 |
| | | $("#district").empty();//三级联动设为空设为空 |
| | | $("#district").append('<option value="">请选择</option>'); |
| | | var province = document.getElementById('province'); |
| | | var index= province.selectedIndex ; |
| | | var id = province.options[index].id; |
| | | var ajax = new $ax(Feng.ctxPath + "/tDriver/areaCity?parentId="+id, function (data) { |
| | | for(var i=0,n=data.length;i<n;i++){//遍历 |
| | | $("#city").append('<option value="'+data[i].id+'">'+data[i].name+'</option>');//创造元素 |
| | | } |
| | | }, function (data) { |
| | | Feng.error("查询失败!" + data.responseJSON.message + "!"); |
| | | }); |
| | | ajax.start(); |
| | | } |
| | | }); |
| | | /*var province = document.getElementById('province'); |
| | | var index= province.selectedIndex ; |
| | | var id = province.options[index].id; |
| | | var ajax = new $ax(Feng.ctxPath + "/tDriver/areaCity?parentId="+id, function (data) { |
| | |
| | | }, function (data) { |
| | | Feng.error("查询失败!" + data.responseJSON.message + "!"); |
| | | }); |
| | | ajax.start(); |
| | | ajax.start();*/ |
| | | } |
| | | |
| | | /** |
| | | * 查询区 |
| | | */ |
| | | TDriver.areaDistrict = function () { |
| | | var city = document.getElementById('city'); |
| | | |
| | | //监听第二个下拉菜单的变动操作 |
| | | $("#city").change(function(){ |
| | | if(this.value==""){//第二级菜单为空,则将第三级菜单也置为空 |
| | | $("#district").empty(); |
| | | $("#district").append('<option value="">请选择</option>'); |
| | | } |
| | | if(this.value!=""){//第二级菜单不为空,则将第三级菜单动态生成 |
| | | $("#district").empty(); |
| | | $("#district").append('<option value="">请选择</option>'); |
| | | |
| | | var city = document.getElementById('city'); |
| | | var cityIndex= city.selectedIndex ; |
| | | var id = city.options[cityIndex].id; |
| | | if(id == ""){ |
| | | id = city.options[cityIndex].value; |
| | | } |
| | | var ajax = new $ax(Feng.ctxPath + "/tDriver/areaCity?parentId="+id, function (data) { |
| | | for(var i=0,n=data.length;i<n;i++){//对区数据进行遍历,动态生成 |
| | | $("#district").append('<option value="'+data[i].id+'">'+data[i].name+'</option>'); |
| | | } |
| | | }, function (data) { |
| | | Feng.error("查询失败!" + data.responseJSON.message + "!"); |
| | | }); |
| | | ajax.start(); |
| | | } |
| | | }) |
| | | |
| | | /*var city = document.getElementById('city'); |
| | | var cityIndex= city.selectedIndex ; |
| | | var id = city.options[cityIndex].value; |
| | | var ajax = new $ax(Feng.ctxPath + "/tDriver/areaCity?parentId="+id, function (data) { |
| | |
| | | }, function (data) { |
| | | Feng.error("查询失败!" + data.responseJSON.message + "!"); |
| | | }); |
| | | ajax.start(); |
| | | ajax.start();*/ |
| | | } |
| | | |
| | | /** |
| | |
| | | var provinceName = province.options[provinceIndex].value; |
| | | var provinceId = province.options[provinceIndex].id; |
| | | |
| | | if(provinceName == null || provinceName == ''){ |
| | | Feng.error("请选择省份!") |
| | | return; |
| | | } |
| | | |
| | | var city = document.getElementById('city'); |
| | | var cityIndex= city.selectedIndex ; |
| | | var cityId = city.options[cityIndex].value; |
| | | var cityName = city.options[cityIndex].innerText; |
| | | |
| | | if(cityName == null || cityName == '' || cityName =='请选择'){ |
| | | Feng.error("请选择市区!") |
| | | return; |
| | | } |
| | | |
| | | var district = document.getElementById('district'); |
| | | var districtIndex= district.selectedIndex ; |
| | | var districtId = district.options[districtIndex].value; |
| | | var districtName = district.options[districtIndex].innerText; |
| | | |
| | | if(districtName == null || districtName == '' || districtName =='请选择'){ |
| | | Feng.error("请选择区县!") |
| | | return; |
| | | } |
| | | |
| | | parent.$("#area").val(provinceName+'/'+cityName+'/'+districtName) |
| | | parent.$("#areaId").val(provinceId+'/'+cityId+'/'+districtId) |
| | | console.log() |
| | | TDriverInfoDlg.close(); |
| | | } |
| | | |