123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192 |
- using AntDesign;
- using Blazor.ECharts.Options;
- using Microsoft.AspNetCore.Components;
- using System;
- using System.Collections.Generic;
- using System.Data;
- using System.Linq;
- using System.Text.Json;
- using System.Threading.Tasks;
- using wispro.sp.share;
- using wispro.sp.web.Services;
- using Blazor.ECharts.Options;
- using Blazor.ECharts.Options.Enum;
- using L = Blazor.ECharts.Options.Series.Line;
- namespace wispro.sp.web.Pages.Report
- {
- public partial class AppealTrend
- {
- private int iType = 3;
- private DateTime? start = new DateTime(DateTime.Now.Year, 1, 1);
- private DateTime? end = DateTime.Now;
- private EChartsOption<L.Line> option;
- private Blazor.ECharts.Components.ELine chart;
- internal class TJType
- {
- public string Name { get; set; }
- public int value { get; set; }
- }
- List<TJType> Types = new List<TJType>
- {
- new TJType { value = 3,Name = "申诉人统计" },
- new TJType { value = 4,Name = "申诉类型统计" },
- new TJType { value = 5,Name = "部门申诉统计" },
-
- };
- share.ChartDatas Datas = new share.ChartDatas()
- {
- Title = "初始化标题",
- Datas = new List<share.ChartData>() {
- new share.ChartData(){ type ="部门一", value =1, year="2022-01", CustomerType ="", CustomerYear=""},
- new share.ChartData(){ type ="部门一",value =5, year="2022-02",CustomerType ="", CustomerYear=""},
- new share.ChartData(){ type ="部门二", value =3, year="2022-01", CustomerType ="", CustomerYear=""},
- new share.ChartData(){ type ="部门二",value =4, year="2022-02",CustomerType ="", CustomerYear=""},
- new share.ChartData(){ type ="部门三",value =2.5, year="2022-02",CustomerType ="", CustomerYear=""}
- },
- ATitle = "部门",
- BTitle = "申诉月份"
- };
-
- [Inject] ReportService reportService { get; set; }
- [Inject] MessageService msgService { get; set; }
-
- private void OnTimeRangeChange(DateRangeChangedEventArgs args)
- {
- msgService.Info($"Selected Time: {JsonSerializer.Serialize(args.Dates)}");
-
- if (args.Dates?.Length > 0)
- {
- //Console.WriteLine(args.Dates[0]);
-
- start = args.Dates[0];
- }
- if (args.Dates?.Length > 1)
- {
- end = args.Dates[1];
- }
- }
- private bool _noIconLoading;
- private async Task OnButtonClick()
- {
- _noIconLoading = true;
- Datas = await reportService.GetAppealReportData(iType, start, end, null);
- GetOption();
- _noIconLoading = false;
- }
- private void GetOption()
- {
- if (Datas != null)
- {
- List<object> series = new List<object>();
- DataTable dt = Datas.GetTableData();
- foreach (DataRow row in dt.Rows)
- {
- L.Line l = new L.Line();
- l.Name = row[0].ToString();
- List<double> data = new List<double>();
- for (int i = 1; i < dt.Columns.Count; i++)
- {
- double dTem = 0;
- if(!double.TryParse(row[i].ToString(), out dTem))
- {
- dTem = 0;
- }
- data.Add(dTem);
- }
- l.Data = data;
- series.Add(l);
- }
- //Console.WriteLine(System.Text.Json.JsonSerializer.Serialize(series, new JsonSerializerOptions()
- //{
- // DefaultIgnoreCondition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingNull
- //}));
- option = new()
- {
- Toolbox = new()
- {
- Show = true,
- Feature = new()
- {
- SaveAsImage = new()
- {
- PixelRatio = 2,
- Name = "保存图片"
- }
- }
- },
- Tooltip = new()
- {
- Trigger = TooltipTrigger.Item,
- Formatter = "{a} <br/>{b}: {c}"
- },
- Title = new()
- {
- Text = Datas.Title
- },
- YAxis = new()
- {
- new()
- {
- Type = AxisType.Value,
- Name = "申诉量",
- AxisLine = new()
- {
- Show = true,
- }
- }
- },
- XAxis = new()
- {
- new()
- {
- Type = AxisType.Category,
- Data = Datas.GetYear(),
- Name = Datas.BTitle
- }
- },
- Series = series
- };
- //Console.WriteLine(System.Text.Json.JsonSerializer.Serialize(option, new JsonSerializerOptions()
- //{
- // DefaultIgnoreCondition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingNull
- //}));
- }
- }
- [Inject] protected IAuthService _authService { get; set; }
- protected async override Task OnInitializedAsync()
- {
- await _authService.CanVisitResource();
- Datas = await reportService.GetAppealReportData(iType, DateTime.Parse("2022-01-01"), DateTime.Now, null);
- GetOption();
- StateHasChanged();
- await base.OnInitializedAsync();
- }
-
- }
- }
|