修改工单流程页面,订单列表增加工单按钮
This commit is contained in:
1 parent
f9dcae4610
commit
10bb0803d9
44 files changed
+5920
-1291
No files matched your search
@@ -1,6 +1,12 @@
|
||||
using AllBase.Helper;
|
||||
using OrderSupportTicket.Models.Api;
|
||||
using OrderSupportTicket.Services;
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Threading;
|
||||
using WPFCommon.Models;
|
||||
|
||||
namespace OrderSupportTicket.ViewModels;
|
||||
@@ -21,6 +27,13 @@ public sealed class WorkOrderSummaryViewModel : BindableBaseEx
|
||||
private int _unreadCount;
|
||||
private bool _hasNewMessage;
|
||||
private string _version;
|
||||
private string _productName;
|
||||
private string _productImageUrl;
|
||||
private decimal? _productAmount;
|
||||
private ImageSource _productImage;
|
||||
private int _productImageVersion;
|
||||
private readonly Dispatcher _dispatcher =
|
||||
System.Windows.Application.Current?.Dispatcher ?? Dispatcher.CurrentDispatcher;
|
||||
|
||||
public WorkOrderSummaryViewModel(WorkOrderSummaryDto dto)
|
||||
{
|
||||
@@ -35,7 +48,29 @@ public sealed class WorkOrderSummaryViewModel : BindableBaseEx
|
||||
public string AppId
|
||||
{
|
||||
get => _appId;
|
||||
private set => SetValue(ref _appId, value);
|
||||
private set
|
||||
{
|
||||
if (SetValue(ref _appId, value))
|
||||
RaisePropertyChanged(nameof(ShopName));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 工单所属店铺的显示名称。列表中不直接展示 APPID。
|
||||
/// </summary>
|
||||
public string ShopName
|
||||
{
|
||||
get
|
||||
{
|
||||
var shop = GlobalConfig.ShopLoginList?.FirstOrDefault(s =>
|
||||
string.Equals(s.ShopId, AppId, StringComparison.Ordinal)
|
||||
|| string.Equals(s.AppKey, AppId, StringComparison.Ordinal));
|
||||
if (!string.IsNullOrWhiteSpace(shop?.ShopAccount))
|
||||
return shop.ShopAccount;
|
||||
if (!string.IsNullOrWhiteSpace(shop?.CompanyName))
|
||||
return shop.CompanyName;
|
||||
return "未知店铺";
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -144,6 +179,66 @@ public sealed class WorkOrderSummaryViewModel : BindableBaseEx
|
||||
private set => SetValue(ref _version, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 商品名称,优先来自当前订单列表或本地工单缓存。
|
||||
/// </summary>
|
||||
public string ProductName
|
||||
{
|
||||
get => _productName;
|
||||
private set
|
||||
{
|
||||
if (SetValue(ref _productName, value))
|
||||
RaisePropertyChanged(nameof(ProductNameText));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 商品名称的展示文本,尚未同步到商品信息时给出提示。
|
||||
/// </summary>
|
||||
public string ProductNameText =>
|
||||
string.IsNullOrWhiteSpace(ProductName) ? "商品信息待同步" : ProductName;
|
||||
|
||||
/// <summary>
|
||||
/// 商品金额,单位元;旧缓存没有金额时为 null。
|
||||
/// </summary>
|
||||
public decimal? ProductAmount
|
||||
{
|
||||
get => _productAmount;
|
||||
private set
|
||||
{
|
||||
if (SetValue(ref _productAmount, value))
|
||||
RaisePropertyChanged(nameof(ProductAmountText));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 商品金额展示文本。
|
||||
/// </summary>
|
||||
public string ProductAmountText =>
|
||||
ProductAmount.HasValue
|
||||
? "¥ " + ProductAmount.Value.ToString(
|
||||
"N2",
|
||||
CultureInfo.GetCultureInfo("zh-CN"))
|
||||
: string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 商品缩略图地址。
|
||||
/// </summary>
|
||||
public string ProductImageUrl
|
||||
{
|
||||
get => _productImageUrl;
|
||||
private set => SetValue(ref _productImageUrl, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 商品缩略图,加载完成前为空。
|
||||
/// </summary>
|
||||
public ImageSource ProductImage
|
||||
{
|
||||
get => _productImage;
|
||||
private set => SetValue(ref _productImage, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 用于合并工单的 APPID 与订单号组合键。
|
||||
/// </summary>
|
||||
@@ -230,6 +325,30 @@ public sealed class WorkOrderSummaryViewModel : BindableBaseEx
|
||||
UnreadCount = 1;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 合并商品信息。空值不会覆盖已有数据,便于先应用缓存、再应用最新的订单信息。
|
||||
/// </summary>
|
||||
public void ApplyProductInfo(
|
||||
string productName,
|
||||
string imageUrl,
|
||||
decimal? amount)
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(productName))
|
||||
ProductName = productName.Trim();
|
||||
if (amount.HasValue)
|
||||
ProductAmount = amount;
|
||||
|
||||
if (string.IsNullOrWhiteSpace(imageUrl))
|
||||
return;
|
||||
|
||||
var normalizedUrl = imageUrl.Trim();
|
||||
if (string.Equals(ProductImageUrl, normalizedUrl, StringComparison.Ordinal))
|
||||
return;
|
||||
|
||||
ProductImageUrl = normalizedUrl;
|
||||
_ = LoadProductImageAsync(normalizedUrl);
|
||||
}
|
||||
|
||||
private void Apply(WorkOrderSummaryDto dto)
|
||||
{
|
||||
AppId = dto.AppId;
|
||||
@@ -246,6 +365,35 @@ public sealed class WorkOrderSummaryViewModel : BindableBaseEx
|
||||
Version = dto.Version;
|
||||
}
|
||||
|
||||
private async Task LoadProductImageAsync(string url)
|
||||
{
|
||||
try
|
||||
{
|
||||
var version = ++_productImageVersion;
|
||||
ProductImage = null;
|
||||
|
||||
var image = await ProductImageLoader.LoadAsync(url);
|
||||
if (image == null || version != _productImageVersion)
|
||||
return;
|
||||
|
||||
if (_dispatcher.CheckAccess())
|
||||
{
|
||||
ProductImage = image;
|
||||
return;
|
||||
}
|
||||
|
||||
await _dispatcher.InvokeAsync(() =>
|
||||
{
|
||||
if (version == _productImageVersion)
|
||||
ProductImage = image;
|
||||
});
|
||||
}
|
||||
catch
|
||||
{
|
||||
// 商品图加载失败不影响工单列表展示。
|
||||
}
|
||||
}
|
||||
|
||||
private bool IsAtLeastCurrentVersion(string incomingVersion)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(incomingVersion))
|
||||
|
||||
Reference in new issue
Block a user