Case_accounting/CaseAccounting/CaseAccountingProviderView/wwwroot/js/hearing/hearing-update.js

65 lines
1.7 KiB
JavaScript
Raw Normal View History

const updateBtn = document.getElementById("update-button");
const informationInput = document.getElementById("information-input");
const dateInput = document.getElementById("date-input");
const caseSelect = document.getElementById("case-select");
const hearingId = document.getElementById("vb-id").dataset.id;
2023-05-19 02:05:22 +04:00
var cases = [];
window.addEventListener("load", async () => {
try {
$.ajax({
url: "/case/getallbyuser",
2023-05-19 02:05:22 +04:00
type: "GET",
contentType: "json"
}).done((result) => {
cases = result;
cases.forEach((element) => {
const option = document.createElement("option");
option.value = element.id;
option.innerHTML = "Дело №" + element.id;
caseSelect.appendChild(option);
caseSelect.selectedIndex = -1;
});
2023-05-19 02:05:22 +04:00
});
} catch (error) {
console.error(error);
}
});
updateBtn.addEventListener("click", () => {
if (!correctData()) {
return;
}
if (!validate()) {
return;
}
});
const correctData = function () {
return true;
};
const validate = function () {
return true;
};
updateBtn.addEventListener("click", () => {
let hearingModel = {
"Id": parseInt(hearingId),
"Information": informationInput.value,
"CaseId": parseInt(caseSelect.value),
"Date": new Date(dateInput.value)
};
console.log(hearingModel)
$.ajax({
url: "/hearing/update",
type: "POST",
contentType: "application/json",
data: JSON.stringify(hearingModel)
}).done(() => {
window.location.href = "/Home/Hearings";
});
});