@page "/_Admin/FrameworkRole/PageFunction/{id}" @using WalkingTec.Mvvm.Mvc.Admin.ViewModels.FrameworkRoleVMs @inherits BasePage @if (Roles?.Pages != null) {
}
@code { private FrameworkRoleMDVM2 Roles = new FrameworkRoleMDVM2(); private Dictionary> AllActions; private ValidateForm vform { get; set; } private Table table; [Parameter] public string id { get; set; } protected override async Task OnInitializedAsync() { var rv = await WtmBlazor.Api.CallAPI($"/api/_FrameworkRole/GetPageActions/{id}"); AllActions = new Dictionary>(); foreach (var item in rv.Data.Pages) { AllActions.Add(item.ID, item.AllActions.ToBBItems()); } Roles = rv.Data; } private async Task SetSub(Page_View row) { if (row.IsFolder == true) { foreach (var item in Roles.Pages) { if (item.ParentID == row.ID) { AllActions[item.ID].ForEach(x => x.Active = AllActions[row.ID].Any(x => x.Active)); item.Actions = AllActions[item.ID].Where(x => x.Active == true).Select(x => x.Value).ToList().ConvertAll(x => new Guid(x)); await SetSub(item); } } } } private async Task SetParent(Page_View row) { var parent = Roles.Pages.Where(x => x.ID == row.ParentID).FirstOrDefault(); if (parent != null) { AllActions[parent.ID].ForEach(x => x.Active = true); parent.Actions = AllActions[parent.ID].Where(x => x.Active == true).Select(x => x.Value).ToList().ConvertAll(x => new Guid(x)); await SetParent(parent); } } private async Task Submit(EditContext context) { await PostsForm(vform, $"/api/_FrameworkRole/EditPrivilege", (s) => "Sys.OprationSuccess", method: HttpMethodEnum.PUT); } public void OnClose() { CloseDialog(); } }