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.web.Services; namespace wispro.sp.web.Components { public partial class AutoCompleteStaff { private Staff _SelectedItem; private string SelectValueName; List _ShowStaffLists; [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() { _ShowStaffLists = StaffLists; base.OnInitialized(); } Func CompareWith = (a, b) => { if (a is Staff o1 && b is Staff o2) { return o1.Name == o2.Name ; } else { return false; } }; void OnSelectionChange(AutoCompleteOption item) { _SelectedItem = (Staff)item.Value; StaffId = _SelectedItem.Id; } void OnInput(ChangeEventArgs e) { var v = e.Value.ToString(); _ShowStaffLists = StaffLists.Where(s => s.Name.Contains(v)).ToList(); } } }