新增全量拉取功能,允许用户从远程同步所有物料数据,优化用户体验。更新前端视图以支持新命令,并添加同步状态管理,确保操作的安全性和反馈。
This commit is contained in:
@@ -84,9 +84,13 @@ public class MixerMaterialListViewModel : BaseViewModel
|
|||||||
|
|
||||||
public string ToggleExpandButtonText => _isTreeAllExpanded ? "折叠全部" : "展开全部";
|
public string ToggleExpandButtonText => _isTreeAllExpanded ? "折叠全部" : "展开全部";
|
||||||
|
|
||||||
|
private bool _isSyncing;
|
||||||
|
public bool IsSyncing { get => _isSyncing; set => SetProperty(ref _isSyncing, value); }
|
||||||
|
|
||||||
public DelegateCommand SearchCommand { get; }
|
public DelegateCommand SearchCommand { get; }
|
||||||
public DelegateCommand ResetCommand { get; }
|
public DelegateCommand ResetCommand { get; }
|
||||||
public DelegateCommand AddCommand { get; }
|
public DelegateCommand AddCommand { get; }
|
||||||
|
public DelegateCommand PullAllCommand { get; }
|
||||||
public DelegateCommand<MesMixerMaterial> EditCommand { get; }
|
public DelegateCommand<MesMixerMaterial> EditCommand { get; }
|
||||||
public DelegateCommand<MesMixerMaterial> DeleteCommand { get; }
|
public DelegateCommand<MesMixerMaterial> DeleteCommand { get; }
|
||||||
public DelegateCommand PrevPageCommand { get; }
|
public DelegateCommand PrevPageCommand { get; }
|
||||||
@@ -120,6 +124,25 @@ public class MixerMaterialListViewModel : BaseViewModel
|
|||||||
PrevPageCommand = new DelegateCommand(async () => { if (PageNo > 1) { PageNo--; await LoadAsync(); } });
|
PrevPageCommand = new DelegateCommand(async () => { if (PageNo > 1) { PageNo--; await LoadAsync(); } });
|
||||||
NextPageCommand = new DelegateCommand(async () => { if ((long)PageNo * PageSize < Total) { PageNo++; await LoadAsync(); } });
|
NextPageCommand = new DelegateCommand(async () => { if ((long)PageNo * PageSize < Total) { PageNo++; await LoadAsync(); } });
|
||||||
ToggleExpandCommand = new DelegateCommand(ToggleExpand);
|
ToggleExpandCommand = new DelegateCommand(ToggleExpand);
|
||||||
|
PullAllCommand = new DelegateCommand(async () =>
|
||||||
|
{
|
||||||
|
if (IsSyncing) return;
|
||||||
|
IsSyncing = true;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
await _mixerMaterialService.SyncFromRemoteAsync();
|
||||||
|
await LoadAsync();
|
||||||
|
Growl.Success("全量拉取完成!");
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Growl.Error($"全量拉取失败:{ex.Message}");
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
IsSyncing = false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
_materialChangedToken = _eventAggregator
|
_materialChangedToken = _eventAggregator
|
||||||
.GetEvent<MixerMaterialChangedEvent>()
|
.GetEvent<MixerMaterialChangedEvent>()
|
||||||
|
|||||||
@@ -93,6 +93,13 @@
|
|||||||
<TextBlock Text="新增" Style="{StaticResource IconButtonStyle}"/>
|
<TextBlock Text="新增" Style="{StaticResource IconButtonStyle}"/>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</Button>
|
</Button>
|
||||||
|
<Button Style="{StaticResource ButtonInfo}" Command="{Binding PullAllCommand}"
|
||||||
|
IsEnabled="{Binding IsSyncing, Converter={StaticResource Boolean2BooleanReConverter}}">
|
||||||
|
<StackPanel Orientation="Horizontal">
|
||||||
|
<md:PackIcon Kind="CloudDownload"/>
|
||||||
|
<TextBlock Text="全量拉取" Style="{StaticResource IconButtonStyle}"/>
|
||||||
|
</StackPanel>
|
||||||
|
</Button>
|
||||||
</hc:UniformSpacingPanel>
|
</hc:UniformSpacingPanel>
|
||||||
</Border>
|
</Border>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user