WorkpieceProcessingRecordPage.razor
2.11 KB
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
@page "/DataAnalysis/WorkpieceProcessingRecord"
@using System.Text.Json;
@using AntDesign.TableModels
@using System.ComponentModel
@using DataAcquisition.DataAccess
@using DataAcquisition.Models
@using Microsoft.EntityFrameworkCore
@inject IDbContextFactory<DataContext> dbContextFactory;
<Table @ref="table"
TItem="WorkpieceProcessingRecord"
Loading="loading"
DataSource="@dataItems"
Total="_total"
@bind-PageIndex="_pageIndex"
@bind-PageSize="_pageSize"
OnChange="OnChange"
Size="TableSize.Small"
RowKey="x=>x.Id">
<PropertyColumn Property="c=>c.Id" Hidden />
<PropertyColumn Title="设备编号" Property="c=>c.EquipmentCode" />
<PropertyColumn Title="设备名称" Property="c=>c.EquipmentName" />
<PropertyColumn Title="工件型号" Property="c=>c.WorkpieceCode" />
<PropertyColumn Title="程序号" Property="c=>c.ProgramNo" />
<PropertyColumn Title="完成状态" Property="c=>c.IsEnd">
<Switch @bind-Value="@context.IsEnd" Disabled="true"></Switch>
</PropertyColumn>
<PropertyColumn Title="开始时间" Property="c=>c.CreateTime" />
<PropertyColumn Title="结束时间" Property="c=>c.UpdateTime" />
</Table>
@code {
bool loading = true;
List<WorkpieceProcessingRecord> dataItems = new List<WorkpieceProcessingRecord>();
IEnumerable<WorkpieceProcessingRecord> selectedRows = null!;
ITable table = null!;
int _pageIndex = 1;
int _pageSize = 10;
int _total = 0;
public async Task OnChange(QueryModel<WorkpieceProcessingRecord> queryModel)
{
loading = true;
using var dbContext = dbContextFactory.CreateDbContext();
var query = dbContext.WorkpieceProcessingRecords;
dataItems = await query.OrderByDescending(x => x.Id).Skip(((queryModel.PageIndex - 1) * queryModel.PageSize)).Take(queryModel.PageSize).AsNoTracking().ToListAsync();
_total = await query.CountAsync();
loading = false;
}
public void RemoveSelection(Guid id)
{
var selected = selectedRows.Where(x => x.Id != id);
selectedRows = selected;
}
}