UserConditionInput.razor.cs 4.0 KB

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