public async Task OnEdit(IndexLibraryDto model)
        {
            var result = await DrawerSvr.CreateDialogAsync <IndexLibraryEdit, Guid?, IndexLibraryDto>(model.IndexLibraryId, title : $"编辑指标 {model.Name}", width : 450);

            if (result != null)
            {
                var index = datas.IndexOf(model);
                datas[index] = result;
            }
        }
        public async void OnDelete(IndexLibraryDto model)
        {
            if (await ConfirmSvr.Show($"是否删除指标 {model.Name}", "删除", ConfirmButtons.YesNo, ConfirmIcon.Question) == ConfirmResult.Yes)
            {
                var result = await Http.DeleteFromJsonAsync <ResultMsg>($"api/IndexLibrary/Delete?id={model.IndexLibraryId}");

                if (result.IsSuccess)
                {
                    datas.Remove(model);
                    MsgSvr.Success($"{model.Name} 删除成功");
                    await InvokeAsync(StateHasChanged);
                }
                else
                {
                    MsgSvr.Error($"{model.Name} 删除失败,错误:{result.Msg}");
                }
            }
        }
        public ResultData <IndexLibraryDto> Save(IndexLibraryDto model)
        {
            var entity = Context.IndexLibraries.FirstOrDefault(x => x.IndexLibraryId == model.IndexLibraryId);

            if (entity == null)
            {
                entity = new IndexLibrary();
                entity.IndexLibraryId = model.IndexLibraryId;
                Context.Add(entity);
            }
            entity.Name       = model.Name;
            entity.Scope      = model.Scope;
            entity.Type       = model.Type;
            entity.Unit       = model.Unit;
            entity.Definition = model.Definition;
            entity.Remark     = model.Remark;
            entity.IsEnabled  = model.IsEnabled;

            Context.SaveChanges();
            return(new(model));
        }
 public async void OnChart(IndexLibraryDto model)
 {
     await DrawerSvr.CreateDialogAsync <IndexLibraryChart, Guid, object>(model.IndexLibraryId, title : $"指标分析 {model.Name}", width : 450);
 }