[Web Api] GetDevice CCTV 更改 SQL Filter | [緊急應變] 前端程序災害類別按鈕有異常設備也要呈現紅色 | 進入頁面預設全選棟別

This commit is contained in:
dev01 2023-10-30 15:01:59 +08:00
parent 465a55f203
commit 72b1e2f1e8
3 changed files with 31 additions and 23 deletions

View File

@ -524,12 +524,12 @@ namespace FrontendWebApi.ApiControllers
{string.Join(" AND ", str_arr)} {string.Join(" AND ", str_arr)}
) OR ) OR
d.device_system_category_layer3 = 'C' d.device_name_tag = 'C'
)"; )";
} }
else else
{ {
sWhere = $@" AND d.device_system_category_layer3 = 'C'"; sWhere = $@" AND d.device_name_tag = 'C'";
} }
} }
else else

View File

@ -123,15 +123,17 @@ namespace FrontendWebApi.ApiControllers
{ {
string deviceQue = ""; string deviceQue = "";
string disasQue = ""; string disasQue = "";
if (selectdevice.selectbuilding != null && selectdevice.selectbuilding.Count > 0) if (selectdevice.selectbuilding == null || selectdevice.selectbuilding.Count == 0)
deviceQue += $" AND d.device_building_tag in @building_tag "; selectdevice.selectbuilding = new List<string>();
if (selectdevice.select_Floors != null && selectdevice.select_Floors.Count > 0) if (selectdevice.select_Floors != null && selectdevice.select_Floors.Count > 0)
deviceQue += $" AND d.device_floor_tag in @floor "; deviceQue += $" AND d.device_floor_tag in @floor ";
if (selectdevice.select_Layer3 != null && selectdevice.select_Layer3.Count > 0) if (selectdevice.select_Layer3 != null && selectdevice.select_Layer3.Count > 0)
deviceQue += $" AND d.device_name_tag IN @layer3 "; deviceQue += $" AND d.device_name_tag IN @layer3 ";
if (selectdevice.select_disasters != null && selectdevice.select_disasters.Count > 0) if (selectdevice.select_disasters == null || selectdevice.select_disasters.Count == 0)
disasQue = " where dd.device_system_value IN @disasters "; selectdevice.select_disasters = new List<int>();
deviceQue += $" AND d.device_building_tag in @building_tag ";
disasQue = " where dd.device_system_value IN @disasters ";
var sqlString = @$"select var sqlString = @$"select
d.device_guid, d.device_guid,
d.device_number, d.device_number,

View File

@ -569,7 +569,7 @@
`;*@ `;*@
var html = ` var html = `
<a href="http://${row.ip_address}/file/BajascriptTest/_FloorMap.html?building_tag=${row.building_tag}&floor_guid=${row.floorguid}&layer3=${row.layer3}&device_number=${data}&show_cctv=1&jwt=${localStorage.getItem('JWT-Authorization')}" target="_blank"> <a href="https://${row.ip_address}/file/BajascriptTest/_FloorMap.html?building_tag=${row.building_tag}&main_system_tag=${row.layer2}&floor_guid=${row.floorguid}&sub_system_tag=${row.layer3}&device_number=${data}&show_cctv=1&jwt=${localStorage.getItem('JWT-Authorization')}" target="_blank">
${data} ${data}
</a> </a>
`; `;
@ -639,7 +639,9 @@
is_need_reload = true; is_need_reload = true;
} }
$(`button[id^=buildingBtn]`).removeClass("btn-danger").addClass("btn-secondary");
$(`button[id^=buildingBtn]`).removeClass("btn-danger");
$(`button[id^=disasterBtn]`).removeClass("btn-danger");
enable_alarm_timer = true; enable_alarm_timer = true;
is_need_reload = false; is_need_reload = false;
@ -711,7 +713,8 @@
backfill_layer3_alarm_device_amount[temp_layer3_index].device_amount += 1; backfill_layer3_alarm_device_amount[temp_layer3_index].device_amount += 1;
} }
$(`#buildingBtn${temp_device.building_tag}`).removeClass("btn-secondary").addClass("btn-danger"); $(`#buildingBtn${temp_device.building_tag}`).addClass("btn-danger");
$(`#disasterBtn${temp_device.disaster}`).addClass("btn-danger");
alarm_data.push(obj); alarm_data.push(obj);
} }
}); });
@ -822,13 +825,13 @@
temp_all_disaster = []; temp_all_disaster = [];
$('#disaster').empty(); $('#disaster').empty();
$('#disaster').append(`<button type="button" class="btn btn-secondary ml-2" onclick="AllDisaster()">全選</button>`); $('#disaster').append(`<button type="button" class="btn btn-secondary ml-2 all-btn" onclick="AllDisaster()">全選</button>`);
var html = ""; var html = "";
rel.data.forEach(function (item, index) { rel.data.forEach(function (item, index) {
temp_all_disaster.push(item.value); temp_all_disaster.push(item.value);
SelectedFilter.disasters.push(item.value); SelectedFilter.disasters.push(item.value);
html += '<button type="button" class="btn btn-success ml-2" onclick="SelectDisaster(' + item.value + ',this)">' + item.name + '</button>'; html += '<button type="button" id="disasterBtn'+ item.value +'" class="btn btn-success ml-2" onclick="SelectDisaster(' + item.value + ',this)">' + item.name + '</button>';
}); });
$('#disaster').append(html); $('#disaster').append(html);
@ -887,15 +890,16 @@
function AllDisaster() { function AllDisaster() {
if (select_all_disaster) { //全選 -> 取消全選 if (select_all_disaster) { //全選 -> 取消全選
select_all_disaster = false; select_all_disaster = false;
$('#disaster').find('.btn-success').removeClass('btn-success').addClass('btn-outline-success'); $('#disaster').find('button').not(".all-btn").removeClass('btn-success').removeClass('btn-danger').addClass('btn-outline-success');
SelectedFilter.disasters = []; SelectedFilter.disasters = [];
} else { //取消全選 -> 全選 } else { //取消全選 -> 全選
select_all_disaster = true; select_all_disaster = true;
$('#disaster').find('.btn-outline-success').removeClass('btn-outline-success').addClass('btn-success'); $('#disaster').find('button').not(".all-btn").removeClass('btn-outline-success').addClass('btn-success');
SelectedFilter.disasters = temp_all_disaster; SelectedFilter.disasters = temp_all_disaster;
} }
is_need_reload = true; is_need_reload = true;
ResetDeviceTable();
ChangeFilterBuilding(); ChangeFilterBuilding();
UpdateDeviceAmount(); UpdateDeviceAmount();
@*console.log("SelectedFilter", SelectedFilter);*@ @*console.log("SelectedFilter", SelectedFilter);*@
@ -953,10 +957,10 @@
<button id="buildingBtn${building.tag}" type="button" class="btn btn-secondary" data-tag="${building.tag}" >${building.name}</button> <button id="buildingBtn${building.tag}" type="button" class="btn btn-secondary" data-tag="${building.tag}" >${building.name}</button>
</div>`; </div>`;
}); });
$('#building').append(`<button type="button" class="btn btn-secondary waves-effect waves-themed d-inline-block ml-2" onclick="AllBuilding()"> 全選 </button>`); $('#building').append(`<button type="button" class="btn btn-secondary waves-effect waves-themed d-inline-block ml-2 all-btn" onclick="AllBuilding()"> 全選 </button>`);
$('#building').append(html); $('#building').append(html);
$('#building').find('div').first().click(); $('#building').find('button').first().click();
} }
else { else {
var html = ""; var html = "";
@ -964,7 +968,7 @@
html += '<button type="button" class="btn btn-secondary ml-2" onclick="SelectBuilding(\'' + building.tag + '\',this)">' + building.name + '</button>'; html += '<button type="button" class="btn btn-secondary ml-2" onclick="SelectBuilding(\'' + building.tag + '\',this)">' + building.name + '</button>';
}); });
$('#building').append(`<button type="button" class="btn btn-secondary waves-effect waves-themed d-inline-block ml-2" onclick="AllBuilding()"> 全選 </button>`); $('#building').append(`<button type="button" class="btn btn-secondary waves-effect waves-themed d-inline-block ml-2 all-btn" onclick="AllBuilding()"> 全選 </button>`);
$('#building').append(html); $('#building').append(html);
$('#building').find('button').first().click(); $('#building').find('button').first().click();
@ -1138,14 +1142,15 @@
function AllBuilding() { function AllBuilding() {
if (select_all_building) { //全選 -> 取消全選 if (select_all_building) { //全選 -> 取消全選
select_all_building = false; select_all_building = false;
$('#building').find('div > button.btn-success').removeClass('btn-success').addClass('btn-secondary'); $('#building').find('button').not(".all-btn").removeClass('btn-success').removeClass('btn-danger').addClass('btn-secondary');
} else { //取消全選 -> 全選 } else { //取消全選 -> 全選
select_all_building = true; select_all_building = true;
$('#building').find('div > button.btn-secondary').removeClass('btn-secondary').addClass('btn-success'); $('#building').find('button').not(".all-btn").removeClass('btn-secondary').addClass('btn-success');
} }
resetCalSelectBuilding(); resetCalSelectBuilding();
is_need_reload = true; is_need_reload = true;
ResetDeviceTable();
UpdateDeviceAmount(); UpdateDeviceAmount();
@*console.log("SelectedFilter", SelectedFilter);*@ @*console.log("SelectedFilter", SelectedFilter);*@
} }
@ -1302,11 +1307,12 @@
//#region 重設設備表格 //#region 重設設備表格
function ResetDeviceTable() { function ResetDeviceTable() {
if ((SelectedFilter.disasters == null || SelectedFilter.disasters.length <= 0) //if ((SelectedFilter.disasters == null || SelectedFilter.disasters.length <= 0)
|| (SelectedFilter.building_tag == null || SelectedFilter.building_tag.length <= 0) // || (SelectedFilter.building_tag == null || SelectedFilter.building_tag.length <= 0)
) { //) {
return; // alarmDeviceTable.clear().draw();
} // return;
//}
//if (changeBuilding != "" && changeBuilding != SelectedFilter.building_tag) { //if (changeBuilding != "" && changeBuilding != SelectedFilter.building_tag) {
// alarmDeviceTable.clear().draw(); // alarmDeviceTable.clear().draw();