新增MES模块,包含供应商、客户、车辆和地磅数据记录管理功能,支持免密接口和数据同步。更新相关控制器、实体、服务和数据库配置,优化权限管理和数据字典支持,确保系统的灵活性和可扩展性。

This commit is contained in:
geht
2026-04-30 15:28:20 +08:00
parent 142a0bdaba
commit b03cbeff9b
121 changed files with 10540 additions and 424 deletions

View File

@@ -0,0 +1,111 @@
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.Supplier;
public class SupplierEditDialogViewModel : BaseViewModel, HandyControl.Tools.Extension.IDialogResultable<bool>
{
private readonly ISupplierService _supplierService;
private readonly IJeecgDictSyncService _dictSyncService;
private bool _result;
public bool Result { get => _result; set => SetProperty(ref _result, value); }
public Action? CloseAction { get; set; }
private MesXslSupplier? _supplier;
public MesXslSupplier? Supplier
{
get => _supplier;
set => SetProperty(ref _supplier, value);
}
public bool IsAddMode => string.IsNullOrWhiteSpace(Supplier?.Id) || (Supplier?.Id?.StartsWith("local-") ?? false);
public string DialogTitle => IsAddMode ? "新增供应商" : "编辑供应商";
public ObservableCollection<KeyValuePair<string, string>> StatusOptions { get; } = new();
public DelegateCommand SaveCommand { get; }
public DelegateCommand CancelCommand { get; }
public SupplierEditDialogViewModel(ISupplierService supplierService, IJeecgDictSyncService dictSyncService, IContainerExtension container, IRegionManager regionManager) : base(container, regionManager)
{
_supplierService = supplierService;
_dictSyncService = dictSyncService;
SaveCommand = new DelegateCommand(async () => await SaveAsync());
CancelCommand = new DelegateCommand(() => CloseAction?.Invoke());
_ = LoadDictOptionsAsync();
}
private async Task LoadDictOptionsAsync()
{
try
{
var statusOpts = await _dictSyncService.GetDictOptionsAsync("xslmes_supplier_status");
StatusOptions.Clear();
foreach (var item in statusOpts) StatusOptions.Add(item);
if (StatusOptions.Count == 0)
{
StatusOptions.Add(new KeyValuePair<string, string>("启用", "0"));
StatusOptions.Add(new KeyValuePair<string, string>("停用", "1"));
}
}
catch { }
}
public void InitializeForAdd()
{
Supplier = new MesXslSupplier { Status = "0" };
RaisePropertyChanged(nameof(IsAddMode));
RaisePropertyChanged(nameof(DialogTitle));
}
public void InitializeForEdit(MesXslSupplier supplier)
{
Supplier = new MesXslSupplier
{
Id = supplier.Id,
SupplierCode = supplier.SupplierCode,
SupplierName = supplier.SupplierName,
SupplierShortName = supplier.SupplierShortName,
ErpCode = supplier.ErpCode,
Status = supplier.Status,
Remark = supplier.Remark,
TenantId = supplier.TenantId,
};
RaisePropertyChanged(nameof(IsAddMode));
RaisePropertyChanged(nameof(DialogTitle));
}
private async Task SaveAsync()
{
if (Supplier == null) return;
if (string.IsNullOrWhiteSpace(Supplier.SupplierCode))
{
HandyControl.Controls.MessageBox.Warning("供应商编码不能为空!");
return;
}
if (string.IsNullOrWhiteSpace(Supplier.SupplierName))
{
HandyControl.Controls.MessageBox.Warning("供应商名称不能为空!");
return;
}
bool ok = IsAddMode ? await _supplierService.AddAsync(Supplier) : await _supplierService.EditAsync(Supplier);
if (ok)
{
if (IsAddMode)
{
HandyControl.Controls.MessageBox.Success("新增供应商成功!");
}
Result = true;
CloseAction?.Invoke();
return;
}
else
{
HandyControl.Controls.MessageBox.Error("保存供应商失败!");
}
}
}