工单 优化 ,增加图片

This commit is contained in:
chfei committed 2026-10-20 17:03:23 +08:00
1 parent bf5a70597c
commit cf2efbcb16
27 files changed
+3555 -1538

No files matched your search

@@ -0,0 +1,290 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<BooleanToVisibilityConverter x:Key="BoolToVisibility" />
<SolidColorBrush x:Key="BrandBrush" Color="#98638F" />
<SolidColorBrush x:Key="BrandSoftBrush" Color="#F3EAF2" />
<SolidColorBrush x:Key="LineBrush" Color="#DDE2E8" />
<SolidColorBrush x:Key="TextBrush" Color="#1F2933" />
<SolidColorBrush x:Key="SubTextBrush" Color="#6B7785" />
<SolidColorBrush x:Key="PriceBrush" Color="#C2410C" />
<SolidColorBrush x:Key="BackgroundBrush" Color="#EEF1F4" />
<SolidColorBrush x:Key="PanelBrush" Color="#FFFFFF" />
<SolidColorBrush x:Key="OtherBubbleBrush" Color="#F1F3F6" />
<SolidColorBrush x:Key="WaitingBrush" Color="#B45309" />
<SolidColorBrush x:Key="WaitingBackgroundBrush" Color="#FDF0DA" />
<SolidColorBrush x:Key="RepliedBrush" Color="#1D5FA8" />
<SolidColorBrush x:Key="RepliedBackgroundBrush" Color="#E2EDF9" />
<SolidColorBrush x:Key="DoneBrush" Color="#5B6673" />
<SolidColorBrush x:Key="DoneBackgroundBrush" Color="#E9ECF0" />
<Style x:Key="CopyableOrderIdStyle" TargetType="TextBlock">
<Setter Property="Background" Value="Transparent" />
<Setter Property="Cursor" Value="Hand" />
<Setter Property="FontWeight" Value="SemiBold" />
<Setter Property="Foreground" Value="{StaticResource TextBrush}" />
<Setter Property="ToolTip" Value="点击复制订单号" />
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Foreground" Value="{StaticResource BrandBrush}" />
<Setter Property="TextDecorations" Value="Underline" />
</Trigger>
</Style.Triggers>
</Style>
<Style x:Key="PrimaryButtonStyle" TargetType="Button">
<Setter Property="Foreground" Value="White" />
<Setter Property="Background" Value="{StaticResource BrandBrush}" />
<Setter Property="BorderBrush" Value="{StaticResource BrandBrush}" />
<Setter Property="BorderThickness" Value="1" />
<Setter Property="Padding" Value="14,6" />
<Setter Property="Cursor" Value="Hand" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<Border
x:Name="Root"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="4">
<ContentPresenter
Margin="{TemplateBinding Padding}"
HorizontalAlignment="Center"
VerticalAlignment="Center" />
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter TargetName="Root" Property="Opacity" Value="0.88" />
</Trigger>
<Trigger Property="IsPressed" Value="True">
<Setter TargetName="Root" Property="Opacity" Value="0.72" />
</Trigger>
<Trigger Property="IsEnabled" Value="False">
<Setter TargetName="Root" Property="Opacity" Value="0.45" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="GhostButtonStyle" TargetType="Button">
<Setter Property="Foreground" Value="{StaticResource BrandBrush}" />
<Setter Property="Background" Value="Transparent" />
<Setter Property="BorderBrush" Value="{StaticResource BrandBrush}" />
<Setter Property="BorderThickness" Value="1" />
<Setter Property="Padding" Value="12,5" />
<Setter Property="Cursor" Value="Hand" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<Border
x:Name="Root"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="4">
<ContentPresenter
Margin="{TemplateBinding Padding}"
HorizontalAlignment="Center"
VerticalAlignment="Center" />
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter TargetName="Root" Property="Background" Value="{StaticResource BrandSoftBrush}" />
</Trigger>
<Trigger Property="IsEnabled" Value="False">
<Setter TargetName="Root" Property="Opacity" Value="0.42" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="StatusTagStyle" TargetType="Border">
<Setter Property="Background" Value="{StaticResource DoneBackgroundBrush}" />
<Setter Property="CornerRadius" Value="10" />
<Setter Property="Padding" Value="8,2" />
<Style.Triggers>
<DataTrigger Binding="{Binding Status}" Value="waiting_reply">
<Setter Property="Background" Value="{StaticResource WaitingBackgroundBrush}" />
</DataTrigger>
<DataTrigger Binding="{Binding Status}" Value="replied">
<Setter Property="Background" Value="{StaticResource RepliedBackgroundBrush}" />
</DataTrigger>
</Style.Triggers>
</Style>
<Style x:Key="StatusTextStyle" TargetType="TextBlock">
<Setter Property="Foreground" Value="{StaticResource DoneBrush}" />
<Setter Property="FontSize" Value="12" />
<Style.Triggers>
<DataTrigger Binding="{Binding Status}" Value="waiting_reply">
<Setter Property="Foreground" Value="{StaticResource WaitingBrush}" />
</DataTrigger>
<DataTrigger Binding="{Binding Status}" Value="replied">
<Setter Property="Foreground" Value="{StaticResource RepliedBrush}" />
</DataTrigger>
</Style.Triggers>
</Style>
<Style x:Key="TicketListItemStyle" TargetType="ListBoxItem">
<Setter Property="Padding" Value="0" />
<Setter Property="Margin" Value="0" />
<Setter Property="HorizontalContentAlignment" Value="Stretch" />
<Setter Property="Background" Value="Transparent" />
<Setter Property="Cursor" Value="Hand" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ListBoxItem">
<Border
x:Name="Root"
Background="{TemplateBinding Background}"
BorderBrush="Transparent"
BorderThickness="3,0,0,0">
<ContentPresenter />
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter TargetName="Root" Property="Background" Value="{StaticResource BackgroundBrush}" />
</Trigger>
<Trigger Property="IsSelected" Value="True">
<Setter TargetName="Root" Property="Background" Value="{StaticResource BrandSoftBrush}" />
<Setter TargetName="Root" Property="BorderBrush" Value="{StaticResource BrandBrush}" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="ChatListItemStyle" TargetType="ListBoxItem">
<Setter Property="Padding" Value="0" />
<Setter Property="Margin" Value="0" />
<Setter Property="HorizontalContentAlignment" Value="Stretch" />
<Setter Property="Background" Value="Transparent" />
<Setter Property="Focusable" Value="False" />
<Setter Property="IsTabStop" Value="False" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ListBoxItem">
<ContentPresenter />
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="AttachmentRemoveButtonStyle" TargetType="Button">
<Setter Property="Width" Value="20" />
<Setter Property="Height" Value="20" />
<Setter Property="Padding" Value="0" />
<Setter Property="Foreground" Value="White" />
<Setter Property="Background" Value="#CC1F2933" />
<Setter Property="BorderThickness" Value="0" />
<Setter Property="Cursor" Value="Hand" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<Border
x:Name="Root"
Background="{TemplateBinding Background}"
CornerRadius="10">
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center" />
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter TargetName="Root" Property="Background" Value="#E61F2933" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="StatusTabItemStyle" TargetType="TabItem">
<Setter Property="Padding" Value="6,6" />
<Setter Property="FontSize" Value="12" />
<Setter Property="Foreground" Value="{StaticResource SubTextBrush}" />
<Setter Property="Cursor" Value="Hand" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="TabItem">
<Border
x:Name="Root"
Padding="{TemplateBinding Padding}"
Background="Transparent"
BorderBrush="{StaticResource BrandBrush}"
BorderThickness="0,0,0,2">
<ContentPresenter
HorizontalAlignment="Center"
VerticalAlignment="Center"
ContentSource="Header"
RecognizesAccessKey="True" />
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsSelected" Value="True">
<Setter Property="Foreground" Value="{StaticResource BrandBrush}" />
<Setter Property="FontWeight" Value="SemiBold" />
</Trigger>
<Trigger Property="IsSelected" Value="False">
<Setter TargetName="Root" Property="BorderBrush" Value="Transparent" />
</Trigger>
<Trigger Property="IsMouseOver" Value="True">
<Setter TargetName="Root" Property="Background" Value="{StaticResource BrandSoftBrush}" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="ChatScrollBarStyle" TargetType="ScrollBar">
<Setter Property="Width" Value="8" />
<Setter Property="MinWidth" Value="8" />
<Setter Property="MaxWidth" Value="8" />
<Setter Property="Margin" Value="0,4,2,4" />
<Setter Property="Opacity" Value="0.65" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ScrollBar">
<Grid Background="Transparent">
<Track
x:Name="PART_Track"
Focusable="False"
IsDirectionReversed="True">
<Track.DecreaseRepeatButton>
<RepeatButton
Command="ScrollBar.PageUpCommand"
Focusable="False"
Opacity="0" />
</Track.DecreaseRepeatButton>
<Track.Thumb>
<Thumb MinHeight="32">
<Thumb.Template>
<ControlTemplate TargetType="Thumb">
<Border
x:Name="ThumbBorder"
Margin="1,0"
Background="#AAB4C0"
CornerRadius="3" />
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter TargetName="ThumbBorder" Property="Background" Value="{StaticResource BrandBrush}" />
</Trigger>
<Trigger Property="IsDragging" Value="True">
<Setter TargetName="ThumbBorder" Property="Background" Value="#7F4F77" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Thumb.Template>
</Thumb>
</Track.Thumb>
<Track.IncreaseRepeatButton>
<RepeatButton
Command="ScrollBar.PageDownCommand"
Focusable="False"
Opacity="0" />
</Track.IncreaseRepeatButton>
</Track>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Opacity" Value="1" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>
File diff suppressed because it is too large. Load diff
@@ -1,234 +1,105 @@
using _29WxOrderWpf.ToolCtrls;
using OrderSupportTicket.Models;
using OrderSupportTicket.Services;
using OrderSupportTicket.ViewModels;
using System.Runtime.InteropServices;
using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
namespace OrderSupportTicket.Views;
/// <summary>
/// 工单对话页面。页面生命周期只负责激活/停用 ViewModel,业务交互均在 ViewModel 中。
/// 工单页面外壳,只负责组合子视图以及管理页面生命周期。
/// </summary>
public partial class OrderSupportTicketView : UserControl
{
private bool _active;
private Window _hostWindow;
private bool _active;
private Window _hostWindow;
public OrderSupportTicketView()
: this(new TicketService(), CreateDefaultOptions())
{
}
public OrderSupportTicketView() : this(new TicketService(), CreateDefaultOptions()) { }
/// <summary>
/// 使用工单业务服务创建工单页。
/// </summary>
public OrderSupportTicketView(
TicketService ticketService,
TicketClientOptions options = null)
{
InitializeComponent();
ViewModel = new OrderSupportTicketViewModel(
ticketService,
options ?? CreateDefaultOptions());
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>
public OrderSupportTicketViewModel ViewModel { get; }
/// <summary>
/// 宿主可在页面加载前注入账号、APPID 与本地订单数据。
/// </summary>
public void Configure(TicketClientOptions options)
{
ViewModel.Configure(options);
}
/// <summary>
/// 从订单页直接打开新工单草稿。
/// </summary>
public void OpenNewTicket(TicketOrderOption order)
{
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;
if (ClipboardHelper.TrySetText(orderId))
{
ToastHelper.Show(window, "订单号已复制");
}
else
{
ToastHelper.Show(window, "复制失败");
}
public OrderSupportTicketView(TicketService ticketService, TicketClientOptions options = null)
{
InitializeComponent();
ViewModel = new OrderSupportTicketViewModel(ticketService, options ?? CreateDefaultOptions());
DataContext = ViewModel;
Loaded += OnLoaded;
Unloaded += OnUnloaded;
}
private async void OnLoaded(object sender, System.Windows.RoutedEventArgs e)
{
if (_active)
return;
_active = true;
AttachHostWindow(Window.GetWindow(this));
UpdateWindowActiveState();
await ViewModel.InitializeAsync();
}
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" };
private async void OnUnloaded(object sender, System.Windows.RoutedEventArgs e)
{
if (!_active)
return;
_active = false;
ViewModel.IsWindowActive = false;
DetachHostWindow();
await ViewModel.DeactivateAsync();
}
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) }
]
};
}
private void AttachHostWindow(Window window)
{
DetachHostWindow();
_hostWindow = window;
if (_hostWindow == null)
return;
public OrderSupportTicketViewModel ViewModel { get; }
public void Configure(TicketClientOptions options) => ViewModel.Configure(options);
public void OpenNewTicket(TicketOrderOption order) => ViewModel.OpenNewTicket(order);
public void OpenTicket(string appId, string wechatOrderId) => ViewModel.OpenTicket(appId, wechatOrderId);
_hostWindow.Activated += OnHostWindowActivated;
_hostWindow.Deactivated += OnHostWindowDeactivated;
_hostWindow.IsVisibleChanged += OnHostWindowIsVisibleChanged;
_hostWindow.StateChanged += OnHostWindowStateChanged;
_hostWindow.Closed += OnHostWindowClosed;
}
private async void OnLoaded(object sender, RoutedEventArgs e)
{
if (_active) return;
_active = true;
AttachHostWindow(Window.GetWindow(this));
UpdateWindowActiveState();
await ViewModel.InitializeAsync();
}
private void DetachHostWindow()
{
if (_hostWindow == null)
return;
private async void OnUnloaded(object sender, RoutedEventArgs e)
{
if (!_active) return;
_active = false;
ViewModel.IsWindowActive = false;
DetachHostWindow();
await ViewModel.DeactivateAsync();
}
_hostWindow.Activated -= OnHostWindowActivated;
_hostWindow.Deactivated -= OnHostWindowDeactivated;
_hostWindow.IsVisibleChanged -= OnHostWindowIsVisibleChanged;
_hostWindow.StateChanged -= OnHostWindowStateChanged;
_hostWindow.Closed -= OnHostWindowClosed;
_hostWindow = null;
}
private void AttachHostWindow(Window window)
{
DetachHostWindow();
_hostWindow = window;
if (_hostWindow == null) return;
_hostWindow.Activated += OnHostWindowStateChanged;
_hostWindow.Deactivated += OnHostWindowStateChanged;
_hostWindow.IsVisibleChanged += OnHostWindowIsVisibleChanged;
_hostWindow.StateChanged += OnHostWindowStateChanged;
_hostWindow.Closed += OnHostWindowClosed;
}
private void UpdateWindowActiveState()
{
var window = _hostWindow;
ViewModel.IsWindowActive = window != null
&& window.IsVisible
&& window.IsActive
&& window.WindowState != WindowState.Minimized;
}
private void DetachHostWindow()
{
if (_hostWindow == null) return;
_hostWindow.Activated -= OnHostWindowStateChanged;
_hostWindow.Deactivated -= OnHostWindowStateChanged;
_hostWindow.IsVisibleChanged -= OnHostWindowIsVisibleChanged;
_hostWindow.StateChanged -= OnHostWindowStateChanged;
_hostWindow.Closed -= OnHostWindowClosed;
_hostWindow = null;
}
private void OnHostWindowActivated(object sender, EventArgs e)
{
UpdateWindowActiveState();
}
private void UpdateWindowActiveState()
{
ViewModel.IsWindowActive = _hostWindow != null && _hostWindow.IsVisible && _hostWindow.IsActive && _hostWindow.WindowState != WindowState.Minimized;
}
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();
}
private void OnHostWindowStateChanged(object sender, EventArgs e) => UpdateWindowActiveState();
private void OnHostWindowIsVisibleChanged(object sender, DependencyPropertyChangedEventArgs e) => UpdateWindowActiveState();
private void OnHostWindowClosed(object sender, EventArgs e) { ViewModel.IsWindowActive = false; DetachHostWindow(); }
}
@@ -0,0 +1,197 @@
<UserControl
x:Class="OrderSupportTicket.Views.TicketComposerView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:behaviors="clr-namespace:OrderSupportTicket.Behaviors"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:vm="clr-namespace:OrderSupportTicket.ViewModels"
xmlns:wpf="WPFCommon">
<UserControl.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="OrderSupportTicketStyles.xaml" />
</ResourceDictionary.MergedDictionaries>
<wpf:CommandProxy x:Key="AddImagesCommand" Command="{Binding AddImagesCommand}" />
</ResourceDictionary>
</UserControl.Resources>
<Grid>
<Border
Padding="18,12"
BorderBrush="#DDE2E8"
BorderThickness="0,1,0,0"
Visibility="{Binding IsChatVisible, Converter={StaticResource BoolToVisibility}}">
<Border
Padding="12,10"
Background="White"
BorderBrush="#DDE2E8"
BorderThickness="1"
CornerRadius="8">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<ItemsControl
Margin="0,0,0,8"
ItemsSource="{Binding PendingAttachments}"
Visibility="{Binding HasPendingAttachments, Converter={StaticResource BoolToVisibility}}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel />
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate DataType="{x:Type vm:PendingAttachmentViewModel}">
<Grid
Width="76"
Height="76"
Margin="0,0,8,4"
ToolTip="{Binding FileName}">
<Border
Background="#F1F3F6"
BorderBrush="#DDE2E8"
BorderThickness="1"
ClipToBounds="True"
CornerRadius="5">
<Grid>
<Image Source="{Binding Preview}" Stretch="UniformToFill" />
</Grid>
</Border>
<Button
Margin="0,-6,-6,0"
HorizontalAlignment="Right"
VerticalAlignment="Top"
Command="{Binding DataContext.RemovePendingAttachmentCommand, RelativeSource={RelativeSource AncestorType={x:Type UserControl}}}"
CommandParameter="{Binding}"
Content="×"
Style="{StaticResource AttachmentRemoveButtonStyle}" />
</Grid>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
<TextBox
Grid.Row="1"
MinHeight="64"
MaxHeight="110"
AcceptsReturn="True"
Background="Transparent"
BorderThickness="0"
MaxLength="4000"
PreviewKeyDown="ChatTextBox_PreviewKeyDown"
Text="{Binding ChatText, UpdateSourceTrigger=PropertyChanged}"
TextWrapping="Wrap"
ToolTip="{Binding ComposerPlaceholder}"
VerticalScrollBarVisibility="Auto">
<TextBox.InputBindings>
<KeyBinding
Key="Enter"
Command="{Binding SendMessageCommand}"
Modifiers="Control" />
</TextBox.InputBindings>
</TextBox>
<Grid Grid.Row="2" Margin="0,8,0,0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<StackPanel Orientation="Horizontal">
<Button
Height="28"
Padding="9,0"
Command="{Binding Source={StaticResource AddImagesCommand}}"
CommandParameter="{Binding RelativeSource={RelativeSource AncestorType={x:Type UserControl}}}"
Content="图片"
Style="{StaticResource GhostButtonStyle}" />
<TextBlock
Margin="8,0,0,0"
VerticalAlignment="Center"
FontSize="12"
Foreground="#6B7785"
Text="{Binding AttachmentCountText}" />
<TextBlock
Margin="12,0,0,0"
VerticalAlignment="Center"
FontSize="12"
Foreground="#6B7785"
Text="Ctrl+Enter 发送" />
</StackPanel>
<StackPanel Grid.Column="1" Orientation="Horizontal">
<TextBlock
Margin="0,0,10,0"
VerticalAlignment="Center"
FontSize="12"
Foreground="#6B7785"
Text="{Binding ChatCharacterCountText}" />
<Button
Width="72"
Height="32"
Command="{Binding SendMessageCommand}"
Content="发送"
Style="{StaticResource PrimaryButtonStyle}" />
</StackPanel>
</Grid>
</Grid>
</Border>
</Border>
<Border
Padding="18,12"
BorderBrush="#DDE2E8"
BorderThickness="0,1,0,0"
Visibility="{Binding IsDraftVisible, Converter={StaticResource BoolToVisibility}}">
<Border
Padding="12,10"
Background="White"
BorderBrush="#DDE2E8"
BorderThickness="1"
CornerRadius="8">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<TextBox
MinHeight="64"
MaxHeight="110"
AcceptsReturn="True"
Background="Transparent"
BorderThickness="0"
MaxLength="2000"
Text="{Binding DraftText, UpdateSourceTrigger=PropertyChanged}"
TextWrapping="Wrap"
ToolTip="请描述您遇到的问题"
VerticalScrollBarVisibility="Auto">
<TextBox.InputBindings>
<KeyBinding
Key="Enter"
Command="{Binding CreateTicketCommand}"
Modifiers="Control" />
</TextBox.InputBindings>
</TextBox>
<Grid Grid.Row="1" Margin="0,8,0,0">
<TextBlock
VerticalAlignment="Center"
FontSize="12"
Foreground="#6B7785"
Text="Ctrl+Enter 提交" />
<TextBlock
Margin="0,0,96,0"
HorizontalAlignment="Right"
VerticalAlignment="Center"
FontSize="12"
Foreground="#6B7785"
Text="{Binding DraftCharacterCountText}" />
<Button
Width="86"
Height="32"
HorizontalAlignment="Right"
Command="{Binding CreateTicketCommand}"
Content="提交工单"
Style="{StaticResource PrimaryButtonStyle}" />
</Grid>
</Grid>
</Border>
</Border>
</Grid>
</UserControl>
@@ -0,0 +1,29 @@
using OrderSupportTicket.ViewModels;
using System.Linq;
using System.Runtime.InteropServices;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media.Imaging;
namespace OrderSupportTicket.Views;
public partial class TicketComposerView : UserControl
{
public TicketComposerView() => InitializeComponent();
private void ChatTextBox_PreviewKeyDown(object sender, KeyEventArgs e)
{
var isPaste = (e.Key == Key.V && Keyboard.Modifiers == ModifierKeys.Control) || (e.Key == Key.Insert && Keyboard.Modifiers == ModifierKeys.Shift);
if (!isPaste || DataContext is not OrderSupportTicketViewModel viewModel) return;
IDataObject data;
try { data = Clipboard.GetDataObject(); } catch (ExternalException) { return; }
if (data == null) return;
if (data.GetDataPresent(DataFormats.Bitmap) && data.GetData(DataFormats.Bitmap) is BitmapSource bitmap) { viewModel.AddPendingImage(bitmap); e.Handled = true; return; }
if (!data.GetDataPresent(DataFormats.FileDrop) || data.GetData(DataFormats.FileDrop) is not string[] files) return;
var images = files.Where(path => PendingAttachmentViewModel.TryGetMimeType(System.IO.Path.GetExtension(path), out _)).ToArray();
if (images.Length == 0) return;
viewModel.AddPendingImages(images);
e.Handled = true;
}
}
@@ -0,0 +1,272 @@
<UserControl
x:Class="OrderSupportTicket.Views.TicketConversationView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:behaviors="clr-namespace:OrderSupportTicket.Behaviors"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:vm="clr-namespace:OrderSupportTicket.ViewModels"
xmlns:wpf="WPFCommon"
d:Background="White"
mc:Ignorable="d">
<UserControl.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="OrderSupportTicketStyles.xaml" />
</ResourceDictionary.MergedDictionaries>
<wpf:CommandProxy x:Key="ShowImageCommand" Command="{Binding ShowImageWindowCommand}" />
</ResourceDictionary>
</UserControl.Resources>
<Grid>
<Grid d:Visibility="Visible" Visibility="{Binding IsChatVisible, Converter={StaticResource BoolToVisibility}}">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Border
Padding="18,11"
BorderBrush="#DDE2E8"
BorderThickness="0,0,0,1">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<StackPanel>
<StackPanel Orientation="Horizontal">
<TextBlock
FontWeight="SemiBold"
MouseLeftButtonUp="CopyOrderId_MouseLeftButtonUp"
Style="{StaticResource CopyableOrderIdStyle}"
Tag="{Binding SelectedTicket.WechatOrderId}"
Text="{Binding SelectedTicket.WechatOrderId}" />
<Border
Margin="9,0,0,0"
DataContext="{Binding SelectedTicket}"
Style="{StaticResource StatusTagStyle}">
<TextBlock Style="{StaticResource StatusTextStyle}" Text="{Binding StatusText}" />
</Border>
</StackPanel>
<TextBlock
Margin="0,3,0,0"
FontSize="13"
FontWeight="SemiBold"
Text="{Binding SelectedTicket.ProductNameText}"
TextTrimming="CharacterEllipsis" />
<TextBlock
Margin="0,2,0,0"
FontSize="12"
Foreground="#6B7785"
Text="{Binding SelectedTicket.ShopName, StringFormat=店铺 {0}}" />
</StackPanel>
<Button
Grid.Column="1"
Padding="12,5"
Background="Transparent"
BorderBrush="#98638F"
Command="{Binding LoadEarlierMessagesCommand}"
Content="加载更早留言">
<Button.Style>
<Style BasedOn="{StaticResource GhostButtonStyle}" TargetType="Button">
<Style.Triggers>
<DataTrigger Binding="{Binding HasMoreMessages}" Value="False">
<Setter Property="Visibility" Value="Collapsed" />
</DataTrigger>
</Style.Triggers>
</Style>
</Button.Style>
</Button>
</Grid>
</Border>
<Grid Grid.Row="1">
<ListBox
Margin="18,10"
behaviors:ListBoxInteractionBehavior.ScrollVersion="{Binding MessageScrollVersion}"
d:ItemsSource="{d:SampleData ItemCount=10}"
Background="Transparent"
BorderThickness="0"
ItemContainerStyle="{StaticResource ChatListItemStyle}"
ItemsSource="{Binding Messages}"
ScrollViewer.HorizontalScrollBarVisibility="Disabled"
ScrollViewer.VerticalScrollBarVisibility="Auto"
VirtualizingPanel.ScrollUnit="Pixel">
<ListBox.Resources>
<Style BasedOn="{StaticResource ChatScrollBarStyle}" TargetType="ScrollBar" />
</ListBox.Resources>
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<VirtualizingStackPanel />
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
<ListBox.ItemTemplate>
<DataTemplate DataType="{x:Type vm:ChatMessageViewModel}">
<Grid Margin="0,5">
<StackPanel
x:Name="BubbleColumn"
MaxWidth="560"
HorizontalAlignment="Left">
<TextBlock
x:Name="Sender"
Margin="1,0,0,3"
FontSize="12"
Foreground="#6B7785"><Run Text="{Binding SenderDisplayName, Mode=OneWay}" /><Run Text=" " /><Run Text="{Binding CreatedAtText, Mode=OneWay}" /></TextBlock>
<Border
x:Name="Bubble"
Padding="13,9"
Background="#F1F3F6"
CornerRadius="8,8,8,2">
<StackPanel>
<TextBlock
x:Name="MessageText"
Foreground="#1F2933"
LineHeight="22"
Text="{Binding Content}"
TextWrapping="Wrap"
Visibility="{Binding HasText, Converter={StaticResource BoolToVisibility}}" />
<ItemsControl
Margin="0,6,0,0"
d:ItemsSource="{d:SampleData ItemCount=1}"
ItemsSource="{Binding Attachments}"
Visibility="{Binding HasAttachments, Converter={StaticResource BoolToVisibility}}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel />
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate DataType="{x:Type vm:ChatAttachmentViewModel}">
<Border
Margin="0,0,6,4"
Background="#26000000"
CornerRadius="5"
Cursor="Hand"
ToolTip="{Binding ToolTipText}">
<Border.InputBindings>
<MouseBinding
Command="{Binding Source={StaticResource ShowImageCommand}}"
CommandParameter="{Binding}"
MouseAction="LeftClick" />
</Border.InputBindings>
<Grid Width="150" Height="150">
<Image Source="{Binding Image}" Stretch="Uniform" />
<TextBlock
HorizontalAlignment="Center"
VerticalAlignment="Center"
FontSize="50"
Text="{StaticResource txt-image}">
<TextBlock.Style>
<Style BasedOn="{StaticResource TextBlockIcon}" TargetType="TextBlock">
<Setter Property="Foreground" Value="#5B6673" />
<Setter Property="Visibility" Value="Visible" />
<Style.Triggers>
<DataTrigger Binding="{Binding DataContext.IsCustomer, RelativeSource={RelativeSource AncestorType={x:Type ListBoxItem}}}" Value="True">
<Setter Property="Foreground" Value="White" />
</DataTrigger>
<DataTrigger Binding="{Binding IsLoadFailed}" Value="True">
<Setter Property="Text" Value="{StaticResource txt-dismiss_square}" />
</DataTrigger>
<DataTrigger Binding="{Binding HasImage}" Value="True">
<Setter Property="Visibility" Value="Collapsed" />
</DataTrigger>
</Style.Triggers>
</Style>
</TextBlock.Style>
</TextBlock>
</Grid>
</Border>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</StackPanel>
</Border>
</StackPanel>
</Grid>
<DataTemplate.Triggers>
<DataTrigger Binding="{Binding IsCustomer}" Value="True">
<Setter TargetName="BubbleColumn" Property="HorizontalAlignment" Value="Right" />
<Setter TargetName="Bubble" Property="Background" Value="#98638F" />
<Setter TargetName="MessageText" Property="Foreground" Value="White" />
<Setter TargetName="Sender" Property="HorizontalAlignment" Value="Right" />
</DataTrigger>
<DataTrigger Binding="{Binding IsRecalled}" Value="True">
<Setter TargetName="Bubble" Property="Opacity" Value="0.62" />
</DataTrigger>
</DataTemplate.Triggers>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
<TextBlock
HorizontalAlignment="Center"
VerticalAlignment="Center"
Foreground="#6B7785"
Text="暂无公开留言">
<TextBlock.Style>
<Style TargetType="TextBlock">
<Setter Property="Visibility" Value="Collapsed" />
<Style.Triggers>
<DataTrigger Binding="{Binding Messages.Count}" Value="0">
<Setter Property="Visibility" Value="Visible" />
</DataTrigger>
</Style.Triggers>
</Style>
</TextBlock.Style>
</TextBlock>
</Grid>
</Grid>
<Grid d:Visibility="Hidden" Visibility="{Binding IsDraftVisible, Converter={StaticResource BoolToVisibility}}">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Border
Padding="18,11"
BorderBrush="#DDE2E8"
BorderThickness="0,0,0,1">
<StackPanel>
<TextBlock FontWeight="SemiBold" Text="新建工单" />
<TextBlock
Margin="0,2,0,0"
FontSize="12"
Foreground="#6B7785"
Text="提交后进入等待客服回复;已完结订单再次提交会重开原工单。" />
</StackPanel>
</Border>
<Border
Grid.Row="1"
Margin="18"
Padding="14,12"
VerticalAlignment="Top"
Background="#FAFBFC"
BorderBrush="#DDE2E8"
BorderThickness="1"
CornerRadius="6">
<StackPanel>
<TextBlock Foreground="#6B7785" Text="关联订单" />
<TextBlock
Margin="0,4,0,0"
FontWeight="SemiBold"
Text="{Binding SelectedOrderText}"
TextWrapping="Wrap" />
<TextBlock
Margin="0,4,0,0"
FontSize="12"
Foreground="#6B7785"
Text="{Binding SelectedOrderDescription}"
TextWrapping="Wrap" />
</StackPanel>
</Border>
</Grid>
<StackPanel
HorizontalAlignment="Center"
VerticalAlignment="Center"
d:Visibility="Hidden"
Visibility="{Binding IsEmptyVisible, Converter={StaticResource BoolToVisibility}}">
<TextBlock Foreground="#6B7785" Text="在左侧选择工单查看对话" />
<TextBlock
Margin="0,6,0,0"
FontSize="12"
Foreground="#6B7785"
Text="实时通知已订阅当前拍单账号下的全部店铺" />
</StackPanel>
</Grid>
</UserControl>
@@ -0,0 +1,18 @@
using _29WxOrderWpf.ToolCtrls;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using Work._29Tools.Forms.ToolForms;
namespace OrderSupportTicket.Views;
public partial class TicketConversationView : UserControl
{
public TicketConversationView() => InitializeComponent();
private void CopyOrderId_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
{
if (sender is not FrameworkElement element || element.Tag is not string orderId || string.IsNullOrWhiteSpace(orderId)) return;
var window = Window.GetWindow(this);
if (window != null) ToastHelper.Show(window, ClipboardHelper.TrySetText(orderId) ? "订单号已复制" : "复制失败");
}
}
@@ -0,0 +1,289 @@
<UserControl
x:Class="OrderSupportTicket.Views.TicketSidebarView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:behaviors="clr-namespace:OrderSupportTicket.Behaviors"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:models="clr-namespace:OrderSupportTicket.Models"
xmlns:vm="clr-namespace:OrderSupportTicket.ViewModels"
d:Background="White"
mc:Ignorable="d">
<UserControl.Resources>
<ResourceDictionary Source="OrderSupportTicketStyles.xaml" />
</UserControl.Resources>
<Border BorderBrush="#DDE2E8" BorderThickness="0,0,1,0">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="40" />
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<StackPanel
Margin="14,0"
VerticalAlignment="Center"
Orientation="Horizontal">
<TextBlock
FontSize="15"
FontWeight="SemiBold"
Text="历史工单" />
<Border
Margin="8,0,0,0"
Padding="7,2"
Background="#B3261E"
CornerRadius="9"
Visibility="{Binding HasNewData, Converter={StaticResource BoolToVisibility}}">
<TextBlock
FontSize="11"
Foreground="White"
Text="{Binding NewDataText}" />
</Border>
</StackPanel>
<Grid Grid.Row="1">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Grid Margin="11,8,14,4">
<TextBox
Padding="8,5"
Background="#FAFBFC"
BorderBrush="#DDE2E8"
GotFocus="TicketSearchBox_GotFocus"
Text="{Binding TicketSearchText, UpdateSourceTrigger=PropertyChanged}" />
<TextBlock
Margin="9,0"
VerticalAlignment="Center"
Foreground="#6B7785"
IsHitTestVisible="False"
Text="搜索订单号、商品、店铺或状态">
<TextBlock.Style>
<Style TargetType="TextBlock">
<Setter Property="Visibility" Value="Collapsed" />
<Style.Triggers>
<DataTrigger Binding="{Binding TicketSearchText}" Value="">
<Setter Property="Visibility" Value="Visible" />
</DataTrigger>
</Style.Triggers>
</Style>
</TextBlock.Style>
</TextBlock>
</Grid>
<TabControl
Grid.Row="1"
Margin="11,0,14,4"
Background="Transparent"
BorderThickness="0"
ItemContainerStyle="{StaticResource StatusTabItemStyle}"
SelectedIndex="{Binding SelectedTicketStatusIndex}">
<TabItem Header="全部" />
<TabItem Header="待客服回复" />
<TabItem Header="客服已回复" />
<TabItem Header="已完结" />
</TabControl>
<Border
Grid.Row="2"
Padding="11,10"
Background="#F3EAF2"
BorderBrush="#98638F"
BorderThickness="3,1,0,1"
Visibility="{Binding IsDraftVisible, Converter={StaticResource BoolToVisibility}}">
<StackPanel>
<TextBlock FontWeight="SemiBold" Text="新工单(未提交)" />
<TextBlock
Margin="0,5,0,0"
FontSize="12"
MouseLeftButtonUp="CopyOrderId_MouseLeftButtonUp"
Style="{StaticResource CopyableOrderIdStyle}"
Tag="{Binding SelectedOrder.OrderId}"
Text="{Binding SelectedOrder.OrderId, StringFormat=订单 {0}}" />
<TextBlock
Margin="0,4,0,0"
FontSize="12"
Foreground="#6B7785"
Text="请在右侧描述问题" />
</StackPanel>
</Border>
<ListBox
Grid.Row="3"
behaviors:ListBoxInteractionBehavior.SelectedItemCommand="{Binding SelectTicketCommand}"
d:ItemsSource="{d:SampleData ItemCount=10}"
Background="Transparent"
BorderThickness="0"
ItemContainerStyle="{StaticResource TicketListItemStyle}"
ItemsSource="{Binding TicketView}"
ScrollViewer.HorizontalScrollBarVisibility="Disabled"
SelectedItem="{Binding SelectedTicket, Mode=OneWay}">
<ListBox.Resources>
<Style BasedOn="{StaticResource ChatScrollBarStyle}" TargetType="ScrollBar" />
</ListBox.Resources>
<ListBox.ItemTemplate>
<DataTemplate DataType="{x:Type vm:WorkOrderSummaryViewModel}">
<Grid Margin="11,10,14,10">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<TextBlock
FontWeight="SemiBold"
Foreground="{StaticResource TextBrush}"
Tag="{Binding WechatOrderId}"
Text="{Binding WechatOrderId}"
TextTrimming="CharacterEllipsis" />
<Border
x:Name="UnreadBadge"
Grid.Column="1"
Height="18"
MinWidth="18"
Margin="6,-1,0,0"
Padding="5,0"
Background="{StaticResource BrandBrush}"
CornerRadius="9">
<TextBlock
HorizontalAlignment="Center"
VerticalAlignment="Center"
FontSize="11"
Foreground="White"
Text="{Binding UnreadCount}" />
</Border>
</Grid>
<Border
Grid.Column="1"
Margin="8,0,0,0"
Style="{StaticResource StatusTagStyle}">
<TextBlock Style="{StaticResource StatusTextStyle}" Text="{Binding StatusText}" />
</Border>
</Grid>
<Grid Grid.Row="1" Margin="0,7,0,0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="48" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Grid Width="48" Height="48">
<Border
Background="#F1F3F6"
BorderBrush="#DDE2E8"
BorderThickness="1"
CornerRadius="4">
<TextBlock
HorizontalAlignment="Center"
VerticalAlignment="Center"
FontSize="18"
Foreground="#9AA5B1"
Style="{StaticResource TextBlockIcon}"
Text="{StaticResource txt-image}" />
</Border>
<Border
BorderBrush="#DDE2E8"
BorderThickness="1"
CornerRadius="4">
<Border.Background>
<ImageBrush ImageSource="{Binding ProductImage}" Stretch="UniformToFill" />
</Border.Background>
</Border>
</Grid>
<StackPanel Grid.Column="1" Margin="9,0,0,0">
<TextBlock
FontSize="13"
FontWeight="SemiBold"
Text="{Binding ProductNameText}"
TextTrimming="CharacterEllipsis" />
<Grid Margin="0,3,0,0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<TextBlock
FontSize="12"
FontWeight="SemiBold"
Foreground="{StaticResource PriceBrush}"
Text="{Binding ProductAmountText}" />
<TextBlock
Grid.Column="1"
Margin="8,0,0,0"
FontSize="12"
Foreground="{StaticResource SubTextBrush}"
Text="{Binding ShopName, StringFormat=店铺 {0}}"
TextTrimming="CharacterEllipsis" />
</Grid>
<Grid Margin="0,3,0,0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<TextBlock
FontSize="11"
Foreground="{StaticResource SubTextBrush}"
Text="{Binding PreviewText}"
TextTrimming="CharacterEllipsis" />
<TextBlock
Grid.Column="1"
Margin="8,0,0,0"
FontSize="11"
Foreground="{StaticResource SubTextBrush}"
Text="{Binding UpdatedAtText}" />
</Grid>
</StackPanel>
</Grid>
</Grid>
<DataTemplate.Triggers>
<DataTrigger Binding="{Binding UnreadCount}" Value="0">
<Setter TargetName="UnreadBadge" Property="Visibility" Value="Collapsed" />
</DataTrigger>
</DataTemplate.Triggers>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</Grid>
<Button
Grid.Row="2"
Padding="14,9"
HorizontalContentAlignment="Left"
Background="Transparent"
BorderBrush="#DDE2E8"
BorderThickness="0,1,0,0"
Command="{Binding RetryRealtimeCommand}"
Cursor="Hand">
<StackPanel Orientation="Horizontal">
<Ellipse
Width="8"
Height="8"
Margin="0,0,8,0">
<Ellipse.Style>
<Style TargetType="Ellipse">
<Setter Property="Fill" Value="#D14343" />
<Style.Triggers>
<DataTrigger Binding="{Binding SseState}" Value="{x:Static models:TicketRealtimeState.Connected}">
<Setter Property="Fill" Value="#2F7D4F" />
</DataTrigger>
<DataTrigger Binding="{Binding SseState}" Value="{x:Static models:TicketRealtimeState.Connecting}">
<Setter Property="Fill" Value="#D99A1B" />
</DataTrigger>
<DataTrigger Binding="{Binding SseState}" Value="{x:Static models:TicketRealtimeState.Reconnecting}">
<Setter Property="Fill" Value="#D99A1B" />
</DataTrigger>
</Style.Triggers>
</Style>
</Ellipse.Style>
</Ellipse>
<TextBlock
FontSize="12"
Foreground="#6B7785"
Text="{Binding SseStatusText}" />
</StackPanel>
</Button>
</Grid>
</Border>
</UserControl>
@@ -0,0 +1,22 @@
using _29WxOrderWpf.ToolCtrls;
using OrderSupportTicket.ViewModels;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using Work._29Tools.Forms.ToolForms;
namespace OrderSupportTicket.Views;
public partial class TicketSidebarView : UserControl
{
public TicketSidebarView() => InitializeComponent();
private void TicketSearchBox_GotFocus(object sender, RoutedEventArgs e) { if (DataContext is OrderSupportTicketViewModel vm) vm.CancelNewTicketDraft(); }
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;
var window = Window.GetWindow(this);
if (window != null && !string.IsNullOrWhiteSpace(orderId)) ToastHelper.Show(window, ClipboardHelper.TrySetText(orderId) ? "订单号已复制" : "复制失败");
}
}