@page "/Box/BoxBindings"
@code { @inject IChannelListDao channelListDao; @inject IDrugInfoDao drugInfoDao; @inject DialogService dialogService; @inject NotificationService _message RadzenDataList grid; bool isLoading; int count; private IEnumerable? _forecasts; List drugInfos; List drugManuNos; DrugInfo drugInfo; DrugManuNo drugManuNo; List plans; protected override async Task OnInitializedAsync() { await base.OnInitializedAsync(); //drugInfos = await drugInfoDao.GetAllDrug(); } async Task LoadData(LoadDataArgs args) { isLoading = true; var result = await channelListDao.GetAllChannelListWithPlan(args.Top, args.Skip); // Update the Data property _forecasts = result.Desserts; // Update the count count = result.TotalDesserts; isLoading = false; plans = result.Other; } async Task reloadGrid() { await grid.Reload(); } async Task EditChannel(ChannelList list) { if (list.PlanInfo.Id > 0) { // 说明之前有绑定并且未改变,那么就是在进行解绑 if (list.DrugId != null && list.DrugId.Equals(list.PlanInfo.Id.ToString())) { var b = await channelListDao.UnBindBox(list); if (b) { _message.Notify( new NotificationMessage { Severity = NotificationSeverity.Success, Summary = "提示", Detail = $"解除绑定成功", Duration = 4000 } ); await reloadGrid(); } } // 否则是进行绑定 else { var b = await channelListDao.BindBox(list); if (b) { _message.Notify( new NotificationMessage { Severity = NotificationSeverity.Success, Summary = "提示", Detail = $"绑定成功", Duration = 4000 } ); await reloadGrid(); } } } else { if (list.PlanInfo != null) { // 说明只设置了药品 var b = await channelListDao.BindBox(list); if (b) { _message.Notify( new NotificationMessage { Severity = NotificationSeverity.Success, Summary = "提示", Detail = $"绑定成功", Duration = 4000 } ); await reloadGrid(); } } // 什么都没有选择或者么有改变,只是点击了按钮,此时不操作 else { } } } }