|
|
@ -24,11 +24,13 @@ namespace BBWY.Client.ViewModels |
|
|
|
private IHttpClientFactory httpClientFactory; |
|
|
|
private MdsApiService mdsApiService; |
|
|
|
private LogisticsService logisticsService; |
|
|
|
private ShopService shopService; |
|
|
|
private MenuModel selectedMenuModel; |
|
|
|
private bool showShopChoosePanel; |
|
|
|
private bool showWB2RuntimeDownloadPanel; |
|
|
|
private double wb2DownloadProgress; |
|
|
|
|
|
|
|
private IList<string> managerDepartment; |
|
|
|
private WebView2Manager w2m; |
|
|
|
public GlobalContext GlobalContext { get; set; } |
|
|
|
public IList<MenuModel> MenuList { get; set; } |
|
|
|
|
|
|
@ -78,11 +80,19 @@ namespace BBWY.Client.ViewModels |
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region Methods
|
|
|
|
public MainViewModel(GlobalContext globalContext, MdsApiService mdsApiService, LogisticsService logisticsService, IHttpClientFactory httpClientFactory) |
|
|
|
{ |
|
|
|
public MainViewModel(GlobalContext globalContext, |
|
|
|
MdsApiService mdsApiService, |
|
|
|
LogisticsService logisticsService, |
|
|
|
ShopService shopService, |
|
|
|
IHttpClientFactory httpClientFactory, |
|
|
|
WebView2Manager w2m) |
|
|
|
{ |
|
|
|
this.w2m = w2m; |
|
|
|
this.managerDepartment = new List<string>() { "董事办", "财务部", "技术部" }; |
|
|
|
this.httpClientFactory = httpClientFactory; |
|
|
|
this.mdsApiService = mdsApiService; |
|
|
|
this.logisticsService = logisticsService; |
|
|
|
this.shopService = shopService; |
|
|
|
ClosingCommand = new RelayCommand<System.ComponentModel.CancelEventArgs>(Exit); |
|
|
|
//ChooseShopCommand = new RelayCommand<Shop>((s) => ChooseShop(s));
|
|
|
|
OpenSelectShopCommand = new RelayCommand(OpenSelectShop); |
|
|
@ -151,14 +161,7 @@ namespace BBWY.Client.ViewModels |
|
|
|
|
|
|
|
GlobalContext.User = mdsUserResponse.Data.Map<User>(); |
|
|
|
#if RELEASE
|
|
|
|
if (GlobalContext.User.TeamName == "财务部") |
|
|
|
{ |
|
|
|
App.Current.Dispatcher.Invoke(() => |
|
|
|
{ |
|
|
|
for (var i = 0; i < 3; i++) { MenuList.RemoveAt(0); } |
|
|
|
}); |
|
|
|
} |
|
|
|
else |
|
|
|
if (!managerDepartment.Contains(GlobalContext.User.TeamName)) //非管理账号,屏蔽财务端
|
|
|
|
{ |
|
|
|
App.Current.Dispatcher.Invoke(() => |
|
|
|
{ |
|
|
@ -167,22 +170,9 @@ namespace BBWY.Client.ViewModels |
|
|
|
} |
|
|
|
|
|
|
|
#endif
|
|
|
|
IList<Department> departmentList = null; |
|
|
|
|
|
|
|
//请求用户信息接口
|
|
|
|
//GlobalContext.User = new User()
|
|
|
|
//{
|
|
|
|
// Id = userId,
|
|
|
|
// Name = "ShanJ",
|
|
|
|
// Store = new Store()
|
|
|
|
// {
|
|
|
|
// Platform = Platform.京东,
|
|
|
|
// AppKey = "120EA9EC65AB017567D78CC1139EEEA5",
|
|
|
|
// AppSecret = "866a9877f5f24b03b537483b4defe75d",
|
|
|
|
// AppToken = "d8433fb2a4994484b5d9e5a5896a6dfdmyjj" //10388155
|
|
|
|
// }
|
|
|
|
//};
|
|
|
|
|
|
|
|
if (GlobalContext.User.TeamName != "财务部") |
|
|
|
if (!managerDepartment.Contains(GlobalContext.User.TeamName)) |
|
|
|
{ |
|
|
|
var shopListResponse = mdsApiService.GetShopsByUserTeam(GlobalContext.User.Id); |
|
|
|
if (!shopListResponse.Success) |
|
|
@ -194,26 +184,36 @@ namespace BBWY.Client.ViewModels |
|
|
|
{ |
|
|
|
ShowShopChoosePanel = false; |
|
|
|
ChooseShop(shopList[0], true); |
|
|
|
return; |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
ShowShopChoosePanel = true; |
|
|
|
IList<Department2> department2s = new List<Department2>(); |
|
|
|
departmentList = new List<Department>(); |
|
|
|
foreach (var shop in shopList) |
|
|
|
{ |
|
|
|
var department = department2s.FirstOrDefault(d => d.Id == shop.TeamId); |
|
|
|
var department = departmentList.FirstOrDefault(d => d.Id == shop.TeamId); |
|
|
|
if (department == null) |
|
|
|
{ |
|
|
|
department = new Department2() { Id = shop.TeamId, Name = shop.TeamName }; |
|
|
|
department2s.Add(department); |
|
|
|
department = new Department() { Id = shop.TeamId, Name = shop.TeamName }; |
|
|
|
departmentList.Add(department); |
|
|
|
} |
|
|
|
department.ShopList.Add(shop); |
|
|
|
} |
|
|
|
GlobalContext.User.DepartmentList = department2s; |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
var response = shopService.GetDepartmentList(); |
|
|
|
if (!response.Success) |
|
|
|
throw new Exception(response.Msg); |
|
|
|
departmentList = response.Data.Map<IList<Department>>(); |
|
|
|
} |
|
|
|
|
|
|
|
GlobalContext.User.DepartmentList = departmentList; |
|
|
|
App.Current.Dispatcher.Invoke(() => |
|
|
|
{ |
|
|
|
var selectShop = new SelectShop(department2s); |
|
|
|
var selectShop = new SelectShop(departmentList); |
|
|
|
if (selectShop.ShowDialog() == true) |
|
|
|
{ |
|
|
|
ChooseShop(selectShop.Shop, true); |
|
|
@ -223,15 +223,6 @@ namespace BBWY.Client.ViewModels |
|
|
|
Environment.Exit(Environment.ExitCode); |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
//App.Current.Dispatcher.Invoke(() =>
|
|
|
|
//{
|
|
|
|
// foreach (var s in shopList)
|
|
|
|
// ShopList.Add(s);
|
|
|
|
//});
|
|
|
|
//ShowShopChoosePanel = true;
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
catch (Exception ex) |
|
|
|
{ |
|
|
@ -256,6 +247,12 @@ namespace BBWY.Client.ViewModels |
|
|
|
vm.WareManager.Refresh(); |
|
|
|
if (vm.IsCreateWareStock) |
|
|
|
vm.WareStock.Refresh(); |
|
|
|
|
|
|
|
try |
|
|
|
{ |
|
|
|
w2m.Close(); |
|
|
|
} |
|
|
|
catch { } |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
@ -268,7 +265,7 @@ namespace BBWY.Client.ViewModels |
|
|
|
string.IsNullOrEmpty(shop.AppToken) || |
|
|
|
(shop.Platform == Platform.京东 && string.IsNullOrEmpty(shop.VenderType))) |
|
|
|
{ |
|
|
|
var error = $"{shop.Name} 店铺数据不完整"; |
|
|
|
var error = $"{shop.ShopName} 店铺数据不完整"; |
|
|
|
if (_throw) |
|
|
|
throw new Exception(error); |
|
|
|
else |
|
|
|