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.

114 lines
3.4 KiB
C#

using GalaSoft.MvvmLight;
using GalaSoft.MvvmLight.Command;
using Microsoft.Extensions.DependencyInjection;
using SlnMesnac.Business.business;
using SlnMesnac.Config;
using SlnMesnac.Model.domain;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SlnMesnac.WPF.ViewModel
{
internal class IndexControlViewModel : ViewModelBase
{
private InStoreBusiness inStoreBusiness;
public IndexControlViewModel()
{
this.inStoreBusiness = App.ServiceProvider.GetService<InStoreBusiness>();
UpdateInStoreFlagCommand = new RelayCommand<Int32>(obj =>
{
Console.WriteLine($"{obj};设置");
});
this.Init();
InStoreAmount = inStoreAmount + "19";
}
#region 参数定义
public string inStoreAmount = "入库数量:";
public string InStoreAmount
{
get { return this.inStoreAmount; }
set
{
inStoreAmount = value;
RaisePropertyChanged(nameof(InStoreAmount));
}
}
/// <summary>
/// A区域货道集合
/// </summary>
public ObservableCollection<BaseSpaceinfo> _areaA_SpaceInfo;
public ObservableCollection<BaseSpaceinfo> AreaA_SpaceInfo
{
get { return _areaA_SpaceInfo; }
set { _areaA_SpaceInfo = value; RaisePropertyChanged(nameof(AreaA_SpaceInfo)); }
}
/// <summary>
/// B区域货道集合
/// </summary>
public ObservableCollection<BaseSpaceinfo> _areaB_SpaceInfo;
public ObservableCollection<BaseSpaceinfo> AreaB_SpaceInfo
{
get { return _areaB_SpaceInfo; }
set { _areaB_SpaceInfo = value; RaisePropertyChanged(nameof(AreaB_SpaceInfo)); }
}
#endregion
public RelayCommand<Int32> UpdateInStoreFlagCommand { get; set; }
private ObservableCollection<BaseSpaceinfo> spaceItems = new ObservableCollection<BaseSpaceinfo>();
private void Init()
{
App.Current.Dispatcher.BeginInvoke((Action)(() =>
{
var info = inStoreBusiness.GetBaseSpaceinfos("A");
if (info != null)
{
if (spaceItems.Count > 0)
{
spaceItems.Clear();
}
info = info.OrderByDescending(x=>x.SpaceName).ToList();
foreach (var item in info)
{
spaceItems.Add(item);
}
AreaA_SpaceInfo = spaceItems;
}
}));
App.Current.Dispatcher.BeginInvoke((Action)(() =>
{
var info = inStoreBusiness.GetBaseSpaceinfos("A");
if (info != null)
{
if (spaceItems.Count > 0)
{
spaceItems.Clear();
}
info = info.OrderByDescending(x => x.SpaceName).ToList();
foreach (var item in info)
{
spaceItems.Add(item);
}
AreaB_SpaceInfo = spaceItems;
}
}));
}
}
}