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
// WTM默认页面 Wtm buidin page
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using WalkingTec.Mvvm.Core;
 
namespace WalkingTec.Mvvm.Mvc.Admin.ViewModels.DataPrivilegeVMs
{
    public class DpListVM : BasePagedListVM<DpView,DpSearcher>
    {
        public DpListVM()
        {
            NeedPage = false;
        }
 
        protected override IEnumerable<IGridColumn<DpView>> InitGridHeader()
        {
            return new List<GridColumn<DpView>>{
                this.MakeGridHeader(x => x.Name),
            };
        }
 
        public override IOrderedQueryable<DpView> GetSearchQuery()
        {
 
            var dps = Wtm.DataPrivilegeSettings.Where(x => x.ModelName == Searcher.TableName).SingleOrDefault();
            if (dps != null)
            {
                return dps.GetItemList(Wtm, Searcher.Filter).Select(x => new DpView { ID = x.Value.ToString(), Name = x.Text }).AsQueryable().OrderBy(x => x.Name);
            }
            else
            {
                return new List<DpView>().AsQueryable().OrderBy(x => x.Name);
            }
        }
 
        public override IOrderedQueryable<DpView> GetBatchQuery()
        {
            var dps = Wtm.DataPrivilegeSettings.Where(x => x.ModelName == Searcher.TableName).SingleOrDefault();
            if (dps != null)
            {
                return dps.GetItemList(Wtm, null,Ids).Select(x => new DpView { ID = x.Value.ToString(), Name = x.Text }).AsQueryable().OrderBy(x => x.Name);
            }
            else
            {
                return new List<DpView>().AsQueryable().OrderBy(x => x.Name);
            }
        }
    }
 
    public class DpView : TopBasePoco
    {
        public new string ID { get; set; }
 
        [Display(Name = "_Admin.DataPrivilegeName")]
        public string Name { get; set; }
    }
 
    public class DpSearcher : BaseSearcher
    {
        public string TableName { get; set; }
        [Display(Name = "_Admin.DataPrivilegeName")]
        public string Filter { get; set; }
    }
 
}