QueryPanelPageModelBase.cs 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. using GalaSoft.MvvmLight;
  2. using GalaSoft.MvvmLight.Command;
  3. using Muchinfo.MTPClient.Data;
  4. using Muchinfo.MTPClient.Infrastructure.Helpers;
  5. using Muchinfo.MTPClient.Infrastructure.Utilities;
  6. using Muchinfo.MTPClient.IService;
  7. using Muchinfo.MTPClient.Resources;
  8. using System;
  9. using Muchinfo.PC.Common.Extensions;
  10. using System.Collections.Generic;
  11. using System.Collections.ObjectModel;
  12. using System.Linq;
  13. using System.Threading.Tasks;
  14. //----------------------------------------------------------------
  15. //Module Name: $safeprojectname$
  16. //Purpose:
  17. //CopyRight: Muchinfo
  18. //History:
  19. //----------------------------------------------------------------
  20. //DateTime 2016/4/16 13:44:50
  21. //Author
  22. //Description Create
  23. //----------------------------------------------------------------
  24. using System.Windows;
  25. namespace Muchinfo.MTPClient.Infrastructure.Windows
  26. {
  27. public abstract class QueryPanelPageModelBase<T> : ViewModelBase, IOrderRefresh
  28. {
  29. public QueryPanelPageModelBase()
  30. {
  31. }
  32. #region QueryPanel基类数据
  33. #region IsBusy
  34. private bool _isBusy;
  35. /// <summary>
  36. /// 是否在忙
  37. /// </summary>
  38. public bool IsBusy
  39. {
  40. get { return _isBusy; }
  41. set
  42. {
  43. Set(() => IsBusy, ref _isBusy, value);
  44. }
  45. }
  46. #endregion
  47. /// <summary>
  48. /// 刷新
  49. /// </summary>
  50. public virtual RelayCommand RefreshCommand
  51. {
  52. get
  53. {
  54. return new RelayCommand(() =>
  55. {
  56. RefreshContent();
  57. });
  58. }
  59. }
  60. /// <summary>
  61. /// 单据注册消息
  62. /// </summary>
  63. public abstract void RegisterMessage();
  64. /// <summary>
  65. /// 销毁消息
  66. /// </summary>
  67. public virtual void UnRegisterMessage()
  68. {
  69. // MessengerHelper.DefaultUnregister(this);
  70. }
  71. /// <summary>
  72. /// 刷新数据
  73. /// </summary>
  74. public abstract void RefreshContent();
  75. public virtual void QueryErrorCallback(ErrorEntity errorEntity)
  76. {
  77. IsBusy = false;
  78. Application.Current.Dispatcher.BeginInvoke(new Action(() =>
  79. {
  80. ErrorManager.ShowReturnError(errorEntity, Client_Resource.APP_Tips, false);
  81. }));
  82. }
  83. /// <summary>
  84. /// 刷新数据
  85. /// </summary>
  86. public void Refresh()
  87. {
  88. RefreshContent();
  89. }
  90. /// <summary>
  91. /// Cleanups this instance.
  92. /// </summary>
  93. public override void Cleanup()
  94. {
  95. ////取消注册消息
  96. base.Cleanup();
  97. MessengerHelper.QuoteUnregister(this);
  98. }
  99. #endregion
  100. }
  101. }