//初始化级联列表
function showCasecade(event,obj,aab301,type){
var id=$(obj).attr("id");
id=$.trim(id).substring((id.length-2),id.length);
if(id=="01"){
getCaseData(event,obj,'340000000000','1');
}else if(id=="02"){
var parentId=$("#casecade_01").attr("data-idv");
if(parentId){
getCaseData(event,obj,parentId,'2');
}else{
var mb=mbox({
title : "系统提示",
message :"请选择城市!",
onClose : function() {
return true;
}
});
setTimeout(function(){
mb.close();
},2000);
}
}else if(id=="03"){
var parentId=$("#casecade_02").attr("data-idv");
if(parentId){
getCaseData(event,obj,parentId,'3');
}else{
var mb=mbox({
title : "系统提示",
message :"请选择区县!",
onClose : function() {
return true;
}
});
setTimeout(function(){
mb.close();
},2000);
}
}
/*
if(!$("#casecade_cnt").attr("id")){
getCaseData(event,obj,'340000000000','1');
}else{
$("#casecade_cnt").slideToggle();
}*/
}
//获取列表数据
function getCaseData(e,o,aab301,type){
window.__cityData={};
window.__countyData={};
window.__streetData={};
aab301=aab301?aab301:'340000000000';
type=type?type:'1';
$.post("/ww/z/f/wwzf_choose.html?timestamp="+new Date().getTime(),{aab301:aab301,type:type},function(data){
if($("#casecade_cnt").attr("id")){
$("#casecade_cnt").remove();
}
var objs=eval("("+data+")");
var caseArray={};
if(type=='1'){
caseArray=window.__cityData=objs.list;
window.__cityData.parentId=aab301;
$("#casecade_0"+(parseInt(type)+1)).val("请选择区县");
$("#casecade_0"+(parseInt(type)+1)).attr("data-idv","");
$("#casecade_0"+(parseInt(type)+2)).val("请选择街道");
}else if(type=="2"){
caseArray=window.__countyData=objs.list;
window.__countyData.parentId=aab301;
$("#casecade_0"+(parseInt(type)+1)).val("请选择街道");
}else if(type=="3"){
caseArray=window.__streetData=objs.list;
window.__streetData.parentId=aab301;
}else if(type=="4"){
}
if(caseArray.length>0){
createCaseDiv(caseArray,o);
stopBrowserDefault(e,o);
setPositionCaseDiv(o,$("#casecade_cnt"));
}else{
$("#casecade_0"+(parseInt(type)+1)).val("请选择街道");
}
});
}
//创建列表
function createCaseDiv(datalist,o){
/*
*/
var caseCadeDiv=$("");
caseCadeDiv.attr("id","casecade_cnt");
caseCadeDiv.addClass("casecade_cnt");
var ul="";
for(var i=0;i");
if((i+1)%4==1){
li.addClass("lifirstchild");
if(i==0){
ul=$("");
ul.addClass("ulfirstchild");
}else{
ul=$("");
}
}
li.attr("data-aab301",datalist[i].aab301);
li.text(datalist[i].aab302_simple);
li.click(function(){
$(o).val($(this).text());
var _aab301=$(this).attr("data-aab301");
$("#"+$(o).attr("data-id")).val(_aab301);
$(o).attr("data-idv",_aab301);
$(o).parent().find("input").each(function(){
$(this).removeClass("openinput");
$(this).removeClass("openinputUp");
});
caseCadeDiv.slideToggle("fast");
//加载下一菜单
var type=getAcessType(_aab301);
if(type!="5"){
getCaseData(undefined,$("#casecade_0"+type)[0],_aab301,type);
}
});
ul.append(li);
if((i+1)==datalist.length){
caseCadeDiv.append(ul);
}
if((i+1)%4==0){
caseCadeDiv.append(ul);
}
}
$("body").append(caseCadeDiv);
}
//获取地址层级
function getAcessType(aab301){
//340000 00 00 00 1省 2市 3区 (县) 4街道 5社区 6(00)
//340100000000
//340101000000
var tempId=aab301;
var step=2;
var strLength=tempId.length;
var type=6;
while("00"===tempId.substring(strLength-step,strLength)){
strLength-=2;
type-=1;
}
return type;
}
//阻止事件冒泡
function stopBrowserDefault(event,obj){
if(event&&event.stopPropagation){
event.stopPropagation();
}else if(window.event&&window.event.cancelBubble){
window.event.cancelBubble = true;
}
}
//设置层级列表显示位置
function setPositionCaseDiv(o,jqObj){
var oh=o.clientHeight;
var ow=o.clientWidth;
var tH=jqObj.height();
//padding
var tW=jqObj.width()+20;
var pgW=window.screen.availWidth;
var pgH=window.screen.availHeight;
var offsetW=o.offsetLeft;
var offsetH=o.offsetTop;
var sT=$(document).scrollTop();
var _realPageH=offsetH-sT+180;
var t,l;
$(o).parent().find("input").each(function(){
$(this).removeClass("openinput");
$(this).removeClass("openinputUp");
});
if((pgW-offsetW-44)>=tW&&(pgH-_realPageH)>=tH){
t=o.offsetTop+oh+2;
l=offsetW;
$(o).addClass("openinput");
}else if((pgW-offsetW-44)=tH){
t=o.offsetTop+oh+2;
l=(offsetW+ow)-tW;
$(o).addClass("openinput");
}else if((pgW-offsetW-44)>=tW&&(pgH-_realPageH) |