CreateAppeal.razor.cs 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  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. return false;
  58. }
  59. }
  60. #endregion
  61. private string warningMessage = "";
  62. protected override async void OnInitialized()
  63. {
  64. attrs = new Dictionary<string, object>
  65. {
  66. {"Action", $"{_configuration.GetValue<string>("APIUrl")}AttachFiles/PostFile" },
  67. {"Name", "files" },
  68. {"Multiple", false }
  69. };
  70. _Model = base.Options ?? new CreateAppealModel();
  71. if (_Model.AppealType.Name == "案件系数复核")
  72. {
  73. //判断是否案件系数是否A或S是否超过限额
  74. Customer customer = _Model.Item.Customer;
  75. if (customer == null)
  76. {
  77. //获取客户信息
  78. if(_Model.Item.CustomerId != null)
  79. {
  80. customer = await _orgService.GetCustomer(_Model.Item.CustomerId.Value);
  81. }
  82. }
  83. if(customer!= null)
  84. {
  85. Console.WriteLine(System.Text.Json.JsonSerializer.Serialize(customer));
  86. _Model.cssObject = await _atService.GetCaseCoefficientStatistics(customer.Id, _Model.Item.CalMonthId);
  87. if (_Model.cssObject != null && _Model.cssObject.isExceedingLimit())
  88. {
  89. warningMessage = $"客戶:{customer.Name}新申请案件S和A案件数已超过阈值,如果需要申请A或S的案件系数,请将审核人设置为钟子敏!";
  90. }
  91. }
  92. }
  93. //if(!string.IsNullOrEmpty(_Model.AppealType.ReviewerExpress))
  94. //{
  95. _Staffs =await _UserService.GetReviewers(_Model.AppealRecord.ItemId, _Model.AppealType.Id);
  96. if (!string.IsNullOrWhiteSpace(warningMessage) && _Model.AppealType.Name == "案件系数复核")
  97. {
  98. var zzmList = _Staffs.Where<Staff>(s => s.Name == "钟子敏");
  99. if (zzmList==null || zzmList.Count() == 0)
  100. {
  101. _Staffs.Add(await _UserService.GetUserByName("钟子敏"));
  102. }
  103. }
  104. //}
  105. //else
  106. //{
  107. // _Staffs =await _UserService.GetAll();
  108. //}
  109. base.OnInitialized();
  110. feedbackRef = base.FeedbackRef;
  111. StateHasChanged();
  112. }
  113. string _ErrorMessage;
  114. private async void OnFinish()
  115. {
  116. await base.OnFeedbackOkAsync(new ModalClosingEventArgs() { Cancel = true });
  117. }
  118. private void OnCancel()
  119. {
  120. base.OnFeedbackCancelAsync(new ModalClosingEventArgs() { Cancel = true });
  121. //_ = feedbackRef.CloseAsync();
  122. }
  123. }
  124. }