Добавлена функция сохранения истории обработки территорий
This commit is contained in:
@@ -13,6 +13,11 @@
|
||||
</svg>
|
||||
<span>Конструктор</span>
|
||||
</a>
|
||||
|
||||
<button onclick="Territory.report()">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"> <path d="M13.13,2H5.958c-1.1,0-2,0.9-2,2v16c0,1.1,0.9,2,2,2h12c1.1,0,2-0.9,2-2V8.828c0-0.53-0.211-1.039-0.586-1.414l-4.828-4.828 C14.169,2.211,13.66,2,13.13,2z M11.255,17.711l-1.297-1.297l-1.251,1.293c-0.39,0.39-1.024,0.39-1.414,0l0,0 c-0.39-0.39-0.39-1.024,0-1.414l1.958-1.989c0.39-0.396,1.027-0.398,1.42-0.006l1.287,1.287l2.335-2.293 c0.39-0.39,1.024-0.39,1.414,0l0,0c0.39,0.39,0.39,1.024,0,1.414l-3.042,3.008C12.274,18.102,11.644,18.1,11.255,17.711z M12.958,9 V3.5l5.5,5.5H12.958z"/></svg>
|
||||
<span>Звіт опрацьовання</span>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="list-controls">
|
||||
|
||||
@@ -116,7 +116,7 @@ const Territory = {
|
||||
const person = working
|
||||
? `<span>Територію опрацьовує:</span> <p>${element.history.name === 'Групова' ? 'Група ' + element.history.group_id : element.history.name}</p>`
|
||||
: `<span>Територія не опрацьовується</span>`;
|
||||
|
||||
|
||||
return `
|
||||
<div class="card">
|
||||
<i style="background-image: url(https://sheep-service.com/cards/house/T${element.house.id}.webp);"></i>
|
||||
@@ -248,5 +248,32 @@ const Territory = {
|
||||
|
||||
Territory.house.setHTML();
|
||||
Territory.homestead.setHTML();
|
||||
},
|
||||
report: async () => {
|
||||
const uuid = localStorage.getItem("uuid");
|
||||
const url = `${CONFIG.api}generator/report/territories`;
|
||||
await fetch(url, {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
"Authorization": uuid
|
||||
}
|
||||
}).then(response => {
|
||||
if (!response.ok) throw new Error('Network response was not ok');
|
||||
return response.blob();
|
||||
})
|
||||
.then(blob => {
|
||||
const link = document.createElement('a');
|
||||
const url = window.URL.createObjectURL(blob);
|
||||
link.href = url;
|
||||
link.download = 'report.xlsx';
|
||||
document.body.appendChild(link);
|
||||
link.click();
|
||||
link.remove();
|
||||
window.URL.revokeObjectURL(url);
|
||||
})
|
||||
.catch(err => {
|
||||
console.error('Fetch error:', err);
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user