2022-12-07 09:25:43 +08:00
|
|
|
<main id="js-page-content" role="main" class="page-content">
|
2022-12-08 18:26:23 +08:00
|
|
|
<div class="row">
|
|
|
|
<div class="col-sm-12 col-xl-12">
|
|
|
|
<h1 class="p-2 mb-0">即時告警</h1>
|
|
|
|
<div class="row bg-dark p-2">
|
|
|
|
<div class="col-auto">
|
|
|
|
<div class="btn-group">
|
|
|
|
<button id="returnFalse" onclick="setReturn(false)" type="button" class="btn btn-secondary waves-effect waves-themed">未復歸</button>
|
|
|
|
<button id="returnTrue" onclick="setReturn(true)" type="button" class="btn btn-secondary waves-effect waves-themed">已復歸</button>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="col-auto">
|
|
|
|
<div class="btn-group">
|
|
|
|
<button id="unconfirmed" onclick="setConfirm(false)" type="button" class="btn btn-secondary waves-effect waves-themed">未確認</button>
|
|
|
|
<button id="confirmed" onclick="setConfirm(true)" type="button" class="btn btn-secondary waves-effect waves-themed">已確認</button>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="col-auto">
|
|
|
|
<a href="#" id="nearthirty" class="btn btn-secondary">近30天</a>
|
|
|
|
</div>
|
|
|
|
<div class="col-auto">
|
|
|
|
<div class="form-group">
|
|
|
|
<input class="form-control" id="alr_startdate" data-val="" type="date" name="alr_startdate" value="" style="cursor: pointer">
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="col-auto">
|
|
|
|
<div class="form-group">
|
|
|
|
<input class="form-control" id="alr_enddate" data-val="" type="date" name="alr_enddate" value="" style="cursor: pointer">
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<hr>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
<div class="row bg-dark p-2 align-items-center" id="alr_mainList">
|
|
|
|
</div>
|
|
|
|
<div class="row bg-dark p-2 mb-5 align-items-center" id="alr_subList">
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div>
|
|
|
|
<div class="frame-wrap">
|
|
|
|
<table id="alertTable" class="table table-bordered table-striped text-center m-0 w-100">
|
|
|
|
</table>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
2022-12-07 09:25:43 +08:00
|
|
|
</main>
|
|
|
|
|
2022-12-08 18:26:23 +08:00
|
|
|
<!-- Modal center 保養/維修 -->
|
|
|
|
<div class="modal fade" id="alr_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-content">
|
|
|
|
<div class="modal-header">
|
|
|
|
<h4 id="opeRecTitle" class="modal-title">
|
|
|
|
新增維修單
|
|
|
|
</h4>
|
|
|
|
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
|
|
|
<span aria-hidden="true"><i class="fal fa-times"></i></span>
|
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
<form id="opeRecForm">
|
|
|
|
<div class="modal-body">
|
|
|
|
<div class="row">
|
|
|
|
<div class="col-md-6">
|
|
|
|
<div class="form-group">
|
|
|
|
<label class="form-label" for="inpErrCode">異常編號</label>
|
|
|
|
<select class="form-control" id="inpErrCode" name="inpErrCode" disabled>
|
|
|
|
<option value=''>未選擇</option>
|
|
|
|
</select>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="col-md-6">
|
|
|
|
<div class="form-group">
|
|
|
|
<label class="form-label" for="inpStaTime">預計開始時間</label>
|
|
|
|
<input type="date" id="inpStaTime" name="inpStaTime" class="form-control">
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="col-md-6">
|
|
|
|
<div class="form-group">
|
|
|
|
<label class="form-label" for="inpWorTyp">項目</label>
|
|
|
|
<select class="form-control custom-select-ri" id="inpWorTyp" name="inpWorTyp" disabled>
|
2022-12-10 16:23:02 +08:00
|
|
|
<option value='2' selected>維修</option>
|
2022-12-08 18:26:23 +08:00
|
|
|
</select>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="col-md-6">
|
|
|
|
<div class="form-group">
|
|
|
|
<label class="form-label" for="inpFixDo">維修項目</label>
|
|
|
|
<input type="text" id="inpFixDo" name="inpFixDo" class="form-control">
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="col-md-6">
|
|
|
|
<div class="form-group">
|
|
|
|
<label class="form-label" for="inpFixDoCode">維修項目代碼(設備編號)</label>
|
2022-12-09 15:37:15 +08:00
|
|
|
<select class="form-control" id="inpFixDoCode" name="inpFixDoCode">
|
2022-12-08 18:26:23 +08:00
|
|
|
<option value=''>未選擇</option>
|
|
|
|
</select>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="col-md-6">
|
|
|
|
<div class="form-group">
|
|
|
|
<label class="form-label" for="inpFixFirm">負責廠商</label>
|
|
|
|
<select class="form-control" id="inpFixFirm" name="inpFixFirm">
|
|
|
|
<option value=''>未選擇</option>
|
|
|
|
</select>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="col-md-6">
|
|
|
|
<div class="form-group">
|
|
|
|
<label class="form-label" for="inpStatus">狀態</label>
|
|
|
|
<div class="form-control" id="inpStatus">
|
|
|
|
<div class="row container">
|
|
|
|
<div class="">
|
|
|
|
<input class="custom-radio-input" type="radio" name="inpSta" id="inpSta_0" value="0" checked>
|
|
|
|
<label class="form-label" for="inpSta_0">未完成</label>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="px-4">
|
|
|
|
<input class="custom-radio-input" type="radio" name="inpSta" id="inpSta_1" value="1">
|
|
|
|
<label class="form-label" for="inpSta_1">完成</label>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="col-md-6">
|
|
|
|
<div class="form-group">
|
|
|
|
<label class="form-label" for="inpWorPerId">工作人員編號</label>
|
|
|
|
<select class="form-control" id="inpWorPerId" name="inpWorPerId">
|
|
|
|
<option value=''>未選擇</option>
|
|
|
|
</select>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="col-md-12">
|
|
|
|
<div class="form-group">
|
|
|
|
<label class="form-label" for="inpNotice">注意事項</label>
|
|
|
|
<textarea class="form-control" type="text" id="inpNotice" name="inpNotice" rows="7"></textarea>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="col-md-12">
|
|
|
|
<div class="form-group">
|
|
|
|
<label class="form-label" for="inpDescription">結果描述</label>
|
|
|
|
<textarea class="form-control" type="text" id="inpDescription" name="inpDescription" rows="7"></textarea>
|
|
|
|
</div>
|
|
|
|
</div>
|
2022-12-09 15:37:15 +08:00
|
|
|
<div class="col-md-12">
|
2022-12-08 18:26:23 +08:00
|
|
|
<label class="form-label">上傳檔案</label>
|
2022-12-09 15:37:15 +08:00
|
|
|
<div id='alr_forImage' class="col-sm-12 forimage mt-2 p-0">
|
|
|
|
</div>
|
|
|
|
<div id='alr_forFile' class="col-sm-12 forfile mt-2 p-0">
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="form-group dropzone" id="alr_dropZone">
|
2022-12-08 18:26:23 +08:00
|
|
|
<div class="dz-message">
|
|
|
|
<div class="drag-icon-cph">
|
|
|
|
<i class="material-icons">backup</i>
|
|
|
|
</div>
|
|
|
|
<h3>選擇一個文件或拖放到這裡</h3>
|
|
|
|
<p class="mb-0 col-grey">
|
|
|
|
PDF檔案不超過 3MB
|
|
|
|
</p>
|
|
|
|
</div>
|
|
|
|
<div class="fallback">
|
|
|
|
<input name="file" type="file" multiple />
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="modal-footer">
|
|
|
|
<button type="button" class="btn btn-secondary" id="OpeRecCanBtn" data-dismiss="modal">關閉</button>
|
|
|
|
<button type="button" class="btn btn-primary" id="OpeRecSendBtn" e-prevent>儲存</button>
|
|
|
|
</div>
|
|
|
|
</form>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
2022-12-07 09:25:43 +08:00
|
|
|
<script>
|
2022-12-08 18:26:23 +08:00
|
|
|
pageAct.selSysMain = null;
|
|
|
|
pageAct.selSysSub = null;
|
|
|
|
pageAct.alr_startdate = null;
|
|
|
|
pageAct.alr_enddate = null;
|
2022-12-09 15:37:15 +08:00
|
|
|
pageAct.imageFile = [];
|
2022-12-08 18:26:23 +08:00
|
|
|
first = true;
|
|
|
|
|
|
|
|
$(function () {
|
2022-12-09 15:37:15 +08:00
|
|
|
initDropzone();
|
2022-12-08 18:26:23 +08:00
|
|
|
setReturn(false);
|
|
|
|
setConfirm(false);
|
|
|
|
event();
|
|
|
|
sysList();
|
|
|
|
$('#nearthirty').click();
|
|
|
|
|
|
|
|
$('#alr_mainList').on('click', 'a[data-type=alr_main]', function () {
|
|
|
|
$(this).parent().parent().find('a').removeClass('btn-info');
|
|
|
|
$(this).parent().parent().find('a').addClass('btn-secondary');
|
|
|
|
$(this).addClass('btn-info');
|
|
|
|
|
|
|
|
$('a[data-type=alr_sub]').parent().parent().find('a').removeClass('btn-info');
|
|
|
|
$('a[data-type=alr_sub]').parent().parent().find('a').addClass('btn-secondary');
|
|
|
|
|
|
|
|
pageAct.SysType = null;
|
|
|
|
});
|
|
|
|
|
|
|
|
$('#alr_subList, #alr_mainList').on('click', 'a[data-type=alr_sub][id!=selAllSys]', function () {
|
|
|
|
pageAct.selSysMain = $(this).parent().data('main');
|
|
|
|
pageAct.selSysSub = $(this).prop('id');
|
|
|
|
|
|
|
|
if ($('#selAllSys').hasClass('btn-info')) {
|
|
|
|
$('#selAllSys').removeClass('btn-info');
|
|
|
|
$('#selAllSys').addClass('btn-secondary');
|
|
|
|
$('#alr_mainList a[data-type=alr_main]').removeClass('btn-info');
|
|
|
|
$('#alr_mainList a[data-type=alr_main]').addClass('btn-secondary');
|
|
|
|
$(`#alr_mainList a[data-type=alr_main][id=` + pageAct.selSysMain + `]`).addClass('btn-info');
|
|
|
|
$('#alr_subList a[data-type=alr_sub]').parent().attr('hidden', true);
|
|
|
|
$('#alr_subList a[data-type=alr_sub]').parent('[data-main=' + pageAct.selSysMain + ']').attr('hidden', false);
|
|
|
|
}
|
|
|
|
|
|
|
|
$(this).parent().parent().find('a').removeClass('btn-info');
|
|
|
|
$(this).parent().parent().find('a').addClass('btn-secondary');
|
|
|
|
$(this).addClass('btn-info');
|
|
|
|
|
|
|
|
pageAct.SysType = null;
|
|
|
|
getData();
|
|
|
|
});
|
|
|
|
|
|
|
|
first = false;
|
|
|
|
});
|
|
|
|
|
|
|
|
function event() {
|
|
|
|
onEvent('click', '#nearthirty', function () {
|
|
|
|
let today = displayDate(new Date(Date.now()), "date").replaceAll('/', '-');
|
|
|
|
let thirtyDays = displayDate(new Date(new Date().setDate(new Date(Date.now()).getDate() - 30)), "date").replaceAll('/', '-');
|
|
|
|
$('#alr_startdate').val(thirtyDays);
|
|
|
|
$('#alr_startdate').data('val', thirtyDays);
|
|
|
|
$('#alr_enddate').val(today);
|
|
|
|
$('#alr_enddate').data('val', today);
|
|
|
|
if (!$(this).hasClass('btn-info'))
|
|
|
|
elemSelCol($(this));
|
|
|
|
|
|
|
|
pageAct.alr_startdate = $("#alr_startdate").val();
|
|
|
|
pageAct.alr_enddate = $("#alr_enddate").val();
|
|
|
|
getData();
|
|
|
|
});
|
|
|
|
|
|
|
|
onEvent('change', '#alr_startdate, #alr_enddate', function () {
|
|
|
|
if ($('#alr_startdate').val() > $('#alr_enddate').val()) {
|
|
|
|
$('#alr_startdate').val($('#alr_startdate').data('val'));
|
|
|
|
$('#alr_enddate').val($('#alr_enddate').data('val'));
|
|
|
|
toast_error('不可選擇大於結束時間');
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
let today = displayDate(new Date(Date.now()), "date").replaceAll('/', '-');
|
|
|
|
let alr_enddate = displayDate(new Date(new Date().setDate(new Date($('#alr_enddate').val()).getDate() - 30)), "date").replaceAll('/', '-');
|
|
|
|
let alr_startdate = $('#alr_startdate').val();
|
|
|
|
if (alr_enddate == alr_startdate && $('#alr_enddate').val() == today) {
|
|
|
|
$('#nearthirty').click();
|
|
|
|
}
|
|
|
|
else {
|
2022-12-07 09:25:43 +08:00
|
|
|
$('#nearthirty').removeClass('btn-info');
|
|
|
|
$('#nearthirty').addClass('btn-secondary');
|
|
|
|
}
|
|
|
|
|
2022-12-08 18:26:23 +08:00
|
|
|
$('#alr_startdate').data('val', $('#alr_startdate').val());
|
|
|
|
$('#alr_enddate').data('val', $('#alr_enddate').val());
|
2022-12-07 09:25:43 +08:00
|
|
|
}
|
|
|
|
|
2022-12-08 18:26:23 +08:00
|
|
|
pageAct.alr_startdate = $("#alr_startdate").val();
|
|
|
|
pageAct.alr_enddate = $("#alr_enddate").val();
|
|
|
|
getData();
|
|
|
|
});
|
|
|
|
|
|
|
|
onEvent('click', 'a[data-type=alr_main]', function () {
|
|
|
|
$(`a[data-type=alr_sub]`).parent(`[data-main!=` + $(this).prop('id') + `]`).attr('hidden', true);
|
|
|
|
$(`a[data-type=alr_sub]`).parent(`[data-main=` + $(this).prop('id') + `]`).attr('hidden', false);
|
|
|
|
});
|
|
|
|
|
|
|
|
onEvent('click', '#alertTable a[id=alr_recModal]', function () {
|
2022-12-10 16:23:02 +08:00
|
|
|
$('#alr_forImage').html('');
|
|
|
|
$('#alr_forFile').html('');
|
|
|
|
$('#inpNotice').val('');
|
|
|
|
$('#inpDescription').val('');
|
2022-12-08 18:26:23 +08:00
|
|
|
let alr_table = $('#alertTable').DataTable();
|
|
|
|
let alr_elem = $(this).parent().parent();
|
|
|
|
let alr_tableData = alr_table.row(alr_elem).data();
|
|
|
|
$('#inpErrCode').html(`<option value = ${alr_tableData.uuid}>${alr_tableData.msgText}</option>`);
|
|
|
|
$('#inpStaTime').val(displayDate(new Date(Date.now()), "date").replaceAll('/', '-'));
|
|
|
|
let deviceNumber = null
|
|
|
|
|
|
|
|
deviceNumber = pageAct.AreaTag + "_" + alr_tableData.buildingFloorName_zh.toString().split('-')[0] + "_" + alr_tableData.alarmClass.toString().split('_')[0] + "_"
|
|
|
|
+ alr_tableData.alarmClass.toString().split('_')[1] + "_" + alr_tableData.buildingFloorName_zh.toString().split('-')[1] + "_" + alr_tableData.sourceName_zh.toString().split('-')[0] + "_"
|
|
|
|
+ alr_tableData.sourceName_zh.toString().split('-')[1];
|
|
|
|
|
|
|
|
selUser();
|
|
|
|
selDevice();
|
|
|
|
selOpeFir();
|
2022-12-09 15:37:15 +08:00
|
|
|
|
|
|
|
$('#inpFixDoCode option[data-sub=' + alr_tableData.alarmClass.toString().split('_')[1] + '][data-main=' + alr_tableData.alarmClass.toString().split('_')[0] + ']').attr('hidden', false);
|
|
|
|
$('#inpFixDoCode option[data-sub!=' + alr_tableData.alarmClass.toString().split('_')[1] + '][data-main!=' + alr_tableData.alarmClass.toString().split('_')[0] + ']').attr('hidden', true);
|
|
|
|
|
|
|
|
let alr_fixDoCode = $($('#inpFixDoCode option[data-sub=' + alr_tableData.alarmClass.toString().split('_')[1] + '][data-main=' + alr_tableData.alarmClass.toString().split('_')[0] + ']')[0]).val();
|
|
|
|
$('#inpFixDoCode').val(alr_fixDoCode);
|
2022-12-08 18:26:23 +08:00
|
|
|
});
|
2022-12-10 16:23:02 +08:00
|
|
|
|
|
|
|
onEvent('click', '#OpeRecSendBtn', function () {
|
|
|
|
let form = $("#opeRecForm");
|
|
|
|
$(form).validate({
|
|
|
|
rules: {
|
|
|
|
inpWorTyp: { required: true },
|
|
|
|
inpFixDo: { required: true },
|
|
|
|
inpFixDoCode: { required: true },
|
|
|
|
inpFixFirm: { required: true },
|
|
|
|
inpStatus: { required: true },
|
|
|
|
inpWorPerId: { required: true },
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
if ($(form).valid()) {
|
|
|
|
let url = baseApiUrl + "/operation/SavOpeRecord";
|
|
|
|
|
|
|
|
let fd = new FormData();
|
|
|
|
$.each(pageAct.imageFile, function (i, v) {
|
|
|
|
fd.append("lorf[" + i + "].id", v.id);
|
|
|
|
fd.append("lorf[" + i + "].file", v.file);
|
|
|
|
fd.append("lorf[" + i + "].save_file_name", v.save_file_name);
|
|
|
|
fd.append("lorf[" + i + "].ori_file_name", v.ori_file_name);
|
|
|
|
});
|
|
|
|
|
|
|
|
fd.append("error_code", $('#inpErrCode').val());
|
|
|
|
fd.append("location", "台北" + $('#buiActDrop').text() + pageAct.floor);
|
|
|
|
fd.append("location_code", pageAct.AreaTag + pageAct.buiTag + pageAct.floor);
|
|
|
|
fd.append("device_system_category_layer2", pageAct.selSysMain);
|
|
|
|
fd.append("device_system_category_layer3", pageAct.selSysSub);
|
|
|
|
fd.append("work_type", parseInt($('#inpWorTyp').val()));
|
|
|
|
fd.append("fix_do", $('#inpFixDo').val());
|
|
|
|
fd.append("fix_do_code", $('#inpFixDoCode').val());
|
|
|
|
fd.append("fix_firm", parseInt($('#inpFixFirm').val()));
|
|
|
|
fd.append("status", parseInt($('#inpStatus').val()));
|
|
|
|
fd.append("work_person_id", $('#inpWorPerId').val());
|
|
|
|
fd.append("start_time", ($('#inpStaTime').val() || null) == null ? null : new Date($('#inpStaTime').val()).toISOString());
|
|
|
|
fd.append("notice", $('#inpNotice').val() || null);
|
|
|
|
fd.append("description", $('#inpDescription').val() || null);
|
|
|
|
|
|
|
|
objSendData.Data = sendData;
|
|
|
|
$.ajax({
|
|
|
|
url: url,
|
|
|
|
type: "POST",
|
|
|
|
data: fd,
|
|
|
|
async: false,
|
|
|
|
cache: false,
|
|
|
|
contentType: false,
|
|
|
|
processData: false,
|
|
|
|
beforeSend: function (xhr) { xhr.setRequestHeader('Authorization', "Bearer " + localStorage.getItem("JWT-Authorization")) },
|
|
|
|
success: function (res) {
|
|
|
|
if (!res || res.code != "0000" || !res.data) {
|
|
|
|
|
|
|
|
} else {
|
|
|
|
//toast_ok(common.AddSuc);
|
|
|
|
//$("#opeFirmModal").modal("hide");
|
|
|
|
$("#OpeRecCanBtn").click();
|
|
|
|
getData();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
//ytAjax = new YourTeam.Ajax(url, objSendData, function (res) {
|
|
|
|
// if (!res || res.code != "0000" || !res.data) {
|
|
|
|
|
|
|
|
// } else {
|
|
|
|
// //toast_ok(common.AddSuc);
|
|
|
|
// //$("#opeFirmModal").modal("hide");
|
|
|
|
// $("#OpeRecCanBtn").click();
|
|
|
|
// refTable();
|
|
|
|
// }
|
|
|
|
//}, null, "POST").send();
|
|
|
|
}
|
|
|
|
});
|
2022-12-08 18:26:23 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
function setReturn(bool) {
|
|
|
|
pageAct.return = bool;
|
2022-12-07 09:25:43 +08:00
|
|
|
$('#returnFalse').removeClass('btn-info');
|
|
|
|
$('#returnTrue').removeClass('btn-info');
|
2022-12-08 18:26:23 +08:00
|
|
|
if (!bool) {
|
|
|
|
$('#returnFalse').removeClass('btn-secondary');
|
|
|
|
$('#returnFalse').addClass('btn-info');
|
2022-12-07 09:25:43 +08:00
|
|
|
$('#returnTrue').addClass('btn-secondary');
|
2022-12-08 18:26:23 +08:00
|
|
|
}
|
|
|
|
else {
|
2022-12-07 09:25:43 +08:00
|
|
|
$('#returnTrue').removeClass('btn-secondary');
|
2022-12-08 18:26:23 +08:00
|
|
|
$('#returnTrue').addClass('btn-info');
|
2022-12-07 09:25:43 +08:00
|
|
|
$('#returnFalse').addClass('btn-secondary');
|
|
|
|
}
|
|
|
|
|
2022-12-08 18:26:23 +08:00
|
|
|
if (!first)
|
|
|
|
getData();
|
|
|
|
}
|
|
|
|
|
|
|
|
function setConfirm(bool) {
|
|
|
|
pageAct.confirm = bool;
|
|
|
|
$('#unconfirmed').removeClass('btn-info');
|
2022-12-07 09:25:43 +08:00
|
|
|
$('#confirmed').removeClass('btn-info');
|
2022-12-08 18:26:23 +08:00
|
|
|
if (!bool) {
|
|
|
|
$('#unconfirmed').removeClass('btn-secondary');
|
|
|
|
$('#unconfirmed').addClass('btn-info');
|
2022-12-07 09:25:43 +08:00
|
|
|
$('#confirmed').addClass('btn-secondary');
|
2022-12-08 18:26:23 +08:00
|
|
|
}
|
|
|
|
else {
|
2022-12-07 09:25:43 +08:00
|
|
|
$('#confirmed').removeClass('btn-secondary');
|
2022-12-08 18:26:23 +08:00
|
|
|
$('#confirmed').addClass('btn-info');
|
2022-12-07 09:25:43 +08:00
|
|
|
$('#unconfirmed').addClass('btn-secondary');
|
|
|
|
}
|
2022-12-08 18:26:23 +08:00
|
|
|
|
|
|
|
if (!first)
|
|
|
|
getData();
|
2022-12-07 09:25:43 +08:00
|
|
|
}
|
|
|
|
|
2022-12-08 18:26:23 +08:00
|
|
|
function elemSelCol(elem) {
|
|
|
|
if (elem.hasClass('btn-secondary')) {
|
2022-12-07 09:25:43 +08:00
|
|
|
$(elem).removeClass('btn-secondary');
|
2022-12-08 18:26:23 +08:00
|
|
|
$(elem).addClass('btn-info');
|
|
|
|
}
|
|
|
|
else if (elem.hasClass('btn-info')) {
|
2022-12-07 09:25:43 +08:00
|
|
|
$(elem).removeClass('btn-info');
|
|
|
|
$(elem).addClass('btn-secondary');
|
|
|
|
}
|
|
|
|
}
|
2022-12-08 18:26:23 +08:00
|
|
|
|
|
|
|
function sysList() {
|
|
|
|
let url = baseApiUrl + "/api/GetMainSub";
|
|
|
|
let sendData = {
|
|
|
|
building_tag: pageAct.buiTag
|
|
|
|
}
|
|
|
|
objSendData.Data = sendData;
|
|
|
|
function success(res) {
|
|
|
|
let mainStrHtml = ``;
|
|
|
|
let subStrHtml = ``;
|
|
|
|
let display = pageAct.mainStatus ? "hidden" : "";
|
|
|
|
|
|
|
|
if (pageAct.mainStatus) {
|
|
|
|
mainStrHtml += `<div class="col-auto">
|
|
|
|
<a href="#" id="selAllSys" onclick="selAllSysVal(this)" class="btn btn-secondary">全部類別</a>
|
|
|
|
</div>`;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
subStrHtml += `<div class="col-auto">
|
|
|
|
<a href="#" id="selAllSys" onclick="selAllSysVal(this)" class="btn btn-secondary">全部類別</a>
|
|
|
|
</div>`;
|
|
|
|
}
|
|
|
|
|
|
|
|
$.each(res.data.history_Main_Systems, function (i, v) {
|
|
|
|
if (pageAct.mainStatus) {
|
|
|
|
mainStrHtml += `<div class="col-auto">
|
|
|
|
<a href="#" class="btn btn-secondary" id=${v.main_system_tag} data-type="alr_main">${v.full_name}</a>
|
|
|
|
</div>`;
|
|
|
|
}
|
|
|
|
|
|
|
|
$.each(v.history_Sub_systems, function (i2, v2) {
|
|
|
|
let selected = (i2 == 0 && i == 0) ? "info" : "secondary";
|
|
|
|
subStrHtml += `<div class="col-auto" data-main="${v.main_system_tag}" ${display}>
|
|
|
|
<a href="#" class="btn btn-${selected}" id="${v2.sub_system_tag}" data-type="alr_sub">${v2.full_name}</a>
|
|
|
|
</div>`;
|
|
|
|
|
|
|
|
if (i2 == 0 && i == 0) {
|
|
|
|
pageAct.selSysSub = v2.sub_system_tag;
|
|
|
|
pageAct.selSysMain = v.main_system_tag;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
if (pageAct.mainStatus) {
|
|
|
|
$('#alr_mainList').html(mainStrHtml);
|
|
|
|
$('#alr_subList').html(subStrHtml);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$('#alr_mainList').html(subStrHtml);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ytAjax = new YourTeam.Ajax(url, objSendData, success, null, "POST").send();
|
|
|
|
}
|
|
|
|
|
|
|
|
function selAllSysVal(elem) {
|
|
|
|
$(elem).parent().parent().find('a').removeClass('btn-secondary');
|
|
|
|
$(elem).parent().parent().find('a').addClass('btn-info');
|
|
|
|
|
|
|
|
if ($('a[data-type=alr_sub]').length > 0) {
|
|
|
|
$('a[data-type=alr_sub]').parent().attr('hidden', false);
|
|
|
|
$('a[data-type=alr_sub]').parent().parent().find('a').removeClass('btn-secondary');
|
|
|
|
$('a[data-type=alr_sub]').parent().parent().find('a').addClass('btn-info');
|
|
|
|
}
|
|
|
|
|
|
|
|
pageAct.SysType = 'all';
|
|
|
|
getData();
|
|
|
|
}
|
|
|
|
|
|
|
|
function getData(type = null) {
|
|
|
|
$(loadEle).Loading("start");
|
|
|
|
|
|
|
|
let enddate = new Date(new Date().setDate(new Date(pageAct.alr_enddate).getDate() + 1)).getTime();
|
|
|
|
|
|
|
|
if (pageAct.SysType == "all") {
|
|
|
|
getAllDeviceAlarmByBaja(new Date(pageAct.alr_startdate).getTime(), enddate, pageAct.return, pageAct.confirm, callBackFromAllDeviceAlert);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
getAlarmByBaja(new Date(pageAct.alr_startdate).getTime(), enddate, pageAct.return, pageAct.confirm, pageAct.selSysMain + "_" + pageAct.selSysSub + "_AlarmClass", callBackFromOneDeviceAlert);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function callBackFromAllDeviceAlert(res) {
|
|
|
|
res = JSON.parse(res);
|
|
|
|
refTable(res.data);
|
|
|
|
if (historyTable != null) {
|
|
|
|
let t = $('#alertTable').dataTable();
|
|
|
|
|
|
|
|
t.fnClearTable();
|
|
|
|
if (res.data.length > 0)
|
|
|
|
t.fnAddData(res.data);
|
|
|
|
}
|
|
|
|
$(loadEle).Loading("close");
|
|
|
|
}
|
|
|
|
|
|
|
|
function callBackFromOneDeviceAlert(res) {
|
|
|
|
res = JSON.parse(res);
|
|
|
|
refTable(res.data);
|
|
|
|
if (historyTable != null) {
|
|
|
|
let t = $('#alertTable').dataTable();
|
|
|
|
|
|
|
|
t.fnClearTable();
|
|
|
|
if (res.data.length > 0)
|
|
|
|
t.fnAddData(res.data);
|
|
|
|
}
|
|
|
|
$(loadEle).Loading("close");
|
|
|
|
}
|
|
|
|
|
|
|
|
function refTable(data) {
|
|
|
|
let tag = "#alertTable";
|
|
|
|
$.each(data, function (i, v) {
|
|
|
|
v.formId = AlertList(v.uuid);
|
|
|
|
});
|
|
|
|
|
|
|
|
let column_defs = [
|
|
|
|
{ "targets": [0], "width": "5%", "sortable": true },
|
|
|
|
{ "targets": [1], "width": "5%", "sortable": true },
|
|
|
|
{ "targets": [2], "width": "5%", "sortable": true },
|
|
|
|
{ "targets": [3], "width": "5%", "sortable": true },
|
|
|
|
{ "targets": [4], "width": "5%", "sortable": true },
|
|
|
|
{ "targets": [5], "width": "5%", "sortable": true },
|
|
|
|
{ "targets": [6], "width": "5%", "sortable": true },
|
|
|
|
{ "targets": [7], "width": "5%", "sortable": true },
|
|
|
|
];
|
|
|
|
|
|
|
|
let columns = [
|
|
|
|
{
|
|
|
|
"title": "棟別-樓層",
|
|
|
|
"data": "buildingFloorName_zh"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"title": "異常ID",
|
|
|
|
"data": "uuid",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"title": "發生時間",
|
|
|
|
"data": "timestamp",
|
|
|
|
"render": function (data) {
|
|
|
|
return displayDate(data, "datetime");
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"title": "異常類別",
|
|
|
|
"data": "alarmClass",
|
|
|
|
"render": function (data) {
|
2022-12-09 15:37:15 +08:00
|
|
|
return data.split('_')[0] + "-" + data.split('_')[1];
|
2022-12-08 18:26:23 +08:00
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"title": "設備編號",
|
|
|
|
"data": "sourceName_zh",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"title": "異常原因",
|
|
|
|
"data": "msgText",
|
|
|
|
"render": function (data) {
|
|
|
|
return data.split(':')[0];
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"title": "Ack 確認",
|
|
|
|
"data": "ackState",
|
|
|
|
"render": function (data) {
|
|
|
|
let confirm = data == "1" ? "未確認" : "確認";
|
|
|
|
let btnCol = data == "1" ? "warning" : "info";
|
|
|
|
return `<td><a href="#" onclick="return false" class="btn btn-${btnCol}">${confirm}</a></td>`
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"title": "派工/維運單號",
|
|
|
|
"data": "formId",
|
|
|
|
"render": function (data) {
|
|
|
|
return data ?? `<td><a href="#" id="alr_recModal" class="btn btn-info" data-toggle="modal" data-target="#alr_opeRecModal">+ 維修單</a></td>`;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
];
|
|
|
|
|
|
|
|
historyTable = new YourTeam.JqDataTables.getTableByStatic(tag, data, columns, column_defs, null, null, null, null, "tpi");
|
|
|
|
}
|
|
|
|
|
|
|
|
function AlertList(errCode) {
|
|
|
|
objSendData.Data = { uuid: errCode };
|
|
|
|
let a = null
|
|
|
|
url = baseApiUrl + "/Alert/AlertList";
|
|
|
|
ytAjax = new YourTeam.Ajax(url, objSendData, function (rel) {
|
|
|
|
if (rel.code == "0000")
|
|
|
|
a = rel.data;
|
|
|
|
}, null, "POST").send();
|
|
|
|
|
|
|
|
return a;
|
|
|
|
}
|
|
|
|
|
|
|
|
function selDevice() {
|
|
|
|
let url = baseApiUrl + "/operation/DevList";
|
|
|
|
let lsst = [];
|
|
|
|
$('a[data-type=alr_sub]').map(function (i, v) { lsst.push($(v).prop('id')); });
|
|
|
|
sendData = {
|
|
|
|
device_area_tag: pageAct.AreaTag,
|
|
|
|
device_building_tag: pageAct.buiTag,
|
|
|
|
list_sub_system_tag: lsst,
|
|
|
|
};
|
|
|
|
objSendData.Data = sendData;
|
|
|
|
ytAjax = new YourTeam.Ajax(url, objSendData, function (res) {
|
|
|
|
if (!res || res.code != "0000" || !res.data) {
|
|
|
|
|
|
|
|
} else {
|
|
|
|
strHtml = ``;
|
|
|
|
$("#inpFixDoCode").html();
|
|
|
|
$.each(res.data, (index, roleObj) => {
|
2022-12-09 15:37:15 +08:00
|
|
|
strHtml += `<option value='${roleObj.device_number}' data-floor=${roleObj.device_floor_tag} data-main=${roleObj.device_system_tag} data-sub=${roleObj.device_name_tag} hidden>${roleObj.device_name}</option>`;
|
2022-12-08 18:26:23 +08:00
|
|
|
|
|
|
|
if (index == 0) {
|
|
|
|
pageAct.sysMain = roleObj.device_system_tag;
|
|
|
|
pageAct.sysSub = roleObj.device_name_tag;
|
|
|
|
pageAct.floor = roleObj.device_floor_tag;
|
|
|
|
pageAct.number = roleObj.device_number;
|
|
|
|
}
|
|
|
|
})
|
|
|
|
$("#inpFixDoCode").html(strHtml);
|
|
|
|
}
|
|
|
|
}, null, "POST").send();
|
|
|
|
}
|
|
|
|
|
|
|
|
function selUser() {
|
|
|
|
let url = baseApiUrl + "/User/UserManagerList";
|
|
|
|
ytAjax = new YourTeam.Ajax(url, objSendData, function (res) {
|
|
|
|
if (!res || res.code != "0000" || !res.data) {
|
|
|
|
|
|
|
|
} else {
|
|
|
|
$("#inpWorPerId").html();
|
|
|
|
strHtml = ``;
|
|
|
|
strHtml += `<option value=''>未選擇</option>`;
|
|
|
|
$.each(res.data, (index, roleObj) => {
|
|
|
|
strHtml += `<option value='${roleObj.userinfo_guid}'>${roleObj.full_name}</option>`;
|
|
|
|
})
|
|
|
|
$("#inpWorPerId").html(strHtml);
|
|
|
|
}
|
|
|
|
}, null, "POST").send();
|
|
|
|
}
|
|
|
|
|
|
|
|
function selOpeFir() {
|
|
|
|
let url = baseApiUrl + "/operation/OpeFirSel";
|
|
|
|
objSendData.Data = { sub_system_tag: $('a[data-type=alr_sub].btn-info').map(function (i, v) { return $(v).prop('id'); }).toArray() };
|
|
|
|
ytAjax = new YourTeam.Ajax(url, objSendData, function (res) {
|
|
|
|
if (!res || res.code != "0000" || !res.data) {
|
|
|
|
|
|
|
|
} else {
|
|
|
|
$("#inpFixFirm").html();
|
|
|
|
strHtml = ``;
|
|
|
|
strHtml += `<option value=''>未選擇</option>`;
|
|
|
|
$.each(res.data, (index, roleObj) => {
|
|
|
|
strHtml += `<option value='${roleObj.id}'>${roleObj.name}</option>`;
|
|
|
|
})
|
|
|
|
$("#inpFixFirm").html(strHtml);
|
|
|
|
}
|
|
|
|
}, null, "POST").send();
|
|
|
|
}
|
2022-12-09 15:37:15 +08:00
|
|
|
|
|
|
|
//上傳檔案 dropzone
|
|
|
|
function initDropzone() {
|
|
|
|
uploader = $("#alr_dropZone").dropzone({
|
|
|
|
url: baseApiUrl + '/api/Upload',
|
|
|
|
previewsContainer: false,
|
|
|
|
addRemoveLinks: false,
|
|
|
|
dictRemoveFile: `<span class="material-icons mi-delete">delete</span>`,
|
|
|
|
dictInvalidFileType: `上傳格式錯誤`,
|
|
|
|
dictCancelUploadConfirmation: `確定要取消上傳此檔案嗎?`,
|
|
|
|
dictCancelUpload: `<span class="material-icons mi-cancel">cancel</span>`,
|
|
|
|
maxFilesize: 3,
|
|
|
|
filesizeBase: 1024,
|
|
|
|
maxFiles: 50,
|
|
|
|
acceptedFiles: ".pdf, .docx, .doc, .xls, .xlsm, .xlsx, .ppt, .pptx, .gif, .png, .jpg, .jpeg",
|
|
|
|
headers: { "Authorization": 'Bearer ' + localStorage.getItem("JWT-Authorization") },
|
|
|
|
accept: function (file, done) {
|
|
|
|
let fileHelper = new YourTeam.Utility.File();
|
|
|
|
tmpGuidArr = [];
|
|
|
|
|
|
|
|
if (/\.(jpe?g|png|gif)$/i.test(file.name)) {
|
|
|
|
fileHelper.readAndPreviewImages(file, 'alr_forImage', 70, 70, '<span class="file-item m-1">', '<button class="btn-dark m-1" name="btnDelImg"><i class="fa fa-times"></i></button></span>');
|
|
|
|
|
|
|
|
pageAct.imageFile.map(function (v, i) { tmpGuidArr.push(v.file.guid) });
|
|
|
|
if (jQuery.inArray(file.guid, tmpGuidArr) == -1) { //not in array
|
|
|
|
let fd = new FormData();
|
|
|
|
let f = file;
|
|
|
|
fd.append('file', f);
|
|
|
|
pageAct.imageFile.push({ "ori_file_name": f.name, "save_file_name": f.guid, "file": fd.get("file") });
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (/\.(xls?x|doc?x|ptt?x|pdf|zip|rar|7zip|txt|odt|xml|rtf|ods|odp|pps?x)$/i.test(file.name)) {
|
|
|
|
fileHelper.readAndPreviewFiles(file, 'alr_forFile', 70, 70, "<div class='file-item'><i class='fas fa-file-alt fa-2x m-1'></i>", "<button class='btn-dark m-1' name='btnDelImg'><i class='fa fa-times'></i></button></div>");
|
|
|
|
|
|
|
|
pageAct.imageFile.map(function (v, i) { tmpGuidArr.push(v.file.guid) });
|
|
|
|
if (jQuery.inArray(file.guid, tmpGuidArr) == -1) { //not in array
|
|
|
|
let fd = new FormData();
|
|
|
|
let f = file;
|
|
|
|
fd.append('file', f);
|
|
|
|
pageAct.imageFile.push({ "ori_file_name": f.name, "save_file_name": f.guid, "file": fd.get("file") });
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2022-12-07 09:25:43 +08:00
|
|
|
</script>
|