shanji 2 years ago
parent
commit
0269ec5016
  1. 1
      BBWY.Client/Models/APIModel/Response/ServiceOrder/ServiceOrderItemResponse.cs
  2. 33
      BBWY.Client/Models/ServiceOrder/ServiceOrder.cs
  3. 126
      BBWY.Client/ViewModels/ServiceOrder/ServiceOrderViewModel.cs
  4. 65
      BBWY.Client/Views/ServiceOrder/ServiceOrderList.xaml

1
BBWY.Client/Models/APIModel/Response/ServiceOrder/ServiceOrderItemResponse.cs

@ -5,6 +5,7 @@ namespace BBWY.Client.Models
{ {
public class ServiceOrderItemResponse public class ServiceOrderItemResponse
{ {
public long Id { get; set; } public long Id { get; set; }
/// <summary> /// <summary>

33
BBWY.Client/Models/ServiceOrder/ServiceOrder.cs

@ -1,6 +1,37 @@
namespace BBWY.Client.Models using System.Collections.Generic;
namespace BBWY.Client.Models
{ {
public class ServiceOrder : ServiceOrderItemResponse public class ServiceOrder : ServiceOrderItemResponse
{ {
public ServiceOrder()
{
ThumbnailImageList = new List<string>();
}
/// <summary>
/// 是否显示商品情况
/// </summary>
public bool IsShowProductInfo
{
get
{
return ProductAppearance != null || ProductFunction != null || ProductHealth != null || ProductPackage != null;
}
}
public IList<string> ThumbnailImageList { get; set; }
public void Init()
{
if (!string.IsNullOrEmpty(ImageName))
{
var imageNameArray = ImageName.Split(',', System.StringSplitOptions.RemoveEmptyEntries);
foreach (var imgItemName in imageNameArray)
{
ThumbnailImageList.Add($"https://qiyue-qiku.oss-cn-beijing.aliyuncs.com/tuihuo/{imgItemName}.jpg?x-oss-process=image/resize,m_lfit,w_35/quality,q_100");
}
}
}
} }
} }

126
BBWY.Client/ViewModels/ServiceOrder/ServiceOrderViewModel.cs

@ -1,12 +1,17 @@
using BBWY.Client.APIServices; using BBWY.Client.APIServices;
using BBWY.Client.Helpers;
using BBWY.Client.Models; using BBWY.Client.Models;
using BBWY.Common.Extensions; using BBWY.Common.Extensions;
using BBWY.Common.Http;
using BBWY.Common.Models; using BBWY.Common.Models;
using BBWY.Controls;
using GalaSoft.MvvmLight.Command; using GalaSoft.MvvmLight.Command;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System.IO;
using System.Linq; using System.Linq;
using System.Net.Http;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows; using System.Windows;
using System.Windows.Input; using System.Windows.Input;
@ -16,6 +21,7 @@ namespace BBWY.Client.ViewModels
public class ServiceOrderViewModel : BaseVM, IDenpendency public class ServiceOrderViewModel : BaseVM, IDenpendency
{ {
private ServiceOrderService serviceOrderService; private ServiceOrderService serviceOrderService;
private IHttpClientFactory httpClientFactory;
private bool isLoading; private bool isLoading;
private ServiceOrderState? serviceOrderState; private ServiceOrderState? serviceOrderState;
@ -47,6 +53,10 @@ namespace BBWY.Client.ViewModels
public ICommand SearchServiceOrderCommand { get; set; } public ICommand SearchServiceOrderCommand { get; set; }
public ICommand NavigateToDetailCommand { get; set; }
public ICommand PreviewImgCommand { get; set; }
public IList<ServiceOrder> ServiceOrderList { get; set; } public IList<ServiceOrder> ServiceOrderList { get; set; }
public long ServiceOrderCount { get => serviceOrderCount; set { Set(ref serviceOrderCount, value); } } public long ServiceOrderCount { get => serviceOrderCount; set { Set(ref serviceOrderCount, value); } }
@ -69,23 +79,27 @@ namespace BBWY.Client.ViewModels
public GlobalContext GlobalContext { get; set; } public GlobalContext GlobalContext { get; set; }
public ServiceOrderViewModel(ServiceOrderService serviceOrderService, GlobalContext globalContext) public ServiceOrderViewModel(ServiceOrderService serviceOrderService, GlobalContext globalContext, IHttpClientFactory httpClientFactory)
{ {
this.httpClientFactory = httpClientFactory;
this.serviceOrderService = serviceOrderService; this.serviceOrderService = serviceOrderService;
SetServiceOrderStateCommand = new RelayCommand<ServiceOrderState?>(SetServiceOrderState); SetServiceOrderStateCommand = new RelayCommand<ServiceOrderState?>(SetServiceOrderState);
SetReturnDirectionCommand = new RelayCommand<ReturnDirection?>(SetReturnDirection); SetReturnDirectionCommand = new RelayCommand<ReturnDirection?>(SetReturnDirection);
CopyTextCommand = new RelayCommand<string>(s => { try { Clipboard.SetText(s); } catch (Exception ex) { } }); CopyTextCommand = new RelayCommand<string>(s => { try { Clipboard.SetText(s); } catch (Exception ex) { } });
SetSearchDateCommand = new RelayCommand<int>(SetSearchDate); SetSearchDateCommand = new RelayCommand<int>(SetSearchDate);
SearchServiceOrderCommand = new RelayCommand(SearchServiceOrder); SearchServiceOrderCommand = new RelayCommand(InitQueryServiceOrder);
NavigateToDetailCommand = new RelayCommand<string>(NavigateToDetail);
OnPageIndexChangedCommand = new RelayCommand<PageArgs>(OnPageIndexChanged);
PreviewImgCommand = new RelayCommand<string>(PreviewImg);
ServiceOrderList = new ObservableCollection<ServiceOrder>() { new ServiceOrder(), new ServiceOrder(), new ServiceOrder() }; ServiceOrderList = new ObservableCollection<ServiceOrder>() { new ServiceOrder(), new ServiceOrder(), new ServiceOrder() };
PageSize = 10; PageSize = 10;
GlobalContext = globalContext; GlobalContext = globalContext;
EndDate = DateTime.Now.Date; EndDate = DateTime.Now.Date;
StartDate = DateTime.Now.Date.AddDays(-15); StartDate = DateTime.Now.Date.AddDays(-15);
SearchServiceOrder(); InitQueryServiceOrder();
} }
private void SearchServiceOrder() private void InitQueryServiceOrder()
{ {
PageIndex = 1; PageIndex = 1;
Task.Factory.StartNew(() => QueryServiceOrder(PageIndex)); Task.Factory.StartNew(() => QueryServiceOrder(PageIndex));
@ -95,31 +109,26 @@ namespace BBWY.Client.ViewModels
{ {
EndDate = d == 1 ? DateTime.Now.Date.AddDays(-1) : DateTime.Now; EndDate = d == 1 ? DateTime.Now.Date.AddDays(-1) : DateTime.Now;
StartDate = DateTime.Now.Date.AddDays(d * -1); StartDate = DateTime.Now.Date.AddDays(d * -1);
SearchServiceOrder(); InitQueryServiceOrder();
} }
private void SetServiceOrderState(ServiceOrderState? state) private void SetServiceOrderState(ServiceOrderState? state)
{ {
this.ServiceOrderState = state; this.ServiceOrderState = state;
//query //query
SearchServiceOrder(); InitQueryServiceOrder();
} }
private void SetReturnDirection(ReturnDirection? returnDirection) private void SetReturnDirection(ReturnDirection? returnDirection)
{ {
this.ReturnDirection = returnDirection; this.ReturnDirection = returnDirection;
//query //query
SearchServiceOrder(); InitQueryServiceOrder();
} }
private void QueryServiceOrder(int pageIndex) private void QueryServiceOrder(int pageIndex)
{ {
IsLoading = true; IsLoading = true;
App.Current.Dispatcher.Invoke(() =>
{
this.ServiceOrderList.Clear();
ServiceOrderCount = 0;
});
var response = serviceOrderService.GetList(OrderId, Sku, Spu, ServiceId, GlobalContext.User.Shop.ShopId.ToString(), ServiceOrderState, ReturnDirection, pageIndex, PageSize, StartDate, EndDate); var response = serviceOrderService.GetList(OrderId, Sku, Spu, ServiceId, GlobalContext.User.Shop.ShopId.ToString(), ServiceOrderState, ReturnDirection, pageIndex, PageSize, StartDate, EndDate);
if (!response.Success) if (!response.Success)
{ {
@ -130,24 +139,107 @@ namespace BBWY.Client.ViewModels
return; return;
}); });
} }
if (response.Data.Items == null || response.Data.Items.Count() == 0)
{
IsLoading = false;
return;
}
IsLoading = false; IsLoading = false;
ServiceOrderCount = response.Data.Count; ServiceOrderCount = response.Data.Count;
App.Current.Dispatcher.Invoke(() => ServiceOrderList.Clear());
if (response.Data.Items == null || response.Data.Items.Count() == 0)
return;
var list = response.Data.Items.Map<IList<ServiceOrder>>(); var list = response.Data.Items.Map<IList<ServiceOrder>>();
App.Current.Dispatcher.Invoke(() => App.Current.Dispatcher.Invoke(() =>
{ {
foreach (var s in list) foreach (var s in list)
{ {
#region Test
//转换ImageName //转换ImageName
if (int.Parse(s.ServiceId) % 2 == 0)
{
s.ProductPackage = ProductPackage.; s.ImageName = "20230317071208762563,8d58b491-7859-4187-9f43-4fd177a0f25f,b0df0763-9cf4-40ca-a1fc-57695e4b8d33";
}
s.Init();
#endregion
ServiceOrderList.Add(s); ServiceOrderList.Add(s);
} }
}); });
} }
private void NavigateToDetail(string serviceId)
{
var url = $"https://sh.shop.jd.com/afs/detail/waitReceive?afsApplyId=undefined&afsServiceId={serviceId}";
try
{
//System.Diagnostics.Process.Start("explorer.exe", url);
ShellExecuteHelper.ShellExecute(IntPtr.Zero, "open", url, string.Empty, string.Empty, ShellExecuteHelper.ShowCommands.SW_SHOWNORMAL);
}
catch (Exception ex)
{
Clipboard.SetText(url);
MessageBox.Show($"{ex.Message}\r\n调用浏览器失败,网页链接已复制到剪切板,请手动打开浏览器访问", "提示");
}
}
private void OnPageIndexChanged(PageArgs pageArgs)
{
Task.Factory.StartNew(() => QueryServiceOrder(pageArgs.PageIndex));
}
private void PreviewImg(string thumbnailImg)
{
var fullUrl = thumbnailImg.Substring(0, thumbnailImg.IndexOf("?"));
var fileName = fullUrl.Substring(fullUrl.LastIndexOf("/") + 1);
var localPath = Path.Combine(Path.GetTempPath(), fileName);
if (!File.Exists(localPath))
{
IsLoading = true;
var downloader = new HttpDownloader(httpClientFactory);
downloader.OnDownloadComplated += (s, e) =>
{
IsLoading = false;
if (e.Error != null)
{
App.Current.Dispatcher.Invoke(() => MessageBox.Show(e.Error.Message));
return;
}
CallWindowsPhoto(localPath);
};
Task.Factory.StartNew(() => downloader.DownloadFile(fullUrl, Path.GetTempPath(), fileName, null));
}
else
{
CallWindowsPhoto(localPath);
}
}
private void CallWindowsPhoto(string path)
{
//建立新的系统进程
try
{
System.Diagnostics.Process process = new System.Diagnostics.Process();
//设置图片的真实路径和文件名
process.StartInfo.FileName = path;
//设置进程运行参数,这里以最大化窗口方法显示图片。
process.StartInfo.Arguments = "rundl132.exe C://WINDOWS//system32//shimgvw.dll,ImageView_Fullscreen";
//此项为是否使用Shell执行程序,因系统默认为true,此项也可不设,但若设置必须为true
process.StartInfo.UseShellExecute = true;
//此处可以更改进程所打开窗体的显示样式,可以不设
process.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
process.Start();
process.Close();
}
catch (Exception ex)
{
App.Current.Dispatcher.Invoke(() => MessageBox.Show($"打开照片查看器失败 {ex.Message}"));
}
}
} }
} }

