|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- using BPASmartClient.CustomResource.Pages.Model;
- using BPASmartClient.CustomResource.UserControls;
- using BPASmartClient.CustomResource.UserControls.MessageShow;
- using BPASmartClient.Helper;
- using BPASmartClient.JXJFoodBigStation.Model;
- using BPASmartClient.JXJFoodBigStation.Model.HK_PLC;
- using Microsoft.Toolkit.Mvvm.ComponentModel;
- using Microsoft.Toolkit.Mvvm.Input;
- using System;
- using System.Collections.Generic;
- using System.Collections.ObjectModel;
- using System.ComponentModel;
- using System.Linq;
- using System.Reflection;
- using System.Text;
- using System.Threading;
- using System.Threading.Tasks;
-
- namespace BPASmartClient.JXJFoodBigStation.ViewModel
- {
- public class BomOfMaterialViewModel : ObservableObject
- {
- public BomOfMaterialViewModel()
- {
- RawMaterialInfo = Json<BomMaterial>.Data.RawMaterials;
- /*if (RawMaterialInfo.Count ==0)
- {
- Json<BomMaterial>.Data.RawMaterials.Clear();
- ProcessControl.GetInstance.RawMaterialNameWithCode();//原料的名称和编码对应 :西门子mes定义的物料编码
- foreach (var item in GVL_BigStation.RawMaterialsNameCode)
- {
- Json<BomMaterial>.Data.RawMaterials.Add(new RawMaterial() { RawMaterialCount = Json<BomMaterial>.Data.RawMaterials.Count + 1, RawMaterialName = item.Key, RawMaterialChineseName = item.Value });
- }
- RawMaterialInfo = Json<BomMaterial>.Data.RawMaterials;
- NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, App.MainWindow, "成功", $"读取程序的Bom清单");
- }*/
- AddMaterial = new RelayCommand(() =>
- {
- RawMaterialInfo.Add(new RawMaterial()
- {
- RawMaterialCount = Json<BomMaterial>.Data.RawMaterials.Count +1 ,
- });
- });
- SaveMaterials = new RelayCommand(() =>
- {
- if (MessageNotify.GetInstance.ShowDialog("请确认是否保存!") == true)
- {
- Json<BomMaterial>.Save();
- MessageNotify.GetInstance.ShowUserLog($"Mes物料清单保存成功");
- NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, App.MainWindow, "成功", $"原料与料仓对应关系保存成功");
- }
- });
- RemoveCommand = new RelayCommand<int>((Count) =>
- {
- if (Count is int cnt)
- {
- var res = RawMaterialInfo.FirstOrDefault(p => p.RawMaterialCount == cnt);
- if (res != null)
- {
- if (MessageNotify.GetInstance.ShowDialog("请确认是否删除!") == true)
- {
- RawMaterialInfo.Remove(res);
- NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, App.MainWindow, "成功", $"删除成功");
- }
- }
- }
- });
- }
- public ObservableCollection<RawMaterial> RawMaterialInfo { get; set; } = new ObservableCollection<RawMaterial>();
- public RelayCommand AddMaterial { get; set; }
- public RelayCommand SaveMaterials { get; set; }
- public RelayCommand<int> RemoveCommand { get; set; }
-
- }
- }
|