新增供应商列表视图的分页功能,添加上一页和下一页命令。优化搜索和重置命令,确保页面号更新时触发属性变化。更新供应商过滤器的界面,增强用户体验。

This commit is contained in:
geht
2026-05-06 17:17:00 +08:00
parent 76ed8f0534
commit a753bc5a4f
3 changed files with 135 additions and 53 deletions

View File

@@ -37,6 +37,8 @@ public class SupplierListViewModel : BaseViewModel
public DelegateCommand<MesXslSupplier> EditCommand { get; }
public DelegateCommand<MesXslSupplier> DeleteCommand { get; }
public DelegateCommand<MesXslSupplier> ToggleStatusCommand { get; }
public DelegateCommand PrevPageCommand { get; }
public DelegateCommand NextPageCommand { get; }
public SupplierListViewModel(
ISupplierService supplierService,
@@ -47,17 +49,41 @@ public class SupplierListViewModel : BaseViewModel
{
_supplierService = supplierService;
_dictSyncService = dictSyncService;
SearchCommand = new DelegateCommand(async () => { PageNo = 1; await LoadAsync(); });
SearchCommand = new DelegateCommand(async () =>
{
PageNo = 1;
RaisePropertyChanged(nameof(PageNo));
await LoadAsync();
});
ResetCommand = new DelegateCommand(async () =>
{
FilterSupplierCode = FilterSupplierName = FilterSupplierShortName = FilterErpCode = FilterStatus = null;
PageNo = 1;
RaisePropertyChanged(nameof(PageNo));
await LoadAsync();
});
AddCommand = new DelegateCommand(async () => await ShowAddDialogAsync());
EditCommand = new DelegateCommand<MesXslSupplier>(async s => await ShowEditDialogAsync(s));
DeleteCommand = new DelegateCommand<MesXslSupplier>(async s => await DeleteAsync(s));
ToggleStatusCommand = new DelegateCommand<MesXslSupplier>(async s => await ToggleStatusAsync(s));
PrevPageCommand = new DelegateCommand(async () =>
{
if (PageNo > 1)
{
PageNo--;
RaisePropertyChanged(nameof(PageNo));
await LoadAsync();
}
});
NextPageCommand = new DelegateCommand(async () =>
{
if ((long)PageNo * PageSize < Total)
{
PageNo++;
RaisePropertyChanged(nameof(PageNo));
await LoadAsync();
}
});
_supplierChangedToken = _eventAggregator.GetEvent<SupplierChangedEvent>()
.Subscribe(async p => await OnSupplierChangedAsync(p), ThreadOption.UIThread);