65
BBWY.Client/Views/ServiceOrder/ServiceOrderList.xaml

@ -9,7 +9,7 @@
xmlns:cmodel="clr-namespace:BBWY.Client.Models" xmlns:cmodel="clr-namespace:BBWY.Client.Models"
xmlns:sys="clr-namespace:System;assembly=mscorlib" xmlns:sys="clr-namespace:System;assembly=mscorlib"
mc:Ignorable="d" mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="2048" d:DesignHeight="450" d:DesignWidth="1920"
Title="ServiceOrderList" Title="ServiceOrderList"
DataContext="{Binding ServiceOrderList,Source={StaticResource Locator}}"> DataContext="{Binding ServiceOrderList,Source={StaticResource Locator}}">
<Page.Resources> <Page.Resources>
@ -61,9 +61,9 @@
<DatePicker SelectedDate="{Binding StartDate}" Width="133.5" Height="30" VerticalContentAlignment="Center" FocusVisualStyle="{x:Null}" Margin="5,0,0,0"/> <DatePicker SelectedDate="{Binding StartDate}" Width="133.5" Height="30" VerticalContentAlignment="Center" FocusVisualStyle="{x:Null}" Margin="5,0,0,0"/>
<DatePicker SelectedDate="{Binding EndDate}" Width="133.5" Height="30" VerticalContentAlignment="Center" FocusVisualStyle="{x:Null}" Margin="5,0,0,0"/> <DatePicker SelectedDate="{Binding EndDate}" Width="133.5" Height="30" VerticalContentAlignment="Center" FocusVisualStyle="{x:Null}" Margin="5,0,0,0"/>
<TextBlock Text="订单号" VerticalAlignment="Center" Margin="5,0,0,0"/> <TextBlock Text="订单号" VerticalAlignment="Center" Margin="5,0,0,0"/>
<c:BTextBox Width="150" Margin="5,0,0,0" Text="{Binding SearchOrderId}" WaterRemark="精确匹配"/> <c:BTextBox Width="150" Margin="5,0,0,0" Text="{Binding OrderId}" WaterRemark="精确匹配"/>
<TextBlock Text="SPU" VerticalAlignment="Center" Margin="5,0,0,0"/> <TextBlock Text="SPU" VerticalAlignment="Center" Margin="5,0,0,0"/>
<c:BTextBox Width="150" Margin="5,0,0,0" WaterRemark="精确匹配" Text="{Binding SearchProductId}"/> <c:BTextBox Width="150" Margin="5,0,0,0" WaterRemark="精确匹配" Text="{Binding ProductId}"/>
</StackPanel> </StackPanel>
<StackPanel Orientation="Horizontal" Grid.Row="2" Margin="0,0,0,5" Height="30"> <StackPanel Orientation="Horizontal" Grid.Row="2" Margin="0,0,0,5" Height="30">
<c:BButton Content="今天" Width="50" Height="25" Margin="5,0,0,0" <c:BButton Content="今天" Width="50" Height="25" Margin="5,0,0,0"
@ -85,9 +85,9 @@
Command="{Binding SetSearchDateCommand}" Command="{Binding SetSearchDateCommand}"
CommandParameter="{StaticResource d30}"/> CommandParameter="{StaticResource d30}"/>
<TextBlock Text="服务单" VerticalAlignment="Center" Margin="5,0,0,0"/> <TextBlock Text="服务单" VerticalAlignment="Center" Margin="5,0,0,0"/>
<c:BTextBox Width="150" Margin="5,0,0,0" Text="{Binding SearchServiceId}" WaterRemark="精确匹配"/> <c:BTextBox Width="150" Margin="5,0,0,0" Text="{Binding ServiceId}" WaterRemark="精确匹配"/>
<TextBlock Text="SKU" VerticalAlignment="Center" Margin="5,0,0,0"/> <TextBlock Text="SKU" VerticalAlignment="Center" Margin="5,0,0,0"/>
<c:BTextBox Width="150" Margin="5,0,0,0" Text="{Binding SearchSku}" WaterRemark="精确匹配"/> <c:BTextBox Width="150" Margin="5,0,0,0" Text="{Binding Sku}" WaterRemark="精确匹配"/>
<c:BButton Content="同步" Width="50" Margin="5,0,0,0" Command="{Binding SyncOrderCommand}" ToolTipService.InitialShowDelay="0" ToolTipService.ShowDuration="10000" <c:BButton Content="同步" Width="50" Margin="5,0,0,0" Command="{Binding SyncOrderCommand}" ToolTipService.InitialShowDelay="0" ToolTipService.ShowDuration="10000"
Visibility="Collapsed"> Visibility="Collapsed">
@ -224,7 +224,7 @@
VerticalAlignment="Center"/> VerticalAlignment="Center"/>
</Border> </Border>
<TextBlock Text="{Binding ApplyTime}" VerticalAlignment="Center" Margin="10,0,0,0"/> <TextBlock Text="{Binding ApplyTime,StringFormat=yyyy-MM-dd HH:mm:ss}" VerticalAlignment="Center" Margin="10,0,0,0"/>
<TextBlock VerticalAlignment="Center" Margin="10,0,0,0"> <TextBlock VerticalAlignment="Center" Margin="10,0,0,0">
<Run Text="服务单类型:"/> <Run Text="服务单类型:"/>
<Run Text="{Binding ServiceResult}" Foreground="{StaticResource Text.Pink}"/> <Run Text="{Binding ServiceResult}" Foreground="{StaticResource Text.Pink}"/>
@ -341,26 +341,57 @@
<RowDefinition/> <RowDefinition/>
</Grid.RowDefinitions> </Grid.RowDefinitions>
<TextBlock> <TextBlock
Visibility="{Binding IsShowProductInfo,Mode=OneWay,UpdateSourceTrigger=PropertyChanged,ConverterParameter=true:Visible:Collapsed,Converter={StaticResource objConverter}}">
<Run Text="商品状态:"/> <Run Text="商品状态:"/>
<Run Text="{Binding ProductHealth}" Foreground="{StaticResource Text.Pink}"/> <Run Text="{Binding ProductHealth,ConverterParameter=#null:未填:#source,Converter={StaticResource objConverter}}" Foreground="{StaticResource Text.Pink}"/>
</TextBlock> </TextBlock>
<TextBlock Grid.Column="1"> <TextBlock Grid.Column="1"
Visibility="{Binding IsShowProductInfo,Mode=OneWay,UpdateSourceTrigger=PropertyChanged,ConverterParameter=true:Visible:Collapsed,Converter={StaticResource objConverter}}">
<Run Text="商品功能:"/> <Run Text="商品功能:"/>
<Run Text="{Binding ProductFunction}" Foreground="{StaticResource Text.Pink}"/> <Run Text="{Binding ProductFunction,ConverterParameter=#null:未填:#source,Converter={StaticResource objConverter}}" Foreground="{StaticResource Text.Pink}"/>
</TextBlock> </TextBlock>
<TextBlock Grid.Row="1"> <TextBlock Grid.Row="1"
Visibility="{Binding IsShowProductInfo,Mode=OneWay,UpdateSourceTrigger=PropertyChanged,ConverterParameter=true:Visible:Collapsed,Converter={StaticResource objConverter}}">
<Run Text="商品外观:"/> <Run Text="商品外观:"/>
<Run Text="{Binding ProductAppearance}" Foreground="{StaticResource Text.Pink}"/> <Run Text="{Binding ProductAppearance,ConverterParameter=#null:未填:#source,Converter={StaticResource objConverter}}" Foreground="{StaticResource Text.Pink}"/>
</TextBlock> </TextBlock>
<TextBlock Grid.Row="1" Grid.Column="1"> <TextBlock Grid.Row="1" Grid.Column="1"
Visibility="{Binding IsShowProductInfo,Mode=OneWay,UpdateSourceTrigger=PropertyChanged,ConverterParameter=true:Visible:Collapsed,Converter={StaticResource objConverter}}">
<Run Text="商品包装:"/> <Run Text="商品包装:"/>
<Run Text="{Binding ProductPackage}" Foreground="{StaticResource Text.Pink}"/> <Run Text="{Binding ProductPackage,ConverterParameter=#null:未填:#source,Converter={StaticResource objConverter}}" Foreground="{StaticResource Text.Pink}"/>
</TextBlock> </TextBlock>
</Grid> </Grid>
<ListBox ItemsSource="{Binding ThumbnailImageList}"
ItemContainerStyle="{StaticResource NoBgListBoxItemStyle}"
Style="{StaticResource NoScrollViewListBoxStyle}"
Grid.Row="1">
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal"/>
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
<ListBox.ItemTemplate>
<DataTemplate>
<Grid Margin="5,0,0,0" Cursor="Hand">
<c:BAsyncImage UrlSource="{Binding }"
DecodePixelWidth="35"
Width="35">
<b:Interaction.Triggers>
<b:EventTrigger EventName="PreviewMouseLeftButtonDown">
<b:InvokeCommandAction PassEventArgsToCommand="True"
CommandParameter="{Binding }"
Command="{Binding DataContext.PreviewImgCommand,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type Page}}}"/>
</b:EventTrigger>
</b:Interaction.Triggers>
</c:BAsyncImage>
</Grid>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</Grid> </Grid>
<Border Grid.Column="3" Width="1" HorizontalAlignment="Right" Background="{StaticResource Border.Brush}"/> <Border Grid.Column="3" Width="1" HorizontalAlignment="Right" Background="{StaticResource Border.Brush}"/>
@ -410,7 +441,9 @@
<Border Grid.Column="6" Width="1" HorizontalAlignment="Right" Background="{StaticResource Border.Brush}"/> <Border Grid.Column="6" Width="1" HorizontalAlignment="Right" Background="{StaticResource Border.Brush}"/>
<StackPanel Orientation="Horizontal" Grid.Column="7" HorizontalAlignment="Center"> <StackPanel Orientation="Horizontal" Grid.Column="7" HorizontalAlignment="Center">
<c:BButton Style="{StaticResource LinkButton}" Content="查看详情"/> <c:BButton Style="{StaticResource LinkButton}" Content="查看详情"
Command="{Binding DataContext.NavigateToDetailCommand,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type ListBox}}}"
CommandParameter="{Binding ServiceId}"/>
</StackPanel> </StackPanel>
</Grid> </Grid>
</Grid> </Grid>
@ -429,6 +462,8 @@
</b:EventTrigger> </b:EventTrigger>
</b:Interaction.Triggers> </b:Interaction.Triggers>
</c:PageControl> </c:PageControl>
</Grid> </Grid>
</Grid> </Grid>

Loading…
Cancel
Save