[緊急應變] 簡訊發送程序建置

This commit is contained in:
dev01 2023-05-19 18:47:45 +08:00
parent e77715fb0e
commit 8a2ac8e393
4 changed files with 128 additions and 20 deletions

View File

@ -582,41 +582,41 @@ namespace FrontendWebApi.ApiControllers
{
var device_url = string.Empty;
if (((de.icon_click & 1) > 0) && !string.IsNullOrEmpty(de.icon_click_url))
if (((de.left_icon_click & 1) > 0) && !string.IsNullOrEmpty(de.left_icon_click_url))
{
device_url = de.icon_click_url;
device_url = de.left_icon_click_url;
//點擊顯示系統圖
if (de.icon_click_url.Contains("[device_building_tag]"))
if (de.left_icon_click_url.Contains("[device_building_tag]"))
{
device_url = device_url.Replace("[device_building_tag]", de.device_building_tag);
}
if (de.icon_click_url.Contains("[device_system_tag]"))
if (de.left_icon_click_url.Contains("[device_system_tag]"))
{
device_url = device_url.Replace("[device_system_tag]", de.device_system_tag);
}
if (de.icon_click_url.Contains("[device_floor_tag]"))
if (de.left_icon_click_url.Contains("[device_floor_tag]"))
{
device_url = device_url.Replace("[device_floor_tag]", de.device_floor_tag);
}
if (de.icon_click_url.Contains("[device_name_tag]"))
if (de.left_icon_click_url.Contains("[device_name_tag]"))
{
device_url = device_url.Replace("[device_name_tag]", de.device_name_tag);
}
if (de.icon_click_url.Contains("[device_serial_tag]"))
if (de.left_icon_click_url.Contains("[device_serial_tag]"))
{
device_url = device_url.Replace("[device_serial_tag]", de.device_serial_tag);
}
if (de.icon_click_url.Contains("[tag_name]"))
if (de.left_icon_click_url.Contains("[tag_name]"))
{
device_url = device_url.Replace("[tag_name]", de.device_number);
}
de.icon_click_url = null;
de.left_icon_click_url = null;
de.DeviceURL = device_url;
}
@ -642,7 +642,7 @@ namespace FrontendWebApi.ApiControllers
// priority = de.priority,
// status = de.status,
// DeviceURL = device_url,
// icon_click = de.icon_click
// left_icon_click = de.left_icon_click
//};
//afloor.device.Add(device);
}

View File

@ -825,7 +825,7 @@ namespace FrontendWebApi.ApiControllers
Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message);
return Ok(apiResult);
}
apiResult.Code = "0000";
return Ok(apiResult);
}
}

View File

@ -186,10 +186,10 @@ namespace FrontendWebApi.Models
public byte device_error_flashing { get; set; }
public byte device_error_independent { get; set; }
public int priority { get; set; }
public byte icon_click { get; set; }
public string icon_click_url { get; set; }
public int icon_click_url_width { get; set; }
public int icon_click_url_height { get; set; }
public byte left_icon_click { get; set; }
public string left_icon_click_url { get; set; }
public int left_icon_click_url_width { get; set; }
public int left_icon_click_url_height { get; set; }
public string DeviceURL { get; set; }
public string point_name { get; set; }
public string points { get; set; }

View File

@ -282,20 +282,23 @@
</table>
</div>
<div class="col-6">
<textarea class="form-control mt-3 mb-2" rows="5"></textarea>
<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">取消</button>
<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="text" placeholder="請輸入指揮官密碼" />
<input class="form-control" type="password" id="sendSms_verify_input" placeholder="請輸入指揮官密碼" />
</div>
<div class="col-auto">
<button type="button" class="btn btn-primary" onclick="SaveSubSetting()">儲存</button>
<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>
@ -1418,6 +1421,7 @@
//#region 模擬演練 / SOP modal 開啟發送簡訊Modal
function OpenSendSMSModal() {
ToVerifyType = 2;
$('#send-sms-modal').modal();
SmsMemberTable.ajax.reload();
}
@ -1731,7 +1735,7 @@
{
EmerLastsetting = $('#bigsetting').find('.active').attr('mas');
ToVerifyType = 0;
$('.modal-title').html("指揮官驗證");
//$('.modal-title').html("指揮官驗證");
$('#small_setting').hide();
$('#emergency_verify_input').val('');
$('#emergency-verify-modal').modal();
@ -1747,6 +1751,7 @@
}
function PassVerify(Vbool) {
console.log(SmsMemberTable.data().toArray())
if (ToVerifyType == 0) {
if (Vbool) {
var url = "api/EmergencyDevice/CheckVerifybool";
@ -1815,6 +1820,109 @@
$('#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() {