123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596 |
- using DbCommon.Enties.DbModels;
- using Mapster;
- using MaterialDesignThemes.Wpf;
- using Prism.Commands;
- using Prism.Services.Dialogs;
- using ProjectManagementSystem.Common.Extenions;
- using ProjectManagementSystem.Common.Service;
- using ProjectManagementSystemView.Infrastructure;
- using ProjectManagementSystemView.Infrastructure.Models;
- using PropertyChanged;
- using System;
- using System.Collections.Generic;
- using System.Collections.ObjectModel;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace ProjectManagementSystemView.ViewModels.Dialogs
- {
- [AddINotifyPropertyChangedInterface]
- public class ModifyWmsViewModel : IDialogHostAware
- {
- public ObservableCollection<object> StatusCollection { get; set; }
- public ObservableCollection<string> MaterialIdCollection { get; set; }
- public VmLocationProperty Model { get; set; }
- public string DialogHostName { get; set; }
- public DelegateCommand SaveCommand { get; set; }
- public DelegateCommand CancelCommand { get; set; }
- public ModifyWmsViewModel()
- {
- Model = new VmLocationProperty();
- StatusCollection = new ObservableCollection<object>();
- MaterialIdCollection = new ObservableCollection<string>();
- StatusCollection.Add(new { Value = LocationStatus.None, Display = LocationStatus.None.ToStatusString() });
- StatusCollection.Add(new { Value = LocationStatus.Filled, Display = LocationStatus.Filled.ToStatusString() });
- StatusCollection.Add(new { Value = LocationStatus.Empty, Display = LocationStatus.Empty.ToStatusString() });
- if (Crms.PmsTaskService is PmsTaskServiceSWms)
- {
- var goodsList = Crms.SWmsApi.GetAllGoods();
- if (goodsList != null)
- {
- goodsList.ForEach(d => MaterialIdCollection.Add(d.goodsCode));
- }
- }
- else
- {
- MaterialIdCollection.Add("默认货物");
- MaterialIdCollection.Add("空料车");
- MaterialIdCollection.Add("满料车");
- }
- MaterialIdCollection.Add("");
- SaveCommand = new DelegateCommand(Save);
- CancelCommand = new DelegateCommand(Cancel);
- }
- /// <summary>
- /// 取消
- /// </summary>
- private void Cancel()
- {
- if (DialogHost.IsDialogOpen(DialogHostName))
- DialogHost.Close(DialogHostName, new DialogResult(ButtonResult.No)); //取消返回NO告诉操作结束
- }
- /// <summary>
- /// 确定
- /// </summary>
- private void Save()
- {
- if (DialogHost.IsDialogOpen(DialogHostName))
- {
- //确定时,把编辑的实体返回并且返回OK
- DialogParameters param = new DialogParameters();
- param.Add("Value", Model);
- DialogHost.Close(DialogHostName, new DialogResult(ButtonResult.OK, param));
- }
- }
- public void OnDialogOpend(IDialogParameters parameters)
- {
- if (parameters.ContainsKey("Value"))
- {
- var data = parameters.GetValue<VmLocationProperty>("Value");
- data?.Adapt(Model);
- }
- }
- }
- }
|