修复开票 过程中出现的错误提示

This commit is contained in:
chfei committed 2026-10-12 18:44:30 +08:00
1 parent dd512a0dcb
commit 064bd1f142
2 files changed
+63 -15

No files matched your search

@@ -1,5 +1,7 @@
using _29WxOrderWpf.Commands; using _29WxOrderWpf.Commands;
using _29WxOrderWpf.Common;
using _29WxOrderWpf.Ctrls.PDDInvoice.ViewModels; using _29WxOrderWpf.Ctrls.PDDInvoice.ViewModels;
using Prism.Services.Dialogs;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
@@ -22,19 +24,26 @@ namespace _29WxOrderWpf.Ctrls.PDDInvoice;
/// <summary> /// <summary>
/// PDDInvoiceDialog.xaml 的交互逻辑 /// PDDInvoiceDialog.xaml 的交互逻辑
/// </summary> /// </summary>
public partial class PDDInvoiceDialog : UserControl public partial class PDDInvoiceDialog : UserControl, IDialogAware
{ {
public PDDInvoiceDialog() public PDDInvoiceDialog(InvoiceConfig config)
{ {
InitializeComponent(); InitializeComponent();
DataContext = this; DataContext = this;
Config = NaiBa.Util.Helper.ConfigHelper.LoadConfig<InvoiceConfig>(ConfigPath); Config = new InvoiceConfig();
Config.Assign(config);
} }
public string Title { get; set; }
public event Action<IDialogResult> RequestClose;
private void PDDInvoiceDialog_Loaded(object sender, RoutedEventArgs e) private void PDDInvoiceDialog_Loaded(object sender, RoutedEventArgs e)
{ {
} }
public void OnDialogOpened(IDialogParameters parameters)
{
Title = "设置";
}
private void ViewModel_RequestClose() private void ViewModel_RequestClose()
{ {
@@ -44,21 +53,35 @@ public partial class PDDInvoiceDialog : UserControl
} }
private const string ConfigPath = "./invoice.config";
public InvoiceConfig Config { get; } public InvoiceConfig Config { get; }
public ICommand ConfirmCommand => new DelegateCommand(Confirm); public ICommand ConfirmCommand => new DelegateCommand(Confirm);
private void Confirm() private void Confirm()
{ {
NaiBa.Util.Helper.ConfigHelper.SaveConfig(ConfigPath, Config); RequestClose?.Invoke(new DialogResult(ButtonResult.OK, new DialogParameters
ViewModel_RequestClose(); {
{ "config",Config}
}));
} }
public ICommand CancelCommand => new DelegateCommand(Cancel); public ICommand CancelCommand => new DelegateCommand(Cancel);
private void Cancel() private void Cancel()
{ {
ViewModel_RequestClose(); RequestClose?.Invoke(new DialogResult(ButtonResult.Cancel));
} }
public bool CanCloseDialog()
{
return true;
}
public void OnDialogClosed()
{
}
} }
@@ -15,6 +15,7 @@ using MAX.Core.Helpers;
using NaiBa.Util.Extension; using NaiBa.Util.Extension;
using Newtonsoft.Json; using Newtonsoft.Json;
using NPOI.SS.Formula.Functions; using NPOI.SS.Formula.Functions;
using Prism.Services.Dialogs;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
@@ -475,13 +476,17 @@ public partial class PDDInvoiceViewModel : BindableBaseEx
private void ShowSettingDialog() private void ShowSettingDialog()
{ {
var view = new PDDInvoiceDialog(); var view = new PDDInvoiceDialog(Config);
new DialogWindow DialogService.ShowDialog(view, null, result =>
{ {
Title = "设置", if (result.Result == ButtonResult.OK)
Content = view, {
}.ShowDialog(); Config.Assign(view.Config);
Config = view.Config; NaiBa.Util.Helper.ConfigHelper.SaveConfig(ConfigPath, Config);
}
});
} }
public event EventHandler<int> BatchInvoiceChanged; public event EventHandler<int> BatchInvoiceChanged;
@@ -537,6 +542,11 @@ public partial class PDDInvoiceViewModel : BindableBaseEx
order.IsSelected = false; order.IsSelected = false;
success++; success++;
AmountTotal += order.order_amount / 100m; AmountTotal += order.order_amount / 100m;
if (Config.IsSaveData)
{
var temp = OrderInvoiceInfoList?.FirstOrDefault(a => a.order_sn == order.order_sn);
if (temp != null) temp.IsInvoiced = true;
}
} }
else else
{ {
@@ -547,6 +557,12 @@ public partial class PDDInvoiceViewModel : BindableBaseEx
BottomRMsg = $"批量开票状态:成功 {success} 个,失败 {fail} 个。总金额:{AmountTotal.ToString("N2")}"; BottomRMsg = $"批量开票状态:成功 {success} 个,失败 {fail} 个。总金额:{AmountTotal.ToString("N2")}";
StatisticsInvoiceAmount(); StatisticsInvoiceAmount();
await Task.Delay(1000); await Task.Delay(1000);
if (Config.IsSaveData)
{
SaveOrderInvoiceInfo();
}
} }
} }
catch (Exception ex) catch (Exception ex)
@@ -716,10 +732,11 @@ public partial class PDDInvoiceViewModel : BindableBaseEx
} }
} }
StatisticsInvoiceAmount(); StatisticsInvoiceAmount();
if (Config.IsSaveData)
{
SaveOrderInvoiceInfo(); SaveOrderInvoiceInfo();
} }
}
#endregion #endregion
@@ -897,4 +914,12 @@ public class InvoiceConfig
public string TaxNo { get; set; } public string TaxNo { get; set; }
public decimal MaxAmount { get; set; } public decimal MaxAmount { get; set; }
public bool IsSaveData { get; set; } public bool IsSaveData { get; set; }
public void Assign(InvoiceConfig config)
{
Title = config.Title;
TaxNo = config.TaxNo;
MaxAmount = config.MaxAmount;
IsSaveData = config.IsSaveData;
}
} }