using Microsoft.AspNetCore.Components; using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using wispro.sp.entity; using wispro.sp.web.Services; namespace wispro.sp.web.Components { public partial class StaffSelect { private Staff _SelectedItem; private List _ShowStaffs; [Parameter] public int? StaffId { get; set; } [Parameter] public EventCallback StaffIdChanged { get; set; } [Parameter] public List StaffLists { get; set; } [Inject] IUserService _UserService { get; set; } protected override void OnInitialized() { _ShowStaffs = StaffLists; if(_ShowStaffs !=null && _ShowStaffs.Count > 0) { StaffId = _ShowStaffs[0].Id; } base.OnInitialized(); } protected override Task OnParametersSetAsync() { _ShowStaffs = StaffLists; if (_ShowStaffs != null && _ShowStaffs.Count > 0) { StaffId = _ShowStaffs[0].Id; } return base.OnParametersSetAsync(); } private void OnSelectedItemChangedHandler(Staff value) { _SelectedItem = value; StaffIdChanged.InvokeAsync(_SelectedItem.Id); } private void OnSearch(string value) { _ShowStaffs = _ShowStaffs.Where(p => p.Name.Contains(value)).ToList(); //StateHasChanged(); } } }