Browse Source

客户端对接获取最新报价

updatebug
shanji 2 years ago
parent
commit
eb5a49934b
  1. 12
      BBWYB.Client/APIServices/PurchaseService.cs
  2. 37
      BBWYB.Client/ViewModels/Order/ChoosePurchaseSchemeViewModel.cs
  3. 12
      BBWYB.Client/Views/Order/ChoosePurchaseScheme.xaml
  4. 4
      BBWYB.Client/appsettings.json

12
BBWYB.Client/APIServices/PurchaseService.cs

@ -40,6 +40,18 @@ namespace BBWYB.Client.APIServices
HttpMethod.Post);
}
public ApiResponse<IList<PurchaseSchemeResponse>> RefreshPurchaseScheme(IList<long> schemeIdList)
{
return SendRequest<IList<PurchaseSchemeResponse>>(globalContext.BBWYApiHost,
"api/PurchaseScheme/RefreshPurchaseScheme",
new
{
schemeIdList
},
null,
HttpMethod.Post);
}
/// <summary>
/// 获取共有采购商
/// </summary>

37
BBWYB.Client/ViewModels/Order/ChoosePurchaseSchemeViewModel.cs

@ -3,6 +3,7 @@ using BBWYB.Client.Models;
using BBWYB.Client.Views.Order;
using BBWYB.Client.Views.Purchase;
using BBWYB.Common.Extensions;
using BBWYB.Common.Models;
using CommunityToolkit.Mvvm.Input;
using CommunityToolkit.Mvvm.Messaging;
using System.Collections.Generic;
@ -21,22 +22,31 @@ namespace BBWYB.Client.ViewModels
private Order order;
private bool freeChoice;
private bool isResponse = true;
private bool isLoading;
public IList<PurchaseSchemeSkuGroup> SkuGroup { get; set; }
public ICommand ConfirmCommand { get; set; }
public ICommand RefreshCommand { get; set; }
public bool FreeChoice { get => freeChoice; set { SetProperty(ref freeChoice, value); } }
public bool IsLoading { get => isLoading; set { SetProperty(ref isLoading, value); } }
public ChoosePurchaseSchemeViewModel(PurchaseService purchaseService, GlobalContext globalContext)
{
this.purchaseService = purchaseService;
this.globalContext = globalContext;
this.SkuGroup = new ObservableCollection<PurchaseSchemeSkuGroup>();
ConfirmCommand = new RelayCommand(Confirm);
RefreshCommand = new RelayCommand(Refresh);
}
protected override void Load()
{
IsLoading = true;
Task.Factory.StartNew(() => LoadScheme());
}
@ -49,6 +59,12 @@ namespace BBWYB.Client.ViewModels
{
var skuIdList = order.ItemList.Select(osku => osku.SkuId).ToList();
var response = purchaseService.GetPurchaseSchemeList(skuIdList, shopId: globalContext.User.Shop.ShopId);
LoadScheme(response);
}
private void LoadScheme(ApiResponse<IList<PurchaseSchemeResponse>> response)
{
IsLoading = false;
if (!response.Success)
{
App.Current.Dispatcher.Invoke(() => MessageBox.Show(response.Msg, "提示"));
@ -114,5 +130,26 @@ namespace BBWYB.Client.ViewModels
}
isResponse = true;
}
public override void Refresh()
{
if (SkuGroup.Count() == 0)
return;
IsLoading = true;
var schemeIdList = new List<long>();
foreach (var group in SkuGroup)
{
schemeIdList.AddRange(group.SchemeList.Select(s => s.Id));
group.SchemeList.Clear();
}
SkuGroup.Clear();
Task.Factory.StartNew(() => purchaseService.RefreshPurchaseScheme(schemeIdList)).ContinueWith(t =>
{
var response = t.Result;
LoadScheme(response);
});
}
}
}

12
BBWYB.Client/Views/Order/ChoosePurchaseScheme.xaml

@ -34,6 +34,8 @@
<TextBlock Text="选择采购商" Style="{StaticResource middleTextBlock}"/>
</Border>
<c:RoundWaitProgress Play="{Binding IsLoading}" Panel.ZIndex="999" Grid.Row="1" Grid.RowSpan="3"/>
<Border BorderBrush="{StaticResource Border.Brush}" BorderThickness="1,1,1,0"
Background="#F2F2F2"
Grid.Row="1">
@ -137,7 +139,7 @@
</ListBox.ItemTemplate>
</ListBox>
<CheckBox Grid.Row="3" HorizontalAlignment="Right" Margin="0,0,100,0" VerticalContentAlignment="Center" VerticalAlignment="Center"
<CheckBox Grid.Row="3" HorizontalAlignment="Left" Margin="5,0,0,0" VerticalContentAlignment="Center" VerticalAlignment="Center"
IsChecked="{Binding FreeChoice,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}">
<CheckBox.Content>
<StackPanel Orientation="Horizontal">
@ -152,8 +154,14 @@
</CheckBox.Content>
</CheckBox>
<c:BButton Grid.Row="3" HorizontalAlignment="Right" Margin="0,0,5,0" Content="确定" Width="80"
<StackPanel Grid.Row="3" HorizontalAlignment="Right" Margin="0,0,5,0" VerticalAlignment="Center" Orientation="Horizontal">
<c:BButton Grid.Row="3" HorizontalAlignment="Right" Content="获取最新报价" Width="100"
Command="{Binding RefreshCommand}"
Background="#1CC2A2"/>
<c:BButton Grid.Row="3" HorizontalAlignment="Right" Content="确定" Width="80"
Command="{Binding ConfirmCommand}"/>
</StackPanel>
<!--<DataGrid Grid.Row="1"
ItemsSource="{Binding PurchaserList}">

4
BBWYB.Client/appsettings.json

@ -1,6 +1,6 @@
{
"BBWYApiHost": "http://localhost:5000",
//"BBWYApiHost": "http://bbwyb.qiyue666.com",
//"BBWYApiHost": "http://localhost:5000",
"BBWYApiHost": "http://bbwyb.qiyue666.com",
"MDSApiHost": "http://mdsapi.qiyue666.com",
"BBWYCApiHost": "http://bbwytest.qiyue666.com",
"QKApiHost": "http://localhost:8080"

Loading…
Cancel
Save