/// <summary> /// 选中数据移动方法 /// </summary> private async Task TransferItems(List <SelectedItem> source, List <SelectedItem> target) { if (!IsDisabled && Items != null) { var items = source.Where(i => i.Active).ToList(); source.RemoveAll(i => items.Contains(i)); target.AddRange(items); LeftItems.ForEach(i => { var item = Items.FirstOrDefault(item => item.Value == i.Value && item.Text == i.Text && item.GroupName == i.GroupName); if (item != null) { item.Active = false; } }); RightItems.ForEach(i => { var item = Items.FirstOrDefault(item => item.Value == i.Value && item.Text == i.Text && item.GroupName == i.GroupName); if (item != null) { item.Active = true; } }); Value = default; CurrentValueAsString = string.Join(",", RightItems.Select(i => i.Value)); if (OnSelectedItemsChanged != null) { await OnSelectedItemsChanged.Invoke(RightItems); } } }
/// <summary> /// 选中数据移动方法 /// </summary> private async Task TransferItems(List <SelectedItem> source, List <SelectedItem> target) { IsTransfer = true; if (!IsDisabled && Items != null) { var items = source.Where(i => i.Active).ToList(); source.RemoveAll(i => items.Contains(i)); target.AddRange(items); LeftItems.ForEach(i => { var item = Items.FirstOrDefault(item => item.Value == i.Value && item.Text == i.Text && item.GroupName == i.GroupName); if (item != null) { item.Active = false; } }); RightItems.ForEach(i => { var item = Items.FirstOrDefault(item => item.Value == i.Value && item.Text == i.Text && item.GroupName == i.GroupName); if (item != null) { item.Active = true; } }); // 回调 if (ItemsChanged.HasDelegate) { await ItemsChanged.InvokeAsync(Items); } else { StateHasChanged(); } } }