SaleMenuService.cs 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel.Design;
  4. using System.Linq;
  5. using System.Text;
  6. //----------------------------------------------------------------
  7. //Module Name: $safeprojectname$
  8. //Purpose:
  9. //CopyRight: Muchinfo
  10. //History:
  11. //----------------------------------------------------------------
  12. //DateTime 2016/4/19 17:09:50
  13. //Author
  14. //Description Create
  15. //----------------------------------------------------------------
  16. using System.Windows;
  17. using System.Windows.Input;
  18. using GalaSoft.MvvmLight.Command;
  19. using GalaSoft.MvvmLight.Ioc;
  20. using GalaSoft.MvvmLight.Messaging;
  21. using Muchinfo.MTPClient.Data;
  22. using Muchinfo.MTPClient.Data.Enums;
  23. using Muchinfo.MTPClient.Infrastructure.Cache;
  24. using Muchinfo.MTPClient.Infrastructure.Helpers;
  25. using Muchinfo.MTPClient.IService;
  26. using Muchinfo.MTPClient.Sale.ViewModels;
  27. using Muchinfo.MTPClient.Sale.Views;
  28. namespace Muchinfo.MTPClient.Sale.Utilities
  29. {
  30. public class SaleMenuService:IModuleMenuService
  31. {
  32. public Dictionary<Data.Enums.MenuCommandType, Data.SysMenuItem> GetModuleMenuItems()
  33. {
  34. var sysMenu = new Dictionary<MenuCommandType, SysMenuItem>();
  35. //sysMenu.Add(MenuCommandType.SaleOrder, new SysMenuItem(MenuCommandType.SaleOrder));
  36. // sysMenu.Add(MenuCommandType.AccountInfo,
  37. // new SysMenuItem(MenuCommandType.AccountInfo) { Command = MenuCommand, View = new QueryDealPurchaseView()});
  38. //sysMenu.Add(MenuCommandType.SaleApply, new SysMenuItem(MenuCommandType.SaleApply) { Command = SimpleIoc.Default.GetInstance<QuerySaleGoodsViewModel>().DetailCommand } );
  39. sysMenu.Add(MenuCommandType.Distribute,
  40. new SysMenuItem(MenuCommandType.Distribute) { Command = MenuCommand, ViewType = typeof(DistributeBallotView) });
  41. var showQuery = CacheManager.CacheMarketsGroups != null && CacheManager.CacheMarketsGroups.Any((goodsGroups) => goodsGroups.TradeMode == eTradeMode.TRADEMODE_SALE);
  42. if (showQuery) ////没有发售市场不显示
  43. {
  44. sysMenu.Add(MenuCommandType.DepositQuery,
  45. new SysMenuItem(MenuCommandType.DepositQuery)
  46. {
  47. Command = MenuCommand,
  48. ViewType = typeof (QueryDepositAppView)
  49. });
  50. }
  51. return sysMenu;
  52. }
  53. private ICommand _menuCommand;
  54. /// <summary>
  55. /// 菜单操作
  56. /// </summary>
  57. public ICommand MenuCommand
  58. {
  59. get
  60. {
  61. if (_menuCommand == null)
  62. {
  63. _menuCommand = new RelayCommand<SysMenuItem>((item) =>
  64. {
  65. if (!item.IsDialog)
  66. {
  67. var type = item.ViewType;
  68. var assembly = System.Reflection.Assembly.GetAssembly(type);
  69. var view = assembly.CreateInstance(type.FullName, false, System.Reflection.BindingFlags.CreateInstance, null, item.Params == null ? null : item.Params.ToArray(), null, null) as FrameworkElement;
  70. if (view != null)
  71. {
  72. MessengerHelper.DefaultSend(view, MessengerTokens.ShowQueryContet);
  73. }
  74. }
  75. else
  76. {
  77. var type = item.ViewType;
  78. if (type == null) return;
  79. var assembly = System.Reflection.Assembly.GetAssembly(type);
  80. var view = assembly.CreateInstance(type.FullName, false, System.Reflection.BindingFlags.CreateInstance, null, item.Params == null ? null : item.Params.ToArray(), null, null) as Window;
  81. if (view != null)
  82. {
  83. view.ShowDialog();
  84. }
  85. }
  86. });
  87. }
  88. return _menuCommand;
  89. }
  90. }
  91. }
  92. }