From 9c75a284f7412bd81f949e3a09c43026ebb6491c Mon Sep 17 00:00:00 2001 From: maxnes3 <112558334+maxnes3@users.noreply.github.com> Date: Sat, 20 May 2023 04:01:37 +0400 Subject: [PATCH] =?UTF-8?q?=D0=9E=D1=81=D1=82=D0=B0=D0=BB=D0=BE=D1=81?= =?UTF-8?q?=D1=8C=20=D1=87=D1=83=D1=82=D1=8C-=D1=87=D1=83=D1=82=D1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../wwwroot/js/case/case-update.js | 29 +++++++++++++++++++ .../wwwroot/js/deal/deal-update.js | 16 ++++++++++ .../wwwroot/js/hearing/hearing-update.js | 17 +++++++++++ 3 files changed, 62 insertions(+) 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); }