using GalaSoft.MvvmLight; using GalaSoft.MvvmLight.Command; using HighWayIot.Repository.domain; using HighWayIot.Repository.service; using HighWayIot.Repository.service.Impl; using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.ComponentModel; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows; using System.Windows.Input; namespace Aucma.Scada.UI.viewModel.AssemblyPlan { public class PlanInfoEditViewModel : ViewModelBase { private ISysUserInfoService sysUserInfoService = new SysUserInfoServiceImpl(); public PlanInfoEditViewModel() { PlanInfoTransmitCommand = new RelayCommand(PlanInfoTransmit); MouseClickCommand = new RelayCommand(MouseClick); Query(); } #region 参数定义 /// /// 生产计划编号 /// private string _ProductPlanCode = string.Empty; public string ProductPlanCode { get { return _ProductPlanCode; } set { _ProductPlanCode = value; RaisePropertyChanged(nameof(ProductPlanCode)); } } /// /// 物料编号 /// private string _MaterialCode = string.Empty; public string MaterialCode { get { return _MaterialCode; } set { _MaterialCode = value; RaisePropertyChanged(nameof(MaterialCode)); } } /// /// 物料编号 /// private int _TransmitAmount = 0; public int TransmitAmount { get { return _TransmitAmount; } set { _TransmitAmount = value; RaisePropertyChanged(nameof(TransmitAmount)); } } private SysUserInfo selectedDataItem; public SysUserInfo SelectedDataItem { get { return selectedDataItem; } set { selectedDataItem = value; RaisePropertyChanged(nameof(SelectedDataItem)); } } #endregion #region 事件定义 /// /// 计划列表DataGrid /// private ObservableCollection planInfoDataGrid; public ObservableCollection PlanInfoDataGrid { get { return planInfoDataGrid; } set { planInfoDataGrid = value; RaisePropertyChanged(() => PlanInfoDataGrid); } } /// /// 生产计划下达 /// public RelayCommand PlanInfoTransmitCommand { get; set; } public RelayCommand MouseClickCommand { get; set; } #endregion /// /// 箱壳入库任务列表查询 /// public void Query() { var models = sysUserInfoService.GetUserInfos(); PlanInfoDataGrid = new ObservableCollection(); if (models != null) { models.ForEach( arg => { PlanInfoDataGrid.Add(arg); }); } } private void PlanInfoTransmit() { MessageBox.Show($"生产计划编号{_ProductPlanCode}物料编号{_MaterialCode}下达数量{_TransmitAmount}"); } public void MouseClick(object obj) { TransmitAmount = 0; var info = SelectedDataItem as SysUserInfo; ProductPlanCode = info.userId.ToString(); MaterialCode = info.userName; } } }