This commit is contained in:
dev02 2023-05-22 12:22:39 +08:00
commit 568a9e7e53
7 changed files with 81 additions and 29 deletions

View File

@ -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)

View File

@ -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 = [];

View File

@ -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) {

View File

@ -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") {

View File

@ -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>

View File

@ -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>
}

View File

@ -54,7 +54,7 @@ $(function () {
"Please check your input."
);
})
//#region 個人資訊表單驗證
@ -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 () {
});