新增原料入场记录功能,包含免密接口和数据同步,更新相关控制器、实体和服务,支持条码/批次号生成及管理,优化用户体验和系统实时数据处理能力。
This commit is contained in:
@@ -120,7 +120,12 @@ namespace YY.Admin.ViewModels.Control
|
||||
// 已实现页面:密炼物料信息
|
||||
["MixerMaterialListView"] = "MixerMaterialListView",
|
||||
["/xslmes/mesMixerMaterial"] = "MixerMaterialListView",
|
||||
["mesMixerMaterial"] = "MixerMaterialListView"
|
||||
["mesMixerMaterial"] = "MixerMaterialListView",
|
||||
|
||||
// 已实现页面:原料入场记录
|
||||
["RawMaterialEntryListView"] = "RawMaterialEntryListView",
|
||||
["/xslmes/mesXslRawMaterialEntry"] = "RawMaterialEntryListView",
|
||||
["mesXslRawMaterialEntry"] = "RawMaterialEntryListView"
|
||||
};
|
||||
|
||||
private MenuItem? _selectedMenuItem;
|
||||
|
||||
@@ -0,0 +1,278 @@
|
||||
using HandyControl.Controls;
|
||||
using HandyControl.Tools.Extension;
|
||||
using System.Collections.ObjectModel;
|
||||
using YY.Admin.Core;
|
||||
using YY.Admin.Core.Entity;
|
||||
using YY.Admin.Core.Services;
|
||||
using YY.Admin.Services.Service;
|
||||
|
||||
namespace YY.Admin.ViewModels.RawMaterialEntry;
|
||||
|
||||
public class RawMaterialEntryEditDialogViewModel : BaseViewModel, IDialogResultable<bool>
|
||||
{
|
||||
private readonly IRawMaterialEntryService _entryService;
|
||||
private readonly IJeecgDictSyncService _dictSyncService;
|
||||
private readonly IMixerMaterialService _mixerMaterialService;
|
||||
|
||||
// 加载完物料后用于回填 Edit 模式选中项
|
||||
private string? _pendingMaterialId;
|
||||
|
||||
private MesXslRawMaterialEntry? _entry;
|
||||
public MesXslRawMaterialEntry? Entry
|
||||
{
|
||||
get => _entry;
|
||||
set => SetProperty(ref _entry, value);
|
||||
}
|
||||
|
||||
private MesMixerMaterial? _selectedMaterial;
|
||||
public MesMixerMaterial? SelectedMaterial
|
||||
{
|
||||
get => _selectedMaterial;
|
||||
set
|
||||
{
|
||||
if (!SetProperty(ref _selectedMaterial, value) || value == null || Entry == null) return;
|
||||
Entry.MaterialId = value.Id;
|
||||
Entry.MaterialCode = value.MaterialCode;
|
||||
Entry.MaterialName = value.MaterialName;
|
||||
RaisePropertyChanged(nameof(Entry));
|
||||
|
||||
// 新增模式自动生成条码/批次号
|
||||
if (IsAddMode && !string.IsNullOrEmpty(value.MaterialCode))
|
||||
_ = AutoGenerateBarcodeAsync(value.MaterialCode);
|
||||
}
|
||||
}
|
||||
|
||||
private bool _isGenerating;
|
||||
public bool IsGenerating
|
||||
{
|
||||
get => _isGenerating;
|
||||
set => SetProperty(ref _isGenerating, value);
|
||||
}
|
||||
|
||||
public bool IsAddMode => string.IsNullOrWhiteSpace(Entry?.Id);
|
||||
public string DialogTitle => IsAddMode ? "新增原料入场记录" : "编辑原料入场记录";
|
||||
|
||||
public ObservableCollection<MesMixerMaterial> MaterialOptions { get; } = new();
|
||||
public ObservableCollection<KeyValuePair<string, string>> TestResultOptions { get; } = new();
|
||||
public ObservableCollection<KeyValuePair<string, string>> TestStatusOptions { get; } = new();
|
||||
public ObservableCollection<KeyValuePair<string, string>> PrintFlagOptions { get; } = new();
|
||||
public ObservableCollection<KeyValuePair<string, string>> StockBalanceOptions { get; } = new();
|
||||
public ObservableCollection<KeyValuePair<string, string>> IsSpecialAdoptionOptions { get; } = new();
|
||||
public ObservableCollection<KeyValuePair<string, string>> StatusOptions { get; } = new();
|
||||
|
||||
private bool _result;
|
||||
public bool Result { get => _result; set => SetProperty(ref _result, value); }
|
||||
public Action? CloseAction { get; set; }
|
||||
|
||||
public DelegateCommand SaveCommand { get; }
|
||||
public DelegateCommand CancelCommand { get; }
|
||||
|
||||
public RawMaterialEntryEditDialogViewModel(
|
||||
IRawMaterialEntryService entryService,
|
||||
IJeecgDictSyncService dictSyncService,
|
||||
IMixerMaterialService mixerMaterialService,
|
||||
IContainerExtension container,
|
||||
IRegionManager regionManager) : base(container, regionManager)
|
||||
{
|
||||
_entryService = entryService;
|
||||
_dictSyncService = dictSyncService;
|
||||
_mixerMaterialService = mixerMaterialService;
|
||||
SaveCommand = new DelegateCommand(async () => await SaveAsync());
|
||||
CancelCommand = new DelegateCommand(() => CloseAction?.Invoke());
|
||||
_ = LoadAllAsync();
|
||||
}
|
||||
|
||||
private async Task LoadAllAsync()
|
||||
{
|
||||
await Task.WhenAll(LoadDictOptionsAsync(), LoadMaterialOptionsAsync());
|
||||
}
|
||||
|
||||
private async Task LoadMaterialOptionsAsync()
|
||||
{
|
||||
try
|
||||
{
|
||||
// 每次打开弹窗都主动拉一次,确保直接写库的数据也能同步到
|
||||
await _mixerMaterialService.SyncFromRemoteAsync();
|
||||
var result = await _mixerMaterialService.PageAsync(1, 2000);
|
||||
MaterialOptions.Clear();
|
||||
foreach (var m in result.Records)
|
||||
MaterialOptions.Add(m);
|
||||
|
||||
// Edit 模式:物料加载完后回填选中项
|
||||
if (_pendingMaterialId != null)
|
||||
{
|
||||
var match = MaterialOptions.FirstOrDefault(m =>
|
||||
string.Equals(m.Id, _pendingMaterialId, StringComparison.OrdinalIgnoreCase));
|
||||
if (match != null)
|
||||
SelectedMaterial = match;
|
||||
_pendingMaterialId = null;
|
||||
}
|
||||
}
|
||||
catch { /* 无法加载物料列表时不阻断表单 */ }
|
||||
}
|
||||
|
||||
private async Task LoadDictOptionsAsync()
|
||||
{
|
||||
try
|
||||
{
|
||||
var testResultOpts = await _dictSyncService.GetDictOptionsAsync("xslmes_test_result");
|
||||
var testStatusOpts = await _dictSyncService.GetDictOptionsAsync("xslmes_test_status");
|
||||
var printFlagOpts = await _dictSyncService.GetDictOptionsAsync("xslmes_print_flag");
|
||||
var ynOpts = await _dictSyncService.GetDictOptionsAsync("yn");
|
||||
var statusOpts = await _dictSyncService.GetDictOptionsAsync("xslmes_entry_status");
|
||||
|
||||
PopulateOptions(TestResultOptions, testResultOpts, new[]
|
||||
{
|
||||
new KeyValuePair<string, string>("未检", "0"),
|
||||
new KeyValuePair<string, string>("合格", "1"),
|
||||
new KeyValuePair<string, string>("不合格", "2"),
|
||||
});
|
||||
PopulateOptions(TestStatusOptions, testStatusOpts, new[]
|
||||
{
|
||||
new KeyValuePair<string, string>("送样", "0"),
|
||||
new KeyValuePair<string, string>("已批准", "1"),
|
||||
});
|
||||
PopulateOptions(PrintFlagOptions, printFlagOpts, new[]
|
||||
{
|
||||
new KeyValuePair<string, string>("未打印", "0"),
|
||||
new KeyValuePair<string, string>("已打印", "1"),
|
||||
});
|
||||
PopulateOptions(StockBalanceOptions, ynOpts, new[]
|
||||
{
|
||||
new KeyValuePair<string, string>("否", "0"),
|
||||
new KeyValuePair<string, string>("是", "1"),
|
||||
});
|
||||
PopulateOptions(IsSpecialAdoptionOptions, ynOpts, new[]
|
||||
{
|
||||
new KeyValuePair<string, string>("否", "0"),
|
||||
new KeyValuePair<string, string>("是", "1"),
|
||||
});
|
||||
PopulateOptions(StatusOptions, statusOpts, Array.Empty<KeyValuePair<string, string>>());
|
||||
}
|
||||
catch { FillFallbackOptions(); }
|
||||
}
|
||||
|
||||
private static void PopulateOptions(
|
||||
ObservableCollection<KeyValuePair<string, string>> target,
|
||||
IEnumerable<KeyValuePair<string, string>> items,
|
||||
IEnumerable<KeyValuePair<string, string>> fallback)
|
||||
{
|
||||
target.Clear();
|
||||
var list = items.ToList();
|
||||
foreach (var item in list.Count > 0 ? list : fallback.ToList())
|
||||
target.Add(item);
|
||||
}
|
||||
|
||||
private void FillFallbackOptions()
|
||||
{
|
||||
PopulateOptions(TestResultOptions, Array.Empty<KeyValuePair<string, string>>(), new[]
|
||||
{
|
||||
new KeyValuePair<string, string>("未检", "0"),
|
||||
new KeyValuePair<string, string>("合格", "1"),
|
||||
new KeyValuePair<string, string>("不合格", "2"),
|
||||
});
|
||||
PopulateOptions(TestStatusOptions, Array.Empty<KeyValuePair<string, string>>(), new[]
|
||||
{
|
||||
new KeyValuePair<string, string>("送样", "0"),
|
||||
new KeyValuePair<string, string>("已批准", "1"),
|
||||
});
|
||||
PopulateOptions(PrintFlagOptions, Array.Empty<KeyValuePair<string, string>>(), new[]
|
||||
{
|
||||
new KeyValuePair<string, string>("未打印", "0"),
|
||||
new KeyValuePair<string, string>("已打印", "1"),
|
||||
});
|
||||
var ynDefault = new[] { new KeyValuePair<string, string>("否", "0"), new KeyValuePair<string, string>("是", "1") };
|
||||
PopulateOptions(StockBalanceOptions, Array.Empty<KeyValuePair<string, string>>(), ynDefault);
|
||||
PopulateOptions(IsSpecialAdoptionOptions, Array.Empty<KeyValuePair<string, string>>(), ynDefault);
|
||||
}
|
||||
|
||||
private async Task AutoGenerateBarcodeAsync(string materialCode)
|
||||
{
|
||||
IsGenerating = true;
|
||||
try
|
||||
{
|
||||
var code = await _entryService.GenerateBarcodeAsync(materialCode);
|
||||
if (!string.IsNullOrEmpty(code) && Entry != null)
|
||||
{
|
||||
Entry.Barcode = code;
|
||||
Entry.BatchNo = code;
|
||||
RaisePropertyChanged(nameof(Entry));
|
||||
}
|
||||
}
|
||||
finally { IsGenerating = false; }
|
||||
}
|
||||
|
||||
public void InitializeForAdd()
|
||||
{
|
||||
_selectedMaterial = null;
|
||||
RaisePropertyChanged(nameof(SelectedMaterial));
|
||||
Entry = new MesXslRawMaterialEntry
|
||||
{
|
||||
TestResult = "0", TestStatus = "0", PrintFlag = "0",
|
||||
StockBalance = "0", IsSpecialAdoption = "0"
|
||||
};
|
||||
RaisePropertyChanged(nameof(IsAddMode));
|
||||
RaisePropertyChanged(nameof(DialogTitle));
|
||||
}
|
||||
|
||||
public void InitializeForEdit(MesXslRawMaterialEntry entry)
|
||||
{
|
||||
Entry = new MesXslRawMaterialEntry
|
||||
{
|
||||
Id = entry.Id, Barcode = entry.Barcode, BatchNo = entry.BatchNo, EntryTime = entry.EntryTime,
|
||||
WeightRecordId = entry.WeightRecordId, BillNo = entry.BillNo,
|
||||
MaterialId = entry.MaterialId, MaterialCode = entry.MaterialCode, MaterialName = entry.MaterialName,
|
||||
SupplyCustomer = entry.SupplyCustomer, SupplierId = entry.SupplierId, SupplierName = entry.SupplierName,
|
||||
ManufacturerMaterialName = entry.ManufacturerMaterialName,
|
||||
ShelfLife = entry.ShelfLife, TotalWeight = entry.TotalWeight, TotalPortions = entry.TotalPortions,
|
||||
PortionWeight = entry.PortionWeight, PortionPackages = entry.PortionPackages,
|
||||
TestResult = entry.TestResult, TestStatus = entry.TestStatus, PrintFlag = entry.PrintFlag,
|
||||
StockBalance = entry.StockBalance, WarehouseLocation = entry.WarehouseLocation,
|
||||
UnloadOperator = entry.UnloadOperator, IsSpecialAdoption = entry.IsSpecialAdoption,
|
||||
SpecialAdoptionOperator = entry.SpecialAdoptionOperator, SpecialAdoptionTime = entry.SpecialAdoptionTime,
|
||||
SpecialAdoptionReason = entry.SpecialAdoptionReason, Status = entry.Status, Remark = entry.Remark,
|
||||
TenantId = entry.TenantId,
|
||||
};
|
||||
|
||||
// 若物料列表已加载则直接回填,否则记录 pending 等加载完后回填
|
||||
if (MaterialOptions.Count > 0)
|
||||
{
|
||||
_selectedMaterial = MaterialOptions.FirstOrDefault(m =>
|
||||
string.Equals(m.Id, entry.MaterialId, StringComparison.OrdinalIgnoreCase));
|
||||
RaisePropertyChanged(nameof(SelectedMaterial));
|
||||
}
|
||||
else
|
||||
{
|
||||
_pendingMaterialId = entry.MaterialId;
|
||||
}
|
||||
|
||||
RaisePropertyChanged(nameof(IsAddMode));
|
||||
RaisePropertyChanged(nameof(DialogTitle));
|
||||
}
|
||||
|
||||
private async Task SaveAsync()
|
||||
{
|
||||
if (Entry == null) return;
|
||||
try
|
||||
{
|
||||
bool ok;
|
||||
if (IsAddMode)
|
||||
{
|
||||
ok = await _entryService.AddAsync(Entry);
|
||||
if (ok) HandyControl.Controls.MessageBox.Success("新增成功!");
|
||||
else { HandyControl.Controls.MessageBox.Error("新增失败!"); return; }
|
||||
}
|
||||
else
|
||||
{
|
||||
ok = await _entryService.EditAsync(Entry);
|
||||
if (!ok) { HandyControl.Controls.MessageBox.Error("编辑失败!"); return; }
|
||||
}
|
||||
Result = ok;
|
||||
CloseAction?.Invoke();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
HandyControl.Controls.MessageBox.Error($"操作失败:{ex.Message}");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,204 @@
|
||||
using HandyControl.Controls;
|
||||
using HandyControl.Tools.Extension;
|
||||
using Prism.Events;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Diagnostics;
|
||||
using System.Windows;
|
||||
using YY.Admin.Core;
|
||||
using YY.Admin.Core.Events;
|
||||
using YY.Admin.Core.Helper;
|
||||
using YY.Admin.Core.Entity;
|
||||
using YY.Admin.Core.Services;
|
||||
using YY.Admin.Services.Service;
|
||||
using YY.Admin.Views.RawMaterialEntry;
|
||||
|
||||
namespace YY.Admin.ViewModels.RawMaterialEntry;
|
||||
|
||||
public class RawMaterialEntryListViewModel : BaseViewModel
|
||||
{
|
||||
private readonly IRawMaterialEntryService _entryService;
|
||||
private readonly IJeecgDictSyncService _dictSyncService;
|
||||
private SubscriptionToken? _entryChangedToken;
|
||||
private SubscriptionToken? _syncConflictToken;
|
||||
|
||||
private ObservableCollection<MesXslRawMaterialEntry> _entries = new();
|
||||
public ObservableCollection<MesXslRawMaterialEntry> Entries
|
||||
{
|
||||
get => _entries;
|
||||
set => SetProperty(ref _entries, value);
|
||||
}
|
||||
|
||||
private long _total;
|
||||
public long Total { get => _total; set => SetProperty(ref _total, value); }
|
||||
|
||||
private int _pageNo = 1;
|
||||
public int PageNo { get => _pageNo; set => SetProperty(ref _pageNo, value); }
|
||||
|
||||
private int _pageSize = 20;
|
||||
public int PageSize { get => _pageSize; set => SetProperty(ref _pageSize, value); }
|
||||
|
||||
private string? _filterBarcode;
|
||||
public string? FilterBarcode { get => _filterBarcode; set => SetProperty(ref _filterBarcode, value); }
|
||||
|
||||
private string? _filterBatchNo;
|
||||
public string? FilterBatchNo { get => _filterBatchNo; set => SetProperty(ref _filterBatchNo, value); }
|
||||
|
||||
private string? _filterBillNo;
|
||||
public string? FilterBillNo { get => _filterBillNo; set => SetProperty(ref _filterBillNo, value); }
|
||||
|
||||
private string? _filterMaterialName;
|
||||
public string? FilterMaterialName { get => _filterMaterialName; set => SetProperty(ref _filterMaterialName, value); }
|
||||
|
||||
private string? _filterSupplierName;
|
||||
public string? FilterSupplierName { get => _filterSupplierName; set => SetProperty(ref _filterSupplierName, value); }
|
||||
|
||||
public DelegateCommand SearchCommand { get; }
|
||||
public DelegateCommand ResetCommand { get; }
|
||||
public DelegateCommand AddCommand { get; }
|
||||
public DelegateCommand<MesXslRawMaterialEntry> EditCommand { get; }
|
||||
public DelegateCommand<MesXslRawMaterialEntry> DeleteCommand { get; }
|
||||
public DelegateCommand PrevPageCommand { get; }
|
||||
public DelegateCommand NextPageCommand { get; }
|
||||
|
||||
public RawMaterialEntryListViewModel(
|
||||
IRawMaterialEntryService entryService,
|
||||
IJeecgDictSyncService dictSyncService,
|
||||
IContainerExtension container,
|
||||
IRegionManager regionManager) : base(container, regionManager)
|
||||
{
|
||||
_entryService = entryService;
|
||||
_dictSyncService = dictSyncService;
|
||||
|
||||
SearchCommand = new DelegateCommand(async () => { PageNo = 1; await LoadAsync(); });
|
||||
ResetCommand = new DelegateCommand(async () =>
|
||||
{
|
||||
FilterBarcode = null; FilterBatchNo = null; FilterBillNo = null;
|
||||
FilterMaterialName = null; FilterSupplierName = null;
|
||||
PageNo = 1;
|
||||
await LoadAsync();
|
||||
});
|
||||
AddCommand = new DelegateCommand(async () => await ShowAddDialogAsync());
|
||||
EditCommand = new DelegateCommand<MesXslRawMaterialEntry>(async e => await ShowEditDialogAsync(e));
|
||||
DeleteCommand = new DelegateCommand<MesXslRawMaterialEntry>(async e => await DeleteAsync(e));
|
||||
PrevPageCommand = new DelegateCommand(async () => { if (PageNo > 1) { PageNo--; await LoadAsync(); } });
|
||||
NextPageCommand = new DelegateCommand(async () => { if ((long)PageNo * PageSize < Total) { PageNo++; await LoadAsync(); } });
|
||||
|
||||
_entryChangedToken = _eventAggregator
|
||||
.GetEvent<RawMaterialEntryChangedEvent>()
|
||||
.Subscribe(async p => await OnEntryChangedAsync(p), ThreadOption.UIThread);
|
||||
|
||||
_syncConflictToken = _eventAggregator.GetEvent<SyncConflictEvent>()
|
||||
.Subscribe(OnSyncConflict, ThreadOption.UIThread);
|
||||
|
||||
_ = InitializeAsync();
|
||||
}
|
||||
|
||||
private async Task OnEntryChangedAsync(RawMaterialEntryChangedPayload payload)
|
||||
{
|
||||
if (payload.Action == "edit" && !string.IsNullOrWhiteSpace(payload.EntryId))
|
||||
await RefreshSingleAsync(payload.EntryId!);
|
||||
else
|
||||
await LoadAsync();
|
||||
}
|
||||
|
||||
private async Task RefreshSingleAsync(string entryId)
|
||||
{
|
||||
try
|
||||
{
|
||||
var updated = await _entryService.GetByIdAsync(entryId);
|
||||
if (updated == null) return;
|
||||
var idx = Entries.ToList().FindIndex(e => string.Equals(e.Id, entryId, StringComparison.OrdinalIgnoreCase));
|
||||
if (idx >= 0) Entries[idx] = updated;
|
||||
}
|
||||
catch (Exception ex) { Debug.WriteLine($"[原料入场] 单条刷新失败: {ex.Message}"); }
|
||||
}
|
||||
|
||||
private void OnSyncConflict(SyncConflictPayload payload)
|
||||
{
|
||||
if (!string.Equals(payload.EntityName, "原料入场", StringComparison.OrdinalIgnoreCase)) return;
|
||||
var parts = new List<string>();
|
||||
if (payload.PushedCount > 0) parts.Add($"已同步 {payload.PushedCount} 条本地改动到服务器");
|
||||
if (payload.NewRecordsPushed > 0) parts.Add($"已上传 {payload.NewRecordsPushed} 条本地新增记录");
|
||||
if (payload.ConflictCount > 0) parts.Add($"{payload.ConflictCount} 条记录与服务器版本冲突,已保留服务器版本");
|
||||
if (parts.Count == 0) return;
|
||||
var message = string.Join("\n", parts);
|
||||
if (payload.ConflictCount > 0) Growl.Warning(message); else Growl.Success(message);
|
||||
}
|
||||
|
||||
private async Task InitializeAsync()
|
||||
{
|
||||
try
|
||||
{
|
||||
await UIHelper.WaitForRenderAsync();
|
||||
await LoadAsync();
|
||||
}
|
||||
catch (Exception ex) { Debug.WriteLine($"原料入场列表初始化失败: {ex.Message}"); }
|
||||
}
|
||||
|
||||
public async Task LoadAsync()
|
||||
{
|
||||
try
|
||||
{
|
||||
IsLoading = true;
|
||||
var result = await _entryService.PageAsync(PageNo, PageSize,
|
||||
FilterBarcode, FilterBatchNo, FilterBillNo, FilterMaterialName, FilterSupplierName);
|
||||
Entries = new ObservableCollection<MesXslRawMaterialEntry>(result.Records);
|
||||
Total = result.Total;
|
||||
}
|
||||
catch (Exception ex) { Growl.Error($"加载原料入场记录失败:{ex.Message}"); }
|
||||
finally { IsLoading = false; }
|
||||
}
|
||||
|
||||
private async Task ShowAddDialogAsync()
|
||||
{
|
||||
try
|
||||
{
|
||||
var result = await HandyControl.Controls.Dialog.Show<RawMaterialEntryEditDialogView>()
|
||||
.Initialize<RawMaterialEntryEditDialogViewModel>(vm => vm.InitializeForAdd())
|
||||
.GetResultAsync<bool>();
|
||||
if (result) await LoadAsync();
|
||||
}
|
||||
catch (Exception ex) { Growl.Error($"打开新增对话框失败:{ex.Message}"); }
|
||||
}
|
||||
|
||||
private async Task ShowEditDialogAsync(MesXslRawMaterialEntry entry)
|
||||
{
|
||||
if (entry == null) return;
|
||||
try
|
||||
{
|
||||
var result = await HandyControl.Controls.Dialog.Show<RawMaterialEntryEditDialogView>()
|
||||
.Initialize<RawMaterialEntryEditDialogViewModel>(vm => vm.InitializeForEdit(entry))
|
||||
.GetResultAsync<bool>();
|
||||
if (result) await LoadAsync();
|
||||
}
|
||||
catch (Exception ex) { Growl.Error($"打开编辑对话框失败:{ex.Message}"); }
|
||||
}
|
||||
|
||||
private async Task DeleteAsync(MesXslRawMaterialEntry entry)
|
||||
{
|
||||
if (entry?.Id == null) return;
|
||||
var confirm = System.Windows.MessageBox.Show(
|
||||
$"确定删除该原料入场记录(条码:{entry.Barcode})?此操作不可恢复!",
|
||||
"确认删除", MessageBoxButton.OKCancel, MessageBoxImage.Question);
|
||||
if (confirm != System.Windows.MessageBoxResult.OK) return;
|
||||
|
||||
var ok = await _entryService.DeleteAsync(entry.Id);
|
||||
if (ok) { Growl.Success("删除成功!"); await LoadAsync(); }
|
||||
else Growl.Error("删除失败!");
|
||||
}
|
||||
|
||||
protected override void CleanUp()
|
||||
{
|
||||
base.CleanUp();
|
||||
if (_entryChangedToken != null)
|
||||
{
|
||||
_eventAggregator.GetEvent<RawMaterialEntryChangedEvent>().Unsubscribe(_entryChangedToken);
|
||||
_entryChangedToken = null;
|
||||
}
|
||||
if (_syncConflictToken != null)
|
||||
{
|
||||
_eventAggregator.GetEvent<SyncConflictEvent>().Unsubscribe(_syncConflictToken);
|
||||
_syncConflictToken = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user