[前台][緊急應變] GetEmergencySetting, GetContentAndMakeItem, BuildInfoList API 程序調整 | [緊急應變][聯絡清單] 前端程序api串接調整 | [緊急應變][設備總覽] 前端程序api串接調整 | [緊急應變][紀錄查詢] 前端程序api串接調整 | [緊急應變][AED裝置設定] 前端程序api串接調整、下載程序調整 | [緊急應變][滅火器裝置設定] 前端程序api串接調整、下載程序調整 |
This commit is contained in:
parent
8a2ac8e393
commit
c5ee9299ab
@ -267,7 +267,7 @@ namespace FrontendWebApi.ApiControllers
|
||||
try
|
||||
{
|
||||
Emergency_Setting_tables = await backendRepository.GetAllAsync<EmergencySettingTable>($@"
|
||||
select v.system_key big_setting_name,* from emergency_setting es left join variable v on es.big_setting = v.id
|
||||
select v.system_key big_setting_name,es.* from emergency_setting es left join variable v on es.big_setting = v.id
|
||||
where es.big_setting = {selectsetting} and es.deleted = 0 order by es.priority");
|
||||
apiResult.Code = "0000";
|
||||
apiResult.Data = Emergency_Setting_tables;
|
||||
@ -296,7 +296,7 @@ namespace FrontendWebApi.ApiControllers
|
||||
try
|
||||
{
|
||||
var Emergency_Setting_tables = await backendRepository.GetOneAsync<EmergencyitemWithguid>($@"
|
||||
select v.system_key big_setting_name,* from emergency_setting es left join variable v on es.big_setting = v.id
|
||||
select v.system_key big_setting_name,es.* from emergency_setting es left join variable v on es.big_setting = v.id
|
||||
where es.emergency_guid = '{post.emergency_guid}'");
|
||||
|
||||
if (post.make_item == 1)
|
||||
|
@ -88,7 +88,7 @@ namespace FrontendWebApi.ApiControllers
|
||||
|
||||
try
|
||||
{
|
||||
var sqlString = @$"select building_tag as Value, full_name as Name from building a where a.deleted = 0 and a.status = 0 ORDER BY A.priority ASC, A.created_at DESC";
|
||||
var sqlString = @$"select building_tag as Value, full_name as Name from building a where a.deleted = 0 and a.status = 0 ORDER BY a.priority ASC, a.created_at DESC";
|
||||
KeyValue = await backendRepository.GetAllAsync<KeyValue>(sqlString);
|
||||
|
||||
apiResult.Code = "0000";
|
||||
|
@ -106,7 +106,7 @@
|
||||
$(row).attr('guid', data.emergency_guid);
|
||||
},
|
||||
"ajax": {
|
||||
"url": "/EmergencyContact/EmergencyContactTable",
|
||||
"url": "/api/EmergencyContact/EmergencyContactTable",
|
||||
"type": "POST",
|
||||
"data": function (d) {
|
||||
d.selectgroupidlist = selectgroupidlist
|
||||
@ -116,7 +116,7 @@
|
||||
toast_error(rel.msg);
|
||||
return;
|
||||
}
|
||||
data = rel.data.data;
|
||||
data = rel.data;
|
||||
if (data == null || data.length == 0) {
|
||||
|
||||
this.data = [];
|
||||
|
@ -767,10 +767,10 @@
|
||||
device_amount: layer3.device_amount
|
||||
}
|
||||
|
||||
var temp_building_index = backfill_building_device_amount.findIndex(x => x.building_tag == building.guid);
|
||||
var temp_building_index = backfill_building_device_amount.findIndex(x => x.building_tag == building.tag);
|
||||
if (temp_building_index < 0) {
|
||||
var building_obj = {
|
||||
building_tag: building.guid,
|
||||
building_tag: building.tag,
|
||||
device_amount: new_layer3.device_amount
|
||||
}
|
||||
|
||||
@ -779,10 +779,10 @@
|
||||
backfill_building_device_amount[temp_building_index].device_amount += new_layer3.device_amount;
|
||||
}
|
||||
|
||||
var temp_layer2_index = backfill_layer2_device_amount.findIndex(x => x.value == layer2.value && x.building_tag == building.guid)
|
||||
var temp_layer2_index = backfill_layer2_device_amount.findIndex(x => x.value == layer2.value && x.building_tag == building.tag)
|
||||
if (temp_layer2_index < 0) {
|
||||
var layer2_obj = {
|
||||
building_tag: building.guid,
|
||||
building_tag: building.tag,
|
||||
value: layer2.value,
|
||||
device_amount: new_layer3.device_amount
|
||||
}
|
||||
@ -792,10 +792,10 @@
|
||||
backfill_layer2_device_amount[temp_layer2_index].device_amount += new_layer3.device_amount;
|
||||
}
|
||||
|
||||
var temp_layer3_index = backfill_layer3_device_amount.findIndex(x => x.layer3 == layer3.value && x.layer2 == layer2.value && x.building_tag == building.guid)
|
||||
var temp_layer3_index = backfill_layer3_device_amount.findIndex(x => x.layer3 == layer3.value && x.layer2 == layer2.value && x.building_tag == building.tag)
|
||||
if (temp_layer3_index < 0) {
|
||||
var layer3_obj = {
|
||||
building_tag: building.guid,
|
||||
building_tag: building.tag,
|
||||
layer2: layer2.value,
|
||||
layer3: layer3.value,
|
||||
device_amount: new_layer3.device_amount
|
||||
@ -900,7 +900,7 @@
|
||||
all_device_group.forEach(function (disaster, disaster_index) {
|
||||
if (SelectedFilter.disasters.findIndex(x => x == disaster.value) > -1) { //表示已選擇該防災類型
|
||||
disaster.groupBuildings.forEach(function (building, building_index) {
|
||||
if (temp_all_building.findIndex(x => x.guid == building.guid) < 0) { //表示未加入,需加入
|
||||
if (temp_all_building.findIndex(x => x.tag == building.tag) < 0) { //表示未加入,需加入
|
||||
temp_all_building.push(building);
|
||||
}
|
||||
});
|
||||
@ -912,16 +912,16 @@
|
||||
var html = "";
|
||||
temp_all_building.forEach(function (building, building_index) {
|
||||
|
||||
var building_device_amount = backfill_building_device_amount.filter(x => x.building_tag == building.guid)[0];
|
||||
var building_device_amount = backfill_building_device_amount.filter(x => x.building_tag == building.tag)[0];
|
||||
|
||||
@*html += `<div class="btn-group ml-2" onclick="SelectBuilding('${building.guid}',this)">
|
||||
@*html += `<div class="btn-group ml-2" onclick="SelectBuilding('${building.tag}',this)">
|
||||
<button type="button" class="btn btn-secondary">${building.name}</button>
|
||||
<button type="button" class="btn btn-secondary building_device_amount" id="${building.guid}_device_amount">${building_device_amount.device_amount}</button>
|
||||
<button type="button" class="btn btn-secondary building_device_amount" id="${building.tag}_device_amount">${building_device_amount.device_amount}</button>
|
||||
</div>`;*@
|
||||
|
||||
html += `<div class="btn-group ml-2" onclick="SelectBuilding('${building.guid}',this)">
|
||||
html += `<div class="btn-group ml-2" onclick="SelectBuilding('${building.tag}',this)">
|
||||
<button type="button" class="btn btn-secondary">${building.name}</button>
|
||||
<button type="button" class="btn btn-secondary building_device_amount" id="${building.guid}_device_amount">0</button>
|
||||
<button type="button" class="btn btn-secondary building_device_amount" id="${building.tag}_device_amount">0</button>
|
||||
</div>`;
|
||||
});
|
||||
|
||||
@ -932,7 +932,7 @@
|
||||
else {
|
||||
var html = "";
|
||||
temp_all_building.forEach(function (building, building_index) {
|
||||
html += '<button type="button" class="btn btn-secondary ml-2" onclick="SelectBuilding(\'' + building.guid + '\',this)">' + building.name + '</button>';
|
||||
html += '<button type="button" class="btn btn-secondary ml-2" onclick="SelectBuilding(\'' + building.tag + '\',this)">' + building.name + '</button>';
|
||||
});
|
||||
|
||||
$('#building').append(html);
|
||||
@ -966,7 +966,7 @@
|
||||
all_device_group.forEach(function (disaster, disaster_index) {
|
||||
if (SelectedFilter.disasters.findIndex(x => x == disaster.value) > -1) { //抓取已選擇的防災類型的棟別內容
|
||||
disaster.groupBuildings.forEach(function (building, building_index) {
|
||||
if (building.guid == SelectedFilter.building_tag) { //抓取選擇棟別的底下樓層
|
||||
if (building.tag == SelectedFilter.building_tag) { //抓取選擇棟別的底下樓層
|
||||
building.groupFloors.forEach(function (floor, floor_index) {
|
||||
if (temp_all_floor.findIndex(x => x.guid == floor.guid) < 0) { //表示未加入,需加入
|
||||
temp_all_floor.push(floor);
|
||||
@ -1037,7 +1037,7 @@
|
||||
all_device_group.forEach(function (disaster, disaster_index) {
|
||||
if (SelectedFilter.disasters.findIndex(x => x == disaster.value) > -1) { //抓取選擇防災類型的底下棟別
|
||||
disaster.groupBuildings.forEach(function (building, building_index) {
|
||||
if (building.guid == SelectedFilter.building_tag) { //抓取選擇棟別的底下樓層
|
||||
if (building.tag == SelectedFilter.building_tag) { //抓取選擇棟別的底下樓層
|
||||
building.groupFloors.forEach(function (floor, floor_index) {
|
||||
if (SelectedFilter.floor_guids.findIndex(x => x == floor.guid) > -1) { //抓取選擇樓層的底下大類
|
||||
floor.groupLayer2s.forEach(function (layer2, layer2_index) {
|
||||
@ -1128,7 +1128,7 @@
|
||||
all_device_group.forEach(function (disaster, disaster_index) {
|
||||
if (SelectedFilter.disasters.findIndex(x => x == disaster.value) > -1) { //抓取選擇防災類型的底下棟別
|
||||
disaster.groupBuildings.forEach(function (building, building_index) {
|
||||
if (building.guid == SelectedFilter.building_tag) { //抓取選擇棟別的底下樓層
|
||||
if (building.tag == SelectedFilter.building_tag) { //抓取選擇棟別的底下樓層
|
||||
building.groupFloors.forEach(function (floor, floor_index) {
|
||||
if (SelectedFilter.floor_guids.findIndex(x => x == floor.guid) > -1) { //抓取選擇樓層的底下大類
|
||||
floor.groupLayer2s.forEach(function (layer2, layer2_index) {
|
||||
|
@ -192,7 +192,7 @@
|
||||
$(row).attr('device', data.device_name);
|
||||
},
|
||||
"ajax": {
|
||||
"url": "/EmergencyRecord/EmergencyRecordTable",
|
||||
"url": "/api/EmergencyRecord/EmergencyRecordTable",
|
||||
"type": "POST",
|
||||
"data": function (d) {
|
||||
d.selectaDisaster = SelectaDisaster,
|
||||
@ -205,7 +205,7 @@
|
||||
toast_error(rel.msg);
|
||||
return;
|
||||
}
|
||||
data = rel.data.data;
|
||||
data = rel.data;
|
||||
if (data == null || data.length == 0) {
|
||||
|
||||
this.data = [];
|
||||
@ -252,7 +252,7 @@
|
||||
$(row).attr('guid', data.emergency_item_guid);
|
||||
},
|
||||
"ajax": {
|
||||
"url": "/EmergencyRecord/EmergencyItemTable",
|
||||
"url": "/api/EmergencyRecord/EmergencyItemTable",
|
||||
"type": "POST",
|
||||
"data": function (d) {
|
||||
d.event_guid = SelectEvent
|
||||
@ -262,7 +262,7 @@
|
||||
toast_error(rel.msg);
|
||||
return;
|
||||
}
|
||||
data = rel.data.data;
|
||||
data = rel.data;
|
||||
if (data == null || data.length == 0) {
|
||||
|
||||
this.data = [];
|
||||
@ -320,7 +320,7 @@
|
||||
|
||||
//取得所有棟別
|
||||
function GetBuild() {
|
||||
var url = "/EmergencyRecord/BuildInfoList";
|
||||
var url = "/api/EmergencyRecord/BuildInfoList";
|
||||
var send_data = {};
|
||||
$.post(url, send_data, function (rel) {
|
||||
if (rel.code != "0000") {
|
||||
|
@ -253,7 +253,17 @@
|
||||
kind: 1
|
||||
};
|
||||
var url = "/RescueDevice/ExportExcel";
|
||||
window.location = "/RescueDevice/ExportExcel?post=" + JSON.stringify(send_data);
|
||||
$.ajax({
|
||||
method: "POST",
|
||||
xhrFields: { responseType: "blob" },
|
||||
headers: { "Authorization": "Bearer " + localStorage.getItem('JWT-Authorization') },
|
||||
url: "/RescueDevice/ExportExcel",
|
||||
data: { "post": JSON.stringify(send_data) },
|
||||
success: (res, text, xhr) => {
|
||||
download(xhr, res);
|
||||
}
|
||||
})
|
||||
//window.location = "/RescueDevice/ExportExcel?post=" + JSON.stringify(send_data);
|
||||
return;
|
||||
}
|
||||
</script>
|
||||
|
@ -253,8 +253,20 @@
|
||||
kind: 0
|
||||
};
|
||||
var url = "/RescueDevice/ExportExcel";
|
||||
window.location = "/RescueDevice/ExportExcel?post=" + JSON.stringify(send_data);
|
||||
$.ajax({
|
||||
method:"POST",
|
||||
xhrFields:{responseType:"blob"},
|
||||
headers:{"Authorization":"Bearer " + localStorage.getItem('JWT-Authorization')},
|
||||
url: "/RescueDevice/ExportExcel",
|
||||
data:{"post":JSON.stringify(send_data)},
|
||||
success:(res,text,xhr) => {
|
||||
download(xhr,res);
|
||||
}
|
||||
})
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
</script>
|
||||
}
|
@ -228,6 +228,36 @@ function SaveSpinner(status) { //1:Spinner 0:還原儲存
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 下載檔案
|
||||
*/
|
||||
function download(res, blob, filename, fetchOption, callback = null) {
|
||||
// 擷取回傳 header > content-disposition (後端定義檔案名稱)
|
||||
let disposition = res.getResponseHeader("Content-Disposition");
|
||||
let sDowName = "";
|
||||
if (disposition) {
|
||||
// 解析出名稱
|
||||
sDowName = disposition.split(/filename\*=(?:utf-8'')?(.*)/gi)[1];
|
||||
if (sDowName.toLowerCase().startsWith("utf-8''"))
|
||||
sDowName = decodeURIComponent(sDowName.replace(/utf-8''/i, ""));
|
||||
else sDowName = sDowName.replace(/['"]/g, "");
|
||||
sDowName = decodeURIComponent(sDowName);
|
||||
}
|
||||
// 隱形a標籤
|
||||
const a = document.createElement("a");
|
||||
let href = URL.createObjectURL(blob);
|
||||
if (href) {
|
||||
a.href = href;
|
||||
a.download = filename || sDowName || "";
|
||||
document.body.appendChild(a);
|
||||
a.click();
|
||||
document.body.removeChild(a);
|
||||
callback ? callback() : "";
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
$(document).ready(function () {
|
||||
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user