[前端] 修改歷史資料, 運維管理程序

This commit is contained in:
dev02 2023-07-26 17:04:43 +08:00
parent f82f1ec177
commit 13abccd24e
2 changed files with 86 additions and 46 deletions

View File

@ -386,7 +386,7 @@
} }
} }
function searchDate() { function searchDate() {
let start = new Date($('#his_startdate').val()); let start = new Date($('#his_startdate').val());
let end = new Date(new Date().setDate(new Date($('#his_enddate input').val()).getDate() + 1)); let end = new Date(new Date().setDate(new Date($('#his_enddate input').val()).getDate() + 1));
@ -399,8 +399,10 @@
else if (pageAct.dateType != "range") else if (pageAct.dateType != "range")
return; return;
pageAct.hisStartDate = start;
pageAct.hisEndDate = end;
getData(formatDate(start, "date", true), formatDate(end, "date", true)); getData(formatDate(start, "date", true), formatDate(end, "date", true));
} }
function formatDate(date, type, send = false) { function formatDate(date, type, send = false) {
if (!send) if (!send)
@ -461,18 +463,16 @@
} }
} }
function exportExcel() { function exportExcel() {
$(loadEle).Loading("start"); $(loadEle).Loading("start");
let token = cookies.get("JWT-Authorization"); let token = cookies.get("JWT-Authorization");
let url = baseApiUrl + "/api/ExportHistory"; let url = baseApiUrl + "/api/ExportHistory";
let v = {}; 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.dateType = pageAct.dateType; v.endtime = pageAct.hisEndDate;
v.building_tag = pageAct.buiTag; v.dateType = pageAct.dateType;
v.device_number = pageAct.deviceNumber; v.device_number = pageAct.deviceNumber;
v.device_item = pageAct.deviceItem;
v.deviceComName = pageAct.deviceComName;
objSendData.Data = v; objSendData.Data = v;
$.ajax({ $.ajax({
@ -497,8 +497,17 @@
$(loadEle).Loading("close"); $(loadEle).Loading("close");
}, },
complete: (xhr) => { complete: (xhr) => {
$(loadEle).Loading("close"); setLoading(false);
}, },
}); });
} // ytAjax = new YourTeam.Ajax(url, objSendData, function (rel) {
// $(loadEle).Loading("close");
// }, function (rel) {
// if (rel) {
// downloadByBlob(xhr, rel);
// }
// $(loadEle).Loading("close");
// }, "POST",true).send();
}
</script> </script>

View File

