FIC_Solar/SolarPower/Views/StationOverview/StationOverviewInfo.cshtml
2021-07-08 17:24:13 +08:00

572 lines
24 KiB
Plaintext

@{
ViewData["MainNum"] = "1";
ViewData["SubNum"] = "2";
ViewData["Title"] = "電站總覽";
}
<ol class="breadcrumb page-breadcrumb">
<li class="breadcrumb-item"><a href="javascript:void(0);">總覽</a></li>
<li class="breadcrumb-item">@ViewData["Title"]</li>
<li class="breadcrumb-item city-name">新竹市</li>
<li class="breadcrumb-item power-station-name active">新竹巨城站</li>
<li class="position-absolute pos-top pos-right d-none d-sm-block"><span class="js-get-date"></span></li>
</ol>
<div class="row">
<div class="col-xl-12">
<div id="panel-5" class="panel">
<div class="panel-container show">
<div class="panel-content">
<div class="row subheader">
<div class="col-xl-2">
<h1 class="subheader-title">
<span class="icon-stack fa-1x">
<i class="base-7 icon-stack-3x color-info-500"></i>
<i class="base-7 icon-stack-2x color-info-700"></i>
<i class="ni ni-graph icon-stack-1x text-white"></i>
</span>
<span id="power-station-title">新竹巨城站</span>
</h1>
</div>
<div class="col-xl-3 d-flex justify-content-start">
<p class="card-text px-3"><i class="fal fa-cloud-sun-rain fa-3x"></i></p>
<p class="font-weight-bold">27°C<br>降雨幾率: 15%</p>
</div>
</div>
<ul class="nav nav-tabs mb-5" role="tablist">
<li class="nav-item">
<a class="nav-link fs-lg px-4 active" data-toggle="tab" href="#tab-overview-uptodate" role="tab">
<i class="fal fa-home text-success"></i> <span class="hidden-sm-down ml-1">即時資訊</span>
</a>
</li>
<li class="nav-item">
<a class="nav-link fs-lg px-4" data-toggle="tab" href="#tab-overview-info" role="tab">
<i class="fal fa-home text-success"></i> <span class="hidden-sm-down ml-1">基本資料</span>
</a>
</li>
<li class="nav-item">
<a class="nav-link fs-lg px-4" data-toggle="tab" href="#tab-overview-history" role="tab">
<i class="fal fa-home text-success"></i> <span class="hidden-sm-down ml-1">歷史資料</span>
</a>
</li>
<li class="nav-item">
<a class="nav-link fs-lg px-4" data-toggle="tab" href="#tab-overview-inverter" role="tab">
<i class="fal fa-home text-success"></i> <span class="hidden-sm-down ml-1">逆變器分析</span>
</a>
</li>
<li class="nav-item">
<a class="nav-link fs-lg px-4" data-toggle="tab" href="#tab-overview-exception" role="tab">
<i class="fal fa-home text-success"></i> <span class="hidden-sm-down ml-1">異常記錄</span>
</a>
</li>
<li class="nav-item">
<a class="nav-link fs-lg px-4" data-toggle="tab" href="#tab-overview-operationRecord" role="tab">
<i class="fal fa-home text-success"></i> <span class="hidden-sm-down ml-1">運維記錄</span>
</a>
</li>
</ul>
<div class="tab-content p-3">
<div class="tab-pane fade show active" id="tab-overview-uptodate" role="tabpanel" aria-labelledby="tab-overview-uptodate">
@Html.Partial("_UpToDate")
</div>
<div class="tab-pane fade" id="tab-overview-info" role="tabpanel" aria-labelledby="tab-overview-info">
@Html.Partial("_Info")
</div>
<div class="tab-pane fade" id="tab-overview-history" role="tabpanel" aria-labelledby="tab-overview-history">
@Html.Partial("_History")
</div>
<div class="tab-pane fade" id="tab-overview-inverter" role="tabpanel" aria-labelledby="tab-overview-inverter">
@Html.Partial("_Inverter")
</div>
<div class="tab-pane fade" id="tab-overview-exception" role="tabpanel" aria-labelledby="tab-overview-exception">
@Html.Partial("_Exception")
</div>
<div class="tab-pane fade" id="tab-overview-operationRecord" role="tabpanel" aria-labelledby="tab-overview-operationRecord">
@Html.Partial("_OperationRecord")
</div>
</div>
</div>
</div>
</div>
</div>
</div>
@section Scripts{
<script>
var powerids = new Array(0);//當前選擇電站
var Type = 0; // 項目
var stationId;
var powerStationData;
var recode;
var selected_work_type = -1;
$(function () {
var url = new URL(location.href);
stationId = url.searchParams.get('stationId');
var url = "/PowerStation/GetOnePowerStation"
var send_data = {
id: stationId
}
$.post(url, send_data, function (rel) {
if (rel.code != "0000") {
toast_error(rel.msg);
return;
}
powerStationData = rel.data;
$(".city-name").html(powerStationData.cityName);
$(".power-station-name").html(powerStationData.name);
$("#power-station-title").html(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');
}, 'json');
//#region Date Picker
datepicker = $('#date-range-record').daterangepicker({
autoUpdateInput: false,
locale: { format: 'YYYY/MM/DD' },
opens: 'left'
}, function (start, end, label) {
@* console.log("A new date selection was made: " + start.format('YYYY-MM-DD') + ' to ' + end.format('YYYY-MM-DD'));*@
});
$('#date-range-record').on('apply.daterangepicker', function (ev, picker) {
$(this).val(picker.startDate.format('YYYY/MM/DD') + ' - ' + picker.endDate.format('YYYY/MM/DD'));
$(this).trigger('change');
});
$('#date-range-record').on('cancel.daterangepicker', function (ev, picker) {
$(this).val('');
$(this).trigger('change');
});
//#endregion
//#region 運維作業記錄 DataTable
powerids.push(stationId);
operationRecodeTable = $("#operation_recode_table").DataTable({
"pageLength": 20,
"paging": true,
"lengthChange": false,
"searching": false,
"ordering": false,
"info": true,
"autoWidth": false,
"responsive": true,
"columns": [{
"data": "powerStationName"
}, {
"data": "formId"
}, {
"data": "workTypeText"
}, {
"data": "fixDo"
}, {
"data": "statusText"
}, {
"data": "workPersonName"
}, {
"data": "operationPredict"
}, {
"data": "recodeFiles"
}, {
"data": "finishTime"
}],
"columnDefs": [{
'targets': 7,
'searchable': false,
'orderable': false,
'className': 'dt-body-center img-zoom-div',
'createdCell': function (td, cellData, rowData, row, col) {
$(td).empty();
$(td).append('<div class="row"></div>');
if (cellData != null) {
cellData.forEach(function (value, index) {
CreateRecodeFileBox($(td).children(".row"), value, false);
});
}
}
}],
"language": {
"emptyTable": "無資料...",
"processing": "處理中...",
"loadingRecords": "載入中...",
"lengthMenu": "顯示 _MENU_ 項結果",
"zeroRecords": "沒有符合的結果",
"info": "顯示第 _START_ 至 _END_ 項結果,共 _TOTAL_ 項",
"infoEmpty": "顯示第 0 至 0 項結果,共 0 項",
"infoFiltered": "(從 _MAX_ 項結果中過濾)",
"infoPostFix": "",
"search": "搜尋:",
"paginate": {
"first": "第一頁",
"previous": "上一頁",
"next": "下一頁",
"last": "最後一頁"
},
"aria": {
"sortAscending": ": 升冪排列",
"sortDescending": ": 降冪排列"
}
},
'createdRow': function (row, data, dataIndex) {
$(row).attr('data-id', data.id);
$(row).attr('data-work-type', data.workType);
},
"ajax": {
"url": "/Operation/OperationRecodeList",
"type": "POST",
"data": function (d) {
d.PowerStationIds = powerids;
d.WorkType = Type;
d.Range = $('#date-range').val();
},
"dataSrc": function (rel) {
if (rel.data.code == "9999") {
toast_error(rel.data.msg);
return;
}
data = rel.data.data;
if (data == null || data.length == 0) {
this.data = [];
}
return data;
}
}
});
//#endregion
//#region 切換電站時,載入該電站運維人員
$("#power_station_select_modal").change(function () {
//查詢該電站的運維人員
var url_power_station_operation_personnel = "/PowerStation/GetOperationPersonnelSelectOptionList";
send_data = {
PowerStationId: stationId
}
$.post(url_power_station_operation_personnel, send_data, function (rel) {
if (rel.code != "0000") {
toast_error(rel.msg);
return;
}
$("#work_person_select_modal").empty();
if (rel.data.length > 0) {
$.each(rel.data, function (index, val) {
$("#work_person_select_modal").append($("<option />").val(val.value).text(val.text));
});
if (recode != null || recode != undefined) {
$("#work_person_select_modal").val(recode.workPersonId);
}
}
});
});
//#endregion
});
//#region 改變日期
$('#date-range-record').on('change', function () {
operationRecodeTable.ajax.reload();
});
//#endregion
//#region 改變項目
function ChangeType(type) {
Type = type;
for (var i = 0; i < 4; i++) {
var name = "button" + i;
document.getElementById(name).setAttribute("class", "btn btn-secondary waves-effect waves-themed");
}
document.getElementById("button" + type).setAttribute("class", "btn btn-success waves-effect waves-themed");
operationRecodeTable.ajax.reload();
}
//#endregion
//#region 產生檔案html
function CreateRecodeFileBox(dom, value, show_del_btn) {
var str = "";
str += '<div class="col-auto px-0 py-2 mx-2">';
var split = value.fileName.split(".");
var excel_format = ["xls", "xlsx"];
var word_format = ["doc", "docx"];
if (split[split.length - 1].toLowerCase() == "pdf") {
str += '<a href="' + value.fileName + '" class="btn btn-info waves-effect waves-themed mb-3 mr-2" download><i class="fal fa-file-pdf" style="font-size: 1.5em; line-height: 2;"></i></a>';
} else if (excel_format.indexOf(split[split.length - 1].toLowerCase()) > -1) {
str += '<a href="' + value.fileName + '" class="btn btn-info waves-effect waves-themed mb-3 mr-2" download><i class="fal fa-file-excel" style="font-size: 1.5em; line-height: 2;"></i></a>';
} else if (word_format.indexOf(split[split.length - 1].toLowerCase()) > -1) {
str += '<a href="' + value.fileName + '" class="btn btn-info waves-effect waves-themed mb-3 mr-2" download><i class="fal fa-file-word" style="font-size: 1.5em; line-height: 2;"></i></a>';
} else {
str += '<img src="' + value.fileName + '" class="img-zoom" width="100%" />';
}
if (show_del_btn) {
str += '<a href="javascript:;" class="del-operation-recode-file-btn" data-id="' + value.id + '">';
str += '<span class="badge border border-light rounded-pill bg-danger-500 position-absolute pos-top pos-right"><i class="fal fa-times"></i></span>';
str += '</a>';
}
str += '</div>';
dom.append(str);
}
//#endregion
//#region 編輯表單內容
$('#operation_recode_table').on("click", "a.edit-btn", function () {
work_type = $(this).parents('tr').attr('data-work-type');
if (work_type == 0) {
$("#recode-form-modal .modal-title .main-title").html("清洗單 - ");
} else if (work_type == 1) {
$("#recode-form-modal .modal-title .main-title").html("巡檢單 - ");
} else {
$("#recode-form-modal .modal-title .main-title").html("維修單 - ");
}
selected_id = $(this).parents('tr').attr('data-id');
//取得單一記錄表單
var url = "/Operation/GetOneOperationRecode/";
var send_data = {
id: selected_id
}
$.post(url, send_data, function (rel) {
if (rel.code != "0000") {
toast_error(rel.msg);
return;
}
recode = rel.data;
countOperationRecodeFile = recode.recodeFiles.length;
$("#recode-form-modal .modal-title .sub-title").html(recode.powerStationName);
$("#power_station_select_modal").val(recode.powerStationId);
$("#power_station_select_modal").attr("disabled", true);
$("#work_time_modal").val(recode.workTime);
var status = -1;
if (recode.status == 0 || recode.status == 2) {
status = 0;
} else if (recode.status == 1 || recode.status == 3) {
status = 1;
}
$("input[name=status_modal][value='" + status + "']").prop('checked', true); //狀態
$('#work_person_select_modal').val(recode.workPersonId);
if (work_type != 2) {
$(".fix-div").hide();
} else {
$(".fix-div").show();
$("#error_code_modal").val(recode.errorCode);
$("#fix_do_modal").val(recode.fixDo);
}
$("#notice_textarea_modal").val(recode.notice);
$("#description_textarea_modal").val(recode.description);
var str = "";
RecodeFileBox = $("#recode_files_div > .row");
RecodeFileBox.empty();
recode.recodeFiles.forEach(function (value, index) {
CreateRecodeFileBox(RecodeFileBox, value, true);
});
$("#recode-form-modal").modal();
}, 'json');
});
//#endregion
//#region 表單檔案資料
Dropzone.autoDiscover = false;
recodeFileDropzone = new Dropzone("#recode-file-form", {
url: "/Operation/SaveOperationRecodeFile",
acceptedFiles: "image/*, application/pdf,.doc,.docx,.xls,.xlsx",
autoProcessQueue: false,
parallelUploads: 5,
maxFiles: 5,
addRemoveLinks: true,
uploadMultiple: true,
dictRemoveFile: "移除",
init: function (e) {
var myDropzone = this;
myDropzone.on("sending", function (file, xhr, data) {
if ((countOperationRecodeFile + myDropzone.files.length) > 5) {
toast_warning("檔案總數量不可超過 5 張");
myDropzone.removeFile(file);
return;
} else {
data.append("Id", selected_id);
data.append("RecodeFiles", file);
}
});
}
});
//#endregion
//#region 查詢近30天
function ChangeDate30() {
var today = new Date();
var dateLimit = new Date(new Date().setDate(today.getDate() - 30));
var today_format = today.toISOString().slice(0, 10).replace(/-/g, "/");
var dateLimit_format = dateLimit.toISOString().slice(0, 10).replace(/-/g, "/");
datepicker.data('daterangepicker').setStartDate(dateLimit_format);
datepicker.data('daterangepicker').setEndDate(today_format);
$('#date-range-record').val(dateLimit_format + ' - ' + today_format);
$('#date-range-record').trigger('change');
}
//#endregion
//#region 儲存表單資料
function SaveRecode() {
if ($("#recode-form").valid()) {
var url = "/Operation/SaveOperationRecode";
var formData = new FormData();
formData.append("Id", selected_id);
formData.append("PowerStationId", $("#power_station_select_modal").val());
formData.append("WorkType", selected_work_type);
formData.append("ErrorCode", $("#error_code_modal").val());
formData.append("FixDo", $("#fix_do_modal").val());
formData.append("Status", $("input[name=status_modal]:checked").val());
formData.append("WorkPersonId", $("#work_person_select_modal").val());
formData.append("WorkTime", $("#work_time_modal").val());
formData.append("Notice", $("#notice_textarea_modal").val());
formData.append("Description", $("#description_textarea_modal").val());
$.ajax({
type: "POST",
url: url,
data: formData,
cache: false,
contentType: false,
processData: false,
success: function (rel) {
if (rel.code != "0000") {
toast_error(rel.msg);
return;
}
var myDropzone = Dropzone.forElement("#recode-file-form");
if (myDropzone.files.length > 0) {
myDropzone.processQueue();
myDropzone.on("successmultiple", function (file, rel) {
if (rel.code != "0000") {
toast_error(rel.msg);
return;
}
toast_ok(rel.msg);
$('#recode-form-modal').modal('hide');
recodeFileDropzone.removeAllFiles();
operationRecodeTable.ajax.reload();
});
} else {
$('#recode-form-modal').modal('hide');
myDropzone.removeAllFiles();
operationRecodeTable.ajax.reload();
}
}
});
}
}
//#endregion
//#region 點擊圖片放大
$('#operation_recode_table').on("click", "img.img-zoom", function () {
var _this = $(this);//將當前的pimg元素作為_this傳入函式
imgShow("#img-zoom-outer-div", "#innerdiv", "#bigimg", _this);
});
//#endregion
//#region 匯出excel
function ExportExcel() {
var url = "/Operation/ExportOperationRecodeExcel";
var send_data = {
CityIds: [3],
PowerStationIds: powerids
};
$.post(url, send_data, function (rel) {
if (rel.code != "0000") {
toast_error(rel.msg);
return;
}
$('#NoViewbody').empty();
var str = "";
rel.data.forEach(function (value, index) {
str += "<tr>" +
"<td>" + value.powerStationName + "</td>" +
"<td>" + value.formId + "</td>" +
"<td>" + value.workTypeText + "</td>" +
"<td>" + value.fixDo + "</td>" +
"<td>" + value.statusText + "</td>" +
"<td>" + value.workPersonName + "</td>" +
"<td>" + value.operationPredict + "</td>";
str += "<td>";
if (value.hyperLinks != undefined || value.hyperLinks != null) {
value.hyperLinks.forEach(function (value2, index) {
str += value2 + "<br>";
});
}
str += "</td>";
str += "<td>";
if (value.finishTime != undefined || value.finishTime != null || value.finishTime != "") {
//value.hyperLinks.forEach(function (value3, index) {
// str += value3;
//});
str += value.finishTime;
}
str += "</td>";
str += "</tr>";
});
$('#NoViewbody').append(str);
$("#NoView").table2excel({
// 匯出的Excel文件的名稱
name: "abc",
// Excel檔案的名稱
filename: "test",
//檔案字尾名
fileext: ".xls",
});
}, 'json');
}
//#endregion
</script>
}