管理者模式更新輸出EXCEL
This commit is contained in:
parent
a7aedcd924
commit
e1feb05e43
@ -20,7 +20,10 @@
|
||||
</th>
|
||||
|
||||
<th>
|
||||
|
||||
<button class="btn btn-outline-info" onclick="export_excel()" style="position: relative;">
|
||||
<img class="img-profile rounded-circle" style="width:20%; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);" src="~/image/icon/724933.png">
|
||||
<span style="visibility: hidden;">下載</span>
|
||||
</button>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
@ -176,10 +179,10 @@
|
||||
var myBarChart = new Chart(ctx, {
|
||||
type: 'bar',
|
||||
data: {
|
||||
labels: date.reverse(),
|
||||
labels: date,
|
||||
datasets: [{
|
||||
label: '違規數量',
|
||||
data: values.reverse(),
|
||||
data: values,
|
||||
backgroundColor: 'rgba(255, 0, 0, 0.5)', // 設定半透明的紅色背景
|
||||
borderColor: 'rgba(255, 0, 0, 1)', // 設定不透明的紅色邊框
|
||||
borderWidth: 1
|
||||
@ -360,6 +363,45 @@
|
||||
</script>
|
||||
|
||||
|
||||
<!--輸出EXCEL-->
|
||||
<script>
|
||||
function export_excel() {
|
||||
// 發送HTTP GET請求到Web API動作方法
|
||||
fetch('http://140.125.20.183:7700/api/Violation_car_table/export-all_excel', {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
'Authorization': token
|
||||
}
|
||||
})
|
||||
.then(response => {
|
||||
// 確認響應的狀態碼是否為200(成功)
|
||||
if (!response.ok) {
|
||||
throw new Error('Network response was not ok');
|
||||
}
|
||||
// 將響應的數據轉換為Blob對象
|
||||
return response.blob();
|
||||
})
|
||||
.then(blob => {
|
||||
// 創建URL對象
|
||||
const url = window.URL.createObjectURL(blob);
|
||||
// 創建當前時間
|
||||
const currentTime = new Date().toISOString().replace(/[-:]/g, "").replace(/\.\d{3}/g, "");
|
||||
// 構建檔案名稱
|
||||
const filename = `所有違規車輛-${currentTime}.xlsx`;
|
||||
// 創建<a>元素
|
||||
const a = document.createElement('a');
|
||||
a.href = url;
|
||||
a.download = filename; // 下載時的文件名稱
|
||||
// 模擬單擊<a>元素
|
||||
a.click();
|
||||
// 釋放URL對象
|
||||
window.URL.revokeObjectURL(url);
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('There was a problem with your fetch operation:', error);
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
|
@ -12,7 +12,16 @@
|
||||
起始時間 : <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 class="btn btn-outline-info" onclick="date_export_excel()" style="position: relative;height:30px">
|
||||
<img class="img-profile rounded-circle" style="height:30px;width=10%; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);" src="~/image/icon/724933.png">
|
||||
<span style="visibility: hidden;">下載</span>
|
||||
</button>
|
||||
|
||||
|
||||
<button class="btn btn-outline-info" onclick="plate_export_excel()" style="position: relative;height:30px;float:right">
|
||||
<img class="img-profile rounded-circle" style="height:30px;width=10%; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);" src="~/image/icon/724933.png">
|
||||
<span style="visibility: hidden;">下載</span>
|
||||
</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">
|
||||
@ -304,6 +313,91 @@
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
<!--透過日期下載EXCEL-->
|
||||
<script>
|
||||
function date_export_excel() {
|
||||
var name = document.getElementById("parking_spaces_name_id").value
|
||||
var start_date = document.getElementById("start_date_id").value
|
||||
var end_date = document.getElementById("end_date_id").value
|
||||
// 發送HTTP GET請求到Web API動作方法
|
||||
fetch('http://140.125.20.183:7700/api/Violation_car_table/export-excel_location_name_1_-' + name + "-start_time-" + start_date + "-end_time-" + end_date, {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
'Authorization': token
|
||||
}
|
||||
})
|
||||
.then(response => {
|
||||
// 確認響應的狀態碼是否為200(成功)
|
||||
if (!response.ok) {
|
||||
throw new Error('Network response was not ok');
|
||||
}
|
||||
// 將響應的數據轉換為Blob對象
|
||||
return response.blob();
|
||||
})
|
||||
.then(blob => {
|
||||
// 創建URL對象
|
||||
const url = window.URL.createObjectURL(blob);
|
||||
// 創建當前時間
|
||||
const currentTime = new Date().toISOString().replace(/[-:]/g, "").replace(/\.\d{3}/g, "");
|
||||
// 構建檔案名稱
|
||||
const filename = `所有違規車輛-${currentTime}.xlsx`;
|
||||
// 創建<a>元素
|
||||
const a = document.createElement('a');
|
||||
a.href = url;
|
||||
a.download = filename; // 下載時的文件名稱
|
||||
// 模擬單擊<a>元素
|
||||
a.click();
|
||||
// 釋放URL對象
|
||||
window.URL.revokeObjectURL(url);
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('There was a problem with your fetch operation:', error);
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
||||
<!--透過車牌號碼下載EXCEL-->
|
||||
<script>
|
||||
function plate_export_excel() {
|
||||
var license_plate_number = document.getElementById("serch_text_id").value
|
||||
// 發送HTTP GET請求到Web API動作方法
|
||||
fetch('http://140.125.20.183:7700/api/Violation_car_table/export-excel_license_plate_number-' + license_plate_number, {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
'Authorization': token
|
||||
}
|
||||
})
|
||||
.then(response => {
|
||||
// 確認響應的狀態碼是否為200(成功)
|
||||
if (!response.ok) {
|
||||
throw new Error('Network response was not ok');
|
||||
}
|
||||
// 將響應的數據轉換為Blob對象
|
||||
return response.blob();
|
||||
})
|
||||
.then(blob => {
|
||||
// 創建URL對象
|
||||
const url = window.URL.createObjectURL(blob);
|
||||
// 創建當前時間
|
||||
const currentTime = new Date().toISOString().replace(/[-:]/g, "").replace(/\.\d{3}/g, "");
|
||||
// 構建檔案名稱
|
||||
const filename = `${license_plate_number}-${currentTime}.xlsx`;
|
||||
// 創建<a>元素
|
||||
const a = document.createElement('a');
|
||||
a.href = url;
|
||||
a.download = filename; // 下載時的文件名稱
|
||||
// 模擬單擊<a>元素
|
||||
a.click();
|
||||
// 釋放URL對象
|
||||
window.URL.revokeObjectURL(url);
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('There was a problem with your fetch operation:', error);
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
||||
<!--刪除資料-->
|
||||
<script>
|
||||
function delet_data(location_name , name , time) {
|
||||
|
Loading…
Reference in New Issue
Block a user