DeliveryMenuService.cs 4.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. using GalaSoft.MvvmLight.Command;
  2. using Muchinfo.MTPClient.Data;
  3. using Muchinfo.MTPClient.Data.Enums;
  4. using Muchinfo.MTPClient.Delivery.Views;
  5. using Muchinfo.MTPClient.Infrastructure.Helpers;
  6. using Muchinfo.MTPClient.IService;
  7. using System;
  8. using System.Collections.Generic;
  9. using System.Linq;
  10. using System.Text;
  11. using System.Windows;
  12. using System.Windows.Input;
  13. namespace Muchinfo.MTPClient.Delivery.Utilities
  14. {
  15. /// <summary>
  16. /// 交收管理菜单
  17. /// Add By DK 20160804
  18. /// </summary>
  19. public class DeliveryMenuService : IModuleMenuService
  20. {
  21. /// <summary>
  22. /// Gets the module menu items.
  23. /// </summary>
  24. /// <returns>System.Collections.Generic.Dictionary{Muchinfo.MTPClient.Data.Enums.MenuCommandType,Muchinfo.MTPClient.Data.SysMenuItem}.</returns>
  25. public Dictionary<MenuCommandType, SysMenuItem> GetModuleMenuItems()
  26. {
  27. var sysMenu = new Dictionary<MenuCommandType, SysMenuItem>();
  28. sysMenu.Add(MenuCommandType.DeliveryManage, new SysMenuItem(MenuCommandType.DeliveryManage));
  29. sysMenu.Add(MenuCommandType.DeliveryDeclaration, new SysMenuItem(MenuCommandType.DeliveryDeclaration) { Command = MenuCommand, ViewType = typeof(NDeliveryOrderView), IsDialog = true });
  30. //sysMenu.Add(MenuCommandType.DeliveryDeclarationSearch, new SysMenuItem(MenuCommandType.DeliveryDeclarationSearch) { Command = MenuCommand, ViewType = typeof(DeliveryEntructOrderView), });
  31. sysMenu.Add(MenuCommandType.DeliveryDeclarationSearch, new SysMenuItem(MenuCommandType.DeliveryDeclarationSearch) { Command = MenuCommand, ViewType = typeof(NDeliveryEntructOrderView), });
  32. sysMenu.Add(MenuCommandType.DeliveryOrderSearch, new SysMenuItem(MenuCommandType.DeliveryOrderSearch) { Command = MenuCommand, ViewType = typeof(DryHoldDetailView), });
  33. sysMenu.Add(MenuCommandType.WarehouseManagement, new SysMenuItem(MenuCommandType.WarehouseManagement));
  34. //仓单查询
  35. sysMenu.Add(MenuCommandType.WarehouseSearch, new SysMenuItem(MenuCommandType.WarehouseSearch) { Command = MenuCommand, ViewType = typeof(DeliveryWarehouseOrderView), });
  36. //提货申请
  37. sysMenu.Add(MenuCommandType.TakaDeliveryGoodsApply, new SysMenuItem(MenuCommandType.TakaDeliveryGoodsApply) { Command = MenuCommand, ViewType = typeof(TakaDeliveryGoodsApplyView), IsDialog = true });
  38. //提货查询
  39. sysMenu.Add(MenuCommandType.TakaDeliveryGoodsQuery, new SysMenuItem(MenuCommandType.TakaDeliveryGoodsQuery) { Command = MenuCommand, ViewType = typeof(TakaDeliveryGoodsQueryView), });
  40. //成交单查询
  41. sysMenu.Add(MenuCommandType.DeliveryComplete, new SysMenuItem(MenuCommandType.DeliveryComplete) { Command = MenuCommand, ViewType = typeof(DeliveryComplete), });
  42. return sysMenu;
  43. }
  44. private ICommand _menuCommand;
  45. /// <summary>
  46. /// 菜单操作
  47. /// </summary>
  48. public ICommand MenuCommand
  49. {
  50. get
  51. {
  52. if (_menuCommand == null)
  53. {
  54. _menuCommand = new RelayCommand<SysMenuItem>((item) =>
  55. {
  56. if (!item.IsDialog)
  57. {
  58. var type = item.ViewType;
  59. var assembly = System.Reflection.Assembly.GetAssembly(type);
  60. var view = assembly.CreateInstance(type.FullName, false, System.Reflection.BindingFlags.CreateInstance, null, item.Params == null ? null : item.Params.ToArray(), null, null) as FrameworkElement;
  61. if (view != null)
  62. {
  63. MessengerHelper.DefaultSend(view, MessengerTokens.ShowQueryContet);
  64. }
  65. }
  66. else
  67. {
  68. var type = item.ViewType;
  69. var assembly = System.Reflection.Assembly.GetAssembly(type);
  70. var view = assembly.CreateInstance(type.FullName, false, System.Reflection.BindingFlags.CreateInstance, null, item.Params == null ? null : item.Params.ToArray(), null, null) as Window;
  71. if (view != null)
  72. {
  73. view.Owner = Application.Current.MainWindow;
  74. view.WindowStartupLocation = WindowStartupLocation.CenterOwner;
  75. view.ShowDialog();
  76. }
  77. }
  78. });
  79. }
  80. return _menuCommand;
  81. }
  82. }
  83. }
  84. }