| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141 |
- using Prism.Commands;
- using Prism.Events;
- using Prism.Ioc;
- using Prism.Mvvm;
- using Prism.Regions;
- using Prism.Services.Dialogs;
- using System;
- using System.Collections.Generic;
- using System.Collections.ObjectModel;
- using System.Linq;
- using System.Windows;
- using TeamAAS_VP.Events;
- using TeamAAS_VP.Core;
- using TeamAAS_VP.Models;
- using TeamAAS_VP.Resources.Languages;
- namespace TeamAAS_VP.ViewModels.Product
- {
- public class ProductParamsViewModel : BindableBase
- {
- IRegionManager _regionManager;
- IEventAggregator _eventAggregator;
- IContainerProvider _container;
- IDialogService _dialogService;
- ProductsViewModel productsViewModel;
- #region 属性
- private ProductModel _SelectProduct;
- /// <summary>
- /// 选中的产品
- /// </summary>
- public ProductModel SelectProduct
- {
- get { return _SelectProduct; }
- set { SetProperty(ref _SelectProduct, value); }
- }
- private Management _management;
- public Management management
- {
- get { return _management; }
- set { SetProperty(ref _management, value); }
- }
- #endregion
- #region 命令
- private DelegateCommand _NextCommand;
- public DelegateCommand NextCommand =>
- _NextCommand ?? (_NextCommand = new DelegateCommand(ExecuteNextCommand));
- private DelegateCommand _BackCommand;
- public DelegateCommand BackCommand =>
- _BackCommand ?? (_BackCommand = new DelegateCommand(ExecuteBackCommand));
- private DelegateCommand _LoadedCommand;
- public DelegateCommand LoadedCommand =>
- _LoadedCommand ?? (_LoadedCommand = new DelegateCommand(ExecuteLoadedCommand));
- #endregion
- #region 事件
-
- #endregion
- public ProductParamsViewModel(IRegionManager regionManager, IEventAggregator ea, IContainerProvider container, IDialogService dialogService)
- {
- _regionManager = regionManager;
- _eventAggregator = ea;
- _container = container;
- _dialogService = dialogService;
- //订阅权限登录事件
- _eventAggregator.GetEvent<UserLoginNotification>().Subscribe(LoginChange);
- productsViewModel = _container.Resolve<ProductsViewModel>();
- SelectProduct = productsViewModel.SelectProduct;
- management = _container.Resolve<Management>();
- }
- #region 方法
- /// <summary>
- /// 完成
- /// </summary>
- void ExecuteNextCommand()
- {
- if (MessageBox.Show(Lang.是否保存产品.Replace("[{0}]", ""), Lang.保存产品, MessageBoxButton.YesNo,MessageBoxImage.Question)==MessageBoxResult.Yes)
- {
- management.SaveProducts(SelectProduct);
- }
- _regionManager.RequestNavigate("ProductRegionContext", "ProductHome");
- }
- /// <summary>
- /// 上一步
- /// </summary>
- void ExecuteBackCommand()
- {
- _regionManager.RequestNavigate("ProductRegionContext", "RobotPointParams");
- }
- void ExecuteLoadedCommand()
- {
- if (_container.Resolve<Management>().CurrentUser.userPart == Enums.UserPart.Operator)
- {
- IsAllowEdit = false;
- }
- else
- {
- IsAllowEdit = true;
- }
- productsViewModel = _container.Resolve<ProductsViewModel>();
- SelectProduct = productsViewModel.SelectProduct;
- management = _container.Resolve<Management>();
- }
- #endregion
- private bool _IsAllowEdit = false;
- public bool IsAllowEdit
- {
- get { return _IsAllowEdit; }
- set { SetProperty(ref _IsAllowEdit, value); }
- }
- private void LoginChange(Models.User user)
- {
- if (user.userPart == Enums.UserPart.Operator)
- {
- IsAllowEdit = false;
- }
- else
- {
- IsAllowEdit = true;
- }
- }
- }
- }
|