都市、郡、村の4つのカスケード(MINIUIによって実現)

一、前端面面现
<fieldset class = "layui-elem-field">
<legend>行政区划信息</ legend>
<div class = "layui-field-box" id = "xzqhxx">
<table style = "width :99.5%; ">
<tr class =" table_tr ">
<td class =" table_td_label "align =" right ">市(省管县)</ td>
<td class =" table_td_input ">
<input id =" city "name =" city "class =" mini-combobox "width =" 95% "textField =" name "valueField =" id "enabled =" false "showNullItem =" true "nullItemText ="请选择 "
onvaluechanged ="
</ td>
<td class =" table_td_label "align =" right ">县(区)</ td>
<td class =" table_td_input ">
<input id = "county" name = "county" class = "mini-combobox" textField = "name" valueField = "id" width = "95%" showNullItem = "true" nullItemText = "请选择"
onvaluechanged = "onCountyChanged "/>
</ td>
<td class =" table_td_label "align =" right ">乡镇(街道)</ td>
<td class =" table_td_input ">
<input id =" country "name =" country "class = "mini-combobox" textField = "name" valueField = "id" width = "95%" showNullItem = "true" nullItemText = "请选择"
onvaluechanged = "onCountryChanged" />
<span class = "red_star"> * </ span>
</ td>
<td class = "table_td_label" align = "right">村(社区)</ td>
<td class = "table_td_input">
<input id = "village" name = "village" class = "mini-combobox" textField = "name" valueField = "id" width = "95%" showNullItem = "true" nullItemText = "请选择"
onvaluechanged = "onVillageChanged" required = "true" />
<span class = "red_star"> * </ span>
</ td>
</ tr>
<tr>
<td class = "table_td_label" align = "右 ">组</ td>
<td class =" table_td_input ">
<input id =" group "name = "group" class = "mini-combobox" textField = "name" showNullItem = "true" nullItemText = "请选择"
valueField = "id" width = "95%" />
</ td>
data、citybm); city.select(index);


















var id = city.getValue();
onCityChanged(id);
});
//选中市
関数onCityChanged(e){
if( "1" == sgxflag){
var id = city.getValue();
county.setValue( "");
url = "$ {basePath} / jmggyw / common / querySxxc?id =" + id;
county.setUrl(url);
if(countybm == "" || countybm == null){
county.select(0);
} else {
var index = getMapSubscript(county.data、countybm);
county.select(index);
mini.get( "county")。setEnabled(false);
}
var id = county.getValue();
onCountyChanged(id);
} else {
var id = city.getValue();
country.setValue( "");
url = "$ {basePath} / jmggyw / common / querySxxc?id =" + id;
country.setUrl(url);
if(countybm == "" || countybm == null){country.select
(0);
} else {
var index = getMapSubscript(country.data、countrybm);
country.select(index);
mini.get( "county")。setEnabled(false);
}
var id = country.getValue();
onCountryChanged_sgx(id);
}
if(sbjandqx == "1"){ //省管县比正常的少一级
url = "$ {basePath} / jmggyw / common / querySbjandQx?id =" + id;
county.setValue( "");
county.setUrl(url);
county.setEnabled(true);
}
};

//乡
function onCountryChanged_sgx(e){
デバッガ;
var id = country.getValue();
var text = country.getText();
village.setValue( "");
url = "$ {basePath} / jmggyw / common / querySxxc?id =" + id;
village.setUrl(url);
if(villagebm == "" || villagebm == null){
if( "大中专院校" == text){village.select
(1);
} else {
村。select(0);
}
} else {
var index = getMapSubscript(village.data、villagebm);
village.select(index);
village.setEnabled(false);
}
var id = village.getValue();
onVillageChanged(id);
};

//选中县
function onCountyChanged(e){
var id = county.getValue();
country.setValue( "");
url = "$ {basePath} / jmggyw / common / querySxxc?id =" + id;
country.setUrl(url);
if(countrybm == "" || countrybm == null){country.select
(0);
} else {
var index = getMapSubscript(country.data、countrybm);
country.select(index);
mini.get( "country")。setEnabled(false);
}
var id = country.getValue();
onCountryChanged(id);
};

//乡
function onCountryChanged(e){
var id = country.getValue ();
village.setValue( "");
url = "$ {basePath} / jmggyw / common / querySxxc?id =" + id;
village.setUrl(url);
if(villagebm == "" || villagebm == null){
village.select(0);
} else {
var index = getMapSubscript(village.data、villagebm);
village.select(index);
mini.get( "village")。setEnabled(false);
}
var id = village。
onVillageChanged(id);
};

// Village
関数onVillageChanged(e){
var id =
village.getValue(); group.setValue( "");
url = "$ {basePath} / jmggyw / common / querySxxc?id =" + id;
group.setUrl(url);
group.select(0);
};
//添え字
関数を取得getMapSubscript(map、value){
//添え字を取得 var
index = 0;
for(var i = 0; i <map.length; i ++){
if(value ==(map [i])。id){
index = i;
}
}
return index;
};

2番目に、バックグラウンドデータの取得(抽出のためにMAPに配置)
/ ** 
*下位の行政区画コードを取得
* @param
* @return
* /
public List <Map <String、Object >> querySxxc(String id){
StringBuffer sql = new StringBuffer();
sql.append( "select AAB301 id、
-行政区分コード\ n "); sql.append(" AAE044 name --Name \ n ");
sql.append(" from AB51 \ n ");
sql.append(" where BAE024 =?Order by AAB301 \ n ");
return DBUtils.query(sql.toString()、id);
}

備考:
<input id = "group" name = "group" class = "mini-combobox" textField = "name" showNullItem = "true" nullItemText = "Please select" 
valueField = "id" width = "95%" />
ドロップダウンミニコンボボックスを介して実現されますが、欠点と利点があります。欠点は、連想クエリを実現できないことです。利点は、IDが異なり、名前が同じ場合、名前を選択してIDを取得することです。
達成するミニcomselectの欠点と利点があります。利点は関連クエリを実現できます。欠点は、IDが異なる場合、名前が同じであり、同じ名前が選択されたときに最初のID値が常に取得されることです。

おすすめ

転載: www.cnblogs.com/xiaoyuer1229/p/12689919.html