UserConditionInput.razor.cs 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. using Microsoft.AspNetCore.Components;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Threading.Tasks;
  6. using wispro.sp.entity;
  7. using wispro.sp.entity.workflowDefine;
  8. using wispro.sp.web.Services;
  9. namespace wispro.sp.web.Components
  10. {
  11. public class UserItem
  12. {
  13. public UserType UserType { get; set; }
  14. public string Label { get; set; }
  15. public string Value { get; set; }
  16. public string GroupName { get; set; }
  17. }
  18. public partial class UserConditionInput
  19. {
  20. List<UserItem> UserItems = new List<UserItem>();
  21. UserItem SelectedUserItem;
  22. string _selectedValue ;
  23. [Parameter]
  24. public Workflow Workflow { get; set; }
  25. [Parameter]
  26. public UserType UserType { get; set; }
  27. [Parameter]
  28. public string UserValue { get; set; }
  29. //[Parameter]
  30. //public EventCallback<UserType> UserTypeChanged { get; set; }
  31. //[Parameter]
  32. //public EventCallback<string> UserValueChanged { get; set; }
  33. [Parameter]
  34. public EventCallback<UserItem> OnSelectedChange { get; set; }
  35. [Inject] public WorkflowService wfService { get; set; }
  36. [Inject] IUserService _UserService { get; set; }
  37. protected async override Task OnInitializedAsync()
  38. {
  39. UserItems = new List<UserItem>();
  40. if (!string.IsNullOrEmpty(Workflow.ContentObjectType))
  41. {
  42. string temString = wfService.GetBindObjectName(Workflow.ContentObjectType);
  43. var dic = share.Utility.UserConditionHelper.GetPropertyDescription<Staff>(Workflow.ContentObjectType);
  44. foreach (string key in dic.Keys)
  45. {
  46. UserItems.Add(new UserItem()
  47. {
  48. Value = dic[key].ToString(),
  49. Label = $"{temString}.{key}",
  50. UserType = UserType.BindObjectProperty,
  51. GroupName = temString //EnumHelper.GetDescription<UserType>(UserType.BindObjectProperty)
  52. });
  53. }
  54. }
  55. var actions =await wfService.GetActions(Workflow.Id);
  56. //Console.WriteLine(System.Text.Json.JsonSerializer.Serialize(actions));
  57. foreach(var action in actions)
  58. {
  59. if (action.Id == Workflow.InitActionId)
  60. {
  61. UserItems.Add(new UserItem()
  62. {
  63. Value = action.Id.ToString(),
  64. Label = $"流程创建人",
  65. UserType = UserType.DoActionUser,
  66. GroupName = EnumHelper.GetDescription<UserType>(UserType.DoActionUser)
  67. });
  68. }
  69. else
  70. {
  71. UserItems.Add(new UserItem()
  72. {
  73. Value = action.Id.ToString(),
  74. Label = $"{action.step.Name}.{action.Name}处理人",
  75. UserType = UserType.DoActionUser,
  76. GroupName = EnumHelper.GetDescription<UserType>(UserType.DoActionUser)
  77. });
  78. }
  79. }
  80. UserItems.Add(new UserItem()
  81. {
  82. Value = "",
  83. Label = "登录用户",
  84. UserType = UserType.LoginUser,
  85. GroupName = EnumHelper.GetDescription<UserType>(UserType.LoginUser)
  86. });
  87. var Staffs =await _UserService.GetAll();
  88. //Console.WriteLine(System.Text.Json.JsonSerializer.Serialize(Staffs));
  89. foreach (var sf in Staffs)
  90. {
  91. UserItems.Add(new UserItem()
  92. {
  93. Value = sf.Id.ToString(),
  94. Label = sf.Name,
  95. UserType = UserType.Staff,
  96. GroupName = EnumHelper.GetDescription<UserType>(UserType.Staff)
  97. });
  98. }
  99. }
  100. private void OnSelectedItemChangedHandler(UserItem value)
  101. {
  102. SelectedUserItem = value;
  103. if (OnSelectedChange.HasDelegate)
  104. {
  105. OnSelectedChange.InvokeAsync(value);
  106. }
  107. //UserType = SelectedUserItem.UserType;
  108. //UserValue = SelectedUserItem.Value;
  109. //Console.WriteLine($"selected: ${value?.Value}");
  110. //Console.WriteLine(UserValue);
  111. }
  112. }
  113. }