Опубликовано через кнопку

This commit is contained in:
MeruertYes 2026-08-24 05:21:22 +00:00
parent 87693f77bd
commit be0a8e51f3

View File

@ -257,7 +257,10 @@
</div>
<div id="tab-analysis" class="hidden">
<div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px;">
<h3>Выявленные замечания</h3>
<button class="btn btn-primary" onclick="openAddRemarkModal()">+ Добавить замечание</button>
</div>
<div id="remarks-list" style="margin-top: 16px;"></div>
</div>
@ -576,7 +579,9 @@
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ remarks: check.remarks })
});
loadCheckDetail(currentCheckId);
renderRemarks(check.remarks);
renderReport(check);
load();
}
}
@ -588,7 +593,9 @@
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ remarks: check.remarks })
});
loadCheckDetail(currentCheckId);
renderRemarks(check.remarks);
renderReport(check);
load();
}
document.getElementById("btn-copy-response").addEventListener("click", () => {
@ -664,8 +671,45 @@
function closeModal() {
document.getElementById("modal-add-remark").classList.add("hidden");
document.getElementById("add-remark-form").reset();
}
function openAddRemarkModal() {
document.getElementById("modal-add-remark").classList.remove("hidden");
}
document.getElementById("add-remark-form").addEventListener("submit", async (e) => {
e.preventDefault();
const formData = new FormData(e.target);
const data = Object.fromEntries(formData.entries());
const check = await (await fetch(`/api/checks/${currentCheckId}`)).json();
const newRemark = {
id: Date.now(),
category: data.category,
type: data.type || "Ручное",
document: data.document || "Общее",
text: data.text,
recommendation: data.recommendation || "",
confirmed: true,
page: null
};
check.remarks = check.remarks || [];
check.remarks.push(newRemark);
await fetch(`/api/checks/${currentCheckId}`, {
method: "PUT",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ remarks: check.remarks })
});
closeModal();
renderRemarks(check.remarks);
renderReport(check);
load();
});
load();
</script>
</body>