51 lines
1.7 KiB
C#
51 lines
1.7 KiB
C#
using Microsoft.AspNetCore.Mvc;
|
|
using Microsoft.AspNetCore.Mvc.RazorPages;
|
|
using Microsoft.AspNetCore.Mvc.Rendering;
|
|
using Nirvana.Common;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
using YBDevice.Application;
|
|
using YBDevice.Entity;
|
|
|
|
namespace YBDevice.NWeb.Pages.Menu
|
|
{
|
|
public class EditButtonModel : BaseModel
|
|
{
|
|
public YB_nMenuAction data = new YB_nMenuAction();
|
|
public List<TreeSelectModel> list = new List<TreeSelectModel>();
|
|
public List<SelectListItem> types = new List<SelectListItem>();
|
|
private ISystemService _systemService;
|
|
public EditButtonModel(ISystemService systemService)
|
|
{
|
|
_systemService = systemService;
|
|
}
|
|
public async Task OnGetAsync(Guid? id)
|
|
{
|
|
types = EnumHelper.GetEnumDictionary<MenuButtonPosition>().Select(x => new SelectListItem
|
|
{
|
|
Value = x.Key.ToString(),
|
|
Text = x.Value
|
|
}).ToList();
|
|
|
|
var menu = await _systemService.GetMenuListAsync();
|
|
var treeList = new List<TreeSelectModel>();
|
|
foreach (var item in menu)
|
|
{
|
|
TreeSelectModel treeModel = new TreeSelectModel();
|
|
treeModel.id = item.Id + "";
|
|
treeModel.text = item.Name;
|
|
treeModel.parentId = item.ParentId + "";
|
|
treeModel.data = item;
|
|
treeList.Add(treeModel);
|
|
}
|
|
list = treeList.TreeSelectGuidJson().ToObject<List<TreeSelectModel>>();
|
|
if (id.HasValue && id.Value != Guid.Empty)
|
|
{
|
|
data = await _systemService.GetActionDetailAsync(id.Value);
|
|
}
|
|
}
|
|
}
|
|
}
|