CreateAppeal.razor.cs 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. using AntDesign;
  2. using Microsoft.AspNetCore.Components;
  3. using Microsoft.AspNetCore.Components.Forms;
  4. using Microsoft.Extensions.Configuration;
  5. using Microsoft.JSInterop;
  6. using ServiceStack;
  7. using ServiceStack.Messaging;
  8. using System;
  9. using System.Collections.Generic;
  10. using System.Linq;
  11. using System.Net.Http;
  12. using System.Net.Http.Json;
  13. using System.Text.Json;
  14. using System.Threading.Tasks;
  15. using wispro.sp.entity;
  16. using wispro.sp.web.Models;
  17. using wispro.sp.web.Services;
  18. namespace wispro.sp.web.Components
  19. {
  20. public partial class CreateAppeal
  21. {
  22. private CreateAppealModel _Model;
  23. private IFeedbackRef feedbackRef;
  24. private List<Staff> _Staffs;
  25. [Inject]
  26. protected AppealTypeService _atService { get; set; }
  27. [Inject] IUserService _UserService { get; set; }
  28. [Inject]
  29. protected IHttpService _httpClient { get; set; }
  30. [Inject]
  31. protected IConfiguration _configuration { get; set; }
  32. [Inject]
  33. protected OrganizationService _orgService { get; set; }
  34. #region 文件上传控件设定
  35. //List<UploadFileItem> fileList = new List<UploadFileItem>();
  36. Dictionary<string, object> attrs;
  37. void HandleChange(UploadInfo fileinfo)
  38. {
  39. try
  40. {
  41. _Model.FileList.Where(file => file.State == UploadState.Success && !string.IsNullOrWhiteSpace(file.Response)).ForEach(file =>
  42. {
  43. var result = file.GetResponse<List<AttachFile>>();
  44. file.Url = $"{_configuration.GetValue<string>("APIUrl")}AttachFiles/Download?id={result[0].Id}";
  45. });
  46. }
  47. catch { }
  48. }
  49. private async Task<bool> RemoveFile(UploadFileItem fileinfo)
  50. {
  51. try
  52. {
  53. var result = fileinfo.GetResponse<List<AttachFile>>();
  54. return await _httpClient.Get<bool>($"{_configuration.GetValue<string>("APIUrl")}AttachFiles/Delete?id={result[0].Id}");
  55. }
  56. catch
  57. {
  58. return false;
  59. }
  60. }
  61. #endregion
  62. private string warningMessage = "";
  63. protected override async void OnInitialized()
  64. {
  65. attrs = new Dictionary<string, object>
  66. {
  67. {"Action", $"{_configuration.GetValue<string>("APIUrl")}AttachFiles/PostFile" },
  68. {"Name", "files" },
  69. {"Multiple", false }
  70. };
  71. _Model = base.Options ?? new CreateAppealModel();
  72. if (_Model.AppealType.Name == "案件系数复核")
  73. {
  74. //判断是否案件系数是否A或S是否超过限额
  75. Customer customer = _Model.Item.Customer;
  76. if (customer == null)
  77. {
  78. //获取客户信息
  79. if (_Model.Item.CustomerId != null)
  80. {
  81. customer = await _orgService.GetCustomer(_Model.Item.CustomerId.Value);
  82. }
  83. }
  84. if (customer != null)
  85. {
  86. Console.WriteLine(System.Text.Json.JsonSerializer.Serialize(customer));
  87. _Model.cssObject = await _atService.GetCaseCoefficientStatistics(customer.Id, _Model.Item.CalMonthId);
  88. if (_Model.cssObject != null && _Model.cssObject.isExceedingLimit())
  89. {
  90. warningMessage = $"客戶:{customer.Name}新申请案件S和A案件数已超过阈值,如果需要申请A或S的案件系数,请将审核人设置为钟子敏!";
  91. }
  92. }
  93. }
  94. //if(!string.IsNullOrEmpty(_Model.AppealType.ReviewerExpress))
  95. //{
  96. _Staffs = await _UserService.GetReviewers(_Model.AppealRecord.ItemId, _Model.AppealType.Id);
  97. if (!string.IsNullOrWhiteSpace(warningMessage) && _Model.AppealType.Name == "案件系数复核")
  98. {
  99. var zzmList = _Staffs.Where<Staff>(s => s.Name == "钟子敏");
  100. if (zzmList == null || zzmList.Count() == 0)
  101. {
  102. _Staffs.Add(await _UserService.GetUserByName("钟子敏"));
  103. }
  104. }
  105. //}
  106. //else
  107. //{
  108. // _Staffs =await _UserService.GetAll();
  109. //}
  110. base.OnInitialized();
  111. feedbackRef = base.FeedbackRef;
  112. StateHasChanged();
  113. }
  114. string _ErrorMessage;
  115. private async void OnFinish()
  116. {
  117. await base.OnFeedbackOkAsync(new ModalClosingEventArgs() { Cancel = true });
  118. }
  119. private void OnCancel()
  120. {
  121. base.OnFeedbackCancelAsync(new ModalClosingEventArgs() { Cancel = true });
  122. //_ = feedbackRef.CloseAsync();
  123. }
  124. }
  125. }