diff --git a/CaseAccounting/CaseAccountingProviderView/wwwroot/js/case/case-update.js b/CaseAccounting/CaseAccountingProviderView/wwwroot/js/case/case-update.js index 952ab06..14d1791 100644 --- a/CaseAccounting/CaseAccountingProviderView/wwwroot/js/case/case-update.js +++ b/CaseAccounting/CaseAccountingProviderView/wwwroot/js/case/case-update.js @@ -9,8 +9,32 @@ const caseId = document.getElementById("vb-id").dataset.id; var specializations = []; +const formatDate = (dateString) => { + const date = new Date(dateString); + const year = date.getFullYear(); + const month = ('0' + (date.getMonth() + 1)).slice(-2); + const day = ('0' + date.getDate()).slice(-2); + return `${year}-${month}-${day}`; +}; + window.addEventListener("load", async () => { try { + let specializationId; + await $.ajax({ + url: `/case/get?id=${caseId}`, + type: "GET", + contentType: "json" + }).done((result) => { + nameInput.value = result.name; + applicantInput.value = result.applicant; + defendantInput.value = result.defendant; + annotationInput.value = result.annotation; + dateInput.value = formatDate(result.date); + specializationId = result.specializationId; + }); + + let specializationIndex; + await $.ajax({ url: `/case/getallspecializations`, type: "GET", @@ -22,9 +46,14 @@ window.addEventListener("load", async () => { option.value = specialization.id; option.innerHTML = specialization.name; specializationSelect.appendChild(option); + if(specialization.id === specializationId){ + specializationIndex = specializationSelect.selectedIndex; + } specializationSelect.selectedIndex = -1; }); }); + + specializationSelect.selectedIndex = specializationIndex; } catch (error) { console.error(error); } diff --git a/CaseAccounting/CaseAccountingProviderView/wwwroot/js/deal/deal-update.js b/CaseAccounting/CaseAccountingProviderView/wwwroot/js/deal/deal-update.js index 9ca9a0f..f5ceec4 100644 --- a/CaseAccounting/CaseAccountingProviderView/wwwroot/js/deal/deal-update.js +++ b/CaseAccounting/CaseAccountingProviderView/wwwroot/js/deal/deal-update.js @@ -4,6 +4,22 @@ const responsibilitiesInput = document.getElementById("responsibilities-input"); const dateInput = document.getElementById("date-input"); const dealId = document.getElementById("vb-id").dataset.id; +window.addEventListener("load", async () => { + try { + await $.ajax({ + url: `/deal/get?id=${dealId}`, + type: "GET", + contentType: "json" + }).done((result) => { + subjectInput.value = result.subject; + responsibilitiesInput.value = result.responsibilities; + dateInput.value = new Date(result.date); + }); + } catch (error) { + console.error(error); + } +}); + updateBtn.addEventListener("click", () => { if (!correctData()) { return; diff --git a/CaseAccounting/CaseAccountingProviderView/wwwroot/js/hearing/hearing-update.js b/CaseAccounting/CaseAccountingProviderView/wwwroot/js/hearing/hearing-update.js index 14101ea..32f48a0 100644 --- a/CaseAccounting/CaseAccountingProviderView/wwwroot/js/hearing/hearing-update.js +++ b/CaseAccounting/CaseAccountingProviderView/wwwroot/js/hearing/hearing-update.js @@ -8,6 +8,18 @@ var cases = []; window.addEventListener("load", async () => { try { + let caseId; + await $.ajax({ + url: `/hearing/get?id=${hearingId}`, + type: "GET", + contentType: "json" + }).done((result) => { + informationInput.value = result.information; + dateInput.value = new Date(result.date); + caseId = result.caseId; + }); + + let caseIndex; $.ajax({ url: "/case/getallbyuser", type: "GET", @@ -19,9 +31,14 @@ window.addEventListener("load", async () => { option.value = element.id; option.innerHTML = "Дело №" + element.id; caseSelect.appendChild(option); + if(element.id === caseId){ + caseIndex = caseSelect.selectedIndex; + } caseSelect.selectedIndex = -1; }); }); + + caseSelect.selectedIndex = caseIndex; } catch (error) { console.error(error); }