发票助手 增加 发票状态筛选,修复不能选中bug,修复开票失败bug
This commit is contained in:
1 parent
df340c920a
commit
c0e3b998ac
3 files changed
+61
-6
No files matched your search
@@ -41,6 +41,7 @@ namespace _29WxOrderWpf.Ctrls.PDDInvoice.ViewModels;
|
||||
/// </summary>
|
||||
public partial class PDDInvoiceViewModel : BindableBaseEx
|
||||
{
|
||||
private const string ConfigPath = "./invoice.config";
|
||||
private readonly ObservableCollection<PddBrowserOrderInvoiceViewModel> _allOrders = new();
|
||||
private readonly HashSet<string> _orderSns = new();
|
||||
private string _searchText = "";
|
||||
@@ -49,9 +50,11 @@ public partial class PDDInvoiceViewModel : BindableBaseEx
|
||||
private bool _isInvoiceDetailOpen;
|
||||
private string _invoiceTitle = "";
|
||||
private string _taxNo = "";
|
||||
private CancellationTokenSource _cancellationTokenSource; public PDDInvoiceViewModel()
|
||||
private CancellationTokenSource _cancellationTokenSource;
|
||||
private InvoiceConfig Config { get; }
|
||||
public PDDInvoiceViewModel()
|
||||
{
|
||||
|
||||
Config = NaiBa.Util.Helper.ConfigHelper.LoadConfig<InvoiceConfig>(ConfigPath);
|
||||
Orders = new ObservableCollection<PddBrowserOrderInvoiceViewModel>();
|
||||
Orders.CollectionChanged += Orders_CollectionChanged;
|
||||
|
||||
@@ -60,6 +63,10 @@ public partial class PDDInvoiceViewModel : BindableBaseEx
|
||||
|
||||
|
||||
InitBrowser();
|
||||
if (Config == null) Config = new InvoiceConfig();
|
||||
InvoiceTitle = Config.Title;
|
||||
TaxNo = Config.TaxNo;
|
||||
MaxAmount = Config.MaxAmount;
|
||||
|
||||
if (EnvironmentHelper.IsTest)
|
||||
{
|
||||
@@ -105,6 +112,17 @@ public partial class PDDInvoiceViewModel : BindableBaseEx
|
||||
|
||||
|
||||
public ObservableCollectionThreadSafe<BuyerLoginInfo> BuyerLoginList { get; set; } = new ObservableCollectionThreadSafe<BuyerLoginInfo>();
|
||||
public int InvoiceStatus
|
||||
{
|
||||
get => GetValue<int>();
|
||||
set => SetValue(value, InvoiceStatusChanged);
|
||||
}
|
||||
|
||||
private void InvoiceStatusChanged()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public BuyerLoginInfo SelectedBuyer
|
||||
{
|
||||
get => GetProperty(() => SelectedBuyer);
|
||||
@@ -371,6 +389,11 @@ public partial class PDDInvoiceViewModel : BindableBaseEx
|
||||
"批量开票");
|
||||
if (confirm.DialogResult != true) return;
|
||||
|
||||
Config.Title = InvoiceTitle;
|
||||
Config.TaxNo = TaxNo;
|
||||
Config.MaxAmount = MaxAmount;
|
||||
NaiBa.Util.Helper.ConfigHelper.SaveConfig(ConfigPath, Config);
|
||||
|
||||
await BatchInvoiceAsync(targets);
|
||||
}
|
||||
|
||||
@@ -460,8 +483,17 @@ public partial class PDDInvoiceViewModel : BindableBaseEx
|
||||
{
|
||||
var keyword = SearchText?.Trim();
|
||||
Orders.Clear();
|
||||
foreach (var order in _allOrders.Where(o => IsKeywordMatch(o, keyword)))
|
||||
bool? _tempIsInvoiced = InvoiceStatus == 0 ? null : InvoiceStatus == 2;
|
||||
foreach (var order in _allOrders)
|
||||
{
|
||||
if (_tempIsInvoiced.HasValue)
|
||||
{
|
||||
if (order.IsInvoiced != _tempIsInvoiced.Value) continue;
|
||||
}
|
||||
if (!IsKeywordMatch(order, keyword))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
Orders.Add(order);
|
||||
}
|
||||
}
|
||||
@@ -476,6 +508,7 @@ public partial class PDDInvoiceViewModel : BindableBaseEx
|
||||
private void ResetSearch()
|
||||
{
|
||||
SearchText = "";
|
||||
InvoiceStatus = 0;
|
||||
Search();
|
||||
}
|
||||
/// <summary>
|
||||
@@ -608,6 +641,7 @@ public partial class PDDInvoiceViewModel : BindableBaseEx
|
||||
|
||||
}
|
||||
}
|
||||
Orders.FirstOrDefault().IsInvoiced = true;
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
@@ -714,3 +748,9 @@ public partial class PDDInvoiceViewModel : BindableBaseEx
|
||||
#endregion
|
||||
}
|
||||
|
||||
class InvoiceConfig
|
||||
{
|
||||
public string Title { get; set; }
|
||||
public string TaxNo { get; set; }
|
||||
public decimal MaxAmount { get; set; }
|
||||
}
|
||||
Reference in new issue
Block a user