[前端] 修改時間格式, 時間問題

This commit is contained in:
dev02 2023-07-26 13:41:02 +08:00
parent df95bf5827
commit 120642b5c7
2 changed files with 20 additions and 15 deletions

View File

@ -438,6 +438,8 @@
else if (pageAct.dateType != "range")
return;
pageAct.hisStartDate = start;
pageAct.hisEndDate = end;
getData(formatDate(start, "date", true), formatDate(end, "date", true));
}
@ -506,8 +508,9 @@
let token = cookies.get("JWT-Authorization");
let url = baseApiUrl + "/api/ExportHistory";
let v = {};
v.starttime = (pageAct.dateType == "month" ? new Date($('#getmonth').val()) : new Date($('#his_startdate').val()));
v.endtime = $('#his_enddate input').val() === "" ? null : new Date($('#his_enddate input').val());
v.starttime = pageAct.hisStartDate;
v.endtime = pageAct.hisEndDate;
v.dateType = pageAct.dateType;
v.device_number = pageAct.deviceNumber;
objSendData.Data = v;

View File

@ -636,7 +636,7 @@
{ "targets": [7], "width": "6%", "sortable": true },
{ "targets": [8], "width": "15%", "sortable": false },
{ "targets": [9], "width": "6%", "sortable": false },
{ "targets": [10], "width": "8%", "sortable": false },
{ "targets": [10], "width": "8%", "sortable": true },
{ "targets": [11], "width": "8%", "sortable": false },
];
@ -653,7 +653,7 @@
"title": "異常代號",
"data": "error_code",
render: (data) => {
return data?.split('-')[0] || '';
return data?.split('-')[0] || '' == null ? '' : data?.split('-')[0] || '';
}
},
{
@ -755,7 +755,8 @@
{ "targets": [7], "width": "15%", "sortable": false },
{ "targets": [8], "width": "6%", "sortable": false },
{ "targets": [9], "width": "8%", "sortable": false },
{ "targets": [10], "width": "8%", "sortable": false },
{ "targets": [10], "width": "8%", "sortable": true },
{ "targets": [11], "width": "8%", "sortable": false },
];
columns = [
@ -771,7 +772,7 @@
"title": "異常代號",
"data": "error_code",
render: (data) => {
return data?.split('-')[0] || '';
return data?.split('-')[0] || '' == null ? '' : data?.split('-')[0] || '';
}
},
{
@ -860,6 +861,7 @@
}
opeRecTable = new YourTeam.JqDataTables.getTableByAjax(ajaxObj, tag, null, columns, column_defs);
$(tag).DataTable().order([10, 'desc']);
}
function setType(wt) {
@ -881,6 +883,7 @@
pageAct.startdate = startdate;
pageAct.enddate = enddate;
if ($('#startdate').val() > $('#enddate').val()) {
$('#startdate').val($('#startdate').data('val'));
$('#enddate').val($('#enddate').data('val'));
@ -891,22 +894,23 @@
let ytd = displayDate(new Date(new Date().setDate(new Date().getDate() - 1)), 'date').replaceAll('/', '-')
if (dateType == 'tdy') {
pageAct.startdate = new Date(displayDate(new Date(new Date().setDate(new Date().getDate())), 'date'));
pageAct.enddate = new Date(displayDate(new Date(new Date().setDate(new Date().getDate() - 1)), 'date'));
pageAct.startdate = displayDate(new Date(new Date().setDate(new Date().getDate() + 1)), 'datetime');
pageAct.enddate = new Date(displayDate(new Date(new Date().setDate(new Date().getDate() + 2)), 'date'));
$('#startdate').val(today);
$('#startdate').data('val', today);
$('#enddate').val(today);
$('#enddate').data('val', today);
}
else if (dateType == 'ytd') {
pageAct.startdate = new Date(displayDate(new Date(new Date().setDate(new Date().getDate() - 1)), 'date'));
pageAct.enddate = new Date(displayDate(new Date(new Date().setDate(new Date().getDate() - 2)), 'date'));
pageAct.startdate = new Date(displayDate(new Date(new Date().setDate(new Date().getDate())), 'date'));
pageAct.enddate = new Date(displayDate(new Date(new Date().setDate(new Date().getDate() + 1)), 'date'));
$('#startdate').val(ytd);
$('#startdate').data('val', ytd);
$('#enddate').val(ytd);
$('#enddate').data('val', ytd);
}
else {
pageAct.enddate = new Date(displayDate(new Date(pageAct.enddate.valueOf()).setDate(pageAct.enddate.getDate() + 2), 'date'));
$(`[onclick^=setDate]`).removeClass('btn-info');
$(`[onclick^=setDate]`).addClass('btn-secondary');
if ($('#startdate').val() == $('#enddate').val()) {
@ -918,8 +922,7 @@
$('#startdate').data('val', $('#startdate').val());
$('#enddate').data('val', $('#enddate').val());
}
console.log("start :" + pageAct.startdate);
console.log("end :" + pageAct.enddate);
refTable();
}
}
@ -1002,15 +1005,14 @@
}
function exportExcel(e) {
console.log("export", e)
let url = baseApiUrl + "/operation/OpeExportExcel";
console.log()
objSendData.Data = {
work_type: pageAct.work_type,
startdate: pageAct.startdate == undefined ? null : pageAct.startdate,
enddate: pageAct.enddate == undefined ? null : pageAct.enddate,
};
console.log("data", objSendData.Data)
ytAjax = new YourTeam.Ajax(url, objSendData, function (rel) {
if (rel.code == "0000")
location.href = baseApiUrl + "/api/df?path=" + rel.data.split('/')[0] + "&fileName=" + rel.data.split('/')[1] + "&token=" + cookies.get("JWT-Authorization");