新增磅单管理功能,支持免密接口和数据同步,更新相关控制器、实体和服务,优化权限管理,确保系统的灵活性和可扩展性。
This commit is contained in:
@@ -0,0 +1,84 @@
|
||||
using HandyControl.Tools.Extension;
|
||||
using System.Collections.ObjectModel;
|
||||
using YY.Admin.Core;
|
||||
using YY.Admin.Core.Entity;
|
||||
using YY.Admin.Core.Services;
|
||||
|
||||
namespace YY.Admin.ViewModels.WeightRecord;
|
||||
|
||||
public class SupplierPickerDialogViewModel : BaseViewModel, IDialogResultable<bool>
|
||||
{
|
||||
private readonly ISupplierService _supplierService;
|
||||
|
||||
private string? _searchText;
|
||||
public string? SearchText { get => _searchText; set => SetProperty(ref _searchText, value); }
|
||||
|
||||
public ObservableCollection<MesXslSupplier> Suppliers { get; } = new();
|
||||
|
||||
private MesXslSupplier? _selectedSupplier;
|
||||
public MesXslSupplier? SelectedSupplier
|
||||
{
|
||||
get => _selectedSupplier;
|
||||
set
|
||||
{
|
||||
SetProperty(ref _selectedSupplier, value);
|
||||
ConfirmCommand.RaiseCanExecuteChanged();
|
||||
RaisePropertyChanged(nameof(SelectedSupplierDisplay));
|
||||
RaisePropertyChanged(nameof(HasSelectedSupplier));
|
||||
}
|
||||
}
|
||||
|
||||
public string SelectedSupplierDisplay => _selectedSupplier != null
|
||||
? $"[{_selectedSupplier.SupplierCode}] {_selectedSupplier.SupplierName}"
|
||||
: "选中供应商后点击「确认选择」";
|
||||
|
||||
public bool HasSelectedSupplier => _selectedSupplier != null;
|
||||
|
||||
private bool _result;
|
||||
public bool Result { get => _result; set => SetProperty(ref _result, value); }
|
||||
public Action? CloseAction { get; set; }
|
||||
|
||||
public DelegateCommand SearchCommand { get; }
|
||||
public DelegateCommand ConfirmCommand { get; }
|
||||
public DelegateCommand CancelCommand { get; }
|
||||
|
||||
public SupplierPickerDialogViewModel(
|
||||
ISupplierService supplierService,
|
||||
IContainerExtension container,
|
||||
IRegionManager regionManager) : base(container, regionManager)
|
||||
{
|
||||
_supplierService = supplierService;
|
||||
SearchCommand = new DelegateCommand(async () => await LoadAsync());
|
||||
ConfirmCommand = new DelegateCommand(Confirm, () => SelectedSupplier != null);
|
||||
CancelCommand = new DelegateCommand(() => CloseAction?.Invoke());
|
||||
_ = LoadAsync();
|
||||
}
|
||||
|
||||
private async Task LoadAsync()
|
||||
{
|
||||
try
|
||||
{
|
||||
IsLoading = true;
|
||||
var keyword = SearchText?.Trim();
|
||||
var result = await _supplierService.PageAsync(1, 200, supplierName: keyword);
|
||||
Suppliers.Clear();
|
||||
foreach (var s in result.Records)
|
||||
Suppliers.Add(s);
|
||||
}
|
||||
catch
|
||||
{
|
||||
Suppliers.Clear();
|
||||
}
|
||||
finally
|
||||
{
|
||||
IsLoading = false;
|
||||
}
|
||||
}
|
||||
|
||||
private void Confirm()
|
||||
{
|
||||
if (SelectedSupplier == null) return;
|
||||
Result = true;
|
||||
CloseAction?.Invoke();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user