新增總車位數量 並可以手動更新

This commit is contained in:
威勝 張 2024-05-02 13:44:16 +08:00
parent 6a268dbaa8
commit 8182308983

View File

@ -205,6 +205,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 />
@ -597,6 +626,79 @@
} }
</script> </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>
<!--跳轉頁面--> <!--跳轉頁面-->
@ -1084,6 +1186,7 @@
get_LED_data() get_LED_data()
get_RTSP_data() get_RTSP_data()
get_in_yuntech_data_1() get_in_yuntech_data_1()
get_yuntech_parking_data()
} }
else { else {
window.location.href = '/'; window.location.href = '/';