getHwList.html
4.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
<th:block th:include="include :: header('下拉框')"/>
<th:block th:include="include :: select2-css"/>
<th:block th:include="include :: bootstrap-select-css"/>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
<form class="form-horizontal m" id="form-menu-add">
<input id="ent_name" name="ent_name" type="hidden"/>
<input id="ent_code" name="ent_code" type="hidden"/>
<input id="ent_country" name="ent_country" type="hidden"/>
<div class="form-group" id="countryDiv">
<label class="col-sm-3 control-label"><span style="color: red; ">*</span>国别:</label>
<div class="col-sm-8">
<select id="country" class="form-control m-b" required>
<option th:each="item:${countryList}" th:value="${item.jcCode}" th:text="${item.gj}"></option>
</select>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label"><span style="color: red; ">*</span>订单名称:</label>
<div class="col-sm-8">
<input id="name" type="text" placeholder="请选择订单名称" class="form-control" required>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label"></label>
<div class="col-sm-8">
<button type="button" class="btn btn-success" id="select" onclick="search()">查询</button>
<!--<button id="addEnterprise" type="button" class="btn btn-success">查询不到企业?</button>-->
</div>
</div>
<div class="col-sm-12 select-table table-striped">
<table class="table table-bordered" id="table_own">
<thead>
<tr>
<th>企业名称</th>
<th>企业状态</th>
<th>所在城市</th>
<th>企业地址</th>
<th>企业注册号</th>
<th>操作</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
</form>
</div>
<th:block th:include="include :: footer"/>
<th:block th:include="include :: select2-js"/>
<th:block th:include="include :: bootstrap-select-js"/>
<script>
let searchData = []
function search() {
var country = $("#country").val();
var name = $("#name").val();
$("#table_own tbody").html('正在查询中。。。');
if (name === '') {
$.modal.alertError("请输入企业名称")
return;
}
$.ajax({
url: '/web/monitorCompany/getEnterpraseInfo',
data: {
countryCode: country,
name: name
},
type: 'get',
dataType: 'json',
success: function (res) {
console.log(res)
$("#table_own tbody").empty();
if (res.code == '2000') {
let itemList = res.data.items;
searchData = res.data.items;
let tempList = ``
itemList.forEach((item, index) => {
let temp = `<tr>
<td>${item.name}</td>
<td>${item.status}</td>
<td>${item.city}</td>
<td>${item.postcode},${item.street},${item.county}</td>
<td>${item.creditCode}</td>
<td><button type="button" class="btn btn-warning choiceBtn" onclick="handleChoice('${index}')">请选择</button></td>
</tr>`
tempList += temp;
})
$("#table_own tbody").append(tempList);
} else {
$.modal.alertError(res.msg)
}
}
})
}
function handleChoice(index) {
console.log(index)
searchData.forEach((item, dataIndex)=> {
if (dataIndex == index) {
$("#ent_name").val(item.name);
$("#ent_code").val(item.creditCode);
$("#ent_country").val(item.country);
}
})
$(".choiceBtn").removeClass("btn-success");
$(".choiceBtn").addClass("btn-warning");
$(".choiceBtn").eq(index).addClass("btn-success");
$(".choiceBtn").eq(index).removeClass("btn-warning");
// $("#table_own tbody tr").not($("#table_own tbody tr").eq(index)).removeClass("btn-success");
// $("#table_own tbody tr").not($("#table_own tbody tr").eq(index)).addClass("btn-warning");
$(".choiceBtn").html("请选择");
$(".choiceBtn").eq(index).html("已选择");
}
</script>
</body>
</html>