增加Code验证功能
This commit is contained in:
parent
c7e3c0fe81
commit
1cbd295691
@ -1,12 +1,14 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Collections.ObjectModel;
|
using System.Collections.ObjectModel;
|
||||||
|
using System.Threading.Tasks;
|
||||||
using Avalonia.Controls.Notifications;
|
using Avalonia.Controls.Notifications;
|
||||||
using CommunityToolkit.Mvvm.ComponentModel;
|
using CommunityToolkit.Mvvm.ComponentModel;
|
||||||
using CommunityToolkit.Mvvm.Input;
|
using CommunityToolkit.Mvvm.Input;
|
||||||
using CommunityToolkit.Mvvm.Messaging;
|
using CommunityToolkit.Mvvm.Messaging;
|
||||||
using Seyounth.Hyosung.Data.Models;
|
using Seyounth.Hyosung.Data.Models;
|
||||||
using Seyounth.Hyosung.Data.Services;
|
using Seyounth.Hyosung.Data.Services;
|
||||||
|
using Seyounth.Hyosung.Data.Services.Hyosung;
|
||||||
using SukiUI.Toasts;
|
using SukiUI.Toasts;
|
||||||
|
|
||||||
namespace Seyounth.Hyosung.Ava.ViewModels;
|
namespace Seyounth.Hyosung.Ava.ViewModels;
|
||||||
@ -22,6 +24,7 @@ public partial class PalletManagerViewModel : ObservableObject
|
|||||||
|
|
||||||
private readonly IPalletService _palletService;
|
private readonly IPalletService _palletService;
|
||||||
|
|
||||||
|
|
||||||
public PalletManagerViewModel(IPalletService palletService, ISukiToastManager toastManager)
|
public PalletManagerViewModel(IPalletService palletService, ISukiToastManager toastManager)
|
||||||
{
|
{
|
||||||
_toastManager = toastManager;
|
_toastManager = toastManager;
|
||||||
@ -65,13 +68,13 @@ public partial class PalletManagerViewModel : ObservableObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
[RelayCommand]
|
[RelayCommand]
|
||||||
private void OnSavePallet(object obj)
|
private async Task OnSavePallet(object obj)
|
||||||
{
|
{
|
||||||
if (obj is Pallet pallet)
|
if (obj is Pallet pallet)
|
||||||
{
|
{
|
||||||
if (pallet.Id == 0)
|
if (pallet.Id == 0)
|
||||||
{
|
{
|
||||||
var id = _palletService.AddPalletAsync(pallet).Result;
|
await _palletService.AddPalletAsync(pallet);
|
||||||
_toastManager.CreateToast()
|
_toastManager.CreateToast()
|
||||||
.WithTitle("新增辅料成功")
|
.WithTitle("新增辅料成功")
|
||||||
.Dismiss().After(TimeSpan.FromSeconds(3))
|
.Dismiss().After(TimeSpan.FromSeconds(3))
|
||||||
@ -81,7 +84,7 @@ public partial class PalletManagerViewModel : ObservableObject
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_palletService.UpdatePalletAsync(pallet);
|
await _palletService.UpdatePalletAsync(pallet);
|
||||||
_toastManager.CreateToast()
|
_toastManager.CreateToast()
|
||||||
.WithTitle("修改辅料成功")
|
.WithTitle("修改辅料成功")
|
||||||
.Dismiss().After(TimeSpan.FromSeconds(3))
|
.Dismiss().After(TimeSpan.FromSeconds(3))
|
||||||
|
@ -8,6 +8,7 @@ using CommunityToolkit.Mvvm.Input;
|
|||||||
using CommunityToolkit.Mvvm.Messaging;
|
using CommunityToolkit.Mvvm.Messaging;
|
||||||
using Seyounth.Hyosung.Data.Models;
|
using Seyounth.Hyosung.Data.Models;
|
||||||
using Seyounth.Hyosung.Data.Services;
|
using Seyounth.Hyosung.Data.Services;
|
||||||
|
using Seyounth.Hyosung.Data.Services.Hyosung;
|
||||||
using SukiUI.Toasts;
|
using SukiUI.Toasts;
|
||||||
|
|
||||||
namespace Seyounth.Hyosung.Ava.ViewModels;
|
namespace Seyounth.Hyosung.Ava.ViewModels;
|
||||||
@ -27,7 +28,7 @@ public partial class VarietyManagerViewModel : ObservableObject
|
|||||||
private readonly ISukiToastManager _toastManager;
|
private readonly ISukiToastManager _toastManager;
|
||||||
private readonly IVarietyService _varietyService;
|
private readonly IVarietyService _varietyService;
|
||||||
private readonly IPalletService _palletService;
|
private readonly IPalletService _palletService;
|
||||||
|
private readonly IHyosungWmsService _wmsService;
|
||||||
public void Reload()
|
public void Reload()
|
||||||
{
|
{
|
||||||
Pallets = new ObservableCollection<Pallet>(_palletService.GetPallets());
|
Pallets = new ObservableCollection<Pallet>(_palletService.GetPallets());
|
||||||
@ -55,8 +56,9 @@ public partial class VarietyManagerViewModel : ObservableObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
public VarietyManagerViewModel(IVarietyService varietyService, ISukiToastManager toastManager,
|
public VarietyManagerViewModel(IVarietyService varietyService, ISukiToastManager toastManager,
|
||||||
IPalletService palletService)
|
IPalletService palletService,IHyosungWmsService wmsService)
|
||||||
{
|
{
|
||||||
|
_wmsService = wmsService;
|
||||||
_toastManager = toastManager;
|
_toastManager = toastManager;
|
||||||
_palletService = palletService;
|
_palletService = palletService;
|
||||||
_varietyService = varietyService;
|
_varietyService = varietyService;
|
||||||
@ -139,8 +141,20 @@ public partial class VarietyManagerViewModel : ObservableObject
|
|||||||
[RelayCommand]
|
[RelayCommand]
|
||||||
private async Task OnSavePallet(object obj)
|
private async Task OnSavePallet(object obj)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (obj is Variety variety)
|
if (obj is Variety variety)
|
||||||
{
|
{
|
||||||
|
var mod = await _wmsService.GetItemInfoByItemCode(variety.Code);
|
||||||
|
if(mod is null)
|
||||||
|
{
|
||||||
|
_toastManager.CreateToast()
|
||||||
|
.WithTitle("请检查产品代码是否错误")
|
||||||
|
.Dismiss().After(TimeSpan.FromSeconds(3))
|
||||||
|
.OfType(NotificationType.Error)
|
||||||
|
.Dismiss().ByClicking()
|
||||||
|
.Queue();
|
||||||
|
return;
|
||||||
|
}
|
||||||
await _varietyService.AddVarietyAsync(variety);
|
await _varietyService.AddVarietyAsync(variety);
|
||||||
_toastManager.CreateToast()
|
_toastManager.CreateToast()
|
||||||
.WithTitle("保存成功")
|
.WithTitle("保存成功")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user