@ -8,13 +8,22 @@
<div class="btn-group"> <div class="btn-group">
<button type="button" onclick="setType(2)" class="btn btn-secondary waves-effect waves-themed">維修</button> <button type="button" onclick="setType(2)" class="btn btn-secondary waves-effect waves-themed">維修</button>
<button type="button" onclick="setType(1)" class="btn btn-secondary waves-effect waves-themed">保養記錄</button> <button type="button" onclick="setType(1)" class="btn btn-secondary waves-effect waves-themed">保養記錄</button>
<button type="button" onclick="setType(null)" class="btn btn-secondary waves-effect waves-themed">廠商資料</button> <button type="button" onclick="setType(null)"
class="btn btn-secondary waves-effect waves-themed">
廠商資料
</button>
</div> </div>
</div> </div>
<div id="setDate" class="col-auto"> <div id="setDate" class="col-auto">
<div class="btn-group"> <div class="btn-group">
<button onclick="setDate('tdy')" type="button" class="btn btn-secondary waves-effect waves-themed">今天</button> <button onclick="setDate('tdy')" type="button"
<button onclick="setDate('ytd')" type="button" class="btn btn-secondary waves-effect waves-themed">昨天</button> class="btn btn-secondary waves-effect waves-themed">
今天
</button>
<button onclick="setDate('ytd')" type="button"
class="btn btn-secondary waves-effect waves-themed">
昨天
</button>
</div> </div>
</div> </div>
<div class="col-auto"> <div class="col-auto">
@ -60,7 +69,7 @@
<a href="#" id="newForm" class="btn btn-success" data-toggle="modal" data-target="#opeFirmModal">新增</a> <a href="#" id="newForm" class="btn btn-success" data-toggle="modal" data-target="#opeFirmModal">新增</a>
<a href="#" onclick="exportExcel()" class="btn btn-info waves-effect waves-themed"> <a href="#" onclick="exportExcel()" class="btn btn-info waves-effect waves-themed">
<span class="fal fa-file-excel mr-1"></span> <span class="fal fa-file-excel mr-1"></span>
匯出 <span>匯出</span>
</a> </a>
</div> </div>
<table id="opeFirmTable" class="table table-bordered table-striped text-center m-0 w-100"> <table id="opeFirmTable" class="table table-bordered table-striped text-center m-0 w-100">
@ -76,7 +85,8 @@
</main> </main>
<!-- Modal center 廠商資料 --> <!-- Modal center 廠商資料 -->
<div class="modal fade" id="opeFirmModal" tabindex="-1" role="dialog" aria-hidden="true" data-backdrop="static" data-keyboard="false"> <div class="modal fade" id="opeFirmModal" tabindex="-1" role="dialog" aria-hidden="true" data-backdrop="static"
data-keyboard="false">
<div class="modal-dialog modal-dialog-centered" role="document"> <div class="modal-dialog modal-dialog-centered" role="document">
<div class="modal-content"> <div class="modal-content">
<div class="modal-header"> <div class="modal-header">
@ -152,7 +162,8 @@
</div> </div>
<!-- Modal center 維修--> <!-- Modal center 維修-->
<div class="modal fade" id="opeRecModal_2" tabindex="-1" role="dialog" aria-hidden="true" data-backdrop="static" data-keyboard="false"> <div class="modal fade" id="opeRecModal_2" tabindex="-1" role="dialog" aria-hidden="true" data-backdrop="static"
data-keyboard="false">
<div class="modal-dialog modal-dialog-centered" role="document"> <div class="modal-dialog modal-dialog-centered" role="document">
<div class="modal-content"> <div class="modal-content">
<div class="modal-header"> <div class="modal-header">
@ -222,12 +233,14 @@
<div class="form-control" id="inpStatus_2"> <div class="form-control" id="inpStatus_2">
<div class="row container"> <div class="row container">
<div class=""> <div class="">
<input class="custom-radio-input" type="radio" name="inpSta_2" id="inpSta_2_0" value="0" data-value="0" checked> <input class="custom-radio-input" type="radio" name="inpSta_2" id="inpSta_2_0" value="0"
data-value="0" checked>
<label class="form-label" for="inpSta_0">未完成</label> <label class="form-label" for="inpSta_0">未完成</label>
</div> </div>
<div class="px-4"> <div class="px-4">
<input class="custom-radio-input" type="radio" name="inpSta_2" id="inpSta_2_1" value="1" data-value="1"> <input class="custom-radio-input" type="radio" name="inpSta_2" id="inpSta_2_1" value="1"
data-value="1">
<label class="form-label" for="inpSta_1">完成</label> <label class="form-label" for="inpSta_1">完成</label>
</div> </div>
</div> </div>
@ -251,7 +264,8 @@
<div class="col-md-12"> <div class="col-md-12">
<div class="form-group"> <div class="form-group">
<label class="form-label" for="inpDescription_2">結果描述</label> <label class="form-label" for="inpDescription_2">結果描述</label>
<textarea class="form-control" type="text" id="inpDescription_2" name="inpDescription_2" rows="7"></textarea> <textarea class="form-control" type="text" id="inpDescription_2" name="inpDescription_2"
rows="7"></textarea>
</div> </div>
</div> </div>
<div class="col-md-12"> <div class="col-md-12">
@ -288,7 +302,8 @@
</div> </div>
<!-- Modal center 保養 --> <!-- Modal center 保養 -->
<div class="modal fade" id="opeRecModal" tabindex="-1" role="dialog" aria-hidden="true" data-backdrop="static" data-keyboard="false"> <div class="modal fade" id="opeRecModal" tabindex="-1" role="dialog" aria-hidden="true" data-backdrop="static"
data-keyboard="false">
<div class="modal-dialog modal-dialog-centered" role="document"> <div class="modal-dialog modal-dialog-centered" role="document">
<div class="modal-content"> <div class="modal-content">
<div class="modal-header"> <div class="modal-header">
@ -350,12 +365,14 @@
<div class="form-control" id="inpStatus"> <div class="form-control" id="inpStatus">
<div class="row container"> <div class="row container">
<div class=""> <div class="">
<input class="custom-radio-input" type="radio" name="inpSta" id="inpSta_0" data-value="0" value="0" checked> <input class="custom-radio-input" type="radio" name="inpSta" id="inpSta_0" data-value="0"
value="0" checked>
<label class="form-label" for="inpSta_0">未完成</label> <label class="form-label" for="inpSta_0">未完成</label>
</div> </div>
<div class="px-4"> <div class="px-4">
<input class="custom-radio-input" type="radio" name="inpSta" id="inpSta_1" data-value="1" value="1"> <input class="custom-radio-input" type="radio" name="inpSta" id="inpSta_1" data-value="1"
value="1">
<label class="form-label" for="inpSta_1">完成</label> <label class="form-label" for="inpSta_1">完成</label>
</div> </div>
</div> </div>
@ -379,7 +396,8 @@
<div class="col-md-12"> <div class="col-md-12">
<div class="form-group"> <div class="form-group">
<label class="form-label" for="inpDescription">結果描述</label> <label class="form-label" for="inpDescription">結果描述</label>
<textarea class="form-control" type="text" id="inpDescription" name="inpDescription" rows="7"></textarea> <textarea class="form-control" type="text" id="inpDescription" name="inpDescription"
rows="7"></textarea>
</div> </div>
</div> </div>
<div class="col-md-12"> <div class="col-md-12">
@ -416,7 +434,8 @@
</div> </div>
<!-- Modal center 刪除 --> <!-- Modal center 刪除 -->
<div class="modal fade" id="delModal" tabindex="-1" role="dialog" aria-hidden="true" data-backdrop="static" data-keyboard="false"> <div class="modal fade" id="delModal" tabindex="-1" role="dialog" aria-hidden="true" data-backdrop="static"
data-keyboard="false">
<div class="modal-dialog modal-dialog-centered" role="document"> <div class="modal-dialog modal-dialog-centered" role="document">
<div class="modal-content"> <div class="modal-content">
<div class="modal-header"> <div class="modal-header">
@ -517,7 +536,6 @@
}); });
function loadOpeFirmTable() { function loadOpeFirmTable() {
$(loadEle).Loading("start");
$('#opeFirmTable_wrapper').css('display', 'block'); $('#opeFirmTable_wrapper').css('display', 'block');
$('#opeRecTable_wrapper').css('display', 'none'); $('#opeRecTable_wrapper').css('display', 'none');
$('#opeRecTable_2_wrapper').css('display', 'none'); $('#opeRecTable_2_wrapper').css('display', 'none');
@ -583,11 +601,9 @@
]; ];
opeFirmTable = new YourTeam.JqDataTables.getTableByAjax(ajaxObj, tag, null, columns, column_defs); opeFirmTable = new YourTeam.JqDataTables.getTableByAjax(ajaxObj, tag, null, columns, column_defs);
$(loadEle).Loading("close");
} }
function loadOpeRecTable() { function loadOpeRecTable() {
$(loadEle).Loading("start");
$('#opeFirmTable_wrapper').css('display', 'none'); $('#opeFirmTable_wrapper').css('display', 'none');
$('#serial_number').parent().parent().css('display', 'block'); $('#serial_number').parent().parent().css('display', 'block');
@ -620,7 +636,7 @@
{ "targets": [7], "width": "6%", "sortable": true }, { "targets": [7], "width": "6%", "sortable": true },
{ "targets": [8], "width": "15%", "sortable": false }, { "targets": [8], "width": "15%", "sortable": false },
{ "targets": [9], "width": "6%", "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 }, { "targets": [11], "width": "8%", "sortable": false },
]; ];
@ -637,7 +653,7 @@
"title": "異常代號", "title": "異常代號",
"data": "error_code", "data": "error_code",
render: (data) => { render: (data) => {
return data?.split('-')[0] || ''; return data?.split('-')[0] || '' == null ? '' : data?.split('-')[0] || '';
} }
}, },
{ {
@ -739,7 +755,8 @@
{ "targets": [7], "width": "15%", "sortable": false }, { "targets": [7], "width": "15%", "sortable": false },
{ "targets": [8], "width": "6%", "sortable": false }, { "targets": [8], "width": "6%", "sortable": false },
{ "targets": [9], "width": "8%", "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 = [ columns = [
@ -755,7 +772,7 @@
"title": "異常代號", "title": "異常代號",
"data": "error_code", "data": "error_code",
render: (data) => { render: (data) => {
return data?.split('-')[0] || ''; return data?.split('-')[0] || '' == null ? '' : data?.split('-')[0] || '';
} }
}, },
{ {
@ -844,7 +861,7 @@
} }
opeRecTable = new YourTeam.JqDataTables.getTableByAjax(ajaxObj, tag, null, columns, column_defs); opeRecTable = new YourTeam.JqDataTables.getTableByAjax(ajaxObj, tag, null, columns, column_defs);
$(loadEle).Loading("close"); $(tag).DataTable().order([10, 'desc']).draw();
} }
function setType(wt) { function setType(wt) {
@ -866,6 +883,7 @@
pageAct.startdate = startdate; pageAct.startdate = startdate;
pageAct.enddate = enddate; pageAct.enddate = enddate;
if ($('#startdate').val() > $('#enddate').val()) { if ($('#startdate').val() > $('#enddate').val()) {
$('#startdate').val($('#startdate').data('val')); $('#startdate').val($('#startdate').data('val'));
$('#enddate').val($('#enddate').data('val')); $('#enddate').val($('#enddate').data('val'));
@ -876,20 +894,23 @@
let ytd = displayDate(new Date(new Date().setDate(new Date().getDate() - 1)), 'date').replaceAll('/', '-') let ytd = displayDate(new Date(new Date().setDate(new Date().getDate() - 1)), 'date').replaceAll('/', '-')
if (dateType == 'tdy') { if (dateType == 'tdy') {
pageAct.startdate = new Date(displayDate(new Date(new Date().setDate(new Date().getDate())), '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').val(today);
$('#startdate').data('val', today); $('#startdate').data('val', today);
$('#enddate').val(today); $('#enddate').val(today);
$('#enddate').data('val', today); $('#enddate').data('val', today);
} }
else if (dateType == 'ytd') { else if (dateType == 'ytd') {
pageAct.startdate = new Date(displayDate(new Date(new Date().setDate(new Date().getDate() - 1)), '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').val(ytd);
$('#startdate').data('val', ytd); $('#startdate').data('val', ytd);
$('#enddate').val(ytd); $('#enddate').val(ytd);
$('#enddate').data('val', ytd); $('#enddate').data('val', ytd);
} }
else { else {
pageAct.enddate = new Date(displayDate(new Date(pageAct.enddate.valueOf()).setDate(pageAct.enddate.getDate() + 2), 'date'));
$(`[onclick^=setDate]`).removeClass('btn-info'); $(`[onclick^=setDate]`).removeClass('btn-info');
$(`[onclick^=setDate]`).addClass('btn-secondary'); $(`[onclick^=setDate]`).addClass('btn-secondary');
if ($('#startdate').val() == $('#enddate').val()) { if ($('#startdate').val() == $('#enddate').val()) {
@ -983,10 +1004,9 @@
loadOpeRecTable(); loadOpeRecTable();
} }
function exportExcel() { function exportExcel(e) {
$(loadEle).Loading("start");
let url = baseApiUrl + "/operation/OpeExportExcel";
let url = baseApiUrl + "/operation/OpeExportExcel";
objSendData.Data = { objSendData.Data = {
work_type: pageAct.work_type, work_type: pageAct.work_type,
startdate: pageAct.startdate == undefined ? null : pageAct.startdate, startdate: pageAct.startdate == undefined ? null : pageAct.startdate,
@ -997,7 +1017,6 @@
if (rel.code == "0000") if (rel.code == "0000")
location.href = baseApiUrl + "/api/df?path=" + rel.data.split('/')[0] + "&fileName=" + rel.data.split('/')[1] + "&token=" + cookies.get("JWT-Authorization"); location.href = baseApiUrl + "/api/df?path=" + rel.data.split('/')[0] + "&fileName=" + rel.data.split('/')[1] + "&token=" + cookies.get("JWT-Authorization");
}, null, "POST").send(); }, null, "POST").send();
$(loadEle).Loading("close");
} }
function selSysMain() { function selSysMain() {
@ -1086,6 +1105,7 @@
} }
function selAllSysVal(elem) { function selAllSysVal(elem) {
$(loadEle).Loading("start");
if ($(elem).html() == '全選類別') { if ($(elem).html() == '全選類別') {
$('#mainList input').map(function (i, v) { $('#mainList input').map(function (i, v) {
if (!$(v).is(':checked')) { if (!$(v).is(':checked')) {
@ -1112,6 +1132,7 @@
} }
refTable(); refTable();
$(loadEle).Loading("close");
} }
function event() { function event() {
@ -1359,12 +1380,18 @@
if (!res || res.code != "0000" || !res.data) { if (!res || res.code != "0000" || !res.data) {
} else { } else {
pageAct.sysMain = res.data.device_system_category_layer2;
pageAct.sysSub = res.data.device_system_category_layer3; pageAct.sysSub = res.data.device_system_category_layer3;
pageAct.number = res.data.fix_do_code; pageAct.number = res.data.fix_do_code;
selOpeFir();
errCodeList();
callbackForErr(JSON.stringify({
count: [res.data].length,
data: [{ uuid: res.data.error_code }]
}));
$(pageAct.work_type == "1" ? '#inpNumber' : '#inpNumber_2').val(res.data.formId); $(pageAct.work_type == "1" ? '#inpNumber' : '#inpNumber_2').val(res.data.formId);
$(pageAct.work_type == "1" ? '#inpWorTyp' : '#inpWorTyp_2').val(res.data.work_type); $(pageAct.work_type == "1" ? '#inpWorTyp' : '#inpWorTyp_2').val(res.data.work_type);
$(pageAct.work_type == "1" ? '#inpErrCode' : '#inpErrCode_2').val(res.data.error_code);
$(pageAct.work_type == "1" ? '#inpFixDo' : '#inpFixDo_2').val(res.data.fix_do); $(pageAct.work_type == "1" ? '#inpFixDo' : '#inpFixDo_2').val(res.data.fix_do);
$(pageAct.work_type == "1" ? '#inpFixDoCode' : '#inpFixDoCode_2').val(res.data.fix_do_code); $(pageAct.work_type == "1" ? '#inpFixDoCode' : '#inpFixDoCode_2').val(res.data.fix_do_code);
$(pageAct.work_type == "1" ? '#inpFixFirm' : '#inpFixFirm_2').val(res.data.fix_firm); $(pageAct.work_type == "1" ? '#inpFixFirm' : '#inpFixFirm_2').val(res.data.fix_firm);
@ -1373,6 +1400,9 @@
$(pageAct.work_type == "1" ? '#inpStaTime' : '#inpStaTime_2').val(displayDate(res.data.start_time, 'date').replaceAll('/', '-')); $(pageAct.work_type == "1" ? '#inpStaTime' : '#inpStaTime_2').val(displayDate(res.data.start_time, 'date').replaceAll('/', '-'));
$(pageAct.work_type == "1" ? '#inpNotice' : '#inpNotice_2').val(res.data.notice); $(pageAct.work_type == "1" ? '#inpNotice' : '#inpNotice_2').val(res.data.notice);
$(pageAct.work_type == "1" ? '#inpDescription' : '#inpDescription_2').val(res.data.description); $(pageAct.work_type == "1" ? '#inpDescription' : '#inpDescription_2').val(res.data.description);
let elemSel = $(pageAct.work_type == "1" ? '#inpFixDoCode' : '#inpFixDoCode_2').find('option:selected');;
pageAct.number = elemSel.val();
selOpeFir();
ope_imgHtml = null; ope_imgHtml = null;
$.each(res.data.lorf, function (i, v) { $.each(res.data.lorf, function (i, v) {
@ -1468,17 +1498,18 @@
} }
function callbackForErr(res) { function callbackForErr(res) {
res = JSON.parse(res); res = JSON.parse(res) || res;
console.log(res)
strHtml = ``; strHtml = ``;
$.each(res.data, function (i, v) { $.each(res.data, function (i, v) {
msg = v.msgText != null ? ($.trim(v.msgText.toString()).length > 0 ? v.msgText.split(':')[0] : '') : ''; msg = v.msgText != null ? ($.trim(v.msgText.toString()).length > 0 ? v.msgText.split(':')[0] : '') : '';
strHtml += `<option value=${v.uuid}>${v.uuid}</option>`; strHtml += `<option value=${v.uuid}>${v.uuid.split("-")[0]}</option>`;
}); });
if (res.count > 0) if (res.count > 0)
$(pageAct.work_type == '1' ? '#inpErrCode' : '#inpErrCode_2').html(strHtml); $(pageAct.work_type == '1' ? '#inpErrCode' : '#inpErrCode_2').html(strHtml);
else
$(pageAct.work_type == '1' ? '#inpErrCode' : '#inpErrCode_2').html("");
$(loadEle).Loading("close"); $(loadEle).Loading("close");
} }