Добавил диаграмму
This commit is contained in:
parent
636af51602
commit
db5681fc25
@ -76,6 +76,11 @@ namespace CaseAccountingBusinessLogic.BusinessLogics
|
||||
return list;
|
||||
}
|
||||
|
||||
public List<SpecializationCasesViewModel> GetSpecializationCases()
|
||||
{
|
||||
return _caseStorage.GetSpecializationCases() ?? new List<SpecializationCasesViewModel>();
|
||||
}
|
||||
|
||||
public bool Update(CaseBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
|
@ -16,5 +16,6 @@ namespace CaseAccountingContracts.BusinessLogicContracts
|
||||
bool Create(CaseBindingModel model);
|
||||
bool Update(CaseBindingModel model);
|
||||
bool Delete(CaseBindingModel model);
|
||||
List<SpecializationCasesViewModel> GetSpecializationCases();
|
||||
}
|
||||
}
|
||||
|
@ -19,5 +19,6 @@ namespace CaseAccountingContracts.StoragesContracts
|
||||
CaseViewModel? Delete(CaseBindingModel model);
|
||||
|
||||
List<HearingViewModel> GetCaseHearings(CaseSearchModel model);
|
||||
List<SpecializationCasesViewModel>? GetSpecializationCases();
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CaseAccountingContracts.ViewModels
|
||||
{
|
||||
public class SpecializationCasesViewModel
|
||||
{
|
||||
public int Count { get; set; }
|
||||
public string Name { get; set; } = string.Empty;
|
||||
}
|
||||
}
|
@ -185,5 +185,22 @@ namespace CaseAccountingDataBaseImplement.Implements
|
||||
return hearings;
|
||||
}
|
||||
|
||||
public List<SpecializationCasesViewModel>? GetSpecializationCases()
|
||||
{
|
||||
using var context = new CaseAccountingDatabase();
|
||||
var result = context.Specializations
|
||||
.GroupJoin(
|
||||
context.Cases,
|
||||
status => status.Id,
|
||||
caseModel => caseModel.SpecializationId,
|
||||
(status, caseModels) => new SpecializationCasesViewModel
|
||||
{
|
||||
Name = status.Name,
|
||||
Count = caseModels.Count()
|
||||
})
|
||||
.ToList();
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -129,5 +129,15 @@ namespace CaseAccountingProviderView.Controllers
|
||||
List<SpecializationViewModel>? specializationModel = APIUser.GetRequest<List<SpecializationViewModel>>($"api/case/getallspecializations");
|
||||
return specializationModel ?? new();
|
||||
}
|
||||
}
|
||||
|
||||
public List<SpecializationCasesViewModel> GetSpecializationCases()
|
||||
{
|
||||
if (APIUser.User == null)
|
||||
{
|
||||
return new();
|
||||
}
|
||||
List<SpecializationCasesViewModel>? specializationCases = APIUser.GetRequest<List<SpecializationCasesViewModel>>($"api/case/getspecializationcases");
|
||||
return specializationCases ?? new();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -40,6 +40,11 @@ namespace CaseAccountingProviderView.Controllers
|
||||
return View();
|
||||
}
|
||||
|
||||
public IActionResult Diagram()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public int[]? SpecializationCaselist([FromBody] CaseSpecializationListBindingModel listModel)
|
||||
{
|
||||
|
@ -0,0 +1,15 @@
|
||||
|
||||
<div class="text-center">
|
||||
<h1 class="display-4">Круговая диаграмма</h1>
|
||||
</div>
|
||||
|
||||
<div class="container">
|
||||
<button class="btn btn-success mt-4" id="btnStatus">Статистика по специализации дел</button>
|
||||
<div class="container col-8 mt-4">
|
||||
<canvas id="myChart"></canvas>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
|
||||
<script src="~/js/diagram/diagram.js" asp-append-version="true"></script>
|
@ -23,6 +23,7 @@
|
||||
<a class="nav-link text-white" asp-area="" asp-controller="Home" asp-action="Hearings">Слушания</a>
|
||||
<a class="nav-link text-white" asp-area="" asp-controller="Home" asp-action="SpecializationCaselist">Получение список</a>
|
||||
<a class="nav-link text-white" asp-area="" asp-controller="Home" asp-action="GetReport">Получение отчёта</a>
|
||||
<a class="nav-link text-white" asp-area="" asp-controller="Home" asp-action="Diagram">Формирование диаграммы</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -19,7 +19,6 @@ const formatDate = (dateString) => {
|
||||
|
||||
window.addEventListener("load", async () => {
|
||||
try {
|
||||
let specializationId;
|
||||
await $.ajax({
|
||||
url: `/case/get?id=${caseId}`,
|
||||
type: "GET",
|
||||
@ -30,11 +29,8 @@ window.addEventListener("load", async () => {
|
||||
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",
|
||||
@ -46,14 +42,9 @@ 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);
|
||||
}
|
||||
@ -84,7 +75,7 @@ updateBtn.addEventListener("click", () => {
|
||||
"Name": nameInput.value,
|
||||
"Applicant": applicantInput.value,
|
||||
"Defendant": defendantInput.value,
|
||||
"Date": new Date(dateInput.value),
|
||||
"Date": dateInput.value,
|
||||
"Annotation": annotationInput.value,
|
||||
"SpecializationId": parseInt(specializationSelect.value),
|
||||
};
|
||||
|
@ -4,6 +4,14 @@ const responsibilitiesInput = document.getElementById("responsibilities-input");
|
||||
const dateInput = document.getElementById("date-input");
|
||||
const dealId = document.getElementById("vb-id").dataset.id;
|
||||
|
||||
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 {
|
||||
await $.ajax({
|
||||
@ -13,7 +21,7 @@ window.addEventListener("load", async () => {
|
||||
}).done((result) => {
|
||||
subjectInput.value = result.subject;
|
||||
responsibilitiesInput.value = result.responsibilities;
|
||||
dateInput.value = new Date(result.date);
|
||||
dateInput.value = formatDate(result.date);
|
||||
});
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
@ -44,7 +52,7 @@ updateBtn.addEventListener("click", () => {
|
||||
"Id": parseInt(dealId),
|
||||
"Subject": subjectInput.value,
|
||||
"Responsibilities": responsibilitiesInput.value,
|
||||
"Date": new Date(dateInput.value)
|
||||
"Date": dateInput.value
|
||||
};
|
||||
console.log(dealModel)
|
||||
$.ajax({
|
||||
|
@ -0,0 +1,52 @@
|
||||
var btnStatus = document.getElementById('btnStatus');
|
||||
var casespecializations = [];
|
||||
|
||||
window.addEventListener('load', async () => {
|
||||
await $.ajax({
|
||||
url: "/case/getspecializationcases",
|
||||
type: "GET",
|
||||
contentType: "json"
|
||||
}).done((result) => {
|
||||
casespecializations = result;
|
||||
console.log(casespecializations);
|
||||
});
|
||||
})
|
||||
|
||||
var ctx = document.getElementById('myChart').getContext('2d');
|
||||
var chart;
|
||||
|
||||
function drawStatusChart() {
|
||||
var edStatus = [];
|
||||
var edCount = [];
|
||||
console.log(casespecializations)
|
||||
casespecializations.forEach((item) => {
|
||||
edStatus.push(item.name);
|
||||
});
|
||||
casespecializations.forEach((item) => {
|
||||
edCount.push(item.count);
|
||||
});
|
||||
var statusData = {
|
||||
labels: edStatus,
|
||||
datasets: [{
|
||||
data: edCount
|
||||
}]
|
||||
};
|
||||
|
||||
// Clear the previous chart if it exists
|
||||
if (chart) {
|
||||
chart.destroy();
|
||||
}
|
||||
|
||||
chart = new Chart(ctx, {
|
||||
type: 'pie',
|
||||
data: statusData,
|
||||
options: {
|
||||
responsive: true
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
btnStatus.addEventListener('click', function () {
|
||||
drawStatusChart();
|
||||
});
|
||||
|
@ -6,21 +6,25 @@ const hearingId = document.getElementById("vb-id").dataset.id;
|
||||
|
||||
var cases = [];
|
||||
|
||||
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 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;
|
||||
dateInput.value = formatDate(result.date);
|
||||
});
|
||||
|
||||
let caseIndex;
|
||||
$.ajax({
|
||||
await $.ajax({
|
||||
url: "/case/getallbyuser",
|
||||
type: "GET",
|
||||
contentType: "json"
|
||||
@ -31,14 +35,9 @@ 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);
|
||||
}
|
||||
@ -68,7 +67,7 @@ updateBtn.addEventListener("click", () => {
|
||||
"Id": parseInt(hearingId),
|
||||
"Information": informationInput.value,
|
||||
"CaseId": parseInt(caseSelect.value),
|
||||
"Date": new Date(dateInput.value)
|
||||
"Date": dateInput.value
|
||||
};
|
||||
console.log(hearingModel)
|
||||
$.ajax({
|
||||
|
@ -59,7 +59,20 @@ namespace CaseAccountingRestApi.Controllers
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[HttpGet]
|
||||
public List<SpecializationCasesViewModel> GetSpecializationCases()
|
||||
{
|
||||
try
|
||||
{
|
||||
return _logic.GetSpecializationCases();
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void Create(CaseBindingModel model)
|
||||
{
|
||||
try
|
||||
|
Loading…
Reference in New Issue
Block a user