diff --git a/Sln.Wcs.UI/ViewModels/Base/CrudPageViewModel.cs b/Sln.Wcs.UI/ViewModels/Base/CrudPageViewModel.cs index 69f3aac..f35f9c0 100644 --- a/Sln.Wcs.UI/ViewModels/Base/CrudPageViewModel.cs +++ b/Sln.Wcs.UI/ViewModels/Base/CrudPageViewModel.cs @@ -108,9 +108,13 @@ public abstract partial class CrudPageViewModel : ObservableObject, ICrudPage } [RelayCommand] - private void Delete() + private async System.Threading.Tasks.Task Delete() { if (SelectedItem is null) return; + var dialog = new Views.Base.ConfirmDialog(); + var ok = await dialog.ShowDialog("确定要删除该条记录吗?此操作不可恢复。", GetMainWindow()); + if (!ok) return; + var prop = typeof(T).GetProperty("objId") ?? typeof(T).GetProperty("ObjId"); if (prop is null) return; var id = prop.GetValue(SelectedItem); diff --git a/Sln.Wcs.UI/ViewModels/Device/DeviceInfoViewModel.cs b/Sln.Wcs.UI/ViewModels/Device/DeviceInfoViewModel.cs index 93e965b..962cee9 100644 --- a/Sln.Wcs.UI/ViewModels/Device/DeviceInfoViewModel.cs +++ b/Sln.Wcs.UI/ViewModels/Device/DeviceInfoViewModel.cs @@ -86,8 +86,10 @@ public partial class DeviceInfoViewModel : CrudPageViewModel } } - public void DeleteParam(BaseDeviceParam param) + public async System.Threading.Tasks.Task DeleteParamAsync(BaseDeviceParam param) { + var dlg = new Sln.Wcs.UI.Views.Base.ConfirmDialog(); + if (!await dlg.ShowDialog("确定要删除该参数吗?", GetMainWindow())) return; _paramService.DeleteById(param.objId); LoadParams(); } diff --git a/Sln.Wcs.UI/ViewModels/Path/PathInfoViewModel.cs b/Sln.Wcs.UI/ViewModels/Path/PathInfoViewModel.cs index ff0fd69..386297c 100644 --- a/Sln.Wcs.UI/ViewModels/Path/PathInfoViewModel.cs +++ b/Sln.Wcs.UI/ViewModels/Path/PathInfoViewModel.cs @@ -86,8 +86,10 @@ public partial class PathInfoViewModel : CrudPageViewModel } } - public void DeleteDetail(BasePathDetails detail) + public async System.Threading.Tasks.Task DeleteDetailAsync(BasePathDetails detail) { + var dlg = new Sln.Wcs.UI.Views.Base.ConfirmDialog(); + if (!await dlg.ShowDialog("确定要删除该明细吗?", GetMainWindow())) return; _detailService.DeleteById(detail.objId); LoadDetails(); } diff --git a/Sln.Wcs.UI/ViewModels/Task/TaskQueueViewModel.cs b/Sln.Wcs.UI/ViewModels/Task/TaskQueueViewModel.cs index 5c036ad..496c0a0 100644 --- a/Sln.Wcs.UI/ViewModels/Task/TaskQueueViewModel.cs +++ b/Sln.Wcs.UI/ViewModels/Task/TaskQueueViewModel.cs @@ -92,8 +92,10 @@ public partial class TaskQueueViewModel : CrudPageViewModel } } - public void DeleteDetail(LiveTaskDetail detail) + public async System.Threading.Tasks.Task DeleteDetailAsync(LiveTaskDetail detail) { + var dlg = new Sln.Wcs.UI.Views.Base.ConfirmDialog(); + if (!await dlg.ShowDialog("确定要删除该明细吗?", GetMainWindow())) return; _detailService.DeleteById(detail.objId); LoadDetails(); } diff --git a/Sln.Wcs.UI/Views/Base/ConfirmDialog.axaml b/Sln.Wcs.UI/Views/Base/ConfirmDialog.axaml new file mode 100644 index 0000000..dc6e08e --- /dev/null +++ b/Sln.Wcs.UI/Views/Base/ConfirmDialog.axaml @@ -0,0 +1,50 @@ + + + + + + + + + + + + + + + + + + + + +