123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128 |
- using Microsoft.AspNetCore.Components;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Threading.Tasks;
- using wispro.sp.entity;
- using wispro.sp.entity.workflowDefine;
- using wispro.sp.web.Services;
- namespace wispro.sp.web.Components
- {
- public partial class UserConditionInput
- {
- protected class UserItem
- {
- public UserType UserType { get; set; }
- public string Label { get; set; }
- public string Value { get; set; }
- public string GroupName { get; set; }
- }
- List<UserItem> UserItems = new List<UserItem>();
- UserItem SelectedUserItem;
- string _selectedValue ;
- [Parameter]
- public Workflow Workflow { get; set; }
- [Parameter]
- public UserType UserType { get; set; }
- [Parameter]
- public string UserValue { get; set; }
- [Parameter]
- public EventCallback<UserType> UserTypeChanged { get; set; }
- [Parameter]
- public EventCallback<string> UserValueChanged { get; set; }
- [Inject] public WorkflowService wfService { get; set; }
- [Inject] IUserService _UserService { get; set; }
- protected async override Task OnInitializedAsync()
- {
- UserItems = new List<UserItem>();
- if (!string.IsNullOrEmpty(Workflow.ContentObjectType))
- {
- string temString = wfService.GetBindObjectName(Workflow.ContentObjectType);
- var dic = share.Utility.UserConditionHelper.GetPropertyDescription<Staff>(Workflow.ContentObjectType);
- foreach (string key in dic.Keys)
- {
- UserItems.Add(new UserItem()
- {
- Value = dic[key].ToString(),
- Label = $"{temString}.{key}",
- UserType = UserType.BindObjectProperty,
- GroupName = temString //EnumHelper.GetDescription<UserType>(UserType.BindObjectProperty)
- });
- }
- }
- var actions =await wfService.GetActions(Workflow.Id);
- //Console.WriteLine(System.Text.Json.JsonSerializer.Serialize(actions));
- foreach(var action in actions)
- {
- if (action.Id == Workflow.InitActionId)
- {
- UserItems.Add(new UserItem()
- {
- Value = action.Id.ToString(),
- Label = $"流程创建人",
- UserType = UserType.DoActionUser,
- GroupName = EnumHelper.GetDescription<UserType>(UserType.DoActionUser)
- });
- }
- else
- {
- UserItems.Add(new UserItem()
- {
- Value = action.Id.ToString(),
- Label = $"{action.step.Name}.{action.Name}处理人",
- UserType = UserType.DoActionUser,
- GroupName = EnumHelper.GetDescription<UserType>(UserType.DoActionUser)
- });
- }
- }
- UserItems.Add(new UserItem()
- {
- Value = "",
- Label = "登录用户",
- UserType = UserType.LoginUser,
- GroupName = EnumHelper.GetDescription<UserType>(UserType.LoginUser)
- });
- var Staffs =await _UserService.GetAll();
- //Console.WriteLine(System.Text.Json.JsonSerializer.Serialize(Staffs));
- foreach (var sf in Staffs)
- {
- UserItems.Add(new UserItem()
- {
- Value = sf.Id.ToString(),
- Label = sf.Name,
- UserType = UserType.Staff,
- GroupName = EnumHelper.GetDescription<UserType>(UserType.Staff)
- });
- }
-
- }
- private void OnSelectedItemChangedHandler(UserItem value)
- {
- SelectedUserItem = value;
- UserType = SelectedUserItem.UserType;
- UserValue = SelectedUserItem.Value;
- //Console.WriteLine($"selected: ${value?.Name}");
- }
- }
- }
|