管理者模式 下放

1. 總車輛剩餘車輛
2.進入車輛區域選擇
This commit is contained in:
威勝 張 2024-05-02 15:11:17 +08:00
parent 8182308983
commit a3f8be283e
3 changed files with 268 additions and 16 deletions

View File

@ -643,6 +643,7 @@
}); });
} }
</script> </script>
<!--放置總車位資料--> <!--放置總車位資料-->
<script> <script>
function set_yuntech_parking_data(Model) { function set_yuntech_parking_data(Model) {
@ -1125,6 +1126,18 @@
<!--Get_data-->
<script>
function get_data() {
get_violation_data_1()
get_algorithm_data()
get_LED_data()
get_RTSP_data()
get_in_yuntech_data_1()
get_yuntech_parking_data()
}
</script>
<!--檢查token--> <!--檢查token-->
<script> <script>
var token var token
@ -1181,12 +1194,7 @@
position = model.lastname position = model.lastname
//console.log(position) //console.log(position)
if (position == "engineer") { if (position == "engineer") {
get_violation_data_1() get_data()
get_algorithm_data()
get_LED_data()
get_RTSP_data()
get_in_yuntech_data_1()
get_yuntech_parking_data()
} }
else { else {
window.location.href = '/'; window.location.href = '/';

View File

@ -10,7 +10,7 @@
<div class="row"> <div class="row">
<!--每日違規數量--> <!--每日違規數量-->
<div class="col-xl-6 col-lg-6"> <div class="col-xl-8 col-lg-8">
<div class="card shadow mb-8"> <div class="card shadow mb-8">
<div class="card-header py-3"> <div class="card-header py-3">
<h6 class="m-0 font-weight-bold text-primary"> <h6 class="m-0 font-weight-bold text-primary">
@ -25,9 +25,42 @@
</div> </div>
</div> </div>
</div> </div>
<!--字幕機狀態-->
<div class="col-xl-4 col-lg-4">
<div class="card shadow mb-4">
<!-- Card Header - Dropdown -->
<div class="card-header py-3">
<h6 class="m-0 font-weight-bold text-primary">
各停車場車位數量<button class="btn btn-info btn-circle btn-sm" style="float:right; background-image: url('/image/icon/F5.png'); background-size: cover;" onclick="get_LED_data()"></button>
</h6>
</div>
<!-- Card Body -->
<div>
<table class="table">
<thead>
<tr>
<th>
停車場位置
</th>
<th>
剩餘車位
</th>
</tr>
</thead>
<tbody id="LED_table">
</tbody>
</table>
</div>
</div>
</div>
</div>
<br />
<div class="row">
<!--每日車流量--> <!--每日車流量-->
<div class="col-xl-6 col-lg-6"> <div class="col-xl-8 col-lg-8">
<div class="card shadow mb-8"> <div class="card shadow mb-8">
<div class="card-header py-3"> <div class="card-header py-3">
<h6 class="m-0 font-weight-bold text-primary"> <h6 class="m-0 font-weight-bold text-primary">
@ -41,6 +74,35 @@
</div> </div>
</div> </div>
</div> </div>
<!--校園總車位數量-->
<div class="col-xl-4 col-lg-4">
<div class="card shadow mb-4">
<!-- Card Header - Dropdown -->
<div class="card-header py-3">
<h6 class="m-0 font-weight-bold text-primary">
校園總車位數量<button class="btn btn-info btn-circle btn-sm" style="float:right; background-image: url('/image/icon/F5.png'); background-size: cover;" onclick="get_yuntech_parking_data()"></button>
</h6>
</div>
<!-- Card Body -->
<div>
<table class="table">
<thead>
<tr>
<th>
總車位
</th>
<th>
剩餘車位
</th>
</tr>
</thead>
<tbody id="parking_all_table">
</tbody>
</table>
</div>
</div>
</div>
</div> </div>
<br /> <br />
@ -189,6 +251,8 @@
console.log("GET") console.log("GET")
get_violation_data_1() get_violation_data_1()
get_in_yuntech_data_1() get_in_yuntech_data_1()
get_yuntech_parking_data()
get_LED_data()
} }
</script> </script>
@ -287,6 +351,122 @@
} }
</script> </script>
<!--獲取字幕機資料-->
<script>
function get_LED_data() {
$.ajax({
type: "GET",
url: "http://140.125.20.183:7700/api/Parking_spaces_lcd_instand",
data: {},
headers: {
'Authorization': token
},
contentType: "application/json",
success: function (Model) {
//console.log(Model)
set_LED_data(Model)
}
});
}
</script>
<!--放置字幕機資料-->
<script>
function set_LED_data(Model) {
table = "<tr>";
//console.log(Model.length)
if (Model.length > 0) {
for (var i = 0; i < Model.length; i++) {
if (Model[i].parking_spaces_name != null) {
table += "<td>" + Model[i].parking_spaces_name + "</td>"
table += "<td>" + Model[i].parking_space_amount + "</td>"
}
table += "</tr>"
table += "<tr>"
}
}
document.getElementById("LED_table").innerHTML = table
}
</script>
<!--獲取總車位資料-->
<script>
function get_yuntech_parking_data() {
$.ajax({
type: "GET",
url: "http://140.125.20.183:7700/api/Yuntech_parking",
data: {},
headers: {
'Authorization': token
},
contentType: "application/json",
success: function (Model) {
set_yuntech_parking_data(Model)
}
});
}
</script>
<!--放置總車位資料-->
<script>
function set_yuntech_parking_data(Model) {
table = "<tr>";
if (Model.length > 0) {
for (var i = 0; i < Model.length; i++) {
if (Model[i].all_num != null) {
table += "<td>" + Model[i].all_num + "</td>"
table += "<td>" + '<input type="text" id = "parking_space_amount_id" value =' + Model[i].now_num + ' />' + "</td > "
table += "<td>" + '<button class="btn btn-outline-warning " onclick="Update_now_num(' + "'" + Model[i].all_num + "'" + ')">更新並上傳</button>'
}
table += "</tr>"
table += "<tr>"
}
}
document.getElementById("parking_all_table").innerHTML = table
}
</script>
<!--更新剩餘車位資料-->
<script>
function Update_now_num(all_num) {
$.ajax({
type: "GET",
url: "http://140.125.20.183:7700/api/Yuntech_parking/" + all_num,
data: {},
headers: {
'Authorization': token
},
contentType: "application/json",
success: function (Model) {
console.log(Model)
Update_detail_1(Model)
}
});
}
function Update_detail_1(Model) {
var parking_spaces_now_num = document.getElementById("parking_space_amount_id").value
Model.now_num = parking_spaces_now_num
var stringify_obj = JSON.stringify(Model);
$.ajax({
type: "PUT",
url: "http://140.125.20.183:7700/api/Yuntech_parking/" + Model.all_num,
data: stringify_obj,
headers: {
'Authorization': token
},
contentType: "application/json",
success: function (Model) {
console.log(Model)
}
});
}
</script>
<!--檢查token--> <!--檢查token-->

