ibms-dome/FrontendWebApi/Views/EmergencyRecord/Index.cshtml

1520 lines
72 KiB
Plaintext

@{
ViewData["MainNum"] = "4";
ViewData["SubNum"] = "4";
ViewData["Title"] = "事件查詢";
}
<ol class="breadcrumb page-breadcrumb">
<li class="breadcrumb-item"><a href="javascript:void(0);">首頁</a></li>
<li class="breadcrumb-item 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-12">
<div id="panel-5" class="panel">
<div class="panel-container show">
<div class="panel-content">
<div class="subheader">
<h1 class="subheader-title">
<span>事件查詢</span>
</h1>
</div>
<div class="row mb-3 d-flex align-items-center px-3 justify-content-between">
<div class="pr-3 ">
<div class="btn-group btn-group-md" id="Disasterlist">
</div>
</div>
</div>
<div class="row mb-3 d-flex align-items-center px-3 justify-content-between">
<div class="pr-3 ">
<div class="btn-group btn-group-md" id="buildlist">
</div>
</div>
</div>
<div class="row mb-3 d-flex align-items-center px-3">
<div class="pr-3 ">
<div class="btn-group btn-group-md" id="Typelist">
<button type="button" class="btn btn-success waves-effect waves-themed mb-2" onclick="SelectType(2,this)">全選</button>
<button type="button" class="btn btn-secondary waves-effect waves-themed mb-2" onclick="SelectType(1,this)">演習</button>
<button type="button" class="btn btn-secondary waves-effect waves-themed mb-2" onclick="SelectType(0,this)">正式</button>
</div>
</div>
<div class="pr-3">
<button type="button" class="btn btn-secondary waves-effect waves-themed mb-2" onclick="ChangeDate30()">近30天</button>
</div>
<div class="pr-3">
<div class="form-group">
<input class="form-control" id="date-range" type="text" name="date" value="">
</div>
</div>
</div>
<div class="card border mb-g w-100 mb-5 " id="menucard">
<div class="mb-2 card-header bg-fusion-25 py-2 pr-3 d-flex align-items-center flex-wrap justify-content-end">
@*<div class="text-right ">
<a href="javascript:;" class="btn btn-sm btn-success ml-auto waves-effect waves-themed" id="addUser-btn" onclick="AddFloor()"> 匯出PDF</a>
<a href="javascript:;" class="btn btn-sm btn-success ml-auto waves-effect waves-themed" id="addUser-btn" onclick="AddFloor()"> 匯出Excel</a>
</div>*@
</div>
<div class="card border mb-g mb-2 m-3" id="menucard">
<div class="card-header bg-fusion-25 py-2 pr-3 d-flex align-items-center flex-wrap justify-content-between">
<div class="card-title font-weight-bold">事件列表</div>
</div>
<div class="card-body">
<div class="w-100">
<div class="col-12">
<table id="emergency_event_table" class="table table-bordered table-hover m-0 text-center">
<thead class="thead-themed">
<tr>
<th>序</th>
<th>棟別</th>
<th>災別</th>
<th>設備</th>
<th>類別</th>
<th>發生時間</th>
<th>完成時間</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
</div>
</div>
</div>
<div class="card border mb-g mb-2 m-3" id="emergencyitem" style="display:none">
<div class="card-header bg-fusion-25 py-2 pr-3 d-flex align-items-center flex-wrap justify-content-between">
<div class="card-title font-weight-bold">事件明細</div>
</div>
<div class="card-body">
<div class="w-100">
<div class="col-12">
<table id="emergency_item_table" class="table table-bordered table-hover m-0 text-center">
<thead class="thead-themed">
<tr>
<th>項目</th>
<th>步驟</th>
<th>是否完成操作</th>
<th>不執行原因</th>
<th>時間</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="modal fade modal-fullscreen example-modal-fullscreen" id="SimulationExercisemodal" 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 h-100 border-0 shadow-0 bg-fusion-800">
@*<button type="button" class="close p-sm-2 p-md-4 text-dark fs-xxl position-absolute pos-right mr-sm-2 mt-sm-1 z-index-space" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true"><i class="fal fa-times"></i></span>
</button>*@
<div class="position-absolute pos-right mr-sm-3 mt-sm-3 z-index-space">
<button type="button" class="btn btn-danger waves-effect waves-themed mr-2" id="Tcp" onclick="SendMessageAsync('D002')">取消上牆</button>
<button type="button" class="btn btn-danger waves-effect waves-themed" id="closemodal" onclick="Closemodal()">關閉流程</button>
</div>
<div class="modal-body bg-white">
<div class="container-fluid">
<div class="row">
<div class="col-12 text-center"><h1 class="mb-3">緊急應變措施 - <span id="simulation-disaster">火災</span>處置</h1></div>
<ul class="nav nav-tabs mb-3 w-100" role="tablist" id="bigsetting">
<li class="nav-item"> <a class="nav-link fs-xl py-3 px-5" data-toggle="tab" href="#" role="tab"> <i class="fal fa-check text-success"></i> <span class="hidden-sm-down ml-1 text-secondary">確認與通報</span> </a> </li>
<li class="nav-item"> <a class="nav-link fs-xl py-3 px-5" data-toggle="tab" href="#" role="tab"> <i class="fal fa-check text-success"></i> <span class="hidden-sm-down ml-1 text-secondary">通報火災授信總機</span> </a> </li>
<li class="nav-item"> <a class="nav-link fs-xl py-3 px-5" data-toggle="tab" href="#" role="tab"> <i class="fal fa-check text-success"></i> <span class="hidden-sm-down ml-1 text-secondary">通報防災中心</span> </a> </li>
<li class="nav-item"> <a class="nav-link fs-xl py-3 px-5" data-toggle="tab" href="#" role="tab"> <i class="fal fa-check text-success"></i> <span class="hidden-sm-down ml-1 text-secondary">疏導人群</span> </a> </li>
</ul>
</div>
<div class="row">
<div class="col-md-8 tab-content" id="small_setting">
<div class="tab-pane fade show active" id="export_modal" role="tabpanel" aria-labelledby="16_modal">
<div class="row">
<div class="pr-2" style="width:38.5%">
<div id="panel-1" class="panel">
<div class="panel-container show">
<div class="panel-content">
<ul class="list-group">
<li class="list-group-item active"> <i class="fal fa-check text-success"></i> 確認與通報</li>
<li class="list-group-item"> <i class="fal fa-check text-success"></i> 通報火災授信總機</li>
<li class="list-group-item"> <i class="fal fa-check text-success"></i> 通報防災中心</li>
<li class="list-group-item"> <i class="fal fa-check text-success"></i> 疏導人群</li>
</ul>
</div>
</div>
</div>
</div>
<div class="" style="width:61.5%">
<div id="panel-2" class="panel">
<div class="panel-hdr">
<h2>通報火災授信總機</h2>
</div>
<div class="panel-container show">
<div class="panel-content">
<div class="panel-tag">
All panels needs to have an unique ID in order to use the panel funtions. <code>.panel</code> is a container with no padding, <code>.panel-hdr</code> has a <code>min-height</code> value and default <code>flexbox</code> properties. The <code>.panel-toolbar</code> is inserted into <code>.panel-hdr</code> for extra elements. The <code>.panel-container</code> wraps <code>.panel-content</code> which has a predefined padding.
</div>
<p>
Default panel text.
</p>
</div>
<div class="panel-content py-2 border-faded border-left-0 border-right-0 border-bottom-0 text-muted d-flex justify-content-between">
<div class=""><button type="button" class="btn btn-danger waves-effect waves-themed mr-2"> 不通報 </button><input type="text" class=""></div>
<div><button type="button" class="btn btn-success waves-effect waves-themed"> 下一步 </button></div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="col-md-4">
<div id="panel-12" class="panel">
<div class="panel-hdr border-faded border-top-0 border-right-0 border-left-0 shadow-0">
<h2></h2>
<div class="panel-toolbar pr-3 align-self-end">
<ul id="demo_panel-tabs" class="nav nav-tabs border-bottom-0 nav-tabs-clean" role="tablist">
<li class="nav-item">
<a class="nav-link text-dark active" data-toggle="tab" href="#tab_content" role="tab">緊急聯絡清單</a>
</li>
<li class="nav-item">
<a class="nav-link text-dark" data-toggle="tab" href="#tab_dohistory" role="tab">操作歷史</a>
</li>
</ul>
</div>
</div>
<div class="panel-container show">
<div class="panel-content tab-content">
<div class="tab-pane fade show active" id="tab_content" role="tabpanel" aria-labelledby="tab_content">
<div class="row justify-content-between mb-2">
<div class="col-auto">
<span class="d-inline-block">組別</span>
<button type="button" class="btn btn-secondary waves-effect waves-themed d-inline-block ml-2" onclick="Allgroupingselect()"> 全選 </button>
</div>
<div class="col-auto">
<button type="button" class="btn btn-primary waves-effect waves-themed" onclick="OpenSendSMSModal()">發送簡訊</button>
</div>
</div>
<h2 id="button_grouping">
<button type="button" class="btn btn-success waves-effect waves-themed mb-2"> 主防災中心 </button>
<button type="button" class="btn btn-outline-success waves-effect waves-themed mb-2"> 通報聯絡班 </button>
<button type="button" class="btn btn-outline-success waves-effect waves-themed mb-2"> 外部救援引導班 </button>
<button type="button" class="btn btn-outline-success waves-effect waves-themed mb-2"> 滅火班 </button>
<button type="button" class="btn btn-outline-success waves-effect waves-themed mb-2"> 緊急救護班 </button>
<button type="button" class="btn btn-outline-success waves-effect waves-themed mb-2"> 安全防護班 </button>
</h2>
<table class="table table-bordered m-0" id="membertable">
<thead>
<tr>
<th>姓名</th>
<th>部門</th>
<th>電話</th>
<th>LineID</th>
<th>Email</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
<div class="tab-pane fade" id="tab_dohistory" role="tabpanel" aria-labelledby="tab_dohistory">
<table class="table table-bordered m-0" id="dohistorytable">
<thead>
<tr>
<th>項目</th>
<th>步驟</th>
<th>結果</th>
<th>時間</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="modal fade" id="emergency-verify-modal" 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 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>
<div class="modal-body">
<form id="emergency-item-form" onsubmit="PassVerify(true)">
<div class="row">
<div class="form-group col-6">
<label class="form-label" for="emergency_verify_modal"><span class="text-danger">*</span>指揮官密碼</label>
<input class="form-control" type="password" id="emergency_verify_input" />
</div>
</div>
</form>
</div>
<div class="row">
<div class="col-12">
<div class="modal-footer">
<button type="button" class="btn btn-secondary" onclick="PassVerify(false)">取消</button>
<button type="button" class="btn btn-primary" onclick="PassVerify(true)">確認</button>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="modal fade" id="send-sms-modal" tabindex="-1" role="dialog" aria-hidden="true" data-backdrop="static" data-keyboard="false">
<div class="modal-dialog modal-dialog-centered modal-xl" role="document">
<div class="modal-content">
<div class="modal-header">
<h4 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>
<div class="modal-body">
<div class="row mb-2">
<div class="col-auto">
<span class="d-inline-block">組別</span>
<button type="button" class="btn btn-secondary waves-effect waves-themed d-inline-block ml-2" onclick="AllSMSgroupingselect()">全選</button>
</div>
<div class="col" id="sms-grouping"></div>
</div>
<div class="row mb-2">
<div class="col-6">
<table class="table table-bordered m-0" id="smsMemberTable">
<thead>
<tr>
<th>姓名</th>
<th>部門</th>
<th>電話</th>
<th>LineID</th>
<th>Email</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
<div class="col-6">
<textarea class="form-control mt-3 mb-2" rows="5" id="sms_messagebox"></textarea>
<span>發訊人:</span>
</div>
</div>
<div class="row justify-content-between">
<div class="col-auto">
<button type="button" class="btn btn-secondary" data-dismiss="modal" onclick="PassVerify(false)">取消</button>
</div>
<div class="col-auto row">
<div class="col-auto">
<input class="form-control" type="password" id="sendSms_verify_input" placeholder="請輸入指揮官密碼" />
</div>
<div class="col-auto">
<button type="button" class="btn btn-primary" onclick="PassVerify(true)">
<span class="spinner-border spinner-border-sm" role="status" aria-hidden="true" id="smsSaveBtnLoading" style="display:none"></span>
儲存
</button>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="loading-overlay" id="loading-overlay">
<div class="spinner-border text-primary" role="status">
<span class="sr-only">Loading...</span>
</div>
<p class="loading-text">資料載入中...</p>
</div>
@section Scripts {
<script>
var SelectaDisaster;
var SelectaBuild;
var SelectaType = 2;//2:全選 1:演習 0:正式
var datepicker;
var EmergencyEventTable;
var EmergencyItemTable;
var SelectEvent;
var alarmDeviceTable, emergencyContactTable, historyTable;
var SimulationExerciseGuid;
var Allgroupidlist = new Array(0);
var Allgroupingbool = false;
var SelectMemberDepart = new Array(0);
var SelectSMSMemberDepart = new Array(0);
var AllSMSgroupidlist = new Array(0);
var AllSMSgroupingbool = false;
var SmsMemberTable;
var EmerLastsetting; //-正在使用的tab
var Verifybool = false; //-驗證成功
var CloseVerify = false;
var ToVerifyType = 0;
$(function () {
//#region Date-Picker
datepicker = $('#date-range').daterangepicker({
autoUpdateInput: false,
locale: {
format: 'YYYY/MM/DD',
cancelLabel: '取消',
applyLabel: '確定'
},
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').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').on('cancel.daterangepicker', function (ev, picker) {
$(this).val('');
$(this).trigger('change');
});
//#endregion
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').val(dateLimit_format + ' - ' + today_format);
// 在ajax事件添加loading
$(document).ajaxStart(function () {
$('#loading-overlay').show();
}).ajaxStop(function () {
$('#loading-overlay').hide();
});
EmergencyEventTable = $("#emergency_event_table").DataTable({
"order": [[6, "desc"]],
"columns": [
{
"data": "emergency_event_guid",
"render": function (data, type, row, meta) {
return meta.row + 1;
},
},
{
"data": "building_name"
},
{
"data": "disaster_name"
},
{
"data": "device_name"
},
{
"data": "type"
},
{
"data": "alarm_time",
"render": function (data, type, row, meta) {
if (data == '0001-01-01 00:00:00') {
return ""
}
return data;
}
},
{
"data": "finish_time",
"render": function (data, type, row, meta) {
if (row.type === "演習") {
return "";
} else if (row.type === "正式" && data == '0001-01-01 00:00:00') {
var html = '<button class="btn btn-sm btn-danger sop-btn">啟動SOP</button>';
return html
}
return data;
}
}
],
'createdRow': function (row, data, dataIndex) {
$(row).attr('guid', data.emergency_event_guid);
$(row).attr('type', data.type);
$(row).attr('device', data.device_name);
$(row).attr('data-guid', data.device_guid);
$(row).attr('data-disaster', data.disaster);
$(row).attr('disaster_name', data.disaster_name);
},
"ajax": {
"url": "/api/EmergencyRecord/EmergencyRecordTable",
"type": "POST",
"data": function (d) {
d.selectaDisaster = SelectaDisaster,
d.selectaBuild = SelectaBuild,
d.selectaType = SelectaType,
d.dateranger = $('#date-range').val()
},
"dataSrc": function (rel) {
if (rel.code == "9999") {
toast_error(rel.msg);
return;
}
data = rel.data;
if (data == null || data.length == 0) {
this.data = [];
}
$.each(this.data, function (index, val) {
if (val.type == 0) {
val.type = "正式";
} else {
val.type = "演習";
}
})
return data;
}
}
});
EmergencyItemTable = $('#emergency_item_table').DataTable({
"order": [[4, "desc"]],
"columns": [
{
"data": "big_setting"
},
{
"data": "step_setting"
},
{
"data": "finished"
},
{
"data": "reason"
},
{
"data": "updated_at",
"render": function (data, type, row, meta) {
if (data == "0001-01-01 00:00:00") {
return "";
}
return data;
},
}
],
'createdRow': function (row, data, dataIndex) {
$(row).attr('guid', data.emergency_item_guid);
},
"ajax": {
"url": "/api/EmergencyRecord/EmergencyItemTable",
"type": "POST",
"data": function (d) {
d.event_guid = SelectEvent
},
"dataSrc": function (rel) {
if (rel.code == "9999") {
toast_error(rel.msg);
return;
}
data = rel.data;
if (data == null || data.length == 0) {
this.data = [];
}
$.each(this.data, function (index, val) {
if (val.finished == 0) {
val.finished = "未執行";
}
else if (val.finished == 1) {
val.finished = "完成";
}
else {
val.finished = "不執行";
}
})
return data;
}
}
});
//#region 模擬演練 / SOP modal 聯絡清單Table
emergencyContactTable = $("#membertable").DataTable({
"columns": [
{
"data": "full_name"
},
{
"data": "departmentName"
},
{
"data": "phone"
},
{
"data": "lineid"
},
{
"data": "email"
}
],
'createdRow': function (row, data, dataIndex) {
$(row).attr('guid', data.emergency_guid);
},
"ajax": {
"url": "/api/EmergencyDevice/EmergencyContactTable",
"type": "POST",
"data": function (d) {
d.selectgroupidlist = SelectMemberDepart
},
"dataSrc": function (rel) {
if (rel.code == "9999") {
toast_error(rel.msg);
return;
}
data = rel.data.data;
if (data == null || data.length == 0) {
this.data = [];
}
return data;
}
}
});
//#endregion
// #region 模擬演練 / SOP modal 發送簡訊Table
SmsMemberTable = $("#smsMemberTable").DataTable({
"columns": [
{
"data": "full_name"
},
{
"data": "departmentName"
},
{
"data": "phone"
},
{
"data": "lineid"
},
{
"data": "email"
}
],
'createdRow': function (row, data, dataIndex) {
$(row).attr('guid', data.emergency_guid);
},
"ajax": {
"url": "/api/EmergencyDevice/EmergencyContactTable",
"type": "POST",
"data": function (d) {
d.selectgroupidlist = SelectSMSMemberDepart
},
"dataSrc": function (rel) {
if (rel.code == "9999") {
toast_error(rel.msg);
return;
}
data = rel.data.data;
if (data == null || data.length == 0) {
this.data = [];
}
return data;
}
}
});
// #endregion
// #region 模擬演練 / SOP modal 操作紀錄Table
historyTable = $('#dohistorytable').DataTable({
"iDisplayLength": 5,
"order": [[3, 'desc']],
"columns": [
{
"data": "big_setting",
},
{
"data": "step_setting"
},
{
"data": "finished"
},
{
"data": "updated_at"
}
],
'createdRow': function (row, data, dataIndex) {
$(row).attr('guid', data.emergency_guid);
},
"ajax": {
"url": "/api/EmergencyDevice/Dohistorytotable",
"type": "POST",
"data": function (d) {
d.eventguid = SimulationExerciseGuid
},
"dataSrc": function (rel) {
if (rel.code == "9999") {
toast_error(rel.msg);
return;
}
data = rel.data.data;
if (data == null || data.length == 0) {
this.data = [];
} else {
$.each(this.data, function (index, value) {
if (value.finished == 0) {
value.finished = "未執行";
} else if (value.finished == 1) {
value.finished = "完成";
} else if (value.finished == 2) {
value.finished = "不執行";
if (value.reason != null) {
value.finished += "-" + value.reason;
}
}
if (value.updated_at == "0001-01-01 00:00:00") {
value.updated_at = "";
}
})
}
return data;
}
}
});
// #endregion
GetDisasterList();
GetBuild();
})
//取得所有災難別
function GetDisasterList() {
var url = "/EmergencyRecord/DisasterList";
var send_data = {};
$.post(url, send_data, function (rel) {
if (rel.code != "0000") {
if (rel.code == "9999") {
toast_error(rel.msg);
}
return;
}
else {
$('#Disasterlist').empty();
var Disasterstr = "";
$.each(rel.data, function (index, val) {
if (index == 0) {
Disasterstr += '<button type="button" class="btn btn-success waves-effect waves-themed" onclick = "SelectDisaster(' + val.value + ',this)"> ' + val.name + '</button>';
}
else {
Disasterstr += '<button type="button" class="btn btn-secondary waves-effect waves-themed" onclick = "SelectDisaster(' + val.value + ',this)">' + val.name + '</button>';
}
});
$('#Disasterlist').append(Disasterstr);
$('#Disasterlist').find('.btn-success').trigger('click');
return;
}
}, 'json');
}
//取得所有棟別
function GetBuild() {
var url = "/api/EmergencyRecord/BuildInfoList";
var send_data = {};
$.post(url, send_data, function (rel) {
if (rel.code != "0000") {
if (rel.code == "9999") {
toast_error(rel.msg);
}
return;
}
else {
$('#buildlist').empty();
var buildstr = "";
$.each(rel.data, function (index, val) {
$('#build_menu_building_modal').append($("<option />").val(val.value).text(val.name));
if (index == 0) {
SelectBuild = val.value;
buildstr += '<button type="button" class="btn btn-success waves-effect waves-themed" onclick="SelectBulid(\'' + val.value + '\' ,this)">' + val.name + '</button>';
}
else {
buildstr += '<button type="button" class="btn btn-secondary waves-effect waves-themed" onclick="SelectBulid(\'' + val.value + '\',this)" >' + val.name + '</button>';
}
});
$('#buildlist').append(buildstr);
$('#buildlist').find('.btn-success').trigger('click');
//GetMainlistByBuild(SelectBuild);
return;
}
}, 'json');
}
//選擇災難類別
function SelectDisaster(Disaster, e) {
SelectaDisaster = Disaster;
if ($("#Disasterlist").find('.btn').hasClass("btn-success")) {
$("#Disasterlist").find('.btn').removeClass("btn-success").addClass("btn-secondary");
}
$(e).removeClass("btn-secondary").addClass("btn-success");
reloadeventTable();
}
//選擇棟別
function SelectBulid(build, e) {
SelectaBuild = build;
if ($("#buildlist").find('.btn').hasClass("btn-success")) {
$("#buildlist").find('.btn').removeClass("btn-success").addClass("btn-secondary");
}
$(e).removeClass("btn-secondary").addClass("btn-success");
reloadeventTable();
}
//選擇類別(正式 or 演習)
function SelectType(type, e) {
SelectaType = type
if ($("#Typelist").find('.btn').hasClass("btn-success")) {
$("#Typelist").find('.btn').removeClass("btn-success").addClass("btn-secondary");
}
$(e).removeClass("btn-secondary").addClass("btn-success");
reloadeventTable();
}
//查詢近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').val(dateLimit_format + ' - ' + today_format);
$('#date-range').trigger('change');
}
//改變日期
$('#date-range').on('change', function () {
reloadeventTable();
});
//點選Event
$('#emergency_event_table').on("click", "tbody>tr", function () {
$(this).parents().find('tr').css('background-color', '#fff');
$(this).css('background-color', '#67B4AC');
SelectEvent = $(this).attr('guid');
var title = "事件明細" + "-" + $(this).attr('type')
if ($(this).attr('device') != undefined) { title += "-" + $(this).attr('device') }
$('#emergencyitem').find('.card-title').html(title);
// $('#emergencyitem').find('.card-title').html("事件明細" + "-" + $(this).attr('type') + "-" + $(this).attr('device'));
EmergencyItemTable.ajax.reload();
$('#emergencyitem').show();
})
//重新執行EventTable
function reloadeventTable() {
EmergencyEventTable.ajax.reload();
$('#emergencyitem').hide();
}
//#region 啟動SOP
$('#emergency_event_table').on("click", "button.sop-btn", function () {
selected_device_guid = $(this).parents('tr').attr('data-guid');
selected_device_disaster = $(this).parents('tr').attr('data-disaster');
selected_event_guid = $(this).parents('tr').attr('guid');
selected_disaster_name = $(this).parents('tr').attr('disaster_name');
$("#simulation-disaster").html(selected_disaster_name);
SimulationExerciseGuid = selected_event_guid;
OnSimulationExercise(selected_event_guid, selected_device_disaster, 0);
SendMessageAsync("D001");
});
//#endregion
//#region 模擬演練 / SOP 開啟畫面
function OnSimulationExercise(guid, disaster, type) {
GetbuttonList(disaster);
GetBigsetting(disaster);
// SimulationExerciseGuid = guid;
}
//#endregion
//#region 更新事件完成時間
function UpdateRecordFinishTime(callback) {
var url = "/api/EmergencyDevice/SaveAndOpenSimulationExercise";
var send_data = {
emergency_event_guid: SimulationExerciseGuid
};
$.post(url, send_data, function (rel) {
if (rel.code != "0000") {
if (rel.code == "9999") {
toast_error(rel.msg);
}
return;
}
else {
if (callback) {
callback();
}
}
}, 'json');
}
//#endregion
//#region 發送電視牆訊號
function SendMessageAsync(message) {
var url = "/api/Send";
var send_data = {
message: message
};
$.post(url, send_data, function (rel) {
if (rel.code != "0000") {
if (rel.code == "9999") {
toast_error("電視牆送訊號" + message + "失敗");
}
return;
}
else {
return;
}
}, 'json');
}
//#endregion
//#region 模擬演練 / SOP modal 取得組別
function GetbuttonList(selected_disaster) {
var url = "/api/EmergencyDevice/GetGroupingList";
var send_data = {
system_parent_id: selected_disaster
};
$.ajax({
url: url,
data: send_data,
type: 'POST',
dataType: 'json',
success: function (rel, statut) {
if (rel.code != "0000") {
if (rel.code == "9999") {
toast_error(rel.msg);
}
return;
}
else {
//console.log(rel);
var grouping = "";
$('#button_grouping').empty();
Allgroupidlist = [];
$.each(rel.data, function (index, val) {
Allgroupidlist.push(val.id);
grouping += '<div class="btn-group mb-2 mr-2">';
grouping += '<button type="button" class="btn btn-outline-success select" onclick="SelectGrouping(' + val.id + ',this)">' + val.name + '</button>';
grouping += '</div>';
});
$('#button_grouping').append(grouping);
//SMS
$("#sms-grouping").empty();
$.each(rel.data, function (index, val) {
$('#sms-grouping').append(`
<div class="btn-group mb-2 mr-2">
<button type="button" class="btn btn-outline-success select"
onclick="SelectSMSGrouping(${val.id},this)">${val.name}</button>
</div>`);
});
return;
//$('#button_grouping').empty();
}
}
});
}
//#endregion
//#region 模擬演練 / SOP modal 選擇組別
function SelectGrouping(grouping, e) {
if ($(e).hasClass("btn-outline-success")) {
$(e).removeClass("btn-outline-success").addClass("btn-success");
SelectMemberDepart.push(grouping);
} else if ($(e).hasClass("btn-success")) {
$(e).removeClass("btn-success").addClass("btn-outline-success");
var a = SelectMemberDepart.filter(function (n, i) {
if (n === grouping) {
SelectMemberDepart.splice(i, 1);
}
});
}
emergencyContactTable.ajax.reload();
}
//#endregion
//#region 模擬演練 / SOP modal 全選所有組別
function Allgroupingselect() {
if (Allgroupingbool) {
$('#button_grouping').find(".btn-success").removeClass("btn-success").addClass("btn-outline-success");
SelectMemberDepart = [];
Allgroupingbool = false;
}
else {
$('#button_grouping').find(".btn-outline-success").removeClass("btn-outline-success").addClass("btn-success");
SelectMemberDepart = Allgroupidlist;
Allgroupingbool = true;
}
emergencyContactTable.ajax.reload();
}
//#endregion
//#region 模擬演練 / SOP modal 開啟發送簡訊Modal
function OpenSendSMSModal() {
ToVerifyType = 2;
$('#send-sms-modal').modal();
SmsMemberTable.ajax.reload();
}
//#endregion
//#region 模擬演練 / SOP modal 選擇要發送簡訊的組別
function SelectSMSGrouping(grouping, e) {
if ($(e).hasClass("btn-outline-success")) {
$(e).removeClass("btn-outline-success").addClass("btn-success");
SelectSMSMemberDepart.push(grouping);
} else if ($(e).hasClass("btn-success")) {
$(e).removeClass("btn-success").addClass("btn-outline-success");
var a = SelectSMSMemberDepart.filter(function (n, i) {
if (n === grouping) {
SelectSMSMemberDepart.splice(i, 1);
}
});
}
SmsMemberTable.ajax.reload();
}
//#endregion
//#region 模擬演練 / SOP modal 全選所有發送簡訊的組別
function AllSMSgroupingselect() {
if (AllSMSgroupingbool) {
$('#sms-grouping').find(".btn-success").removeClass("btn-success").addClass("btn-outline-success");
SelectSMSMemberDepart = [];
AllSMSgroupingbool = false;
}
else {
$('#sms-grouping').find(".btn-outline-success").removeClass("btn-outline-success").addClass("btn-success");
SelectSMSMemberDepart = Allgroupidlist;
AllSMSgroupingbool = true;
}
SmsMemberTable.ajax.reload();
}
//#endregion
//#region 模擬演練 / SOP modal 組成頁面
function GetBigsetting(selected_disaster) {
var url = "/api/EmergencyDevice/GetBigsetting";
var send_data = {
disaster: selected_disaster
};
$.post(url, send_data, function (rel) {
if (rel.code != "0000") {
if (rel.code == "9999") {
toast_error(rel.msg);
}
return;
}
else {
var bigsetting = "";
var smallsetting = "";
$('#bigsetting').empty();
$.each(rel.data, function (index, val) {
//<li class="nav-item"> <a class="nav-link fs-xl py-3 px-5" data-toggle="tab" href="#" role="tab"> <i class="fal fa-check text-success"></i> <span class="hidden-sm-down ml-1 text-secondary">確認與通報</span> </a> </li>
if (index == 0) {
bigsetting += '<li class="nav-item">';
bigsetting += '<a class="nav-link fs-xl py-3 px-5 active" data-toggle="tab" mas="' + val.id + '" href="#t' + val.id + '_modal" id="t' + val.id + '_tab" onclick="ChangeBigSetting(' + val.id + ')" role="tab">';
bigsetting += '<span class="hidden-sm-down ml-1 text-secondary">';
bigsetting += val.name + '</span > </a > </li >';
smallsetting += '<div class="tab-pane fade show active" id="t' + val.id + '_modal" role="tabpanel" aria-labelledby="' + val.id + '_modal">';
smallsetting += '<div class="row">';
smallsetting += '<div class="pr-2" style="width:38.5%">';
smallsetting += '<div id="panel-1" class="panel">';
smallsetting += '<div class="panel-container show">';
smallsetting += '<div class="panel-content">';
smallsetting += '<ul class="list-group" id="list_' + val.id + '">';
smallsetting += '</ul>';
smallsetting += '</div>';
smallsetting += '</div>';
smallsetting += '</div>';
smallsetting += '</div>';
smallsetting += '<div class="" style="width:61.5%">';
smallsetting += '<div class="panel">';
smallsetting += '<div class="panel-hdr" id="hbr_' + val.id + '">';
smallsetting += '</div>';
smallsetting += '<div class="panel-container show">';
smallsetting += '<div class="panel-content">';
smallsetting += '<div class="panel-tag" id="tag_' + val.id + '">';
smallsetting += '</div>';
smallsetting += '</div>';
smallsetting += '<div class="panel-content py-2 border-faded border-left-0 border-right-0 border-bottom-0 text-muted d-flex justify-content-between" id="button_' + val.id + '">';
smallsetting += '<div class=""><button type="button" class="btn btn-danger waves-effect waves-themed mr-2"> 不通報 </button><input type="text" class=""></div>';
smallsetting += '<div><button type="button" class="btn btn-success waves-effect waves-themed"> 下一步 </button></div>';
smallsetting += '</div>';
smallsetting += '</div>';
smallsetting += '</div>';
smallsetting += '</div>';
smallsetting += '</div>';
smallsetting += '</div>';
} else {
bigsetting += '<li class="nav-item">';
bigsetting += '<a class="nav-link fs-xl py-3 px-5" data-toggle="tab" href="#t' + val.id + '_modal" id="t' + val.id + '_tab" onclick="ChangeBigSetting(' + val.id + ',' + val.verify + ')" role="tab">';
bigsetting += '<span class="hidden-sm-down ml-1 text-secondary">';
bigsetting += val.name + '</span > </a > </li >';
smallsetting += '<div class="tab-pane fade" id="t' + val.id + '_modal" role="tabpanel" aria-labelledby="' + val.id + '_modal">';
smallsetting += '<div class="row">';
smallsetting += '<div class="pr-2" style="width:38.5%">';
smallsetting += '<div id="panel-1" class="panel">';
smallsetting += '<div class="panel-container show">';
smallsetting += '<div class="panel-content">';
smallsetting += '<ul class="list-group" id="list_' + val.id + '">';
smallsetting += '</ul>';
smallsetting += '</div>';
smallsetting += '</div>';
smallsetting += '</div>';
smallsetting += '</div>';
smallsetting += '<div class="" style="width:61.5%">';
smallsetting += '<div class="panel">';
smallsetting += '<div class="panel-hdr" id="hbr_' + val.id + '">';
smallsetting += '</div>';
smallsetting += '<div class="panel-container show">';
smallsetting += '<div class="panel-content">';
smallsetting += '<div class="panel-tag" id="tag_' + val.id + '">';
smallsetting += '</div>';
smallsetting += '</div>';
smallsetting += '<div class="panel-content py-2 border-faded border-left-0 border-right-0 border-bottom-0 text-muted d-flex justify-content-between" id="button_' + val.id + '">';
smallsetting += '</div>';
smallsetting += '</div>';
smallsetting += '</div>';
smallsetting += '</div>';
smallsetting += '</div>';
smallsetting += '</div>';
}
});
//console.log(smallsetting);
$('#bigsetting').append(bigsetting);
$('#small_setting').empty();
$('#small_setting').append(smallsetting);
$.each(rel.data, function (index, val) {
if (index == 0) {
GetEmergencySetting(val.id, true);
} else {
GetEmergencySetting(val.id, false);
}
})
$('#SimulationExercisemodal').modal();
return;
}
}, 'json');
}
//#endregion
//#region 模擬演練 / SOP modal 生成左邊按鈕
function GetEmergencySetting(setting, bool) {
var url = "/api/EmergencyDevice/GetEmergencySetting";
var send_data = {
selectsetting: setting
};
$.post(url, send_data, function (rel) {
if (rel.code != "0000") {
if (rel.code == "9999") {
toast_error(rel.msg);
}
return;
}
else {
var includeli = "";
$.each(rel.data, function (index, val) {
if (index == 0) {
includeli += '<li class="list-group-item active" id="li_' + val.emergency_guid + '" > <a class="abc" onclick="GetContentAndMakeItem(\'' + val.emergency_guid + '\',this,' + setting + ')" >' + val.full_name + '</a></li>';
} else {
includeli += '<li class="list-group-item" id="li_' + val.emergency_guid + '"> <a class="abc" onclick="GetContentAndMakeItem(\'' + val.emergency_guid + '\',this,' + setting + ')" >' + val.full_name + '</a></li>';
}
});
$('#list_' + setting).append(includeli);
if (bool) {
$('#bigsetting').find('.active').children().trigger('click');
}
//console.log(rel);
}
}, 'json');
}
//#endregion
function GetContentAndMakeItem(smallsetting, e, setting)//小項目,按鈕,大項目 //點選左邊按鈕
{
var FirstNotSend = $('#list_' + EmerNowsetting).children().not('.send').first().attr('id'); //當前要執行的步驟
var touch = $(e).parent().attr('id');//觸碰的按鈕
var has;
if (FirstNotSend == touch) {
has = 1; //true
} else {
has = 0; //false
}
$(e).parent().parent().find('.active').removeClass('active');
$(e).parent().addClass('active');
var url = "/api/EmergencyDevice/GetContentAndMakeItem";
var send_data = {
emergency_guid: smallsetting,
big_setting: $('#li_' + smallsetting).find('.abc').html(),
step_setting: $('#t' + setting + '_tab').find('.text-secondary').html(),
event_guid: SimulationExerciseGuid,
make_item: has
};
$.post(url, send_data, function (rel) {
if (rel.code != "0000") {
if (rel.code == "9999") {
toast_error(rel.msg);
}
return;
}
else {
console.log(rel);
var buttonstr = "";
if (rel.data.not_answer == 1) {
buttonstr += '<div><button type="button" class="btn btn-danger waves-effect waves-themed mr-2" onclick="NextStep(\'' + rel.data.emergency_item_guid + '\',1)"> 不執行 </button>';
buttonstr += '<input type="text" id="text_' + rel.data.emergency_item_guid + '" />';
} else {
buttonstr += '<div><button type="button" class="btn btn-danger waves-effect waves-themed mr-2" onclick="NextStep(\'' + rel.data.emergency_item_guid + '\',2)"> 不執行 </button>';
}
buttonstr += '</div>';
buttonstr += '<div><button type="button" class="btn btn-success waves-effect waves-themed" onclick="NextStep(\'' + rel.data.emergency_item_guid + '\',0)"> 執行 </button></div>';
$('#button_' + setting).empty();
$('#button_' + setting).append(buttonstr);
if (has == 0) {
$('#button_' + setting).find('button').attr('disabled', true);
}
$('#hbr_' + setting).empty();
$('#hbr_' + setting).append('<h2>' + rel.data.full_name + '</h2>');
$('#tag_' + setting).empty();
$('#tag_' + setting).append(rel.data.set_doing);
historyTable.ajax.reload();
}
}, 'json');
}
function NextStep(eventguid, choose) { //choose:選擇 0:下一步 1:不通報(需要原因) 2:不通報(不用原因)
var url = "/api/EmergencyDevice/NextStep";
var send_data = {
eventguid: eventguid,
choose: choose,
reason: $('#text_' + eventguid).val()
};
$.post(url, send_data, function (rel) {
if (rel.code != "0000") {
if (rel.code == "9999") {
toast_error(rel.msg);
}
return;
}
else {
$('#list_' + EmerNowsetting).find('.active').addClass('send');
//給予完成勾勾
var strnow = $('#list_' + EmerNowsetting).find('.active').find('.abc').html();
$('#list_' + EmerNowsetting).find('.active').find('.abc').html('<i class="fal fa-check text-success"></i>' + strnow);
//找下一個沒有的做動作
var a = $('#list_' + EmerNowsetting).children().not('.send').not('.active').first().attr('id');
//如果沒下一個動作則到下一格大步驟
if (a == undefined) {
strnow = $('#t' + EmerNowsetting + '_tab').find('.text-secondary').html();
$('#t' + EmerNowsetting + '_tab').find('.text-secondary').html('<i class="fal fa-check text-success"></i>' + strnow);
$('#t' + EmerNowsetting + '_tab').addClass('send');
var tablist = $('#t' + EmerNowsetting + '_tab').parent().parent().children().children().not('.send').not('.active').first().attr('id');
//console.log(tablist);
if (tablist == undefined) {
$('#button_' + EmerNowsetting).find('button').attr('disabled', true);
// CloseVerify = true;
//$('#closemodal').attr('disabled', false);
} else {
$('#' + tablist).trigger('click');
}
}
else {
$('#' + a).find('.abc').trigger('click');
}
}
}, 'json')
historytable.ajax.reload();
}
function ChangeBigSetting(setting, verify) {//-------------------------------------------------------------------------------------
//console.log(verify);
if (verify == 1) {
if (Verifybool)//需驗證且通過
{
}
else//需驗證未通過
{
EmerLastsetting = $('#bigsetting').find('.active').attr('mas');
ToVerifyType = 0;
//$('.modal-title').html("指揮官驗證");
$('#small_setting').hide();
$('#emergency_verify_input').val('');
$('#emergency-verify-modal').modal();
}
}
else//不需驗證
{
}
EmerNowsetting = setting;
$('#list_' + EmerNowsetting).find('.active').children().trigger('click');
}
function PassVerify(Vbool) {
if (ToVerifyType == 0) {
if (Vbool) {
var url = "api/EmergencyDevice/CheckVerifybool";
var send_data = {
pass: $('#emergency_verify_input').val()
};
$.post(url, send_data, function (rel) {
if (rel.code != "0000") {
if (rel.code == "9999") {
toast_error(rel.msg);
}
return;
} else {
if (rel.data) {
Verifybool = true;
$('#small_setting').show();
$('#emergency-verify-modal').modal('hide');
} else {
toast_warning('密碼驗證失敗,請重新驗證');
}
}
})
} else {//取消驗證
if (EmerLastsetting == 0) {
} else {
$('#small_setting').show();
$('#bigsetting').find('.active').removeClass('active');
$(`#t${EmerLastsetting}_tab`).addClass('active');
$('#small_setting').find('.show').removeClass('active show')
$(`#t${EmerLastsetting}_modal`).addClass('active show');
$('#list_' + EmerLastsetting).find('.active').children().trigger('click');
$('#emergency-verify-modal').modal('hide');
}
}
}
if (ToVerifyType == 1) {
if (Vbool) {
var url = "api/EmergencyDevice/CheckVerifybool";
var send_data = {
pass: $('#emergency_verify_input').val()
};
$.post(url, send_data, function (rel) {
if (rel.code != "0000") {
if (rel.code == "9999") {
toast_error(rel.msg);
}
return;
} else {
if (rel.data) {
CloseVerify = true;
$('#emergency-verify-modal').modal('hide');
$('#SimulationExercisemodal').modal('hide');
SendMessageAsync("D002");
UpdateRecordFinishTime(function () {
EmergencyEventTable.ajax.reload();
});
CloseVerify = false; // 每次關閉流程都要驗證一次
} else {
toast_warning('密碼驗證失敗,請重新驗證');
}
}
})
}
else {
$('#emergency-verify-modal').modal('hide');
}
}
if (ToVerifyType == 2) {
if (Vbool) {
if (!$("#sms_messagebox").val()) {
toast_warning('請輸入簡訊內容');
return;
}
controlSmsSaveBtnLoading(true);
var url = "api/EmergencyDevice/CheckVerifybool";
var send_data = {
pass: $('#sendSms_verify_input').val()
};
$.post(url, send_data, function (rel) {
if (rel.code != "0000") {
if (rel.code == "9999") {
toast_error(rel.msg);
}
return;
} else {
if (rel.data) {
Verifybool = true;
sendSmsMessage();
} else {
toast_warning('密碼驗證失敗,請重新驗證');
}
}
controlSmsSaveBtnLoading(false);
})
} else {//取消驗證
if (EmerLastsetting == 0) {
} else {
$('#small_setting').show();
$('#bigsetting').find('.active').removeClass('active');
$(`#t${EmerLastsetting}_tab`).addClass('active');
$('#small_setting').find('.show').removeClass('active show')
$(`#t${EmerLastsetting}_modal`).addClass('active show');
$('#list_' + EmerLastsetting).find('.active').children().trigger('click');
$('#emergency-verify-modal').modal('hide');
}
}
}
}
function controlSmsSaveBtnLoading(isShow = true) {
if (isShow) {
$("#smsSaveBtnLoading").parent("button").prop("disabled", true);
$("#smsSaveBtnLoading").fadeIn(200);
} else {
$("#smsSaveBtnLoading").fadeOut(200);
$("#smsSaveBtnLoading").parent("button").prop("disabled", false);
}
}
function sendSmsMessage() {
if (Verifybool) {
const members = SmsMemberTable.data().toArray();
const url = "api/HiNetMsg";
controlSmsSaveBtnLoading(true);
members.forEach(m => {
const send_data = {
Number: m.phone,
Msg: $("#sms_messagebox").val(),
};
$.ajax({
method: "POST",
url: url,
data: JSON.stringify(send_data),
contentType: "application/json;charset=utf-8",
success: (rel) => {
if (rel.code != "0000") {
if (rel.code == "9999") {
toast_error(rel.msg);
}
return;
} else {
if (rel.data) {
toast_ok("簡訊發送成功");
$("#send-sms-modal").modal("hide");
} else {
toast_warning('簡訊發送失敗,請重新操作');
}
}
},
complete: () => {
controlSmsSaveBtnLoading(false);
}
})
//$.post(url, JSON.stringify(send_data),{contentType:"applicaiton/json;charset=utf-8"}, function (rel) {
//})
})
} else {
toast_warning('密碼驗證失敗,請重新驗證');
}
}
function Closemodal() {
$('.modal-title').html("指揮官驗證");
ToVerifyType = 1;
if (CloseVerify) {
$('#SimulationExercisemodal').modal('hide');
} else {
$('#emergency_verify_input').val('');
$('#emergency-verify-modal').modal();
}
}
</script>
}