You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

93 lines
2.8 KiB
C#

1 year ago
using Admin.Core.IService;
using Admin.Core.Model.Model_New;
using Admin.Core.Service;
using Aucma.Core.OldBoxFoam;
using Aucma.Core.OldBoxFoam.Models;
1 year ago
using Aucma.Core.OldBoxFoam.Views;
1 year ago
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using CommunityToolkit.Mvvm.Messaging;
using Microsoft.Extensions.DependencyInjection;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
1 year ago
using System.Threading.Tasks;
using System.Windows;
1 year ago
namespace Aucma.Core.OldBoxFoam.ViewModels
1 year ago
{
public partial class RoadKindPageViewModel : ObservableObject
{
protected readonly IBoxFoamPlanServices? _boxFoamPlanServices;
protected IOldBoxFoamTypeServices? _boxFoamTypeServices;
public RoadKindPageViewModel()
{
1 year ago
// 设置型号
SubmitCommand = new RelayCommand<string>(obj => SubmitCommandExecute(obj));
1 year ago
_boxFoamPlanServices = App.ServiceProvider.GetService<IBoxFoamPlanServices>();
_boxFoamTypeServices = App.ServiceProvider.GetService<IOldBoxFoamTypeServices>();
1 year ago
SelectTypeViewModel.RefreshPageEvent += InitData;
1 year ago
InitData();
}
1 year ago
/// <summary>
/// 设置型号
/// </summary>
public RelayCommand<string> SubmitCommand { get; set; }
private void SubmitCommandExecute(string spaceCode)
{
SelectType type = new SelectType(spaceCode);
type.ShowDialog();
}
1 year ago
public async void InitData()
{
1 year ago
Shapes.Clear();
1 year ago
List<OldBoxFoamType> list = await _boxFoamTypeServices.QueryAsync();
1 year ago
if (list == null) return;
1 year ago
foreach(OldBoxFoamType item in list)
{
OldBoxFoamTypeModel model= new OldBoxFoamTypeModel();
model.MaterialCode = item.MaterialCode;
string pattern = @",(.*)";
Regex regex = new Regex(pattern);
Match match = regex.Match(item.MaterialName);
if (match.Success)
{
string result = match.Groups[1].Value;
model.MaterialName = result;
}
else
{
model.MaterialName = item.MaterialName;
}
1 year ago
model.ObjId = item.ObjId;
1 year ago
model.Status = "1";
Shapes.Add(model);
}
}
#region 初始化
private ObservableCollection<OldBoxFoamTypeModel> _shapes = new ObservableCollection<OldBoxFoamTypeModel>();
public ObservableCollection<OldBoxFoamTypeModel> Shapes
{
get => _shapes;
set => SetProperty(ref _shapes, value);
}
#endregion
}
}