StaffStaticsReport.razor.cs 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  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 StaffStaticsReport
  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 = 0,Name = "代理人每月绩效统计" },
  27. new TJType { value = 2,Name = "代理人每年绩效统计" },
  28. new TJType { value = 1,Name = "部门每月绩效统计" },
  29. new TJType { value = 3,Name = "部门每年绩效统计" },
  30. new TJType { value = 4,Name = "人员专案绩效统计" },
  31. //new TJType { value = 4,Name = "部门申诉统计" },
  32. };
  33. share.ChartDatas Datas = new share.ChartDatas()
  34. {
  35. Title = "初始化标题",
  36. Datas = new List<share.ChartData>() {
  37. //new share.ChartData(){ type ="部门一", value =1, year="2022-01", CustomerType ="", CustomerYear=""},
  38. //new share.ChartData(){ type ="部门一",value =5, year="2022-02",CustomerType ="", CustomerYear=""},
  39. //new share.ChartData(){ type ="部门二", value =3, year="2022-01", CustomerType ="", CustomerYear=""},
  40. //new share.ChartData(){ type ="部门二",value =4, year="2022-02",CustomerType ="", CustomerYear=""},
  41. //new share.ChartData(){ type ="部门三",value =2.5, year="2022-02",CustomerType ="", CustomerYear=""}
  42. },
  43. ATitle = "部门",
  44. BTitle = "申诉月份"
  45. };
  46. LineConfig config = new LineConfig
  47. {
  48. Title = new AntDesign.Charts.Title
  49. {
  50. Visible = true,
  51. Text = "带数据点的折线图"
  52. },
  53. ForceFit = true,
  54. Padding = "auto",
  55. XField = "year",
  56. YField = "value",
  57. SeriesField = "type",
  58. Point = new LineViewConfigPoint
  59. {
  60. Visible = true
  61. },
  62. Label = new Label
  63. {
  64. Visible = true,
  65. Type = "point"
  66. },
  67. Legend = new Legend
  68. {
  69. Visible = false,
  70. Position = "bottom",
  71. },
  72. XAxis = new ValueCatTimeAxis
  73. {
  74. Type = "time",
  75. //Visible= true,
  76. //Label = new BaseAxisLabel()
  77. //{
  78. // AutoRotate = true
  79. //},
  80. //Title = new BaseAxisTitle()
  81. //{
  82. // Text = "绩效月份",
  83. // AutoRotate = true
  84. //}
  85. },
  86. YAxis = new ValueAxis
  87. {
  88. Label = new BaseAxisLabel()
  89. {
  90. AutoRotate = true
  91. },
  92. Title = new BaseAxisTitle()
  93. {
  94. Visible = true,
  95. Text = "申诉数量"
  96. }
  97. }
  98. };
  99. [Inject] ReportService reportService { get; set; }
  100. [Inject] MessageService msgService { get; set; }
  101. private AntDesign.Charts.IChartComponent chart;
  102. private void OnTimeRangeChange(DateRangeChangedEventArgs args)
  103. {
  104. msgService.Info($"Selected Time: {JsonSerializer.Serialize(args.Dates)}");
  105. Console.WriteLine($"Selected Time: {JsonSerializer.Serialize(args.Dates)}");
  106. Console.WriteLine($"Formatted Selected Time: {JsonSerializer.Serialize(args.DateStrings)}");
  107. if (args.Dates?.Length > 0)
  108. {
  109. Console.WriteLine(args.Dates[0]);
  110. start = args.Dates[0];
  111. }
  112. if (args.Dates?.Length > 1)
  113. {
  114. Console.WriteLine(args.Dates[1]);
  115. end = args.Dates[1];
  116. }
  117. }
  118. private bool _noIconLoading;
  119. private async Task OnButtonClick()
  120. {
  121. _noIconLoading = true;
  122. Datas = await reportService.GetStaticReportData(iType);
  123. if (Datas != null)
  124. {
  125. config.Title.Text = Datas.Title;
  126. config.XField = Datas.ATitle;
  127. await chart.ChangeData(Datas.Datas);
  128. await chart.UpdateChart(config);
  129. StateHasChanged();
  130. }
  131. _noIconLoading = false;
  132. }
  133. protected async override Task OnInitializedAsync()
  134. {
  135. //Datas = await reportService.GetAppealReportData(iType, DateTime.Parse("2022-01-01"), DateTime.Now, null);
  136. if (Datas != null)
  137. {
  138. config.Title.Text = Datas.Title;
  139. await chart.ChangeData(Datas.Datas);
  140. await chart.UpdateChart(config);
  141. StateHasChanged();
  142. }
  143. await base.OnInitializedAsync();
  144. }
  145. }
  146. }