電站資訊-異常紀錄: 顯示loading圖示、全部資訊加載完,才結束大圈圈(loading)

This commit is contained in:
wanling040@gmail.com 2022-08-22 17:20:48 +08:00
parent 3f009e7c12
commit 44e94c8b67
3 changed files with 48 additions and 7 deletions

View File

@ -418,7 +418,7 @@ namespace SolarPower.Repository.Implement
{ {
PowerStationId = post.Id, PowerStationId = post.Id,
Status = post.Status, Status = post.Status,
})).ToList(); }, commandTimeout: 600)).ToList();
} }
catch (Exception exception) catch (Exception exception)
{ {

View File

@ -175,6 +175,13 @@
var selectInverterkwhBarType = 0; var selectInverterkwhBarType = 0;
var HeapMapXAxis = []; var HeapMapXAxis = [];
var countOperationRecordFile = 0; var countOperationRecordFile = 0;
var isloadingdone_uptodate = false;
var isloadingdone_info = false;
var isloadingdone_inverterinfo = false;
var isloadingdone_inverter = false;
var isloadingdone_history = false;
var isloadingdone_exception = false;
var isloadingdone_operation = false;
function showLoading() { function showLoading() {
var i = document.getElementById("loading"); var i = document.getElementById("loading");
@ -183,7 +190,10 @@
function hideLoading() { function hideLoading() {
var i = document.getElementById("loading"); var i = document.getElementById("loading");
i.style.display = "none"; if (isloadingdone_uptodate && isloadingdone_info && isloadingdone_inverterinfo && isloadingdone_inverter && isloadingdone_history && isloadingdone_exception && isloadingdone_operation)
{
i.style.display = "none";
}
} }
$(function () { $(function () {
@ -262,6 +272,7 @@
}; };
$.post(url, send_data, function (rel) { $.post(url, send_data, function (rel) {
if (rel.code != "0000") { if (rel.code != "0000") {
isloadingdone_uptodate = true;
hideLoading(); hideLoading();
toast_error(rel.msg); toast_error(rel.msg);
return; return;
@ -320,6 +331,7 @@
$("#money-card-subtitle-total").html("總計"); $("#money-card-subtitle-total").html("總計");
$("#money-card-subtitle-avg").html("今日"); $("#money-card-subtitle-avg").html("今日");
} }
isloadingdone_uptodate = true;
hideLoading(); hideLoading();
}, 'json'); }, 'json');
@ -757,6 +769,7 @@
} }
$.post(url, send_data, function (rel) { $.post(url, send_data, function (rel) {
if (rel.code != "0000") { if (rel.code != "0000") {
isloadingdone_info = true;
hideLoading(); hideLoading();
toast_error(rel.msg); toast_error(rel.msg);
return; return;
@ -781,6 +794,7 @@
$("#power_station_select_modal").append($("<option />").val(stationId).text(powerStationData.name)); $("#power_station_select_modal").append($("<option />").val(stationId).text(powerStationData.name));
$("#power_station_select_modal").val($("#power_station_select_modal option:first").val()).trigger('change'); $("#power_station_select_modal").val($("#power_station_select_modal option:first").val()).trigger('change');
isloadingdone_info = true;
hideLoading(); hideLoading();
}, 'json'); }, 'json');
@ -1101,6 +1115,7 @@
} }
$.post(url_power_station_operation_personnel, send_data, function (rel) { $.post(url_power_station_operation_personnel, send_data, function (rel) {
if (rel.code != "0000") { if (rel.code != "0000") {
isloadingdone_operation = true;
hideLoading(); hideLoading();
toast_error(rel.msg); toast_error(rel.msg);
return; return;
@ -1117,12 +1132,12 @@
$("#work_person_select_modal_exc").val(record.workPersonId); $("#work_person_select_modal_exc").val(record.workPersonId);
} }
} }
isloadingdone_operation = true;
hideLoading(); hideLoading();
}); });
//#endregion //#endregion
//#region 異常table //#region 異常table
showLoading();
ExceptionTable = $("#Exception_Table").DataTable({ ExceptionTable = $("#Exception_Table").DataTable({
"pageLength": 20, "pageLength": 20,
"paging": true, "paging": true,
@ -1186,6 +1201,10 @@
}, },
"dataSrc": function (rel) { "dataSrc": function (rel) {
if (rel.data.code == "9999") { if (rel.data.code == "9999") {
isloadingdone_exception = true;
$("#errbutton1").html('未解決').attr("disabled", false);
$("#errbutton0").html('已解決').attr("disabled", false);
$("#to30day").html('近30天').attr("disabled", false);
hideLoading(); hideLoading();
toast_error(rel.data.msg); toast_error(rel.data.msg);
return; return;
@ -1195,11 +1214,19 @@
this.data = []; this.data = [];
} }
$("#Exception_Table_wrapper").show(); $("#Exception_Table_wrapper").show();
isloadingdone_exception = true;
$("#errbutton1").html('未解決').attr("disabled", false);
$("#errbutton0").html('已解決').attr("disabled", false);
$("#to30day").html('近30天').attr("disabled", false);
hideLoading(); hideLoading();
return data; return data;
} }
}, },
"error": function (xhr, error, thrown) { "error": function (xhr, error, thrown) {
isloadingdone_exception = true;
$("#errbutton1").html('未解決').attr("disabled", false);
$("#errbutton0").html('已解決').attr("disabled", false);
$("#to30day").html('近30天').attr("disabled", false);
hideLoading(); hideLoading();
console.log(xhr); console.log(xhr);
} }
@ -1366,13 +1393,15 @@
//#region 改變日期(異常) //#region 改變日期(異常)
$('#date-range-exception').on('change', function () { $('#date-range-exception').on('change', function () {
showLoading();
ExceptionTable.ajax.reload(); ExceptionTable.ajax.reload();
}); });
//#endregion //#endregion
//#region 匯出excel(異常) //#region 匯出excel(異常)
function ExportExcelToExc() { function ExportExcelToExc() {
showLoading(); //showLoading();
$("#exportBtn").html('<span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span>').attr("disabled", true);
var url = "/StationOverview/GetExceptionTable"; var url = "/StationOverview/GetExceptionTable";
var send_data = { var send_data = {
id: stationId, id: stationId,
@ -1381,7 +1410,8 @@
}; };
$.post(url, send_data, function (rel) { $.post(url, send_data, function (rel) {
if (rel.data.code != "0000") { if (rel.data.code != "0000") {
hideLoading(); //hideLoading();
$("#exportBtn").html('<span class="fal fa-file-excel mr-1"></span> 匯出').attr("disabled", false);
toast_error(rel.data.msg); toast_error(rel.data.msg);
return; return;
} }
@ -1412,7 +1442,8 @@
//檔案字尾名 //檔案字尾名
fileext: ".xls", fileext: ".xls",
}); });
hideLoading(); //hideLoading();
$("#exportBtn").html('<span class="fal fa-file-excel mr-1"></span> 匯出').attr("disabled", false);
}, 'json'); }, 'json');
} }
//#endregion //#endregion
@ -1494,6 +1525,7 @@
//#region 查詢近30天(異常) //#region 查詢近30天(異常)
function ChangeDate30exception() { function ChangeDate30exception() {
$("#Exception_Table_wrapper").hide(); $("#Exception_Table_wrapper").hide();
$("#to30day").html('<span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span>').attr("disabled", true);
var today = new Date(); var today = new Date();
var dateLimit = new Date(new Date().setDate(today.getDate() - 30)); var dateLimit = new Date(new Date().setDate(today.getDate() - 30));
@ -1613,9 +1645,11 @@
var name; var name;
var name2; var name2;
if (type == 0) { if (type == 0) {
$("#errbutton0").html('<span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span>').attr("disabled", true);
name = "errbutton" + "0"; name = "errbutton" + "0";
name2 = "errbutton" + "1"; name2 = "errbutton" + "1";
} else { } else {
$("#errbutton1").html('<span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span>').attr("disabled", true);
name = "errbutton" + "1"; name = "errbutton" + "1";
name2 = "errbutton" + "0"; name2 = "errbutton" + "0";
} }
@ -2378,6 +2412,7 @@
} }
$.post(url, send_data, function (rel) { $.post(url, send_data, function (rel) {
if (rel.code != "0000") { if (rel.code != "0000") {
isloadingdone_inverter = true;
hideLoading(); hideLoading();
toast_error(rel.msg); toast_error(rel.msg);
return; return;
@ -2432,6 +2467,7 @@
//#endregion //#endregion
$('#inverter-kWh-convas-div').show(); $('#inverter-kWh-convas-div').show();
isloadingdone_inverter = true;
hideLoading(); hideLoading();
}, 'json'); }, 'json');
@ -2658,6 +2694,7 @@
var Nurl = "/StationOverview/GetTotalTableToHistory"; var Nurl = "/StationOverview/GetTotalTableToHistory";
$.post(Nurl, send_data, function (rel) { $.post(Nurl, send_data, function (rel) {
if (rel.code != "0000") { if (rel.code != "0000") {
isloadingdone_history = true;
hideLoading(); hideLoading();
toast_error(rel.msg); toast_error(rel.msg);
return; return;
@ -2944,6 +2981,7 @@
'</tr>'); '</tr>');
} }
$('#all').show(); $('#all').show();
isloadingdone_history = true;
hideLoading(); hideLoading();
}) })
} }
@ -3051,11 +3089,13 @@
} }
$.post(url, send_data, function (rel) { $.post(url, send_data, function (rel) {
if (rel.code == "9999") { if (rel.code == "9999") {
isloadingdone_inverterinfo = true;
hideLoading(); hideLoading();
toast_error(rel.msg); toast_error(rel.msg);
return; return;
} }
if (rel.code == "0001") { if (rel.code == "0001") {
isloadingdone_inverterinfo = true;
hideLoading(); hideLoading();
toast_warning(rel.msg); toast_warning(rel.msg);
return; return;
@ -3181,6 +3221,7 @@
} }
}; };
isloadingdone_inverterinfo = true;
hideLoading(); hideLoading();
}); });
} }

View File

@ -15,7 +15,7 @@
</div> </div>
</div> </div>
<div class="row d-flex justify-content-end"> <div class="row d-flex justify-content-end">
<button type="button" class="btn btn-success waves-effect waves-themed mb-3" onclick="ExportExcelToExc()"> <button type="button" class="btn btn-success waves-effect waves-themed mb-3" onclick="ExportExcelToExc()" id="exportBtn">
<span class="fal fa-file-excel mr-1"></span> <span class="fal fa-file-excel mr-1"></span>
匯出 匯出
</button> </button>