...
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
@using Shared.DTOs
|
@using Shared.DTOs
|
||||||
<Modal @ref="modal" />
|
<Modal @ref="modal" />
|
||||||
|
|
||||||
<Grid TItem="InvoiceItemDTO"
|
<Grid @ref="grid" TItem="InvoiceItemDTO"
|
||||||
AllowRowClick="true"
|
AllowRowClick="true"
|
||||||
AllowSorting="true"
|
AllowSorting="true"
|
||||||
Class="table table-hover"
|
Class="table table-hover"
|
||||||
@@ -48,6 +48,7 @@
|
|||||||
|
|
||||||
|
|
||||||
@code {
|
@code {
|
||||||
|
Grid<InvoiceItemDTO> grid = default!;
|
||||||
[Parameter] public int InvoiceID { get; set; }
|
[Parameter] public int InvoiceID { get; set; }
|
||||||
[Parameter] public bool IsDeleted { get; set; }
|
[Parameter] public bool IsDeleted { get; set; }
|
||||||
[Parameter] public EventCallback<string> OnMultipleOfThree { get; set; }
|
[Parameter] public EventCallback<string> OnMultipleOfThree { get; set; }
|
||||||
@@ -60,6 +61,12 @@
|
|||||||
|
|
||||||
return await Task.FromResult(request.ApplyTo(InvoiceItems));
|
return await Task.FromResult(request.ApplyTo(InvoiceItems));
|
||||||
}
|
}
|
||||||
|
protected override async Task OnParametersSetAsync()
|
||||||
|
{
|
||||||
|
if(grid != null)
|
||||||
|
await grid.RefreshDataAsync();
|
||||||
|
await base.OnParametersSetAsync();
|
||||||
|
}
|
||||||
private async Task OnRowClick(GridRowEventArgs<InvoiceItemDTO> args)
|
private async Task OnRowClick(GridRowEventArgs<InvoiceItemDTO> args)
|
||||||
{
|
{
|
||||||
if (!IsDeleted)
|
if (!IsDeleted)
|
||||||
@@ -99,7 +106,7 @@
|
|||||||
// if (result.Status == ComponentStatus.success)
|
// if (result.Status == ComponentStatus.success)
|
||||||
// await LoadCod(1);
|
// await LoadCod(1);
|
||||||
|
|
||||||
// await modal.HideAsync();
|
await modal.HideAsync();
|
||||||
}
|
}
|
||||||
private IEnumerable<InvoiceItemDTO> GetInvoiceItems()
|
private IEnumerable<InvoiceItemDTO> GetInvoiceItems()
|
||||||
{
|
{
|
||||||
|
@@ -386,7 +386,6 @@
|
|||||||
|
|
||||||
@code {
|
@code {
|
||||||
private Modal Codemodal = default!;
|
private Modal Codemodal = default!;
|
||||||
|
|
||||||
public bool SendInvoice { get; set; } = false;
|
public bool SendInvoice { get; set; } = false;
|
||||||
List<ToastMessage> messages = new List<ToastMessage>();
|
List<ToastMessage> messages = new List<ToastMessage>();
|
||||||
private ConfirmDialog dialog = default!;
|
private ConfirmDialog dialog = default!;
|
||||||
@@ -504,29 +503,8 @@
|
|||||||
hc._nav.NavigateTo($"FullInvoiceItem/{InvoiceID}");
|
hc._nav.NavigateTo($"FullInvoiceItem/{InvoiceID}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private async Task onClickLink()
|
|
||||||
{
|
|
||||||
|
|
||||||
ExUrl = $"{fv.Domin}/InvoiceReport/" + InvoiceID;
|
|
||||||
await Codemodal.ShowAsync();
|
|
||||||
}
|
|
||||||
private async Task ShowReport()
|
|
||||||
{
|
|
||||||
PreloadService.Show(SpinnerColor.Dark);
|
|
||||||
var rsp = await hc.Get($"Invoice/GetReport/{InvoiceID}");
|
|
||||||
if (rsp.IsSuccessStatusCode)
|
|
||||||
{
|
|
||||||
var str = await rsp.Content.ReadAsStringAsync();
|
|
||||||
if (string.IsNullOrEmpty(str))
|
|
||||||
ShowDangerAlert("مشکلی در ساخت فایل رخ داده لطفا مجدد تلاش کنید");
|
|
||||||
else
|
|
||||||
await DownloadFileFromStream(str, $"{invoice.ID}.pdf");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
ShowDangerAlert("خطایی در چاپ فاکتور");
|
|
||||||
|
|
||||||
PreloadService.Hide();
|
|
||||||
}
|
|
||||||
private async Task LoadData()
|
private async Task LoadData()
|
||||||
{
|
{
|
||||||
PreloadService.Show(SpinnerColor.Dark);
|
PreloadService.Show(SpinnerColor.Dark);
|
||||||
@@ -568,7 +546,7 @@
|
|||||||
}
|
}
|
||||||
await CallBack(msg);
|
await CallBack(msg);
|
||||||
// if (result.Status == ComponentStatus.success)
|
// if (result.Status == ComponentStatus.success)
|
||||||
// await LoadCod(1);
|
//await LoadData();
|
||||||
|
|
||||||
await modal.HideAsync();
|
await modal.HideAsync();
|
||||||
}
|
}
|
||||||
@@ -578,6 +556,7 @@
|
|||||||
{
|
{
|
||||||
ShowSuccessAlert(result);
|
ShowSuccessAlert(result);
|
||||||
await LoadData();
|
await LoadData();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private void ShowSuccessAlert(string msg)
|
private void ShowSuccessAlert(string msg)
|
||||||
@@ -784,35 +763,5 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
//for download
|
|
||||||
private Stream GetFileStream(byte[] bytes)
|
|
||||||
{
|
|
||||||
var fileStream = new MemoryStream(bytes);
|
|
||||||
|
|
||||||
return fileStream;
|
|
||||||
}
|
}
|
||||||
private async Task DownloadFileFromStream(string Base64, string FileName)
|
|
||||||
{
|
|
||||||
byte[] bytes = System.Convert.FromBase64String(Base64);
|
|
||||||
|
|
||||||
var fileStream = GetFileStream(bytes);
|
|
||||||
// var fileName = "log.bin";
|
|
||||||
|
|
||||||
using var streamRef = new DotNetStreamReference(stream: fileStream);
|
|
||||||
|
|
||||||
await JS.InvokeVoidAsync("downloadFileFromStream", FileName, streamRef);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
<script>
|
|
||||||
window.downloadFileFromStream = async (fileName, contentStreamReference) => {
|
|
||||||
const arrayBuffer = await contentStreamReference.arrayBuffer();
|
|
||||||
const blob = new Blob([arrayBuffer]);
|
|
||||||
const url = URL.createObjectURL(blob);
|
|
||||||
const anchorElement = document.createElement('a');
|
|
||||||
anchorElement.href = url;
|
|
||||||
anchorElement.download = fileName ?? '';
|
|
||||||
anchorElement.click();
|
|
||||||
anchorElement.remove();
|
|
||||||
URL.revokeObjectURL(url);
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
Reference in New Issue
Block a user