311 lines
9.4 KiB
Plaintext
311 lines
9.4 KiB
Plaintext
|
|
@{
|
|
ViewData["Title"] = "Yuntech_in_car";
|
|
Layout = "~/Views/Shared/_Layout_Manager.cshtml";
|
|
}
|
|
|
|
<h1>進入車輛</h1>
|
|
|
|
|
|
<div class="size2">
|
|
起始時間 : <input type="date" id="start_date_id">
|
|
結束時間 : <input type="date" id="end_date_id">
|
|
<button style="height:30px; " class="btn btn-outline-secondary" onclick="serch_date_click()">搜尋</button>
|
|
|
|
<button style="height:30px;float:right " class="btn btn-outline-secondary" onclick="serch_click()">搜尋</button>
|
|
<input type="text" style="float:right" placeholder="請輸入車牌 ex:ABC4321" id="serch_text_id" />
|
|
<table class="table">
|
|
<thead>
|
|
<tr>
|
|
<th>
|
|
區域
|
|
</th>
|
|
<th>
|
|
車牌號碼
|
|
</th>
|
|
<!--<th>
|
|
進入圖片
|
|
</th>
|
|
<th>
|
|
違規圖片
|
|
</th>-->
|
|
<th>
|
|
時間
|
|
</th>
|
|
<th></th>
|
|
</tr>
|
|
</thead>
|
|
|
|
<tbody id="demo">
|
|
</tbody>
|
|
|
|
|
|
</table>
|
|
</div>
|
|
|
|
<!--車輛詳細-彈跳視窗-->
|
|
<div>
|
|
<dialog id="detail_car_data_view" style="width:100%;">
|
|
<table class="table">
|
|
<button class="btn btn-danger" style="float:right" onclick="detail_car_data_view.close();"> 關閉 </button>
|
|
|
|
<p></p>
|
|
<thead>
|
|
<tr>
|
|
<th>
|
|
區域
|
|
</th>
|
|
<th>
|
|
車牌號碼
|
|
</th>
|
|
<th>
|
|
進入圖片
|
|
</th>
|
|
<th>
|
|
時間
|
|
</th>
|
|
|
|
</tr>
|
|
</thead>
|
|
|
|
<tbody id="detail_car_data">
|
|
</tbody>
|
|
|
|
|
|
</table>
|
|
<button class="btn btn-outline-success" style="float:left" onclick="previous_detail_data()"> Previous</button>
|
|
<button class="btn btn-outline-success" style="float:right" onclick="next_detail_data()"> Next </button>
|
|
</dialog>
|
|
|
|
</div>
|
|
|
|
|
|
<!--獲取資料-->
|
|
<script>
|
|
var All_Model
|
|
var serial_number = 0
|
|
function get_data() {
|
|
var name = "大門口"
|
|
//console.log(name)
|
|
$.ajax({
|
|
type: "GET",
|
|
url: "http://140.125.20.183:7700/api/Yuntech_in_car_table/location-" + name,
|
|
data: {},
|
|
contentType: "application/json",
|
|
success: function (Model) {
|
|
//console.log(Model)
|
|
All_Model = Model
|
|
set_data(Model)
|
|
|
|
}
|
|
});
|
|
}
|
|
</script>
|
|
|
|
<!--放置資料-->
|
|
<script>
|
|
|
|
function set_data(Model) {
|
|
table = "<tr>";
|
|
console.log(Model.length)
|
|
if (Model.length > 0) {
|
|
for (var i = 0; i < Model.length; i++) {
|
|
if (Model[i].location != null) {
|
|
table += "<td>" + Model[i].location + "</td>"
|
|
table += "<td>" + Model[i].license_plate_number + "</td>"
|
|
// 将字符串转换为 Date 对象
|
|
var timestampDt = new Date(Model[i].in_time);
|
|
// 转换为其他格式
|
|
var options = { year: 'numeric', month: '2-digit', day: '2-digit', hour: '2-digit', minute: '2-digit', second: '2-digit' };
|
|
var formattedDate = timestampDt.toLocaleDateString('en-US', options);
|
|
table += "<td>" + formattedDate + "</td>"
|
|
table += "<td>" + '<button class="btn btn-outline-success" onclick="detail_data(' + "'" + Model[i].location + "','" + i + "','" + Model[i].in_time + "'" + ')">詳細</button>'
|
|
|
|
|
|
}
|
|
table += "</tr>"
|
|
table += "<tr>"
|
|
|
|
}
|
|
}
|
|
document.getElementById("demo").innerHTML = table
|
|
}
|
|
</script>
|
|
|
|
|
|
<!--下一筆資料-->
|
|
<script>
|
|
function next_detail_data() {
|
|
serial_number = Number(serial_number) + 1
|
|
if (serial_number >= All_Model.length) {
|
|
window.alert('無下一筆資料')
|
|
serial_number = All_Model.length - 1
|
|
return
|
|
}
|
|
//console.log(serial_number)
|
|
//console.log(All_Model[serial_number])
|
|
detail_data(All_Model[serial_number]['location'], serial_number, All_Model[serial_number]['in_time'])
|
|
}
|
|
</script>
|
|
|
|
<!--上一筆資料-->
|
|
<script>
|
|
function previous_detail_data() {
|
|
serial_number = Number(serial_number) - 1
|
|
if (serial_number < 0) {
|
|
window.alert('無上一筆資料')
|
|
serial_number = 0
|
|
return
|
|
}
|
|
// console.log(serial_number)
|
|
//console.log(All_Model[serial_number])
|
|
detail_data(All_Model[serial_number]['location'], serial_number, All_Model[serial_number]['in_time'])
|
|
}
|
|
</script>
|
|
|
|
<!--車輛詳細-->
|
|
<script>
|
|
function detail_data(location_name, car_serial_number, time) {
|
|
//console.log(location_name)
|
|
//console.log(All_Model[car_serial_number])
|
|
//console.log(time)
|
|
serial_number = car_serial_number
|
|
$.ajax({
|
|
type: "GET",
|
|
url: "http://140.125.20.183:7700/api/Yuntech_in_car_table/location_name-" + location_name + "-time-" + time,
|
|
data: {},
|
|
contentType: "application/json",
|
|
success: function (Model) {
|
|
console.log(Model)
|
|
table = "<tr>";
|
|
table += "<td>" + Model.location + "</td>"
|
|
table += "<td>" + '<input type="text" id = "license_plate_number_text_id" value="' + Model.license_plate_number + '"/>' + "</td>"
|
|
//table += "<td>" + "</td>"
|
|
//table += "<td>" + "</td>"
|
|
table += "<td>" + "<img src=" + Model.car_img + ' style="width:80%"' + ">" + "</td>"
|
|
table += "<td id = 'create_data_time_id' >" + Model.in_time + "</td>"
|
|
document.getElementById("detail_car_data").innerHTML = table
|
|
}
|
|
});
|
|
detail_car_data_view.showModal();
|
|
}
|
|
</script>
|
|
|
|
<!--透過車牌號碼搜尋-->
|
|
<script>
|
|
function serch_click() {
|
|
var license_plate_number = document.getElementById("serch_text_id").value
|
|
if (license_plate_number == "") {
|
|
get_data()
|
|
}
|
|
$.ajax({
|
|
type: "GET",
|
|
url: "http://140.125.20.183:7700/api/Yuntech_in_car_table/license_plate_number-" + license_plate_number,
|
|
data: {},
|
|
contentType: "application/json",
|
|
success: function (Model) {
|
|
console.log(Model)
|
|
All_Model = Model
|
|
|
|
set_data(Model)
|
|
|
|
}
|
|
});
|
|
}
|
|
</script>
|
|
|
|
<!--透過日期搜尋紀錄-->
|
|
<script>
|
|
function serch_date_click() {
|
|
var name = "大門口"
|
|
var start_date = document.getElementById("start_date_id").value
|
|
var end_date = document.getElementById("end_date_id").value
|
|
console.log(start_date)
|
|
$.ajax({
|
|
type: "GET",
|
|
url: "http://140.125.20.183:7700/api/Yuntech_in_car_table/location_name_1_-" + name + "-start_time-" + start_date + "-end_time-" + end_date,
|
|
data: {},
|
|
contentType: "application/json",
|
|
success: function (Model) {
|
|
console.log(Model)
|
|
All_Model = Model
|
|
set_data(Model)
|
|
|
|
}
|
|
});
|
|
|
|
|
|
}
|
|
</script>
|
|
|
|
<!--檢查token-->
|
|
<script>
|
|
function token_check() {
|
|
// 检查本地存储中是否存在JWT令牌
|
|
var token = localStorage.getItem('token_park_space');
|
|
console.log(token)
|
|
$.ajax({
|
|
type: "GET",
|
|
url: 'http://140.125.20.183:7700/Users/token_check',
|
|
headers: {
|
|
'Authorization': token
|
|
},
|
|
success: function (response) {
|
|
console.log(response)
|
|
token_check = "true"
|
|
from_token_import_id()
|
|
},
|
|
error: function (xhr) {
|
|
token_check = "false"
|
|
window.location.href = '/';
|
|
// 处理错误响应,例如跳转到未授权页面
|
|
//window.location.href = 'https://example.com/unauthorized_page';
|
|
}
|
|
});
|
|
}
|
|
|
|
function from_token_import_id() {
|
|
var token = localStorage.getItem('token_park_space');
|
|
$.ajax({
|
|
type: "GET",
|
|
url: 'http://140.125.20.183:7700/Users/token-' + token,
|
|
headers: {
|
|
'Authorization': token
|
|
},
|
|
success: function (response) {
|
|
console.log(response)
|
|
from_id_import_user_data(response)
|
|
|
|
|
|
}
|
|
});
|
|
}
|
|
function from_id_import_user_data(id) {
|
|
var token = localStorage.getItem('token_park_space');
|
|
$.ajax({
|
|
type: "GET",
|
|
url: 'http://140.125.20.183:7700/Users/user_id-' + id,
|
|
headers: {
|
|
'Authorization': token
|
|
},
|
|
success: function (model) {
|
|
model = model.result
|
|
position = model.lastname
|
|
console.log(position)
|
|
if (position == "manager") {
|
|
get_data()
|
|
}
|
|
else {
|
|
window.location.href = '/';
|
|
}
|
|
|
|
}
|
|
});
|
|
}
|
|
</script>
|
|
|
|
<!--開機自啟-->
|
|
<script>
|
|
window.onload = token_check;
|
|
</script>
|