修改匯出流程
This commit is contained in:
parent
2c3704f5a6
commit
06d0e84782
@ -84,6 +84,7 @@
|
|||||||
initApp.buildNavigation($('#js_nested_list'));
|
initApp.buildNavigation($('#js_nested_list'));
|
||||||
|
|
||||||
loadTable(null);
|
loadTable(null);
|
||||||
|
$(`[onclick="setDateType('today')"]`).click();
|
||||||
});
|
});
|
||||||
|
|
||||||
function initList() {
|
function initList() {
|
||||||
@ -186,12 +187,12 @@
|
|||||||
var edt = new Date(new Date().setDate(sdt.getDate() + 1));
|
var edt = new Date(new Date().setDate(sdt.getDate() + 1));
|
||||||
start = start ?? sdt.toLocaleDateString();
|
start = start ?? sdt.toLocaleDateString();
|
||||||
end = end ?? edt.toLocaleDateString();
|
end = end ?? edt.toLocaleDateString();
|
||||||
getHistoryDataByBaja(pageAct.deviceNumber + "_" + pageAct.deviceItem,
|
// getHistoryDataByBaja(pageAct.deviceNumber + "_" + pageAct.deviceItem,
|
||||||
new Date(start).getTime(),
|
//new Date(start).getTime(),
|
||||||
new Date(end).getTime(),
|
//new Date(end).getTime(),
|
||||||
pageAct.deviceName,
|
//pageAct.deviceName,
|
||||||
"Mitsubishi_Sup",
|
// "Mitsubishi_Sup",
|
||||||
callBackFromHistory);
|
// callBackFromHistory);
|
||||||
}
|
}
|
||||||
|
|
||||||
function callBackFromHistory(res) {
|
function callBackFromHistory(res) {
|
||||||
@ -262,7 +263,7 @@
|
|||||||
|
|
||||||
if (pageAct.dateType == "day")
|
if (pageAct.dateType == "day")
|
||||||
end = new Date(new Date().setDate(start.getDate() + 1));
|
end = new Date(new Date().setDate(start.getDate() + 1));
|
||||||
else if (pageAct.dateType == "month") {
|
else if (pageAct.dateType == "month") {
|
||||||
start = new Date($('#getmonth').val());
|
start = new Date($('#getmonth').val());
|
||||||
end = new Date(new Date().setDate(start.getDate() + 30));
|
end = new Date(new Date().setDate(start.getDate() + 30));
|
||||||
}
|
}
|
||||||
@ -290,7 +291,7 @@
|
|||||||
let column_defs = [
|
let column_defs = [
|
||||||
{ "targets": [0], "width": "20%", "sortable": true },
|
{ "targets": [0], "width": "20%", "sortable": true },
|
||||||
{ "targets": [1], "width": "20%", "sortable": true },
|
{ "targets": [1], "width": "20%", "sortable": true },
|
||||||
{ "targets": [2], "width": "20%", "sortable": true },
|
{ "targets": [2], "width": "20%", "sortable": true }
|
||||||
];
|
];
|
||||||
|
|
||||||
let columns = [
|
let columns = [
|
||||||
@ -308,17 +309,25 @@
|
|||||||
"render": function (date) {
|
"render": function (date) {
|
||||||
return displayDate(date, "datetime");
|
return displayDate(date, "datetime");
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
historyTable = new YourTeam.JqDataTables.getTableByStatic(tag, data, columns, column_defs, null, null, null, null, "tpi");
|
historyTable = new YourTeam.JqDataTables.getTableByStatic(tag, data, columns, column_defs, null, null, null, null, "tpi");
|
||||||
}
|
}
|
||||||
|
|
||||||
function exportExcel() {
|
function exportExcel() {
|
||||||
let url = baseApiUrl + "/History/OpeExportExcel";
|
let url = baseApiUrl + "/History/OpeExportExcel";
|
||||||
objSendData.Data = $('#historyTable').dataTable().fnGetData();;
|
objSendData.Data = $('#historyTable').dataTable().fnGetData();
|
||||||
|
|
||||||
|
$.each(objSendData.Data, function (i, v) {
|
||||||
|
v.starttime = (pageAct.dateType == "month" ? new Date($('#getmonth').val()) : new Date($('#startdate').val()));
|
||||||
|
v.endtime = $('#enddate input').val() === "" ? null : new Date($('#enddate input').val());
|
||||||
|
v.dateType = pageAct.dateType;
|
||||||
|
});
|
||||||
|
|
||||||
ytAjax = new YourTeam.Ajax(url, objSendData, function (rel) {
|
ytAjax = new YourTeam.Ajax(url, objSendData, function (rel) {
|
||||||
location.href = baseApiUrl + "/api/df?fileName=" + rel.data + "&token=" + localStorage.getItem("JWT-Authorization");
|
if (rel.code == "0000")
|
||||||
|
location.href = baseApiUrl + "/api/df?fileName=" + rel.data + "&token=" + localStorage.getItem("JWT-Authorization");
|
||||||
}, null, "POST").send();
|
}, null, "POST").send();
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
@ -55,7 +55,8 @@ namespace FrontendWebApi.ApiControllers
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var fileName = "廠商資料.xlsx";
|
var fileDateName = lhe.FirstOrDefault().dateType == "month" ? lhe.FirstOrDefault().starttime.ToString("yyyy-MM") : lhe.FirstOrDefault().endtime == null ? lhe.FirstOrDefault().starttime.ToString("yyyy-MM-dd") : lhe.FirstOrDefault().starttime.ToString("yyyy-MM-dd") + "_" + ((DateTime)lhe.FirstOrDefault().endtime).ToString("yyyy-MM-dd");
|
||||||
|
var fileName = "廠商資料_"+fileDateName+".xlsx";
|
||||||
var filePath = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot", "excel", "history");
|
var filePath = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot", "excel", "history");
|
||||||
|
|
||||||
if (!System.IO.Directory.Exists(filePath))
|
if (!System.IO.Directory.Exists(filePath))
|
||||||
|
@ -268,5 +268,8 @@ namespace FrontendWebApi.Models
|
|||||||
public string deviceName { get; set; }
|
public string deviceName { get; set; }
|
||||||
public int value { get; set; }
|
public int value { get; set; }
|
||||||
public DateTime timestamp { get; set; }
|
public DateTime timestamp { get; set; }
|
||||||
|
public DateTime starttime { get; set; }
|
||||||
|
public DateTime? endtime { get; set; }
|
||||||
|
public string dateType { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Binary file not shown.
Loading…
Reference in New Issue
Block a user