View File

@ -14,6 +14,8 @@
<button style="height:30px;float:right " class="btn btn-outline-secondary" onclick="serch_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" /> <input type="text" style="float:right" placeholder="請輸入車牌 ex:ABC4321" id="serch_text_id" />
<br />
<select style="width:10%" id="location_select_id" onchange="location_select()"></select>
<table class="table"> <table class="table">
<thead> <thead>
<tr> <tr>
@ -131,6 +133,30 @@
} }
}); });
*/ */
var select = document.getElementById("location_select_id")
$.ajax({
type: "GET",
url: "http://140.125.20.183:7700/api/Yuntech_in_car_table/location_name",
data: {},
headers: {
'Authorization': token
},
contentType: "application/json",
headers: {
'Authorization': token
},
success: function (Model) {
console.log(Model)
// 清除现有的选项
select.innerHTML = "";
// 添加新的选项
Model.forEach(function (item) {
var option = document.createElement('option');
option.text = item.location_name;
select.add(option);
});
}
});
} }
@ -297,6 +323,7 @@
}, },
success: function (Model) { success: function (Model) {
console.log(Model) console.log(Model)
if (Model.out_time == null) {
table = "<tr>"; table = "<tr>";
table += "<td>" + Model.location + "</td>" table += "<td>" + Model.location + "</td>"
table += "<td>" + '<input type="text" id = "license_plate_number_text_id" value="' + Model.license_plate_number + '"/>' + "</td>" table += "<td>" + '<input type="text" id = "license_plate_number_text_id" value="' + Model.license_plate_number + '"/>' + "</td>"
@ -306,6 +333,17 @@
table += "<td id = 'create_data_time_id' >" + Model.in_time + "</td>" table += "<td id = 'create_data_time_id' >" + Model.in_time + "</td>"
document.getElementById("detail_car_data").innerHTML = table document.getElementById("detail_car_data").innerHTML = table
} }
else {
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:40%"' + ">" + " <img src=" + Model.out_car_img + ' style="width:40%"' + ">" + "</td>"
table += "<td id = 'create_data_time_id' >" + "進入時間:" + Model.in_time + "<br/>" + "<br/>" + "出去時間: " + Model.out_time + "</td>"
document.getElementById("detail_car_data").innerHTML = table
}
}
}); });
detail_car_data_view.showModal(); detail_car_data_view.showModal();
} }
@ -364,6 +402,32 @@
} }
</script> </script>
<!--透過進入位置搜尋-->
<script>
function location_select() {
var select_location = document.getElementById("location_select_id").value
console.log(select_location)
$.ajax({
type: "GET",
url: "http://140.125.20.183:7700/api/Yuntech_in_car_table/location-" + select_location,
data: {},
headers: {
'Authorization': token
},
contentType: "application/json",
headers: {
'Authorization': token
},
success: function (Model) {
//console.log(Model)
All_Model = Model
set_data(Model)
}
});
}
</script>
<!--檢查token--> <!--檢查token-->
<script> <script>
var token var token