-
Notifications
You must be signed in to change notification settings - Fork 10
/
ListCard.razor
105 lines (90 loc) · 3.19 KB
/
ListCard.razor
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
@inject IHttpService _httpService
@inject IPopupService PopupService
<DataTableCard TModel="EntryInformationTypeOverviewModel" Headers="_headers" ApiUrl="@(_baseUrl)" Title="@($"{_name}列表")" OnClickAdd="AddItem" @ref="dataTableCard">
<ItemColContent>
@if (context.Header.Value == "actions")
{
<MIcon Color="success"
Class="mr-2"
OnClick="()=>EditItem(context.Item)">mdi-pencil</MIcon>
}
else if (context.Header.Value == nameof(EntryInformationTypeOverviewModel.IsHidden))
{
<CnGalWebSite.Shared.MasaComponent.PC.Admin.Recommends.StateChip IsHidden="context.Item.IsHidden" />
}
else if (context.Header.Value == nameof(EntryInformationTypeOverviewModel.Icon))
{
<MIcon>@context.Item.Icon</MIcon>
}
else if (context.Header.Value == nameof(EntryInformationTypeOverviewModel.Types))
{
<TypesChip Types="context.Item.Types"/>
}
else
{
@context.Value
}
</ItemColContent>
</DataTableCard>
<MDialog @bind-Value="_editDialog"
MaxWidth="1200">
<EditCard Id="_editedItemId" OnEdited="OnEdited" @ref="editCard" />
</MDialog>
@code {
private bool _editDialog;
private long _editedItemId;
private bool _detailDialog;
private string _baseUrl = "api/entries/ListEntryInformationTypes";
private string _name = "基础信息类型";
EditCard editCard;
private List<DataTableHeader<EntryInformationTypeOverviewModel>> _headers = new List<DataTableHeader<EntryInformationTypeOverviewModel>>
{
new ()
{
Text= "Id",
Align= DataTableHeaderAlign.Start,
Value= nameof(EntryInformationTypeOverviewModel.Id)
},
new (){ Text= "名称", Value= nameof(EntryInformationTypeOverviewModel.Name)},
new (){ Text= "描述", Value= nameof(EntryInformationTypeOverviewModel.Description)},
new (){ Text= "图标", Value= nameof(EntryInformationTypeOverviewModel.Icon)},
new (){ Text= "支持的类型", Value= nameof(EntryInformationTypeOverviewModel.Types)},
new (){ Text= "状态", Value= nameof(EntryInformationTypeOverviewModel.IsHidden)},
new (){ Text= "操作", Value= "actions",Sortable=false }
};
DataTableCard<EntryInformationTypeOverviewModel> dataTableCard;
[CascadingParameter]
public ErrorHandler ErrorHandler { get; set; }
protected override async Task OnInitializedAsync()
{
}
public async void EditItem(EntryInformationTypeOverviewModel item)
{
_editedItemId = item.Id;
_editDialog = true;
StateHasChanged();
if (editCard != null)
{
await editCard.Refresh();
}
}
public void OnEdited()
{
_editDialog = false;
StateHasChanged();
if (dataTableCard != null)
{
dataTableCard.GetDataFromApi();
}
}
public async Task AddItem()
{
_editedItemId = 0;
_editDialog = true;
StateHasChanged();
if (editCard != null)
{
await editCard.Refresh();
}
}
}