<%@ page language="java" import="java.util.*" pageEncoding="UTF-8" %>
|
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
|
<%
|
String path = request.getContextPath();
|
String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
|
+ path + "/";
|
%>
|
<html>
|
<head>
|
<base href="<%=basePath%>">
|
<meta name="viewport" charset="width=device-width, initial-scale=1.0">
|
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
<title>选择行政区</title>
|
<link href="static/plugins/font-awesome/css/font-awesome.css" rel="stylesheet" type="text/css">
|
<link href="static/plugins/jquery-easyui/themes/bootstrap/easyui.css" rel="stylesheet" type="text/css">
|
<link rel="stylesheet" href="static/styles/initialize.css" type="text/css">
|
<link rel="stylesheet" href="static/styles/common.css" type="text/css">
|
<link rel="stylesheet" href="static/plugins/layer/skin/default/layer.css" type="text/css">
|
|
<script type="text/javascript" src="static/plugins/jquery/jquery.min.js"></script>
|
<script type="text/javascript" src="static/plugins/jquery-easyui/jquery.easyui.min.js"></script>
|
<script type="text/javascript" src="static/plugins/jquery-easyui/locale/easyui-lang-zh_CN.js"></script>
|
<script type="text/javascript" src="static/scripts/easyuiExtend.js"></script>
|
<script type="text/javascript" src="static/scripts/jquery-extend.js"></script>
|
<script type="text/javascript" src="static/plugins/layer/layer.js"></script>
|
<script type="text/javascript" src="static/plugins/slimScroll/jquery.slimscroll.min.js"></script>
|
<script type="text/javascript" src="static/plugins/jquery-easyui-datagrid-dnd/datagrid-dnd.js"></script>
|
<script src="static/plugins/ace/src-noconflict/ace.js" type="text/javascript"></script>
|
<script src="static/plugins/jquery.redirect.js" type="text/javascript"></script>
|
|
<!-- 弹窗加载组件 -->
|
<script type="text/javascript" src="static/plugins/layer/layer.js"></script>
|
<script type="text/javascript" src="static/plugins/spinjs/spin.js"></script>
|
<script type="text/javascript" src="static/plugins/spinjs/jquery.spin.js"></script>
|
<script type="text/javascript" src="static/plugins/jquery.blockUI.js"></script>
|
<!-- wcp组件 -->
|
<script type="text/javascript" src="static/wcp/scripts/wcp.js"></script>
|
<script type="text/javascript" src="static/wcp/scripts/libs/wcp.layer.js"></script>
|
<script type="text/javascript" src="static/wcp/scripts/libs/wcp.blockUI.js"></script>
|
<script type="text/javascript" src="static/wcp/scripts/libs/wcp.spin.js"></script>
|
<script type="text/javascript" src="static/wcp/scripts/libs/wcp.jquery.js"></script>
|
|
<!--[if lt IE 9]>
|
<script type="text/javascript" src="static/plugins/json2.js"></script>
|
<![endif]-->
|
<script type="text/javascript" src="static/wcp/scripts/libs/wcp.infoPicker.js"></script>
|
<script type="text/javascript" src="static/scripts/ResizeScroll.js"></script>
|
<style>
|
html, body {
|
height: 100%;
|
}
|
|
.container {
|
width: 100%;
|
height: 100%;
|
padding: 10px;
|
}
|
|
.left {
|
width: 20%;
|
float: left;
|
text-align: center;
|
padding-top: 10px;
|
}
|
|
.middle1 {
|
width: 25%;
|
float: left;
|
text-align: center;
|
padding-top: 10px;
|
}
|
|
.middle2 {
|
width: 22%;
|
float: left;
|
text-align: center;
|
padding-top: 10px;
|
}
|
|
.right {
|
width: 30%;
|
float: left;
|
text-align: center;
|
padding-top: 10px;
|
}
|
|
.folder {
|
font-size: 18px;
|
font-weight: bold;
|
color: #3c8dbc;
|
float: left;
|
padding-left: 16px;
|
}
|
|
.delText {
|
font-size: 18px;
|
font-weight: bold;
|
color: red;
|
float: right;
|
padding-right: 16px;
|
}
|
|
.deleteAll {
|
font-size: 18px;
|
font-weight: bold;
|
color: red;
|
float: right;
|
padding-right: 16px;
|
}
|
|
.form-group {
|
float: right;
|
padding-right: 80px;
|
}
|
</style>
|
|
</head>
|
<body>
|
<div>
|
<div class="left">
|
<div class="easyui-panel pt-tree" style="border-right: none;height: 440px">
|
<ul id="ul_province"></ul>
|
</div>
|
</div>
|
<div class="middle1">
|
<div class="easyui-panel pt-tree" style="border-right: none;height: 440px">
|
<ul id="ul_city"></ul>
|
</div>
|
</div>
|
<div class="middle2">
|
<div class="easyui-panel pt-tree" style="border-right: none;height: 440px">
|
<ul id="ul_district"></ul>
|
</div>
|
</div>
|
<div class="right">
|
<div class="easyui-panel pt-tree" style="border-right: none;height: 440px">
|
<ul id="dg_hasSelect"></ul>
|
</div>
|
</div>
|
<div class="pt-form-btn">
|
<button type="button" class="pt-btn pt-btn-primary" onclick="doSave();">确定</button>
|
<button type="reset" class="pt-btn pt-btn-default" onclick="doClose();">关闭</button>
|
<button type="button" class="pt-btn pt-btn-danger" onclick="delAll();">删除全部</button>
|
</div>
|
</div>
|
</div>
|
</body>
|
<script>
|
var params = {
|
callBack : null,
|
haveSelected : ""
|
};
|
$(function(){
|
bindProvinceTree();
|
//绑定已选择项,前端js传参数,必须加延迟,否则传参易丢失
|
setTimeout(function () {
|
bindHasSelect(params.haveSelected);
|
}, 500);
|
});
|
var sheng;
|
var Shi;
|
var Xian;
|
var count;
|
//绑定省
|
function bindProvinceTree(){
|
$.ajax({
|
type: "GET",
|
url: "static/scripts/gdmis/XZQ.xml",
|
dataType: "xml",
|
success: function(xml) {
|
var type = [];
|
$(xml).find("Province").each(function() { //遍历国家那一级
|
var cityName = $(this).attr("Name");//读取节点属性
|
var cityCode = $(this).attr("Code");
|
type.push({
|
id: cityCode,
|
text: cityName,
|
iconCls: 'fa fa-database'
|
});
|
});
|
$("#ul_province").tree({
|
data:type,
|
animate: true,
|
cascadeCheck: false,
|
checkbox: false,
|
onLoadSuccess: function (node, data) {
|
wcp.ui.clearBusy("#ul_province");
|
var n = $('#ul_province').tree('find', data[0].id);
|
if (n != null) {
|
$("#ul_province li:eq(0)").find("div").addClass("tree-node-selected"); //设置第一个节点高亮
|
//bindSubType(data[0].id);
|
}
|
new ResizeScroll({
|
"id": "#ul_province",
|
"height": "400"
|
});
|
},
|
onClick: function (node) {
|
$("#ul_district li").remove();
|
bindCityTree(node);
|
sheng = node.text;
|
},
|
onDblClick:function(node){
|
var hasRows = $('#dg_hasSelect').datagrid("getRows");
|
var exist=false;
|
var selCity = node.text;
|
$.each(hasRows, function (index, row) {
|
if(selCity==row.id){
|
exist=true;
|
}
|
});
|
if(!exist){
|
//已选项追加
|
$('#dg_hasSelect').datagrid("appendRow", {
|
id: selCity,
|
name: selCity
|
});
|
}else{
|
top.wcp.notify.error(selCity+"已选择,请勿重复选!");
|
}
|
}
|
});
|
},
|
});
|
}
|
//绑定市、区
|
function bindCityTree(sonNode){
|
var code = sonNode.id;
|
var count = 0;
|
$.ajax({
|
type: "GET",
|
url: "static/scripts/gdmis/XZQ.xml",
|
dataType: "xml",
|
success: function (xml) {
|
var subType = [];
|
var codeSub = code.substring(0, 2);
|
$(xml).find("City").each(function () {
|
var cityName = $(this).attr("Name");//读取节点属性
|
var cityCode = $(this).attr("Code");
|
var sonCode = cityCode.toString().substring(0, 2);
|
if (code == 'W00000') {
|
var abroadCode = cityCode.toString().substring(0, 1);
|
if (abroadCode == 'W') {
|
subType.push({
|
id: cityCode,
|
text: cityName,
|
iconCls: 'fa fa-database'
|
});
|
count ++ ;
|
}
|
}
|
else{
|
if(code != "000000") {
|
if (codeSub == sonCode) {
|
subType.push({
|
id: cityCode,
|
text: cityName,
|
iconCls: 'fa fa-database'
|
});
|
count ++ ;
|
}
|
}
|
}
|
});
|
//如果没有下级,则把选择的放入待选框
|
if(count == 0){
|
var hasRows = $('#dg_hasSelect').datagrid("getRows");
|
var exist=false;
|
$.each(hasRows, function (index, row) {
|
if(sonNode.text==row.id){
|
exist=true;
|
}
|
});
|
if(!exist){
|
//已选项追加
|
$('#dg_hasSelect').datagrid("appendRow", {
|
id: sonNode.text,
|
name: sonNode.text
|
});
|
}else{
|
top.wcp.notify.error(sonNode.text+"已选择,请勿重复选!");
|
}
|
}
|
$("#ul_city").tree({
|
data:subType,
|
animate: true,
|
cascadeCheck: false,
|
checkbox: false,
|
onLoadSuccess: function (node, data) {
|
wcp.ui.clearBusy("#ul_city");
|
new ResizeScroll({
|
"id": "#ul_city",
|
"height": "425"
|
});
|
},
|
onClick: function (node) {
|
bindDistrictTree(node);
|
shi = node.text;
|
},
|
onDblClick:function(node){
|
var hasRows = $('#dg_hasSelect').datagrid("getRows");
|
var exist=false;
|
var selCity = sheng + " " + node.text;
|
$.each(hasRows, function (index, row) {
|
if(selCity==row.id){
|
exist=true;
|
}
|
});
|
if(!exist){
|
//已选项追加
|
$('#dg_hasSelect').datagrid("appendRow", {
|
id: selCity,
|
name: selCity
|
});
|
}else{
|
top.wcp.notify.error(selCity+"已选择,请勿重复选!");
|
}
|
}
|
});
|
}
|
|
});
|
}
|
//绑定县
|
function bindDistrictTree(sonSCode){
|
var sonCode = sonSCode.id;
|
var count = 0;
|
$.ajax({
|
type: "GET",
|
url: "static/scripts/gdmis/XZQ.xml",
|
dataType: "xml",
|
success: function (xml) {
|
var codeSub = sonCode.substring(0, 4);
|
var abroadCode = sonCode.substring(0, 2);
|
var subType = [];
|
$(xml).find("District").each(function () {
|
var cityName = $(this).attr("Name");//读取节点属性
|
var cityCode = $(this).attr("Code");
|
var secondCode = cityCode.toString().substring(0, 4);
|
var abroad = cityCode.toString().substring(0, 2);
|
var sea;
|
if (codeSub == 5001) {
|
if (codeSub == secondCode || secondCode == 5002) {
|
subType.push({
|
id: cityCode,
|
text: cityName,
|
iconCls: 'fa fa-star'
|
});
|
count ++;
|
}
|
}
|
else if (codeSub == 6543) {
|
if (codeSub == secondCode || secondCode == 6590) {
|
subType.push({
|
id: cityCode,
|
text: cityName,
|
iconCls: 'fa fa-star'
|
});
|
count ++;
|
}
|
}
|
else if (sonCode == '00H490') {
|
sea = cityCode.toString().substring(0, 5);
|
if (sea == '00H49') {
|
subType.push({
|
id: cityCode,
|
text: cityName,
|
iconCls: 'fa fa-star'
|
});
|
count ++;
|
}
|
}
|
else if (sonCode == '00H500') {
|
sea = cityCode.toString().substring(0, 5);
|
if (sea == '00H50') {
|
subType.push({
|
id: cityCode,
|
text: cityName,
|
iconCls: 'fa fa-star'
|
});
|
count ++;
|
}
|
}
|
else if (sonCode == '00H510') {
|
}
|
else if (sonCode == '00H51A') {
|
sea = cityCode.toString().substring(0, 5);
|
if (sea == '00H51') {
|
subType.push({
|
id: cityCode,
|
text: cityName,
|
iconCls: 'fa fa-star'
|
});
|
count ++;
|
}
|
}
|
else if (sonCode == '00H520') {
|
}
|
else if (sonCode.substring(0, 1) == "W") { //境外
|
if (abroadCode == abroad) {
|
subType.push({
|
id: cityCode,
|
text: cityName,
|
iconCls: 'fa fa-star'
|
});
|
count ++;
|
}
|
}
|
else {
|
if (codeSub == secondCode) {
|
subType.push({
|
id: cityCode,
|
text: cityName,
|
iconCls: 'fa fa-star'
|
});
|
}
|
count ++;
|
}
|
});
|
//如果没有下级,则把选择的放入待选框
|
if(count == 0){
|
var hasRows = $('#dg_hasSelect').datagrid("getRows");
|
var exist=false;
|
var selCity = sheng + " " + sonSCode.text;
|
$.each(hasRows, function (index, row) {
|
if(selCity==row.id){
|
exist=true;
|
}
|
});
|
if(!exist){
|
//已选项追加
|
$('#dg_hasSelect').datagrid("appendRow", {
|
id: selCity,
|
name: selCity
|
});
|
}else{
|
top.wcp.notify.error(selCity+"已选择,请勿重复选!");
|
}
|
}
|
$("#ul_district").tree({
|
data:subType,
|
animate: true,
|
cascadeCheck: false,
|
checkbox: false,
|
onLoadSuccess: function (node, data) {
|
wcp.ui.clearBusy("#ul_district");
|
new ResizeScroll({
|
"id": "#ul_district",
|
"height": "425"
|
});
|
},
|
onClick: function (node) {
|
xian = node.text;
|
var hasRows = $('#dg_hasSelect').datagrid("getRows");
|
var exist=false;
|
var city = sheng + " " + shi + " " + xian;
|
$.each(hasRows, function (index, row) {
|
if(city==row.id){
|
exist=true;
|
}
|
});
|
if(!exist){
|
//已选项追加
|
$('#dg_hasSelect').datagrid("appendRow", {
|
id: city,
|
name: city
|
});
|
}else{
|
top.wcp.notify.error(city+"已选择,请勿重复选!");
|
}
|
}
|
});
|
}
|
});
|
}
|
//绑定已选择项
|
function bindHasSelect(selectedCity){
|
$('#dg_hasSelect').datagrid({
|
fitColumns: true,
|
nowrap: true,
|
rownumbers: true,
|
height: 438,
|
idField: "id",
|
emptyMsg: "没有找到匹配的记录",
|
toolbar: "#hasToolbar",
|
columns: [[
|
{
|
field: 'name',
|
title: '名称',
|
width: 400
|
},
|
{
|
field: 'id',
|
title: '操作',
|
width: 100,
|
align: 'center',
|
formatter: function (value, row, index) {
|
return '<a href="javascript:void(0)" onclick="delSelectedRow(' + index + ');" class="pt-color-danger">删除</a>';
|
}
|
}
|
|
]],
|
onLoadSuccess: function () {
|
new ResizeScroll({
|
"id": "#dg_hasSelect",
|
"height": "380"
|
});
|
}
|
});
|
if(selectedCity!=undefined&&selectedCity !=""){
|
var haveSelectedMinerals = selectedCity.split(',');
|
$.each(haveSelectedMinerals, function (index, haveSelectedMineral) {
|
$('#dg_hasSelect').datagrid("appendRow", {
|
id: haveSelectedMineral,
|
name: haveSelectedMineral
|
});
|
});
|
}
|
}
|
function doClose() { //关闭按钮事件
|
var index = top.layer.getFrameIndex(window.name); //获取窗口索引
|
top.layer.close(index);
|
}
|
function doSave() {
|
var selectCity = "";
|
var hasRows = $('#dg_hasSelect').datagrid("getRows");
|
var exist=false;
|
$.each(hasRows, function (index, row) {
|
selectCity+=row.name+",";
|
});
|
if(selectCity != ""){
|
selectCity = selectCity.substring(0, selectCity.length - 1).trim();
|
}
|
if (params.callBack) {
|
params.callBack(selectCity);
|
}
|
doClose();
|
}
|
//删除所有
|
function delAll(){
|
$('#dg_hasSelect').datagrid("loadData", []);
|
}
|
function delSelectedRow(index) {
|
$("#dg_hasSelect").datagrid('deleteRow', index);
|
//刷新已选区,重新生成行号,不然会出错
|
var hasRows = $('#dg_hasSelect').datagrid("getRows");
|
for (var i = 0; i < hasRows.length; i++) {
|
$("#dg_hasSelect").datagrid('refreshRow', i);
|
}
|
}
|
</script>
|
</html>
|