1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- 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<Staff> _ShowStaffLists;
- [Parameter]
- public int? StaffId { get; set; }
- [Parameter]
- public EventCallback<int?> StaffIdChanged { get; set; }
- [Parameter]
- public List<Staff> StaffLists { get; set; }
- [Inject] IUserService _UserService { get; set; }
- protected override void OnInitialized()
- {
- _ShowStaffLists = StaffLists;
- base.OnInitialized();
- }
- Func<object, object, bool> 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<Staff>(s => s.Name.Contains(v)).ToList();
- }
- }
- }
|