修改工单流程页面,订单列表增加工单按钮
This commit is contained in:
1 parent
f9dcae4610
commit
10bb0803d9
44 files changed
+5920
-1291
No files matched your search
@@ -1,7 +1,10 @@
|
||||
using _29WxOrderWpf.ToolCtrls;
|
||||
using OrderSupportTicket.Models;
|
||||
using OrderSupportTicket.Services;
|
||||
using OrderSupportTicket.ViewModels;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Input;
|
||||
|
||||
namespace OrderSupportTicket.Views;
|
||||
|
||||
@@ -11,12 +14,14 @@ namespace OrderSupportTicket.Views;
|
||||
public partial class OrderSupportTicketView : UserControl
|
||||
{
|
||||
private bool _active;
|
||||
private Window _hostWindow;
|
||||
|
||||
public OrderSupportTicketView()
|
||||
: this(
|
||||
new TicketApiService(),
|
||||
new EventSourceTicketRealtimeService(),
|
||||
TicketClientOptions.FromApplicationSettings())
|
||||
CreateDefaultOptions(),
|
||||
ownsRealtime: true)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -24,37 +29,76 @@ public partial class OrderSupportTicketView : UserControl
|
||||
ITicketApiService api,
|
||||
ITicketRealtimeService realtime,
|
||||
TicketClientOptions options = null)
|
||||
: this(api, realtime, options, ownsRealtime: true)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建工单页。ownsRealtime 为 false 时复用宿主提供的共享 SSE 连接,
|
||||
/// 页面关闭不会停止该连接。
|
||||
/// </summary>
|
||||
public OrderSupportTicketView(
|
||||
ITicketApiService api,
|
||||
ITicketRealtimeService realtime,
|
||||
TicketClientOptions options,
|
||||
bool ownsRealtime)
|
||||
{
|
||||
InitializeComponent();
|
||||
options = new TicketClientOptions
|
||||
{
|
||||
UserName="18990991234",
|
||||
AppIds = ["wx316b1291351558aa", "wx7999743c3d64c05c"],
|
||||
Orders = [
|
||||
new TicketOrderOption
|
||||
{
|
||||
Amount=109m,
|
||||
AppId="wx316b1291351558aa",
|
||||
GoodsName="梵客隆收腹内裤女新款高腰无痕磨毛暖融收小肚子提臀塑身平角裤",
|
||||
OrderId="9000000000000000001",
|
||||
OrderedAt=new DateTime(2020, 1, 1),
|
||||
},
|
||||
new TicketOrderOption
|
||||
{
|
||||
Amount=109m,
|
||||
AppId="wx7999743c3d64c05c",
|
||||
GoodsName="洁柔抽纸粉Face家用实惠装批发纸巾大包面纸餐巾纸抽整箱可湿水纸",
|
||||
OrderId="9000000000000000002",
|
||||
OrderedAt=new DateTime(2020, 1, 1),
|
||||
}
|
||||
]
|
||||
};
|
||||
ViewModel = new OrderSupportTicketViewModel(api, realtime, options);
|
||||
ViewModel = new OrderSupportTicketViewModel(
|
||||
api,
|
||||
realtime,
|
||||
options ?? CreateDefaultOptions(),
|
||||
ownsRealtime);
|
||||
DataContext = ViewModel;
|
||||
Loaded += OnLoaded;
|
||||
Unloaded += OnUnloaded;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 当前联调使用的默认参数。正式接入时可由宿主替换为登录账号和店铺 APPID。
|
||||
/// </summary>
|
||||
public static TicketClientOptions CreateDefaultOptions(string fallbackUserName = null)
|
||||
{
|
||||
var configured = TicketClientOptions.FromApplicationSettings();
|
||||
var userName = !string.IsNullOrWhiteSpace(configured.UserName)
|
||||
? configured.UserName
|
||||
: (!string.IsNullOrWhiteSpace(fallbackUserName)
|
||||
? fallbackUserName.Trim()
|
||||
: "18990991234");
|
||||
var appIds = configured.AppIds != null && configured.AppIds.Count > 0
|
||||
? configured.AppIds
|
||||
: new List<string>
|
||||
{
|
||||
"wx316b1291351558aa",
|
||||
"wx7999743c3d64c05c"
|
||||
};
|
||||
|
||||
return new TicketClientOptions
|
||||
{
|
||||
UserName = userName,
|
||||
AppIds = appIds,
|
||||
Orders =
|
||||
[
|
||||
new TicketOrderOption
|
||||
{
|
||||
Amount = 109m,
|
||||
AppId = "wx316b1291351558aa",
|
||||
GoodsName = "梵客隆收腹内裤女新款高腰无痕磨毛暖融收小肚子提臀塑身平角裤",
|
||||
OrderId = "9000000000000000001",
|
||||
OrderedAt = new DateTime(2020, 1, 1),
|
||||
},
|
||||
new TicketOrderOption
|
||||
{
|
||||
Amount = 109m,
|
||||
AppId = "wx7999743c3d64c05c",
|
||||
GoodsName = "洁柔抽纸粉Face家用实惠装批发纸巾大包面纸餐巾纸抽整箱可湿水纸",
|
||||
OrderId = "9000000000000000002",
|
||||
OrderedAt = new DateTime(2020, 1, 1),
|
||||
}
|
||||
]
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 当前页面对应的工单 ViewModel。
|
||||
/// </summary>
|
||||
@@ -76,11 +120,58 @@ public partial class OrderSupportTicketView : UserControl
|
||||
ViewModel.OpenNewTicket(order);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 打开并定位到指定工单。
|
||||
/// </summary>
|
||||
public void OpenTicket(string appId, string wechatOrderId)
|
||||
{
|
||||
ViewModel.OpenTicket(appId, wechatOrderId);
|
||||
}
|
||||
|
||||
private void TicketSearchBox_GotFocus(object sender, RoutedEventArgs e)
|
||||
{
|
||||
ViewModel.CancelNewTicketDraft();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 点击订单号复制到剪贴板,并使用宿主窗口的 Toast 提示结果。
|
||||
/// </summary>
|
||||
private void CopyOrderId_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
if (sender is not FrameworkElement element)
|
||||
return;
|
||||
|
||||
var orderId = element.Tag as string;
|
||||
if (string.IsNullOrWhiteSpace(orderId)
|
||||
&& element.DataContext is WorkOrderSummaryViewModel ticket)
|
||||
{
|
||||
orderId = ticket.WechatOrderId;
|
||||
}
|
||||
if (string.IsNullOrWhiteSpace(orderId))
|
||||
return;
|
||||
|
||||
var window = Window.GetWindow(this) ?? _hostWindow;
|
||||
if (window == null)
|
||||
return;
|
||||
|
||||
try
|
||||
{
|
||||
Clipboard.SetText(orderId);
|
||||
ToastHelper.Show(window, "订单号已复制");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ToastHelper.Show(window, "复制失败:" + ex.Message, ToastType.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private async void OnLoaded(object sender, System.Windows.RoutedEventArgs e)
|
||||
{
|
||||
if (_active)
|
||||
return;
|
||||
_active = true;
|
||||
AttachHostWindow(Window.GetWindow(this));
|
||||
UpdateWindowActiveState();
|
||||
await ViewModel.InitializeAsync();
|
||||
}
|
||||
|
||||
@@ -89,6 +180,72 @@ public partial class OrderSupportTicketView : UserControl
|
||||
if (!_active)
|
||||
return;
|
||||
_active = false;
|
||||
ViewModel.IsWindowActive = false;
|
||||
DetachHostWindow();
|
||||
await ViewModel.DeactivateAsync();
|
||||
}
|
||||
|
||||
private void AttachHostWindow(Window window)
|
||||
{
|
||||
DetachHostWindow();
|
||||
_hostWindow = window;
|
||||
if (_hostWindow == null)
|
||||
return;
|
||||
|
||||
_hostWindow.Activated += OnHostWindowActivated;
|
||||
_hostWindow.Deactivated += OnHostWindowDeactivated;
|
||||
_hostWindow.IsVisibleChanged += OnHostWindowIsVisibleChanged;
|
||||
_hostWindow.StateChanged += OnHostWindowStateChanged;
|
||||
_hostWindow.Closed += OnHostWindowClosed;
|
||||
}
|
||||
|
||||
private void DetachHostWindow()
|
||||
{
|
||||
if (_hostWindow == null)
|
||||
return;
|
||||
|
||||
_hostWindow.Activated -= OnHostWindowActivated;
|
||||
_hostWindow.Deactivated -= OnHostWindowDeactivated;
|
||||
_hostWindow.IsVisibleChanged -= OnHostWindowIsVisibleChanged;
|
||||
_hostWindow.StateChanged -= OnHostWindowStateChanged;
|
||||
_hostWindow.Closed -= OnHostWindowClosed;
|
||||
_hostWindow = null;
|
||||
}
|
||||
|
||||
private void UpdateWindowActiveState()
|
||||
{
|
||||
var window = _hostWindow;
|
||||
ViewModel.IsWindowActive = window != null
|
||||
&& window.IsVisible
|
||||
&& window.IsActive
|
||||
&& window.WindowState != WindowState.Minimized;
|
||||
}
|
||||
|
||||
private void OnHostWindowActivated(object sender, EventArgs e)
|
||||
{
|
||||
UpdateWindowActiveState();
|
||||
}
|
||||
|
||||
private void OnHostWindowDeactivated(object sender, EventArgs e)
|
||||
{
|
||||
UpdateWindowActiveState();
|
||||
}
|
||||
|
||||
private void OnHostWindowIsVisibleChanged(
|
||||
object sender,
|
||||
DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
UpdateWindowActiveState();
|
||||
}
|
||||
|
||||
private void OnHostWindowStateChanged(object sender, EventArgs e)
|
||||
{
|
||||
UpdateWindowActiveState();
|
||||
}
|
||||
|
||||
private void OnHostWindowClosed(object sender, EventArgs e)
|
||||
{
|
||||
ViewModel.IsWindowActive = false;
|
||||
DetachHostWindow();
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user