StaffSelect.razor.cs 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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.web.Services;
  8. namespace wispro.sp.web.Components
  9. {
  10. public partial class StaffSelect
  11. {
  12. private Staff _SelectedItem;
  13. private List<Staff> _ShowStaffs;
  14. [Parameter]
  15. public int? StaffId { get; set; }
  16. [Parameter]
  17. public EventCallback<int?> StaffIdChanged { get; set; }
  18. [Parameter]
  19. public List<Staff> StaffLists { get; set; }
  20. [Inject] IUserService _UserService { get; set; }
  21. protected override void OnInitialized()
  22. {
  23. _ShowStaffs = StaffLists;
  24. base.OnInitialized();
  25. }
  26. protected override Task OnParametersSetAsync()
  27. {
  28. _ShowStaffs = StaffLists;
  29. return base.OnParametersSetAsync();
  30. }
  31. private void OnSelectedItemChangedHandler(Staff value)
  32. {
  33. _SelectedItem = value;
  34. StaffIdChanged.InvokeAsync(_SelectedItem.Id);
  35. }
  36. private void OnSearch(string value)
  37. {
  38. _ShowStaffs = _ShowStaffs.Where<Staff>(p => p.Name.Contains(value)).ToList();
  39. StateHasChanged();
  40. }
  41. }
  42. }