二级联动+ajax
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>详情页</title>
<script src="js/jquery.min.js"></script>
<script src="js/echarts.min.js"></script>
<style>
table {
border-collapse: collapse;
margin: 100px auto;
}
td {
width: 160px;
height: 20px;
border: 1px solid #ddd;
padding: 6px 8px;
}
.a1 {
background: #878787;
color: #fff;
font-weight: bolder;
}
tr:hover {
background: #71c671;
color: #404040;
/*font-weight: bolder;*/
}
td {
text-align: center;
}
select {
width: 200px;
height: 30px;
}
</style>
</head>
<body>
<div id="fm">
类型:
<select id="type">
<option>请选择</option>
</select>
序号:
<select id="num">
<option></option>
</select>
<button id="bt" class="bt">确定</button>
</div>
<div>
<table border="1" class="table" id="tb1" style="text-align: center;">
</table>
</div>
<!--信贷利率图-->
<div id="map1" style="width: 1200px;height:650px;"></div>
<!--抵押贷利率图-->
<div id="map2" style="width: 1200px;height:650px;"></div>
<!--表格-->
<script type="text/javascript">
function show1() {
$.ajax({
type: "get",
async: false, //异步请求(同步请求将会锁住浏览器,用户其他操作必须等待请求完成才可以执行)
url: submitData(), //请求发送到TestServlet处
data: {},
dataType: "json", //返回数据形式为json
success: function (result) {
//请求成功时执行该函数内容,result即为服务器返回的json对象
var data = result.data;
if (data) {
var s = "";
s = s + " <div>\n" +
" <tr class=\"a1\">\n" +
" <td>名称</td>\n" +
" <td>" + data.name + "</td>\n" +
" <td>不动产数量</td>\n" +
" <td>" + data.home_number + "</td>\n" +
" <td>公积金总额</td>\n" +
" <td>" + data.gjj_sum + "</td>\n" +
" <td>公积金平均数</td>\n" +
" <td>" + data.gjj_avg + "</td>\n" +
" </tr>\n" +
" </div>\n" +
" <tr>\n" +
" <td>公积金为空/0的数量</td>\n" +
" <td>" + data.gjj_nan + "</td>\n" +
" <td>公积金变化趋势</td>\n" +
" <td>" + data.gjj_state + "</td>\n" +
" <td>社保总额</td>\n" +
" <td>" + data.shebao_sum + "</td>\n" +
" <td>社保平均值</td>\n" +
" <td>" + data.shebao_avg + "</td>\n" +
" </tr>\n" +
" <tr>\n" +
" <td>社保为空/0的数量</td>\n" +
" <td>" + data.shebao_nan + "</td>\n" +
" <td>社保变化趋势</td>\n" +
" <td>" + data.shebao_state + "</td>\n" +
" <td>医保总额</td>\n" +
" <td>" + data.yibao_sum + "</td>\n" +
" <td>医保平均值</td>\n" +
" <td>" + data.yibao_avg + "</td>\n" +
"\n" +
" </tr>\n" +
" <tr>\n" +
" <td>医保为空/0的数量</td>\n" +
" <td>" + data.yibao_nan + "</td>\n" +
" <td>医保变化趋势</td>\n" +
" <td>" + data.yibao_state + "</td>\n" +
" <td>公积金为空/0数量对应分数</td>\n" +
" <td>" + data.gjj_nan_score + "</td>\n" +
" <td>公积金变化趋势对应分数</td>\n" +
" <td>" + data.gjj_state_score + "</td>\n" +
" </tr>\n" +
" <tr>\n" +
" <td>社保为空/0数量对应分数</td>\n" +
" <td>" + data.shebao_nan_score + "</td>\n" +
" <td>社保变化趋势对应分数</td>\n" +
" <td>" + data.shebao_state_score + "</td>\n" +
" <td>医保为空/0数量对应分数</td>\n" +
" <td>" + data.yibao_nan_score + "</td>\n" +
" <td>医保变化趋势对应分数</td>\n" +
" <td>" + data.yibao_state_score + "</td>\n" +
"\n" +
" </tr>\n" +
" <tr>\n" +
" <td>公积金总额对应分数</td>\n" +
" <td>" + data.gjj_sum_score + "</td>\n" +
" <td>公积金平均值对应分数</td>\n" +
" <td>" + data.gjj_avg_score + "</td>\n" +
" <td>社保总额对应分数</td>\n" +
" <td>" + data.shebao_sum_score + "</td>\n" +
" <td>社保平均值对应分数</td>\n" +
" <td>" + data.shebao_avg_score + "</td>\n" +
"\n" +
" </tr>\n" +
" <tr>\n" +
" <td>不动产数量对应分数</td>\n" +
" <td>" + data.home_number_score + "</td>\n" +
" <td>还款意愿分数</td>\n" +
" <td>" + data.desire_score + "</td>\n" +
" <td>还款能力分数</td>\n" +
" <td>" + data.ability_score + "</td>\n" +
" <td>还款意愿能力总分数</td>\n" +
" <td>" + data.score + "</td>\n" +
"\n" +
" </tr>\n" +
" <tr>\n" +
" <td>违约率</td>\n" +
" <td>" + data.defualt_rate + "</td>\n" +
" <td>信用分数</td>\n" +
" <td>" + data.credit_score + "</td>\n" +
" <td>信用等级</td>\n" +
" <td>" + data.credit_grade + "</td>\n" +
" <td>授信率</td>\n" +
" <td>" + data.credit_rate + "</td>\n" +
" </tr>\n" +
" <tr>\n" +
" <td>信贷额度</td>\n" +
" <td>" + data.credit_loan_amount + "</td>\n" +
" <td>抵押贷额度</td>\n" +
" <td>" + data.mortgage_loan_amount + "</td>\n" +
" <td>医保总额对应分数</td>\n" +
" <td>" + data.yibao_sum_score + "</td>\n" +
" <td>医保平均值对应分数</td>\n" +
" <td>" + data.yibao_avg_score + "</td>\n" +
" </tr>";
$('#tb1').html(s)
}
}
})
}
</script>
<!--信贷利率图-->
<script type="text/javascript">
function show2() {
// 基于准备好的dom,初始化echarts实例
var myChart = echarts.init(document.getElementById('map1'));
// 指定图表的配置项和数据
myChart.setOption({
title: {
text: '信贷利率'
},
tooltip: {},
legend: {
data: ['信贷利率']
},
xAxis: {
data: []
},
yAxis: {},
series: [{
name: '信贷利率',
type: 'bar',
data: []
}]
});
myChart.showLoading();
var names = []; //类别数组(实际用来盛放X轴坐标值)
var nums = []; //销量数组(实际用来盛放Y坐标值)
$.ajax({
type: "get",
async: false, //异步请求(同步请求将会锁住浏览器,用户其他操作必须等待请求完成才可以执行)
url: submitData(), //请求发送到TestServlet处
data: {},
dataType: "json", //返回数据形式为json
success: function (result) {
//请求成功时执行该函数内容,result即为服务器返回的json对象
var data = result.data;
if (data) {
for (var i = 0; i < data.xd.length; i++) {
names.push(i); //挨个取出类别并填入类别数组
}
nums = data.xd;
myChart.hideLoading(); //隐藏加载动画
myChart.setOption({ //加载数据图表
xAxis: {
data: names
},
series: [{
// 根据名字对应到相应的系列
name: '信贷利率',
data: nums
}]
});
}
},
error: function () {
//请求失败时执行该函数
alert("图表请求数据失败!");
myChart.hideLoading();
}
})
}
</script>
<!--抵押贷利率图-->
<script type="text/javascript">
function show3() {
// 基于准备好的dom,初始化echarts实例
var myChart = echarts.init(document.getElementById('map2'));
// 指定图表的配置项和数据
myChart.setOption({
title: {
text: '抵押贷利率'
},
tooltip: {},
legend: {
data: ['抵押贷利率']
},
xAxis: {
data: []
},
yAxis: {},
series: [{
name: '抵押贷利率',
type: 'bar',
itemStyle: {
normal: {
color: "red",
lineStyle: {color: 'red'}
}
},
data: []
}]
});
myChart.showLoading();
var names = []; //类别数组(实际用来盛放X轴坐标值)
var nums = []; //销量数组(实际用来盛放Y坐标值)
$.ajax({
type: "get",
async: false, //异步请求(同步请求将会锁住浏览器,用户其他操作必须等待请求完成才可以执行)
url: submitData(), //请求发送到TestServlet处
data: {},
dataType: "json", //返回数据形式为json
success: function (result) {
//请求成功时执行该函数内容,result即为服务器返回的json对象
var data = result.data;
if (data) {
for (var i = 0; i < data.dyd.length; i++) {
names.push(i); //挨个取出类别并填入类别数组
}
nums = data.dyd;
myChart.hideLoading(); //隐藏加载动画
myChart.setOption({ //加载数据图表
xAxis: {
data: names
},
series: [{
// 根据名字对应到相应的系列
name: '抵押贷利率',
data: nums
}]
});
}
},
error: function () {
//请求失败时执行该函数
alert("图表请求数据失败!");
myChart.hideLoading();
}
})
}
</script>
<script type="text/javascript">
var bt=document.getElementById('bt')
bt.addEventListener("click",show1);
bt.addEventListener("click",show2);
bt.addEventListener("click",show3);
</script>
<!--select-->
<script type="text/javascript">
var typeSelect = document.querySelector("#type");
var numSelect = document.querySelector("#num");
//构建数组
var typeArr = ["qiye", "renyuan"];
var numArr = [[], []];
var typeIdenx = 0;
for (let i = 0; i < 267; i++) {
numArr[0].push(i)
}
for (let i = 0; i < 900; i++) {
numArr[1].push(i)
}
//页面加载的时候根据类型数据源添加类型option
for (var i = 0; i < typeArr.length; i++) {
var typeOption = new Option([typeArr[i]]);
typeSelect.options.add(typeOption);
}
//当类型做出change的时候出发change事件
typeSelect.onchange = function (eve) {
typeIdenx = eve.target.selectedIndex - 1;
if (typeIdenx == -1) {
numSelect.options.length = 0;
return;
} else {
numSelect.options.length = 0;
for (var j = 0; j < numArr[typeIdenx].length; j++) {
var numOption = new Option(numArr[typeIdenx][j]);
numSelect.options.add(numOption);
}
}
}
</script>
<script type="text/javascript">
function submitData() {
var type = document.getElementById("type").value;
var num = document.getElementById("num").value;
if (type == "") {
alert("类型不能为空");
return "qiye/0";
}
if (num == "") {
alert("序号不能为空")
return "qiye/0";
}
return ""+type+"/"+num;
}
</script>
</body>
</html>
`application.properties`
server.port=80
spring.web.resources.static-locations=classpath:/META-INF/resources/,classpath:/resources/,classpath:/static/,classpath:/public/,classpath:/templates/
spring.devtools.add-properties=false
logging.level.web=error