liaoxujun@qq.com
2024-02-18 b73ffe97fc885b652b20328c1c3d079a9124fb89
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
// WTM默认页面 Wtm buidin page
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text.RegularExpressions;
using WalkingTec.Mvvm.Core;
using WalkingTec.Mvvm.Core.Extensions;
 
namespace WalkingTec.Mvvm.Mvc.Admin.ViewModels.FrameworkMenuVMs
{
    public class FrameworkMenuListVM2 : BasePagedListVM<FrameworkMenu_ListView, BaseSearcher>
    {
        public FrameworkMenuListVM2()
        {
            this.NeedPage = false;
        }
 
        protected override IEnumerable<IGridColumn<FrameworkMenu_ListView>> InitGridHeader()
        {
            List<GridColumn<FrameworkMenu_ListView>> rv = new List<GridColumn<FrameworkMenu_ListView>>();
            rv.AddRange(new GridColumn<FrameworkMenu_ListView>[] {
                        this.MakeGridHeader(x => x.PageName, 300),
                        this.MakeGridHeader(x => x.ModuleName, 150),
                        this.MakeGridHeader(x => x.ShowOnMenu, 60),
                        this.MakeGridHeader(x => x.FolderOnly, 60),
                        this.MakeGridHeader(x => x.IsPublic, 60),
                        this.MakeGridHeader(x => x.DisplayOrder, 60),
                        this.MakeGridHeader(x => x.TenantAllowed, 60),
                        this.MakeGridHeader(x => x.Icon, 100),
                        this.MakeGridHeader(x => x.Children, 100),
                        this.MakeGridHeader(x=>x.ParentId).SetHide(),
                        this.MakeGridHeaderAction(width: 290)
                    });
            return rv;
        }
 
        public override IOrderedQueryable<FrameworkMenu_ListView> GetSearchQuery()
        {
            List<FrameworkMenu> data = new List<FrameworkMenu>();
            using (var maindc = Wtm.CreateDC(false, "default"))
            {
                data = maindc.Set<FrameworkMenu>().ToList();
            }
            var topdata = data.Where(x => x.ParentId == null).ToList().FlatTree(x => x.DisplayOrder).Where(x => x.IsInside == false || x.FolderOnly == true || x.Url.EndsWith("/Index") || string.IsNullOrEmpty(x.MethodName)).ToList();
            foreach (var item in topdata)
            {
                if (item.PageName?.StartsWith("MenuKey.") == true)
                {
                    item.PageName = Localizer[item.PageName];
                }
                if (item.ModuleName?.StartsWith("MenuKey.") == true)
                {
                    item.ModuleName = Localizer[item.ModuleName];
                }
            }
 
 
            int order = 0;
            var data2 = topdata.Select(x => new FrameworkMenu_ListView
            {
                ID = x.ID,
                PageName = x.PageName,
                ModuleName = x.ModuleName,
                ActionName = x.ActionName,
                ShowOnMenu = x.ShowOnMenu,
                FolderOnly = x.FolderOnly,
                IsPublic = x.IsPublic,
                DisplayOrder = x.DisplayOrder,
                ExtraOrder = order++,
                ParentId = x.ParentId,
                TenantAllowed = x.TenantAllowed,
                Icon = x.Icon
            }).OrderBy(x => x.ExtraOrder).ToList();
 
            return data2.AsQueryable() as IOrderedQueryable<FrameworkMenu_ListView>;
        }
    }
    public class FrameworkMenu_ListView : TreePoco<FrameworkMenu_ListView>
    {
        [Display(Name = "_Admin.PageName")]
        public string PageName { get; set; }
 
        [Display(Name = "Codegen.ModuleName")]
        public string ModuleName { get; set; }
 
        [Display(Name = "_Admin.ActionName")]
        public string ActionName { get; set; }
 
        [Display(Name = "_Admin.ShowOnMenu")]
        public bool? ShowOnMenu { get; set; }
 
        [Display(Name = "_Admin.FolderOnly")]
        public bool? FolderOnly { get; set; }
 
        [Display(Name = "_Admin.IsPublic")]
        public bool? IsPublic { get; set; }
 
        [Display(Name = "_Admin.DisplayOrder")]
        public int? DisplayOrder { get; set; }
 
        [Display(Name = "_Admin.Icon")]
        public string Icon { get; set; }
 
        public bool Allowed { get; set; }
 
        public bool Denied { get; set; }
 
        public bool HasChild { get => HasChildren; }
 
        public string IconClass { get; set; }
 
 
        public int ExtraOrder { get; set; }
 
        public bool? IsInside { get; set; }
 
        [Display(Name = "_Admin.TenantAllowed")]
        public bool? TenantAllowed { get; set; }
 
    }
 
}