UserConditionInput.razor.cs 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  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 partial class UserConditionInput
  12. {
  13. protected class UserItem
  14. {
  15. public UserType UserType { get; set; }
  16. public string Label { get; set; }
  17. public string Value { get; set; }
  18. public string GroupName { get; set; }
  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. [Inject] public WorkflowService wfService { get; set; }
  34. [Inject] IUserService _UserService { get; set; }
  35. protected async override Task OnInitializedAsync()
  36. {
  37. UserItems = new List<UserItem>();
  38. if (!string.IsNullOrEmpty(Workflow.ContentObjectType))
  39. {
  40. string temString = wfService.GetBindObjectName(Workflow.ContentObjectType);
  41. var dic = share.Utility.UserConditionHelper.GetPropertyDescription<Staff>(Workflow.ContentObjectType);
  42. foreach (string key in dic.Keys)
  43. {
  44. UserItems.Add(new UserItem()
  45. {
  46. Value = dic[key].ToString(),
  47. Label = $"{temString}.{key}",
  48. UserType = UserType.BindObjectProperty,
  49. GroupName = temString //EnumHelper.GetDescription<UserType>(UserType.BindObjectProperty)
  50. });
  51. }
  52. }
  53. var actions =await wfService.GetActions(Workflow.Id);
  54. //Console.WriteLine(System.Text.Json.JsonSerializer.Serialize(actions));
  55. foreach(var action in actions)
  56. {
  57. if (action.Id == Workflow.InitActionId)
  58. {
  59. UserItems.Add(new UserItem()
  60. {
  61. Value = action.Id.ToString(),
  62. Label = $"流程创建人",
  63. UserType = UserType.DoActionUser,
  64. GroupName = EnumHelper.GetDescription<UserType>(UserType.DoActionUser)
  65. });
  66. }
  67. else
  68. {
  69. UserItems.Add(new UserItem()
  70. {
  71. Value = action.Id.ToString(),
  72. Label = $"{action.step.Name}.{action.Name}处理人",
  73. UserType = UserType.DoActionUser,
  74. GroupName = EnumHelper.GetDescription<UserType>(UserType.DoActionUser)
  75. });
  76. }
  77. }
  78. UserItems.Add(new UserItem()
  79. {
  80. Value = "",
  81. Label = "登录用户",
  82. UserType = UserType.LoginUser,
  83. GroupName = EnumHelper.GetDescription<UserType>(UserType.LoginUser)
  84. });
  85. var Staffs =await _UserService.GetAll();
  86. //Console.WriteLine(System.Text.Json.JsonSerializer.Serialize(Staffs));
  87. foreach (var sf in Staffs)
  88. {
  89. UserItems.Add(new UserItem()
  90. {
  91. Value = sf.Id.ToString(),
  92. Label = sf.Name,
  93. UserType = UserType.Staff,
  94. GroupName = EnumHelper.GetDescription<UserType>(UserType.Staff)
  95. });
  96. }
  97. }
  98. private void OnSelectedItemChangedHandler(UserItem value)
  99. {
  100. SelectedUserItem = value;
  101. UserType = SelectedUserItem.UserType;
  102. UserValue = SelectedUserItem.Value;
  103. //Console.WriteLine($"selected: ${value?.Name}");
  104. }
  105. }
  106. }