Skip to content

Commit f8a6d72

Browse files
ArgoZhangdensen2014lambert leeh2ls
authored
doc: update verify vat invoice sample code (#351)
Co-authored-by: alex chow <zhouchuanglin@gmail.com> Co-authored-by: lambert lee <1708416@qq.com> Co-authored-by: lambert lee <lish@live.cn>
1 parent 25b6393 commit f8a6d72

1 file changed

Lines changed: 9 additions & 13 deletions

File tree

src/BootstrapBlazor.Shared/Demos/BaiduOcr/BaiduOcrVerifyVatInvoice.razor

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<ValidateForm Model="Model" OnValidSubmit="@Verify">
66
<EditorForm TModel="InvoiceForm" RowType="RowType.Inline" AutoGenerateAllItem="false">
77
<FieldItems>
8-
<EditorItem @bind-Field="@context.InvoiceType" Text="发票种类" Readonly="true" />
8+
<EditorItem @bind-Field="@context.InvoiceType" Text="发票种类" />
99
<EditorItem @bind-Field="@context.InvoiceCode" Text="发票代码" />
1010
<EditorItem @bind-Field="@context.InvoiceNum" Text="发票号码" />
1111
<EditorItem @bind-Field="@context.InvoiceDate" Text="开票日期" PlaceHolder="YYYYMMDD" />
@@ -18,26 +18,22 @@
1818
</EditorForm>
1919
</ValidateForm>
2020

21-
@if (InvoiceVerifyResult != null)
22-
{
23-
<div class="mt-3">@InvoiceVerifyResult.VerifyMessage</div>
24-
}
25-
2621
@code {
27-
/// <summary>
28-
/// 取消请求令牌
29-
/// </summary>
3022
private CancellationTokenSource? TokenSource { get; set; }
3123

32-
private InvoiceVerifyResult? InvoiceVerifyResult { get; set; }
33-
3424
private InvoiceForm Model { get; set; } = new() { InvoiceType = "elec_special_vat_invoice", TotalAmount = "0" };
3525

3626
private async Task Verify(EditContext context)
3727
{
3828
var result = await OcrService.VerifyInvoiceAsync(Model.InvoiceCode, Model.InvoiceNum, Model.InvoiceDate, Model.InvoiceType, Model.CheckCode, Model.TotalAmount);
39-
InvoiceVerifyResult = result.Entity;
40-
StateHasChanged();
29+
if (result.ErrorCode != 0)
30+
{
31+
await ToastService.Information("Verify Vat", $"{result.ErrorCode}: {result.ErrorMessage}");
32+
}
33+
else if (result.Entity != null)
34+
{
35+
await ToastService.Success("Verify Vat", result.Entity?.VerifyMessage);
36+
}
4137
}
4238

4339
/// <summary>

0 commit comments

Comments
 (0)