AppealTrend.razor.cs 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. using AntDesign;
  2. using AntDesign.Charts;
  3. using Microsoft.AspNetCore.Components;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Data;
  7. using System.Linq;
  8. using System.Text.Json;
  9. using System.Threading.Tasks;
  10. using wispro.sp.share;
  11. using wispro.sp.web.Services;
  12. namespace wispro.sp.web.Pages.Report
  13. {
  14. public partial class AppealTrend
  15. {
  16. private int iType = 3;
  17. private DateTime? start = new DateTime(DateTime.Now.Year, 1, 1);
  18. private DateTime? end = DateTime.Now;
  19. internal class TJType
  20. {
  21. public string Name { get; set; }
  22. public int value { get; set; }
  23. }
  24. List<TJType> Types = new List<TJType>
  25. {
  26. new TJType { value = 3,Name = "申诉人统计" },
  27. new TJType { value = 4,Name = "申诉类型统计" },
  28. new TJType { value = 4,Name = "部门申诉统计" },
  29. };
  30. share.ChartDatas Datas = new share.ChartDatas()
  31. {
  32. Title = "初始化标题",
  33. Datas = new List<share.ChartData>() {
  34. new share.ChartData(){ type ="部门一", value =1, year="2022-01", CustomerType ="", CustomerYear=""},
  35. new share.ChartData(){ type ="部门一",value =5, year="2022-02",CustomerType ="", CustomerYear=""},
  36. new share.ChartData(){ type ="部门二", value =3, year="2022-01", CustomerType ="", CustomerYear=""},
  37. new share.ChartData(){ type ="部门二",value =4, year="2022-02",CustomerType ="", CustomerYear=""},
  38. new share.ChartData(){ type ="部门三",value =2.5, year="2022-02",CustomerType ="", CustomerYear=""}
  39. },
  40. ATitle = "部门",
  41. BTitle = "申诉月份"
  42. };
  43. LineConfig config = new LineConfig
  44. {
  45. Title = new AntDesign.Charts.Title
  46. {
  47. Visible = true,
  48. Text = "带数据点的折线图"
  49. },
  50. ForceFit = true,
  51. Padding = "auto",
  52. XField = "year",
  53. YField = "value",
  54. SeriesField = "type",
  55. Point = new LineViewConfigPoint
  56. {
  57. Visible = true
  58. },
  59. Label = new Label
  60. {
  61. Visible = true,
  62. Type = "point"
  63. },
  64. Legend = new Legend
  65. {
  66. Visible = false,
  67. Position = "bottom",
  68. },
  69. XAxis = new ValueCatTimeAxis
  70. {
  71. Type="time",
  72. //Visible= true,
  73. //Label = new BaseAxisLabel()
  74. //{
  75. // AutoRotate = true
  76. //},
  77. //Title = new BaseAxisTitle()
  78. //{
  79. // Text = "绩效月份",
  80. // AutoRotate = true
  81. //}
  82. },
  83. YAxis = new ValueAxis
  84. {
  85. Label = new BaseAxisLabel()
  86. {
  87. AutoRotate=true
  88. },
  89. Title = new BaseAxisTitle()
  90. {
  91. Visible=true,
  92. Text = "申诉数量"
  93. }
  94. }
  95. };
  96. [Inject] ReportService reportService { get; set; }
  97. [Inject] MessageService msgService { get; set; }
  98. private AntDesign.Charts.IChartComponent chart;
  99. private void OnTimeRangeChange(DateRangeChangedEventArgs args)
  100. {
  101. msgService.Info($"Selected Time: {JsonSerializer.Serialize(args.Dates)}");
  102. Console.WriteLine($"Selected Time: {JsonSerializer.Serialize(args.Dates)}");
  103. Console.WriteLine($"Formatted Selected Time: {JsonSerializer.Serialize(args.DateStrings)}");
  104. if (args.Dates?.Length > 0)
  105. {
  106. Console.WriteLine(args.Dates[0]);
  107. start = args.Dates[0];
  108. }
  109. if (args.Dates?.Length > 1)
  110. {
  111. Console.WriteLine(args.Dates[1]);
  112. end = args.Dates[1];
  113. }
  114. }
  115. private bool _noIconLoading;
  116. private async Task OnButtonClick()
  117. {
  118. _noIconLoading = true;
  119. Datas = await reportService.GetAppealReportData(iType, start, end, null);
  120. if (Datas != null)
  121. {
  122. config.Title.Text = Datas.Title;
  123. config.XField = Datas.ATitle;
  124. await chart.ChangeData(Datas.Datas);
  125. await chart.UpdateChart(config);
  126. StateHasChanged();
  127. }
  128. _noIconLoading = false;
  129. }
  130. protected async override Task OnInitializedAsync()
  131. {
  132. //Datas = await reportService.GetAppealReportData(iType, DateTime.Parse("2022-01-01"), DateTime.Now, null);
  133. if (Datas != null)
  134. {
  135. config.Title.Text = Datas.Title;
  136. await chart.ChangeData(Datas.Datas);
  137. await chart.UpdateChart(config);
  138. StateHasChanged();
  139. }
  140. await base.OnInitializedAsync();
  141. }
  142. }
  143. }