123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154 |
- using AntDesign;
- 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 ResponseManCondition
- {
-
- UserConditionType userConditionType;
-
- UserType _userType;
- List<Department> departments;
- List<Position> lstPosition;
- int SelectPositionsId;
- internal class UserConditionTpyeItem
- {
- public UserConditionType Type { get; set; }
- public string Description
- {
- get
- {
- return EnumHelper.GetDescription<UserConditionType>(Type);
- }
- }
- }
- List<UserConditionTpyeItem> uctItems = new List<UserConditionTpyeItem>();
- List<CascaderNode> optoins = new List<CascaderNode>();
- private List<CascaderNode> GetFromDepartment(List<Department> _departments)
- {
- List<CascaderNode> retList = new List<CascaderNode>();
- foreach(var dept in _departments)
- {
- CascaderNode node = new CascaderNode() { Label = dept.Name, Value = dept.Id.ToString() };
- retList.Add(node);
- }
- foreach(var dept in _departments)
- {
- if(dept.parentId != null)
- {
- var parentNode = FindNode(dept.parentId.Value.ToString(),retList);
- var currentNode = FindNode(dept.Id.ToString(), retList);
- Console.WriteLine($"Find:{dept.parentId},return:{System.Text.Json.JsonSerializer.Serialize(parentNode)}");
- Console.WriteLine($"Find:{dept.Id},return:{System.Text.Json.JsonSerializer.Serialize(currentNode)}");
- if (parentNode != null)
- {
- if (parentNode.Children == null)
- {
- parentNode.Children = new List<CascaderNode>();
- }
- ((List<CascaderNode>)parentNode.Children).Add(currentNode);
- retList.Remove(currentNode);
- }
-
- }
-
- }
- return retList;
- }
- private CascaderNode FindNode(string deptId,List<CascaderNode> retList)
- {
-
- foreach(var node in retList)
- {
-
- if (node.Value == deptId)
- {
- Console.WriteLine($"Founded:{System.Text.Json.JsonSerializer.Serialize(node)}");
- return node;
- }
- else
- {
- if (node.Children != null)
- {
- var temNode = FindNode(deptId, (List<CascaderNode>)node.Children);
- if (temNode != null)
- {
-
- return temNode;
- }
- }
- }
-
- }
-
- return null;
- }
- [Inject] OrganizationService _orgService { get; set; }
- [Parameter]
- public Workflow Workflow { get; set; }
- [Parameter]
- public UserField UserField { get; set; }
- protected async override Task OnInitializedAsync()
- {
- departments =await _orgService.GetDepartments();
- lstPosition = await _orgService.getPositions(null);
- optoins = GetFromDepartment(departments);
- uctItems.Add(new UserConditionTpyeItem() { Type = UserConditionType.Department });
- uctItems.Add(new UserConditionTpyeItem() { Type = UserConditionType.DepartmentPosition });
- uctItems.Add(new UserConditionTpyeItem() { Type = UserConditionType.Staff });
- uctItems.Add(new UserConditionTpyeItem() { Type = UserConditionType.UserDepartment });
- uctItems.Add(new UserConditionTpyeItem() { Type = UserConditionType.UserDepartmentPosition });
- await base.OnInitializedAsync();
- }
- private void OnUCTItemChangedHandler(UserConditionTpyeItem value)
- {
- userConditionType = value.Type;
- }
- private async Task OnDeptChange(CascaderNode[] selectedNodes)
- {
- int deptId = int.Parse(selectedNodes[0].Value);
- if(userConditionType == UserConditionType.DepartmentPosition || userConditionType == UserConditionType.DepartmentPosition)
- {
- lstPosition =await _orgService.getPositions(deptId);
- }
- }
- void OnPositionChangedHandler(Position position)
- {
- UserField.Positon = position.Id.ToString();
- }
- }
- }
|