initial commit
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net9.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="7.1.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\Core\Application\Application.csproj" />
|
||||
<ProjectReference Include="..\..\Infrastructure\Infrastructure\Infrastructure.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<ActiveDebugProfile>https</ActiveDebugProfile>
|
||||
<Controller_SelectedScaffolderID>MvcControllerEmptyScaffolder</Controller_SelectedScaffolderID>
|
||||
<Controller_SelectedScaffolderCategoryPath>root/Common/MVC/Controller</Controller_SelectedScaffolderCategoryPath>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,118 @@
|
||||
using Application;
|
||||
using ASPNET.BackEnd.Common.Handlers;
|
||||
using Infrastructure;
|
||||
using Infrastructure.DataAccessManager.EFCore;
|
||||
using Infrastructure.SeedManager;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.OpenApi.Models;
|
||||
|
||||
namespace ASPNET.BackEnd;
|
||||
|
||||
public static class BackEndConfiguration
|
||||
{
|
||||
public static IServiceCollection AddBackEndServices(this IServiceCollection services, IConfiguration configuration)
|
||||
{
|
||||
//>>> Application Layer
|
||||
services.AddApplicationServices();
|
||||
|
||||
//>>> Infrastructure Layer
|
||||
services.AddInfrastructureServices(configuration);
|
||||
|
||||
services.AddExceptionHandler<CustomExceptionHandler>();
|
||||
|
||||
//>>> Common
|
||||
|
||||
services.AddHttpContextAccessor();
|
||||
services.AddCors(opt =>
|
||||
{
|
||||
opt.AddDefaultPolicy(builder => builder
|
||||
.AllowAnyOrigin()
|
||||
.AllowAnyMethod()
|
||||
.AllowAnyHeader());
|
||||
});
|
||||
services.AddControllers()
|
||||
.AddJsonOptions(options =>
|
||||
{
|
||||
options.JsonSerializerOptions.ReferenceHandler = System.Text.Json.Serialization.ReferenceHandler.IgnoreCycles;
|
||||
options.JsonSerializerOptions.WriteIndented = true;
|
||||
});
|
||||
services.AddEndpointsApiExplorer();
|
||||
services.AddSwaggerGen(c =>
|
||||
{
|
||||
c.SwaggerDoc("v1", new OpenApiInfo { Title = "Indotalent API", Version = "v1" });
|
||||
c.AddSecurityDefinition("Bearer", new OpenApiSecurityScheme
|
||||
{
|
||||
Name = "Authorization",
|
||||
Type = SecuritySchemeType.ApiKey,
|
||||
Scheme = "bearer",
|
||||
BearerFormat = "JWT",
|
||||
In = ParameterLocation.Header,
|
||||
Description = "JWT Authorization header using the Bearer scheme."
|
||||
});
|
||||
|
||||
c.AddSecurityRequirement(new OpenApiSecurityRequirement
|
||||
{
|
||||
{
|
||||
new OpenApiSecurityScheme
|
||||
{
|
||||
Reference = new OpenApiReference
|
||||
{
|
||||
Type = ReferenceType.SecurityScheme,
|
||||
Id = "Bearer"
|
||||
}
|
||||
},
|
||||
new string[] { }
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
||||
services.Configure<ApiBehaviorOptions>(x =>
|
||||
{
|
||||
x.SuppressModelStateInvalidFilter = true;
|
||||
});
|
||||
|
||||
return services;
|
||||
}
|
||||
|
||||
public static IEndpointRouteBuilder MapBackEndRoutes(this IEndpointRouteBuilder endpoints)
|
||||
{
|
||||
endpoints.MapControllers();
|
||||
|
||||
return endpoints;
|
||||
}
|
||||
|
||||
public static IApplicationBuilder RegisterBackEndBuilder(
|
||||
this IApplicationBuilder app,
|
||||
IWebHostEnvironment environment,
|
||||
IHost host,
|
||||
IConfiguration configuration
|
||||
)
|
||||
{
|
||||
// >>> Create database
|
||||
host.CreateDatabase();
|
||||
|
||||
//seed database with system data
|
||||
host.SeedSystemData();
|
||||
|
||||
//seed database with demo data
|
||||
if (configuration.GetValue<bool>("IsDemoVersion"))
|
||||
{
|
||||
host.SeedDemoData();
|
||||
}
|
||||
|
||||
if (environment.IsDevelopment())
|
||||
{
|
||||
app.UseSwagger();
|
||||
app.UseSwaggerUI(c =>
|
||||
{
|
||||
c.SwaggerEndpoint("/swagger/v1/swagger.json", "Indotalent V1");
|
||||
});
|
||||
}
|
||||
|
||||
return app;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
using MediatR;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace ASPNET.BackEnd.Common.Base;
|
||||
|
||||
[ApiController]
|
||||
[Route("api/[controller]/[action]")]
|
||||
public abstract class BaseApiController : ControllerBase
|
||||
{
|
||||
protected readonly ISender _sender;
|
||||
|
||||
protected BaseApiController(ISender sender)
|
||||
{
|
||||
_sender = sender;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
using ASPNET.BackEnd.Common.Models;
|
||||
using Microsoft.AspNetCore.Diagnostics;
|
||||
|
||||
namespace ASPNET.BackEnd.Common.Handlers;
|
||||
|
||||
public class CustomExceptionHandler : IExceptionHandler
|
||||
{
|
||||
private readonly Dictionary<Type, Func<HttpContext, Exception, Task>> _exceptionHandlers;
|
||||
|
||||
public CustomExceptionHandler()
|
||||
{
|
||||
_exceptionHandlers = new()
|
||||
{
|
||||
{ typeof(Exception), HandleException },
|
||||
};
|
||||
}
|
||||
public async ValueTask<bool> TryHandleAsync(HttpContext httpContext, Exception exception, CancellationToken cancellationToken)
|
||||
{
|
||||
var exceptionType = exception.GetType();
|
||||
|
||||
if (_exceptionHandlers.ContainsKey(exceptionType))
|
||||
{
|
||||
await _exceptionHandlers[exceptionType].Invoke(httpContext, exception);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
await HandleException(httpContext, exception);
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private async Task HandleException(HttpContext httpContext, Exception ex)
|
||||
{
|
||||
var statusCode = httpContext.Response.StatusCode != 200
|
||||
? httpContext.Response.StatusCode
|
||||
: StatusCodes.Status500InternalServerError;
|
||||
|
||||
var errorMessage = ex.Message;
|
||||
|
||||
var result = new ApiErrorResult
|
||||
{
|
||||
Code = statusCode,
|
||||
Message = $"Exception: {errorMessage}",
|
||||
Error = new Error(ex.InnerException?.Message, ex.Source, ex.StackTrace, ex.GetType().Name)
|
||||
};
|
||||
|
||||
httpContext.Response.ContentType = "application/json";
|
||||
await httpContext.Response.WriteAsJsonAsync(result);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
using Microsoft.AspNetCore.Diagnostics;
|
||||
|
||||
namespace ASPNET.BackEnd.Common.Middlewares;
|
||||
|
||||
public class GlobalApiExceptionHandlerMiddleware
|
||||
{
|
||||
private readonly RequestDelegate _next;
|
||||
|
||||
public GlobalApiExceptionHandlerMiddleware(RequestDelegate next)
|
||||
{
|
||||
_next = next;
|
||||
}
|
||||
|
||||
public async Task InvokeAsync(HttpContext httpContext, IExceptionHandler customExceptionHandler)
|
||||
{
|
||||
try
|
||||
{
|
||||
await _next(httpContext);
|
||||
|
||||
switch (httpContext.Response.StatusCode)
|
||||
{
|
||||
case StatusCodes.Status401Unauthorized:
|
||||
await customExceptionHandler.TryHandleAsync(
|
||||
httpContext,
|
||||
new UnauthorizedAccessException("Unauthorized - Token missing or invalid"),
|
||||
CancellationToken.None
|
||||
);
|
||||
break;
|
||||
|
||||
case StatusCodes.Status403Forbidden:
|
||||
await customExceptionHandler.TryHandleAsync(
|
||||
httpContext,
|
||||
new Exception("Forbidden - Access denied"),
|
||||
CancellationToken.None
|
||||
);
|
||||
break;
|
||||
|
||||
default:
|
||||
// Let other status codes pass through
|
||||
break;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
await customExceptionHandler.TryHandleAsync(httpContext, ex, CancellationToken.None);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
namespace ASPNET.BackEnd.Common.Models;
|
||||
|
||||
public class ApiErrorResult
|
||||
{
|
||||
public int? Code { get; init; }
|
||||
public string? Message { get; init; }
|
||||
public Error? Error { get; init; }
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
namespace ASPNET.BackEnd.Common.Models;
|
||||
|
||||
public class ApiSuccessResult<T>
|
||||
{
|
||||
public int? Code { get; init; }
|
||||
public string? Message { get; init; }
|
||||
public T? Content { get; init; }
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
namespace ASPNET.BackEnd.Common.Models;
|
||||
|
||||
public class Error
|
||||
{
|
||||
public Error(
|
||||
string? innerException,
|
||||
string? source,
|
||||
string? stackTrace,
|
||||
string? exceptionType)
|
||||
{
|
||||
Ref = "https://datatracker.ietf.org/doc/html/rfc9110";
|
||||
InnerException = innerException;
|
||||
Source = source?.Trim();
|
||||
StackTrace = stackTrace?.Trim();
|
||||
ExceptionType = exceptionType;
|
||||
}
|
||||
public string Ref { get; set; }
|
||||
public string? ExceptionType { get; init; }
|
||||
public string? InnerException { get; init; }
|
||||
public string? Source { get; init; }
|
||||
public string? StackTrace { get; init; }
|
||||
}
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
using Application.Features.CompanyManager.Commands;
|
||||
using Application.Features.CompanyManager.Queries;
|
||||
using ASPNET.BackEnd.Common.Base;
|
||||
using ASPNET.BackEnd.Common.Models;
|
||||
using MediatR;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace ASPNET.BackEnd.Controllers;
|
||||
|
||||
[Route("api/[controller]")]
|
||||
public class CompanyController : BaseApiController
|
||||
{
|
||||
public CompanyController(ISender sender) : base(sender)
|
||||
{
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
[HttpPost("UpdateCompany")]
|
||||
public async Task<ActionResult<ApiSuccessResult<UpdateCompanyResult>>> UpdateCompanyAsync(UpdateCompanyRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<UpdateCompanyResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(UpdateCompanyAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
[HttpGet("GetCompanySingle")]
|
||||
public async Task<ActionResult<ApiSuccessResult<GetCompanySingleResult>>> GetCompanySingleAsync(
|
||||
CancellationToken cancellationToken,
|
||||
[FromQuery] string id
|
||||
)
|
||||
{
|
||||
var request = new GetCompanySingleRequest { Id = id };
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<GetCompanySingleResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(GetCompanySingleAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
[HttpGet("GetCompanyList")]
|
||||
public async Task<ActionResult<ApiSuccessResult<GetCompanyListResult>>> GetCompanyListAsync(
|
||||
CancellationToken cancellationToken,
|
||||
[FromQuery] bool isDeleted = false
|
||||
)
|
||||
{
|
||||
var request = new GetCompanyListRequest { IsDeleted = isDeleted };
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<GetCompanyListResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(GetCompanyListAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,81 @@
|
||||
using Application.Features.CustomerCategoryManager.Commands;
|
||||
using Application.Features.CustomerCategoryManager.Queries;
|
||||
using ASPNET.BackEnd.Common.Base;
|
||||
using ASPNET.BackEnd.Common.Models;
|
||||
using MediatR;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace ASPNET.BackEnd.Controllers;
|
||||
|
||||
[Route("api/[controller]")]
|
||||
public class CustomerCategoryController : BaseApiController
|
||||
{
|
||||
public CustomerCategoryController(ISender sender) : base(sender)
|
||||
{
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
[HttpPost("CreateCustomerCategory")]
|
||||
public async Task<ActionResult<ApiSuccessResult<CreateCustomerCategoryResult>>> CreateCustomerCategoryAsync(CreateCustomerCategoryRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<CreateCustomerCategoryResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(CreateCustomerCategoryAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
[HttpPost("UpdateCustomerCategory")]
|
||||
public async Task<ActionResult<ApiSuccessResult<UpdateCustomerCategoryResult>>> UpdateCustomerCategoryAsync(UpdateCustomerCategoryRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<UpdateCustomerCategoryResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(UpdateCustomerCategoryAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
[HttpPost("DeleteCustomerCategory")]
|
||||
public async Task<ActionResult<ApiSuccessResult<DeleteCustomerCategoryResult>>> DeleteCustomerCategoryAsync(DeleteCustomerCategoryRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<DeleteCustomerCategoryResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(DeleteCustomerCategoryAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
[HttpGet("GetCustomerCategoryList")]
|
||||
public async Task<ActionResult<ApiSuccessResult<GetCustomerCategoryListResult>>> GetCustomerCategoryListAsync(
|
||||
CancellationToken cancellationToken,
|
||||
[FromQuery] bool isDeleted = false
|
||||
)
|
||||
{
|
||||
var request = new GetCustomerCategoryListRequest { IsDeleted = isDeleted };
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<GetCustomerCategoryListResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(GetCustomerCategoryListAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,99 @@
|
||||
using Application.Features.CustomerContactManager.Commands;
|
||||
using Application.Features.CustomerContactManager.Queries;
|
||||
using ASPNET.BackEnd.Common.Base;
|
||||
using ASPNET.BackEnd.Common.Models;
|
||||
using MediatR;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace ASPNET.BackEnd.Controllers;
|
||||
|
||||
[Route("api/[controller]")]
|
||||
public class CustomerContactController : BaseApiController
|
||||
{
|
||||
public CustomerContactController(ISender sender) : base(sender)
|
||||
{
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
[HttpPost("CreateCustomerContact")]
|
||||
public async Task<ActionResult<ApiSuccessResult<CreateCustomerContactResult>>> CreateCustomerContactAsync(CreateCustomerContactRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<CreateCustomerContactResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(CreateCustomerContactAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
[HttpPost("UpdateCustomerContact")]
|
||||
public async Task<ActionResult<ApiSuccessResult<UpdateCustomerContactResult>>> UpdateCustomerContactAsync(UpdateCustomerContactRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<UpdateCustomerContactResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(UpdateCustomerContactAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
[HttpPost("DeleteCustomerContact")]
|
||||
public async Task<ActionResult<ApiSuccessResult<DeleteCustomerContactResult>>> DeleteCustomerContactAsync(DeleteCustomerContactRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<DeleteCustomerContactResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(DeleteCustomerContactAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
[HttpGet("GetCustomerContactList")]
|
||||
public async Task<ActionResult<ApiSuccessResult<GetCustomerContactListResult>>> GetCustomerContactListAsync(
|
||||
CancellationToken cancellationToken,
|
||||
[FromQuery] bool isDeleted = false
|
||||
)
|
||||
{
|
||||
var request = new GetCustomerContactListRequest { IsDeleted = isDeleted };
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<GetCustomerContactListResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(GetCustomerContactListAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
[HttpGet("GetCustomerContactByCustomerIdList")]
|
||||
public async Task<ActionResult<ApiSuccessResult<GetCustomerContactByCustomerIdListResult>>> GetCustomerContactByCustomerIdListAsync(
|
||||
CancellationToken cancellationToken,
|
||||
[FromQuery] string customerId
|
||||
)
|
||||
{
|
||||
var request = new GetCustomerContactByCustomerIdListRequest { CustomerId = customerId };
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<GetCustomerContactByCustomerIdListResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(GetCustomerContactByCustomerIdListAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,81 @@
|
||||
using Application.Features.CustomerManager.Commands;
|
||||
using Application.Features.CustomerManager.Queries;
|
||||
using ASPNET.BackEnd.Common.Base;
|
||||
using ASPNET.BackEnd.Common.Models;
|
||||
using MediatR;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace ASPNET.BackEnd.Controllers;
|
||||
|
||||
[Route("api/[controller]")]
|
||||
public class CustomerController : BaseApiController
|
||||
{
|
||||
public CustomerController(ISender sender) : base(sender)
|
||||
{
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
[HttpPost("CreateCustomer")]
|
||||
public async Task<ActionResult<ApiSuccessResult<CreateCustomerResult>>> CreateCustomerAsync(CreateCustomerRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<CreateCustomerResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(CreateCustomerAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
[HttpPost("UpdateCustomer")]
|
||||
public async Task<ActionResult<ApiSuccessResult<UpdateCustomerResult>>> UpdateCustomerAsync(UpdateCustomerRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<UpdateCustomerResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(UpdateCustomerAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
[HttpPost("DeleteCustomer")]
|
||||
public async Task<ActionResult<ApiSuccessResult<DeleteCustomerResult>>> DeleteCustomerAsync(DeleteCustomerRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<DeleteCustomerResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(DeleteCustomerAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
[HttpGet("GetCustomerList")]
|
||||
public async Task<ActionResult<ApiSuccessResult<GetCustomerListResult>>> GetCustomerListAsync(
|
||||
CancellationToken cancellationToken,
|
||||
[FromQuery] bool isDeleted = false
|
||||
)
|
||||
{
|
||||
var request = new GetCustomerListRequest { IsDeleted = isDeleted };
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<GetCustomerListResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(GetCustomerListAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,81 @@
|
||||
using Application.Features.CustomerGroupManager.Commands;
|
||||
using Application.Features.CustomerGroupManager.Queries;
|
||||
using ASPNET.BackEnd.Common.Base;
|
||||
using ASPNET.BackEnd.Common.Models;
|
||||
using MediatR;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace ASPNET.BackEnd.Controllers;
|
||||
|
||||
[Route("api/[controller]")]
|
||||
public class CustomerGroupController : BaseApiController
|
||||
{
|
||||
public CustomerGroupController(ISender sender) : base(sender)
|
||||
{
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
[HttpPost("CreateCustomerGroup")]
|
||||
public async Task<ActionResult<ApiSuccessResult<CreateCustomerGroupResult>>> CreateCustomerGroupAsync(CreateCustomerGroupRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<CreateCustomerGroupResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(CreateCustomerGroupAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
[HttpPost("UpdateCustomerGroup")]
|
||||
public async Task<ActionResult<ApiSuccessResult<UpdateCustomerGroupResult>>> UpdateCustomerGroupAsync(UpdateCustomerGroupRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<UpdateCustomerGroupResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(UpdateCustomerGroupAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
[HttpPost("DeleteCustomerGroup")]
|
||||
public async Task<ActionResult<ApiSuccessResult<DeleteCustomerGroupResult>>> DeleteCustomerGroupAsync(DeleteCustomerGroupRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<DeleteCustomerGroupResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(DeleteCustomerGroupAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
[HttpGet("GetCustomerGroupList")]
|
||||
public async Task<ActionResult<ApiSuccessResult<GetCustomerGroupListResult>>> GetCustomerGroupListAsync(
|
||||
CancellationToken cancellationToken,
|
||||
[FromQuery] bool isDeleted = false
|
||||
)
|
||||
{
|
||||
var request = new GetCustomerGroupListRequest { IsDeleted = isDeleted };
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<GetCustomerGroupListResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(GetCustomerGroupListAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,93 @@
|
||||
using Application.Features.DashboardManager.Queries;
|
||||
using ASPNET.BackEnd.Common.Base;
|
||||
using ASPNET.BackEnd.Common.Models;
|
||||
using MediatR;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace ASPNET.BackEnd.Controllers;
|
||||
|
||||
[Route("api/[controller]")]
|
||||
public class DashboardController : BaseApiController
|
||||
{
|
||||
public DashboardController(ISender sender) : base(sender)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
[Authorize]
|
||||
[HttpGet("GetCardsDashboard")]
|
||||
public async Task<ActionResult<ApiSuccessResult<GetCardsDashboardResult>>> GetCardsDashboardAsync(
|
||||
CancellationToken cancellationToken
|
||||
)
|
||||
{
|
||||
var request = new GetCardsDashboardRequest { };
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<GetCardsDashboardResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(GetCardsDashboardAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
[Authorize]
|
||||
[HttpGet("GetSalesDashboard")]
|
||||
public async Task<ActionResult<ApiSuccessResult<GetSalesDashboardResult>>> GetSalesDashboardAsync(
|
||||
CancellationToken cancellationToken
|
||||
)
|
||||
{
|
||||
var request = new GetSalesDashboardRequest { };
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<GetSalesDashboardResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(GetSalesDashboardAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
[Authorize]
|
||||
[HttpGet("GetPurchaseDashboard")]
|
||||
public async Task<ActionResult<ApiSuccessResult<GetPurchaseDashboardResult>>> GetPurchaseDashboardAsync(
|
||||
CancellationToken cancellationToken
|
||||
)
|
||||
{
|
||||
var request = new GetPurchaseDashboardRequest { };
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<GetPurchaseDashboardResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(GetPurchaseDashboardAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
[Authorize]
|
||||
[HttpGet("GetInventoryDashboard")]
|
||||
public async Task<ActionResult<ApiSuccessResult<GetInventoryDashboardResult>>> GetInventoryDashboardAsync(
|
||||
CancellationToken cancellationToken
|
||||
)
|
||||
{
|
||||
var request = new GetInventoryDashboardRequest { };
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<GetInventoryDashboardResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(GetInventoryDashboardAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,118 @@
|
||||
using Application.Features.DeliveryOrderManager.Commands;
|
||||
using Application.Features.DeliveryOrderManager.Queries;
|
||||
using ASPNET.BackEnd.Common.Base;
|
||||
using ASPNET.BackEnd.Common.Models;
|
||||
using MediatR;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace ASPNET.BackEnd.Controllers;
|
||||
|
||||
[Route("api/[controller]")]
|
||||
public class DeliveryOrderController : BaseApiController
|
||||
{
|
||||
public DeliveryOrderController(ISender sender) : base(sender)
|
||||
{
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
[HttpPost("CreateDeliveryOrder")]
|
||||
public async Task<ActionResult<ApiSuccessResult<CreateDeliveryOrderResult>>> CreateDeliveryOrderAsync(CreateDeliveryOrderRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<CreateDeliveryOrderResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(CreateDeliveryOrderAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
[HttpPost("UpdateDeliveryOrder")]
|
||||
public async Task<ActionResult<ApiSuccessResult<UpdateDeliveryOrderResult>>> UpdateDeliveryOrderAsync(UpdateDeliveryOrderRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<UpdateDeliveryOrderResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(UpdateDeliveryOrderAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
[HttpPost("DeleteDeliveryOrder")]
|
||||
public async Task<ActionResult<ApiSuccessResult<DeleteDeliveryOrderResult>>> DeleteDeliveryOrderAsync(DeleteDeliveryOrderRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<DeleteDeliveryOrderResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(DeleteDeliveryOrderAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
[HttpGet("GetDeliveryOrderList")]
|
||||
public async Task<ActionResult<ApiSuccessResult<GetDeliveryOrderListResult>>> GetDeliveryOrderListAsync(
|
||||
CancellationToken cancellationToken,
|
||||
[FromQuery] bool isDeleted = false
|
||||
)
|
||||
{
|
||||
var request = new GetDeliveryOrderListRequest { IsDeleted = isDeleted };
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<GetDeliveryOrderListResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(GetDeliveryOrderListAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
[Authorize]
|
||||
[HttpGet("GetDeliveryOrderStatusList")]
|
||||
public async Task<ActionResult<ApiSuccessResult<GetDeliveryOrderStatusListResult>>> GetDeliveryOrderStatusListAsync(
|
||||
CancellationToken cancellationToken
|
||||
)
|
||||
{
|
||||
var request = new GetDeliveryOrderStatusListRequest { };
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<GetDeliveryOrderStatusListResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(GetDeliveryOrderStatusListAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
[Authorize]
|
||||
[HttpGet("GetDeliveryOrderSingle")]
|
||||
public async Task<ActionResult<ApiSuccessResult<GetDeliveryOrderSingleResult>>> GetDeliveryOrderSingleAsync(
|
||||
CancellationToken cancellationToken,
|
||||
[FromQuery] string id
|
||||
)
|
||||
{
|
||||
var request = new GetDeliveryOrderSingleRequest { Id = id };
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<GetDeliveryOrderSingleResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(GetDeliveryOrderSingleAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,91 @@
|
||||
using Application.Features.FileDocumentManager.Commands;
|
||||
using Application.Features.FileDocumentManager.Queries;
|
||||
using ASPNET.BackEnd.Common.Base;
|
||||
using ASPNET.BackEnd.Common.Models;
|
||||
using Infrastructure.FileDocumentManager;
|
||||
using MediatR;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace ASPNET.BackEnd.Controllers;
|
||||
|
||||
[Route("api/[controller]")]
|
||||
public class FileDocumentController : BaseApiController
|
||||
{
|
||||
public FileDocumentController(ISender sender) : base(sender)
|
||||
{
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
[HttpPost("UploadDocument")]
|
||||
public async Task<ActionResult<CreateDocumentResult>> UploadDocumentAsync(IFormFile file, CancellationToken cancellationToken)
|
||||
{
|
||||
if (file == null || file.Length == 0)
|
||||
{
|
||||
return BadRequest("Invalid file.");
|
||||
}
|
||||
|
||||
using (var memoryStream = new MemoryStream())
|
||||
{
|
||||
await file.CopyToAsync(memoryStream, cancellationToken);
|
||||
var fileData = memoryStream.ToArray();
|
||||
var extension = Path.GetExtension(file.FileName).TrimStart('.');
|
||||
|
||||
var command = new CreateDocumentRequest
|
||||
{
|
||||
OriginalFileName = file.FileName,
|
||||
Extension = extension,
|
||||
Data = fileData,
|
||||
Size = fileData.Length
|
||||
};
|
||||
|
||||
var result = await _sender.Send(command, cancellationToken);
|
||||
|
||||
if (result?.DocumentName == null)
|
||||
{
|
||||
return StatusCode(500, "An error occurred while uploading the document.");
|
||||
}
|
||||
|
||||
return Ok(new ApiSuccessResult<CreateDocumentResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(UploadDocumentAsync)}",
|
||||
Content = result
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
[Authorize]
|
||||
[HttpGet("GetDocument")]
|
||||
public async Task<IActionResult> GetDocumentAsync(
|
||||
[FromQuery] string documentName,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
if (string.IsNullOrEmpty(documentName) || Path.GetExtension(documentName) == string.Empty)
|
||||
{
|
||||
documentName = "nodocument.txt";
|
||||
}
|
||||
|
||||
var request = new GetDocumentRequest
|
||||
{
|
||||
DocumentName = documentName
|
||||
};
|
||||
|
||||
var result = await _sender.Send(request, cancellationToken);
|
||||
|
||||
if (result?.Data == null)
|
||||
{
|
||||
return NotFound("Document not found.");
|
||||
}
|
||||
|
||||
var extension = Path.GetExtension(documentName).ToLower();
|
||||
var mimeType = FileDocumentHelper.GetMimeType(extension);
|
||||
|
||||
return File(result.Data, mimeType);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,91 @@
|
||||
using Application.Features.FileImageManager.Commands;
|
||||
using Application.Features.FileImageManager.Queries;
|
||||
using ASPNET.BackEnd.Common.Base;
|
||||
using ASPNET.BackEnd.Common.Models;
|
||||
using Infrastructure.FileImageManager;
|
||||
using MediatR;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace ASPNET.BackEnd.Controllers;
|
||||
|
||||
[Route("api/[controller]")]
|
||||
public class FileImageController : BaseApiController
|
||||
{
|
||||
public FileImageController(ISender sender) : base(sender)
|
||||
{
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
[HttpPost("UploadImage")]
|
||||
public async Task<ActionResult<CreateImageResult>> UploadImageAsync(IFormFile file, CancellationToken cancellationToken)
|
||||
{
|
||||
if (file == null || file.Length == 0)
|
||||
{
|
||||
return BadRequest("Invalid file.");
|
||||
}
|
||||
|
||||
using (var memoryStream = new MemoryStream())
|
||||
{
|
||||
await file.CopyToAsync(memoryStream, cancellationToken);
|
||||
var fileData = memoryStream.ToArray();
|
||||
var extension = Path.GetExtension(file.FileName).TrimStart('.');
|
||||
|
||||
var command = new CreateImageRequest
|
||||
{
|
||||
OriginalFileName = file.FileName,
|
||||
Extension = extension,
|
||||
Data = fileData,
|
||||
Size = fileData.Length
|
||||
};
|
||||
|
||||
var result = await _sender.Send(command, cancellationToken);
|
||||
|
||||
if (result?.ImageName == null)
|
||||
{
|
||||
return StatusCode(500, "An error occurred while uploading the image.");
|
||||
}
|
||||
|
||||
return Ok(new ApiSuccessResult<CreateImageResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(UploadImageAsync)}",
|
||||
Content = result
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
[Authorize]
|
||||
[HttpGet("GetImage")]
|
||||
public async Task<IActionResult> GetImageAsync(
|
||||
[FromQuery] string imageName,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
if (string.IsNullOrEmpty(imageName) || Path.GetExtension(imageName) == string.Empty)
|
||||
{
|
||||
imageName = "noimage.png";
|
||||
}
|
||||
|
||||
var request = new GetImageRequest
|
||||
{
|
||||
ImageName = imageName
|
||||
};
|
||||
|
||||
var result = await _sender.Send(request, cancellationToken);
|
||||
|
||||
if (result?.Data == null)
|
||||
{
|
||||
return NotFound("Image not found.");
|
||||
}
|
||||
|
||||
var extension = Path.GetExtension(imageName).ToLower();
|
||||
var mimeType = FileImageHelper.GetMimeType(extension);
|
||||
|
||||
return File(result.Data, mimeType);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,118 @@
|
||||
using Application.Features.GoodsReceiveManager.Commands;
|
||||
using Application.Features.GoodsReceiveManager.Queries;
|
||||
using ASPNET.BackEnd.Common.Base;
|
||||
using ASPNET.BackEnd.Common.Models;
|
||||
using MediatR;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace ASPNET.BackEnd.Controllers;
|
||||
|
||||
[Route("api/[controller]")]
|
||||
public class GoodsReceiveController : BaseApiController
|
||||
{
|
||||
public GoodsReceiveController(ISender sender) : base(sender)
|
||||
{
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
[HttpPost("CreateGoodsReceive")]
|
||||
public async Task<ActionResult<ApiSuccessResult<CreateGoodsReceiveResult>>> CreateGoodsReceiveAsync(CreateGoodsReceiveRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<CreateGoodsReceiveResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(CreateGoodsReceiveAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
[HttpPost("UpdateGoodsReceive")]
|
||||
public async Task<ActionResult<ApiSuccessResult<UpdateGoodsReceiveResult>>> UpdateGoodsReceiveAsync(UpdateGoodsReceiveRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<UpdateGoodsReceiveResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(UpdateGoodsReceiveAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
[HttpPost("DeleteGoodsReceive")]
|
||||
public async Task<ActionResult<ApiSuccessResult<DeleteGoodsReceiveResult>>> DeleteGoodsReceiveAsync(DeleteGoodsReceiveRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<DeleteGoodsReceiveResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(DeleteGoodsReceiveAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
[HttpGet("GetGoodsReceiveList")]
|
||||
public async Task<ActionResult<ApiSuccessResult<GetGoodsReceiveListResult>>> GetGoodsReceiveListAsync(
|
||||
CancellationToken cancellationToken,
|
||||
[FromQuery] bool isDeleted = false
|
||||
)
|
||||
{
|
||||
var request = new GetGoodsReceiveListRequest { IsDeleted = isDeleted };
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<GetGoodsReceiveListResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(GetGoodsReceiveListAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
[Authorize]
|
||||
[HttpGet("GetGoodsReceiveStatusList")]
|
||||
public async Task<ActionResult<ApiSuccessResult<GetGoodsReceiveStatusListResult>>> GetGoodsReceiveStatusListAsync(
|
||||
CancellationToken cancellationToken
|
||||
)
|
||||
{
|
||||
var request = new GetGoodsReceiveStatusListRequest { };
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<GetGoodsReceiveStatusListResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(GetGoodsReceiveStatusListAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
[Authorize]
|
||||
[HttpGet("GetGoodsReceiveSingle")]
|
||||
public async Task<ActionResult<ApiSuccessResult<GetGoodsReceiveSingleResult>>> GetGoodsReceiveSingleAsync(
|
||||
CancellationToken cancellationToken,
|
||||
[FromQuery] string id
|
||||
)
|
||||
{
|
||||
var request = new GetGoodsReceiveSingleRequest { Id = id };
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<GetGoodsReceiveSingleResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(GetGoodsReceiveSingleAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,659 @@
|
||||
using Application.Features.InventoryTransactionManager.Commands;
|
||||
using Application.Features.InventoryTransactionManager.Queries;
|
||||
using ASPNET.BackEnd.Common.Base;
|
||||
using ASPNET.BackEnd.Common.Models;
|
||||
using MediatR;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace ASPNET.BackEnd.Controllers;
|
||||
|
||||
[Route("api/[controller]")]
|
||||
public class InventoryTransactionController : BaseApiController
|
||||
{
|
||||
public InventoryTransactionController(ISender sender) : base(sender)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
[Authorize]
|
||||
[HttpGet("GetInventoryTransactionList")]
|
||||
public async Task<ActionResult<ApiSuccessResult<GetInventoryTransactionListResult>>> GetInventoryTransactionListAsync(
|
||||
CancellationToken cancellationToken
|
||||
)
|
||||
{
|
||||
var request = new GetInventoryTransactionListRequest { };
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<GetInventoryTransactionListResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(GetInventoryTransactionListAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
[Authorize]
|
||||
[HttpGet("GetInventoryStockList")]
|
||||
public async Task<ActionResult<ApiSuccessResult<GetInventoryStockListResult>>> GetInventoryStockListAsync(
|
||||
CancellationToken cancellationToken
|
||||
)
|
||||
{
|
||||
var request = new GetInventoryStockListRequest { };
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<GetInventoryStockListResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(GetInventoryStockListAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
[HttpPost("DeliveryOrderCreateInvenTrans")]
|
||||
public async Task<ActionResult<ApiSuccessResult<DeliveryOrderCreateInvenTransResult>>> DeliveryOrderCreateInvenTransAsync(DeliveryOrderCreateInvenTransRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<DeliveryOrderCreateInvenTransResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(DeliveryOrderCreateInvenTransAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
[HttpPost("DeliveryOrderUpdateInvenTrans")]
|
||||
public async Task<ActionResult<ApiSuccessResult<DeliveryOrderUpdateInvenTransResult>>> DeliveryOrderUpdateInvenTransAsync(DeliveryOrderUpdateInvenTransRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<DeliveryOrderUpdateInvenTransResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(DeliveryOrderUpdateInvenTransAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
[HttpPost("DeliveryOrderDeleteInvenTrans")]
|
||||
public async Task<ActionResult<ApiSuccessResult<DeliveryOrderDeleteInvenTransResult>>> DeliveryOrderDeleteInvenTransAsync(DeliveryOrderDeleteInvenTransRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<DeliveryOrderDeleteInvenTransResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(DeliveryOrderDeleteInvenTransAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
[HttpGet("DeliveryOrderGetInvenTransList")]
|
||||
public async Task<ActionResult<ApiSuccessResult<DeliveryOrderGetInvenTransListResult>>> DeliveryOrderGetInvenTransListAsync(
|
||||
CancellationToken cancellationToken,
|
||||
[FromQuery] string moduleId
|
||||
)
|
||||
{
|
||||
var request = new DeliveryOrderGetInvenTransListRequest { ModuleId = moduleId };
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<DeliveryOrderGetInvenTransListResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(DeliveryOrderGetInvenTransListAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
[HttpPost("SalesReturnCreateInvenTrans")]
|
||||
public async Task<ActionResult<ApiSuccessResult<SalesReturnCreateInvenTransResult>>> SalesReturnCreateInvenTransAsync(SalesReturnCreateInvenTransRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<SalesReturnCreateInvenTransResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(SalesReturnCreateInvenTransAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
[HttpPost("SalesReturnUpdateInvenTrans")]
|
||||
public async Task<ActionResult<ApiSuccessResult<SalesReturnUpdateInvenTransResult>>> SalesReturnUpdateInvenTransAsync(SalesReturnUpdateInvenTransRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<SalesReturnUpdateInvenTransResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(SalesReturnUpdateInvenTransAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
[HttpPost("SalesReturnDeleteInvenTrans")]
|
||||
public async Task<ActionResult<ApiSuccessResult<SalesReturnDeleteInvenTransResult>>> SalesReturnDeleteInvenTransAsync(SalesReturnDeleteInvenTransRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<SalesReturnDeleteInvenTransResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(SalesReturnDeleteInvenTransAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
[HttpGet("SalesReturnGetInvenTransList")]
|
||||
public async Task<ActionResult<ApiSuccessResult<SalesReturnGetInvenTransListResult>>> SalesReturnGetInvenTransListAsync(
|
||||
CancellationToken cancellationToken,
|
||||
[FromQuery] string moduleId
|
||||
)
|
||||
{
|
||||
var request = new SalesReturnGetInvenTransListRequest { ModuleId = moduleId };
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<SalesReturnGetInvenTransListResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(SalesReturnGetInvenTransListAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
[Authorize]
|
||||
[HttpPost("GoodsReceiveCreateInvenTrans")]
|
||||
public async Task<ActionResult<ApiSuccessResult<GoodsReceiveCreateInvenTransResult>>> GoodsReceiveCreateInvenTransAsync(GoodsReceiveCreateInvenTransRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<GoodsReceiveCreateInvenTransResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(GoodsReceiveCreateInvenTransAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
[HttpPost("GoodsReceiveUpdateInvenTrans")]
|
||||
public async Task<ActionResult<ApiSuccessResult<GoodsReceiveUpdateInvenTransResult>>> GoodsReceiveUpdateInvenTransAsync(GoodsReceiveUpdateInvenTransRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<GoodsReceiveUpdateInvenTransResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(GoodsReceiveUpdateInvenTransAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
[HttpPost("GoodsReceiveDeleteInvenTrans")]
|
||||
public async Task<ActionResult<ApiSuccessResult<GoodsReceiveDeleteInvenTransResult>>> GoodsReceiveDeleteInvenTransAsync(GoodsReceiveDeleteInvenTransRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<GoodsReceiveDeleteInvenTransResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(GoodsReceiveDeleteInvenTransAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
[HttpGet("GoodsReceiveGetInvenTransList")]
|
||||
public async Task<ActionResult<ApiSuccessResult<GoodsReceiveGetInvenTransListResult>>> GoodsReceiveGetInvenTransListAsync(
|
||||
CancellationToken cancellationToken,
|
||||
[FromQuery] string moduleId
|
||||
)
|
||||
{
|
||||
var request = new GoodsReceiveGetInvenTransListRequest { ModuleId = moduleId };
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<GoodsReceiveGetInvenTransListResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(GoodsReceiveGetInvenTransListAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
[Authorize]
|
||||
[HttpPost("PurchaseReturnCreateInvenTrans")]
|
||||
public async Task<ActionResult<ApiSuccessResult<PurchaseReturnCreateInvenTransResult>>> PurchaseReturnCreateInvenTransAsync(PurchaseReturnCreateInvenTransRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<PurchaseReturnCreateInvenTransResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(PurchaseReturnCreateInvenTransAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
[HttpPost("PurchaseReturnUpdateInvenTrans")]
|
||||
public async Task<ActionResult<ApiSuccessResult<PurchaseReturnUpdateInvenTransResult>>> PurchaseReturnUpdateInvenTransAsync(PurchaseReturnUpdateInvenTransRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<PurchaseReturnUpdateInvenTransResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(PurchaseReturnUpdateInvenTransAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
[HttpPost("PurchaseReturnDeleteInvenTrans")]
|
||||
public async Task<ActionResult<ApiSuccessResult<PurchaseReturnDeleteInvenTransResult>>> PurchaseReturnDeleteInvenTransAsync(PurchaseReturnDeleteInvenTransRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<PurchaseReturnDeleteInvenTransResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(PurchaseReturnDeleteInvenTransAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
[HttpGet("PurchaseReturnGetInvenTransList")]
|
||||
public async Task<ActionResult<ApiSuccessResult<PurchaseReturnGetInvenTransListResult>>> PurchaseReturnGetInvenTransListAsync(
|
||||
CancellationToken cancellationToken,
|
||||
[FromQuery] string moduleId
|
||||
)
|
||||
{
|
||||
var request = new PurchaseReturnGetInvenTransListRequest { ModuleId = moduleId };
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<PurchaseReturnGetInvenTransListResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(PurchaseReturnGetInvenTransListAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
[HttpPost("TransferOutCreateInvenTrans")]
|
||||
public async Task<ActionResult<ApiSuccessResult<TransferOutCreateInvenTransResult>>> TransferOutCreateInvenTransAsync(TransferOutCreateInvenTransRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<TransferOutCreateInvenTransResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(TransferOutCreateInvenTransAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
[HttpPost("TransferOutUpdateInvenTrans")]
|
||||
public async Task<ActionResult<ApiSuccessResult<TransferOutUpdateInvenTransResult>>> TransferOutUpdateInvenTransAsync(TransferOutUpdateInvenTransRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<TransferOutUpdateInvenTransResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(TransferOutUpdateInvenTransAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
[HttpPost("TransferOutDeleteInvenTrans")]
|
||||
public async Task<ActionResult<ApiSuccessResult<TransferOutDeleteInvenTransResult>>> TransferOutDeleteInvenTransAsync(TransferOutDeleteInvenTransRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<TransferOutDeleteInvenTransResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(TransferOutDeleteInvenTransAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
[HttpGet("TransferOutGetInvenTransList")]
|
||||
public async Task<ActionResult<ApiSuccessResult<TransferOutGetInvenTransListResult>>> TransferOutGetInvenTransListAsync(
|
||||
CancellationToken cancellationToken,
|
||||
[FromQuery] string moduleId
|
||||
)
|
||||
{
|
||||
var request = new TransferOutGetInvenTransListRequest { ModuleId = moduleId };
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<TransferOutGetInvenTransListResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(TransferOutGetInvenTransListAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
[HttpPost("TransferInCreateInvenTrans")]
|
||||
public async Task<ActionResult<ApiSuccessResult<TransferInCreateInvenTransResult>>> TransferInCreateInvenTransAsync(TransferInCreateInvenTransRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<TransferInCreateInvenTransResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(TransferInCreateInvenTransAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
[HttpPost("TransferInUpdateInvenTrans")]
|
||||
public async Task<ActionResult<ApiSuccessResult<TransferInUpdateInvenTransResult>>> TransferInUpdateInvenTransAsync(TransferInUpdateInvenTransRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<TransferInUpdateInvenTransResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(TransferInUpdateInvenTransAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
[HttpPost("TransferInDeleteInvenTrans")]
|
||||
public async Task<ActionResult<ApiSuccessResult<TransferInDeleteInvenTransResult>>> TransferInDeleteInvenTransAsync(TransferInDeleteInvenTransRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<TransferInDeleteInvenTransResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(TransferInDeleteInvenTransAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
[HttpGet("TransferInGetInvenTransList")]
|
||||
public async Task<ActionResult<ApiSuccessResult<TransferInGetInvenTransListResult>>> TransferInGetInvenTransListAsync(
|
||||
CancellationToken cancellationToken,
|
||||
[FromQuery] string moduleId
|
||||
)
|
||||
{
|
||||
var request = new TransferInGetInvenTransListRequest { ModuleId = moduleId };
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<TransferInGetInvenTransListResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(TransferInGetInvenTransListAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
[HttpPost("PositiveAdjustmentCreateInvenTrans")]
|
||||
public async Task<ActionResult<ApiSuccessResult<PositiveAdjustmentCreateInvenTransResult>>> PositiveAdjustmentCreateInvenTransAsync(PositiveAdjustmentCreateInvenTransRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<PositiveAdjustmentCreateInvenTransResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(PositiveAdjustmentCreateInvenTransAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
[HttpPost("PositiveAdjustmentUpdateInvenTrans")]
|
||||
public async Task<ActionResult<ApiSuccessResult<PositiveAdjustmentUpdateInvenTransResult>>> PositiveAdjustmentUpdateInvenTransAsync(PositiveAdjustmentUpdateInvenTransRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<PositiveAdjustmentUpdateInvenTransResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(PositiveAdjustmentUpdateInvenTransAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
[HttpPost("PositiveAdjustmentDeleteInvenTrans")]
|
||||
public async Task<ActionResult<ApiSuccessResult<PositiveAdjustmentDeleteInvenTransResult>>> PositiveAdjustmentDeleteInvenTransAsync(PositiveAdjustmentDeleteInvenTransRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<PositiveAdjustmentDeleteInvenTransResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(PositiveAdjustmentDeleteInvenTransAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
[HttpGet("PositiveAdjustmentGetInvenTransList")]
|
||||
public async Task<ActionResult<ApiSuccessResult<PositiveAdjustmentGetInvenTransListResult>>> PositiveAdjustmentGetInvenTransListAsync(
|
||||
CancellationToken cancellationToken,
|
||||
[FromQuery] string moduleId
|
||||
)
|
||||
{
|
||||
var request = new PositiveAdjustmentGetInvenTransListRequest { ModuleId = moduleId };
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<PositiveAdjustmentGetInvenTransListResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(PositiveAdjustmentGetInvenTransListAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
[HttpPost("NegativeAdjustmentCreateInvenTrans")]
|
||||
public async Task<ActionResult<ApiSuccessResult<NegativeAdjustmentCreateInvenTransResult>>> NegativeAdjustmentCreateInvenTransAsync(NegativeAdjustmentCreateInvenTransRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<NegativeAdjustmentCreateInvenTransResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(NegativeAdjustmentCreateInvenTransAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
[HttpPost("NegativeAdjustmentUpdateInvenTrans")]
|
||||
public async Task<ActionResult<ApiSuccessResult<NegativeAdjustmentUpdateInvenTransResult>>> NegativeAdjustmentUpdateInvenTransAsync(NegativeAdjustmentUpdateInvenTransRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<NegativeAdjustmentUpdateInvenTransResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(NegativeAdjustmentUpdateInvenTransAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
[HttpPost("NegativeAdjustmentDeleteInvenTrans")]
|
||||
public async Task<ActionResult<ApiSuccessResult<NegativeAdjustmentDeleteInvenTransResult>>> NegativeAdjustmentDeleteInvenTransAsync(NegativeAdjustmentDeleteInvenTransRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<NegativeAdjustmentDeleteInvenTransResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(NegativeAdjustmentDeleteInvenTransAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
[HttpGet("NegativeAdjustmentGetInvenTransList")]
|
||||
public async Task<ActionResult<ApiSuccessResult<NegativeAdjustmentGetInvenTransListResult>>> NegativeAdjustmentGetInvenTransListAsync(
|
||||
CancellationToken cancellationToken,
|
||||
[FromQuery] string moduleId
|
||||
)
|
||||
{
|
||||
var request = new NegativeAdjustmentGetInvenTransListRequest { ModuleId = moduleId };
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<NegativeAdjustmentGetInvenTransListResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(NegativeAdjustmentGetInvenTransListAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
[HttpPost("ScrappingCreateInvenTrans")]
|
||||
public async Task<ActionResult<ApiSuccessResult<ScrappingCreateInvenTransResult>>> ScrappingCreateInvenTransAsync(ScrappingCreateInvenTransRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<ScrappingCreateInvenTransResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(ScrappingCreateInvenTransAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
[HttpPost("ScrappingUpdateInvenTrans")]
|
||||
public async Task<ActionResult<ApiSuccessResult<ScrappingUpdateInvenTransResult>>> ScrappingUpdateInvenTransAsync(ScrappingUpdateInvenTransRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<ScrappingUpdateInvenTransResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(ScrappingUpdateInvenTransAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
[HttpPost("ScrappingDeleteInvenTrans")]
|
||||
public async Task<ActionResult<ApiSuccessResult<ScrappingDeleteInvenTransResult>>> ScrappingDeleteInvenTransAsync(ScrappingDeleteInvenTransRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<ScrappingDeleteInvenTransResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(ScrappingDeleteInvenTransAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
[HttpGet("ScrappingGetInvenTransList")]
|
||||
public async Task<ActionResult<ApiSuccessResult<ScrappingGetInvenTransListResult>>> ScrappingGetInvenTransListAsync(
|
||||
CancellationToken cancellationToken,
|
||||
[FromQuery] string moduleId
|
||||
)
|
||||
{
|
||||
var request = new ScrappingGetInvenTransListRequest { ModuleId = moduleId };
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<ScrappingGetInvenTransListResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(ScrappingGetInvenTransListAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
[HttpPost("StockCountCreateInvenTrans")]
|
||||
public async Task<ActionResult<ApiSuccessResult<StockCountCreateInvenTransResult>>> StockCountCreateInvenTransAsync(StockCountCreateInvenTransRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<StockCountCreateInvenTransResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(StockCountCreateInvenTransAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
[HttpPost("StockCountUpdateInvenTrans")]
|
||||
public async Task<ActionResult<ApiSuccessResult<StockCountUpdateInvenTransResult>>> StockCountUpdateInvenTransAsync(StockCountUpdateInvenTransRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<StockCountUpdateInvenTransResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(StockCountUpdateInvenTransAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
[HttpPost("StockCountDeleteInvenTrans")]
|
||||
public async Task<ActionResult<ApiSuccessResult<StockCountDeleteInvenTransResult>>> StockCountDeleteInvenTransAsync(StockCountDeleteInvenTransRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<StockCountDeleteInvenTransResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(StockCountDeleteInvenTransAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
[HttpGet("StockCountGetInvenTransList")]
|
||||
public async Task<ActionResult<ApiSuccessResult<StockCountGetInvenTransListResult>>> StockCountGetInvenTransListAsync(
|
||||
CancellationToken cancellationToken,
|
||||
[FromQuery] string moduleId
|
||||
)
|
||||
{
|
||||
var request = new StockCountGetInvenTransListRequest { ModuleId = moduleId };
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<StockCountGetInvenTransListResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(StockCountGetInvenTransListAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,118 @@
|
||||
using Application.Features.NegativeAdjustmentManager.Commands;
|
||||
using Application.Features.NegativeAdjustmentManager.Queries;
|
||||
using ASPNET.BackEnd.Common.Base;
|
||||
using ASPNET.BackEnd.Common.Models;
|
||||
using MediatR;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace ASPNET.BackEnd.Controllers;
|
||||
|
||||
[Route("api/[controller]")]
|
||||
public class NegativeAdjustmentController : BaseApiController
|
||||
{
|
||||
public NegativeAdjustmentController(ISender sender) : base(sender)
|
||||
{
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
[HttpPost("CreateNegativeAdjustment")]
|
||||
public async Task<ActionResult<ApiSuccessResult<CreateNegativeAdjustmentResult>>> CreateNegativeAdjustmentAsync(CreateNegativeAdjustmentRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<CreateNegativeAdjustmentResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(CreateNegativeAdjustmentAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
[HttpPost("UpdateNegativeAdjustment")]
|
||||
public async Task<ActionResult<ApiSuccessResult<UpdateNegativeAdjustmentResult>>> UpdateNegativeAdjustmentAsync(UpdateNegativeAdjustmentRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<UpdateNegativeAdjustmentResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(UpdateNegativeAdjustmentAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
[HttpPost("DeleteNegativeAdjustment")]
|
||||
public async Task<ActionResult<ApiSuccessResult<DeleteNegativeAdjustmentResult>>> DeleteNegativeAdjustmentAsync(DeleteNegativeAdjustmentRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<DeleteNegativeAdjustmentResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(DeleteNegativeAdjustmentAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
[HttpGet("GetNegativeAdjustmentList")]
|
||||
public async Task<ActionResult<ApiSuccessResult<GetNegativeAdjustmentListResult>>> GetNegativeAdjustmentListAsync(
|
||||
CancellationToken cancellationToken,
|
||||
[FromQuery] bool isDeleted = false
|
||||
)
|
||||
{
|
||||
var request = new GetNegativeAdjustmentListRequest { IsDeleted = isDeleted };
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<GetNegativeAdjustmentListResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(GetNegativeAdjustmentListAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
[Authorize]
|
||||
[HttpGet("GetNegativeAdjustmentStatusList")]
|
||||
public async Task<ActionResult<ApiSuccessResult<GetNegativeAdjustmentStatusListResult>>> GetNegativeAdjustmentStatusListAsync(
|
||||
CancellationToken cancellationToken
|
||||
)
|
||||
{
|
||||
var request = new GetNegativeAdjustmentStatusListRequest { };
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<GetNegativeAdjustmentStatusListResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(GetNegativeAdjustmentStatusListAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
[Authorize]
|
||||
[HttpGet("GetNegativeAdjustmentSingle")]
|
||||
public async Task<ActionResult<ApiSuccessResult<GetNegativeAdjustmentSingleResult>>> GetNegativeAdjustmentSingleAsync(
|
||||
CancellationToken cancellationToken,
|
||||
[FromQuery] string id
|
||||
)
|
||||
{
|
||||
var request = new GetNegativeAdjustmentSingleRequest { Id = id };
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<GetNegativeAdjustmentSingleResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(GetNegativeAdjustmentSingleAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
using Application.Features.NumberSequenceManager.Queries;
|
||||
using ASPNET.BackEnd.Common.Base;
|
||||
using ASPNET.BackEnd.Common.Models;
|
||||
using MediatR;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace ASPNET.BackEnd.Controllers;
|
||||
|
||||
[Route("api/[controller]")]
|
||||
public class NumberSequenceController : BaseApiController
|
||||
{
|
||||
public NumberSequenceController(ISender sender) : base(sender)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
[Authorize]
|
||||
[HttpGet("GetNumberSequenceList")]
|
||||
public async Task<ActionResult<ApiSuccessResult<GetNumberSequenceListResult>>> GetNumberSequenceListAsync(
|
||||
CancellationToken cancellationToken,
|
||||
[FromQuery] bool isDeleted = false
|
||||
)
|
||||
{
|
||||
var request = new GetNumberSequenceListRequest { IsDeleted = isDeleted };
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<GetNumberSequenceListResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(GetNumberSequenceListAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,118 @@
|
||||
using Application.Features.PositiveAdjustmentManager.Commands;
|
||||
using Application.Features.PositiveAdjustmentManager.Queries;
|
||||
using ASPNET.BackEnd.Common.Base;
|
||||
using ASPNET.BackEnd.Common.Models;
|
||||
using MediatR;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace ASPNET.BackEnd.Controllers;
|
||||
|
||||
[Route("api/[controller]")]
|
||||
public class PositiveAdjustmentController : BaseApiController
|
||||
{
|
||||
public PositiveAdjustmentController(ISender sender) : base(sender)
|
||||
{
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
[HttpPost("CreatePositiveAdjustment")]
|
||||
public async Task<ActionResult<ApiSuccessResult<CreatePositiveAdjustmentResult>>> CreatePositiveAdjustmentAsync(CreatePositiveAdjustmentRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<CreatePositiveAdjustmentResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(CreatePositiveAdjustmentAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
[HttpPost("UpdatePositiveAdjustment")]
|
||||
public async Task<ActionResult<ApiSuccessResult<UpdatePositiveAdjustmentResult>>> UpdatePositiveAdjustmentAsync(UpdatePositiveAdjustmentRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<UpdatePositiveAdjustmentResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(UpdatePositiveAdjustmentAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
[HttpPost("DeletePositiveAdjustment")]
|
||||
public async Task<ActionResult<ApiSuccessResult<DeletePositiveAdjustmentResult>>> DeletePositiveAdjustmentAsync(DeletePositiveAdjustmentRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<DeletePositiveAdjustmentResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(DeletePositiveAdjustmentAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
[HttpGet("GetPositiveAdjustmentList")]
|
||||
public async Task<ActionResult<ApiSuccessResult<GetPositiveAdjustmentListResult>>> GetPositiveAdjustmentListAsync(
|
||||
CancellationToken cancellationToken,
|
||||
[FromQuery] bool isDeleted = false
|
||||
)
|
||||
{
|
||||
var request = new GetPositiveAdjustmentListRequest { IsDeleted = isDeleted };
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<GetPositiveAdjustmentListResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(GetPositiveAdjustmentListAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
[Authorize]
|
||||
[HttpGet("GetPositiveAdjustmentStatusList")]
|
||||
public async Task<ActionResult<ApiSuccessResult<GetPositiveAdjustmentStatusListResult>>> GetPositiveAdjustmentStatusListAsync(
|
||||
CancellationToken cancellationToken
|
||||
)
|
||||
{
|
||||
var request = new GetPositiveAdjustmentStatusListRequest { };
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<GetPositiveAdjustmentStatusListResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(GetPositiveAdjustmentStatusListAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
[Authorize]
|
||||
[HttpGet("GetPositiveAdjustmentSingle")]
|
||||
public async Task<ActionResult<ApiSuccessResult<GetPositiveAdjustmentSingleResult>>> GetPositiveAdjustmentSingleAsync(
|
||||
CancellationToken cancellationToken,
|
||||
[FromQuery] string id
|
||||
)
|
||||
{
|
||||
var request = new GetPositiveAdjustmentSingleRequest { Id = id };
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<GetPositiveAdjustmentSingleResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(GetPositiveAdjustmentSingleAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,81 @@
|
||||
using Application.Features.ProductManager.Commands;
|
||||
using Application.Features.ProductManager.Queries;
|
||||
using ASPNET.BackEnd.Common.Base;
|
||||
using ASPNET.BackEnd.Common.Models;
|
||||
using MediatR;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace ASPNET.BackEnd.Controllers;
|
||||
|
||||
[Route("api/[controller]")]
|
||||
public class ProductController : BaseApiController
|
||||
{
|
||||
public ProductController(ISender sender) : base(sender)
|
||||
{
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
[HttpPost("CreateProduct")]
|
||||
public async Task<ActionResult<ApiSuccessResult<CreateProductResult>>> CreateProductAsync(CreateProductRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<CreateProductResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(CreateProductAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
[HttpPost("UpdateProduct")]
|
||||
public async Task<ActionResult<ApiSuccessResult<UpdateProductResult>>> UpdateProductAsync(UpdateProductRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<UpdateProductResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(UpdateProductAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
[HttpPost("DeleteProduct")]
|
||||
public async Task<ActionResult<ApiSuccessResult<DeleteProductResult>>> DeleteProductAsync(DeleteProductRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<DeleteProductResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(DeleteProductAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
[HttpGet("GetProductList")]
|
||||
public async Task<ActionResult<ApiSuccessResult<GetProductListResult>>> GetProductListAsync(
|
||||
CancellationToken cancellationToken,
|
||||
[FromQuery] bool isDeleted = false
|
||||
)
|
||||
{
|
||||
var request = new GetProductListRequest { IsDeleted = isDeleted };
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<GetProductListResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(GetProductListAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,81 @@
|
||||
using Application.Features.ProductGroupManager.Commands;
|
||||
using Application.Features.ProductGroupManager.Queries;
|
||||
using ASPNET.BackEnd.Common.Base;
|
||||
using ASPNET.BackEnd.Common.Models;
|
||||
using MediatR;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace ASPNET.BackEnd.Controllers;
|
||||
|
||||
[Route("api/[controller]")]
|
||||
public class ProductGroupController : BaseApiController
|
||||
{
|
||||
public ProductGroupController(ISender sender) : base(sender)
|
||||
{
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
[HttpPost("CreateProductGroup")]
|
||||
public async Task<ActionResult<ApiSuccessResult<CreateProductGroupResult>>> CreateProductGroupAsync(CreateProductGroupRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<CreateProductGroupResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(CreateProductGroupAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
[HttpPost("UpdateProductGroup")]
|
||||
public async Task<ActionResult<ApiSuccessResult<UpdateProductGroupResult>>> UpdateProductGroupAsync(UpdateProductGroupRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<UpdateProductGroupResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(UpdateProductGroupAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
[HttpPost("DeleteProductGroup")]
|
||||
public async Task<ActionResult<ApiSuccessResult<DeleteProductGroupResult>>> DeleteProductGroupAsync(DeleteProductGroupRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<DeleteProductGroupResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(DeleteProductGroupAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
[HttpGet("GetProductGroupList")]
|
||||
public async Task<ActionResult<ApiSuccessResult<GetProductGroupListResult>>> GetProductGroupListAsync(
|
||||
CancellationToken cancellationToken,
|
||||
[FromQuery] bool isDeleted = false
|
||||
)
|
||||
{
|
||||
var request = new GetProductGroupListRequest { IsDeleted = isDeleted };
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<GetProductGroupListResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(GetProductGroupListAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,117 @@
|
||||
using Application.Features.PurchaseOrderManager.Commands;
|
||||
using Application.Features.PurchaseOrderManager.Queries;
|
||||
using ASPNET.BackEnd.Common.Base;
|
||||
using ASPNET.BackEnd.Common.Models;
|
||||
using MediatR;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace ASPNET.BackEnd.Controllers;
|
||||
|
||||
[Route("api/[controller]")]
|
||||
public class PurchaseOrderController : BaseApiController
|
||||
{
|
||||
public PurchaseOrderController(ISender sender) : base(sender)
|
||||
{
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
[HttpPost("CreatePurchaseOrder")]
|
||||
public async Task<ActionResult<ApiSuccessResult<CreatePurchaseOrderResult>>> CreatePurchaseOrderAsync(CreatePurchaseOrderRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<CreatePurchaseOrderResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(CreatePurchaseOrderAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
[HttpPost("UpdatePurchaseOrder")]
|
||||
public async Task<ActionResult<ApiSuccessResult<UpdatePurchaseOrderResult>>> UpdatePurchaseOrderAsync(UpdatePurchaseOrderRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<UpdatePurchaseOrderResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(UpdatePurchaseOrderAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
[HttpPost("DeletePurchaseOrder")]
|
||||
public async Task<ActionResult<ApiSuccessResult<DeletePurchaseOrderResult>>> DeletePurchaseOrderAsync(DeletePurchaseOrderRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<DeletePurchaseOrderResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(DeletePurchaseOrderAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
[HttpGet("GetPurchaseOrderList")]
|
||||
public async Task<ActionResult<ApiSuccessResult<GetPurchaseOrderListResult>>> GetPurchaseOrderListAsync(
|
||||
CancellationToken cancellationToken,
|
||||
[FromQuery] bool isDeleted = false
|
||||
)
|
||||
{
|
||||
var request = new GetPurchaseOrderListRequest { IsDeleted = isDeleted };
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<GetPurchaseOrderListResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(GetPurchaseOrderListAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
[Authorize]
|
||||
[HttpGet("GetPurchaseOrderStatusList")]
|
||||
public async Task<ActionResult<ApiSuccessResult<GetPurchaseOrderStatusListResult>>> GetPurchaseOrderStatusListAsync(
|
||||
CancellationToken cancellationToken
|
||||
)
|
||||
{
|
||||
var request = new GetPurchaseOrderStatusListRequest { };
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<GetPurchaseOrderStatusListResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(GetPurchaseOrderStatusListAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
[HttpGet("GetPurchaseOrderSingle")]
|
||||
public async Task<ActionResult<ApiSuccessResult<GetPurchaseOrderSingleResult>>> GetPurchaseOrderSingleAsync(
|
||||
CancellationToken cancellationToken,
|
||||
[FromQuery] string id
|
||||
)
|
||||
{
|
||||
var request = new GetPurchaseOrderSingleRequest { Id = id };
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<GetPurchaseOrderSingleResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(GetPurchaseOrderSingleAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,99 @@
|
||||
using Application.Features.PurchaseOrderItemManager.Commands;
|
||||
using Application.Features.PurchaseOrderItemManager.Queries;
|
||||
using ASPNET.BackEnd.Common.Base;
|
||||
using ASPNET.BackEnd.Common.Models;
|
||||
using MediatR;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace ASPNET.BackEnd.Controllers;
|
||||
|
||||
[Route("api/[controller]")]
|
||||
public class PurchaseOrderItemController : BaseApiController
|
||||
{
|
||||
public PurchaseOrderItemController(ISender sender) : base(sender)
|
||||
{
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
[HttpPost("CreatePurchaseOrderItem")]
|
||||
public async Task<ActionResult<ApiSuccessResult<CreatePurchaseOrderItemResult>>> CreatePurchaseOrderItemAsync(CreatePurchaseOrderItemRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<CreatePurchaseOrderItemResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(CreatePurchaseOrderItemAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
[HttpPost("UpdatePurchaseOrderItem")]
|
||||
public async Task<ActionResult<ApiSuccessResult<UpdatePurchaseOrderItemResult>>> UpdatePurchaseOrderItemAsync(UpdatePurchaseOrderItemRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<UpdatePurchaseOrderItemResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(UpdatePurchaseOrderItemAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
[HttpPost("DeletePurchaseOrderItem")]
|
||||
public async Task<ActionResult<ApiSuccessResult<DeletePurchaseOrderItemResult>>> DeletePurchaseOrderItemAsync(DeletePurchaseOrderItemRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<DeletePurchaseOrderItemResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(DeletePurchaseOrderItemAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
[HttpGet("GetPurchaseOrderItemList")]
|
||||
public async Task<ActionResult<ApiSuccessResult<GetPurchaseOrderItemListResult>>> GetPurchaseOrderItemListAsync(
|
||||
CancellationToken cancellationToken,
|
||||
[FromQuery] bool isDeleted = false
|
||||
)
|
||||
{
|
||||
var request = new GetPurchaseOrderItemListRequest { IsDeleted = isDeleted };
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<GetPurchaseOrderItemListResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(GetPurchaseOrderItemListAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
[HttpGet("GetPurchaseOrderItemByPurchaseOrderIdList")]
|
||||
public async Task<ActionResult<ApiSuccessResult<GetPurchaseOrderItemByPurchaseOrderIdListResult>>> GetPurchaseOrderItemByPurchaseOrderIdListAsync(
|
||||
CancellationToken cancellationToken,
|
||||
[FromQuery] string purchaseOrderId
|
||||
)
|
||||
{
|
||||
var request = new GetPurchaseOrderItemByPurchaseOrderIdListRequest { PurchaseOrderId = purchaseOrderId };
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<GetPurchaseOrderItemByPurchaseOrderIdListResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(GetPurchaseOrderItemByPurchaseOrderIdListAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,118 @@
|
||||
using Application.Features.PurchaseReturnManager.Commands;
|
||||
using Application.Features.PurchaseReturnManager.Queries;
|
||||
using ASPNET.BackEnd.Common.Base;
|
||||
using ASPNET.BackEnd.Common.Models;
|
||||
using MediatR;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace ASPNET.BackEnd.Controllers;
|
||||
|
||||
[Route("api/[controller]")]
|
||||
public class PurchaseReturnController : BaseApiController
|
||||
{
|
||||
public PurchaseReturnController(ISender sender) : base(sender)
|
||||
{
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
[HttpPost("CreatePurchaseReturn")]
|
||||
public async Task<ActionResult<ApiSuccessResult<CreatePurchaseReturnResult>>> CreatePurchaseReturnAsync(CreatePurchaseReturnRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<CreatePurchaseReturnResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(CreatePurchaseReturnAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
[HttpPost("UpdatePurchaseReturn")]
|
||||
public async Task<ActionResult<ApiSuccessResult<UpdatePurchaseReturnResult>>> UpdatePurchaseReturnAsync(UpdatePurchaseReturnRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<UpdatePurchaseReturnResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(UpdatePurchaseReturnAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
[HttpPost("DeletePurchaseReturn")]
|
||||
public async Task<ActionResult<ApiSuccessResult<DeletePurchaseReturnResult>>> DeletePurchaseReturnAsync(DeletePurchaseReturnRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<DeletePurchaseReturnResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(DeletePurchaseReturnAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
[HttpGet("GetPurchaseReturnList")]
|
||||
public async Task<ActionResult<ApiSuccessResult<GetPurchaseReturnListResult>>> GetPurchaseReturnListAsync(
|
||||
CancellationToken cancellationToken,
|
||||
[FromQuery] bool isDeleted = false
|
||||
)
|
||||
{
|
||||
var request = new GetPurchaseReturnListRequest { IsDeleted = isDeleted };
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<GetPurchaseReturnListResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(GetPurchaseReturnListAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
[Authorize]
|
||||
[HttpGet("GetPurchaseReturnStatusList")]
|
||||
public async Task<ActionResult<ApiSuccessResult<GetPurchaseReturnStatusListResult>>> GetPurchaseReturnStatusListAsync(
|
||||
CancellationToken cancellationToken
|
||||
)
|
||||
{
|
||||
var request = new GetPurchaseReturnStatusListRequest { };
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<GetPurchaseReturnStatusListResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(GetPurchaseReturnStatusListAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
[Authorize]
|
||||
[HttpGet("GetPurchaseReturnSingle")]
|
||||
public async Task<ActionResult<ApiSuccessResult<GetPurchaseReturnSingleResult>>> GetPurchaseReturnSingleAsync(
|
||||
CancellationToken cancellationToken,
|
||||
[FromQuery] string id
|
||||
)
|
||||
{
|
||||
var request = new GetPurchaseReturnSingleRequest { Id = id };
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<GetPurchaseReturnSingleResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(GetPurchaseReturnSingleAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,116 @@
|
||||
using Application.Features.SalesOrderManager.Commands;
|
||||
using Application.Features.SalesOrderManager.Queries;
|
||||
using ASPNET.BackEnd.Common.Base;
|
||||
using ASPNET.BackEnd.Common.Models;
|
||||
using MediatR;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace ASPNET.BackEnd.Controllers;
|
||||
|
||||
[Route("api/[controller]")]
|
||||
public class SalesOrderController : BaseApiController
|
||||
{
|
||||
public SalesOrderController(ISender sender) : base(sender)
|
||||
{
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
[HttpPost("CreateSalesOrder")]
|
||||
public async Task<ActionResult<ApiSuccessResult<CreateSalesOrderResult>>> CreateSalesOrderAsync(CreateSalesOrderRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<CreateSalesOrderResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(CreateSalesOrderAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
[HttpPost("UpdateSalesOrder")]
|
||||
public async Task<ActionResult<ApiSuccessResult<UpdateSalesOrderResult>>> UpdateSalesOrderAsync(UpdateSalesOrderRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<UpdateSalesOrderResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(UpdateSalesOrderAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
[HttpPost("DeleteSalesOrder")]
|
||||
public async Task<ActionResult<ApiSuccessResult<DeleteSalesOrderResult>>> DeleteSalesOrderAsync(DeleteSalesOrderRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<DeleteSalesOrderResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(DeleteSalesOrderAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
[HttpGet("GetSalesOrderList")]
|
||||
public async Task<ActionResult<ApiSuccessResult<GetSalesOrderListResult>>> GetSalesOrderListAsync(
|
||||
CancellationToken cancellationToken,
|
||||
[FromQuery] bool isDeleted = false
|
||||
)
|
||||
{
|
||||
var request = new GetSalesOrderListRequest { IsDeleted = isDeleted };
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<GetSalesOrderListResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(GetSalesOrderListAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
[Authorize]
|
||||
[HttpGet("GetSalesOrderStatusList")]
|
||||
public async Task<ActionResult<ApiSuccessResult<GetSalesOrderStatusListResult>>> GetSalesOrderStatusListAsync(
|
||||
CancellationToken cancellationToken
|
||||
)
|
||||
{
|
||||
var request = new GetSalesOrderStatusListRequest { };
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<GetSalesOrderStatusListResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(GetSalesOrderStatusListAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
[HttpGet("GetSalesOrderSingle")]
|
||||
public async Task<ActionResult<ApiSuccessResult<GetSalesOrderSingleResult>>> GetSalesOrderSingleAsync(
|
||||
CancellationToken cancellationToken,
|
||||
[FromQuery] string id
|
||||
)
|
||||
{
|
||||
var request = new GetSalesOrderSingleRequest { Id = id };
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<GetSalesOrderSingleResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(GetSalesOrderSingleAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,99 @@
|
||||
using Application.Features.SalesOrderItemManager.Commands;
|
||||
using Application.Features.SalesOrderItemManager.Queries;
|
||||
using ASPNET.BackEnd.Common.Base;
|
||||
using ASPNET.BackEnd.Common.Models;
|
||||
using MediatR;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace ASPNET.BackEnd.Controllers;
|
||||
|
||||
[Route("api/[controller]")]
|
||||
public class SalesOrderItemController : BaseApiController
|
||||
{
|
||||
public SalesOrderItemController(ISender sender) : base(sender)
|
||||
{
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
[HttpPost("CreateSalesOrderItem")]
|
||||
public async Task<ActionResult<ApiSuccessResult<CreateSalesOrderItemResult>>> CreateSalesOrderItemAsync(CreateSalesOrderItemRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<CreateSalesOrderItemResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(CreateSalesOrderItemAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
[HttpPost("UpdateSalesOrderItem")]
|
||||
public async Task<ActionResult<ApiSuccessResult<UpdateSalesOrderItemResult>>> UpdateSalesOrderItemAsync(UpdateSalesOrderItemRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<UpdateSalesOrderItemResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(UpdateSalesOrderItemAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
[HttpPost("DeleteSalesOrderItem")]
|
||||
public async Task<ActionResult<ApiSuccessResult<DeleteSalesOrderItemResult>>> DeleteSalesOrderItemAsync(DeleteSalesOrderItemRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<DeleteSalesOrderItemResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(DeleteSalesOrderItemAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
[HttpGet("GetSalesOrderItemList")]
|
||||
public async Task<ActionResult<ApiSuccessResult<GetSalesOrderItemListResult>>> GetSalesOrderItemListAsync(
|
||||
CancellationToken cancellationToken,
|
||||
[FromQuery] bool isDeleted = false
|
||||
)
|
||||
{
|
||||
var request = new GetSalesOrderItemListRequest { IsDeleted = isDeleted };
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<GetSalesOrderItemListResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(GetSalesOrderItemListAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
[HttpGet("GetSalesOrderItemBySalesOrderIdList")]
|
||||
public async Task<ActionResult<ApiSuccessResult<GetSalesOrderItemBySalesOrderIdListResult>>> GetSalesOrderItemBySalesOrderIdListAsync(
|
||||
CancellationToken cancellationToken,
|
||||
[FromQuery] string salesOrderId
|
||||
)
|
||||
{
|
||||
var request = new GetSalesOrderItemBySalesOrderIdListRequest { SalesOrderId = salesOrderId };
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<GetSalesOrderItemBySalesOrderIdListResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(GetSalesOrderItemBySalesOrderIdListAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,118 @@
|
||||
using Application.Features.SalesReturnManager.Commands;
|
||||
using Application.Features.SalesReturnManager.Queries;
|
||||
using ASPNET.BackEnd.Common.Base;
|
||||
using ASPNET.BackEnd.Common.Models;
|
||||
using MediatR;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace ASPNET.BackEnd.Controllers;
|
||||
|
||||
[Route("api/[controller]")]
|
||||
public class SalesReturnController : BaseApiController
|
||||
{
|
||||
public SalesReturnController(ISender sender) : base(sender)
|
||||
{
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
[HttpPost("CreateSalesReturn")]
|
||||
public async Task<ActionResult<ApiSuccessResult<CreateSalesReturnResult>>> CreateSalesReturnAsync(CreateSalesReturnRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<CreateSalesReturnResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(CreateSalesReturnAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
[HttpPost("UpdateSalesReturn")]
|
||||
public async Task<ActionResult<ApiSuccessResult<UpdateSalesReturnResult>>> UpdateSalesReturnAsync(UpdateSalesReturnRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<UpdateSalesReturnResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(UpdateSalesReturnAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
[HttpPost("DeleteSalesReturn")]
|
||||
public async Task<ActionResult<ApiSuccessResult<DeleteSalesReturnResult>>> DeleteSalesReturnAsync(DeleteSalesReturnRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<DeleteSalesReturnResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(DeleteSalesReturnAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
[HttpGet("GetSalesReturnList")]
|
||||
public async Task<ActionResult<ApiSuccessResult<GetSalesReturnListResult>>> GetSalesReturnListAsync(
|
||||
CancellationToken cancellationToken,
|
||||
[FromQuery] bool isDeleted = false
|
||||
)
|
||||
{
|
||||
var request = new GetSalesReturnListRequest { IsDeleted = isDeleted };
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<GetSalesReturnListResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(GetSalesReturnListAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
[Authorize]
|
||||
[HttpGet("GetSalesReturnStatusList")]
|
||||
public async Task<ActionResult<ApiSuccessResult<GetSalesReturnStatusListResult>>> GetSalesReturnStatusListAsync(
|
||||
CancellationToken cancellationToken
|
||||
)
|
||||
{
|
||||
var request = new GetSalesReturnStatusListRequest { };
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<GetSalesReturnStatusListResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(GetSalesReturnStatusListAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
[Authorize]
|
||||
[HttpGet("GetSalesReturnSingle")]
|
||||
public async Task<ActionResult<ApiSuccessResult<GetSalesReturnSingleResult>>> GetSalesReturnSingleAsync(
|
||||
CancellationToken cancellationToken,
|
||||
[FromQuery] string id
|
||||
)
|
||||
{
|
||||
var request = new GetSalesReturnSingleRequest { Id = id };
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<GetSalesReturnSingleResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(GetSalesReturnSingleAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,118 @@
|
||||
using Application.Features.ScrappingManager.Commands;
|
||||
using Application.Features.ScrappingManager.Queries;
|
||||
using ASPNET.BackEnd.Common.Base;
|
||||
using ASPNET.BackEnd.Common.Models;
|
||||
using MediatR;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace ASPNET.BackEnd.Controllers;
|
||||
|
||||
[Route("api/[controller]")]
|
||||
public class ScrappingController : BaseApiController
|
||||
{
|
||||
public ScrappingController(ISender sender) : base(sender)
|
||||
{
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
[HttpPost("CreateScrapping")]
|
||||
public async Task<ActionResult<ApiSuccessResult<CreateScrappingResult>>> CreateScrappingAsync(CreateScrappingRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<CreateScrappingResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(CreateScrappingAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
[HttpPost("UpdateScrapping")]
|
||||
public async Task<ActionResult<ApiSuccessResult<UpdateScrappingResult>>> UpdateScrappingAsync(UpdateScrappingRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<UpdateScrappingResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(UpdateScrappingAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
[HttpPost("DeleteScrapping")]
|
||||
public async Task<ActionResult<ApiSuccessResult<DeleteScrappingResult>>> DeleteScrappingAsync(DeleteScrappingRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<DeleteScrappingResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(DeleteScrappingAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
[HttpGet("GetScrappingList")]
|
||||
public async Task<ActionResult<ApiSuccessResult<GetScrappingListResult>>> GetScrappingListAsync(
|
||||
CancellationToken cancellationToken,
|
||||
[FromQuery] bool isDeleted = false
|
||||
)
|
||||
{
|
||||
var request = new GetScrappingListRequest { IsDeleted = isDeleted };
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<GetScrappingListResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(GetScrappingListAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
[Authorize]
|
||||
[HttpGet("GetScrappingStatusList")]
|
||||
public async Task<ActionResult<ApiSuccessResult<GetScrappingStatusListResult>>> GetScrappingStatusListAsync(
|
||||
CancellationToken cancellationToken
|
||||
)
|
||||
{
|
||||
var request = new GetScrappingStatusListRequest { };
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<GetScrappingStatusListResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(GetScrappingStatusListAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
[Authorize]
|
||||
[HttpGet("GetScrappingSingle")]
|
||||
public async Task<ActionResult<ApiSuccessResult<GetScrappingSingleResult>>> GetScrappingSingleAsync(
|
||||
CancellationToken cancellationToken,
|
||||
[FromQuery] string id
|
||||
)
|
||||
{
|
||||
var request = new GetScrappingSingleRequest { Id = id };
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<GetScrappingSingleResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(GetScrappingSingleAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,392 @@
|
||||
using Application.Features.SecurityManager.Commands;
|
||||
using Application.Features.SecurityManager.Queries;
|
||||
using ASPNET.BackEnd.Common.Base;
|
||||
using ASPNET.BackEnd.Common.Models;
|
||||
using MediatR;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Infrastructure.SecurityManager.Tokens;
|
||||
using Microsoft.Extensions.Options;
|
||||
|
||||
namespace ASPNET.BackEnd.Controllers;
|
||||
|
||||
|
||||
[Route("api/[controller]")]
|
||||
public class SecurityController : BaseApiController
|
||||
{
|
||||
private readonly IConfiguration _configuration;
|
||||
private readonly TokenSettings _tokenSettings;
|
||||
public SecurityController(ISender sender, IConfiguration configuration, IOptions<TokenSettings> tokenSettings) : base(sender)
|
||||
{
|
||||
_configuration = configuration;
|
||||
_tokenSettings = tokenSettings.Value;
|
||||
}
|
||||
|
||||
[AllowAnonymous]
|
||||
[HttpPost("Login")]
|
||||
public async Task<ActionResult<ApiSuccessResult<LoginResult>>> LoginAsync(LoginRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
// Set HttpOnly cookie for server-side page authorization
|
||||
if (response?.Data?.AccessToken != null)
|
||||
{
|
||||
Response.Cookies.Append("accessToken", response.Data.AccessToken, new CookieOptions
|
||||
{
|
||||
HttpOnly = true,
|
||||
Secure = true,
|
||||
SameSite = SameSiteMode.Lax,
|
||||
Expires = DateTime.UtcNow.AddMinutes(_tokenSettings.ExpireInMinute)
|
||||
});
|
||||
}
|
||||
|
||||
return Ok(new ApiSuccessResult<LoginResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(LoginAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
[AllowAnonymous]
|
||||
[HttpPost("Logout")]
|
||||
public async Task<ActionResult<ApiSuccessResult<LogoutResult>>> LogoutAsync(LogoutRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
// Clear HttpOnly cookie on logout
|
||||
Response.Cookies.Append("accessToken", "", new CookieOptions
|
||||
{
|
||||
HttpOnly = true,
|
||||
Secure = true,
|
||||
SameSite = SameSiteMode.Lax,
|
||||
Expires = DateTime.UtcNow.AddDays(-1)
|
||||
});
|
||||
|
||||
return Ok(new ApiSuccessResult<LogoutResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(LogoutAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
[AllowAnonymous]
|
||||
[HttpPost("Register")]
|
||||
public async Task<ActionResult<ApiSuccessResult<RegisterResult>>> RegisterAsync(
|
||||
RegisterRequest request,
|
||||
CancellationToken cancellationToken
|
||||
)
|
||||
{
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<RegisterResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(RegisterAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
[AllowAnonymous]
|
||||
[HttpGet("ConfirmEmail")]
|
||||
public async Task<ActionResult<ApiSuccessResult<ConfirmEmailResult>>> ConfirmEmailAsync(
|
||||
[FromQuery] string email,
|
||||
[FromQuery] string code,
|
||||
CancellationToken cancellationToken
|
||||
)
|
||||
{
|
||||
var request = new ConfirmEmailRequest { Email = email, Code = code };
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<ConfirmEmailResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(ConfirmEmailAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
[AllowAnonymous]
|
||||
[HttpPost("ForgotPassword")]
|
||||
public async Task<ActionResult<ApiSuccessResult<ForgotPasswordResult>>> ForgotPasswordAsync(
|
||||
ForgotPasswordRequest request,
|
||||
CancellationToken cancellationToken
|
||||
)
|
||||
{
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<ForgotPasswordResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(ForgotPasswordAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
[AllowAnonymous]
|
||||
[HttpGet("ForgotPasswordConfirmation")]
|
||||
public async Task<ActionResult<ApiSuccessResult<ForgotPasswordConfirmationResult>>> ForgotPasswordConfirmationAsync(
|
||||
[FromQuery] string email,
|
||||
[FromQuery] string code,
|
||||
[FromQuery] string tempPassword,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
var request = new ForgotPasswordConfirmationRequest { Email = email, TempPassword = tempPassword, Code = code };
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<ForgotPasswordConfirmationResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(ForgotPasswordConfirmationAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
[AllowAnonymous]
|
||||
[HttpPost("RefreshToken")]
|
||||
public async Task<ActionResult<ApiSuccessResult<RefreshTokenResult>>> RefreshTokenAsync(RefreshTokenRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
// Update HttpOnly cookie with new access token
|
||||
if (response?.Data?.AccessToken != null)
|
||||
{
|
||||
Response.Cookies.Append("accessToken", response.Data.AccessToken, new CookieOptions
|
||||
{
|
||||
HttpOnly = true,
|
||||
Secure = true,
|
||||
SameSite = SameSiteMode.Lax,
|
||||
Expires = DateTime.UtcNow.AddMinutes(_tokenSettings.ExpireInMinute)
|
||||
});
|
||||
}
|
||||
|
||||
return Ok(new ApiSuccessResult<RefreshTokenResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(RefreshTokenAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
[HttpPost("ValidateToken")]
|
||||
public async Task<ActionResult<ApiSuccessResult<ValidateTokenResult>>> ValidateTokenAsync(
|
||||
ValidateTokenRequest request,
|
||||
CancellationToken cancellationToken
|
||||
)
|
||||
{
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<ValidateTokenResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(ValidateTokenAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
[Authorize]
|
||||
[HttpGet("GetMyProfileList")]
|
||||
public async Task<ActionResult<ApiSuccessResult<GetMyProfileListResult>>> GetMyProfileListAsync(
|
||||
[FromQuery] string userId,
|
||||
CancellationToken cancellationToken
|
||||
)
|
||||
{
|
||||
var request = new GetMyProfileListRequest { UserId = userId };
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<GetMyProfileListResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(GetMyProfileListAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
[HttpPost("UpdateMyProfile")]
|
||||
public async Task<ActionResult<ApiSuccessResult<UpdateMyProfileResult>>> UpdateMyProfileAsync(
|
||||
UpdateMyProfileRequest request,
|
||||
CancellationToken cancellationToken
|
||||
)
|
||||
{
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<UpdateMyProfileResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(UpdateMyProfileAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
[HttpPost("UpdateMyProfilePassword")]
|
||||
public async Task<ActionResult<ApiSuccessResult<UpdateMyProfilePasswordResult>>> UpdateMyProfilePasswordAsync(
|
||||
UpdateMyProfilePasswordRequest request,
|
||||
CancellationToken cancellationToken
|
||||
)
|
||||
{
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<UpdateMyProfilePasswordResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(UpdateMyProfilePasswordAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
[Authorize]
|
||||
[HttpGet("GetRoleList")]
|
||||
public async Task<ActionResult<ApiSuccessResult<GetRoleListResult>>> GetRoleListAsync(
|
||||
CancellationToken cancellationToken
|
||||
)
|
||||
{
|
||||
var request = new GetRoleListRequest { };
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<GetRoleListResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(GetRoleListAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
[Authorize(Roles = "Users")]
|
||||
[HttpGet("GetUserList")]
|
||||
public async Task<ActionResult<ApiSuccessResult<GetUserListResult>>> GetUserListAsync(
|
||||
CancellationToken cancellationToken
|
||||
)
|
||||
{
|
||||
var request = new GetUserListRequest { };
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<GetUserListResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(GetUserListAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
[Authorize(Roles = "Users")]
|
||||
[HttpPost("CreateUser")]
|
||||
public async Task<ActionResult<ApiSuccessResult<CreateUserResult>>> CreateUserAsync(
|
||||
CreateUserRequest request,
|
||||
CancellationToken cancellationToken
|
||||
)
|
||||
{
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<CreateUserResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(CreateUserAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
[Authorize(Roles = "Users")]
|
||||
[HttpPost("UpdateUser")]
|
||||
public async Task<ActionResult<ApiSuccessResult<UpdateUserResult>>> UpdateUserAsync(
|
||||
UpdateUserRequest request,
|
||||
CancellationToken cancellationToken
|
||||
)
|
||||
{
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<UpdateUserResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(UpdateUserAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
[Authorize(Roles = "Users")]
|
||||
[HttpPost("DeleteUser")]
|
||||
public async Task<ActionResult<ApiSuccessResult<DeleteUserResult>>> DeleteUserAsync(
|
||||
DeleteUserRequest request,
|
||||
CancellationToken cancellationToken
|
||||
)
|
||||
{
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<DeleteUserResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(DeleteUserAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
[Authorize(Roles = "Users")]
|
||||
[HttpPost("UpdatePasswordUser")]
|
||||
public async Task<ActionResult<ApiSuccessResult<UpdatePasswordUserResult>>> UpdatePasswordUserAsync(
|
||||
UpdatePasswordUserRequest request,
|
||||
CancellationToken cancellationToken
|
||||
)
|
||||
{
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<UpdatePasswordUserResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(UpdatePasswordUserAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
[Authorize(Roles = "Users")]
|
||||
[HttpPost("GetUserRoles")]
|
||||
public async Task<ActionResult<ApiSuccessResult<GetUserRolesResult>>> GetUserRolesAsync(GetUserRolesRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<GetUserRolesResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(GetUserRolesAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
[Authorize(Roles = "Users")]
|
||||
[HttpPost("UpdateUserRole")]
|
||||
public async Task<ActionResult<ApiSuccessResult<UpdateUserRoleResult>>> UpdateUserRoleAsync(UpdateUserRoleRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<UpdateUserRoleResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(UpdateUserRoleAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
[HttpPost("UpdateMyProfileAvatar")]
|
||||
public async Task<ActionResult<ApiSuccessResult<UpdateMyProfileAvatarResult>>> UpdateMyProfileAvatarAsync(UpdateMyProfileAvatarRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<UpdateMyProfileAvatarResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(UpdateMyProfileAvatarAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,118 @@
|
||||
using Application.Features.StockCountManager.Commands;
|
||||
using Application.Features.StockCountManager.Queries;
|
||||
using ASPNET.BackEnd.Common.Base;
|
||||
using ASPNET.BackEnd.Common.Models;
|
||||
using MediatR;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace ASPNET.BackEnd.Controllers;
|
||||
|
||||
[Route("api/[controller]")]
|
||||
public class StockCountController : BaseApiController
|
||||
{
|
||||
public StockCountController(ISender sender) : base(sender)
|
||||
{
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
[HttpPost("CreateStockCount")]
|
||||
public async Task<ActionResult<ApiSuccessResult<CreateStockCountResult>>> CreateStockCountAsync(CreateStockCountRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<CreateStockCountResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(CreateStockCountAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
[HttpPost("UpdateStockCount")]
|
||||
public async Task<ActionResult<ApiSuccessResult<UpdateStockCountResult>>> UpdateStockCountAsync(UpdateStockCountRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<UpdateStockCountResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(UpdateStockCountAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
[HttpPost("DeleteStockCount")]
|
||||
public async Task<ActionResult<ApiSuccessResult<DeleteStockCountResult>>> DeleteStockCountAsync(DeleteStockCountRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<DeleteStockCountResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(DeleteStockCountAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
[HttpGet("GetStockCountList")]
|
||||
public async Task<ActionResult<ApiSuccessResult<GetStockCountListResult>>> GetStockCountListAsync(
|
||||
CancellationToken cancellationToken,
|
||||
[FromQuery] bool isDeleted = false
|
||||
)
|
||||
{
|
||||
var request = new GetStockCountListRequest { IsDeleted = isDeleted };
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<GetStockCountListResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(GetStockCountListAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
[Authorize]
|
||||
[HttpGet("GetStockCountStatusList")]
|
||||
public async Task<ActionResult<ApiSuccessResult<GetStockCountStatusListResult>>> GetStockCountStatusListAsync(
|
||||
CancellationToken cancellationToken
|
||||
)
|
||||
{
|
||||
var request = new GetStockCountStatusListRequest { };
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<GetStockCountStatusListResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(GetStockCountStatusListAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
[Authorize]
|
||||
[HttpGet("GetStockCountSingle")]
|
||||
public async Task<ActionResult<ApiSuccessResult<GetStockCountSingleResult>>> GetStockCountSingleAsync(
|
||||
CancellationToken cancellationToken,
|
||||
[FromQuery] string id
|
||||
)
|
||||
{
|
||||
var request = new GetStockCountSingleRequest { Id = id };
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<GetStockCountSingleResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(GetStockCountSingleAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,82 @@
|
||||
using Application.Features.TaxManager.Commands;
|
||||
using Application.Features.TaxManager.Queries;
|
||||
using ASPNET.BackEnd.Common.Base;
|
||||
using ASPNET.BackEnd.Common.Models;
|
||||
using MediatR;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace ASPNET.BackEnd.Controllers;
|
||||
|
||||
[Route("api/[controller]")]
|
||||
public class TaxController : BaseApiController
|
||||
{
|
||||
public TaxController(ISender sender) : base(sender)
|
||||
{
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
[HttpPost("CreateTax")]
|
||||
public async Task<ActionResult<ApiSuccessResult<CreateTaxResult>>> CreateTaxAsync(CreateTaxRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<CreateTaxResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(CreateTaxAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
[HttpPost("UpdateTax")]
|
||||
public async Task<ActionResult<ApiSuccessResult<UpdateTaxResult>>> UpdateTaxAsync(UpdateTaxRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<UpdateTaxResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(UpdateTaxAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
[HttpPost("DeleteTax")]
|
||||
public async Task<ActionResult<ApiSuccessResult<DeleteTaxResult>>> DeleteTaxAsync(DeleteTaxRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<DeleteTaxResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(DeleteTaxAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
[Authorize]
|
||||
[HttpGet("GetTaxList")]
|
||||
public async Task<ActionResult<ApiSuccessResult<GetTaxListResult>>> GetTaxListAsync(
|
||||
CancellationToken cancellationToken,
|
||||
[FromQuery] bool isDeleted = false
|
||||
)
|
||||
{
|
||||
var request = new GetTaxListRequest { IsDeleted = isDeleted };
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<GetTaxListResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(GetTaxListAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,99 @@
|
||||
using Application.Features.TodoManager.Commands;
|
||||
using Application.Features.TodoManager.Queries;
|
||||
using ASPNET.BackEnd.Common.Base;
|
||||
using ASPNET.BackEnd.Common.Models;
|
||||
using MediatR;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace ASPNET.BackEnd.Controllers;
|
||||
|
||||
[Route("api/[controller]")]
|
||||
public class TodoController : BaseApiController
|
||||
{
|
||||
public TodoController(ISender sender) : base(sender)
|
||||
{
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
[HttpPost("CreateTodo")]
|
||||
public async Task<ActionResult<ApiSuccessResult<CreateTodoResult>>> CreateTodoAsync(CreateTodoRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<CreateTodoResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(CreateTodoAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
[HttpPost("UpdateTodo")]
|
||||
public async Task<ActionResult<ApiSuccessResult<UpdateTodoResult>>> UpdateTodoAsync(UpdateTodoRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<UpdateTodoResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(UpdateTodoAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
[HttpPost("DeleteTodo")]
|
||||
public async Task<ActionResult<ApiSuccessResult<DeleteTodoResult>>> DeleteTodoAsync(DeleteTodoRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<DeleteTodoResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(DeleteTodoAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
[HttpGet("GetTodoSingle")]
|
||||
public async Task<ActionResult<ApiSuccessResult<GetTodoSingleResult>>> GetTodoSingleAsync(
|
||||
CancellationToken cancellationToken,
|
||||
[FromQuery] string id
|
||||
)
|
||||
{
|
||||
var request = new GetTodoSingleRequest { Id = id };
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<GetTodoSingleResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(GetTodoSingleAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
[HttpGet("GetTodoList")]
|
||||
public async Task<ActionResult<ApiSuccessResult<GetTodoListResult>>> GetTodoListAsync(
|
||||
CancellationToken cancellationToken,
|
||||
[FromQuery] bool isDeleted = false
|
||||
)
|
||||
{
|
||||
var request = new GetTodoListRequest { IsDeleted = isDeleted };
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<GetTodoListResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(GetTodoListAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,99 @@
|
||||
using Application.Features.TodoItemManager.Commands;
|
||||
using Application.Features.TodoItemManager.Queries;
|
||||
using ASPNET.BackEnd.Common.Base;
|
||||
using ASPNET.BackEnd.Common.Models;
|
||||
using MediatR;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace ASPNET.BackEnd.Controllers;
|
||||
|
||||
[Route("api/[controller]")]
|
||||
public class TodoItemController : BaseApiController
|
||||
{
|
||||
public TodoItemController(ISender sender) : base(sender)
|
||||
{
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
[HttpPost("CreateTodoItem")]
|
||||
public async Task<ActionResult<ApiSuccessResult<CreateTodoItemResult>>> CreateTodoItemAsync(CreateTodoItemRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<CreateTodoItemResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(CreateTodoItemAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
[HttpPost("UpdateTodoItem")]
|
||||
public async Task<ActionResult<ApiSuccessResult<UpdateTodoItemResult>>> UpdateTodoItemAsync(UpdateTodoItemRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<UpdateTodoItemResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(UpdateTodoItemAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
[HttpPost("DeleteTodoItem")]
|
||||
public async Task<ActionResult<ApiSuccessResult<DeleteTodoItemResult>>> DeleteTodoItemAsync(DeleteTodoItemRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<DeleteTodoItemResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(DeleteTodoItemAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
[HttpGet("GetTodoItemSingle")]
|
||||
public async Task<ActionResult<ApiSuccessResult<GetTodoItemSingleResult>>> GetTodoItemSingleAsync(
|
||||
CancellationToken cancellationToken,
|
||||
[FromQuery] string id
|
||||
)
|
||||
{
|
||||
var request = new GetTodoItemSingleRequest { Id = id };
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<GetTodoItemSingleResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(GetTodoItemSingleAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
[HttpGet("GetTodoItemList")]
|
||||
public async Task<ActionResult<ApiSuccessResult<GetTodoItemListResult>>> GetTodoItemListAsync(
|
||||
CancellationToken cancellationToken,
|
||||
[FromQuery] bool isDeleted = false
|
||||
)
|
||||
{
|
||||
var request = new GetTodoItemListRequest { IsDeleted = isDeleted };
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<GetTodoItemListResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(GetTodoItemListAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,118 @@
|
||||
using Application.Features.TransferInManager.Commands;
|
||||
using Application.Features.TransferInManager.Queries;
|
||||
using ASPNET.BackEnd.Common.Base;
|
||||
using ASPNET.BackEnd.Common.Models;
|
||||
using MediatR;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace ASPNET.BackEnd.Controllers;
|
||||
|
||||
[Route("api/[controller]")]
|
||||
public class TransferInController : BaseApiController
|
||||
{
|
||||
public TransferInController(ISender sender) : base(sender)
|
||||
{
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
[HttpPost("CreateTransferIn")]
|
||||
public async Task<ActionResult<ApiSuccessResult<CreateTransferInResult>>> CreateTransferInAsync(CreateTransferInRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<CreateTransferInResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(CreateTransferInAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
[HttpPost("UpdateTransferIn")]
|
||||
public async Task<ActionResult<ApiSuccessResult<UpdateTransferInResult>>> UpdateTransferInAsync(UpdateTransferInRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<UpdateTransferInResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(UpdateTransferInAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
[HttpPost("DeleteTransferIn")]
|
||||
public async Task<ActionResult<ApiSuccessResult<DeleteTransferInResult>>> DeleteTransferInAsync(DeleteTransferInRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<DeleteTransferInResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(DeleteTransferInAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
[HttpGet("GetTransferInList")]
|
||||
public async Task<ActionResult<ApiSuccessResult<GetTransferInListResult>>> GetTransferInListAsync(
|
||||
CancellationToken cancellationToken,
|
||||
[FromQuery] bool isDeleted = false
|
||||
)
|
||||
{
|
||||
var request = new GetTransferInListRequest { IsDeleted = isDeleted };
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<GetTransferInListResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(GetTransferInListAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
[Authorize]
|
||||
[HttpGet("GetTransferInStatusList")]
|
||||
public async Task<ActionResult<ApiSuccessResult<GetTransferInStatusListResult>>> GetTransferInStatusListAsync(
|
||||
CancellationToken cancellationToken
|
||||
)
|
||||
{
|
||||
var request = new GetTransferInStatusListRequest { };
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<GetTransferInStatusListResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(GetTransferInStatusListAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
[Authorize]
|
||||
[HttpGet("GetTransferInSingle")]
|
||||
public async Task<ActionResult<ApiSuccessResult<GetTransferInSingleResult>>> GetTransferInSingleAsync(
|
||||
CancellationToken cancellationToken,
|
||||
[FromQuery] string id
|
||||
)
|
||||
{
|
||||
var request = new GetTransferInSingleRequest { Id = id };
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<GetTransferInSingleResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(GetTransferInSingleAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,118 @@
|
||||
using Application.Features.TransferOutManager.Commands;
|
||||
using Application.Features.TransferOutManager.Queries;
|
||||
using ASPNET.BackEnd.Common.Base;
|
||||
using ASPNET.BackEnd.Common.Models;
|
||||
using MediatR;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace ASPNET.BackEnd.Controllers;
|
||||
|
||||
[Route("api/[controller]")]
|
||||
public class TransferOutController : BaseApiController
|
||||
{
|
||||
public TransferOutController(ISender sender) : base(sender)
|
||||
{
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
[HttpPost("CreateTransferOut")]
|
||||
public async Task<ActionResult<ApiSuccessResult<CreateTransferOutResult>>> CreateTransferOutAsync(CreateTransferOutRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<CreateTransferOutResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(CreateTransferOutAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
[HttpPost("UpdateTransferOut")]
|
||||
public async Task<ActionResult<ApiSuccessResult<UpdateTransferOutResult>>> UpdateTransferOutAsync(UpdateTransferOutRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<UpdateTransferOutResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(UpdateTransferOutAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
[HttpPost("DeleteTransferOut")]
|
||||
public async Task<ActionResult<ApiSuccessResult<DeleteTransferOutResult>>> DeleteTransferOutAsync(DeleteTransferOutRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<DeleteTransferOutResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(DeleteTransferOutAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
[HttpGet("GetTransferOutList")]
|
||||
public async Task<ActionResult<ApiSuccessResult<GetTransferOutListResult>>> GetTransferOutListAsync(
|
||||
CancellationToken cancellationToken,
|
||||
[FromQuery] bool isDeleted = false
|
||||
)
|
||||
{
|
||||
var request = new GetTransferOutListRequest { IsDeleted = isDeleted };
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<GetTransferOutListResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(GetTransferOutListAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
[Authorize]
|
||||
[HttpGet("GetTransferOutStatusList")]
|
||||
public async Task<ActionResult<ApiSuccessResult<GetTransferOutStatusListResult>>> GetTransferOutStatusListAsync(
|
||||
CancellationToken cancellationToken
|
||||
)
|
||||
{
|
||||
var request = new GetTransferOutStatusListRequest { };
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<GetTransferOutStatusListResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(GetTransferOutStatusListAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
[Authorize]
|
||||
[HttpGet("GetTransferOutSingle")]
|
||||
public async Task<ActionResult<ApiSuccessResult<GetTransferOutSingleResult>>> GetTransferOutSingleAsync(
|
||||
CancellationToken cancellationToken,
|
||||
[FromQuery] string id
|
||||
)
|
||||
{
|
||||
var request = new GetTransferOutSingleRequest { Id = id };
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<GetTransferOutSingleResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(GetTransferOutSingleAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,81 @@
|
||||
using Application.Features.UnitMeasureManager.Commands;
|
||||
using Application.Features.UnitMeasureManager.Queries;
|
||||
using ASPNET.BackEnd.Common.Base;
|
||||
using ASPNET.BackEnd.Common.Models;
|
||||
using MediatR;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace ASPNET.BackEnd.Controllers;
|
||||
|
||||
[Route("api/[controller]")]
|
||||
public class UnitMeasureController : BaseApiController
|
||||
{
|
||||
public UnitMeasureController(ISender sender) : base(sender)
|
||||
{
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
[HttpPost("CreateUnitMeasure")]
|
||||
public async Task<ActionResult<ApiSuccessResult<CreateUnitMeasureResult>>> CreateUnitMeasureAsync(CreateUnitMeasureRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<CreateUnitMeasureResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(CreateUnitMeasureAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
[HttpPost("UpdateUnitMeasure")]
|
||||
public async Task<ActionResult<ApiSuccessResult<UpdateUnitMeasureResult>>> UpdateUnitMeasureAsync(UpdateUnitMeasureRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<UpdateUnitMeasureResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(UpdateUnitMeasureAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
[HttpPost("DeleteUnitMeasure")]
|
||||
public async Task<ActionResult<ApiSuccessResult<DeleteUnitMeasureResult>>> DeleteUnitMeasureAsync(DeleteUnitMeasureRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<DeleteUnitMeasureResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(DeleteUnitMeasureAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
[HttpGet("GetUnitMeasureList")]
|
||||
public async Task<ActionResult<ApiSuccessResult<GetUnitMeasureListResult>>> GetUnitMeasureListAsync(
|
||||
CancellationToken cancellationToken,
|
||||
[FromQuery] bool isDeleted = false
|
||||
)
|
||||
{
|
||||
var request = new GetUnitMeasureListRequest { IsDeleted = isDeleted };
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<GetUnitMeasureListResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(GetUnitMeasureListAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,81 @@
|
||||
using Application.Features.VendorCategoryManager.Commands;
|
||||
using Application.Features.VendorCategoryManager.Queries;
|
||||
using ASPNET.BackEnd.Common.Base;
|
||||
using ASPNET.BackEnd.Common.Models;
|
||||
using MediatR;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace ASPNET.BackEnd.Controllers;
|
||||
|
||||
[Route("api/[controller]")]
|
||||
public class VendorCategoryController : BaseApiController
|
||||
{
|
||||
public VendorCategoryController(ISender sender) : base(sender)
|
||||
{
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
[HttpPost("CreateVendorCategory")]
|
||||
public async Task<ActionResult<ApiSuccessResult<CreateVendorCategoryResult>>> CreateVendorCategoryAsync(CreateVendorCategoryRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<CreateVendorCategoryResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(CreateVendorCategoryAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
[HttpPost("UpdateVendorCategory")]
|
||||
public async Task<ActionResult<ApiSuccessResult<UpdateVendorCategoryResult>>> UpdateVendorCategoryAsync(UpdateVendorCategoryRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<UpdateVendorCategoryResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(UpdateVendorCategoryAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
[HttpPost("DeleteVendorCategory")]
|
||||
public async Task<ActionResult<ApiSuccessResult<DeleteVendorCategoryResult>>> DeleteVendorCategoryAsync(DeleteVendorCategoryRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<DeleteVendorCategoryResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(DeleteVendorCategoryAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
[HttpGet("GetVendorCategoryList")]
|
||||
public async Task<ActionResult<ApiSuccessResult<GetVendorCategoryListResult>>> GetVendorCategoryListAsync(
|
||||
CancellationToken cancellationToken,
|
||||
[FromQuery] bool isDeleted = false
|
||||
)
|
||||
{
|
||||
var request = new GetVendorCategoryListRequest { IsDeleted = isDeleted };
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<GetVendorCategoryListResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(GetVendorCategoryListAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,98 @@
|
||||
using Application.Features.VendorContactManager.Commands;
|
||||
using Application.Features.VendorContactManager.Queries;
|
||||
using ASPNET.BackEnd.Common.Base;
|
||||
using ASPNET.BackEnd.Common.Models;
|
||||
using MediatR;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace ASPNET.BackEnd.Controllers;
|
||||
|
||||
[Route("api/[controller]")]
|
||||
public class VendorContactController : BaseApiController
|
||||
{
|
||||
public VendorContactController(ISender sender) : base(sender)
|
||||
{
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
[HttpPost("CreateVendorContact")]
|
||||
public async Task<ActionResult<ApiSuccessResult<CreateVendorContactResult>>> CreateVendorContactAsync(CreateVendorContactRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<CreateVendorContactResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(CreateVendorContactAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
[HttpPost("UpdateVendorContact")]
|
||||
public async Task<ActionResult<ApiSuccessResult<UpdateVendorContactResult>>> UpdateVendorContactAsync(UpdateVendorContactRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<UpdateVendorContactResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(UpdateVendorContactAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
[HttpPost("DeleteVendorContact")]
|
||||
public async Task<ActionResult<ApiSuccessResult<DeleteVendorContactResult>>> DeleteVendorContactAsync(DeleteVendorContactRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<DeleteVendorContactResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(DeleteVendorContactAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
[HttpGet("GetVendorContactList")]
|
||||
public async Task<ActionResult<ApiSuccessResult<GetVendorContactListResult>>> GetVendorContactListAsync(
|
||||
CancellationToken cancellationToken,
|
||||
[FromQuery] bool isDeleted = false
|
||||
)
|
||||
{
|
||||
var request = new GetVendorContactListRequest { IsDeleted = isDeleted };
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<GetVendorContactListResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(GetVendorContactListAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
[Authorize]
|
||||
[HttpGet("GetVendorContactByVendorIdList")]
|
||||
public async Task<ActionResult<ApiSuccessResult<GetVendorContactByVendorIdListResult>>> GetVendorContactByVendorIdListAsync(
|
||||
CancellationToken cancellationToken,
|
||||
[FromQuery] string vendorId
|
||||
)
|
||||
{
|
||||
var request = new GetVendorContactByVendorIdListRequest { VendorId = vendorId };
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<GetVendorContactByVendorIdListResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(GetVendorContactByVendorIdListAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,81 @@
|
||||
using Application.Features.VendorManager.Commands;
|
||||
using Application.Features.VendorManager.Queries;
|
||||
using ASPNET.BackEnd.Common.Base;
|
||||
using ASPNET.BackEnd.Common.Models;
|
||||
using MediatR;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace ASPNET.BackEnd.Controllers;
|
||||
|
||||
[Route("api/[controller]")]
|
||||
public class VendorController : BaseApiController
|
||||
{
|
||||
public VendorController(ISender sender) : base(sender)
|
||||
{
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
[HttpPost("CreateVendor")]
|
||||
public async Task<ActionResult<ApiSuccessResult<CreateVendorResult>>> CreateVendorAsync(CreateVendorRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<CreateVendorResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(CreateVendorAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
[HttpPost("UpdateVendor")]
|
||||
public async Task<ActionResult<ApiSuccessResult<UpdateVendorResult>>> UpdateVendorAsync(UpdateVendorRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<UpdateVendorResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(UpdateVendorAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
[HttpPost("DeleteVendor")]
|
||||
public async Task<ActionResult<ApiSuccessResult<DeleteVendorResult>>> DeleteVendorAsync(DeleteVendorRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<DeleteVendorResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(DeleteVendorAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
[HttpGet("GetVendorList")]
|
||||
public async Task<ActionResult<ApiSuccessResult<GetVendorListResult>>> GetVendorListAsync(
|
||||
CancellationToken cancellationToken,
|
||||
[FromQuery] bool isDeleted = false
|
||||
)
|
||||
{
|
||||
var request = new GetVendorListRequest { IsDeleted = isDeleted };
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<GetVendorListResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(GetVendorListAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,81 @@
|
||||
using Application.Features.VendorGroupManager.Commands;
|
||||
using Application.Features.VendorGroupManager.Queries;
|
||||
using ASPNET.BackEnd.Common.Base;
|
||||
using ASPNET.BackEnd.Common.Models;
|
||||
using MediatR;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace ASPNET.BackEnd.Controllers;
|
||||
|
||||
[Route("api/[controller]")]
|
||||
public class VendorGroupController : BaseApiController
|
||||
{
|
||||
public VendorGroupController(ISender sender) : base(sender)
|
||||
{
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
[HttpPost("CreateVendorGroup")]
|
||||
public async Task<ActionResult<ApiSuccessResult<CreateVendorGroupResult>>> CreateVendorGroupAsync(CreateVendorGroupRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<CreateVendorGroupResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(CreateVendorGroupAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
[HttpPost("UpdateVendorGroup")]
|
||||
public async Task<ActionResult<ApiSuccessResult<UpdateVendorGroupResult>>> UpdateVendorGroupAsync(UpdateVendorGroupRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<UpdateVendorGroupResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(UpdateVendorGroupAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
[HttpPost("DeleteVendorGroup")]
|
||||
public async Task<ActionResult<ApiSuccessResult<DeleteVendorGroupResult>>> DeleteVendorGroupAsync(DeleteVendorGroupRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<DeleteVendorGroupResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(DeleteVendorGroupAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
[HttpGet("GetVendorGroupList")]
|
||||
public async Task<ActionResult<ApiSuccessResult<GetVendorGroupListResult>>> GetVendorGroupListAsync(
|
||||
CancellationToken cancellationToken,
|
||||
[FromQuery] bool isDeleted = false
|
||||
)
|
||||
{
|
||||
var request = new GetVendorGroupListRequest { IsDeleted = isDeleted };
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<GetVendorGroupListResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(GetVendorGroupListAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,81 @@
|
||||
using Application.Features.WarehouseManager.Commands;
|
||||
using Application.Features.WarehouseManager.Queries;
|
||||
using ASPNET.BackEnd.Common.Base;
|
||||
using ASPNET.BackEnd.Common.Models;
|
||||
using MediatR;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace ASPNET.BackEnd.Controllers;
|
||||
|
||||
[Route("api/[controller]")]
|
||||
public class WarehouseController : BaseApiController
|
||||
{
|
||||
public WarehouseController(ISender sender) : base(sender)
|
||||
{
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
[HttpPost("CreateWarehouse")]
|
||||
public async Task<ActionResult<ApiSuccessResult<CreateWarehouseResult>>> CreateWarehouseAsync(CreateWarehouseRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<CreateWarehouseResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(CreateWarehouseAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
[HttpPost("UpdateWarehouse")]
|
||||
public async Task<ActionResult<ApiSuccessResult<UpdateWarehouseResult>>> UpdateWarehouseAsync(UpdateWarehouseRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<UpdateWarehouseResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(UpdateWarehouseAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
[HttpPost("DeleteWarehouse")]
|
||||
public async Task<ActionResult<ApiSuccessResult<DeleteWarehouseResult>>> DeleteWarehouseAsync(DeleteWarehouseRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<DeleteWarehouseResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(DeleteWarehouseAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
[HttpGet("GetWarehouseList")]
|
||||
public async Task<ActionResult<ApiSuccessResult<GetWarehouseListResult>>> GetWarehouseListAsync(
|
||||
CancellationToken cancellationToken,
|
||||
[FromQuery] bool isDeleted = false
|
||||
)
|
||||
{
|
||||
var request = new GetWarehouseListRequest { IsDeleted = isDeleted };
|
||||
var response = await _sender.Send(request, cancellationToken);
|
||||
|
||||
return Ok(new ApiSuccessResult<GetWarehouseListResult>
|
||||
{
|
||||
Code = StatusCodes.Status200OK,
|
||||
Message = $"Success executing {nameof(GetWarehouseListAsync)}",
|
||||
Content = response
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
namespace ASPNET.FrontEnd;
|
||||
|
||||
public static class FrontEndConfiguration
|
||||
{
|
||||
public static IServiceCollection AddFrontEndServices(this IServiceCollection services)
|
||||
{
|
||||
services.AddRazorPages(options =>
|
||||
{
|
||||
options.RootDirectory = "/FrontEnd/Pages";
|
||||
});
|
||||
return services;
|
||||
}
|
||||
|
||||
public static IEndpointRouteBuilder MapFrontEndRoutes(this IEndpointRouteBuilder endpoints)
|
||||
{
|
||||
endpoints.MapRazorPages()
|
||||
.WithStaticAssets();
|
||||
return endpoints;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
@page
|
||||
@{
|
||||
ViewData["Title"] = "Email Confirm";
|
||||
}
|
||||
<div id="app" class="container-fluid" v-cloak>
|
||||
|
||||
<div class="card-body register-card-body">
|
||||
<p class="login-box-msg">@ViewData["Title"]</p>
|
||||
<div class="row">
|
||||
<div class="col-md-12 text-center mb-3">
|
||||
<h3 class="text-dark">Email Confirm</h3>
|
||||
<a asp-page="/Index" class="">
|
||||
<p><i class="fas fa-home me-2 text-warning"></i><span class="text-dark">INDOTALENT</span></p>
|
||||
</a>
|
||||
</div>
|
||||
<div class="col-md-12">
|
||||
<p>Please wait...</p>
|
||||
<p>Email confirmation is in progress.</p>
|
||||
<span class="spinner-border spinner-border-sm me-2"
|
||||
v-if="state.isSubmitting"
|
||||
role="status"
|
||||
aria-hidden="true"></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
@section scripts {
|
||||
<script src="~/FrontEnd/Pages/Accounts/EmailConfirm.cshtml.js"></script>
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
const App = {
|
||||
setup() {
|
||||
const state = Vue.reactive({
|
||||
isSubmitting: false,
|
||||
});
|
||||
|
||||
const emailConfirmation = async (email, code) => {
|
||||
try {
|
||||
const response = await AxiosManager.get(`/Security/ConfirmEmail?email=${email}&code=${code}`, {});
|
||||
return response;
|
||||
} catch (error) {
|
||||
console.error('Error during emailConfirmation:', error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Vue.onMounted(async () => {
|
||||
try {
|
||||
state.isSubmitting = true;
|
||||
await new Promise(resolve => setTimeout(resolve, 300));
|
||||
|
||||
const params = new URLSearchParams(window.location.search);
|
||||
const email = params.get('email');
|
||||
const code = params.get('code');
|
||||
|
||||
if (email && code) {
|
||||
const response = await emailConfirmation(email, code);
|
||||
if (response.data.code === 200) {
|
||||
Swal.fire({
|
||||
icon: 'success',
|
||||
title: 'Email Confirmation Successful',
|
||||
text: 'You are being redirected...',
|
||||
timer: 2000,
|
||||
showConfirmButton: false
|
||||
});
|
||||
setTimeout(() => {
|
||||
window.location.href = '/Accounts/Login';
|
||||
}, 2000);
|
||||
} else {
|
||||
Swal.fire({
|
||||
icon: 'error',
|
||||
title: 'Email Confirmation Failed',
|
||||
text: response.data.message ?? 'Please check your data.',
|
||||
confirmButtonText: 'Try Again'
|
||||
});
|
||||
}
|
||||
} else {
|
||||
Swal.fire({
|
||||
icon: 'error',
|
||||
title: 'Email Confirmation Failed',
|
||||
text: 'Email or code is missing in the URL query string.',
|
||||
confirmButtonText: 'Try Again'
|
||||
});
|
||||
}
|
||||
|
||||
} catch (e) {
|
||||
console.error('page init error:', e);
|
||||
} finally {
|
||||
state.isSubmitting = false;
|
||||
}
|
||||
});
|
||||
|
||||
return {
|
||||
state
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
Vue.createApp(App).mount('#app');
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
@page
|
||||
@{
|
||||
ViewData["Title"] = "Forgot Password";
|
||||
}
|
||||
|
||||
<div class="container-fluid" id="app" v-cloak>
|
||||
<div class="card-body register-card-body">
|
||||
<p class="login-box-msg">@ViewData["Title"]</p>
|
||||
|
||||
<form v-on:submit.prevent="handleSubmit">
|
||||
<div class="input-group mb-3">
|
||||
<input id="Email"
|
||||
name="Email"
|
||||
type="email"
|
||||
class="form-control"
|
||||
placeholder="name@example.com"
|
||||
v-model="state.email"
|
||||
v-on:input="state.errors.email = ''">
|
||||
<div class="input-group-append">
|
||||
<div class="input-group-text">
|
||||
<span class="fas fa-envelope"></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<label v-if="state.errors.email" class="text-danger">{{ state.errors.email }}</label>
|
||||
<div class="row">
|
||||
<div class="col-8">
|
||||
</div>
|
||||
<!-- /.col -->
|
||||
<div class="col-4">
|
||||
<button type="submit"
|
||||
v-bind:disabled="state.isSubmitting"
|
||||
class="btn btn-primary btn-block">
|
||||
<span class="spinner-border spinner-border-sm me-2"
|
||||
v-if="state.isSubmitting"
|
||||
role="status"
|
||||
aria-hidden="true"></span>
|
||||
<span>{{ state.isSubmitting ? '...' : 'Reset' }}</span>
|
||||
</button>
|
||||
</div>
|
||||
<!-- /.col -->
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<div class="social-auth-links text-center">
|
||||
<p>- OR -</p>
|
||||
<a href="#" class="btn btn-block btn-primary">
|
||||
<i class="fab fa-facebook mr-2"></i>
|
||||
Sign up using Facebook
|
||||
</a>
|
||||
<a href="#" class="btn btn-block btn-danger">
|
||||
<i class="fab fa-google-plus mr-2"></i>
|
||||
Sign up using Google+
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<p class="mb-1">
|
||||
<a asp-page="/Accounts/Login" class="text-center">I already have a membership</a>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
@section scripts {
|
||||
<script src="~/FrontEnd/Pages/Accounts/ForgotPassword.cshtml.js"></script>
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
const App = {
|
||||
setup() {
|
||||
const state = Vue.reactive({
|
||||
email: '',
|
||||
isSubmitting: false,
|
||||
errors: {
|
||||
email: ''
|
||||
}
|
||||
});
|
||||
|
||||
const validateForm = () => {
|
||||
state.errors.email = '';
|
||||
let isValid = true;
|
||||
|
||||
if (!state.email) {
|
||||
state.errors.email = 'Email is required.';
|
||||
isValid = false;
|
||||
} else if (!/\S+@\S+\.\S+/.test(state.email)) {
|
||||
state.errors.email = 'Please enter a valid email address.';
|
||||
isValid = false;
|
||||
}
|
||||
|
||||
return isValid;
|
||||
};
|
||||
|
||||
|
||||
const forgotPassword = async (email) => {
|
||||
try {
|
||||
const response = await AxiosManager.post('/Security/ForgotPassword', {
|
||||
email
|
||||
});
|
||||
return response;
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
const handleSubmit = async () => {
|
||||
|
||||
try {
|
||||
state.isSubmitting = true;
|
||||
await new Promise(resolve => setTimeout(resolve, 300));
|
||||
|
||||
if (!validateForm()) return;
|
||||
|
||||
const response = await forgotPassword(state.email);
|
||||
if (response.data.code === 200) {
|
||||
Swal.fire({
|
||||
icon: 'success',
|
||||
title: 'Reset Password Successful',
|
||||
text: 'Please check your email. You are being redirected...',
|
||||
timer: 2000,
|
||||
showConfirmButton: false
|
||||
});
|
||||
setTimeout(() => {
|
||||
window.location.href = '/';
|
||||
}, 2000);
|
||||
} else {
|
||||
Swal.fire({
|
||||
icon: 'error',
|
||||
title: 'Reset Password Failed',
|
||||
text: response.data.message ?? 'Please check your data.',
|
||||
confirmButtonText: 'Try Again'
|
||||
});
|
||||
}
|
||||
|
||||
} catch (error) {
|
||||
Swal.fire({
|
||||
icon: 'error',
|
||||
title: 'An Error Occurred',
|
||||
text: error.response?.data?.message || 'Please try again.',
|
||||
confirmButtonText: 'OK'
|
||||
});
|
||||
} finally {
|
||||
state.isSubmitting = false;
|
||||
}
|
||||
};
|
||||
|
||||
return {
|
||||
state,
|
||||
handleSubmit
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
Vue.createApp(App).mount('#app');
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
@page
|
||||
@{
|
||||
ViewData["Title"] = "Forgot Password Confirmation";
|
||||
}
|
||||
<div class="container-fluid" id="app" v-cloak>
|
||||
|
||||
<div class="card-body register-card-body">
|
||||
<p class="login-box-msg">@ViewData["Title"]</p>
|
||||
<div class="row">
|
||||
<div class="col-md-12 text-center mb-3">
|
||||
<h3 class="text-dark">Forgot Password Confirm</h3>
|
||||
<a asp-page="/Index" class="">
|
||||
<p><i class="fas fa-home me-2 text-warning"></i><span class="text-dark">INDOTALENT</span></p>
|
||||
</a>
|
||||
</div>
|
||||
<div class="col-md-12">
|
||||
<p>Please wait...</p>
|
||||
<p>Password reset is in progress.</p>
|
||||
<span class="spinner-border spinner-border-sm me-2"
|
||||
v-if="state.isSubmitting"
|
||||
role="status"
|
||||
aria-hidden="true"></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
@section scripts {
|
||||
<script src="~/FrontEnd/Pages/Accounts/ForgotPasswordConfirmation.cshtml.js"></script>
|
||||
}
|
||||
+71
@@ -0,0 +1,71 @@
|
||||
const App = {
|
||||
setup() {
|
||||
const state = Vue.reactive({
|
||||
isSubmitting: false,
|
||||
});
|
||||
|
||||
const forgotPasswordConfirmation = async (email, code, tempPassword) => {
|
||||
try {
|
||||
const response = await AxiosManager.get(`/Security/ForgotPasswordConfirmation?email=${email}&code=${code}&tempPassword=${tempPassword}`, {});
|
||||
return response;
|
||||
} catch (error) {
|
||||
console.error('Error during ForgotPasswordConfirmation:', error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Vue.onMounted(async () => {
|
||||
try {
|
||||
state.isSubmitting = true;
|
||||
await new Promise(resolve => setTimeout(resolve, 300));
|
||||
|
||||
const params = new URLSearchParams(window.location.search);
|
||||
const email = params.get('email');
|
||||
const code = params.get('code');
|
||||
const tempPassword = params.get('tempPassword');
|
||||
|
||||
if (email && code && tempPassword) {
|
||||
const response = await forgotPasswordConfirmation(email, code, tempPassword);
|
||||
if (response.data.code === 200) {
|
||||
Swal.fire({
|
||||
icon: 'success',
|
||||
title: 'Password Reset Successful',
|
||||
text: 'You are being redirected...',
|
||||
timer: 2000,
|
||||
showConfirmButton: false
|
||||
});
|
||||
setTimeout(() => {
|
||||
window.location.href = '/Accounts/Login';
|
||||
}, 2000);
|
||||
} else {
|
||||
Swal.fire({
|
||||
icon: 'error',
|
||||
title: 'Password Reset Failed',
|
||||
text: response.data.message ?? 'Please check your data.',
|
||||
confirmButtonText: 'Try Again'
|
||||
});
|
||||
}
|
||||
} else {
|
||||
Swal.fire({
|
||||
icon: 'error',
|
||||
title: 'Password Reset Failed',
|
||||
text: 'Email or code is missing in the URL query string.',
|
||||
confirmButtonText: 'Try Again'
|
||||
});
|
||||
}
|
||||
|
||||
} catch (e) {
|
||||
console.error('page init error:', e);
|
||||
} finally {
|
||||
state.isSubmitting = false;
|
||||
}
|
||||
});
|
||||
|
||||
return {
|
||||
state
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
Vue.createApp(App).mount('#app');
|
||||
@@ -0,0 +1,91 @@
|
||||
@page
|
||||
@{
|
||||
ViewData["Title"] = "Login";
|
||||
}
|
||||
|
||||
<div id="app" class="container-fluid" v-cloak>
|
||||
|
||||
<div class="card-body login-card-body">
|
||||
<p class="login-box-msg">@ViewData["Title"]</p>
|
||||
|
||||
<form v-on:submit.prevent="handleSubmit">
|
||||
<div class="input-group mb-3">
|
||||
<input id="Email"
|
||||
name="Email"
|
||||
type="email"
|
||||
class="form-control"
|
||||
placeholder="name@example.com"
|
||||
v-model="state.email"
|
||||
v-on:input="state.errors.email = ''">
|
||||
<div class="input-group-append">
|
||||
<div class="input-group-text">
|
||||
<span class="fas fa-envelope"></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<label v-if="state.errors.email" class="text-danger">{{ state.errors.email }}</label>
|
||||
<div class="input-group mb-3">
|
||||
<input id="Password"
|
||||
name="Password"
|
||||
type="password"
|
||||
class="form-control"
|
||||
placeholder="Password"
|
||||
v-model="state.password"
|
||||
v-on:input="state.errors.password = ''">
|
||||
<div class="input-group-append">
|
||||
<div class="input-group-text">
|
||||
<span class="fas fa-lock"></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<label v-if="state.errors.password" class="text-danger">{{ state.errors.password }}</label>
|
||||
<div class="row">
|
||||
<div class="col-8">
|
||||
<div class="icheck-primary">
|
||||
<input type="checkbox">
|
||||
<label for="remember">
|
||||
Remember Me
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<!-- /.col -->
|
||||
<div class="col-4">
|
||||
<button type="submit"
|
||||
v-bind:disabled="state.isSubmitting"
|
||||
class="btn btn-primary btn-block">
|
||||
<span class="spinner-border spinner-border-sm me-2"
|
||||
v-if="state.isSubmitting"
|
||||
role="status"
|
||||
aria-hidden="true"></span>
|
||||
<span>{{ state.isSubmitting ? '...' : 'Log In' }}</span>
|
||||
</button>
|
||||
</div>
|
||||
<!-- /.col -->
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<div class="social-auth-links text-center mb-3">
|
||||
<p>- OR -</p>
|
||||
<a href="#" class="btn btn-block btn-primary">
|
||||
<i class="fab fa-facebook mr-2"></i> Sign in using Facebook
|
||||
</a>
|
||||
<a href="#" class="btn btn-block btn-danger">
|
||||
<i class="fab fa-google-plus mr-2"></i> Sign in using Google+
|
||||
</a>
|
||||
</div>
|
||||
<!-- /.social-auth-links -->
|
||||
|
||||
<p class="mb-1">
|
||||
<a asp-page="/Accounts/ForgotPassword">Forgot Password</a>
|
||||
</p>
|
||||
<p class="mb-0">
|
||||
<a asp-page="/Accounts/Register" class="text-center">Register a new membership</a>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
@section scripts {
|
||||
<script type ="module" src="~/FrontEnd/Pages/Accounts/Login.cshtml.js"></script>
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
const App = {
|
||||
setup() {
|
||||
const state = Vue.reactive({
|
||||
email: '',
|
||||
password: '',
|
||||
isSubmitting: false,
|
||||
errors: {
|
||||
email: '',
|
||||
password: ''
|
||||
}
|
||||
});
|
||||
|
||||
const validateForm = () => {
|
||||
state.errors.email = '';
|
||||
state.errors.password = '';
|
||||
let isValid = true;
|
||||
|
||||
if (!state.email) {
|
||||
state.errors.email = 'Email is required.';
|
||||
isValid = false;
|
||||
} else if (!/\S+@\S+\.\S+/.test(state.email)) {
|
||||
state.errors.email = 'Please enter a valid email address.';
|
||||
isValid = false;
|
||||
}
|
||||
|
||||
if (!state.password) {
|
||||
state.errors.password = 'Password is required.';
|
||||
isValid = false;
|
||||
} else if (state.password.length < 6) {
|
||||
state.errors.password = 'Password must be at least 6 characters.';
|
||||
isValid = false;
|
||||
}
|
||||
|
||||
return isValid;
|
||||
};
|
||||
|
||||
const handleSubmit = async () => {
|
||||
|
||||
try {
|
||||
state.isSubmitting = true;
|
||||
await new Promise(resolve => setTimeout(resolve, 300));
|
||||
|
||||
if (!validateForm()) {
|
||||
return;
|
||||
}
|
||||
|
||||
const response = await AxiosManager.post('/Security/Login', {
|
||||
email: state.email,
|
||||
password: state.password
|
||||
});
|
||||
|
||||
if (response.data.code === 200) {
|
||||
StorageManager.saveLoginResult(response.data);
|
||||
|
||||
Swal.fire({
|
||||
icon: 'success',
|
||||
title: 'Login Successful',
|
||||
text: 'You are being redirected...',
|
||||
timer: 2000,
|
||||
showConfirmButton: false
|
||||
});
|
||||
|
||||
setTimeout(() => {
|
||||
window.location.href = '/Profiles/MyProfile';
|
||||
}, 2000);
|
||||
} else {
|
||||
Swal.fire({
|
||||
icon: 'error',
|
||||
title: 'Login Failed',
|
||||
text: response.data.message || 'Please check your credentials.',
|
||||
confirmButtonText: 'Try Again'
|
||||
});
|
||||
}
|
||||
} catch (error) {
|
||||
Swal.fire({
|
||||
icon: 'error',
|
||||
title: 'An Error Occurred',
|
||||
text: error.response?.data?.message || 'Please try again.',
|
||||
confirmButtonText: 'OK'
|
||||
});
|
||||
} finally {
|
||||
state.isSubmitting = false;
|
||||
}
|
||||
};
|
||||
|
||||
return {
|
||||
state,
|
||||
handleSubmit
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
Vue.createApp(App).mount('#app');
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
@page
|
||||
@{
|
||||
ViewData["Title"] = "Logout";
|
||||
}
|
||||
|
||||
<div class="container-fluid" id="app" v-cloak>
|
||||
|
||||
<div class="card-body login-card-body">
|
||||
<p class="login-box-msg">@ViewData["Title"]</p>
|
||||
|
||||
|
||||
|
||||
<div class="social-auth-links text-center mb-3">
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<form v-on:submit.prevent="handleSubmit">
|
||||
<div class="form-group mb-2 text-center">
|
||||
<p>Are you sure you want to log out?</p>
|
||||
<p>Click the button below to confirm and log out completely.</p>
|
||||
</div>
|
||||
<button type="submit"
|
||||
v-bind:disabled="state.isSubmitting"
|
||||
class="btn btn-primary w-100 mb-2">
|
||||
<span class="spinner-border spinner-border-sm me-2"
|
||||
v-if="state.isSubmitting"
|
||||
role="status"
|
||||
aria-hidden="true"></span>
|
||||
<span>{{ state.isSubmitting ? '...' : 'Log Out' }}</span>
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
@section scripts {
|
||||
<script src="~/FrontEnd/Pages/Accounts/Logout.cshtml.js"></script>
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
const App = {
|
||||
setup() {
|
||||
const state = Vue.reactive({
|
||||
isSubmitting: false,
|
||||
});
|
||||
|
||||
const logout = async () => {
|
||||
try {
|
||||
const response = await AxiosManager.post('/Security/Logout', {
|
||||
userId: StorageManager.getUserId()
|
||||
});
|
||||
return response;
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
const handleSubmit = async () => {
|
||||
|
||||
try {
|
||||
state.isSubmitting = true;
|
||||
await new Promise(resolve => setTimeout(resolve, 300));
|
||||
|
||||
const response = await logout();
|
||||
if (response.data.code === 200) {
|
||||
StorageManager.clearStorage();
|
||||
|
||||
Swal.fire({
|
||||
icon: 'success',
|
||||
title: 'Logout Successful',
|
||||
text: 'You are being redirected...',
|
||||
timer: 2000,
|
||||
showConfirmButton: false
|
||||
});
|
||||
setTimeout(() => {
|
||||
window.location.href = '/';
|
||||
}, 2000);
|
||||
} else {
|
||||
Swal.fire({
|
||||
icon: 'error',
|
||||
title: 'Logout Failed',
|
||||
text: response.data.message ?? 'Logout Failed.',
|
||||
confirmButtonText: 'Try Again'
|
||||
});
|
||||
}
|
||||
|
||||
} catch (error) {
|
||||
Swal.fire({
|
||||
icon: 'error',
|
||||
title: 'An Error Occurred',
|
||||
text: error.response?.data?.message || 'Please try again.',
|
||||
confirmButtonText: 'OK'
|
||||
});
|
||||
} finally {
|
||||
state.isSubmitting = false;
|
||||
}
|
||||
};
|
||||
|
||||
return {
|
||||
state,
|
||||
handleSubmit
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
Vue.createApp(App).mount('#app');
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,149 @@
|
||||
@page
|
||||
@{
|
||||
ViewData["Title"] = "Register";
|
||||
}
|
||||
<div id="app" class="container-fluid" v-cloak>
|
||||
|
||||
<div class="card-body register-card-body">
|
||||
<p class="login-box-msg">@ViewData["Title"]</p>
|
||||
|
||||
<form v-on:submit.prevent="handleSubmit">
|
||||
<div class="input-group mb-3">
|
||||
<input id="Email"
|
||||
name="Email"
|
||||
type="email"
|
||||
placeholder="Enter Email"
|
||||
class="form-control"
|
||||
v-model="state.email"
|
||||
v-on:input="state.errors.email = ''">
|
||||
<div class="input-group-append">
|
||||
<div class="input-group-text">
|
||||
<span class="fas fa-envelope"></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<label v-if="state.errors.email" class="text-danger small">{{ state.errors.email }}</label>
|
||||
<div class="input-group mb-3">
|
||||
<input id="CompanyName"
|
||||
name="CompanyName"
|
||||
type="text"
|
||||
placeholder="Enter Company Name"
|
||||
class="form-control"
|
||||
v-model="state.companyName">
|
||||
<div class="input-group-append">
|
||||
<div class="input-group-text">
|
||||
<span class="fas fa-edit"></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="input-group mb-3">
|
||||
<input id="FirstName"
|
||||
name="FirstName"
|
||||
type="text"
|
||||
placeholder="Enter First Name"
|
||||
class="form-control"
|
||||
v-model="state.firstName"
|
||||
v-on:input="state.errors.firstName = ''">
|
||||
<div class="input-group-append">
|
||||
<div class="input-group-text">
|
||||
<span class="fas fa-edit"></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<label v-if="state.errors.firstName" class="text-danger small">{{ state.errors.firstName }}</label>
|
||||
<div class="input-group mb-3">
|
||||
<input id="LastName"
|
||||
name="LastName"
|
||||
type="text"
|
||||
placeholder="Enter Last Name"
|
||||
class="form-control"
|
||||
v-model="state.lastName"
|
||||
v-on:input="state.errors.lastName = ''">
|
||||
<div class="input-group-append">
|
||||
<div class="input-group-text">
|
||||
<span class="fas fa-edit"></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<label v-if="state.errors.lastName" class="text-danger small">{{ state.errors.lastName }}</label>
|
||||
<div class="input-group mb-3">
|
||||
<input id="Password"
|
||||
name="Password"
|
||||
type="password"
|
||||
placeholder="Enter Password"
|
||||
class="form-control"
|
||||
v-model="state.password"
|
||||
v-on:input="state.errors.password = ''">
|
||||
<div class="input-group-append">
|
||||
<div class="input-group-text">
|
||||
<span class="fas fa-lock"></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<label v-if="state.errors.password" class="text-danger small">{{ state.errors.password }}</label>
|
||||
<div class="input-group mb-3">
|
||||
<input id="ConfirmPassword"
|
||||
name="ConfirmPassword"
|
||||
type="password"
|
||||
placeholder="Re-type Password"
|
||||
class="form-control"
|
||||
v-model="state.confirmPassword"
|
||||
v-on:input="state.errors.confirmPassword = ''">
|
||||
<div class="input-group-append">
|
||||
<div class="input-group-text">
|
||||
<span class="fas fa-lock"></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<label v-if="state.errors.confirmPassword" class="text-danger small">{{ state.errors.confirmPassword }}</label>
|
||||
<div class="row">
|
||||
<div class="col-8">
|
||||
<div class="icheck-primary">
|
||||
<input type="checkbox">
|
||||
<label for="remember">
|
||||
Remember Me
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<!-- /.col -->
|
||||
<div class="col-4">
|
||||
<button type="submit"
|
||||
v-bind:disabled="state.isSubmitting"
|
||||
class="btn btn-primary btn-block">
|
||||
<span class="spinner-border spinner-border-sm me-2"
|
||||
v-if="state.isSubmitting"
|
||||
role="status"
|
||||
aria-hidden="true"></span>
|
||||
<span>{{ state.isSubmitting ? '...' : 'Register' }}</span>
|
||||
</button>
|
||||
</div>
|
||||
<!-- /.col -->
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<div class="social-auth-links text-center">
|
||||
<p>- OR -</p>
|
||||
<a href="#" class="btn btn-block btn-primary">
|
||||
<i class="fab fa-facebook mr-2"></i>
|
||||
Sign up using Facebook
|
||||
</a>
|
||||
<a href="#" class="btn btn-block btn-danger">
|
||||
<i class="fab fa-google-plus mr-2"></i>
|
||||
Sign up using Google+
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<p class="mb-1">
|
||||
<a asp-page="/Accounts/ForgotPassword">I forgot my password</a>
|
||||
</p>
|
||||
<p class="mb-1">
|
||||
<a asp-page="/Accounts/Login" class="text-center">I already have a membership</a>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
@section scripts {
|
||||
<script type="module" src="~/FrontEnd/Pages/Accounts/Register.cshtml.js"></script>
|
||||
}
|
||||
@@ -0,0 +1,123 @@
|
||||
const App = {
|
||||
setup() {
|
||||
const state = Vue.reactive({
|
||||
email: '',
|
||||
password: '',
|
||||
confirmPassword: '',
|
||||
firstName: '',
|
||||
lastName: '',
|
||||
companyName: '',
|
||||
isSubmitting: false,
|
||||
errors: {
|
||||
email: '',
|
||||
password: '',
|
||||
confirmPassword: '',
|
||||
firstName: '',
|
||||
lastName: ''
|
||||
}
|
||||
});
|
||||
|
||||
const validateForm = () => {
|
||||
// Reset errors
|
||||
state.errors.email = '';
|
||||
state.errors.password = '';
|
||||
state.errors.confirmPassword = '';
|
||||
state.errors.firstName = '';
|
||||
state.errors.lastName = '';
|
||||
|
||||
let isValid = true;
|
||||
|
||||
if (!state.email) {
|
||||
state.errors.email = 'Email is required.';
|
||||
isValid = false;
|
||||
} else if (!/\S+@\S+\.\S+/.test(state.email)) {
|
||||
state.errors.email = 'Please enter a valid email address.';
|
||||
isValid = false;
|
||||
}
|
||||
|
||||
if (!state.password) {
|
||||
state.errors.password = 'Password is required.';
|
||||
isValid = false;
|
||||
} else if (state.password.length < 6) {
|
||||
state.errors.password = 'Password must be at least 6 characters.';
|
||||
isValid = false;
|
||||
}
|
||||
|
||||
if (!state.confirmPassword) {
|
||||
state.errors.confirmPassword = 'Confirm Password is required.';
|
||||
isValid = false;
|
||||
} else if (state.password !== state.confirmPassword) {
|
||||
state.errors.confirmPassword = 'Passwords do not match.';
|
||||
isValid = false;
|
||||
}
|
||||
|
||||
if (!state.firstName) {
|
||||
state.errors.firstName = 'First Name is required.';
|
||||
isValid = false;
|
||||
}
|
||||
|
||||
if (!state.lastName) {
|
||||
state.errors.lastName = 'Last Name is required.';
|
||||
isValid = false;
|
||||
}
|
||||
|
||||
return isValid;
|
||||
};
|
||||
|
||||
const handleSubmit = async () => {
|
||||
|
||||
try {
|
||||
state.isSubmitting = true;
|
||||
await new Promise(resolve => setTimeout(resolve, 300));
|
||||
|
||||
if (!validateForm()) return;
|
||||
|
||||
const response = await AxiosManager.post('/Security/Register', {
|
||||
email: state.email,
|
||||
password: state.password,
|
||||
confirmPassword: state.confirmPassword,
|
||||
firstName: state.firstName,
|
||||
lastName: state.lastName,
|
||||
companyName: state.companyName
|
||||
});
|
||||
|
||||
if (response.data.code === 200) {
|
||||
Swal.fire({
|
||||
icon: 'success',
|
||||
title: 'Register Successful',
|
||||
text: 'Please check your email. You are being redirected...',
|
||||
timer: 2000,
|
||||
showConfirmButton: false
|
||||
});
|
||||
|
||||
setTimeout(() => {
|
||||
window.location.href = '/';
|
||||
}, 2000);
|
||||
} else {
|
||||
Swal.fire({
|
||||
icon: 'error',
|
||||
title: 'Register Failed',
|
||||
text: response.data.message || 'Please check your data.',
|
||||
confirmButtonText: 'Try Again'
|
||||
});
|
||||
}
|
||||
} catch (error) {
|
||||
Swal.fire({
|
||||
icon: 'error',
|
||||
title: 'An Error Occurred',
|
||||
text: error.response?.data?.message || 'Please try again.',
|
||||
confirmButtonText: 'OK'
|
||||
});
|
||||
} finally {
|
||||
state.isSubmitting = false;
|
||||
}
|
||||
};
|
||||
|
||||
return {
|
||||
state,
|
||||
handleSubmit
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
Vue.createApp(App).mount('#app');
|
||||
@@ -0,0 +1,3 @@
|
||||
@{
|
||||
Layout = "~/FrontEnd/Pages/Shared/AdminLTE/_Auth.cshtml";
|
||||
}
|
||||
@@ -0,0 +1,160 @@
|
||||
@page
|
||||
@attribute [Authorize(Roles = "Companies")]
|
||||
@{
|
||||
ViewData["Title"] = "My Company";
|
||||
}
|
||||
|
||||
<div id="app" v-cloak>
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<div class="grid-container">
|
||||
<div ref="mainGridRef"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="modal fade" ref="mainModalRef" id="MainModal" tabindex="-1" aria-hidden="true" data-bs-backdrop="static">
|
||||
<div class="modal-dialog modal-dialog-centered modal-lg">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title">{{ state.mainTitle }}</h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<input type="hidden" v-model="state.id" id="Id" name="Id" />
|
||||
<form id="MainForm">
|
||||
<div class="row mb-0">
|
||||
<!-- Main Info -->
|
||||
<div class="col-md-12">
|
||||
<div class="card mb-3">
|
||||
<div class="card-header">
|
||||
<h5>Main Info</h5>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="row mb-2">
|
||||
<div class="col-md-6">
|
||||
<label for="Name">Name</label>
|
||||
<input ref="nameRef" v-model="state.name" type="text" class="form-control" placeholder="">
|
||||
<label class="text-danger">{{ state.errors.name }}</label>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<label for="Currency">Currency</label>
|
||||
<input ref="currencyRef" v-model="state.currency" type="text" class="form-control" placeholder="">
|
||||
<label class="text-danger">{{ state.errors.currency }}</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mb-2">
|
||||
<div class="col-12">
|
||||
<label for="Description">Description</label>
|
||||
<textarea ref="descriptionRef" v-model="state.description" class="form-control" rows="3"></textarea>
|
||||
<label class="text-danger">{{ state.errors.description }}</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row mb-0">
|
||||
<!-- Address -->
|
||||
<div class="col-md-12">
|
||||
<div class="card mb-3">
|
||||
<div class="card-header">
|
||||
<h5>Address</h5>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="row mb-2">
|
||||
<div class="col-md-6">
|
||||
<label for="Street">Street</label>
|
||||
<input ref="streetRef" v-model="state.street" type="text" class="form-control" placeholder="">
|
||||
<label class="text-danger">{{ state.errors.street }}</label>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<label for="City">City</label>
|
||||
<input ref="cityRef" v-model="state.city" type="text" class="form-control" placeholder="">
|
||||
<label class="text-danger">{{ state.errors.city }}</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mb-2">
|
||||
<div class="col-md-6">
|
||||
<label for="State">State</label>
|
||||
<input ref="stateRef" v-model="state.state" type="text" class="form-control" placeholder="">
|
||||
<label class="text-danger">{{ state.errors.state }}</label>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<label for="ZipCode">Zip Code</label>
|
||||
<input ref="zipCodeRef" v-model="state.zipCode" type="text" class="form-control" placeholder="">
|
||||
<label class="text-danger">{{ state.errors.zipCode }}</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mb-2">
|
||||
<div class="col-md-6">
|
||||
<label for="Country">Country</label>
|
||||
<input ref="countryRef" v-model="state.country" type="text" class="form-control" placeholder="">
|
||||
<label class="text-danger">{{ state.errors.country }}</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row mb-0">
|
||||
<!-- Communication -->
|
||||
<div class="col-md-12">
|
||||
<div class="card mb-3">
|
||||
<div class="card-header">
|
||||
<h5>Communication</h5>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="row mb-2">
|
||||
<div class="col-md-6">
|
||||
<label for="PhoneNumber">Phone Number</label>
|
||||
<input ref="phoneNumberRef" v-model="state.phoneNumber" type="text" class="form-control" placeholder="">
|
||||
<label class="text-danger">{{ state.errors.phoneNumber }}</label>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<label for="FaxNumber">Fax Number</label>
|
||||
<input ref="faxNumberRef" v-model="state.faxNumber" type="text" class="form-control" placeholder="">
|
||||
<label class="text-danger">{{ state.errors.faxNumber }}</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mb-2">
|
||||
<div class="col-md-6">
|
||||
<label for="EmailAddress">Email Address</label>
|
||||
<input ref="emailAddressRef" v-model="state.emailAddress" type="email" class="form-control" placeholder="">
|
||||
<label class="text-danger">{{ state.errors.emailAddress }}</label>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<label for="Website">Website</label>
|
||||
<input ref="websiteRef" v-model="state.website" type="url" class="form-control" placeholder="">
|
||||
<label class="text-danger">{{ state.errors.website }}</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
|
||||
<button type="button"
|
||||
id="MainSaveButton"
|
||||
class="btn"
|
||||
v-bind:class="state.deleteMode ? 'btn-danger' : 'btn-primary'"
|
||||
v-on:click="handler.handleSubmit"
|
||||
v-bind:disabled="state.isSubmitting">
|
||||
<span class="spinner-border spinner-border-sm me-2" v-if="state.isSubmitting" role="status" aria-hidden="true"></span>
|
||||
<span v-if="!state.isSubmitting">{{ state.deleteMode ? 'Delete' : 'Save' }}</span>
|
||||
<span v-else>{{ state.deleteMode ? 'Deleting...' : 'Saving...' }}</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@section scripts {
|
||||
<script src="~/FrontEnd/Pages/Companies/MyCompany.cshtml.js"></script>
|
||||
}
|
||||
@@ -0,0 +1,596 @@
|
||||
const App = {
|
||||
setup() {
|
||||
const state = Vue.reactive({
|
||||
mainData: [],
|
||||
deleteMode: false,
|
||||
mainTitle: 'Edit Company',
|
||||
id: '',
|
||||
name: '',
|
||||
description: '',
|
||||
currency: '',
|
||||
street: '',
|
||||
city: '',
|
||||
state: '',
|
||||
zipCode: '',
|
||||
country: '',
|
||||
phoneNumber: '',
|
||||
faxNumber: '',
|
||||
emailAddress: '',
|
||||
website: '',
|
||||
errors: {
|
||||
name: '',
|
||||
currency: '',
|
||||
street: '',
|
||||
city: '',
|
||||
state: '',
|
||||
zipCode: '',
|
||||
phoneNumber: '',
|
||||
emailAddress: ''
|
||||
},
|
||||
isSubmitting: false
|
||||
});
|
||||
|
||||
const mainGridRef = Vue.ref(null);
|
||||
const mainModalRef = Vue.ref(null);
|
||||
const nameRef = Vue.ref(null);
|
||||
const currencyRef = Vue.ref(null);
|
||||
const streetRef = Vue.ref(null);
|
||||
const cityRef = Vue.ref(null);
|
||||
const stateRef = Vue.ref(null);
|
||||
const zipCodeRef = Vue.ref(null);
|
||||
const countryRef = Vue.ref(null);
|
||||
const phoneNumberRef = Vue.ref(null);
|
||||
const faxNumberRef = Vue.ref(null);
|
||||
const emailAddressRef = Vue.ref(null);
|
||||
const websiteRef = Vue.ref(null);
|
||||
|
||||
const services = {
|
||||
getMainData: async () => {
|
||||
try {
|
||||
const response = await AxiosManager.get('/Company/GetCompanyList', {});
|
||||
return response;
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
},
|
||||
updateMainData: async (
|
||||
id, name, description, currency, street, city, state, zipCode, country,
|
||||
phoneNumber, faxNumber, emailAddress, website, updatedById
|
||||
) => {
|
||||
try {
|
||||
const response = await AxiosManager.post('/Company/UpdateCompany', {
|
||||
id,
|
||||
name,
|
||||
description,
|
||||
currency,
|
||||
street,
|
||||
city,
|
||||
state,
|
||||
zipCode,
|
||||
country,
|
||||
phoneNumber,
|
||||
faxNumber,
|
||||
emailAddress,
|
||||
website,
|
||||
updatedById
|
||||
});
|
||||
return response;
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
const mainGrid = {
|
||||
obj: null,
|
||||
create: async (dataSource) => {
|
||||
mainGrid.obj = new ej.grids.Grid({
|
||||
height: '240px',
|
||||
dataSource: dataSource,
|
||||
allowFiltering: true,
|
||||
allowSorting: true,
|
||||
allowSelection: true,
|
||||
allowGrouping: true,
|
||||
allowTextWrap: true,
|
||||
allowResizing: true,
|
||||
allowPaging: true,
|
||||
allowExcelExport: true,
|
||||
filterSettings: { type: 'CheckBox' },
|
||||
sortSettings: { columns: [{ field: 'createdAtUtc', direction: 'Descending' }] },
|
||||
pageSettings: { currentPage: 1, pageSize: 50, pageSizes: ["10", "20", "50", "100", "200", "All"] },
|
||||
selectionSettings: { persistSelection: true, type: 'Single' },
|
||||
autoFit: true,
|
||||
showColumnMenu: true,
|
||||
gridLines: 'Horizontal',
|
||||
columns: [
|
||||
{ type: 'checkbox', width: 60 },
|
||||
{
|
||||
field: 'id', isPrimaryKey: true, headerText: 'Id', visible: false
|
||||
},
|
||||
{ field: 'name', headerText: 'Name', width: 150, minWidth: 150 },
|
||||
{ field: 'currency', headerText: 'Currency', width: 150, minWidth: 150 },
|
||||
{ field: 'street', headerText: 'Street', width: 150, minWidth: 150 },
|
||||
{ field: 'phoneNumber', headerText: 'Phone#', width: 150, minWidth: 150 },
|
||||
{ field: 'emailAddress', headerText: 'Email', width: 150, minWidth: 150 },
|
||||
{ field: 'createdAtUtc', headerText: 'Created At UTC', width: 150, format: 'yyyy-MM-dd HH:mm' }
|
||||
],
|
||||
toolbar: [
|
||||
'ExcelExport', 'Search',
|
||||
{ type: 'Separator' },
|
||||
{ text: 'Edit', tooltipText: 'Edit', prefixIcon: 'e-edit', id: 'EditCustom' },
|
||||
{ type: 'Separator' },
|
||||
],
|
||||
beforeDataBound: () => { },
|
||||
dataBound: function () {
|
||||
mainGrid.obj.toolbarModule.enableItems(['EditCustom'], false);
|
||||
mainGrid.obj.autoFitColumns(['name', 'currency', 'street', 'phoneNumber', 'emailAddress', 'createdAtUtc']);
|
||||
},
|
||||
excelExportComplete: () => { },
|
||||
rowSelected: () => {
|
||||
if (mainGrid.obj.getSelectedRecords().length === 1) {
|
||||
mainGrid.obj.toolbarModule.enableItems(['EditCustom'], true);
|
||||
} else {
|
||||
mainGrid.obj.toolbarModule.enableItems(['EditCustom'], false);
|
||||
}
|
||||
},
|
||||
rowDeselected: () => {
|
||||
if (mainGrid.obj.getSelectedRecords().length === 1) {
|
||||
mainGrid.obj.toolbarModule.enableItems(['EditCustom'], true);
|
||||
} else {
|
||||
mainGrid.obj.toolbarModule.enableItems(['EditCustom'], false);
|
||||
}
|
||||
},
|
||||
rowSelecting: () => {
|
||||
if (mainGrid.obj.getSelectedRecords().length) {
|
||||
mainGrid.obj.clearSelection();
|
||||
}
|
||||
},
|
||||
toolbarClick: (args) => {
|
||||
if (args.item.id === 'MainGrid_excelexport') {
|
||||
mainGrid.obj.excelExport();
|
||||
}
|
||||
|
||||
if (args.item.id === 'EditCustom') {
|
||||
state.deleteMode = false;
|
||||
if (mainGrid.obj.getSelectedRecords().length) {
|
||||
const selectedRecord = mainGrid.obj.getSelectedRecords()[0];
|
||||
state.id = selectedRecord.id ?? '';
|
||||
state.name = selectedRecord.name ?? '';
|
||||
state.description = selectedRecord.description ?? '';
|
||||
state.currency = selectedRecord.currency ?? '';
|
||||
state.street = selectedRecord.street ?? '';
|
||||
state.city = selectedRecord.city ?? '';
|
||||
state.state = selectedRecord.state ?? '';
|
||||
state.zipCode = selectedRecord.zipCode ?? '';
|
||||
state.country = selectedRecord.country ?? '';
|
||||
state.phoneNumber = selectedRecord.phoneNumber ?? '';
|
||||
state.faxNumber = selectedRecord.faxNumber ?? '';
|
||||
state.emailAddress = selectedRecord.emailAddress ?? '';
|
||||
state.website = selectedRecord.website ?? '';
|
||||
mainModal.obj.show();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
mainGrid.obj.appendTo(mainGridRef.value);
|
||||
},
|
||||
refresh: () => {
|
||||
mainGrid.obj.setProperties({ dataSource: state.mainData });
|
||||
}
|
||||
};
|
||||
|
||||
const methods = {
|
||||
populateMainData: async () => {
|
||||
const response = await services.getMainData();
|
||||
const formattedData = response?.data?.content?.data.map(item => ({
|
||||
...item,
|
||||
createdAtUtc: new Date(item.createdAtUtc)
|
||||
}));
|
||||
state.mainData = formattedData;
|
||||
},
|
||||
};
|
||||
|
||||
const mainModal = {
|
||||
obj: null,
|
||||
create: () => {
|
||||
mainModal.obj = new bootstrap.Modal(mainModalRef.value, {
|
||||
backdrop: 'static',
|
||||
keyboard: false
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
const nameText = {
|
||||
obj: null,
|
||||
create: () => {
|
||||
nameText.obj = new ej.inputs.TextBox({
|
||||
placeholder: 'Enter Name',
|
||||
});
|
||||
nameText.obj.appendTo(nameRef.value);
|
||||
},
|
||||
refresh: () => {
|
||||
if (nameText.obj) {
|
||||
nameText.obj.value = state.name;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const currencyText = {
|
||||
obj: null,
|
||||
create: () => {
|
||||
currencyText.obj = new ej.inputs.TextBox({
|
||||
placeholder: 'Enter Currency',
|
||||
});
|
||||
currencyText.obj.appendTo(currencyRef.value);
|
||||
},
|
||||
refresh: () => {
|
||||
if (currencyText.obj) {
|
||||
currencyText.obj.value = state.currency;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const streetText = {
|
||||
obj: null,
|
||||
create: () => {
|
||||
streetText.obj = new ej.inputs.TextBox({
|
||||
placeholder: 'Enter Street',
|
||||
});
|
||||
streetText.obj.appendTo(streetRef.value);
|
||||
},
|
||||
refresh: () => {
|
||||
if (streetText.obj) {
|
||||
streetText.obj.value = state.street;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const cityText = {
|
||||
obj: null,
|
||||
create: () => {
|
||||
cityText.obj = new ej.inputs.TextBox({
|
||||
placeholder: 'Enter City',
|
||||
});
|
||||
cityText.obj.appendTo(cityRef.value);
|
||||
},
|
||||
refresh: () => {
|
||||
if (cityText.obj) {
|
||||
cityText.obj.value = state.city;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const stateText = {
|
||||
obj: null,
|
||||
create: () => {
|
||||
stateText.obj = new ej.inputs.TextBox({
|
||||
placeholder: 'Enter State',
|
||||
});
|
||||
stateText.obj.appendTo(stateRef.value);
|
||||
},
|
||||
refresh: () => {
|
||||
if (stateText.obj) {
|
||||
stateText.obj.value = state.state;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const zipCodeText = {
|
||||
obj: null,
|
||||
create: () => {
|
||||
zipCodeText.obj = new ej.inputs.TextBox({
|
||||
placeholder: 'Enter Zip Code',
|
||||
});
|
||||
zipCodeText.obj.appendTo(zipCodeRef.value);
|
||||
},
|
||||
refresh: () => {
|
||||
if (zipCodeText.obj) {
|
||||
zipCodeText.obj.value = state.zipCode;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const countryText = {
|
||||
obj: null,
|
||||
create: () => {
|
||||
countryText.obj = new ej.inputs.TextBox({
|
||||
placeholder: 'Enter Country',
|
||||
});
|
||||
countryText.obj.appendTo(countryRef.value);
|
||||
},
|
||||
refresh: () => {
|
||||
if (countryText.obj) {
|
||||
countryText.obj.value = state.country;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const phoneNumberText = {
|
||||
obj: null,
|
||||
create: () => {
|
||||
phoneNumberText.obj = new ej.inputs.TextBox({
|
||||
placeholder: 'Enter Phone Number',
|
||||
});
|
||||
phoneNumberText.obj.appendTo(phoneNumberRef.value);
|
||||
},
|
||||
refresh: () => {
|
||||
if (phoneNumberText.obj) {
|
||||
phoneNumberText.obj.value = state.phoneNumber;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const faxNumberText = {
|
||||
obj: null,
|
||||
create: () => {
|
||||
faxNumberText.obj = new ej.inputs.TextBox({
|
||||
placeholder: 'Enter Fax Number',
|
||||
});
|
||||
faxNumberText.obj.appendTo(faxNumberRef.value);
|
||||
},
|
||||
refresh: () => {
|
||||
if (faxNumberText.obj) {
|
||||
faxNumberText.obj.value = state.faxNumber;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const emailAddressText = {
|
||||
obj: null,
|
||||
create: () => {
|
||||
emailAddressText.obj = new ej.inputs.TextBox({
|
||||
placeholder: 'Enter Email Address',
|
||||
});
|
||||
emailAddressText.obj.appendTo(emailAddressRef.value);
|
||||
},
|
||||
refresh: () => {
|
||||
if (emailAddressText.obj) {
|
||||
emailAddressText.obj.value = state.emailAddress;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const websiteText = {
|
||||
obj: null,
|
||||
create: () => {
|
||||
websiteText.obj = new ej.inputs.TextBox({
|
||||
placeholder: 'Enter Website',
|
||||
});
|
||||
websiteText.obj.appendTo(websiteRef.value);
|
||||
},
|
||||
refresh: () => {
|
||||
if (websiteText.obj) {
|
||||
websiteText.obj.value = state.website;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Vue.watch(
|
||||
() => state.name,
|
||||
(newVal, oldVal) => {
|
||||
state.errors.name = '';
|
||||
nameText.refresh();
|
||||
}
|
||||
);
|
||||
|
||||
Vue.watch(
|
||||
() => state.currency,
|
||||
(newVal, oldVal) => {
|
||||
state.errors.currency = '';
|
||||
currencyText.refresh();
|
||||
}
|
||||
);
|
||||
|
||||
Vue.watch(
|
||||
() => state.street,
|
||||
(newVal, oldVal) => {
|
||||
state.errors.street = '';
|
||||
streetText.refresh();
|
||||
}
|
||||
);
|
||||
|
||||
Vue.watch(
|
||||
() => state.city,
|
||||
(newVal, oldVal) => {
|
||||
state.errors.city = '';
|
||||
cityText.refresh();
|
||||
}
|
||||
);
|
||||
|
||||
Vue.watch(
|
||||
() => state.state,
|
||||
(newVal, oldVal) => {
|
||||
state.errors.state = '';
|
||||
stateText.refresh();
|
||||
}
|
||||
);
|
||||
|
||||
Vue.watch(
|
||||
() => state.zipCode,
|
||||
(newVal, oldVal) => {
|
||||
state.errors.zipCode = '';
|
||||
zipCodeText.refresh();
|
||||
}
|
||||
);
|
||||
|
||||
Vue.watch(
|
||||
() => state.country,
|
||||
(newVal, oldVal) => {
|
||||
countryText.refresh();
|
||||
}
|
||||
);
|
||||
|
||||
Vue.watch(
|
||||
() => state.phoneNumber,
|
||||
(newVal, oldVal) => {
|
||||
state.errors.phoneNumber = '';
|
||||
phoneNumberText.refresh();
|
||||
}
|
||||
);
|
||||
|
||||
Vue.watch(
|
||||
() => state.faxNumber,
|
||||
(newVal, oldVal) => {
|
||||
faxNumberText.refresh();
|
||||
}
|
||||
);
|
||||
|
||||
Vue.watch(
|
||||
() => state.emailAddress,
|
||||
(newVal, oldVal) => {
|
||||
state.errors.emailAddress = '';
|
||||
emailAddressText.refresh();
|
||||
}
|
||||
);
|
||||
|
||||
Vue.watch(
|
||||
() => state.website,
|
||||
(newVal, oldVal) => {
|
||||
websiteText.refresh();
|
||||
}
|
||||
);
|
||||
|
||||
const handler = {
|
||||
handleSubmit: async function () {
|
||||
try {
|
||||
state.isSubmitting = true;
|
||||
await new Promise(resolve => setTimeout(resolve, 200));
|
||||
|
||||
// Validation
|
||||
let isValid = true;
|
||||
Object.keys(state.errors).forEach(field => {
|
||||
state.errors[field] = '';
|
||||
if (!state[field] && ['name', 'currency', 'street', 'city', 'state', 'zipCode', 'phoneNumber', 'emailAddress'].includes(field)) {
|
||||
state.errors[field] = `${field.charAt(0).toUpperCase() + field.slice(1)} is required.`;
|
||||
isValid = false;
|
||||
}
|
||||
});
|
||||
|
||||
if (!isValid) return;
|
||||
|
||||
const response = await services.updateMainData(
|
||||
state.id,
|
||||
state.name,
|
||||
state.description,
|
||||
state.currency,
|
||||
state.street,
|
||||
state.city,
|
||||
state.state,
|
||||
state.zipCode,
|
||||
state.country,
|
||||
state.phoneNumber,
|
||||
state.faxNumber,
|
||||
state.emailAddress,
|
||||
state.website,
|
||||
StorageManager.getUserId()
|
||||
);
|
||||
|
||||
if (response.data.code === 200) {
|
||||
await methods.populateMainData();
|
||||
mainGrid.refresh();
|
||||
Swal.fire({
|
||||
icon: 'success',
|
||||
title: state.deleteMode ? 'Delete Successful' : 'Save Successful',
|
||||
text: 'Page will be refreshed...',
|
||||
timer: 1000,
|
||||
showConfirmButton: false
|
||||
});
|
||||
|
||||
setTimeout(() => {
|
||||
mainModal.obj.hide();
|
||||
location.reload();
|
||||
}, 1000);
|
||||
|
||||
} else {
|
||||
Swal.fire({
|
||||
icon: 'error',
|
||||
title: state.deleteMode ? 'Delete Failed' : 'Save Failed',
|
||||
text: response.data.message ?? 'Please check your data.',
|
||||
confirmButtonText: 'Try Again'
|
||||
});
|
||||
}
|
||||
|
||||
} catch (error) {
|
||||
Swal.fire({
|
||||
icon: 'error',
|
||||
title: 'An Error Occurred',
|
||||
text: error.response?.data?.message ?? 'Please try again.',
|
||||
confirmButtonText: 'OK'
|
||||
});
|
||||
} finally {
|
||||
state.isSubmitting = false;
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
Vue.onMounted(async () => {
|
||||
try {
|
||||
await SecurityManager.authorizePage(['Companies']);
|
||||
await SecurityManager.validateToken();
|
||||
await methods.populateMainData();
|
||||
await mainGrid.create(state.mainData);
|
||||
|
||||
nameText.create();
|
||||
currencyText.create();
|
||||
streetText.create();
|
||||
cityText.create();
|
||||
stateText.create();
|
||||
zipCodeText.create();
|
||||
countryText.create();
|
||||
phoneNumberText.create();
|
||||
faxNumberText.create();
|
||||
emailAddressText.create();
|
||||
websiteText.create();
|
||||
|
||||
mainModal.create();
|
||||
|
||||
mainModalRef.value.addEventListener('hidden.bs.modal', () => {
|
||||
Object.keys(state).forEach(key => {
|
||||
if (typeof state[key] === 'string') {
|
||||
state[key] = '';
|
||||
}
|
||||
});
|
||||
state.errors = {
|
||||
name: '',
|
||||
currency: '',
|
||||
street: '',
|
||||
city: '',
|
||||
state: '',
|
||||
zipCode: '',
|
||||
phoneNumber: '',
|
||||
emailAddress: ''
|
||||
};
|
||||
});
|
||||
} catch (e) {
|
||||
console.error('page init error:', e);
|
||||
} finally {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
Vue.onUnmounted(() => {
|
||||
mainModalRef.value?.removeEventListener('hidden.bs.modal', () => { });
|
||||
});
|
||||
|
||||
return {
|
||||
state,
|
||||
mainGridRef,
|
||||
mainModalRef,
|
||||
nameRef,
|
||||
currencyRef,
|
||||
streetRef,
|
||||
cityRef,
|
||||
stateRef,
|
||||
zipCodeRef,
|
||||
countryRef,
|
||||
phoneNumberRef,
|
||||
faxNumberRef,
|
||||
emailAddressRef,
|
||||
websiteRef,
|
||||
handler
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
Vue.createApp(App).mount('#app');
|
||||
@@ -0,0 +1,72 @@
|
||||
@page
|
||||
@attribute [Authorize(Roles = "CustomerCategories")]
|
||||
@{
|
||||
ViewData["Title"] = "Customer Category List";
|
||||
}
|
||||
|
||||
<div id="app" v-cloak>
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<div class="grid-container">
|
||||
<div ref="mainGridRef"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="modal fade" ref="mainModalRef" id="MainModal" tabindex="-1" aria-hidden="true" data-bs-backdrop="static">
|
||||
<div class="modal-dialog modal-dialog-centered modal-lg">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title" v-text="state.mainTitle"></h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<input type="hidden" v-model="state.id" id="Id" name="Id" />
|
||||
<form id="MainForm">
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<h5>Main Info</h5>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="row mb-2">
|
||||
<div class="col-md-6">
|
||||
<label for="Name">Name</label>
|
||||
<input ref="nameRef" v-model="state.name" />
|
||||
<label class="text-danger" v-text="state.errors.name"></label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mb-2">
|
||||
<div class="col-12">
|
||||
<label for="Description">Description</label>
|
||||
<textarea class="form-control" rows="3" v-model="state.description"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
|
||||
<button type="button"
|
||||
id="MainSaveButton"
|
||||
class="btn"
|
||||
v-bind:class="state.deleteMode ? 'btn-danger' : 'btn-primary'"
|
||||
v-on:click="handler.handleSubmit"
|
||||
v-bind:disabled="state.isSubmitting">
|
||||
<span class="spinner-border spinner-border-sm me-2" v-if="state.isSubmitting" role="status" aria-hidden="true"></span>
|
||||
<span v-if="!state.isSubmitting">{{ state.deleteMode ? 'Delete' : 'Save' }}</span>
|
||||
<span v-else>{{ state.deleteMode ? 'Deleting...' : 'Saving...' }}</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@section scripts {
|
||||
<script src="~/FrontEnd/Pages/CustomerCategories/CustomerCategoryList.cshtml.js"></script>
|
||||
}
|
||||
+306
@@ -0,0 +1,306 @@
|
||||
const App = {
|
||||
setup() {
|
||||
const state = Vue.reactive({
|
||||
mainData: [],
|
||||
deleteMode: false,
|
||||
mainTitle: null,
|
||||
id: '',
|
||||
name: '',
|
||||
description: '',
|
||||
errors: {
|
||||
name: ''
|
||||
},
|
||||
isSubmitting: false
|
||||
});
|
||||
|
||||
const mainGridRef = Vue.ref(null);
|
||||
const mainModalRef = Vue.ref(null);
|
||||
const nameRef = Vue.ref(null);
|
||||
|
||||
const services = {
|
||||
getMainData: async () => {
|
||||
try {
|
||||
const response = await AxiosManager.get('/CustomerCategory/GetCustomerCategoryList', {});
|
||||
return response;
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
},
|
||||
createMainData: async (name, description, createdById) => {
|
||||
try {
|
||||
const response = await AxiosManager.post('/CustomerCategory/CreateCustomerCategory', {
|
||||
name, description, createdById
|
||||
});
|
||||
return response;
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
},
|
||||
updateMainData: async (id, name, description, updatedById) => {
|
||||
try {
|
||||
const response = await AxiosManager.post('/CustomerCategory/UpdateCustomerCategory', {
|
||||
id, name, description, updatedById
|
||||
});
|
||||
return response;
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
},
|
||||
deleteMainData: async (id, deletedById) => {
|
||||
try {
|
||||
const response = await AxiosManager.post('/CustomerCategory/DeleteCustomerCategory', {
|
||||
id, deletedById
|
||||
});
|
||||
return response;
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
const methods = {
|
||||
populateMainData: async () => {
|
||||
const response = await services.getMainData();
|
||||
state.mainData = response?.data?.content?.data.map(item => ({
|
||||
...item,
|
||||
createdAtUtc: new Date(item.createdAtUtc)
|
||||
}));
|
||||
}
|
||||
};
|
||||
|
||||
const nameText = {
|
||||
obj: null,
|
||||
create: () => {
|
||||
nameText.obj = new ej.inputs.TextBox({
|
||||
placeholder: 'Enter Name',
|
||||
});
|
||||
nameText.obj.appendTo(nameRef.value);
|
||||
},
|
||||
refresh: () => {
|
||||
if (nameText.obj) {
|
||||
nameText.obj.value = state.name;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Vue.watch(
|
||||
() => state.name,
|
||||
(newVal, oldVal) => {
|
||||
state.errors.name = '';
|
||||
nameText.refresh();
|
||||
}
|
||||
);
|
||||
|
||||
const handler = {
|
||||
handleSubmit: async function () {
|
||||
try {
|
||||
state.isSubmitting = true;
|
||||
await new Promise(resolve => setTimeout(resolve, 200));
|
||||
|
||||
let isValid = true;
|
||||
|
||||
// name validation
|
||||
if (!state.name) {
|
||||
state.errors.name = 'Name is required.';
|
||||
isValid = false;
|
||||
}
|
||||
|
||||
if (!isValid) return;
|
||||
|
||||
const response = state.id === ''
|
||||
? await services.createMainData(state.name, state.description, StorageManager.getUserId())
|
||||
: state.deleteMode
|
||||
? await services.deleteMainData(state.id, StorageManager.getUserId())
|
||||
: await services.updateMainData(state.id, state.name, state.description, StorageManager.getUserId());
|
||||
|
||||
if (response.data.code === 200) {
|
||||
await methods.populateMainData();
|
||||
mainGrid.refresh();
|
||||
|
||||
Swal.fire({
|
||||
icon: 'success',
|
||||
title: state.deleteMode ? 'Delete Successful' : 'Save Successful',
|
||||
text: 'Form will be closed...',
|
||||
timer: 2000,
|
||||
showConfirmButton: false
|
||||
});
|
||||
setTimeout(() => {
|
||||
mainModal.obj.hide();
|
||||
resetFormState();
|
||||
}, 2000);
|
||||
} else {
|
||||
Swal.fire({
|
||||
icon: 'error',
|
||||
title: state.deleteMode ? 'Delete Failed' : 'Save Failed',
|
||||
text: response.data.message ?? 'Please check your data.',
|
||||
confirmButtonText: 'Try Again'
|
||||
});
|
||||
}
|
||||
|
||||
} catch (error) {
|
||||
Swal.fire({
|
||||
icon: 'error',
|
||||
title: 'An Error Occurred',
|
||||
text: error.response?.data?.message ?? 'Please try again.',
|
||||
confirmButtonText: 'OK'
|
||||
});
|
||||
} finally {
|
||||
state.isSubmitting = false;
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
const resetFormState = () => {
|
||||
state.id = '';
|
||||
state.name = '';
|
||||
state.description = '';
|
||||
state.errors = {
|
||||
name: ''
|
||||
};
|
||||
};
|
||||
|
||||
const mainGrid = {
|
||||
obj: null,
|
||||
create: async (dataSource) => {
|
||||
mainGrid.obj = new ej.grids.Grid({
|
||||
height: '240px',
|
||||
dataSource: dataSource,
|
||||
allowFiltering: true,
|
||||
allowSorting: true,
|
||||
allowSelection: true,
|
||||
allowCategorying: true,
|
||||
allowTextWrap: true,
|
||||
allowResizing: true,
|
||||
allowPaging: true,
|
||||
allowExcelExport: true,
|
||||
filterSettings: { type: 'CheckBox' },
|
||||
sortSettings: { columns: [{ field: 'createdAtUtc', direction: 'Descending' }] },
|
||||
pageSettings: { currentPage: 1, pageSize: 50, pageSizes: ["10", "20", "50", "100", "200", "All"] },
|
||||
selectionSettings: { persistSelection: true, type: 'Single' },
|
||||
autoFit: true,
|
||||
showColumnMenu: true,
|
||||
gridLines: 'Horizontal',
|
||||
columns: [
|
||||
{ type: 'checkbox', width: 60 },
|
||||
{
|
||||
field: 'id', isPrimaryKey: true, headerText: 'Id', visible: false
|
||||
},
|
||||
{ field: 'name', headerText: 'Name', width: 200, minWidth: 200 },
|
||||
{ field: 'description', headerText: 'Description', width: 400, minWidth: 400 },
|
||||
{ field: 'createdAtUtc', headerText: 'Created At UTC', width: 150, format: 'yyyy-MM-dd HH:mm' }
|
||||
],
|
||||
toolbar: [
|
||||
'ExcelExport', 'Search',
|
||||
{ type: 'Separator' },
|
||||
{ text: 'Add', tooltipText: 'Add', prefixIcon: 'e-add', id: 'AddCustom' },
|
||||
{ text: 'Edit', tooltipText: 'Edit', prefixIcon: 'e-edit', id: 'EditCustom' },
|
||||
{ text: 'Delete', tooltipText: 'Delete', prefixIcon: 'e-delete', id: 'DeleteCustom' },
|
||||
{ type: 'Separator' },
|
||||
],
|
||||
beforeDataBound: () => { },
|
||||
dataBound: function () {
|
||||
mainGrid.obj.toolbarModule.enableItems(['EditCustom', 'DeleteCustom'], false);
|
||||
mainGrid.obj.autoFitColumns(['name', 'description', 'createdAtUtc']);
|
||||
},
|
||||
excelExportComplete: () => { },
|
||||
rowSelected: () => {
|
||||
if (mainGrid.obj.getSelectedRecords().length == 1) {
|
||||
mainGrid.obj.toolbarModule.enableItems(['EditCustom', 'DeleteCustom'], true);
|
||||
} else {
|
||||
mainGrid.obj.toolbarModule.enableItems(['EditCustom', 'DeleteCustom'], false);
|
||||
}
|
||||
},
|
||||
rowDeselected: () => {
|
||||
if (mainGrid.obj.getSelectedRecords().length == 1) {
|
||||
mainGrid.obj.toolbarModule.enableItems(['EditCustom', 'DeleteCustom'], true);
|
||||
} else {
|
||||
mainGrid.obj.toolbarModule.enableItems(['EditCustom', 'DeleteCustom'], false);
|
||||
}
|
||||
},
|
||||
rowSelecting: () => {
|
||||
if (mainGrid.obj.getSelectedRecords().length) {
|
||||
mainGrid.obj.clearSelection();
|
||||
}
|
||||
},
|
||||
toolbarClick: async (args) => {
|
||||
if (args.item.id === 'MainGrid_excelexport') {
|
||||
mainGrid.obj.excelExport();
|
||||
}
|
||||
|
||||
if (args.item.id === 'AddCustom') {
|
||||
state.deleteMode = false;
|
||||
state.mainTitle = 'Add Customer Category';
|
||||
resetFormState();
|
||||
mainModal.obj.show();
|
||||
}
|
||||
|
||||
if (args.item.id === 'EditCustom') {
|
||||
state.deleteMode = false;
|
||||
if (mainGrid.obj.getSelectedRecords().length) {
|
||||
const selectedRecord = mainGrid.obj.getSelectedRecords()[0];
|
||||
state.mainTitle = 'Edit Customer Category';
|
||||
state.id = selectedRecord.id ?? '';
|
||||
state.name = selectedRecord.name ?? '';
|
||||
state.description = selectedRecord.description ?? '';
|
||||
mainModal.obj.show();
|
||||
}
|
||||
}
|
||||
|
||||
if (args.item.id === 'DeleteCustom') {
|
||||
state.deleteMode = true;
|
||||
if (mainGrid.obj.getSelectedRecords().length) {
|
||||
const selectedRecord = mainGrid.obj.getSelectedRecords()[0];
|
||||
state.mainTitle = 'Delete Customer Category?';
|
||||
state.id = selectedRecord.id ?? '';
|
||||
state.name = selectedRecord.name ?? '';
|
||||
state.description = selectedRecord.description ?? '';
|
||||
mainModal.obj.show();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
mainGrid.obj.appendTo(mainGridRef.value);
|
||||
},
|
||||
refresh: () => {
|
||||
mainGrid.obj.setProperties({ dataSource: state.mainData });
|
||||
}
|
||||
};
|
||||
|
||||
const mainModal = {
|
||||
obj: null,
|
||||
create: () => {
|
||||
mainModal.obj = new bootstrap.Modal(mainModalRef.value, {
|
||||
backdrop: 'static',
|
||||
keyboard: false
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
Vue.onMounted(async () => {
|
||||
try {
|
||||
await SecurityManager.authorizePage(['CustomerCategories']);
|
||||
await SecurityManager.validateToken();
|
||||
|
||||
await methods.populateMainData();
|
||||
await mainGrid.create(state.mainData);
|
||||
nameText.create();
|
||||
mainModal.create();
|
||||
} catch (e) {
|
||||
console.error('page init error:', e);
|
||||
} finally {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
return {
|
||||
mainGridRef,
|
||||
mainModalRef,
|
||||
nameRef,
|
||||
state,
|
||||
handler,
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
Vue.createApp(App).mount('#app');
|
||||
@@ -0,0 +1,100 @@
|
||||
@page
|
||||
@attribute [Authorize(Roles = "CustomerContacts")]
|
||||
@{
|
||||
ViewData["Title"] = "Customer Contact List";
|
||||
}
|
||||
|
||||
<div id="app" v-cloak>
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<div class="grid-container">
|
||||
<div ref="mainGridRef"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="modal fade" ref="mainModalRef" id="MainModal" tabindex="-1" aria-hidden="true" data-bs-backdrop="static">
|
||||
<div class="modal-dialog modal-dialog-centered modal-lg">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title" v-text="state.mainTitle"></h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<input type="hidden" v-model="state.id" id="Id" name="Id" />
|
||||
<form id="MainForm">
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<h5>Main Info</h5>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="row mb-2">
|
||||
<div class="col-md-6">
|
||||
<label for="Name">Name</label>
|
||||
<input ref="nameRef" v-model="state.name" class="form-control" placeholder="" />
|
||||
<label class="text-danger" v-text="state.errors.name"></label>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<label for="Number">Number</label>
|
||||
<input ref="numberRef" v-model="state.number" class="form-control" placeholder="" readonly />
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mb-2">
|
||||
<div class="col-md-6">
|
||||
<label for="PhoneNumber">PhoneNumber</label>
|
||||
<input ref="phoneNumberRef" v-model="state.phoneNumber" class="form-control" placeholder="" />
|
||||
<label class="text-danger" v-text="state.errors.phoneNumber"></label>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<label for="EmailAddress">EmailAddress</label>
|
||||
<input ref="emailAddressRef" v-model="state.emailAddress" class="form-control" placeholder="" />
|
||||
<label class="text-danger" v-text="state.errors.emailAddress"></label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mb-2">
|
||||
<div class="col-md-6">
|
||||
<label for="JobTitle">JobTitle</label>
|
||||
<input ref="jobTitleRef" v-model="state.jobTitle" class="form-control" placeholder="" />
|
||||
<label class="text-danger" v-text="state.errors.jobTitle"></label>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<label for="CustomerId">Customer</label>
|
||||
<div ref="customerIdRef"></div>
|
||||
<label class="text-danger" v-text="state.errors.customerId"></label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mb-2">
|
||||
<div class="col-12">
|
||||
<label for="Description">Description</label>
|
||||
<textarea v-model="state.description" id="Description" name="Description" class="form-control" rows="3" placeholder=""></textarea>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
|
||||
<button type="button"
|
||||
id="MainSaveButton"
|
||||
class="btn"
|
||||
v-bind:class="state.deleteMode ? 'btn-danger' : 'btn-primary'"
|
||||
v-on:click="handler.handleSubmit"
|
||||
v-bind:disabled="state.isSubmitting">
|
||||
<span class="spinner-border spinner-border-sm me-2" v-if="state.isSubmitting" role="status" aria-hidden="true"></span>
|
||||
<span v-if="!state.isSubmitting">{{ state.deleteMode ? 'Delete' : 'Save' }}</span>
|
||||
<span v-else>{{ state.deleteMode ? 'Deleting...' : 'Saving...' }}</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@section scripts {
|
||||
<script src="~/FrontEnd/Pages/CustomerContacts/CustomerContactList.cshtml.js"></script>
|
||||
}
|
||||
+548
@@ -0,0 +1,548 @@
|
||||
const App = {
|
||||
setup() {
|
||||
const state = Vue.reactive({
|
||||
mainData: [],
|
||||
deleteMode: false,
|
||||
customerListLookupData: [],
|
||||
mainTitle: null,
|
||||
id: '',
|
||||
name: '',
|
||||
jobTitle: '',
|
||||
phoneNumber: '',
|
||||
emailAddress: '',
|
||||
description: '',
|
||||
customerId: null,
|
||||
errors: {
|
||||
name: '',
|
||||
jobTitle: '',
|
||||
phoneNumber: '',
|
||||
emailAddress: '',
|
||||
customerId: ''
|
||||
},
|
||||
isSubmitting: false
|
||||
});
|
||||
|
||||
const mainGridRef = Vue.ref(null);
|
||||
const mainModalRef = Vue.ref(null);
|
||||
const nameRef = Vue.ref(null);
|
||||
const numberRef = Vue.ref(null);
|
||||
const jobTitleRef = Vue.ref(null);
|
||||
const phoneNumberRef = Vue.ref(null);
|
||||
const emailAddressRef = Vue.ref(null);
|
||||
const customerIdRef = Vue.ref(null);
|
||||
|
||||
const validateForm = function () {
|
||||
state.errors.name = '';
|
||||
state.errors.jobTitle = '';
|
||||
state.errors.phoneNumber = '';
|
||||
state.errors.emailAddress = '';
|
||||
state.errors.customerId = '';
|
||||
|
||||
let isValid = true;
|
||||
|
||||
if (!state.name) {
|
||||
state.errors.name = 'Name is required.';
|
||||
isValid = false;
|
||||
}
|
||||
if (!state.jobTitle) {
|
||||
state.errors.jobTitle = 'Job Title is required.';
|
||||
isValid = false;
|
||||
}
|
||||
if (!state.phoneNumber) {
|
||||
state.errors.phoneNumber = 'Phone number is required.';
|
||||
isValid = false;
|
||||
}
|
||||
if (!state.emailAddress) {
|
||||
state.errors.emailAddress = 'Email address is required.';
|
||||
isValid = false;
|
||||
}
|
||||
if (!state.customerId) {
|
||||
state.errors.customerId = 'Customer is required.';
|
||||
isValid = false;
|
||||
}
|
||||
|
||||
return isValid;
|
||||
};
|
||||
|
||||
const resetFormState = () => {
|
||||
state.id = '';
|
||||
state.name = '';
|
||||
state.number = '';
|
||||
state.jobTitle = '';
|
||||
state.phoneNumber = '';
|
||||
state.emailAddress = '';
|
||||
state.description = '';
|
||||
state.customerId = null;
|
||||
state.errors = {
|
||||
name: '',
|
||||
jobTitle: '',
|
||||
phoneNumber: '',
|
||||
emailAddress: '',
|
||||
customerId: ''
|
||||
};
|
||||
};
|
||||
|
||||
const services = {
|
||||
getMainData: async () => {
|
||||
try {
|
||||
const response = await AxiosManager.get('/CustomerContact/GetCustomerContactList', {});
|
||||
return response;
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
},
|
||||
createMainData: async (name, jobTitle, phoneNumber, emailAddress, description, customerId, createdById) => {
|
||||
try {
|
||||
const response = await AxiosManager.post('/CustomerContact/CreateCustomerContact', {
|
||||
name, jobTitle, phoneNumber, emailAddress, description, customerId, createdById
|
||||
});
|
||||
return response;
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
},
|
||||
updateMainData: async (id, name, jobTitle, phoneNumber, emailAddress, description, customerId, updatedById) => {
|
||||
try {
|
||||
const response = await AxiosManager.post('/CustomerContact/UpdateCustomerContact', {
|
||||
id, name, jobTitle, phoneNumber, emailAddress, description, customerId, updatedById
|
||||
});
|
||||
return response;
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
},
|
||||
deleteMainData: async (id, deletedById) => {
|
||||
try {
|
||||
const response = await AxiosManager.post('/CustomerContact/DeleteCustomerContact', {
|
||||
id, deletedById
|
||||
});
|
||||
return response;
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
},
|
||||
getCustomerListLookupData: async () => {
|
||||
try {
|
||||
const response = await AxiosManager.get('/Customer/GetCustomerList', {});
|
||||
return response;
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const methods = {
|
||||
populateCustomerListLookupData: async () => {
|
||||
const response = await services.getCustomerListLookupData();
|
||||
state.customerListLookupData = response?.data?.content?.data;
|
||||
},
|
||||
populateMainData: async () => {
|
||||
const response = await services.getMainData();
|
||||
state.mainData = response?.data?.content?.data.map(item => ({
|
||||
...item,
|
||||
createdAtUtc: new Date(item.createdAtUtc)
|
||||
}));
|
||||
},
|
||||
};
|
||||
|
||||
const nameText = {
|
||||
obj: null,
|
||||
create: () => {
|
||||
nameText.obj = new ej.inputs.TextBox({
|
||||
placeholder: 'Enter Name'
|
||||
});
|
||||
nameText.obj.appendTo(nameRef.value);
|
||||
},
|
||||
refresh: () => {
|
||||
if (nameText.obj) {
|
||||
nameText.obj.value = state.name;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
const numberText = {
|
||||
obj: null,
|
||||
create: () => {
|
||||
numberText.obj = new ej.inputs.TextBox({
|
||||
placeholder: '[auto]',
|
||||
readonly: true
|
||||
});
|
||||
numberText.obj.appendTo(numberRef.value);
|
||||
},
|
||||
refresh: () => {
|
||||
if (numberText.obj) {
|
||||
numberText.obj.value = state.number;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const jobTitleText = {
|
||||
obj: null,
|
||||
create: () => {
|
||||
jobTitleText.obj = new ej.inputs.TextBox({
|
||||
placeholder: 'Enter Job Title'
|
||||
});
|
||||
jobTitleText.obj.appendTo(jobTitleRef.value);
|
||||
},
|
||||
refresh: () => {
|
||||
if (jobTitleText.obj) {
|
||||
jobTitleText.obj.value = state.jobTitle;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const phoneNumberText = {
|
||||
obj: null,
|
||||
create: () => {
|
||||
phoneNumberText.obj = new ej.inputs.TextBox({
|
||||
placeholder: 'Enter Phone Number'
|
||||
});
|
||||
phoneNumberText.obj.appendTo(phoneNumberRef.value);
|
||||
},
|
||||
refresh: () => {
|
||||
if (phoneNumberText.obj) {
|
||||
phoneNumberText.obj.value = state.phoneNumber;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const emailAddressText = {
|
||||
obj: null,
|
||||
create: () => {
|
||||
emailAddressText.obj = new ej.inputs.TextBox({
|
||||
placeholder: 'Enter Email Address'
|
||||
});
|
||||
emailAddressText.obj.appendTo(emailAddressRef.value);
|
||||
},
|
||||
refresh: () => {
|
||||
if (emailAddressText.obj) {
|
||||
emailAddressText.obj.value = state.emailAddress;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const customerListLookup = {
|
||||
obj: null,
|
||||
create: () => {
|
||||
if (state.customerListLookupData && Array.isArray(state.customerListLookupData)) {
|
||||
customerListLookup.obj = new ej.dropdowns.DropDownList({
|
||||
dataSource: state.customerListLookupData,
|
||||
fields: { value: 'id', text: 'name' },
|
||||
placeholder: 'Select a Customer',
|
||||
change: (e) => {
|
||||
state.customerId = e.value;
|
||||
}
|
||||
});
|
||||
customerListLookup.obj.appendTo(customerIdRef.value);
|
||||
} else {
|
||||
console.error('Customer list lookup data is not available or invalid.');
|
||||
}
|
||||
},
|
||||
refresh: () => {
|
||||
if (customerListLookup.obj) {
|
||||
customerListLookup.obj.value = state.customerId;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Vue.watch(
|
||||
() => state.name,
|
||||
(newVal, oldVal) => {
|
||||
state.errors.name = '';
|
||||
nameText.refresh();
|
||||
}
|
||||
);
|
||||
|
||||
Vue.watch(
|
||||
() => state.jobTitle,
|
||||
(newVal, oldVal) => {
|
||||
state.errors.jobTitle = '';
|
||||
jobTitleText.refresh();
|
||||
}
|
||||
);
|
||||
|
||||
Vue.watch(
|
||||
() => state.phoneNumber,
|
||||
(newVal, oldVal) => {
|
||||
state.errors.phoneNumber = '';
|
||||
phoneNumberText.refresh();
|
||||
}
|
||||
);
|
||||
|
||||
Vue.watch(
|
||||
() => state.emailAddress,
|
||||
(newVal, oldVal) => {
|
||||
state.errors.emailAddress = '';
|
||||
emailAddressText.refresh();
|
||||
}
|
||||
);
|
||||
|
||||
Vue.watch(
|
||||
() => state.customerId,
|
||||
(newVal, oldVal) => {
|
||||
state.errors.customerId = '';
|
||||
customerListLookup.refresh();
|
||||
}
|
||||
);
|
||||
|
||||
const handler = {
|
||||
handleSubmit: async function () {
|
||||
try {
|
||||
state.isSubmitting = true;
|
||||
await new Promise(resolve => setTimeout(resolve, 300));
|
||||
|
||||
if (!validateForm()) {
|
||||
return;
|
||||
}
|
||||
|
||||
const response = state.id === ''
|
||||
? await services.createMainData(state.name, state.jobTitle, state.phoneNumber, state.emailAddress, state.description, state.customerId, StorageManager.getUserId())
|
||||
: state.deleteMode
|
||||
? await services.deleteMainData(state.id, StorageManager.getUserId())
|
||||
: await services.updateMainData(state.id, state.name, state.jobTitle, state.phoneNumber, state.emailAddress, state.description, state.customerId, StorageManager.getUserId());
|
||||
|
||||
if (response.data.code === 200) {
|
||||
await methods.populateMainData();
|
||||
mainGrid.refresh();
|
||||
|
||||
if (!state.deleteMode) {
|
||||
state.mainTitle = 'Edit Customer Contact';
|
||||
state.id = response?.data?.content?.data.id ?? '';
|
||||
state.number = response?.data?.content?.data.number ?? '';
|
||||
state.name = response?.data?.content?.data.name ?? '';
|
||||
state.jobTitle = response?.data?.content?.data.jobTitle ?? '';
|
||||
state.phoneNumber = response?.data?.content?.data.phoneNumber ?? '';
|
||||
state.emailAddress = response?.data?.content?.data.emailAddress ?? '';
|
||||
state.description = response?.data?.content?.data.description ?? '';
|
||||
state.customerId = response?.data?.content?.data.customerId ?? '';
|
||||
|
||||
Swal.fire({
|
||||
icon: 'success',
|
||||
title: state.deleteMode ? 'Delete Successful' : 'Save Successful',
|
||||
text: 'Form will be closed...',
|
||||
timer: 2000,
|
||||
showConfirmButton: false
|
||||
});
|
||||
setTimeout(() => {
|
||||
mainModal.obj.hide();
|
||||
}, 2000);
|
||||
|
||||
} else {
|
||||
Swal.fire({
|
||||
icon: 'success',
|
||||
title: 'Delete Successful',
|
||||
text: 'Form will be closed...',
|
||||
timer: 2000,
|
||||
showConfirmButton: false
|
||||
});
|
||||
setTimeout(() => {
|
||||
mainModal.obj.hide();
|
||||
resetFormState();
|
||||
}, 2000);
|
||||
}
|
||||
|
||||
} else {
|
||||
Swal.fire({
|
||||
icon: 'error',
|
||||
title: state.deleteMode ? 'Delete Failed' : 'Save Failed',
|
||||
text: response.data.message ?? 'Please check your data.',
|
||||
confirmButtonText: 'Try Again'
|
||||
});
|
||||
}
|
||||
|
||||
} catch (error) {
|
||||
Swal.fire({
|
||||
icon: 'error',
|
||||
title: 'An Error Occurred',
|
||||
text: error.response?.data?.message ?? 'Please try again.',
|
||||
confirmButtonText: 'OK'
|
||||
});
|
||||
} finally {
|
||||
state.isSubmitting = false;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Vue.onMounted(async () => {
|
||||
try {
|
||||
await SecurityManager.authorizePage(['CustomerContacts']);
|
||||
await SecurityManager.validateToken();
|
||||
|
||||
await methods.populateMainData();
|
||||
await mainGrid.create(state.mainData);
|
||||
await methods.populateCustomerListLookupData();
|
||||
customerListLookup.create();
|
||||
nameText.create();
|
||||
numberText.create();
|
||||
jobTitleText.create();
|
||||
phoneNumberText.create();
|
||||
emailAddressText.create();
|
||||
|
||||
mainModal.create();
|
||||
mainModalRef.value?.addEventListener('hidden.bs.modal', () => {
|
||||
resetFormState();
|
||||
});
|
||||
|
||||
} catch (e) {
|
||||
console.error('page init error:', e);
|
||||
} finally {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
Vue.onUnmounted(() => {
|
||||
mainModalRef.value?.removeEventListener('hidden.bs.modal', resetFormState);
|
||||
});
|
||||
|
||||
const mainGrid = {
|
||||
obj: null,
|
||||
create: async (dataSource) => {
|
||||
mainGrid.obj = new ej.grids.Grid({
|
||||
height: '240px',
|
||||
dataSource: dataSource,
|
||||
allowFiltering: true,
|
||||
allowSorting: true,
|
||||
allowSelection: true,
|
||||
allowGrouping: true,
|
||||
groupSettings: {
|
||||
columns: ['customerName']
|
||||
},
|
||||
allowTextWrap: true,
|
||||
allowResizing: true,
|
||||
allowPaging: true,
|
||||
allowExcelExport: true,
|
||||
filterSettings: { type: 'CheckBox' },
|
||||
sortSettings: { columns: [{ field: 'createdAtUtc', direction: 'Descending' }] },
|
||||
pageSettings: { currentPage: 1, pageSize: 50, pageSizes: ["10", "20", "50", "100", "200", "All"] },
|
||||
selectionSettings: { persistSelection: true, type: 'Single' },
|
||||
autoFit: true,
|
||||
showColumnMenu: true,
|
||||
gridLines: 'Horizontal',
|
||||
columns: [
|
||||
{ type: 'checkbox', width: 60 },
|
||||
{
|
||||
field: 'id', isPrimaryKey: true, headerText: 'Id', visible: false
|
||||
},
|
||||
{ field: 'number', headerText: 'Number', width: 150, minWidth: 150 },
|
||||
{ field: 'name', headerText: 'Name', width: 200, minWidth: 200 },
|
||||
{ field: 'customerName', headerText: 'Customer', width: 150, minWidth: 150 },
|
||||
{ field: 'jobTitle', headerText: 'Job Title', width: 150, minWidth: 150 },
|
||||
{ field: 'phoneNumber', headerText: 'Phone', width: 150, minWidth: 150 },
|
||||
{ field: 'emailAddress', headerText: 'Email', width: 150, minWidth: 150 },
|
||||
{ field: 'createdAtUtc', headerText: 'Created At UTC', width: 150, format: 'yyyy-MM-dd HH:mm' }
|
||||
],
|
||||
toolbar: [
|
||||
'ExcelExport', 'Search',
|
||||
{ type: 'Separator' },
|
||||
{ text: 'Add', tooltipText: 'Add', prefixIcon: 'e-add', id: 'AddCustom' },
|
||||
{ text: 'Edit', tooltipText: 'Edit', prefixIcon: 'e-edit', id: 'EditCustom' },
|
||||
{ text: 'Delete', tooltipText: 'Delete', prefixIcon: 'e-delete', id: 'DeleteCustom' },
|
||||
{ type: 'Separator' },
|
||||
],
|
||||
beforeDataBound: () => { },
|
||||
dataBound: function () {
|
||||
mainGrid.obj.toolbarModule.enableItems(['EditCustom', 'DeleteCustom'], false);
|
||||
mainGrid.obj.autoFitColumns(['name', 'customerName', 'jobTitle', 'phoneNumber', 'emailAddress', 'createdAtUtc']);
|
||||
},
|
||||
excelExportComplete: () => { },
|
||||
rowSelected: () => {
|
||||
if (mainGrid.obj.getSelectedRecords().length == 1) {
|
||||
mainGrid.obj.toolbarModule.enableItems(['EditCustom', 'DeleteCustom'], true);
|
||||
} else {
|
||||
mainGrid.obj.toolbarModule.enableItems(['EditCustom', 'DeleteCustom'], false);
|
||||
}
|
||||
},
|
||||
rowDeselected: () => {
|
||||
if (mainGrid.obj.getSelectedRecords().length == 1) {
|
||||
mainGrid.obj.toolbarModule.enableItems(['EditCustom', 'DeleteCustom'], true);
|
||||
} else {
|
||||
mainGrid.obj.toolbarModule.enableItems(['EditCustom', 'DeleteCustom'], false);
|
||||
}
|
||||
},
|
||||
rowSelecting: () => {
|
||||
if (mainGrid.obj.getSelectedRecords().length) {
|
||||
mainGrid.obj.clearSelection();
|
||||
}
|
||||
},
|
||||
toolbarClick: async (args) => {
|
||||
if (args.item.id === 'MainGrid_excelexport') {
|
||||
mainGrid.obj.excelExport();
|
||||
}
|
||||
|
||||
if (args.item.id === 'AddCustom') {
|
||||
state.deleteMode = false;
|
||||
state.mainTitle = 'Add Customer Contact';
|
||||
resetFormState();
|
||||
mainModal.obj.show();
|
||||
}
|
||||
|
||||
if (args.item.id === 'EditCustom') {
|
||||
state.deleteMode = false;
|
||||
if (mainGrid.obj.getSelectedRecords().length) {
|
||||
const selectedRecord = mainGrid.obj.getSelectedRecords()[0];
|
||||
state.mainTitle = 'Edit Customer Contact';
|
||||
state.id = selectedRecord.id ?? '';
|
||||
state.number = selectedRecord.number ?? '';
|
||||
state.name = selectedRecord.name ?? '';
|
||||
state.jobTitle = selectedRecord.jobTitle ?? '';
|
||||
state.phoneNumber = selectedRecord.phoneNumber ?? '';
|
||||
state.emailAddress = selectedRecord.emailAddress ?? '';
|
||||
state.description = selectedRecord.description ?? '';
|
||||
state.customerId = selectedRecord.customerId ?? '';
|
||||
mainModal.obj.show();
|
||||
}
|
||||
}
|
||||
|
||||
if (args.item.id === 'DeleteCustom') {
|
||||
state.deleteMode = true;
|
||||
if (mainGrid.obj.getSelectedRecords().length) {
|
||||
const selectedRecord = mainGrid.obj.getSelectedRecords()[0];
|
||||
state.mainTitle = 'Delete Customer Contact?';
|
||||
state.id = selectedRecord.id ?? '';
|
||||
state.number = selectedRecord.number ?? '';
|
||||
state.name = selectedRecord.name ?? '';
|
||||
state.jobTitle = selectedRecord.jobTitle ?? '';
|
||||
state.phoneNumber = selectedRecord.phoneNumber ?? '';
|
||||
state.emailAddress = selectedRecord.emailAddress ?? '';
|
||||
state.description = selectedRecord.description ?? '';
|
||||
state.customerId = selectedRecord.customerId ?? '';
|
||||
mainModal.obj.show();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
mainGrid.obj.appendTo(mainGridRef.value);
|
||||
},
|
||||
refresh: () => {
|
||||
mainGrid.obj.setProperties({ dataSource: state.mainData });
|
||||
}
|
||||
};
|
||||
|
||||
const mainModal = {
|
||||
obj: null,
|
||||
create: () => {
|
||||
mainModal.obj = new bootstrap.Modal(mainModalRef.value, {
|
||||
backdrop: 'static',
|
||||
keyboard: false
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
return {
|
||||
mainGridRef,
|
||||
mainModalRef,
|
||||
nameRef,
|
||||
numberRef,
|
||||
jobTitleRef,
|
||||
phoneNumberRef,
|
||||
emailAddressRef,
|
||||
customerIdRef,
|
||||
state,
|
||||
handler,
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
Vue.createApp(App).mount('#app');
|
||||
@@ -0,0 +1,72 @@
|
||||
@page
|
||||
@attribute [Authorize(Roles = "CustomerGroups")]
|
||||
@{
|
||||
ViewData["Title"] = "Customer Group List";
|
||||
}
|
||||
|
||||
<div id="app" v-cloak>
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<div class="grid-container">
|
||||
<div ref="mainGridRef"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="modal fade" ref="mainModalRef" id="MainModal" tabindex="-1" aria-hidden="true" data-bs-backdrop="static">
|
||||
<div class="modal-dialog modal-dialog-centered modal-lg">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title" v-text="state.mainTitle"></h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<input type="hidden" v-model="state.id" id="Id" name="Id" />
|
||||
<form id="MainForm">
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<h5>Main Info</h5>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="row mb-2">
|
||||
<div class="col-md-6">
|
||||
<label for="Name">Name</label>
|
||||
<input ref="nameRef" v-model="state.name" />
|
||||
<label class="text-danger" v-text="state.errors.name"></label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mb-2">
|
||||
<div class="col-12">
|
||||
<label for="Description">Description</label>
|
||||
<textarea class="form-control" rows="3" v-model="state.description"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
|
||||
<button type="button"
|
||||
id="MainSaveButton"
|
||||
class="btn"
|
||||
v-bind:class="state.deleteMode ? 'btn-danger' : 'btn-primary'"
|
||||
v-on:click="handler.handleSubmit"
|
||||
v-bind:disabled="state.isSubmitting">
|
||||
<span class="spinner-border spinner-border-sm me-2" v-if="state.isSubmitting" role="status" aria-hidden="true"></span>
|
||||
<span v-if="!state.isSubmitting">{{ state.deleteMode ? 'Delete' : 'Save' }}</span>
|
||||
<span v-else>{{ state.deleteMode ? 'Deleting...' : 'Saving...' }}</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@section scripts {
|
||||
<script src="~/FrontEnd/Pages/CustomerGroups/CustomerGroupList.cshtml.js"></script>
|
||||
}
|
||||
+306
@@ -0,0 +1,306 @@
|
||||
const App = {
|
||||
setup() {
|
||||
const state = Vue.reactive({
|
||||
mainData: [],
|
||||
deleteMode: false,
|
||||
mainTitle: null,
|
||||
id: '',
|
||||
name: '',
|
||||
description: '',
|
||||
errors: {
|
||||
name: ''
|
||||
},
|
||||
isSubmitting: false
|
||||
});
|
||||
|
||||
const mainGridRef = Vue.ref(null);
|
||||
const mainModalRef = Vue.ref(null);
|
||||
const nameRef = Vue.ref(null);
|
||||
|
||||
const services = {
|
||||
getMainData: async () => {
|
||||
try {
|
||||
const response = await AxiosManager.get('/CustomerGroup/GetCustomerGroupList', {});
|
||||
return response;
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
},
|
||||
createMainData: async (name, description, createdById) => {
|
||||
try {
|
||||
const response = await AxiosManager.post('/CustomerGroup/CreateCustomerGroup', {
|
||||
name, description, createdById
|
||||
});
|
||||
return response;
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
},
|
||||
updateMainData: async (id, name, description, updatedById) => {
|
||||
try {
|
||||
const response = await AxiosManager.post('/CustomerGroup/UpdateCustomerGroup', {
|
||||
id, name, description, updatedById
|
||||
});
|
||||
return response;
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
},
|
||||
deleteMainData: async (id, deletedById) => {
|
||||
try {
|
||||
const response = await AxiosManager.post('/CustomerGroup/DeleteCustomerGroup', {
|
||||
id, deletedById
|
||||
});
|
||||
return response;
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
const methods = {
|
||||
populateMainData: async () => {
|
||||
const response = await services.getMainData();
|
||||
state.mainData = response?.data?.content?.data.map(item => ({
|
||||
...item,
|
||||
createdAtUtc: new Date(item.createdAtUtc)
|
||||
}));
|
||||
}
|
||||
};
|
||||
|
||||
const nameText = {
|
||||
obj: null,
|
||||
create: () => {
|
||||
nameText.obj = new ej.inputs.TextBox({
|
||||
placeholder: 'Enter Name',
|
||||
});
|
||||
nameText.obj.appendTo(nameRef.value);
|
||||
},
|
||||
refresh: () => {
|
||||
if (nameText.obj) {
|
||||
nameText.obj.value = state.name;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Vue.watch(
|
||||
() => state.name,
|
||||
(newVal, oldVal) => {
|
||||
state.errors.name = '';
|
||||
nameText.refresh();
|
||||
}
|
||||
);
|
||||
|
||||
const handler = {
|
||||
handleSubmit: async function () {
|
||||
try {
|
||||
state.isSubmitting = true;
|
||||
await new Promise(resolve => setTimeout(resolve, 200));
|
||||
|
||||
let isValid = true;
|
||||
|
||||
// name validation
|
||||
if (!state.name) {
|
||||
state.errors.name = 'Name is required.';
|
||||
isValid = false;
|
||||
}
|
||||
|
||||
if (!isValid) return;
|
||||
|
||||
const response = state.id === ''
|
||||
? await services.createMainData(state.name, state.description, StorageManager.getUserId())
|
||||
: state.deleteMode
|
||||
? await services.deleteMainData(state.id, StorageManager.getUserId())
|
||||
: await services.updateMainData(state.id, state.name, state.description, StorageManager.getUserId());
|
||||
|
||||
if (response.data.code === 200) {
|
||||
await methods.populateMainData();
|
||||
mainGrid.refresh();
|
||||
|
||||
Swal.fire({
|
||||
icon: 'success',
|
||||
title: state.deleteMode ? 'Delete Successful' : 'Save Successful',
|
||||
text: 'Form will be closed...',
|
||||
timer: 2000,
|
||||
showConfirmButton: false
|
||||
});
|
||||
setTimeout(() => {
|
||||
mainModal.obj.hide();
|
||||
resetFormState();
|
||||
}, 2000);
|
||||
} else {
|
||||
Swal.fire({
|
||||
icon: 'error',
|
||||
title: state.deleteMode ? 'Delete Failed' : 'Save Failed',
|
||||
text: response.data.message ?? 'Please check your data.',
|
||||
confirmButtonText: 'Try Again'
|
||||
});
|
||||
}
|
||||
|
||||
} catch (error) {
|
||||
Swal.fire({
|
||||
icon: 'error',
|
||||
title: 'An Error Occurred',
|
||||
text: error.response?.data?.message ?? 'Please try again.',
|
||||
confirmButtonText: 'OK'
|
||||
});
|
||||
} finally {
|
||||
state.isSubmitting = false;
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
const resetFormState = () => {
|
||||
state.id = '';
|
||||
state.name = '';
|
||||
state.description = '';
|
||||
state.errors = {
|
||||
name: ''
|
||||
};
|
||||
};
|
||||
|
||||
const mainGrid = {
|
||||
obj: null,
|
||||
create: async (dataSource) => {
|
||||
mainGrid.obj = new ej.grids.Grid({
|
||||
height: '240px',
|
||||
dataSource: dataSource,
|
||||
allowFiltering: true,
|
||||
allowSorting: true,
|
||||
allowSelection: true,
|
||||
allowGrouping: true,
|
||||
allowTextWrap: true,
|
||||
allowResizing: true,
|
||||
allowPaging: true,
|
||||
allowExcelExport: true,
|
||||
filterSettings: { type: 'CheckBox' },
|
||||
sortSettings: { columns: [{ field: 'createdAtUtc', direction: 'Descending' }] },
|
||||
pageSettings: { currentPage: 1, pageSize: 50, pageSizes: ["10", "20", "50", "100", "200", "All"] },
|
||||
selectionSettings: { persistSelection: true, type: 'Single' },
|
||||
autoFit: true,
|
||||
showColumnMenu: true,
|
||||
gridLines: 'Horizontal',
|
||||
columns: [
|
||||
{ type: 'checkbox', width: 60 },
|
||||
{
|
||||
field: 'id', isPrimaryKey: true, headerText: 'Id', visible: false
|
||||
},
|
||||
{ field: 'name', headerText: 'Name', width: 200, minWidth: 200 },
|
||||
{ field: 'description', headerText: 'Description', width: 400, minWidth: 400 },
|
||||
{ field: 'createdAtUtc', headerText: 'Created At UTC', width: 150, format: 'yyyy-MM-dd HH:mm' }
|
||||
],
|
||||
toolbar: [
|
||||
'ExcelExport', 'Search',
|
||||
{ type: 'Separator' },
|
||||
{ text: 'Add', tooltipText: 'Add', prefixIcon: 'e-add', id: 'AddCustom' },
|
||||
{ text: 'Edit', tooltipText: 'Edit', prefixIcon: 'e-edit', id: 'EditCustom' },
|
||||
{ text: 'Delete', tooltipText: 'Delete', prefixIcon: 'e-delete', id: 'DeleteCustom' },
|
||||
{ type: 'Separator' },
|
||||
],
|
||||
beforeDataBound: () => { },
|
||||
dataBound: function () {
|
||||
mainGrid.obj.toolbarModule.enableItems(['EditCustom', 'DeleteCustom'], false);
|
||||
mainGrid.obj.autoFitColumns(['name', 'description', 'createdAtUtc']);
|
||||
},
|
||||
excelExportComplete: () => { },
|
||||
rowSelected: () => {
|
||||
if (mainGrid.obj.getSelectedRecords().length == 1) {
|
||||
mainGrid.obj.toolbarModule.enableItems(['EditCustom', 'DeleteCustom'], true);
|
||||
} else {
|
||||
mainGrid.obj.toolbarModule.enableItems(['EditCustom', 'DeleteCustom'], false);
|
||||
}
|
||||
},
|
||||
rowDeselected: () => {
|
||||
if (mainGrid.obj.getSelectedRecords().length == 1) {
|
||||
mainGrid.obj.toolbarModule.enableItems(['EditCustom', 'DeleteCustom'], true);
|
||||
} else {
|
||||
mainGrid.obj.toolbarModule.enableItems(['EditCustom', 'DeleteCustom'], false);
|
||||
}
|
||||
},
|
||||
rowSelecting: () => {
|
||||
if (mainGrid.obj.getSelectedRecords().length) {
|
||||
mainGrid.obj.clearSelection();
|
||||
}
|
||||
},
|
||||
toolbarClick: async (args) => {
|
||||
if (args.item.id === 'MainGrid_excelexport') {
|
||||
mainGrid.obj.excelExport();
|
||||
}
|
||||
|
||||
if (args.item.id === 'AddCustom') {
|
||||
state.deleteMode = false;
|
||||
state.mainTitle = 'Add Customer Group';
|
||||
resetFormState();
|
||||
mainModal.obj.show();
|
||||
}
|
||||
|
||||
if (args.item.id === 'EditCustom') {
|
||||
state.deleteMode = false;
|
||||
if (mainGrid.obj.getSelectedRecords().length) {
|
||||
const selectedRecord = mainGrid.obj.getSelectedRecords()[0];
|
||||
state.mainTitle = 'Edit Customer Group';
|
||||
state.id = selectedRecord.id ?? '';
|
||||
state.name = selectedRecord.name ?? '';
|
||||
state.description = selectedRecord.description ?? '';
|
||||
mainModal.obj.show();
|
||||
}
|
||||
}
|
||||
|
||||
if (args.item.id === 'DeleteCustom') {
|
||||
state.deleteMode = true;
|
||||
if (mainGrid.obj.getSelectedRecords().length) {
|
||||
const selectedRecord = mainGrid.obj.getSelectedRecords()[0];
|
||||
state.mainTitle = 'Delete Customer Group?';
|
||||
state.id = selectedRecord.id ?? '';
|
||||
state.name = selectedRecord.name ?? '';
|
||||
state.description = selectedRecord.description ?? '';
|
||||
mainModal.obj.show();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
mainGrid.obj.appendTo(mainGridRef.value);
|
||||
},
|
||||
refresh: () => {
|
||||
mainGrid.obj.setProperties({ dataSource: state.mainData });
|
||||
}
|
||||
};
|
||||
|
||||
const mainModal = {
|
||||
obj: null,
|
||||
create: () => {
|
||||
mainModal.obj = new bootstrap.Modal(mainModalRef.value, {
|
||||
backdrop: 'static',
|
||||
keyboard: false
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
Vue.onMounted(async () => {
|
||||
try {
|
||||
await SecurityManager.authorizePage(['CustomerGroups']);
|
||||
await SecurityManager.validateToken();
|
||||
|
||||
await methods.populateMainData();
|
||||
await mainGrid.create(state.mainData);
|
||||
nameText.create();
|
||||
mainModal.create();
|
||||
} catch (e) {
|
||||
console.error('page init error:', e);
|
||||
} finally {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
return {
|
||||
mainGridRef,
|
||||
mainModalRef,
|
||||
nameRef,
|
||||
state,
|
||||
handler,
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
Vue.createApp(App).mount('#app');
|
||||
@@ -0,0 +1,229 @@
|
||||
@page
|
||||
@attribute [Authorize(Roles = "Customers")]
|
||||
@{
|
||||
ViewData["Title"] = "Customer List";
|
||||
}
|
||||
|
||||
<div id="app" v-cloak>
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<div class="grid-container">
|
||||
<div ref="mainGridRef"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="modal fade" ref="mainModalRef" id="MainModal" tabindex="-1" aria-hidden="true" data-bs-backdrop="static">
|
||||
<div class="modal-dialog modal-dialog-centered modal-lg">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title" v-text="state.mainTitle"></h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<input type="hidden" v-model="state.id" id="Id" name="Id" />
|
||||
<form id="MainForm">
|
||||
<div class="card mb-3">
|
||||
<div class="card-header">
|
||||
<h5>Main Info</h5>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="row mb-2">
|
||||
<div class="col-md-6">
|
||||
<label for="Name">Name</label>
|
||||
<input ref="nameRef" v-model="state.name" class="form-control" placeholder="" />
|
||||
<label class="text-danger" v-text="state.errors.name"></label>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<label for="Number">Number</label>
|
||||
<input ref="numberRef" v-model="state.number" class="form-control" placeholder="" readonly />
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mb-2">
|
||||
<div class="col-md-6">
|
||||
<label for="CustomerGroupId">Customer Group</label>
|
||||
<div ref="customerGroupIdRef"></div>
|
||||
<label class="text-danger" v-text="state.errors.customerGroupId"></label>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<label for="CustomerCategoryId">Customer Category</label>
|
||||
<div ref="customerCategoryIdRef"></div>
|
||||
<label class="text-danger" v-text="state.errors.customerCategoryId"></label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mb-2">
|
||||
<div class="col-12">
|
||||
<label for="Description">Description</label>
|
||||
<textarea v-model="state.description" class="form-control" rows="3" placeholder=""></textarea>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card mb-3">
|
||||
<div class="card-header">
|
||||
<h5>Address</h5>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="row mb-2">
|
||||
<div class="col-md-6">
|
||||
<label for="Street">Street</label>
|
||||
<input ref="streetRef" v-model="state.street" class="form-control" placeholder="" />
|
||||
<label class="text-danger" v-text="state.errors.street"></label>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<label for="City">City</label>
|
||||
<input ref="cityRef" v-model="state.city" class="form-control" placeholder="" />
|
||||
<label class="text-danger" v-text="state.errors.city"></label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mb-2">
|
||||
<div class="col-md-6">
|
||||
<label for="State">State</label>
|
||||
<input ref="stateRef" v-model="state.state" class="form-control" placeholder="" />
|
||||
<label class="text-danger" v-text="state.errors.state"></label>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<label for="ZipCode">Zip Code</label>
|
||||
<input ref="zipCodeRef" v-model="state.zipCode" class="form-control" placeholder="" />
|
||||
<label class="text-danger" v-text="state.errors.zipCode"></label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mb-2">
|
||||
<div class="col-md-6">
|
||||
<label for="Country">Country</label>
|
||||
<input ref="countryRef" v-model="state.country" class="form-control" placeholder="" />
|
||||
<label class="text-danger" v-text="state.errors.country"></label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card mb-3">
|
||||
<div class="card-header">
|
||||
<h5>Communication</h5>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="row mb-2">
|
||||
<div class="col-md-6">
|
||||
<label for="PhoneNumber">Phone Number</label>
|
||||
<input ref="phoneNumberRef" v-model="state.phoneNumber" class="form-control" placeholder="" />
|
||||
<label class="text-danger" v-text="state.errors.phoneNumber"></label>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<label for="FaxNumber">Fax Number</label>
|
||||
<input ref="faxNumberRef" v-model="state.faxNumber" class="form-control" placeholder="" />
|
||||
<label class="text-danger" v-text="state.errors.faxNumber"></label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mb-2">
|
||||
<div class="col-md-6">
|
||||
<label for="EmailAddress">Email</label>
|
||||
<input ref="emailAddressRef" v-model="state.emailAddress" class="form-control" placeholder="" />
|
||||
<label class="text-danger" v-text="state.errors.emailAddress"></label>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<label for="Website">Website</label>
|
||||
<input ref="websiteRef" v-model="state.website" class="form-control" placeholder="" />
|
||||
<label class="text-danger" v-text="state.errors.website"></label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card mb-3">
|
||||
<div class="card-header">
|
||||
<h5>Social Media</h5>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="row mb-2">
|
||||
<div class="col-md-4">
|
||||
<label for="WhatsApp">WhatsApp</label>
|
||||
<input ref="whatsAppRef" v-model="state.whatsApp" class="form-control" placeholder="" />
|
||||
<label class="text-danger" v-text="state.errors.whatsApp"></label>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<label for="LinkedIn">LinkedIn</label>
|
||||
<input ref="linkedInRef" v-model="state.linkedIn" class="form-control" placeholder="" />
|
||||
<label class="text-danger" v-text="state.errors.linkedIn"></label>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<label for="Facebook">Facebook</label>
|
||||
<input ref="facebookRef" v-model="state.facebook" class="form-control" placeholder="" />
|
||||
<label class="text-danger" v-text="state.errors.facebook"></label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mb-2">
|
||||
<div class="col-md-4">
|
||||
<label for="Instagram">Instagram</label>
|
||||
<input ref="instagramRef" v-model="state.instagram" class="form-control" placeholder="" />
|
||||
<label class="text-danger" v-text="state.errors.instagram"></label>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<label for="TwitterX">Twitter/X</label>
|
||||
<input ref="twitterXRef" v-model="state.twitterX" class="form-control" placeholder="" />
|
||||
<label class="text-danger" v-text="state.errors.twitterX"></label>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<label for="TikTok">TikTok</label>
|
||||
<input ref="tikTokRef" v-model="state.tikTok" class="form-control" placeholder="" />
|
||||
<label class="text-danger" v-text="state.errors.tikTok"></label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
|
||||
<button type="button"
|
||||
id="MainSaveButton"
|
||||
class="btn"
|
||||
v-bind:class="state.deleteMode ? 'btn-danger' : 'btn-primary'"
|
||||
v-on:click="handler.handleSubmit"
|
||||
v-bind:disabled="state.isSubmitting">
|
||||
<span class="spinner-border spinner-border-sm me-2" v-if="state.isSubmitting" role="status" aria-hidden="true"></span>
|
||||
<span v-if="!state.isSubmitting">{{ state.deleteMode ? 'Delete' : 'Save' }}</span>
|
||||
<span v-else>{{ state.deleteMode ? 'Deleting...' : 'Saving...' }}</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="modal fade" ref="manageContactModalRef" id="ManageContactModal" tabindex="-1" aria-hidden="true" data-bs-backdrop="static">
|
||||
<div class="modal-dialog modal-dialog-centered modal-lg">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title" v-text="state.manageContactTitle"></h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<input type="hidden" v-model="state.id" id="Id" name="Id" />
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<h5>Customer Contact</h5>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<div class="grid-container">
|
||||
<div ref="secondaryGridRef"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@section scripts {
|
||||
<script src="~/FrontEnd/Pages/Customers/CustomerList.cshtml.js"></script>
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,186 @@
|
||||
@page
|
||||
@attribute [Authorize(Roles = "Dashboards")]
|
||||
@{
|
||||
ViewData["Title"] = "Default Dashboard";
|
||||
}
|
||||
|
||||
<div id="app" v-cloak>
|
||||
<div class="form-card" id="formcard">
|
||||
<div class="container-fluid pt-4 px-4">
|
||||
<div class="row g-4">
|
||||
<div class="col-sm-6 col-xl-3">
|
||||
<div class="bg-white rounded d-flex align-items-center justify-content-between p-4">
|
||||
<i class="fas fa-chart-line fa-3x" style="color: #E94649;"></i>
|
||||
<div class="ms-3">
|
||||
<p class="mb-2">Sales</p>
|
||||
<h6 class="mb-0 text-end"><span ref="cardSalesQtyRef"></span> Qty.</h6>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-6 col-xl-3">
|
||||
<div class="bg-white rounded d-flex align-items-center justify-content-between p-4">
|
||||
<i class="fas fa-undo-alt fa-3x" style="color: #F6B53F;"></i>
|
||||
<div class="ms-3">
|
||||
<p class="mb-2">Sales Rtrn.</p>
|
||||
<h6 class="mb-0 text-end"><span ref="cardSalesReturnQtyRef"></span> Qty.</h6>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-6 col-xl-3">
|
||||
<div class="bg-white rounded d-flex align-items-center justify-content-between p-4">
|
||||
<i class="fas fa-shopping-cart fa-3x text-primary"></i>
|
||||
<div class="ms-3">
|
||||
<p class="mb-2">Purchase</p>
|
||||
<h6 class="mb-0 text-end"><span ref="cardPurchaseQtyRef"></span> Qty.</h6>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-6 col-xl-3">
|
||||
<div class="bg-white rounded d-flex align-items-center justify-content-between p-4">
|
||||
<i class="fas fa-undo fa-3x" style="color: #C4C24A;"></i>
|
||||
<div class="ms-3">
|
||||
<p class="mb-2">Purchase Rtrn.</p>
|
||||
<h6 class="mb-0 text-end"><span ref="cardPurchaseReturnQtyRef"></span> Qty.</h6>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="container-fluid pt-4 px-4">
|
||||
<div class="row g-4">
|
||||
<div class="col-sm-6 col-xl-3">
|
||||
<div class="bg-white rounded d-flex align-items-center justify-content-between p-4">
|
||||
<i class="fas fa-truck fa-3x" style="color: #C4C24A;"></i>
|
||||
<div class="ms-3">
|
||||
<p class="mb-2">Delivery Order</p>
|
||||
<h6 class="mb-0 text-end"><span ref="cardDeliveryOrderQtyRef"></span> Qty.</h6>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-6 col-xl-3">
|
||||
<div class="bg-white rounded d-flex align-items-center justify-content-between p-4">
|
||||
<i class="fas fa-boxes fa-3x text-primary"></i>
|
||||
<div class="ms-3">
|
||||
<p class="mb-2">Goods Receive</p>
|
||||
<h6 class="mb-0 text-end"><span ref="cardGoodsReceiveQtyRef"></span> Qty.</h6>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-6 col-xl-3">
|
||||
<div class="bg-white rounded d-flex align-items-center justify-content-between p-4">
|
||||
<i class="fas fa-sign-out-alt fa-3x" style="color: #F6B53F;"></i>
|
||||
<div class="ms-3">
|
||||
<p class="mb-2">Transfer Out</p>
|
||||
<h6 class="mb-0 text-end"><span ref="cardTransferOutQtyRef"></span> Qty.</h6>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-6 col-xl-3">
|
||||
<div class="bg-white rounded d-flex align-items-center justify-content-between p-4">
|
||||
<i class="fas fa-sign-in-alt fa-3x" style="color: #E94649"></i>
|
||||
<div class="ms-3">
|
||||
<p class="mb-2">Transfer In</p>
|
||||
<h6 class="mb-0 text-end"><span ref="cardTransferInQtyRef"></span> Qty.</h6>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="container-fluid pt-4 px-4">
|
||||
<div class="row g-4">
|
||||
<div class="col-sm-12 col-xl-6">
|
||||
<div class="bg-white text-center rounded p-4">
|
||||
<div class="d-flex align-items-center justify-content-between mb-4">
|
||||
<h6 class="mb-0">Customer Group</h6>
|
||||
<a href="/SalesReports/SalesReportList">Sales</a>
|
||||
</div>
|
||||
<div ref="customerGroupChartRef" align="center"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-12 col-xl-6">
|
||||
<div class="bg-white text-center rounded p-4">
|
||||
<div class="d-flex align-items-center justify-content-between mb-4">
|
||||
<h6 class="mb-0">Vendor Group</h6>
|
||||
<a href="/PurchaseReports/PurchaseReportList">Purchases</a>
|
||||
</div>
|
||||
<div ref="vendorGroupChartRef" align="center"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="container-fluid pt-4 px-4">
|
||||
<div class="row g-4">
|
||||
<div class="col-sm-12 col-xl-6">
|
||||
<div class="bg-white text-center rounded p-4">
|
||||
<div class="d-flex align-items-center justify-content-between mb-4">
|
||||
<h6 class="mb-0">Customer Category</h6>
|
||||
<a href="/SalesReports/SalesReportList">Sales</a>
|
||||
</div>
|
||||
<div ref="customerCategoryChartRef" align="center"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-12 col-xl-6">
|
||||
<div class="bg-white text-center rounded p-4">
|
||||
<div class="d-flex align-items-center justify-content-between mb-4">
|
||||
<h6 class="mb-0">Vendor Category</h6>
|
||||
<a href="/PurchaseReports/PurchaseReportList">Purchases</a>
|
||||
</div>
|
||||
<div ref="vendorCategoryChartRef" align="center"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="container-fluid pt-4 px-4">
|
||||
<div class="row g-4">
|
||||
<div class="col-sm-12 col-xl-6">
|
||||
<div class="bg-white text-center rounded p-4">
|
||||
<div class="d-flex align-items-center justify-content-between mb-4">
|
||||
<h6 class="mb-0">Latest Sales</h6>
|
||||
<a href="/SalesOrders/SalesOrderList">Sales</a>
|
||||
</div>
|
||||
<div ref="salesOrderGridRef" align="center"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-12 col-xl-6">
|
||||
<div class="bg-white text-center rounded p-4">
|
||||
<div class="d-flex align-items-center justify-content-between mb-4">
|
||||
<h6 class="mb-0">Latest Purchase</h6>
|
||||
<a href="/PurchaseOrders/PurchaseOrderList">Purchases</a>
|
||||
</div>
|
||||
<div ref="purchaseOrderGridRef" align="center"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="container-fluid pt-4 px-4">
|
||||
<div class="row g-4">
|
||||
<div class="col-sm-12 col-xl-12">
|
||||
<div class="bg-white text-center rounded p-4">
|
||||
<div class="d-flex align-items-center justify-content-between mb-4">
|
||||
<h6 class="mb-0">Inventory Stock</h6>
|
||||
<a href="/StockReports/StockReportList">Stocks</a>
|
||||
</div>
|
||||
<div ref="stockChartRef" align="center"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="container-fluid pt-4 px-4">
|
||||
<div class="row g-4 mb-4">
|
||||
<div class="col-sm-12 col-xl-12">
|
||||
<div class="bg-white text-center rounded p-4">
|
||||
<div class="d-flex align-items-center justify-content-between mb-4">
|
||||
<h6 class="mb-0">Inventory Transaction</h6>
|
||||
<a href="/TransactionReports/TransactionReportList">Transactions</a>
|
||||
</div>
|
||||
<div ref="inventoryTransactionGridRef" align="center"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@section scripts {
|
||||
<script src="~/FrontEnd/Pages/Dashboards/DefaultDashboard.cshtml.js"></script>
|
||||
}
|
||||
@@ -0,0 +1,337 @@
|
||||
const App = {
|
||||
setup() {
|
||||
const state = Vue.reactive({
|
||||
cardsData: {},
|
||||
salesData: {},
|
||||
purchaseData: {},
|
||||
inventoryData: {}
|
||||
});
|
||||
|
||||
const cardSalesQtyRef = Vue.ref(null);
|
||||
const cardSalesReturnQtyRef = Vue.ref(null);
|
||||
const cardPurchaseQtyRef = Vue.ref(null);
|
||||
const cardPurchaseReturnQtyRef = Vue.ref(null);
|
||||
const cardDeliveryOrderQtyRef = Vue.ref(null);
|
||||
const cardGoodsReceiveQtyRef = Vue.ref(null);
|
||||
const cardTransferOutQtyRef = Vue.ref(null);
|
||||
const cardTransferInQtyRef = Vue.ref(null);
|
||||
|
||||
const salesOrderGridRef = Vue.ref(null);
|
||||
const inventoryTransactionGridRef = Vue.ref(null);
|
||||
const purchaseOrderGridRef = Vue.ref(null);
|
||||
const customerGroupChartRef = Vue.ref(null);
|
||||
const vendorGroupChartRef = Vue.ref(null);
|
||||
const customerCategoryChartRef = Vue.ref(null);
|
||||
const vendorCategoryChartRef = Vue.ref(null);
|
||||
const stockChartRef = Vue.ref(null);
|
||||
|
||||
const services = {
|
||||
getCardsData: async () => {
|
||||
try {
|
||||
const response = await AxiosManager.get('/Dashboard/GetCardsDashboard', {});
|
||||
return response;
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
},
|
||||
getSalesData: async () => {
|
||||
try {
|
||||
const response = await AxiosManager.get('/Dashboard/GetSalesDashboard', {});
|
||||
return response;
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
},
|
||||
getPurchaseData: async () => {
|
||||
try {
|
||||
const response = await AxiosManager.get('/Dashboard/GetPurchaseDashboard', {});
|
||||
return response;
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
},
|
||||
getInventoryData: async () => {
|
||||
try {
|
||||
const response = await AxiosManager.get('/Dashboard/GetInventoryDashboard', {});
|
||||
return response;
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
const methods = {
|
||||
populateCardsData: async () => {
|
||||
const response = await services.getCardsData();
|
||||
state.cardsData = response?.data?.content?.data;
|
||||
methods.populateCards();
|
||||
},
|
||||
populateSalesData: async () => {
|
||||
const response = await services.getSalesData();
|
||||
state.salesData = response?.data?.content?.data;
|
||||
methods.populateSalesOrderGrid();
|
||||
methods.populateSalesByCustomerGroupChart();
|
||||
methods.populateSalesByCustomerCategoryChart();
|
||||
},
|
||||
populatePurchaseData: async () => {
|
||||
const response = await services.getPurchaseData();
|
||||
state.purchaseData = response?.data?.content?.data;
|
||||
methods.populatePurchaseOrderGrid();
|
||||
methods.populatePurchaseByVendorGroupChart();
|
||||
methods.populatePurchaseByVendorCategoryChart();
|
||||
},
|
||||
populateInventoryData: async () => {
|
||||
const response = await services.getInventoryData();
|
||||
state.inventoryData = response?.data?.content?.data;
|
||||
methods.populateInventoryTransactionGrid();
|
||||
methods.populateInventoryStockChart();
|
||||
},
|
||||
populateCards: () => {
|
||||
const cardsDashboard = state.cardsData?.cardsDashboard;
|
||||
|
||||
if (cardsDashboard) {
|
||||
cardSalesQtyRef.value.textContent = cardsDashboard.salesTotal || 0;
|
||||
cardSalesReturnQtyRef.value.textContent = cardsDashboard.salesReturnTotal || 0;
|
||||
cardPurchaseQtyRef.value.textContent = cardsDashboard.purchaseTotal || 0;
|
||||
cardPurchaseReturnQtyRef.value.textContent = cardsDashboard.purchaseReturnTotal || 0;
|
||||
cardDeliveryOrderQtyRef.value.textContent = cardsDashboard.deliveryOrderTotal || 0;
|
||||
cardGoodsReceiveQtyRef.value.textContent = cardsDashboard.goodsReceiveTotal || 0;
|
||||
cardTransferOutQtyRef.value.textContent = cardsDashboard.transferOutTotal || 0;
|
||||
cardTransferInQtyRef.value.textContent = cardsDashboard.transferInTotal || 0;
|
||||
} else {
|
||||
console.error('CardsDashboard data is not available.');
|
||||
}
|
||||
},
|
||||
populateSalesOrderGrid: () => {
|
||||
const salesOrderDashboard = state.salesData?.salesOrderDashboard ?? [];
|
||||
new ej.grids.Grid({
|
||||
dataSource: salesOrderDashboard,
|
||||
allowFiltering: false,
|
||||
allowSorting: true,
|
||||
allowSelection: false,
|
||||
allowGrouping: false,
|
||||
allowTextWrap: false,
|
||||
allowResizing: false,
|
||||
allowPaging: true,
|
||||
allowExcelExport: false,
|
||||
sortSettings: { columns: [{ field: 'orderDate', direction: 'Descending' }] },
|
||||
pageSettings: { currentPage: 1, pageSize: 10 },
|
||||
autoFit: false,
|
||||
showColumnMenu: false,
|
||||
gridLines: 'Horizontal',
|
||||
columns: [
|
||||
{
|
||||
field: 'id', isPrimaryKey: true, headerText: 'Id', visible: false
|
||||
},
|
||||
{ field: 'salesOrder.orderDate', headerText: 'Order Date', width: 70, type: 'dateTime', format: 'yyyy-MM-dd', textAlign: 'Left' },
|
||||
{ field: 'salesOrder.number', headerText: '#Number', width: 90 },
|
||||
{ field: 'product.name', headerText: 'Product', width: 150 },
|
||||
{ field: 'total', headerText: 'Total', width: 70, type: 'number', format: 'N2', textAlign: 'Right' },
|
||||
],
|
||||
}, salesOrderGridRef.value);
|
||||
},
|
||||
populateInventoryTransactionGrid: () => {
|
||||
const inventoryTransactionDashboard = state.inventoryData?.inventoryTransactionDashboard ?? [];
|
||||
new ej.grids.Grid({
|
||||
dataSource: inventoryTransactionDashboard,
|
||||
allowFiltering: false,
|
||||
allowSorting: true,
|
||||
allowSelection: false,
|
||||
allowGrouping: false,
|
||||
allowTextWrap: false,
|
||||
allowResizing: false,
|
||||
allowPaging: true,
|
||||
allowExcelExport: false,
|
||||
sortSettings: { columns: [{ field: 'movementDate', direction: 'Descending' }] },
|
||||
pageSettings: { currentPage: 1, pageSize: 10 },
|
||||
autoFit: false,
|
||||
showColumnMenu: false,
|
||||
gridLines: 'Horizontal',
|
||||
columns: [
|
||||
{
|
||||
field: 'id', isPrimaryKey: true, headerText: 'Id', visible: false
|
||||
},
|
||||
{ field: 'movementDate', headerText: 'Date', width: 150, format: 'yyyy-MM-dd', textAlign: 'Left', type: 'dateTime' },
|
||||
{ field: 'warehouse.name', headerText: 'Warehouse', width: 150 },
|
||||
{ field: 'product.name', headerText: 'Product', width: 150 },
|
||||
{ field: 'number', headerText: 'Number', width: 150 },
|
||||
{ field: 'stock', headerText: 'Movement', width: 100, type: 'number', format: '+0.00;-0.00;0.00', textAlign: 'Right' },
|
||||
{ field: 'moduleName', headerText: 'Module Name', width: 150 },
|
||||
{ field: 'moduleCode', headerText: 'Module Code', width: 150 },
|
||||
{ field: 'moduleNumber', headerText: 'Module Number', width: 150 },
|
||||
{ field: 'warehouseFrom.name', headerText: 'Warehouse From', width: 150 },
|
||||
{ field: 'warehouseTo.name', headerText: 'Warehouse To', width: 150 },
|
||||
],
|
||||
}, inventoryTransactionGridRef.value);
|
||||
},
|
||||
populatePurchaseOrderGrid: () => {
|
||||
const purchaseOrderDashboard = state.purchaseData?.purchaseOrderDashboard ?? [];
|
||||
new ej.grids.Grid({
|
||||
dataSource: purchaseOrderDashboard,
|
||||
allowFiltering: false,
|
||||
allowSorting: true,
|
||||
allowSelection: false,
|
||||
allowGrouping: false,
|
||||
allowTextWrap: false,
|
||||
allowResizing: false,
|
||||
allowPaging: true,
|
||||
allowExcelExport: false,
|
||||
sortSettings: { columns: [{ field: 'orderDate', direction: 'Descending' }] },
|
||||
pageSettings: { currentPage: 1, pageSize: 10 },
|
||||
autoFit: false,
|
||||
showColumnMenu: false,
|
||||
gridLines: 'Horizontal',
|
||||
columns: [
|
||||
{
|
||||
field: 'id', isPrimaryKey: true, headerText: 'Id', visible: false
|
||||
},
|
||||
{ field: 'purchaseOrder.orderDate', headerText: 'Order Date', width: 70, type: 'dateTime', format: 'yyyy-MM-dd', textAlign: 'Left' },
|
||||
{ field: 'purchaseOrder.number', headerText: '#Number', width: 90 },
|
||||
{ field: 'product.name', headerText: 'Product', width: 150 },
|
||||
{ field: 'total', headerText: 'Total', width: 70, type: 'number', format: 'N2', textAlign: 'Right' },
|
||||
],
|
||||
}, purchaseOrderGridRef.value);
|
||||
},
|
||||
populateSalesByCustomerGroupChart: () => {
|
||||
const salesByCustomerGroupDashboard = state.salesData?.salesByCustomerGroupDashboard ?? [];
|
||||
new ej.charts.Chart(
|
||||
{
|
||||
primaryXAxis: {
|
||||
valueType: 'Category', interval: 1, majorGridLines: { width: 0 }, majorTickLines: { width: 0 }, labelIntersectAction: 'None', labelRotation: ej.base.Browser.isDevice ? -45 : 0, minorTickLines: { width: 0 }
|
||||
},
|
||||
chartArea: { border: { width: 0 } },
|
||||
primaryYAxis: {
|
||||
title: 'Quantity',
|
||||
majorTickLines: { width: 0 }, lineStyle: { width: 0 },
|
||||
},
|
||||
series: salesByCustomerGroupDashboard,
|
||||
title: 'Sales by Customer Group',
|
||||
tooltip: { enable: true, header: "<b>${point.tooltip}</b>", shared: true },
|
||||
legendSettings: { enableHighlight: true },
|
||||
palettes: ["#E94649", "#F6B53F", "#009CFF", "#C4C24A"],
|
||||
},
|
||||
customerGroupChartRef.value);
|
||||
},
|
||||
populatePurchaseByVendorGroupChart: () => {
|
||||
const purchaseByVendorGroupDashboard = state.purchaseData?.purchaseByVendorGroupDashboard ?? [];
|
||||
new ej.charts.Chart(
|
||||
{
|
||||
primaryXAxis: {
|
||||
valueType: 'Category', interval: 1, majorGridLines: { width: 0 }, majorTickLines: { width: 0 }, labelIntersectAction: 'None', labelRotation: ej.base.Browser.isDevice ? -45 : 0, minorTickLines: { width: 0 }
|
||||
},
|
||||
chartArea: { border: { width: 0 } },
|
||||
primaryYAxis: {
|
||||
title: 'Quantity',
|
||||
majorTickLines: { width: 0 }, lineStyle: { width: 0 },
|
||||
},
|
||||
series: purchaseByVendorGroupDashboard,
|
||||
title: 'Purchase by Vendor Group',
|
||||
tooltip: { enable: true, header: "<b>${point.tooltip}</b>", shared: true },
|
||||
legendSettings: { enableHighlight: true },
|
||||
palettes: ["#E94649", "#F6B53F", "#009CFF", "#C4C24A"],
|
||||
},
|
||||
vendorGroupChartRef.value);
|
||||
},
|
||||
populateSalesByCustomerCategoryChart: () => {
|
||||
const salesByCustomerCategoryDashboard = state.salesData?.salesByCustomerCategoryDashboard ?? [];
|
||||
new ej.charts.Chart(
|
||||
{
|
||||
primaryXAxis: {
|
||||
valueType: 'Category', interval: 1, majorGridLines: { width: 0 }, majorTickLines: { width: 0 }, labelIntersectAction: 'None', labelRotation: ej.base.Browser.isDevice ? -45 : 0, minorTickLines: { width: 0 }
|
||||
},
|
||||
chartArea: { border: { width: 0 } },
|
||||
primaryYAxis: {
|
||||
title: 'Quantity',
|
||||
majorTickLines: { width: 0 }, lineStyle: { width: 0 },
|
||||
},
|
||||
series: salesByCustomerCategoryDashboard,
|
||||
title: 'Sales by Customer Category',
|
||||
tooltip: { enable: true, header: "<b>${point.tooltip}</b>", shared: true },
|
||||
legendSettings: { enableHighlight: true },
|
||||
palettes: ["#E94649", "#F6B53F", "#009CFF", "#C4C24A"],
|
||||
},
|
||||
customerCategoryChartRef.value);
|
||||
},
|
||||
populatePurchaseByVendorCategoryChart: () => {
|
||||
const purchaseByVendorCategoryDashboard = state.purchaseData?.purchaseByVendorCategoryDashboard ?? [];
|
||||
new ej.charts.Chart(
|
||||
{
|
||||
primaryXAxis: {
|
||||
valueType: 'Category', interval: 1, majorGridLines: { width: 0 }, majorTickLines: { width: 0 }, labelIntersectAction: 'None', labelRotation: ej.base.Browser.isDevice ? -45 : 0, minorTickLines: { width: 0 }
|
||||
},
|
||||
chartArea: { border: { width: 0 } },
|
||||
primaryYAxis: {
|
||||
title: 'Quantity',
|
||||
majorTickLines: { width: 0 }, lineStyle: { width: 0 },
|
||||
},
|
||||
series: purchaseByVendorCategoryDashboard,
|
||||
title: 'Purchase by Vendor Category',
|
||||
tooltip: { enable: true, header: "<b>${point.tooltip}</b>", shared: true },
|
||||
legendSettings: { enableHighlight: true },
|
||||
palettes: ["#E94649", "#F6B53F", "#009CFF", "#C4C24A"],
|
||||
},
|
||||
vendorCategoryChartRef.value);
|
||||
},
|
||||
populateInventoryStockChart: () => {
|
||||
const inventoryStockDashboard = state.inventoryData?.inventoryStockDashboard ?? [];
|
||||
new ej.charts.Chart(
|
||||
{
|
||||
primaryXAxis: {
|
||||
valueType: 'Category', interval: 1, majorGridLines: { width: 0 }, majorTickLines: { width: 0 }, labelIntersectAction: 'None', labelRotation: -15, minorTickLines: { width: 0 }
|
||||
},
|
||||
chartArea: { border: { width: 0 } },
|
||||
primaryYAxis: {
|
||||
title: 'Quantity',
|
||||
majorTickLines: { width: 0 }, lineStyle: { width: 0 },
|
||||
},
|
||||
series: inventoryStockDashboard,
|
||||
title: 'Stock by Warehouse',
|
||||
tooltip: { enable: true, header: "<b>${point.tooltip}</b>", shared: true },
|
||||
legendSettings: { visible: true },
|
||||
palettes: ["#E94649", "#F6B53F", "#009CFF", "#C4C24A"],
|
||||
},
|
||||
stockChartRef.value);
|
||||
},
|
||||
};
|
||||
|
||||
Vue.onMounted(async () => {
|
||||
try {
|
||||
await SecurityManager.authorizePage(['Dashboards']);
|
||||
await SecurityManager.validateToken();
|
||||
|
||||
await methods.populateCardsData();
|
||||
await methods.populateSalesData();
|
||||
await methods.populatePurchaseData();
|
||||
await methods.populateInventoryData();
|
||||
|
||||
|
||||
|
||||
} catch (e) {
|
||||
console.error('page init error:', e);
|
||||
}
|
||||
});
|
||||
|
||||
return {
|
||||
cardSalesQtyRef,
|
||||
cardSalesReturnQtyRef,
|
||||
cardPurchaseQtyRef,
|
||||
cardPurchaseReturnQtyRef,
|
||||
cardDeliveryOrderQtyRef,
|
||||
cardGoodsReceiveQtyRef,
|
||||
cardTransferOutQtyRef,
|
||||
cardTransferInQtyRef,
|
||||
salesOrderGridRef,
|
||||
inventoryTransactionGridRef,
|
||||
purchaseOrderGridRef,
|
||||
customerGroupChartRef,
|
||||
vendorGroupChartRef,
|
||||
customerCategoryChartRef,
|
||||
vendorCategoryChartRef,
|
||||
stockChartRef,
|
||||
state,
|
||||
methods
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
Vue.createApp(App).mount('#app');
|
||||
@@ -0,0 +1,128 @@
|
||||
@page
|
||||
@attribute [Authorize(Roles = "DeliveryOrders")]
|
||||
@{
|
||||
ViewData["Title"] = "Delivery Order List";
|
||||
}
|
||||
|
||||
<div id="app" v-cloak>
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<div class="grid-container">
|
||||
<div ref="mainGridRef"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="modal fade" ref="mainModalRef" id="MainModal" aria-hidden="true" tabindex="-1" data-bs-focus="false" data-bs-backdrop="static">
|
||||
<div class="modal-dialog modal-dialog-centered modal-xl">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title">{{ state.mainTitle }}</h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<input type="hidden" v-model="state.id" id="Id" name="Id" />
|
||||
<form>
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<h5>Main Info</h5>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="row mb-2">
|
||||
<div class="col-md-6">
|
||||
<label for="DeliveryDate">Delivery Date</label>
|
||||
<input ref="deliveryDateRef"/>
|
||||
<label class="text-danger">{{ state.errors.deliveryDate }}</label>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<label for="Number">Number</label>
|
||||
<input ref="numberRef" v-model="state.number" readonly>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mb-2">
|
||||
<div class="col-md-6">
|
||||
<label for="SalesOrderId">Sales Order</label>
|
||||
<div ref="salesOrderIdRef"></div>
|
||||
<label class="text-danger">{{ state.errors.salesOrderId }}</label>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<label for="Status">Status</label>
|
||||
<div ref="statusRef"></div>
|
||||
<label class="text-danger">{{ state.errors.status }}</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mb-2">
|
||||
<div class="col-md-12">
|
||||
<label for="Description">Description</label>
|
||||
<textarea class="form-control" rows="3" v-model="state.description"></textarea>
|
||||
<label class="text-danger">{{ state.errors.description }}</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
<div id="ComplexDiv" :style="{ display: state.showComplexDiv ? 'block' : 'none' }">
|
||||
<div class="row mt-3">
|
||||
<div class="col-md-12">
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<h5>Delivery Item</h5>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<div class="grid-container">
|
||||
<div ref="secondaryGridRef"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mt-4">
|
||||
<div class="col-md-12">
|
||||
<div class="card shadow-sm">
|
||||
<div class="card-header text-white">
|
||||
<h5 class="mb-0">Summary</h5>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="row justify-content-end">
|
||||
<div class="col-md-6">
|
||||
<div class="d-flex justify-content-between py-2">
|
||||
<span class="fw-bold">Total Movement</span>
|
||||
<span id="TotalMovement" class="fw-bold text-success">{{ state.totalMovementFormatted }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
|
||||
<button type="button"
|
||||
id="MainSaveButton"
|
||||
class="btn"
|
||||
v-bind:class="state.deleteMode ? 'btn-danger' : 'btn-primary'"
|
||||
v-on:click="handler.handleSubmit"
|
||||
v-bind:disabled="state.isSubmitting">
|
||||
<span class="spinner-border spinner-border-sm me-2" v-if="state.isSubmitting" role="status" aria-hidden="true"></span>
|
||||
<span v-if="!state.isSubmitting">{{ state.deleteMode ? 'Delete' : 'Save' }}</span>
|
||||
<span v-else>{{ state.deleteMode ? 'Deleting...' : 'Saving...' }}</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@section scripts {
|
||||
<script src="~/FrontEnd/Pages/DeliveryOrders/DeliveryOrderList.cshtml.js"></script>
|
||||
}
|
||||
+874
@@ -0,0 +1,874 @@
|
||||
const App = {
|
||||
setup() {
|
||||
const state = Vue.reactive({
|
||||
mainData: [],
|
||||
deleteMode: false,
|
||||
salesOrderListLookupData: [],
|
||||
statusListLookupData: [],
|
||||
secondaryData: [],
|
||||
productListLookupData: [],
|
||||
warehouseListLookupData: [],
|
||||
mainTitle: null,
|
||||
id: '',
|
||||
number: '',
|
||||
deliveryDate: '',
|
||||
description: '',
|
||||
salesOrderId: null,
|
||||
status: null,
|
||||
errors: {
|
||||
deliveryDate: '',
|
||||
salesOrderId: '',
|
||||
status: '',
|
||||
description: ''
|
||||
},
|
||||
showComplexDiv: false,
|
||||
isSubmitting: false,
|
||||
totalMovementFormatted: '0.00'
|
||||
});
|
||||
|
||||
const mainGridRef = Vue.ref(null);
|
||||
const mainModalRef = Vue.ref(null);
|
||||
const secondaryGridRef = Vue.ref(null);
|
||||
const deliveryDateRef = Vue.ref(null);
|
||||
const salesOrderIdRef = Vue.ref(null);
|
||||
const statusRef = Vue.ref(null);
|
||||
const numberRef = Vue.ref(null);
|
||||
|
||||
|
||||
const validateForm = function () {
|
||||
state.errors.deliveryDate = '';
|
||||
state.errors.salesOrderId = '';
|
||||
state.errors.status = '';
|
||||
|
||||
let isValid = true;
|
||||
|
||||
if (!state.deliveryDate) {
|
||||
state.errors.deliveryDate = 'Delivery date is required.';
|
||||
isValid = false;
|
||||
}
|
||||
if (!state.salesOrderId) {
|
||||
state.errors.salesOrderId = 'Sales Order is required.';
|
||||
isValid = false;
|
||||
}
|
||||
if (!state.status) {
|
||||
state.errors.status = 'Status is required.';
|
||||
isValid = false;
|
||||
}
|
||||
|
||||
return isValid;
|
||||
};
|
||||
|
||||
const resetFormState = () => {
|
||||
state.id = '';
|
||||
state.number = '';
|
||||
state.deliveryDate = '';
|
||||
state.description = '';
|
||||
state.salesOrderId = null;
|
||||
state.status = null;
|
||||
state.errors = {
|
||||
deliveryDate: '',
|
||||
salesOrderId: '',
|
||||
status: '',
|
||||
description: ''
|
||||
};
|
||||
state.secondaryData = [];
|
||||
};
|
||||
|
||||
const orderDatePicker = {
|
||||
obj: null,
|
||||
create: () => {
|
||||
orderDatePicker.obj = new ej.calendars.DatePicker({
|
||||
placeholder: 'Select Date',
|
||||
format: 'yyyy-MM-dd',
|
||||
value: state.deliveryDate ? new Date(state.deliveryDate) : null,
|
||||
change: (e) => {
|
||||
state.deliveryDate = e.value;
|
||||
}
|
||||
});
|
||||
orderDatePicker.obj.appendTo(deliveryDateRef.value);
|
||||
},
|
||||
refresh: () => {
|
||||
if (orderDatePicker.obj) {
|
||||
orderDatePicker.obj.value = state.deliveryDate ? new Date(state.deliveryDate) : null;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Vue.watch(
|
||||
() => state.deliveryDate,
|
||||
(newVal, oldVal) => {
|
||||
orderDatePicker.refresh();
|
||||
state.errors.deliveryDate = '';
|
||||
}
|
||||
);
|
||||
|
||||
const numberText = {
|
||||
obj: null,
|
||||
create: () => {
|
||||
numberText.obj = new ej.inputs.TextBox({
|
||||
placeholder: '[auto]',
|
||||
});
|
||||
numberText.obj.appendTo(numberRef.value);
|
||||
}
|
||||
};
|
||||
|
||||
const salesOrderListLookup = {
|
||||
obj: null,
|
||||
create: () => {
|
||||
if (state.salesOrderListLookupData && Array.isArray(state.salesOrderListLookupData)) {
|
||||
salesOrderListLookup.obj = new ej.dropdowns.DropDownList({
|
||||
dataSource: state.salesOrderListLookupData,
|
||||
fields: { value: 'id', text: 'number' },
|
||||
placeholder: 'Select Sales Order',
|
||||
filterBarPlaceholder: 'Search',
|
||||
sortOrder: 'Ascending',
|
||||
allowFiltering: true,
|
||||
filtering: (e) => {
|
||||
e.preventDefaultAction = true;
|
||||
let query = new ej.data.Query();
|
||||
if (e.text !== '') {
|
||||
query = query.where('number', 'startsWith', e.text, true);
|
||||
}
|
||||
e.updateData(state.salesOrderListLookupData, query);
|
||||
},
|
||||
change: (e) => {
|
||||
state.salesOrderId = e.value;
|
||||
}
|
||||
});
|
||||
salesOrderListLookup.obj.appendTo(salesOrderIdRef.value);
|
||||
}
|
||||
},
|
||||
|
||||
refresh: () => {
|
||||
if (salesOrderListLookup.obj) {
|
||||
salesOrderListLookup.obj.value = state.salesOrderId
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
Vue.watch(
|
||||
() => state.salesOrderId,
|
||||
(newVal, oldVal) => {
|
||||
salesOrderListLookup.refresh();
|
||||
state.errors.salesOrderId = '';
|
||||
}
|
||||
);
|
||||
|
||||
const statusListLookup = {
|
||||
obj: null,
|
||||
create: () => {
|
||||
if (state.statusListLookupData && Array.isArray(state.statusListLookupData)) {
|
||||
statusListLookup.obj = new ej.dropdowns.DropDownList({
|
||||
dataSource: state.statusListLookupData,
|
||||
fields: { value: 'id', text: 'name' },
|
||||
placeholder: 'Select Status',
|
||||
allowFiltering: false,
|
||||
change: (e) => {
|
||||
state.status = e.value;
|
||||
}
|
||||
});
|
||||
statusListLookup.obj.appendTo(statusRef.value);
|
||||
}
|
||||
},
|
||||
|
||||
refresh: () => {
|
||||
if (statusListLookup.obj) {
|
||||
statusListLookup.obj.value = state.status
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
Vue.watch(
|
||||
() => state.status,
|
||||
(newVal, oldVal) => {
|
||||
statusListLookup.refresh();
|
||||
state.errors.status = '';
|
||||
}
|
||||
);
|
||||
|
||||
const services = {
|
||||
getMainData: async () => {
|
||||
try {
|
||||
const response = await AxiosManager.get('/DeliveryOrder/GetDeliveryOrderList', {});
|
||||
return response;
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
},
|
||||
createMainData: async (deliveryDate, description, status, salesOrderId, createdById) => {
|
||||
try {
|
||||
const response = await AxiosManager.post('/DeliveryOrder/CreateDeliveryOrder', {
|
||||
deliveryDate, description, status, salesOrderId, createdById
|
||||
});
|
||||
return response;
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
},
|
||||
updateMainData: async (id, deliveryDate, description, status, salesOrderId, updatedById) => {
|
||||
try {
|
||||
const response = await AxiosManager.post('/DeliveryOrder/UpdateDeliveryOrder', {
|
||||
id, deliveryDate, description, status, salesOrderId, updatedById
|
||||
});
|
||||
return response;
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
},
|
||||
deleteMainData: async (id, deletedById) => {
|
||||
try {
|
||||
const response = await AxiosManager.post('/DeliveryOrder/DeleteDeliveryOrder', {
|
||||
id, deletedById
|
||||
});
|
||||
return response;
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
},
|
||||
getSalesOrderListLookupData: async () => {
|
||||
try {
|
||||
const response = await AxiosManager.get('/SalesOrder/GetSalesOrderList', {});
|
||||
return response;
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
},
|
||||
getDeliveryOrderStatusListLookupData: async () => {
|
||||
try {
|
||||
const response = await AxiosManager.get('/DeliveryOrder/GetDeliveryOrderStatusList', {});
|
||||
return response;
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
},
|
||||
getSecondaryData: async (moduleId) => {
|
||||
try {
|
||||
const response = await AxiosManager.get('/InventoryTransaction/DeliveryOrderGetInvenTransList?moduleId=' + moduleId, {});
|
||||
return response;
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
},
|
||||
createSecondaryData: async (moduleId, warehouseId, productId, movement, createdById) => {
|
||||
try {
|
||||
const response = await AxiosManager.post('/InventoryTransaction/DeliveryOrderCreateInvenTrans', {
|
||||
moduleId, warehouseId, productId, movement, createdById
|
||||
});
|
||||
return response;
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
},
|
||||
updateSecondaryData: async (id, warehouseId, productId, movement, updatedById) => {
|
||||
try {
|
||||
const response = await AxiosManager.post('/InventoryTransaction/DeliveryOrderUpdateInvenTrans', {
|
||||
id, warehouseId, productId, movement, updatedById
|
||||
});
|
||||
return response;
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
},
|
||||
deleteSecondaryData: async (id, deletedById) => {
|
||||
try {
|
||||
const response = await AxiosManager.post('/InventoryTransaction/DeliveryOrderDeleteInvenTrans', {
|
||||
id, deletedById
|
||||
});
|
||||
return response;
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
},
|
||||
getProductListLookupData: async () => {
|
||||
try {
|
||||
const response = await AxiosManager.get('/Product/GetProductList', {});
|
||||
return response;
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
},
|
||||
getWarehouseListLookupData: async () => {
|
||||
try {
|
||||
const response = await AxiosManager.get('/Warehouse/GetWarehouseList', {});
|
||||
return response;
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
const methods = {
|
||||
populateMainData: async () => {
|
||||
const response = await services.getMainData();
|
||||
state.mainData = response?.data?.content?.data.map(item => ({
|
||||
...item,
|
||||
deliveryDate: new Date(item.deliveryDate),
|
||||
createdAtUtc: new Date(item.createdAtUtc)
|
||||
}));
|
||||
},
|
||||
populateSalesOrderListLookupData: async () => {
|
||||
const response = await services.getSalesOrderListLookupData();
|
||||
state.salesOrderListLookupData = response?.data?.content?.data;
|
||||
},
|
||||
populateDeliveryOrderStatusListLookupData: async () => {
|
||||
const response = await services.getDeliveryOrderStatusListLookupData();
|
||||
state.statusListLookupData = response?.data?.content?.data;
|
||||
},
|
||||
populateProductListLookupData: async () => {
|
||||
const response = await services.getProductListLookupData();
|
||||
state.productListLookupData = response?.data?.content?.data
|
||||
.filter(product => product.physical === true)
|
||||
.map(product => ({
|
||||
...product,
|
||||
numberName: `${product.number} - ${product.name}`
|
||||
})) || [];
|
||||
},
|
||||
populateWarehouseListLookupData: async () => {
|
||||
const response = await services.getWarehouseListLookupData();
|
||||
state.warehouseListLookupData = response?.data?.content?.data.filter(warehouse => warehouse.systemWarehouse === false) || [];
|
||||
},
|
||||
populateSecondaryData: async (deliveryOrderId) => {
|
||||
try {
|
||||
const response = await services.getSecondaryData(deliveryOrderId);
|
||||
state.secondaryData = response?.data?.content?.data.map(item => ({
|
||||
...item,
|
||||
createdAtUtc: new Date(item.createdAtUtc)
|
||||
}));
|
||||
methods.refreshSummary();
|
||||
} catch (error) {
|
||||
state.secondaryData = [];
|
||||
}
|
||||
},
|
||||
refreshSummary: () => {
|
||||
const totalMovement = state.secondaryData.reduce((sum, record) => sum + (record.movement ?? 0), 0);
|
||||
state.totalMovementFormatted = NumberFormatManager.formatToLocale(totalMovement);
|
||||
},
|
||||
onMainModalHidden: () => {
|
||||
state.errors.deliveryDate = '';
|
||||
state.errors.salesOrderId = '';
|
||||
state.errors.status = '';
|
||||
}
|
||||
};
|
||||
|
||||
const handler = {
|
||||
handleSubmit: async function () {
|
||||
try {
|
||||
state.isSubmitting = true;
|
||||
await new Promise(resolve => setTimeout(resolve, 300));
|
||||
|
||||
if (!validateForm()) {
|
||||
return;
|
||||
}
|
||||
|
||||
const response = state.id === ''
|
||||
? await services.createMainData(state.deliveryDate, state.description, state.status, state.salesOrderId, StorageManager.getUserId())
|
||||
: state.deleteMode
|
||||
? await services.deleteMainData(state.id, StorageManager.getUserId())
|
||||
: await services.updateMainData(state.id, state.deliveryDate, state.description, state.status, state.salesOrderId, StorageManager.getUserId());
|
||||
|
||||
if (response.data.code === 200) {
|
||||
await methods.populateMainData();
|
||||
mainGrid.refresh();
|
||||
|
||||
if (!state.deleteMode) {
|
||||
state.mainTitle = 'Edit Delivery Order';
|
||||
state.id = response?.data?.content?.data.id ?? '';
|
||||
state.number = response?.data?.content?.data.number ?? '';
|
||||
await methods.populateSecondaryData(state.id);
|
||||
secondaryGrid.refresh();
|
||||
state.showComplexDiv = true;
|
||||
|
||||
Swal.fire({
|
||||
icon: 'success',
|
||||
title: 'Save Successful',
|
||||
timer: 2000,
|
||||
showConfirmButton: false
|
||||
});
|
||||
|
||||
} else {
|
||||
Swal.fire({
|
||||
icon: 'success',
|
||||
title: 'Delete Successful',
|
||||
text: 'Form will be closed...',
|
||||
timer: 2000,
|
||||
showConfirmButton: false
|
||||
});
|
||||
setTimeout(() => {
|
||||
mainModal.obj.hide();
|
||||
resetFormState();
|
||||
}, 2000);
|
||||
}
|
||||
|
||||
} else {
|
||||
Swal.fire({
|
||||
icon: 'error',
|
||||
title: state.deleteMode ? 'Delete Failed' : 'Save Failed',
|
||||
text: response.data.message ?? 'Please check your data.',
|
||||
confirmButtonText: 'Try Again'
|
||||
});
|
||||
}
|
||||
|
||||
} catch (error) {
|
||||
Swal.fire({
|
||||
icon: 'error',
|
||||
title: 'An Error Occurred',
|
||||
text: error.response?.data?.message ?? 'Please try again.',
|
||||
confirmButtonText: 'OK'
|
||||
});
|
||||
} finally {
|
||||
state.isSubmitting = false;
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
Vue.onMounted(async () => {
|
||||
try {
|
||||
await SecurityManager.authorizePage(['DeliveryOrders']);
|
||||
await SecurityManager.validateToken();
|
||||
|
||||
await methods.populateMainData();
|
||||
await mainGrid.create(state.mainData);
|
||||
|
||||
mainModal.create();
|
||||
mainModalRef.value?.addEventListener('hidden.bs.modal', methods.onMainModalHidden());
|
||||
await methods.populateSalesOrderListLookupData();
|
||||
await methods.populateDeliveryOrderStatusListLookupData();
|
||||
numberText.create();
|
||||
orderDatePicker.create();
|
||||
salesOrderListLookup.create();
|
||||
statusListLookup.create();
|
||||
|
||||
await secondaryGrid.create(state.secondaryData);
|
||||
await methods.populateProductListLookupData();
|
||||
await methods.populateWarehouseListLookupData();
|
||||
|
||||
} catch (e) {
|
||||
console.error('page init error:', e);
|
||||
} finally {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
Vue.onUnmounted(() => {
|
||||
mainModalRef.value?.removeEventListener('hidden.bs.modal', methods.onMainModalHidden());
|
||||
});
|
||||
|
||||
const mainGrid = {
|
||||
obj: null,
|
||||
create: async (dataSource) => {
|
||||
mainGrid.obj = new ej.grids.Grid({
|
||||
height: '240px',
|
||||
dataSource: dataSource,
|
||||
allowFiltering: true,
|
||||
allowSorting: true,
|
||||
allowSelection: true,
|
||||
allowGrouping: true,
|
||||
allowTextWrap: true,
|
||||
allowResizing: true,
|
||||
allowPaging: true,
|
||||
allowExcelExport: true,
|
||||
filterSettings: { type: 'CheckBox' },
|
||||
sortSettings: { columns: [{ field: 'createdAtUtc', direction: 'Descending' }] },
|
||||
pageSettings: { currentPage: 1, pageSize: 50, pageSizes: ["10", "20", "50", "100", "200", "All"] },
|
||||
selectionSettings: { persistSelection: true, type: 'Single' },
|
||||
autoFit: true,
|
||||
showColumnMenu: true,
|
||||
gridLines: 'Horizontal',
|
||||
columns: [
|
||||
{ type: 'checkbox', width: 60 },
|
||||
{
|
||||
field: 'id', isPrimaryKey: true, headerText: 'Id', visible: false
|
||||
},
|
||||
{ field: 'number', headerText: 'Number', width: 150, minWidth: 150 },
|
||||
{ field: 'deliveryDate', headerText: 'Delivery Date', width: 150, format: 'yyyy-MM-dd' },
|
||||
{ field: 'salesOrderNumber', headerText: 'Sales Order', width: 150, minWidth: 150 },
|
||||
{ field: 'statusName', headerText: 'Status', width: 150, minWidth: 150 },
|
||||
{ field: 'createdAtUtc', headerText: 'Created At UTC', width: 150, format: 'yyyy-MM-dd HH:mm' }
|
||||
],
|
||||
toolbar: [
|
||||
'ExcelExport', 'Search',
|
||||
{ type: 'Separator' },
|
||||
{ text: 'Add', tooltipText: 'Add', prefixIcon: 'e-add', id: 'AddCustom' },
|
||||
{ text: 'Edit', tooltipText: 'Edit', prefixIcon: 'e-edit', id: 'EditCustom' },
|
||||
{ text: 'Delete', tooltipText: 'Delete', prefixIcon: 'e-delete', id: 'DeleteCustom' },
|
||||
{ type: 'Separator' },
|
||||
{ text: 'Print PDF', tooltipText: 'Print PDF', id: 'PrintPDFCustom' },
|
||||
],
|
||||
beforeDataBound: () => { },
|
||||
dataBound: function () {
|
||||
mainGrid.obj.toolbarModule.enableItems(['EditCustom', 'DeleteCustom', 'PrintPDFCustom'], false);
|
||||
mainGrid.obj.autoFitColumns(['number', 'deliveryDate', 'salesOrderNumber', 'statusName', 'createdAtUtc']);
|
||||
},
|
||||
excelExportComplete: () => { },
|
||||
rowSelected: () => {
|
||||
if (mainGrid.obj.getSelectedRecords().length == 1) {
|
||||
mainGrid.obj.toolbarModule.enableItems(['EditCustom', 'DeleteCustom', 'PrintPDFCustom'], true);
|
||||
} else {
|
||||
mainGrid.obj.toolbarModule.enableItems(['EditCustom', 'DeleteCustom', 'PrintPDFCustom'], false);
|
||||
}
|
||||
},
|
||||
rowDeselected: () => {
|
||||
if (mainGrid.obj.getSelectedRecords().length == 1) {
|
||||
mainGrid.obj.toolbarModule.enableItems(['EditCustom', 'DeleteCustom', 'PrintPDFCustom'], true);
|
||||
} else {
|
||||
mainGrid.obj.toolbarModule.enableItems(['EditCustom', 'DeleteCustom', 'PrintPDFCustom'], false);
|
||||
}
|
||||
},
|
||||
rowSelecting: () => {
|
||||
if (mainGrid.obj.getSelectedRecords().length) {
|
||||
mainGrid.obj.clearSelection();
|
||||
}
|
||||
},
|
||||
toolbarClick: async (args) => {
|
||||
if (args.item.id === 'MainGrid_excelexport') {
|
||||
mainGrid.obj.excelExport();
|
||||
}
|
||||
|
||||
if (args.item.id === 'AddCustom') {
|
||||
state.deleteMode = false;
|
||||
state.mainTitle = 'Add Delivery Order';
|
||||
resetFormState();
|
||||
state.showComplexDiv = false;
|
||||
mainModal.obj.show();
|
||||
}
|
||||
|
||||
if (args.item.id === 'EditCustom') {
|
||||
state.deleteMode = false;
|
||||
if (mainGrid.obj.getSelectedRecords().length) {
|
||||
const selectedRecord = mainGrid.obj.getSelectedRecords()[0];
|
||||
state.mainTitle = 'Edit Delivery Order';
|
||||
state.id = selectedRecord.id ?? '';
|
||||
state.number = selectedRecord.number ?? '';
|
||||
state.deliveryDate = selectedRecord.deliveryDate ? new Date(selectedRecord.deliveryDate) : null;
|
||||
state.description = selectedRecord.description ?? '';
|
||||
state.salesOrderId = selectedRecord.salesOrderId ?? '';
|
||||
state.status = String(selectedRecord.status ?? '');
|
||||
await methods.populateSecondaryData(selectedRecord.id);
|
||||
secondaryGrid.refresh();
|
||||
state.showComplexDiv = true;
|
||||
mainModal.obj.show();
|
||||
}
|
||||
}
|
||||
|
||||
if (args.item.id === 'DeleteCustom') {
|
||||
state.deleteMode = true;
|
||||
if (mainGrid.obj.getSelectedRecords().length) {
|
||||
const selectedRecord = mainGrid.obj.getSelectedRecords()[0];
|
||||
state.mainTitle = 'Delete Delivery Order?';
|
||||
state.id = selectedRecord.id ?? '';
|
||||
state.number = selectedRecord.number ?? '';
|
||||
state.deliveryDate = selectedRecord.deliveryDate ? new Date(selectedRecord.deliveryDate) : null;
|
||||
state.description = selectedRecord.description ?? '';
|
||||
state.salesOrderId = selectedRecord.salesOrderId ?? '';
|
||||
state.status = String(selectedRecord.status ?? '');
|
||||
await methods.populateSecondaryData(selectedRecord.id);
|
||||
secondaryGrid.refresh();
|
||||
state.showComplexDiv = false;
|
||||
mainModal.obj.show();
|
||||
}
|
||||
}
|
||||
|
||||
if (args.item.id === 'PrintPDFCustom') {
|
||||
if (mainGrid.obj.getSelectedRecords().length) {
|
||||
const selectedRecord = mainGrid.obj.getSelectedRecords()[0];
|
||||
window.open('/DeliveryOrders/DeliveryOrderPdf?id=' + (selectedRecord.id ?? ''), '_blank');
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
mainGrid.obj.appendTo(mainGridRef.value);
|
||||
},
|
||||
refresh: () => {
|
||||
mainGrid.obj.setProperties({ dataSource: state.mainData });
|
||||
}
|
||||
};
|
||||
|
||||
const secondaryGrid = {
|
||||
obj: null,
|
||||
create: async (dataSource) => {
|
||||
secondaryGrid.obj = new ej.grids.Grid({
|
||||
height: 400,
|
||||
dataSource: dataSource,
|
||||
editSettings: { allowEditing: true, allowAdding: true, allowDeleting: true, showDeleteConfirmDialog: true, mode: 'Normal', allowEditOnDblClick: true },
|
||||
allowFiltering: false,
|
||||
allowSorting: true,
|
||||
allowSelection: true,
|
||||
allowGrouping: false,
|
||||
allowTextWrap: true,
|
||||
allowResizing: true,
|
||||
allowPaging: false,
|
||||
allowExcelExport: true,
|
||||
filterSettings: { type: 'CheckBox' },
|
||||
sortSettings: { columns: [{ field: 'warehouseName', direction: 'Descending' }] },
|
||||
pageSettings: { currentPage: 1, pageSize: 50, pageSizes: ["10", "20", "50", "100", "200", "All"] },
|
||||
selectionSettings: { persistSelection: true, type: 'Single' },
|
||||
autoFit: false,
|
||||
showColumnMenu: false,
|
||||
gridLines: 'Horizontal',
|
||||
columns: [
|
||||
{ type: 'checkbox', width: 60 },
|
||||
{
|
||||
field: 'id', isPrimaryKey: true, headerText: 'Id', visible: false
|
||||
},
|
||||
{
|
||||
field: 'warehouseId',
|
||||
headerText: 'Warehouse',
|
||||
width: 250,
|
||||
validationRules: { required: true },
|
||||
disableHtmlEncode: false,
|
||||
valueAccessor: (field, data, column) => {
|
||||
const warehouse = state.warehouseListLookupData.find(item => item.id === data[field]);
|
||||
return warehouse ? `${warehouse.name}` : '';
|
||||
},
|
||||
editType: 'dropdownedit',
|
||||
edit: {
|
||||
create: () => {
|
||||
const warehouseElem = document.createElement('input');
|
||||
return warehouseElem;
|
||||
},
|
||||
read: () => {
|
||||
return warehouseObj.value;
|
||||
},
|
||||
destroy: function () {
|
||||
warehouseObj.destroy();
|
||||
},
|
||||
write: function (args) {
|
||||
warehouseObj = new ej.dropdowns.DropDownList({
|
||||
dataSource: state.warehouseListLookupData,
|
||||
fields: { value: 'id', text: 'name' },
|
||||
value: args.rowData.warehouseId,
|
||||
placeholder: 'Select a Warehouse',
|
||||
floatLabelType: 'Never'
|
||||
});
|
||||
warehouseObj.appendTo(args.element);
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
field: 'productId',
|
||||
headerText: 'Product',
|
||||
width: 250,
|
||||
validationRules: { required: true },
|
||||
disableHtmlEncode: false,
|
||||
valueAccessor: (field, data, column) => {
|
||||
const product = state.productListLookupData.find(item => item.id === data[field]);
|
||||
return product ? `${product.numberName}` : '';
|
||||
},
|
||||
editType: 'dropdownedit',
|
||||
edit: {
|
||||
create: () => {
|
||||
const productElem = document.createElement('input');
|
||||
return productElem;
|
||||
},
|
||||
read: () => {
|
||||
return productObj.value;
|
||||
},
|
||||
destroy: function () {
|
||||
productObj.destroy();
|
||||
},
|
||||
write: function (args) {
|
||||
productObj = new ej.dropdowns.DropDownList({
|
||||
dataSource: state.productListLookupData,
|
||||
fields: { value: 'id', text: 'numberName' },
|
||||
value: args.rowData.productId,
|
||||
change: function (e) {
|
||||
if (movementObj) {
|
||||
movementObj.value = 1;
|
||||
}
|
||||
},
|
||||
placeholder: 'Select a Product',
|
||||
floatLabelType: 'Never'
|
||||
});
|
||||
productObj.appendTo(args.element);
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
field: 'movement',
|
||||
headerText: 'Movement',
|
||||
width: 200,
|
||||
validationRules: {
|
||||
required: true,
|
||||
custom: [(args) => {
|
||||
return args['value'] > 0;
|
||||
}, 'Must be a positive number and not zero']
|
||||
},
|
||||
type: 'number', format: 'N2', textAlign: 'Right',
|
||||
edit: {
|
||||
create: () => {
|
||||
const movementElem = document.createElement('input');
|
||||
return movementElem;
|
||||
},
|
||||
read: () => {
|
||||
return movementObj.value;
|
||||
},
|
||||
destroy: function () {
|
||||
movementObj.destroy();
|
||||
},
|
||||
write: function (args) {
|
||||
movementObj = new ej.inputs.NumericTextBox({
|
||||
value: args.rowData.movement ?? 0,
|
||||
});
|
||||
movementObj.appendTo(args.element);
|
||||
}
|
||||
}
|
||||
},
|
||||
],
|
||||
toolbar: [
|
||||
'ExcelExport',
|
||||
{ type: 'Separator' },
|
||||
'Add', 'Edit', 'Delete', 'Update', 'Cancel',
|
||||
],
|
||||
beforeDataBound: () => { },
|
||||
dataBound: function () { },
|
||||
excelExportComplete: () => { },
|
||||
rowSelected: () => {
|
||||
if (secondaryGrid.obj.getSelectedRecords().length == 1) {
|
||||
secondaryGrid.obj.toolbarModule.enableItems(['Edit'], true);
|
||||
} else {
|
||||
secondaryGrid.obj.toolbarModule.enableItems(['Edit'], false);
|
||||
}
|
||||
},
|
||||
rowDeselected: () => {
|
||||
if (secondaryGrid.obj.getSelectedRecords().length == 1) {
|
||||
secondaryGrid.obj.toolbarModule.enableItems(['Edit'], true);
|
||||
} else {
|
||||
secondaryGrid.obj.toolbarModule.enableItems(['Edit'], false);
|
||||
}
|
||||
},
|
||||
rowSelecting: () => {
|
||||
if (secondaryGrid.obj.getSelectedRecords().length) {
|
||||
secondaryGrid.obj.clearSelection();
|
||||
}
|
||||
},
|
||||
toolbarClick: (args) => {
|
||||
if (args.item.id === 'SecondaryGrid_excelexport') {
|
||||
secondaryGrid.obj.excelExport();
|
||||
}
|
||||
},
|
||||
actionComplete: async (args) => {
|
||||
if (args.requestType === 'save' && args.action === 'add') {
|
||||
try {
|
||||
const response = await services.createSecondaryData(state.id, args.data.warehouseId, args.data.productId, args.data.movement, StorageManager.getUserId());
|
||||
await methods.populateSecondaryData(state.id);
|
||||
secondaryGrid.refresh();
|
||||
if (response.data.code === 200) {
|
||||
Swal.fire({
|
||||
icon: 'success',
|
||||
title: 'Save Successful',
|
||||
timer: 2000,
|
||||
showConfirmButton: false
|
||||
});
|
||||
} else {
|
||||
Swal.fire({
|
||||
icon: 'error',
|
||||
title: 'Save Failed',
|
||||
text: response.data.message ?? 'Please check your data.',
|
||||
confirmButtonText: 'Try Again'
|
||||
});
|
||||
}
|
||||
} catch (error) {
|
||||
Swal.fire({
|
||||
icon: 'error',
|
||||
title: 'An Error Occurred',
|
||||
text: error.response?.data?.message ?? 'Please try again.',
|
||||
confirmButtonText: 'OK'
|
||||
});
|
||||
}
|
||||
}
|
||||
if (args.requestType === 'save' && args.action === 'edit') {
|
||||
try {
|
||||
const response = await services.updateSecondaryData(args.data.id, args.data.warehouseId, args.data.productId, args.data.movement, StorageManager.getUserId());
|
||||
await methods.populateSecondaryData(state.id);
|
||||
secondaryGrid.refresh();
|
||||
if (response.data.code === 200) {
|
||||
Swal.fire({
|
||||
icon: 'success',
|
||||
title: 'Update Successful',
|
||||
timer: 2000,
|
||||
showConfirmButton: false
|
||||
});
|
||||
} else {
|
||||
Swal.fire({
|
||||
icon: 'error',
|
||||
title: 'Update Failed',
|
||||
text: response.data.message ?? 'Please check your data.',
|
||||
confirmButtonText: 'Try Again'
|
||||
});
|
||||
}
|
||||
} catch (error) {
|
||||
Swal.fire({
|
||||
icon: 'error',
|
||||
title: 'An Error Occurred',
|
||||
text: error.response?.data?.message ?? 'Please try again.',
|
||||
confirmButtonText: 'OK'
|
||||
});
|
||||
}
|
||||
}
|
||||
if (args.requestType === 'delete') {
|
||||
try {
|
||||
const response = await services.deleteSecondaryData(args.data[0].id, StorageManager.getUserId());
|
||||
await methods.populateSecondaryData(state.id);
|
||||
secondaryGrid.refresh();
|
||||
if (response.data.code === 200) {
|
||||
Swal.fire({
|
||||
icon: 'success',
|
||||
title: 'Delete Successful',
|
||||
timer: 2000,
|
||||
showConfirmButton: false
|
||||
});
|
||||
} else {
|
||||
Swal.fire({
|
||||
icon: 'error',
|
||||
title: 'Delete Failed',
|
||||
text: response.data.message ?? 'Please check your data.',
|
||||
confirmButtonText: 'Try Again'
|
||||
});
|
||||
}
|
||||
} catch (error) {
|
||||
Swal.fire({
|
||||
icon: 'error',
|
||||
title: 'An Error Occurred',
|
||||
text: error.response?.data?.message ?? 'Please try again.',
|
||||
confirmButtonText: 'OK'
|
||||
});
|
||||
}
|
||||
}
|
||||
methods.refreshSummary();
|
||||
}
|
||||
});
|
||||
secondaryGrid.obj.appendTo(secondaryGridRef.value);
|
||||
|
||||
},
|
||||
refresh: () => {
|
||||
secondaryGrid.obj.setProperties({ dataSource: state.secondaryData });
|
||||
}
|
||||
};
|
||||
|
||||
const mainModal = {
|
||||
obj: null,
|
||||
create: () => {
|
||||
mainModal.obj = new bootstrap.Modal(mainModalRef.value, {
|
||||
backdrop: 'static',
|
||||
keyboard: false
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
return {
|
||||
mainGridRef,
|
||||
mainModalRef,
|
||||
secondaryGridRef,
|
||||
numberRef,
|
||||
deliveryDateRef,
|
||||
salesOrderIdRef,
|
||||
statusRef,
|
||||
state,
|
||||
handler,
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
Vue.createApp(App).mount('#app');
|
||||
@@ -0,0 +1,234 @@
|
||||
@page
|
||||
@attribute [Authorize(Roles = "DeliveryOrders")]
|
||||
@{
|
||||
ViewData["Title"] = "Delivery Order PDF";
|
||||
}
|
||||
|
||||
<div id="app" class="row">
|
||||
<div class="col-12">
|
||||
<div class="print-indicator" v-cloak>
|
||||
<div class="content-wrapper">
|
||||
<div>
|
||||
<button id="download-pdf" class="btn btn-danger d-flex align-items-center" v-on:click="handler.downloadPDF" v-bind:disabled="state.isDownloading">
|
||||
<span class="spinner-border spinner-border-sm me-2" role="status" aria-hidden="true" v-if="state.isDownloading"></span>
|
||||
<span class="button-text" v-if="!state.isDownloading">
|
||||
<i class="bi bi-file-earmark-pdf-fill me-2"></i> Download PDF
|
||||
</span>
|
||||
</button>
|
||||
</div>
|
||||
<div id="content" class="print-area">
|
||||
<div class="company-info">
|
||||
<h2>{{ state.company.name }}</h2>
|
||||
<p>{{ state.companyAddress }}</p>
|
||||
<p>Email: {{ state.company.emailAddress }} | Phone: {{ state.company.phoneNumber }}</p>
|
||||
</div>
|
||||
|
||||
<h1>Delivery Order</h1>
|
||||
|
||||
<div class="info-container">
|
||||
<table class="details-table">
|
||||
<tr>
|
||||
<th colspan="2">Customer Information</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>Name:</strong></td>
|
||||
<td>{{ state.customer.name }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>Address:</strong></td>
|
||||
<td>{{ state.customerAddress }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>Email:</strong></td>
|
||||
<td>{{ state.customer.emailAddress }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>Phone:</strong></td>
|
||||
<td>{{ state.customer.phoneNumber }}</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<table class="details-table">
|
||||
<tr>
|
||||
<th colspan="2">Delivery Information</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>Number:</strong></td>
|
||||
<td>{{ state.number }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>Date:</strong></td>
|
||||
<td>{{ state.deliveryDate }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>Reference:</strong></td>
|
||||
<td>{{ state.referenceNumber }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>_</strong></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<table class="product-table" border="1" style="width: 100%; border-collapse: collapse;">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Warehouse</th>
|
||||
<th>Product</th>
|
||||
<th>Movement</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-for="item in state.mappedItems" :key="item.product + item.warehouse">
|
||||
<td>{{ item.warehouse }}</td>
|
||||
<td>{{ item.product }}</td>
|
||||
<td>{{ item.movement }}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<div class="summary">
|
||||
<div class="column"></div>
|
||||
<div class="column">
|
||||
<table style="width: 100%; border-collapse: collapse; margin-top: 20px;">
|
||||
<tr>
|
||||
<td style="font-weight: bold; font-size: 1.2em;">Total Movement:</td>
|
||||
<td style="text-align: right; font-weight: bold; font-size: 1.2em; color: #2c3e50;">
|
||||
{{ state.movementTotal }}
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- CSS -->
|
||||
<style>
|
||||
.print-indicator {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: flex-start;
|
||||
height: 100vh;
|
||||
background-color: #f8f9fa;
|
||||
position: relative;
|
||||
overflow-y: auto;
|
||||
padding: 30px;
|
||||
}
|
||||
|
||||
|
||||
.content-wrapper {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
gap: 20px;
|
||||
}
|
||||
|
||||
.print-area {
|
||||
width: 210mm;
|
||||
padding: 10mm;
|
||||
background-color: white;
|
||||
border: 1px dashed #cccccc;
|
||||
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
|
||||
#download-pdf {
|
||||
padding: 10px 20px;
|
||||
font-size: 16px;
|
||||
border-radius: 5px;
|
||||
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
|
||||
}
|
||||
|
||||
.company-info {
|
||||
text-align: center;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.company-info h2 {
|
||||
font-size: 24px;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.company-info p {
|
||||
margin: 5px 0;
|
||||
font-size: 14px;
|
||||
color: #555;
|
||||
}
|
||||
|
||||
h1 {
|
||||
text-align: center;
|
||||
margin-bottom: 20px;
|
||||
font-size: 28px;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.info-container {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
margin-bottom: 20px;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.details-table {
|
||||
flex: 1;
|
||||
padding: 5px 8px;
|
||||
border: 1px solid #ccc;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.details-table th, .details-table td {
|
||||
padding: 5px 10px;
|
||||
border: 1px solid #ccc;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
|
||||
.details-table th {
|
||||
background-color: #f2f2f2;
|
||||
text-align: left;
|
||||
height: 35px;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
|
||||
|
||||
.product-table {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
margin-bottom: 20px;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.product-table th, .product-table td {
|
||||
padding: 8px;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.product-table th {
|
||||
background-color: #f2f2f2;
|
||||
}
|
||||
|
||||
.summary {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
margin-top: 20px;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.summary .column {
|
||||
width: 48%;
|
||||
}
|
||||
|
||||
.summary p {
|
||||
margin: 5px 0;
|
||||
text-align: right;
|
||||
}
|
||||
</style>
|
||||
|
||||
@section scripts {
|
||||
<script src="~/FrontEnd/Pages/DeliveryOrders/DeliveryOrderPdf.cshtml.js"></script>
|
||||
}
|
||||
+151
@@ -0,0 +1,151 @@
|
||||
const App = {
|
||||
setup() {
|
||||
const state = Vue.reactive({
|
||||
number: '',
|
||||
deliveryDate: new Date(),
|
||||
referenceNumber: '',
|
||||
pdfTransactionList: [],
|
||||
company: {
|
||||
name: '',
|
||||
emailAddress: '',
|
||||
phoneNumber: '',
|
||||
street: '',
|
||||
city: '',
|
||||
state: '',
|
||||
zipCode: '',
|
||||
country: ''
|
||||
},
|
||||
companyAddress: '',
|
||||
customer: {
|
||||
name: '',
|
||||
street: '',
|
||||
city: '',
|
||||
state: '',
|
||||
zipCode: '',
|
||||
country: '',
|
||||
emailAddress: '',
|
||||
phoneNumber: ''
|
||||
},
|
||||
customerAddress: '',
|
||||
isDownloading: false,
|
||||
mappedItems: [],
|
||||
movementTotal: 0
|
||||
});
|
||||
|
||||
const services = {
|
||||
getPDFData: async (id) => {
|
||||
try {
|
||||
const response = await AxiosManager.get('/DeliveryOrder/GetDeliveryOrderSingle?id=' + id, {});
|
||||
return response;
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
const methods = {
|
||||
populatePDFData: async (id) => {
|
||||
const response = await services.getPDFData(id);
|
||||
state.pdfData = response?.data?.content?.data || state.pdfData;
|
||||
state.pdfTransactionList = response?.data?.content?.transactionList || [];
|
||||
methods.bindPDFControls();
|
||||
},
|
||||
|
||||
bindPDFControls: () => {
|
||||
const company = StorageManager.getCompany() || state.company;
|
||||
state.company = {
|
||||
name: company.name,
|
||||
emailAddress: company.emailAddress,
|
||||
phoneNumber: company.phoneNumber,
|
||||
street: company.street,
|
||||
city: company.city,
|
||||
state: company.state,
|
||||
zipCode: company.zipCode,
|
||||
country: company.country
|
||||
};
|
||||
state.companyAddress = [
|
||||
company.street,
|
||||
company.city,
|
||||
company.state,
|
||||
company.zipCode,
|
||||
company.country
|
||||
].filter(Boolean).join(', ');
|
||||
|
||||
const pdfData = state.pdfData;
|
||||
state.customer = pdfData.salesOrder?.customer;
|
||||
state.customerAddress = [
|
||||
state.customer.street,
|
||||
state.customer.city,
|
||||
state.customer.state,
|
||||
state.customer.zipCode,
|
||||
state.customer.country
|
||||
].filter(Boolean).join(', ');
|
||||
|
||||
state.number = pdfData?.number;
|
||||
state.deliveryDate = DateFormatManager.formatToLocale(state.deliveryDate);
|
||||
state.referenceNumber = pdfData?.salesOrder?.number;
|
||||
|
||||
state.mappedItems = (state.pdfTransactionList || []).map(item => ({
|
||||
warehouse: item.warehouse?.name || 'Unknown',
|
||||
product: `${item.product?.number || ''} ${item.product?.name || ''}`.trim() || 'Unknown Product',
|
||||
movement: item.movement || 0,
|
||||
}));
|
||||
|
||||
let movementTotal = (state.pdfTransactionList || []).reduce((sum, item) => sum + (item.movement || 0), 0);
|
||||
state.movementTotal = NumberFormatManager.formatToLocale(movementTotal);
|
||||
}
|
||||
};
|
||||
|
||||
const handler = {
|
||||
downloadPDF: async () => {
|
||||
state.isDownloading = true;
|
||||
await new Promise(resolve => setTimeout(resolve, 500));
|
||||
|
||||
try {
|
||||
const { jsPDF } = window.jspdf;
|
||||
const doc = new jsPDF('p', 'mm', 'a4');
|
||||
const content = document.getElementById('content');
|
||||
|
||||
await html2canvas(content, {
|
||||
scale: 2,
|
||||
useCORS: true
|
||||
}).then(canvas => {
|
||||
const imgData = canvas.toDataURL('image/png');
|
||||
const imgWidth = 210;
|
||||
const pageHeight = 297;
|
||||
const imgHeight = (canvas.height * imgWidth) / canvas.width;
|
||||
let position = 0;
|
||||
|
||||
doc.addImage(imgData, 'PNG', 0, position, imgWidth, imgHeight);
|
||||
doc.save(`delivery-order-${state.pdfData.number || 'unknown'}.pdf`);
|
||||
});
|
||||
} catch (error) {
|
||||
console.error('Error generating PDF:', error);
|
||||
} finally {
|
||||
state.isDownloading = false;
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
Vue.onMounted(async () => {
|
||||
try {
|
||||
await SecurityManager.authorizePage(['DeliveryOrders']);
|
||||
var urlParams = new URLSearchParams(window.location.search);
|
||||
var id = urlParams.get('id');
|
||||
await methods.populatePDFData(id ?? '');
|
||||
} catch (e) {
|
||||
console.error('page init error:', e);
|
||||
} finally {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
return {
|
||||
state,
|
||||
handler,
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
Vue.createApp(App).mount('#app');
|
||||
@@ -0,0 +1,128 @@
|
||||
@page
|
||||
@attribute [Authorize(Roles = "GoodsReceives")]
|
||||
@{
|
||||
ViewData["Title"] = "Goods Receive List";
|
||||
}
|
||||
|
||||
<div id="app" v-cloak>
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<div class="grid-container">
|
||||
<div ref="mainGridRef"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="modal fade" ref="mainModalRef" id="MainModal" aria-hidden="true" tabindex="-1" data-bs-focus="false" data-bs-backdrop="static">
|
||||
<div class="modal-dialog modal-dialog-centered modal-xl">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title">{{ state.mainTitle }}</h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<input type="hidden" v-model="state.id" id="Id" name="Id" />
|
||||
<form>
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<h5>Main Info</h5>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="row mb-2">
|
||||
<div class="col-md-6">
|
||||
<label for="ReceiveDate">Receive Date</label>
|
||||
<input ref="receiveDateRef">
|
||||
<label class="text-danger">{{ state.errors.receiveDate }}</label>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<label for="Number">Number</label>
|
||||
<input ref="numberRef" v-model="state.number" readonly>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mb-2">
|
||||
<div class="col-md-6">
|
||||
<label for="PurchaseOrderId">Purchase Order</label>
|
||||
<div ref="purchaseOrderIdRef"></div>
|
||||
<label class="text-danger">{{ state.errors.purchaseOrderId }}</label>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<label for="Status">Status</label>
|
||||
<div ref="statusRef"></div>
|
||||
<label class="text-danger">{{ state.errors.status }}</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mb-2">
|
||||
<div class="col-md-12">
|
||||
<label for="Description">Description</label>
|
||||
<textarea class="form-control" rows="3" v-model="state.description"></textarea>
|
||||
<label class="text-danger">{{ state.errors.description }}</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
<div id="ComplexDiv" :style="{ display: state.showComplexDiv ? 'block' : 'none' }">
|
||||
<div class="row mt-3">
|
||||
<div class="col-md-12">
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<h5>Receive Item</h5>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<div class="grid-container">
|
||||
<div ref="secondaryGridRef"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mt-4">
|
||||
<div class="col-md-12">
|
||||
<div class="card shadow-sm">
|
||||
<div class="card-header text-white">
|
||||
<h5 class="mb-0">Summary</h5>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="row justify-content-end">
|
||||
<div class="col-md-6">
|
||||
<div class="d-flex justify-content-between py-2">
|
||||
<span class="fw-bold">Total Movement</span>
|
||||
<span id="TotalMovement" class="fw-bold text-success">{{ state.totalMovementFormatted }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
|
||||
<button type="button"
|
||||
id="MainSaveButton"
|
||||
class="btn"
|
||||
v-bind:class="state.deleteMode ? 'btn-danger' : 'btn-primary'"
|
||||
v-on:click="handler.handleSubmit"
|
||||
v-bind:disabled="state.isSubmitting">
|
||||
<span class="spinner-border spinner-border-sm me-2" v-if="state.isSubmitting" role="status" aria-hidden="true"></span>
|
||||
<span v-if="!state.isSubmitting">{{ state.deleteMode ? 'Delete' : 'Save' }}</span>
|
||||
<span v-else>{{ state.deleteMode ? 'Deleting...' : 'Saving...' }}</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@section scripts {
|
||||
<script src="~/FrontEnd/Pages/GoodsReceives/GoodsReceiveList.cshtml.js"></script>
|
||||
}
|
||||
@@ -0,0 +1,871 @@
|
||||
const App = {
|
||||
setup() {
|
||||
const state = Vue.reactive({
|
||||
mainData: [],
|
||||
deleteMode: false,
|
||||
purchaseOrderListLookupData: [],
|
||||
goodsReceiveStatusListLookupData: [],
|
||||
secondaryData: [],
|
||||
productListLookupData: [],
|
||||
warehouseListLookupData: [],
|
||||
mainTitle: null,
|
||||
id: '',
|
||||
number: '',
|
||||
receiveDate: '',
|
||||
description: '',
|
||||
purchaseOrderId: null,
|
||||
status: null,
|
||||
errors: {
|
||||
receiveDate: '',
|
||||
purchaseOrderId: '',
|
||||
status: '',
|
||||
description: ''
|
||||
},
|
||||
showComplexDiv: false,
|
||||
isSubmitting: false,
|
||||
totalMovementFormatted: '0.00'
|
||||
});
|
||||
|
||||
const mainGridRef = Vue.ref(null);
|
||||
const mainModalRef = Vue.ref(null);
|
||||
const secondaryGridRef = Vue.ref(null);
|
||||
const receiveDateRef = Vue.ref(null);
|
||||
const purchaseOrderIdRef = Vue.ref(null);
|
||||
const statusRef = Vue.ref(null);
|
||||
const numberRef = Vue.ref(null);
|
||||
|
||||
const validateForm = function () {
|
||||
state.errors.receiveDate = '';
|
||||
state.errors.purchaseOrderId = '';
|
||||
state.errors.status = '';
|
||||
|
||||
let isValid = true;
|
||||
|
||||
if (!state.receiveDate) {
|
||||
state.errors.receiveDate = 'Receive date is required.';
|
||||
isValid = false;
|
||||
}
|
||||
if (!state.purchaseOrderId) {
|
||||
state.errors.purchaseOrderId = 'Purchase Order is required.';
|
||||
isValid = false;
|
||||
}
|
||||
if (!state.status) {
|
||||
state.errors.status = 'Status is required.';
|
||||
isValid = false;
|
||||
}
|
||||
|
||||
return isValid;
|
||||
};
|
||||
|
||||
const resetFormState = () => {
|
||||
state.id = '';
|
||||
state.number = '';
|
||||
state.receiveDate = '';
|
||||
state.description = '';
|
||||
state.purchaseOrderId = null;
|
||||
state.status = null;
|
||||
state.errors = {
|
||||
receiveDate: '',
|
||||
purchaseOrderId: '',
|
||||
status: '',
|
||||
description: ''
|
||||
};
|
||||
state.secondaryData = [];
|
||||
};
|
||||
|
||||
const receiveDatePicker = {
|
||||
obj: null,
|
||||
create: () => {
|
||||
receiveDatePicker.obj = new ej.calendars.DatePicker({
|
||||
placeholder: 'Select Date',
|
||||
format: 'yyyy-MM-dd',
|
||||
value: state.receiveDate ? new Date(state.receiveDate) : null,
|
||||
change: (e) => {
|
||||
state.receiveDate = e.value;
|
||||
}
|
||||
});
|
||||
receiveDatePicker.obj.appendTo(receiveDateRef.value);
|
||||
},
|
||||
refresh: () => {
|
||||
if (receiveDatePicker.obj) {
|
||||
receiveDatePicker.obj.value = state.receiveDate ? new Date(state.receiveDate) : null;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Vue.watch(
|
||||
() => state.receiveDate,
|
||||
(newVal, oldVal) => {
|
||||
receiveDatePicker.refresh();
|
||||
state.errors.receiveDate = '';
|
||||
}
|
||||
);
|
||||
|
||||
const numberText = {
|
||||
obj: null,
|
||||
create: () => {
|
||||
numberText.obj = new ej.inputs.TextBox({
|
||||
placeholder: '[auto]',
|
||||
});
|
||||
numberText.obj.appendTo(numberRef.value);
|
||||
}
|
||||
};
|
||||
|
||||
const purchaseOrderListLookup = {
|
||||
obj: null,
|
||||
create: () => {
|
||||
if (state.purchaseOrderListLookupData && Array.isArray(state.purchaseOrderListLookupData)) {
|
||||
purchaseOrderListLookup.obj = new ej.dropdowns.DropDownList({
|
||||
dataSource: state.purchaseOrderListLookupData,
|
||||
fields: { value: 'id', text: 'number' },
|
||||
placeholder: 'Select Purchase Order',
|
||||
filterBarPlaceholder: 'Search',
|
||||
sortOrder: 'Ascending',
|
||||
allowFiltering: true,
|
||||
filtering: (e) => {
|
||||
e.preventDefaultAction = true;
|
||||
let query = new ej.data.Query();
|
||||
if (e.text !== '') {
|
||||
query = query.where('number', 'startsWith', e.text, true);
|
||||
}
|
||||
e.updateData(state.purchaseOrderListLookupData, query);
|
||||
},
|
||||
change: (e) => {
|
||||
state.purchaseOrderId = e.value;
|
||||
}
|
||||
});
|
||||
purchaseOrderListLookup.obj.appendTo(purchaseOrderIdRef.value);
|
||||
}
|
||||
},
|
||||
refresh: () => {
|
||||
if (purchaseOrderListLookup.obj) {
|
||||
purchaseOrderListLookup.obj.value = state.purchaseOrderId
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
Vue.watch(
|
||||
() => state.purchaseOrderId,
|
||||
(newVal, oldVal) => {
|
||||
purchaseOrderListLookup.refresh();
|
||||
state.errors.purchaseOrderId = '';
|
||||
}
|
||||
);
|
||||
|
||||
const goodsReceiveStatusListLookup = {
|
||||
obj: null,
|
||||
create: () => {
|
||||
if (state.goodsReceiveStatusListLookupData && Array.isArray(state.goodsReceiveStatusListLookupData)) {
|
||||
goodsReceiveStatusListLookup.obj = new ej.dropdowns.DropDownList({
|
||||
dataSource: state.goodsReceiveStatusListLookupData,
|
||||
fields: { value: 'id', text: 'name' },
|
||||
placeholder: 'Select Status',
|
||||
allowFiltering: false,
|
||||
change: (e) => {
|
||||
state.status = e.value;
|
||||
}
|
||||
});
|
||||
goodsReceiveStatusListLookup.obj.appendTo(statusRef.value);
|
||||
}
|
||||
},
|
||||
refresh: () => {
|
||||
if (goodsReceiveStatusListLookup.obj) {
|
||||
goodsReceiveStatusListLookup.obj.value = state.status
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
Vue.watch(
|
||||
() => state.status,
|
||||
(newVal, oldVal) => {
|
||||
goodsReceiveStatusListLookup.refresh();
|
||||
state.errors.status = '';
|
||||
}
|
||||
);
|
||||
|
||||
const services = {
|
||||
getMainData: async () => {
|
||||
try {
|
||||
const response = await AxiosManager.get('/GoodsReceive/GetGoodsReceiveList', {});
|
||||
return response;
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
},
|
||||
createMainData: async (receiveDate, description, status, purchaseOrderId, createdById) => {
|
||||
try {
|
||||
const response = await AxiosManager.post('/GoodsReceive/CreateGoodsReceive', {
|
||||
receiveDate, description, status, purchaseOrderId, createdById
|
||||
});
|
||||
return response;
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
},
|
||||
updateMainData: async (id, receiveDate, description, status, purchaseOrderId, updatedById) => {
|
||||
try {
|
||||
const response = await AxiosManager.post('/GoodsReceive/UpdateGoodsReceive', {
|
||||
id, receiveDate, description, status, purchaseOrderId, updatedById
|
||||
});
|
||||
return response;
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
},
|
||||
deleteMainData: async (id, deletedById) => {
|
||||
try {
|
||||
const response = await AxiosManager.post('/GoodsReceive/DeleteGoodsReceive', {
|
||||
id, deletedById
|
||||
});
|
||||
return response;
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
},
|
||||
getPurchaseOrderListLookupData: async () => {
|
||||
try {
|
||||
const response = await AxiosManager.get('/PurchaseOrder/GetPurchaseOrderList', {});
|
||||
return response;
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
},
|
||||
getGoodsReceiveStatusListLookupData: async () => {
|
||||
try {
|
||||
const response = await AxiosManager.get('/GoodsReceive/GetGoodsReceiveStatusList', {});
|
||||
return response;
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
},
|
||||
getSecondaryData: async (moduleId) => {
|
||||
try {
|
||||
const response = await AxiosManager.get('/InventoryTransaction/GoodsReceiveGetInvenTransList?moduleId=' + moduleId, {});
|
||||
return response;
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
},
|
||||
createSecondaryData: async (moduleId, warehouseId, productId, movement, createdById) => {
|
||||
try {
|
||||
const response = await AxiosManager.post('/InventoryTransaction/GoodsReceiveCreateInvenTrans', {
|
||||
moduleId, warehouseId, productId, movement, createdById
|
||||
});
|
||||
return response;
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
},
|
||||
updateSecondaryData: async (id, warehouseId, productId, movement, updatedById) => {
|
||||
try {
|
||||
const response = await AxiosManager.post('/InventoryTransaction/GoodsReceiveUpdateInvenTrans', {
|
||||
id, warehouseId, productId, movement, updatedById
|
||||
});
|
||||
return response;
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
},
|
||||
deleteSecondaryData: async (id, deletedById) => {
|
||||
try {
|
||||
const response = await AxiosManager.post('/InventoryTransaction/GoodsReceiveDeleteInvenTrans', {
|
||||
id, deletedById
|
||||
});
|
||||
return response;
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
},
|
||||
getProductListLookupData: async () => {
|
||||
try {
|
||||
const response = await AxiosManager.get('/Product/GetProductList', {});
|
||||
return response;
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
},
|
||||
getWarehouseListLookupData: async () => {
|
||||
try {
|
||||
const response = await AxiosManager.get('/Warehouse/GetWarehouseList', {});
|
||||
return response;
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
const methods = {
|
||||
populateMainData: async () => {
|
||||
const response = await services.getMainData();
|
||||
state.mainData = response?.data?.content?.data.map(item => ({
|
||||
...item,
|
||||
receiveDate: new Date(item.receiveDate),
|
||||
createdAtUtc: new Date(item.createdAtUtc)
|
||||
}));
|
||||
},
|
||||
populatePurchaseOrderListLookupData: async () => {
|
||||
const response = await services.getPurchaseOrderListLookupData();
|
||||
state.purchaseOrderListLookupData = response?.data?.content?.data;
|
||||
},
|
||||
populateGoodsReceiveStatusListLookupData: async () => {
|
||||
const response = await services.getGoodsReceiveStatusListLookupData();
|
||||
state.goodsReceiveStatusListLookupData = response?.data?.content?.data;
|
||||
},
|
||||
populateProductListLookupData: async () => {
|
||||
const response = await services.getProductListLookupData();
|
||||
state.productListLookupData = response?.data?.content?.data
|
||||
.filter(product => product.physical === true)
|
||||
.map(product => ({
|
||||
...product,
|
||||
numberName: `${product.number} - ${product.name}`
|
||||
})) || [];
|
||||
},
|
||||
populateWarehouseListLookupData: async () => {
|
||||
const response = await services.getWarehouseListLookupData();
|
||||
state.warehouseListLookupData = response?.data?.content?.data.filter(warehouse => warehouse.systemWarehouse === false) || [];
|
||||
},
|
||||
populateSecondaryData: async (goodsReceiveId) => {
|
||||
try {
|
||||
const response = await services.getSecondaryData(goodsReceiveId);
|
||||
state.secondaryData = response?.data?.content?.data.map(item => ({
|
||||
...item,
|
||||
createdAtUtc: new Date(item.createdAtUtc)
|
||||
}));
|
||||
methods.refreshSummary();
|
||||
} catch (error) {
|
||||
state.secondaryData = [];
|
||||
}
|
||||
},
|
||||
refreshSummary: () => {
|
||||
const totalMovement = state.secondaryData.reduce((sum, record) => sum + (record.movement ?? 0), 0);
|
||||
state.totalMovementFormatted = NumberFormatManager.formatToLocale(totalMovement);
|
||||
},
|
||||
onMainModalHidden: () => {
|
||||
state.errors.receiveDate = '';
|
||||
state.errors.purchaseOrderId = '';
|
||||
state.errors.status = '';
|
||||
}
|
||||
};
|
||||
|
||||
const handler = {
|
||||
handleSubmit: async function () {
|
||||
try {
|
||||
state.isSubmitting = true;
|
||||
await new Promise(resolve => setTimeout(resolve, 300));
|
||||
|
||||
if (!validateForm()) {
|
||||
return;
|
||||
}
|
||||
|
||||
const response = state.id === ''
|
||||
? await services.createMainData(state.receiveDate, state.description, state.status, state.purchaseOrderId, StorageManager.getUserId())
|
||||
: state.deleteMode
|
||||
? await services.deleteMainData(state.id, StorageManager.getUserId())
|
||||
: await services.updateMainData(state.id, state.receiveDate, state.description, state.status, state.purchaseOrderId, StorageManager.getUserId());
|
||||
|
||||
if (response.data.code === 200) {
|
||||
await methods.populateMainData();
|
||||
mainGrid.refresh();
|
||||
|
||||
if (!state.deleteMode) {
|
||||
state.mainTitle = 'Edit Goods Receive';
|
||||
state.id = response?.data?.content?.data.id ?? '';
|
||||
state.number = response?.data?.content?.data.number ?? '';
|
||||
await methods.populateSecondaryData(state.id);
|
||||
secondaryGrid.refresh();
|
||||
state.showComplexDiv = true;
|
||||
|
||||
Swal.fire({
|
||||
icon: 'success',
|
||||
title: 'Save Successful',
|
||||
timer: 2000,
|
||||
showConfirmButton: false
|
||||
});
|
||||
|
||||
} else {
|
||||
Swal.fire({
|
||||
icon: 'success',
|
||||
title: 'Delete Successful',
|
||||
text: 'Form will be closed...',
|
||||
timer: 2000,
|
||||
showConfirmButton: false
|
||||
});
|
||||
setTimeout(() => {
|
||||
mainModal.obj.hide();
|
||||
resetFormState();
|
||||
}, 2000);
|
||||
}
|
||||
|
||||
} else {
|
||||
Swal.fire({
|
||||
icon: 'error',
|
||||
title: state.deleteMode ? 'Delete Failed' : 'Save Failed',
|
||||
text: response.data.message ?? 'Please check your data.',
|
||||
confirmButtonText: 'Try Again'
|
||||
});
|
||||
}
|
||||
|
||||
} catch (error) {
|
||||
Swal.fire({
|
||||
icon: 'error',
|
||||
title: 'An Error Occurred',
|
||||
text: error.response?.data?.message ?? 'Please try again.',
|
||||
confirmButtonText: 'OK'
|
||||
});
|
||||
} finally {
|
||||
state.isSubmitting = false;
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
Vue.onMounted(async () => {
|
||||
try {
|
||||
await SecurityManager.authorizePage(['GoodsReceives']);
|
||||
await SecurityManager.validateToken();
|
||||
|
||||
await methods.populateMainData();
|
||||
await mainGrid.create(state.mainData);
|
||||
|
||||
mainModal.create();
|
||||
mainModalRef.value?.addEventListener('hidden.bs.modal', methods.onMainModalHidden);
|
||||
await methods.populatePurchaseOrderListLookupData();
|
||||
await methods.populateGoodsReceiveStatusListLookupData();
|
||||
numberText.create();
|
||||
receiveDatePicker.create();
|
||||
purchaseOrderListLookup.create();
|
||||
goodsReceiveStatusListLookup.create();
|
||||
|
||||
await secondaryGrid.create(state.secondaryData);
|
||||
await methods.populateProductListLookupData();
|
||||
await methods.populateWarehouseListLookupData();
|
||||
|
||||
} catch (e) {
|
||||
console.error('page init error:', e);
|
||||
} finally {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
Vue.onUnmounted(() => {
|
||||
mainModalRef.value?.removeEventListener('hidden.bs.modal', methods.onMainModalHidden);
|
||||
});
|
||||
|
||||
const mainGrid = {
|
||||
obj: null,
|
||||
create: async (dataSource) => {
|
||||
mainGrid.obj = new ej.grids.Grid({
|
||||
height: '240px',
|
||||
dataSource: dataSource,
|
||||
allowFiltering: true,
|
||||
allowSorting: true,
|
||||
allowSelection: true,
|
||||
allowGrouping: true,
|
||||
allowTextWrap: true,
|
||||
allowResizing: true,
|
||||
allowPaging: true,
|
||||
allowExcelExport: true,
|
||||
filterSettings: { type: 'CheckBox' },
|
||||
sortSettings: { columns: [{ field: 'createdAtUtc', direction: 'Descending' }] },
|
||||
pageSettings: { currentPage: 1, pageSize: 50, pageSizes: ["10", "20", "50", "100", "200", "All"] },
|
||||
selectionSettings: { persistSelection: true, type: 'Single' },
|
||||
autoFit: true,
|
||||
showColumnMenu: true,
|
||||
gridLines: 'Horizontal',
|
||||
columns: [
|
||||
{ type: 'checkbox', width: 60 },
|
||||
{
|
||||
field: 'id', isPrimaryKey: true, headerText: 'Id', visible: false
|
||||
},
|
||||
{ field: 'number', headerText: 'Number', width: 150, minWidth: 150 },
|
||||
{ field: 'receiveDate', headerText: 'Receive Date', width: 150, format: 'yyyy-MM-dd' },
|
||||
{ field: 'purchaseOrderNumber', headerText: 'Purchase Order', width: 150, minWidth: 150 },
|
||||
{ field: 'statusName', headerText: 'Status', width: 150, minWidth: 150 },
|
||||
{ field: 'createdAtUtc', headerText: 'Created At UTC', width: 150, format: 'yyyy-MM-dd HH:mm' }
|
||||
],
|
||||
toolbar: [
|
||||
'ExcelExport', 'Search',
|
||||
{ type: 'Separator' },
|
||||
{ text: 'Add', tooltipText: 'Add', prefixIcon: 'e-add', id: 'AddCustom' },
|
||||
{ text: 'Edit', tooltipText: 'Edit', prefixIcon: 'e-edit', id: 'EditCustom' },
|
||||
{ text: 'Delete', tooltipText: 'Delete', prefixIcon: 'e-delete', id: 'DeleteCustom' },
|
||||
{ type: 'Separator' },
|
||||
{ text: 'Print PDF', tooltipText: 'Print PDF', id: 'PrintPDFCustom' },
|
||||
],
|
||||
beforeDataBound: () => { },
|
||||
dataBound: function () {
|
||||
mainGrid.obj.toolbarModule.enableItems(['EditCustom', 'DeleteCustom', 'PrintPDFCustom'], false);
|
||||
mainGrid.obj.autoFitColumns(['number', 'receiveDate', 'purchaseOrderNumber', 'statusName', 'createdAtUtc']);
|
||||
},
|
||||
excelExportComplete: () => { },
|
||||
rowSelected: () => {
|
||||
if (mainGrid.obj.getSelectedRecords().length == 1) {
|
||||
mainGrid.obj.toolbarModule.enableItems(['EditCustom', 'DeleteCustom', 'PrintPDFCustom'], true);
|
||||
} else {
|
||||
mainGrid.obj.toolbarModule.enableItems(['EditCustom', 'DeleteCustom', 'PrintPDFCustom'], false);
|
||||
}
|
||||
},
|
||||
rowDeselected: () => {
|
||||
if (mainGrid.obj.getSelectedRecords().length == 1) {
|
||||
mainGrid.obj.toolbarModule.enableItems(['EditCustom', 'DeleteCustom', 'PrintPDFCustom'], true);
|
||||
} else {
|
||||
mainGrid.obj.toolbarModule.enableItems(['EditCustom', 'DeleteCustom', 'PrintPDFCustom'], false);
|
||||
}
|
||||
},
|
||||
rowSelecting: () => {
|
||||
if (mainGrid.obj.getSelectedRecords().length) {
|
||||
mainGrid.obj.clearSelection();
|
||||
}
|
||||
},
|
||||
toolbarClick: async (args) => {
|
||||
if (args.item.id === 'MainGrid_excelexport') {
|
||||
mainGrid.obj.excelExport();
|
||||
}
|
||||
|
||||
if (args.item.id === 'AddCustom') {
|
||||
state.deleteMode = false;
|
||||
state.mainTitle = 'Add Goods Receive';
|
||||
resetFormState();
|
||||
state.showComplexDiv = false;
|
||||
mainModal.obj.show();
|
||||
}
|
||||
|
||||
if (args.item.id === 'EditCustom') {
|
||||
state.deleteMode = false;
|
||||
if (mainGrid.obj.getSelectedRecords().length) {
|
||||
const selectedRecord = mainGrid.obj.getSelectedRecords()[0];
|
||||
state.mainTitle = 'Edit Goods Receive';
|
||||
state.id = selectedRecord.id ?? '';
|
||||
state.number = selectedRecord.number ?? '';
|
||||
state.receiveDate = selectedRecord.receiveDate ? new Date(selectedRecord.receiveDate) : null;
|
||||
state.description = selectedRecord.description ?? '';
|
||||
state.purchaseOrderId = selectedRecord.purchaseOrderId ?? '';
|
||||
state.status = String(selectedRecord.status ?? '');
|
||||
await methods.populateSecondaryData(selectedRecord.id);
|
||||
secondaryGrid.refresh();
|
||||
state.showComplexDiv = true;
|
||||
mainModal.obj.show();
|
||||
}
|
||||
}
|
||||
|
||||
if (args.item.id === 'DeleteCustom') {
|
||||
state.deleteMode = true;
|
||||
if (mainGrid.obj.getSelectedRecords().length) {
|
||||
const selectedRecord = mainGrid.obj.getSelectedRecords()[0];
|
||||
state.mainTitle = 'Delete Goods Receive?';
|
||||
state.id = selectedRecord.id ?? '';
|
||||
state.number = selectedRecord.number ?? '';
|
||||
state.receiveDate = selectedRecord.receiveDate ? new Date(selectedRecord.receiveDate) : null;
|
||||
state.description = selectedRecord.description ?? '';
|
||||
state.purchaseOrderId = selectedRecord.purchaseOrderId ?? '';
|
||||
state.status = String(selectedRecord.status ?? '');
|
||||
await methods.populateSecondaryData(selectedRecord.id);
|
||||
secondaryGrid.refresh();
|
||||
state.showComplexDiv = false;
|
||||
mainModal.obj.show();
|
||||
}
|
||||
}
|
||||
|
||||
if (args.item.id === 'PrintPDFCustom') {
|
||||
if (mainGrid.obj.getSelectedRecords().length) {
|
||||
const selectedRecord = mainGrid.obj.getSelectedRecords()[0];
|
||||
window.open('/GoodsReceives/GoodsReceivePdf?id=' + (selectedRecord.id ?? ''), '_blank');
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
mainGrid.obj.appendTo(mainGridRef.value);
|
||||
},
|
||||
refresh: () => {
|
||||
mainGrid.obj.setProperties({ dataSource: state.mainData });
|
||||
}
|
||||
};
|
||||
|
||||
const secondaryGrid = {
|
||||
obj: null,
|
||||
create: async (dataSource) => {
|
||||
secondaryGrid.obj = new ej.grids.Grid({
|
||||
height: 400,
|
||||
dataSource: dataSource,
|
||||
editSettings: { allowEditing: true, allowAdding: true, allowDeleting: true, showDeleteConfirmDialog: true, mode: 'Normal', allowEditOnDblClick: true },
|
||||
allowFiltering: false,
|
||||
allowSorting: true,
|
||||
allowSelection: true,
|
||||
allowGrouping: false,
|
||||
allowTextWrap: true,
|
||||
allowResizing: true,
|
||||
allowPaging: false,
|
||||
allowExcelExport: true,
|
||||
filterSettings: { type: 'CheckBox' },
|
||||
sortSettings: { columns: [{ field: 'warehouseName', direction: 'Descending' }] },
|
||||
pageSettings: { currentPage: 1, pageSize: 50, pageSizes: ["10", "20", "50", "100", "200", "All"] },
|
||||
selectionSettings: { persistSelection: true, type: 'Single' },
|
||||
autoFit: false,
|
||||
showColumnMenu: false,
|
||||
gridLines: 'Horizontal',
|
||||
columns: [
|
||||
{ type: 'checkbox', width: 60 },
|
||||
{
|
||||
field: 'id', isPrimaryKey: true, headerText: 'Id', visible: false
|
||||
},
|
||||
{
|
||||
field: 'warehouseId',
|
||||
headerText: 'Warehouse',
|
||||
width: 250,
|
||||
validationRules: { required: true },
|
||||
disableHtmlEncode: false,
|
||||
valueAccessor: (field, data, column) => {
|
||||
const warehouse = state.warehouseListLookupData.find(item => item.id === data[field]);
|
||||
return warehouse ? `${warehouse.name}` : '';
|
||||
},
|
||||
editType: 'dropdownedit',
|
||||
edit: {
|
||||
create: () => {
|
||||
const warehouseElem = document.createElement('input');
|
||||
return warehouseElem;
|
||||
},
|
||||
read: () => {
|
||||
return warehouseObj.value;
|
||||
},
|
||||
destroy: function () {
|
||||
warehouseObj.destroy();
|
||||
},
|
||||
write: function (args) {
|
||||
warehouseObj = new ej.dropdowns.DropDownList({
|
||||
dataSource: state.warehouseListLookupData,
|
||||
fields: { value: 'id', text: 'name' },
|
||||
value: args.rowData.warehouseId,
|
||||
placeholder: 'Select a Warehouse',
|
||||
floatLabelType: 'Never'
|
||||
});
|
||||
warehouseObj.appendTo(args.element);
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
field: 'productId',
|
||||
headerText: 'Product',
|
||||
width: 250,
|
||||
validationRules: { required: true },
|
||||
disableHtmlEncode: false,
|
||||
valueAccessor: (field, data, column) => {
|
||||
const product = state.productListLookupData.find(item => item.id === data[field]);
|
||||
return product ? `${product.numberName}` : '';
|
||||
},
|
||||
editType: 'dropdownedit',
|
||||
edit: {
|
||||
create: () => {
|
||||
const productElem = document.createElement('input');
|
||||
return productElem;
|
||||
},
|
||||
read: () => {
|
||||
return productObj.value;
|
||||
},
|
||||
destroy: function () {
|
||||
productObj.destroy();
|
||||
},
|
||||
write: function (args) {
|
||||
productObj = new ej.dropdowns.DropDownList({
|
||||
dataSource: state.productListLookupData,
|
||||
fields: { value: 'id', text: 'numberName' },
|
||||
value: args.rowData.productId,
|
||||
change: function (e) {
|
||||
if (movementObj) {
|
||||
movementObj.value = 1;
|
||||
}
|
||||
},
|
||||
placeholder: 'Select a Product',
|
||||
floatLabelType: 'Never'
|
||||
});
|
||||
productObj.appendTo(args.element);
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
field: 'movement',
|
||||
headerText: 'Movement',
|
||||
width: 200,
|
||||
validationRules: {
|
||||
required: true,
|
||||
custom: [(args) => {
|
||||
return args['value'] > 0;
|
||||
}, 'Must be a positive number and not zero']
|
||||
},
|
||||
type: 'number',
|
||||
format: 'N2', textAlign: 'Right',
|
||||
edit: {
|
||||
create: () => {
|
||||
const movementElem = document.createElement('input');
|
||||
return movementElem;
|
||||
},
|
||||
read: () => {
|
||||
return movementObj.value;
|
||||
},
|
||||
destroy: function () {
|
||||
movementObj.destroy();
|
||||
},
|
||||
write: function (args) {
|
||||
movementObj = new ej.inputs.NumericTextBox({
|
||||
value: args.rowData.movement ?? 0,
|
||||
});
|
||||
movementObj.appendTo(args.element);
|
||||
}
|
||||
}
|
||||
},
|
||||
],
|
||||
toolbar: [
|
||||
'ExcelExport',
|
||||
{ type: 'Separator' },
|
||||
'Add', 'Edit', 'Delete', 'Update', 'Cancel',
|
||||
],
|
||||
beforeDataBound: () => { },
|
||||
dataBound: function () { },
|
||||
excelExportComplete: () => { },
|
||||
rowSelected: () => {
|
||||
if (secondaryGrid.obj.getSelectedRecords().length == 1) {
|
||||
secondaryGrid.obj.toolbarModule.enableItems(['Edit'], true);
|
||||
} else {
|
||||
secondaryGrid.obj.toolbarModule.enableItems(['Edit'], false);
|
||||
}
|
||||
},
|
||||
rowDeselected: () => {
|
||||
if (secondaryGrid.obj.getSelectedRecords().length == 1) {
|
||||
secondaryGrid.obj.toolbarModule.enableItems(['Edit'], true);
|
||||
} else {
|
||||
secondaryGrid.obj.toolbarModule.enableItems(['Edit'], false);
|
||||
}
|
||||
},
|
||||
rowSelecting: () => {
|
||||
if (secondaryGrid.obj.getSelectedRecords().length) {
|
||||
secondaryGrid.obj.clearSelection();
|
||||
}
|
||||
},
|
||||
toolbarClick: (args) => {
|
||||
if (args.item.id === 'SecondaryGrid_excelexport') {
|
||||
secondaryGrid.obj.excelExport();
|
||||
}
|
||||
},
|
||||
actionComplete: async (args) => {
|
||||
if (args.requestType === 'save' && args.action === 'add') {
|
||||
try {
|
||||
const response = await services.createSecondaryData(state.id, args.data.warehouseId, args.data.productId, args.data.movement, StorageManager.getUserId());
|
||||
await methods.populateSecondaryData(state.id);
|
||||
secondaryGrid.refresh();
|
||||
if (response.data.code === 200) {
|
||||
Swal.fire({
|
||||
icon: 'success',
|
||||
title: 'Save Successful',
|
||||
timer: 2000,
|
||||
showConfirmButton: false
|
||||
});
|
||||
} else {
|
||||
Swal.fire({
|
||||
icon: 'error',
|
||||
title: 'Save Failed',
|
||||
text: response.data.message ?? 'Please check your data.',
|
||||
confirmButtonText: 'Try Again'
|
||||
});
|
||||
}
|
||||
} catch (error) {
|
||||
Swal.fire({
|
||||
icon: 'error',
|
||||
title: 'An Error Occurred',
|
||||
text: error.response?.data?.message ?? 'Please try again.',
|
||||
confirmButtonText: 'OK'
|
||||
});
|
||||
}
|
||||
}
|
||||
if (args.requestType === 'save' && args.action === 'edit') {
|
||||
try {
|
||||
const response = await services.updateSecondaryData(args.data.id, args.data.warehouseId, args.data.productId, args.data.movement, StorageManager.getUserId());
|
||||
await methods.populateSecondaryData(state.id);
|
||||
secondaryGrid.refresh();
|
||||
if (response.data.code === 200) {
|
||||
Swal.fire({
|
||||
icon: 'success',
|
||||
title: 'Update Successful',
|
||||
timer: 2000,
|
||||
showConfirmButton: false
|
||||
});
|
||||
} else {
|
||||
Swal.fire({
|
||||
icon: 'error',
|
||||
title: 'Update Failed',
|
||||
text: response.data.message ?? 'Please check your data.',
|
||||
confirmButtonText: 'Try Again'
|
||||
});
|
||||
}
|
||||
} catch (error) {
|
||||
Swal.fire({
|
||||
icon: 'error',
|
||||
title: 'An Error Occurred',
|
||||
text: error.response?.data?.message ?? 'Please try again.',
|
||||
confirmButtonText: 'OK'
|
||||
});
|
||||
}
|
||||
}
|
||||
if (args.requestType === 'delete') {
|
||||
try {
|
||||
const response = await services.deleteSecondaryData(args.data[0].id, StorageManager.getUserId());
|
||||
await methods.populateSecondaryData(state.id);
|
||||
secondaryGrid.refresh();
|
||||
if (response.data.code === 200) {
|
||||
Swal.fire({
|
||||
icon: 'success',
|
||||
title: 'Delete Successful',
|
||||
timer: 2000,
|
||||
showConfirmButton: false
|
||||
});
|
||||
} else {
|
||||
Swal.fire({
|
||||
icon: 'error',
|
||||
title: 'Delete Failed',
|
||||
text: response.data.message ?? 'Please check your data.',
|
||||
confirmButtonText: 'Try Again'
|
||||
});
|
||||
}
|
||||
} catch (error) {
|
||||
Swal.fire({
|
||||
icon: 'error',
|
||||
title: 'An Error Occurred',
|
||||
text: error.response?.data?.message ?? 'Please try again.',
|
||||
confirmButtonText: 'OK'
|
||||
});
|
||||
}
|
||||
}
|
||||
methods.refreshSummary();
|
||||
}
|
||||
});
|
||||
secondaryGrid.obj.appendTo(secondaryGridRef.value);
|
||||
|
||||
},
|
||||
refresh: () => {
|
||||
secondaryGrid.obj.setProperties({ dataSource: state.secondaryData });
|
||||
}
|
||||
};
|
||||
|
||||
const mainModal = {
|
||||
obj: null,
|
||||
create: () => {
|
||||
mainModal.obj = new bootstrap.Modal(mainModalRef.value, {
|
||||
backdrop: 'static',
|
||||
keyboard: false
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
return {
|
||||
mainGridRef,
|
||||
mainModalRef,
|
||||
secondaryGridRef,
|
||||
numberRef,
|
||||
receiveDateRef,
|
||||
purchaseOrderIdRef,
|
||||
statusRef,
|
||||
state,
|
||||
handler,
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
Vue.createApp(App).mount('#app');
|
||||
@@ -0,0 +1,234 @@
|
||||
@page
|
||||
@attribute [Authorize(Roles = "GoodsReceives")]
|
||||
@{
|
||||
ViewData["Title"] = "Goods Receive PDF";
|
||||
}
|
||||
|
||||
<div id="app" class="row">
|
||||
<div class="col-12">
|
||||
<div class="print-indicator" v-cloak>
|
||||
<div class="content-wrapper">
|
||||
<div>
|
||||
<button id="download-pdf" class="btn btn-danger d-flex align-items-center" v-on:click="handler.downloadPDF" v-bind:disabled="state.isDownloading">
|
||||
<span class="spinner-border spinner-border-sm me-2" role="status" aria-hidden="true" v-if="state.isDownloading"></span>
|
||||
<span class="button-text" v-if="!state.isDownloading">
|
||||
<i class="bi bi-file-earmark-pdf-fill me-2"></i> Download PDF
|
||||
</span>
|
||||
</button>
|
||||
</div>
|
||||
<div id="content" class="print-area">
|
||||
<div class="company-info">
|
||||
<h2>{{ state.company.name }}</h2>
|
||||
<p>{{ state.companyAddress }}</p>
|
||||
<p>Email: {{ state.company.emailAddress }} | Phone: {{ state.company.phoneNumber }}</p>
|
||||
</div>
|
||||
|
||||
<h1>Goods Receive</h1>
|
||||
|
||||
<div class="info-container">
|
||||
<table class="details-table">
|
||||
<tr>
|
||||
<th colspan="2">Vendor Information</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>Name:</strong></td>
|
||||
<td>{{ state.vendor.name }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>Address:</strong></td>
|
||||
<td>{{ state.vendorAddress }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>Email:</strong></td>
|
||||
<td>{{ state.vendor.emailAddress }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>Phone:</strong></td>
|
||||
<td>{{ state.vendor.phoneNumber }}</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<table class="details-table">
|
||||
<tr>
|
||||
<th colspan="2">Receive Information</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>Number:</strong></td>
|
||||
<td>{{ state.number }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>Date:</strong></td>
|
||||
<td>{{ state.date }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>Reference:</strong></td>
|
||||
<td>{{ state.reference }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>_</strong></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<table class="product-table" border="1" style="width: 100%; border-collapse: collapse;">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Warehouse</th>
|
||||
<th>Product</th>
|
||||
<th>Movement</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-for="item in state.mappedItems" :key="item.product + item.warehouse">
|
||||
<td>{{ item.warehouse }}</td>
|
||||
<td>{{ item.product }}</td>
|
||||
<td>{{ item.movement }}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<div class="summary">
|
||||
<div class="column"></div>
|
||||
<div class="column">
|
||||
<table style="width: 100%; border-collapse: collapse; margin-top: 20px;">
|
||||
<tr>
|
||||
<td style="font-weight: bold; font-size: 1.2em;">Total Movement:</td>
|
||||
<td style="text-align: right; font-weight: bold; font-size: 1.2em; color: #2c3e50;">
|
||||
{{ state.movementTotal }}
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- CSS -->
|
||||
<style>
|
||||
.print-indicator {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: flex-start;
|
||||
height: 100vh;
|
||||
background-color: #f8f9fa;
|
||||
position: relative;
|
||||
overflow-y: auto;
|
||||
padding: 30px;
|
||||
}
|
||||
|
||||
|
||||
.content-wrapper {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
gap: 20px;
|
||||
}
|
||||
|
||||
.print-area {
|
||||
width: 210mm;
|
||||
padding: 10mm;
|
||||
background-color: white;
|
||||
border: 1px dashed #cccccc;
|
||||
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
|
||||
#download-pdf {
|
||||
padding: 10px 20px;
|
||||
font-size: 16px;
|
||||
border-radius: 5px;
|
||||
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
|
||||
}
|
||||
|
||||
.company-info {
|
||||
text-align: center;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.company-info h2 {
|
||||
font-size: 24px;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.company-info p {
|
||||
margin: 5px 0;
|
||||
font-size: 14px;
|
||||
color: #555;
|
||||
}
|
||||
|
||||
h1 {
|
||||
text-align: center;
|
||||
margin-bottom: 20px;
|
||||
font-size: 28px;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.info-container {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
margin-bottom: 20px;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.details-table {
|
||||
flex: 1;
|
||||
padding: 5px 8px;
|
||||
border: 1px solid #ccc;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.details-table th, .details-table td {
|
||||
padding: 5px 10px;
|
||||
border: 1px solid #ccc;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
|
||||
.details-table th {
|
||||
background-color: #f2f2f2;
|
||||
text-align: left;
|
||||
height: 35px;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
|
||||
|
||||
.product-table {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
margin-bottom: 20px;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.product-table th, .product-table td {
|
||||
padding: 8px;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.product-table th {
|
||||
background-color: #f2f2f2;
|
||||
}
|
||||
|
||||
.summary {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
margin-top: 20px;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.summary .column {
|
||||
width: 48%;
|
||||
}
|
||||
|
||||
.summary p {
|
||||
margin: 5px 0;
|
||||
text-align: right;
|
||||
}
|
||||
</style>
|
||||
|
||||
@section scripts {
|
||||
<script src="~/FrontEnd/Pages/GoodsReceives/GoodsReceivePdf.cshtml.js"></script>
|
||||
}
|
||||
@@ -0,0 +1,150 @@
|
||||
const App = {
|
||||
setup() {
|
||||
const state = Vue.reactive({
|
||||
company: {
|
||||
name: '',
|
||||
emailAddress: '',
|
||||
phoneNumber: '',
|
||||
street: '',
|
||||
city: '',
|
||||
state: '',
|
||||
zipCode: '',
|
||||
country: ''
|
||||
},
|
||||
companyAddress: '',
|
||||
vendor: {
|
||||
name: '',
|
||||
street: '',
|
||||
city: '',
|
||||
state: '',
|
||||
zipCode: '',
|
||||
country: '',
|
||||
emailAddress: '',
|
||||
phoneNumber: ''
|
||||
},
|
||||
vendorAddress: '',
|
||||
number: '',
|
||||
date: '',
|
||||
reference: '',
|
||||
pdfTransactionList: [],
|
||||
isDownloading: false,
|
||||
mappedItems: [],
|
||||
movementTotal: 0
|
||||
});
|
||||
|
||||
const services = {
|
||||
getPDFData: async (id) => {
|
||||
try {
|
||||
const response = await AxiosManager.get('/GoodsReceive/GetGoodsReceiveSingle?id=' + id, {});
|
||||
return response;
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
const methods = {
|
||||
populatePDFData: async (id) => {
|
||||
const response = await services.getPDFData(id);
|
||||
state.pdfData = response?.data?.content?.data || {};
|
||||
state.pdfTransactionList = response?.data?.content?.transactionList || [];
|
||||
methods.bindPDFControls();
|
||||
},
|
||||
|
||||
bindPDFControls: () => {
|
||||
const company = StorageManager.getCompany() || state.company;
|
||||
state.company = {
|
||||
name: company.name,
|
||||
emailAddress: company.emailAddress,
|
||||
phoneNumber: company.phoneNumber,
|
||||
street: company.street,
|
||||
city: company.city,
|
||||
state: company.state,
|
||||
zipCode: company.zipCode,
|
||||
country: company.country
|
||||
};
|
||||
state.companyAddress = [
|
||||
company.street,
|
||||
company.city,
|
||||
company.state,
|
||||
company.zipCode,
|
||||
company.country
|
||||
].filter(Boolean).join(', ');
|
||||
|
||||
const pdfData = state.pdfData;
|
||||
state.vendor = pdfData.purchaseOrder?.vendor || {};
|
||||
state.vendorAddress = [
|
||||
state.vendor.street,
|
||||
state.vendor.city,
|
||||
state.vendor.state,
|
||||
state.vendor.zipCode,
|
||||
state.vendor.country
|
||||
].filter(Boolean).join(', ');
|
||||
|
||||
state.number = pdfData?.number || '';
|
||||
state.date = DateFormatManager.formatToLocale(pdfData?.receiveDate) || '';
|
||||
state.reference = pdfData?.purchaseOrder?.number || '';
|
||||
|
||||
state.mappedItems = (state.pdfTransactionList || []).map(item => ({
|
||||
warehouse: item.warehouse?.name || '',
|
||||
product: `${item.product?.number || ''} ${item.product?.name || ''}`.trim(),
|
||||
movement: item.movement || 0,
|
||||
}));
|
||||
|
||||
let movementTotal = (state.pdfTransactionList || []).reduce((sum, item) => sum + (item.movement || 0), 0);
|
||||
state.movementTotal = NumberFormatManager.formatToLocale(movementTotal);
|
||||
}
|
||||
};
|
||||
|
||||
const handler = {
|
||||
downloadPDF: async () => {
|
||||
state.isDownloading = true;
|
||||
await new Promise(resolve => setTimeout(resolve, 500));
|
||||
|
||||
try {
|
||||
const { jsPDF } = window.jspdf;
|
||||
const doc = new jsPDF('p', 'mm', 'a4');
|
||||
const content = document.getElementById('content');
|
||||
|
||||
await html2canvas(content, {
|
||||
scale: 2,
|
||||
useCORS: true
|
||||
}).then(canvas => {
|
||||
const imgData = canvas.toDataURL('image/png');
|
||||
const imgWidth = 210;
|
||||
const pageHeight = 297;
|
||||
const imgHeight = (canvas.height * imgWidth) / canvas.width;
|
||||
let position = 0;
|
||||
|
||||
doc.addImage(imgData, 'PNG', 0, position, imgWidth, imgHeight);
|
||||
doc.save(`goods-receive-${state.number || 'unknown'}.pdf`);
|
||||
});
|
||||
} catch (error) {
|
||||
console.error('Error generating PDF:', error);
|
||||
} finally {
|
||||
state.isDownloading = false;
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
Vue.onMounted(async () => {
|
||||
try {
|
||||
await SecurityManager.authorizePage(['GoodsReceives']);
|
||||
var urlParams = new URLSearchParams(window.location.search);
|
||||
var id = urlParams.get('id');
|
||||
await methods.populatePDFData(id ?? '');
|
||||
} catch (e) {
|
||||
console.error('page init error:', e);
|
||||
} finally {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
return {
|
||||
state,
|
||||
handler,
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
Vue.createApp(App).mount('#app');
|
||||
@@ -0,0 +1,13 @@
|
||||
@page
|
||||
@{
|
||||
Layout = "~/FrontEnd/Pages/Shared/_Layout.cshtml";
|
||||
ViewData["Title"] = "Home page";
|
||||
}
|
||||
|
||||
<div class="lock-overlay">
|
||||
<h1 class="lock-welcome">INDOTALENT WHMS</h1>
|
||||
<a asp-area="" asp-page="/Accounts/Login" class="lock-login">
|
||||
<i class="fas fa-lock lock-icon"></i>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
@page
|
||||
@attribute [Authorize(Roles = "MovementReports")]
|
||||
@{
|
||||
ViewData["Title"] = "Movement Report List";
|
||||
}
|
||||
|
||||
<div id="app" v-cloak>
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<div class="grid-container">
|
||||
<div ref="mainGridRef"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@section scripts {
|
||||
<script src="~/FrontEnd/Pages/MovementReports/MovementReportList.cshtml.js"></script>
|
||||
}
|
||||
+91
@@ -0,0 +1,91 @@
|
||||
const App = {
|
||||
setup() {
|
||||
const state = Vue.reactive({
|
||||
mainData: []
|
||||
});
|
||||
|
||||
const mainGridRef = Vue.ref(null);
|
||||
|
||||
const services = {
|
||||
getMainData: async () => {
|
||||
try {
|
||||
const response = await AxiosManager.get('/InventoryTransaction/GetInventoryTransactionList', {});
|
||||
return response;
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
const methods = {
|
||||
populateMainData: async () => {
|
||||
const response = await services.getMainData();
|
||||
state.mainData = response?.data?.content?.data.map(item => ({
|
||||
...item,
|
||||
createdAtUtc: new Date(item.createdAtUtc),
|
||||
movementDate: new Date(item.movementDate)
|
||||
}));
|
||||
},
|
||||
onMainModalHidden: () => {
|
||||
}
|
||||
};
|
||||
|
||||
Vue.onMounted(async () => {
|
||||
try {
|
||||
await SecurityManager.authorizePage(['MovementReports']);
|
||||
await SecurityManager.validateToken();
|
||||
|
||||
await methods.populateMainData();
|
||||
await mainGrid.create(state.mainData);
|
||||
|
||||
} catch (e) {
|
||||
console.error('page init error:', e);
|
||||
} finally {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
const mainGrid = {
|
||||
obj: null,
|
||||
create: async (dataSource) => {
|
||||
mainGrid.obj = new ej.pivotview.PivotView({
|
||||
height: '240px',
|
||||
width: '100%',
|
||||
dataSourceSettings: {
|
||||
dataSource: dataSource,
|
||||
expandAll: true,
|
||||
filters: [],
|
||||
columns: [
|
||||
{ name: 'moduleCode' },
|
||||
],
|
||||
rows: [
|
||||
{ name: 'productName' },
|
||||
{ name: 'warehouseName' }
|
||||
],
|
||||
values: [
|
||||
{ name: 'stock' }
|
||||
],
|
||||
},
|
||||
showToolbar: true,
|
||||
showFieldList: false,
|
||||
displayOption: { view: "Table" },
|
||||
showGroupingBar: false,
|
||||
showValuesButton: true,
|
||||
groupingBarSettings: { showFieldsPanel: true },
|
||||
});
|
||||
|
||||
mainGrid.obj.appendTo(mainGridRef.value);
|
||||
},
|
||||
refresh: () => {
|
||||
mainGrid.obj.setProperties({ dataSource: state.mainData });
|
||||
}
|
||||
};
|
||||
|
||||
return {
|
||||
mainGridRef,
|
||||
state,
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
Vue.createApp(App).mount('#app');
|
||||
@@ -0,0 +1,125 @@
|
||||
@page
|
||||
@attribute [Authorize(Roles = "NegativeAdjustments")]
|
||||
@{
|
||||
ViewData["Title"] = "Negative Adjustment List";
|
||||
}
|
||||
|
||||
<div id="app" v-cloak>
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<div class="grid-container">
|
||||
<div ref="mainGridRef"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="modal fade" ref="mainModalRef" id="MainModal" aria-hidden="true" tabindex="-1" data-bs-focus="false" data-bs-backdrop="static">
|
||||
<div class="modal-dialog modal-dialog-centered modal-xl">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title">{{ state.mainTitle }}</h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<input type="hidden" v-model="state.id" id="Id" name="Id" />
|
||||
<form>
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<h5>Main Info</h5>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="row mb-2">
|
||||
<div class="col-md-6">
|
||||
<label for="AdjustmentDate">Adjustment Date</label>
|
||||
<input ref="adjustmentDateRef">
|
||||
<label class="text-danger">{{ state.errors.adjustmentDate }}</label>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<label for="Number">Number</label>
|
||||
<input ref="numberRef" v-model="state.number" readonly>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mb-2">
|
||||
<div class="col-md-6">
|
||||
<label for="Status">Status</label>
|
||||
<div ref="statusRef"></div>
|
||||
<label class="text-danger">{{ state.errors.status }}</label>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mb-2">
|
||||
<div class="col-md-12">
|
||||
<label for="Description">Description</label>
|
||||
<textarea class="form-control" rows="3" v-model="state.description"></textarea>
|
||||
<label class="text-danger">{{ state.errors.description }}</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
<div id="ComplexDiv" :style="{ display: state.showComplexDiv ? 'block' : 'none' }">
|
||||
<div class="row mt-3">
|
||||
<div class="col-md-12">
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<h5>Delivery Item</h5>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<div class="grid-container">
|
||||
<div ref="secondaryGridRef"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mt-4">
|
||||
<div class="col-md-12">
|
||||
<div class="card shadow-sm">
|
||||
<div class="card-header text-white">
|
||||
<h5 class="mb-0">Summary</h5>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="row justify-content-end">
|
||||
<div class="col-md-6">
|
||||
<div class="d-flex justify-content-between py-2">
|
||||
<span class="fw-bold">Total Movement</span>
|
||||
<span id="TotalMovement" class="fw-bold text-success">{{ state.totalMovementFormatted }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
|
||||
<button type="button"
|
||||
id="MainSaveButton"
|
||||
class="btn"
|
||||
v-bind:class="state.deleteMode ? 'btn-danger' : 'btn-primary'"
|
||||
v-on:click="handler.handleSubmit"
|
||||
v-bind:disabled="state.isSubmitting">
|
||||
<span class="spinner-border spinner-border-sm me-2" v-if="state.isSubmitting" role="status" aria-hidden="true"></span>
|
||||
<span v-if="!state.isSubmitting">{{ state.deleteMode ? 'Delete' : 'Save' }}</span>
|
||||
<span v-else>{{ state.deleteMode ? 'Deleting...' : 'Saving...' }}</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@section scripts {
|
||||
<script src="~/FrontEnd/Pages/NegativeAdjustments/NegativeAdjustmentList.cshtml.js"></script>
|
||||
}
|
||||
+799
@@ -0,0 +1,799 @@
|
||||
const App = {
|
||||
setup() {
|
||||
const state = Vue.reactive({
|
||||
mainData: [],
|
||||
deleteMode: false,
|
||||
negativeAdjustmentStatusListLookupData: [],
|
||||
secondaryData: [],
|
||||
productListLookupData: [],
|
||||
warehouseListLookupData: [],
|
||||
mainTitle: null,
|
||||
id: '',
|
||||
number: '',
|
||||
adjustmentDate: '',
|
||||
description: '',
|
||||
status: null,
|
||||
errors: {
|
||||
adjustmentDate: '',
|
||||
status: '',
|
||||
description: ''
|
||||
},
|
||||
showComplexDiv: false,
|
||||
isSubmitting: false,
|
||||
totalMovementFormatted: '0.00'
|
||||
});
|
||||
|
||||
const mainGridRef = Vue.ref(null);
|
||||
const mainModalRef = Vue.ref(null);
|
||||
const secondaryGridRef = Vue.ref(null);
|
||||
const adjustmentDateRef = Vue.ref(null);
|
||||
const statusRef = Vue.ref(null);
|
||||
const numberRef = Vue.ref(null);
|
||||
|
||||
const validateForm = function () {
|
||||
state.errors.adjustmentDate = '';
|
||||
state.errors.status = '';
|
||||
|
||||
let isValid = true;
|
||||
|
||||
if (!state.adjustmentDate) {
|
||||
state.errors.adjustmentDate = 'Adjustment date is required.';
|
||||
isValid = false;
|
||||
}
|
||||
if (!state.status) {
|
||||
state.errors.status = 'Status is required.';
|
||||
isValid = false;
|
||||
}
|
||||
|
||||
return isValid;
|
||||
};
|
||||
|
||||
const resetFormState = () => {
|
||||
state.id = '';
|
||||
state.number = '';
|
||||
state.adjustmentDate = '';
|
||||
state.description = '';
|
||||
state.status = null;
|
||||
state.errors = {
|
||||
adjustmentDate: '',
|
||||
status: '',
|
||||
description: ''
|
||||
};
|
||||
state.secondaryData = [];
|
||||
};
|
||||
|
||||
const adjustmentDatePicker = {
|
||||
obj: null,
|
||||
create: () => {
|
||||
adjustmentDatePicker.obj = new ej.calendars.DatePicker({
|
||||
placeholder: 'Select Date',
|
||||
format: 'yyyy-MM-dd',
|
||||
value: state.adjustmentDate ? new Date(state.adjustmentDate) : null,
|
||||
change: (e) => {
|
||||
state.adjustmentDate = e.value;
|
||||
}
|
||||
});
|
||||
adjustmentDatePicker.obj.appendTo(adjustmentDateRef.value);
|
||||
},
|
||||
refresh: () => {
|
||||
if (adjustmentDatePicker.obj) {
|
||||
adjustmentDatePicker.obj.value = state.adjustmentDate ? new Date(state.adjustmentDate) : null;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Vue.watch(
|
||||
() => state.adjustmentDate,
|
||||
(newVal, oldVal) => {
|
||||
adjustmentDatePicker.refresh();
|
||||
state.errors.adjustmentDate = '';
|
||||
}
|
||||
);
|
||||
|
||||
const numberText = {
|
||||
obj: null,
|
||||
create: () => {
|
||||
numberText.obj = new ej.inputs.TextBox({
|
||||
placeholder: '[auto]',
|
||||
});
|
||||
numberText.obj.appendTo(numberRef.value);
|
||||
}
|
||||
};
|
||||
|
||||
const negativeAdjustmentStatusListLookup = {
|
||||
obj: null,
|
||||
create: () => {
|
||||
if (state.negativeAdjustmentStatusListLookupData && Array.isArray(state.negativeAdjustmentStatusListLookupData)) {
|
||||
negativeAdjustmentStatusListLookup.obj = new ej.dropdowns.DropDownList({
|
||||
dataSource: state.negativeAdjustmentStatusListLookupData,
|
||||
fields: { value: 'id', text: 'name' },
|
||||
placeholder: 'Select Status',
|
||||
allowFiltering: false,
|
||||
change: (e) => {
|
||||
state.status = e.value;
|
||||
}
|
||||
});
|
||||
negativeAdjustmentStatusListLookup.obj.appendTo(statusRef.value);
|
||||
}
|
||||
},
|
||||
refresh: () => {
|
||||
if (negativeAdjustmentStatusListLookup.obj) {
|
||||
negativeAdjustmentStatusListLookup.obj.value = state.status
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
Vue.watch(
|
||||
() => state.status,
|
||||
(newVal, oldVal) => {
|
||||
negativeAdjustmentStatusListLookup.refresh();
|
||||
state.errors.status = '';
|
||||
}
|
||||
);
|
||||
|
||||
const services = {
|
||||
getMainData: async () => {
|
||||
try {
|
||||
const response = await AxiosManager.get('/NegativeAdjustment/GetNegativeAdjustmentList', {});
|
||||
return response;
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
},
|
||||
createMainData: async (adjustmentDate, description, status, createdById) => {
|
||||
try {
|
||||
const response = await AxiosManager.post('/NegativeAdjustment/CreateNegativeAdjustment', {
|
||||
adjustmentDate, description, status, createdById
|
||||
});
|
||||
return response;
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
},
|
||||
updateMainData: async (id, adjustmentDate, description, status, updatedById) => {
|
||||
try {
|
||||
const response = await AxiosManager.post('/NegativeAdjustment/UpdateNegativeAdjustment', {
|
||||
id, adjustmentDate, description, status, updatedById
|
||||
});
|
||||
return response;
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
},
|
||||
deleteMainData: async (id, deletedById) => {
|
||||
try {
|
||||
const response = await AxiosManager.post('/NegativeAdjustment/DeleteNegativeAdjustment', {
|
||||
id, deletedById
|
||||
});
|
||||
return response;
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
},
|
||||
getNegativeAdjustmentStatusListLookupData: async () => {
|
||||
try {
|
||||
const response = await AxiosManager.get('/NegativeAdjustment/GetNegativeAdjustmentStatusList', {});
|
||||
return response;
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
},
|
||||
getSecondaryData: async (moduleId) => {
|
||||
try {
|
||||
const response = await AxiosManager.get('/InventoryTransaction/NegativeAdjustmentGetInvenTransList?moduleId=' + moduleId, {});
|
||||
return response;
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
},
|
||||
createSecondaryData: async (moduleId, warehouseId, productId, movement, createdById) => {
|
||||
try {
|
||||
const response = await AxiosManager.post('/InventoryTransaction/NegativeAdjustmentCreateInvenTrans', {
|
||||
moduleId, warehouseId, productId, movement, createdById
|
||||
});
|
||||
return response;
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
},
|
||||
updateSecondaryData: async (id, warehouseId, productId, movement, updatedById) => {
|
||||
try {
|
||||
const response = await AxiosManager.post('/InventoryTransaction/NegativeAdjustmentUpdateInvenTrans', {
|
||||
id, warehouseId, productId, movement, updatedById
|
||||
});
|
||||
return response;
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
},
|
||||
deleteSecondaryData: async (id, deletedById) => {
|
||||
try {
|
||||
const response = await AxiosManager.post('/InventoryTransaction/NegativeAdjustmentDeleteInvenTrans', {
|
||||
id, deletedById
|
||||
});
|
||||
return response;
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
},
|
||||
getProductListLookupData: async () => {
|
||||
try {
|
||||
const response = await AxiosManager.get('/Product/GetProductList', {});
|
||||
return response;
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
},
|
||||
getWarehouseListLookupData: async () => {
|
||||
try {
|
||||
const response = await AxiosManager.get('/Warehouse/GetWarehouseList', {});
|
||||
return response;
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
const methods = {
|
||||
populateMainData: async () => {
|
||||
const response = await services.getMainData();
|
||||
state.mainData = response?.data?.content?.data.map(item => ({
|
||||
...item,
|
||||
adjustmentDate: new Date(item.adjustmentDate),
|
||||
createdAtUtc: new Date(item.createdAtUtc)
|
||||
}));
|
||||
},
|
||||
populateNegativeAdjustmentStatusListLookupData: async () => {
|
||||
const response = await services.getNegativeAdjustmentStatusListLookupData();
|
||||
state.negativeAdjustmentStatusListLookupData = response?.data?.content?.data;
|
||||
},
|
||||
populateProductListLookupData: async () => {
|
||||
const response = await services.getProductListLookupData();
|
||||
state.productListLookupData = response?.data?.content?.data
|
||||
.filter(product => product.physical === true)
|
||||
.map(product => ({
|
||||
...product,
|
||||
numberName: `${product.number} - ${product.name}`
|
||||
})) || [];
|
||||
},
|
||||
populateWarehouseListLookupData: async () => {
|
||||
const response = await services.getWarehouseListLookupData();
|
||||
state.warehouseListLookupData = response?.data?.content?.data.filter(warehouse => warehouse.systemWarehouse === false) || [];
|
||||
},
|
||||
populateSecondaryData: async (negativeAdjustmentId) => {
|
||||
try {
|
||||
const response = await services.getSecondaryData(negativeAdjustmentId);
|
||||
state.secondaryData = response?.data?.content?.data.map(item => ({
|
||||
...item,
|
||||
createdAtUtc: new Date(item.createdAtUtc)
|
||||
}));
|
||||
methods.refreshSummary();
|
||||
} catch (error) {
|
||||
state.secondaryData = [];
|
||||
}
|
||||
},
|
||||
refreshSummary: () => {
|
||||
const totalMovement = state.secondaryData.reduce((sum, record) => sum + (record.movement ?? 0), 0);
|
||||
state.totalMovementFormatted = NumberFormatManager.formatToLocale(totalMovement);
|
||||
},
|
||||
onMainModalHidden: () => {
|
||||
state.errors.adjustmentDate = '';
|
||||
state.errors.status = '';
|
||||
}
|
||||
};
|
||||
|
||||
const handler = {
|
||||
handleSubmit: async function () {
|
||||
try {
|
||||
state.isSubmitting = true;
|
||||
await new Promise(resolve => setTimeout(resolve, 300));
|
||||
|
||||
if (!validateForm()) {
|
||||
return;
|
||||
}
|
||||
|
||||
const response = state.id === ''
|
||||
? await services.createMainData(state.adjustmentDate, state.description, state.status, StorageManager.getUserId())
|
||||
: state.deleteMode
|
||||
? await services.deleteMainData(state.id, StorageManager.getUserId())
|
||||
: await services.updateMainData(state.id, state.adjustmentDate, state.description, state.status, StorageManager.getUserId());
|
||||
|
||||
if (response.data.code === 200) {
|
||||
await methods.populateMainData();
|
||||
mainGrid.refresh();
|
||||
|
||||
if (!state.deleteMode) {
|
||||
state.mainTitle = 'Edit Negative Adjustment';
|
||||
state.id = response?.data?.content?.data.id ?? '';
|
||||
state.number = response?.data?.content?.data.number ?? '';
|
||||
await methods.populateSecondaryData(state.id);
|
||||
secondaryGrid.refresh();
|
||||
state.showComplexDiv = true;
|
||||
|
||||
Swal.fire({
|
||||
icon: 'success',
|
||||
title: 'Save Successful',
|
||||
timer: 2000,
|
||||
showConfirmButton: false
|
||||
});
|
||||
|
||||
} else {
|
||||
Swal.fire({
|
||||
icon: 'success',
|
||||
title: 'Delete Successful',
|
||||
text: 'Form will be closed...',
|
||||
timer: 2000,
|
||||
showConfirmButton: false
|
||||
});
|
||||
setTimeout(() => {
|
||||
mainModal.obj.hide();
|
||||
resetFormState();
|
||||
}, 2000);
|
||||
}
|
||||
|
||||
} else {
|
||||
Swal.fire({
|
||||
icon: 'error',
|
||||
title: state.deleteMode ? 'Delete Failed' : 'Save Failed',
|
||||
text: response.data.message ?? 'Please check your data.',
|
||||
confirmButtonText: 'Try Again'
|
||||
});
|
||||
}
|
||||
|
||||
} catch (error) {
|
||||
Swal.fire({
|
||||
icon: 'error',
|
||||
title: 'An Error Occurred',
|
||||
text: error.response?.data?.message ?? 'Please try again.',
|
||||
confirmButtonText: 'OK'
|
||||
});
|
||||
} finally {
|
||||
state.isSubmitting = false;
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
Vue.onMounted(async () => {
|
||||
try {
|
||||
await SecurityManager.authorizePage(['NegativeAdjustments']);
|
||||
await SecurityManager.validateToken();
|
||||
|
||||
await methods.populateMainData();
|
||||
await mainGrid.create(state.mainData);
|
||||
|
||||
mainModal.create();
|
||||
mainModalRef.value?.addEventListener('hidden.bs.modal', methods.onMainModalHidden);
|
||||
await methods.populateNegativeAdjustmentStatusListLookupData();
|
||||
numberText.create();
|
||||
adjustmentDatePicker.create();
|
||||
negativeAdjustmentStatusListLookup.create();
|
||||
|
||||
await secondaryGrid.create(state.secondaryData);
|
||||
await methods.populateProductListLookupData();
|
||||
await methods.populateWarehouseListLookupData();
|
||||
|
||||
} catch (e) {
|
||||
console.error('page init error:', e);
|
||||
} finally {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
Vue.onUnmounted(() => {
|
||||
mainModalRef.value?.removeEventListener('hidden.bs.modal', methods.onMainModalHidden);
|
||||
});
|
||||
|
||||
const mainGrid = {
|
||||
obj: null,
|
||||
create: async (dataSource) => {
|
||||
mainGrid.obj = new ej.grids.Grid({
|
||||
height: '240px',
|
||||
dataSource: dataSource,
|
||||
allowFiltering: true,
|
||||
allowSorting: true,
|
||||
allowSelection: true,
|
||||
allowGrouping: true,
|
||||
allowTextWrap: true,
|
||||
allowResizing: true,
|
||||
allowPaging: true,
|
||||
allowExcelExport: true,
|
||||
filterSettings: { type: 'CheckBox' },
|
||||
sortSettings: { columns: [{ field: 'createdAtUtc', direction: 'Descending' }] },
|
||||
pageSettings: { currentPage: 1, pageSize: 50, pageSizes: ["10", "20", "50", "100", "200", "All"] },
|
||||
selectionSettings: { persistSelection: true, type: 'Single' },
|
||||
autoFit: true,
|
||||
showColumnMenu: true,
|
||||
gridLines: 'Horizontal',
|
||||
columns: [
|
||||
{ type: 'checkbox', width: 60 },
|
||||
{
|
||||
field: 'id', isPrimaryKey: true, headerText: 'Id', visible: false
|
||||
},
|
||||
{ field: 'number', headerText: 'Number', width: 150, minWidth: 150 },
|
||||
{ field: 'adjustmentDate', headerText: 'Adjustment Date', width: 150, format: 'yyyy-MM-dd' },
|
||||
{ field: 'statusName', headerText: 'Status', width: 150, minWidth: 150 },
|
||||
{ field: 'createdAtUtc', headerText: 'Created At UTC', width: 150, format: 'yyyy-MM-dd HH:mm' }
|
||||
],
|
||||
toolbar: [
|
||||
'ExcelExport', 'Search',
|
||||
{ type: 'Separator' },
|
||||
{ text: 'Add', tooltipText: 'Add', prefixIcon: 'e-add', id: 'AddCustom' },
|
||||
{ text: 'Edit', tooltipText: 'Edit', prefixIcon: 'e-edit', id: 'EditCustom' },
|
||||
{ text: 'Delete', tooltipText: 'Delete', prefixIcon: 'e-delete', id: 'DeleteCustom' },
|
||||
{ type: 'Separator' },
|
||||
{ text: 'Print PDF', tooltipText: 'Print PDF', id: 'PrintPDFCustom' },
|
||||
],
|
||||
beforeDataBound: () => { },
|
||||
dataBound: function () {
|
||||
mainGrid.obj.toolbarModule.enableItems(['EditCustom', 'DeleteCustom', 'PrintPDFCustom'], false);
|
||||
mainGrid.obj.autoFitColumns(['number', 'adjustmentDate', 'statusName', 'createdAtUtc']);
|
||||
},
|
||||
excelExportComplete: () => { },
|
||||
rowSelected: () => {
|
||||
if (mainGrid.obj.getSelectedRecords().length == 1) {
|
||||
mainGrid.obj.toolbarModule.enableItems(['EditCustom', 'DeleteCustom', 'PrintPDFCustom'], true);
|
||||
} else {
|
||||
mainGrid.obj.toolbarModule.enableItems(['EditCustom', 'DeleteCustom', 'PrintPDFCustom'], false);
|
||||
}
|
||||
},
|
||||
rowDeselected: () => {
|
||||
if (mainGrid.obj.getSelectedRecords().length == 1) {
|
||||
mainGrid.obj.toolbarModule.enableItems(['EditCustom', 'DeleteCustom', 'PrintPDFCustom'], true);
|
||||
} else {
|
||||
mainGrid.obj.toolbarModule.enableItems(['EditCustom', 'DeleteCustom', 'PrintPDFCustom'], false);
|
||||
}
|
||||
},
|
||||
rowSelecting: () => {
|
||||
if (mainGrid.obj.getSelectedRecords().length) {
|
||||
mainGrid.obj.clearSelection();
|
||||
}
|
||||
},
|
||||
toolbarClick: async (args) => {
|
||||
if (args.item.id === 'MainGrid_excelexport') {
|
||||
mainGrid.obj.excelExport();
|
||||
}
|
||||
|
||||
if (args.item.id === 'AddCustom') {
|
||||
state.deleteMode = false;
|
||||
state.mainTitle = 'Add Negative Adjustment';
|
||||
resetFormState();
|
||||
state.showComplexDiv = false;
|
||||
mainModal.obj.show();
|
||||
}
|
||||
|
||||
if (args.item.id === 'EditCustom') {
|
||||
state.deleteMode = false;
|
||||
if (mainGrid.obj.getSelectedRecords().length) {
|
||||
const selectedRecord = mainGrid.obj.getSelectedRecords()[0];
|
||||
state.mainTitle = 'Edit Negative Adjustment';
|
||||
state.id = selectedRecord.id ?? '';
|
||||
state.number = selectedRecord.number ?? '';
|
||||
state.adjustmentDate = selectedRecord.adjustmentDate ? new Date(selectedRecord.adjustmentDate) : null;
|
||||
state.description = selectedRecord.description ?? '';
|
||||
state.status = String(selectedRecord.status ?? '');
|
||||
await methods.populateSecondaryData(selectedRecord.id);
|
||||
secondaryGrid.refresh();
|
||||
state.showComplexDiv = true;
|
||||
mainModal.obj.show();
|
||||
}
|
||||
}
|
||||
|
||||
if (args.item.id === 'DeleteCustom') {
|
||||
state.deleteMode = true;
|
||||
if (mainGrid.obj.getSelectedRecords().length) {
|
||||
const selectedRecord = mainGrid.obj.getSelectedRecords()[0];
|
||||
state.mainTitle = 'Delete Negative Adjustment?';
|
||||
state.id = selectedRecord.id ?? '';
|
||||
state.number = selectedRecord.number ?? '';
|
||||
state.adjustmentDate = selectedRecord.adjustmentDate ? new Date(selectedRecord.adjustmentDate) : null;
|
||||
state.description = selectedRecord.description ?? '';
|
||||
state.status = String(selectedRecord.status ?? '');
|
||||
await methods.populateSecondaryData(selectedRecord.id);
|
||||
secondaryGrid.refresh();
|
||||
state.showComplexDiv = false;
|
||||
mainModal.obj.show();
|
||||
}
|
||||
}
|
||||
|
||||
if (args.item.id === 'PrintPDFCustom') {
|
||||
if (mainGrid.obj.getSelectedRecords().length) {
|
||||
const selectedRecord = mainGrid.obj.getSelectedRecords()[0];
|
||||
window.open('/NegativeAdjustments/NegativeAdjustmentPdf?id=' + (selectedRecord.id ?? ''), '_blank');
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
mainGrid.obj.appendTo(mainGridRef.value);
|
||||
},
|
||||
refresh: () => {
|
||||
mainGrid.obj.setProperties({ dataSource: state.mainData });
|
||||
}
|
||||
};
|
||||
|
||||
const secondaryGrid = {
|
||||
obj: null,
|
||||
create: async (dataSource) => {
|
||||
secondaryGrid.obj = new ej.grids.Grid({
|
||||
height: 400,
|
||||
dataSource: dataSource,
|
||||
editSettings: { allowEditing: true, allowAdding: true, allowDeleting: true, showDeleteConfirmDialog: true, mode: 'Normal', allowEditOnDblClick: true },
|
||||
allowFiltering: false,
|
||||
allowSorting: true,
|
||||
allowSelection: true,
|
||||
allowGrouping: false,
|
||||
allowTextWrap: true,
|
||||
allowResizing: true,
|
||||
allowPaging: false,
|
||||
allowExcelExport: true,
|
||||
filterSettings: { type: 'CheckBox' },
|
||||
sortSettings: { columns: [{ field: 'warehouseName', direction: 'Descending' }] },
|
||||
pageSettings: { currentPage: 1, pageSize: 50, pageSizes: ["10", "20", "50", "100", "200", "All"] },
|
||||
selectionSettings: { persistSelection: true, type: 'Single' },
|
||||
autoFit: false,
|
||||
showColumnMenu: false,
|
||||
gridLines: 'Horizontal',
|
||||
columns: [
|
||||
{ type: 'checkbox', width: 60 },
|
||||
{
|
||||
field: 'id', isPrimaryKey: true, headerText: 'Id', visible: false
|
||||
},
|
||||
{
|
||||
field: 'warehouseId',
|
||||
headerText: 'Warehouse',
|
||||
width: 250,
|
||||
validationRules: { required: true },
|
||||
disableHtmlEncode: false,
|
||||
valueAccessor: (field, data, column) => {
|
||||
const warehouse = state.warehouseListLookupData.find(item => item.id === data[field]);
|
||||
return warehouse ? `${warehouse.name}` : '';
|
||||
},
|
||||
editType: 'dropdownedit',
|
||||
edit: {
|
||||
create: () => {
|
||||
const warehouseElem = document.createElement('input');
|
||||
return warehouseElem;
|
||||
},
|
||||
read: () => {
|
||||
return warehouseObj.value;
|
||||
},
|
||||
destroy: function () {
|
||||
warehouseObj.destroy();
|
||||
},
|
||||
write: function (args) {
|
||||
warehouseObj = new ej.dropdowns.DropDownList({
|
||||
dataSource: state.warehouseListLookupData,
|
||||
fields: { value: 'id', text: 'name' },
|
||||
value: args.rowData.warehouseId,
|
||||
placeholder: 'Select a Warehouse',
|
||||
floatLabelType: 'Never'
|
||||
});
|
||||
warehouseObj.appendTo(args.element);
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
field: 'productId',
|
||||
headerText: 'Product',
|
||||
width: 250,
|
||||
validationRules: { required: true },
|
||||
disableHtmlEncode: false,
|
||||
valueAccessor: (field, data, column) => {
|
||||
const product = state.productListLookupData.find(item => item.id === data[field]);
|
||||
return product ? `${product.numberName}` : '';
|
||||
},
|
||||
editType: 'dropdownedit',
|
||||
edit: {
|
||||
create: () => {
|
||||
const productElem = document.createElement('input');
|
||||
return productElem;
|
||||
},
|
||||
read: () => {
|
||||
return productObj.value;
|
||||
},
|
||||
destroy: function () {
|
||||
productObj.destroy();
|
||||
},
|
||||
write: function (args) {
|
||||
productObj = new ej.dropdowns.DropDownList({
|
||||
dataSource: state.productListLookupData,
|
||||
fields: { value: 'id', text: 'numberName' },
|
||||
value: args.rowData.productId,
|
||||
change: function (e) {
|
||||
if (movementObj) {
|
||||
movementObj.value = 1;
|
||||
}
|
||||
},
|
||||
placeholder: 'Select a Product',
|
||||
floatLabelType: 'Never'
|
||||
});
|
||||
productObj.appendTo(args.element);
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
field: 'movement',
|
||||
headerText: 'Movement',
|
||||
width: 200,
|
||||
validationRules: {
|
||||
required: true,
|
||||
custom: [(args) => {
|
||||
return args['value'] > 0;
|
||||
}, 'Must be a positive number and not zero']
|
||||
},
|
||||
type: 'number', format: 'N2', textAlign: 'Right',
|
||||
edit: {
|
||||
create: () => {
|
||||
const movementElem = document.createElement('input');
|
||||
return movementElem;
|
||||
},
|
||||
read: () => {
|
||||
return movementObj.value;
|
||||
},
|
||||
destroy: function () {
|
||||
movementObj.destroy();
|
||||
},
|
||||
write: function (args) {
|
||||
movementObj = new ej.inputs.NumericTextBox({
|
||||
value: args.rowData.movement ?? 0,
|
||||
});
|
||||
movementObj.appendTo(args.element);
|
||||
}
|
||||
}
|
||||
},
|
||||
],
|
||||
toolbar: [
|
||||
'ExcelExport',
|
||||
{ type: 'Separator' },
|
||||
'Add', 'Edit', 'Delete', 'Update', 'Cancel',
|
||||
],
|
||||
beforeDataBound: () => { },
|
||||
dataBound: function () { },
|
||||
excelExportComplete: () => { },
|
||||
rowSelected: () => {
|
||||
if (secondaryGrid.obj.getSelectedRecords().length == 1) {
|
||||
secondaryGrid.obj.toolbarModule.enableItems(['Edit'], true);
|
||||
} else {
|
||||
secondaryGrid.obj.toolbarModule.enableItems(['Edit'], false);
|
||||
}
|
||||
},
|
||||
rowDeselected: () => {
|
||||
if (secondaryGrid.obj.getSelectedRecords().length == 1) {
|
||||
secondaryGrid.obj.toolbarModule.enableItems(['Edit'], true);
|
||||
} else {
|
||||
secondaryGrid.obj.toolbarModule.enableItems(['Edit'], false);
|
||||
}
|
||||
},
|
||||
rowSelecting: () => {
|
||||
if (secondaryGrid.obj.getSelectedRecords().length) {
|
||||
secondaryGrid.obj.clearSelection();
|
||||
}
|
||||
},
|
||||
toolbarClick: (args) => {
|
||||
if (args.item.id === 'SecondaryGrid_excelexport') {
|
||||
secondaryGrid.obj.excelExport();
|
||||
}
|
||||
},
|
||||
actionComplete: async (args) => {
|
||||
if (args.requestType === 'save' && args.action === 'add') {
|
||||
try {
|
||||
const response = await services.createSecondaryData(state.id, args.data.warehouseId, args.data.productId, args.data.movement, StorageManager.getUserId());
|
||||
await methods.populateSecondaryData(state.id);
|
||||
secondaryGrid.refresh();
|
||||
if (response.data.code === 200) {
|
||||
Swal.fire({
|
||||
icon: 'success',
|
||||
title: 'Save Successful',
|
||||
timer: 2000,
|
||||
showConfirmButton: false
|
||||
});
|
||||
} else {
|
||||
Swal.fire({
|
||||
icon: 'error',
|
||||
title: 'Save Failed',
|
||||
text: response.data.message ?? 'Please check your data.',
|
||||
confirmButtonText: 'Try Again'
|
||||
});
|
||||
}
|
||||
} catch (error) {
|
||||
Swal.fire({
|
||||
icon: 'error',
|
||||
title: 'An Error Occurred',
|
||||
text: error.response?.data?.message ?? 'Please try again.',
|
||||
confirmButtonText: 'OK'
|
||||
});
|
||||
}
|
||||
}
|
||||
if (args.requestType === 'save' && args.action === 'edit') {
|
||||
try {
|
||||
const response = await services.updateSecondaryData(args.data.id, args.data.warehouseId, args.data.productId, args.data.movement, StorageManager.getUserId());
|
||||
await methods.populateSecondaryData(state.id);
|
||||
secondaryGrid.refresh();
|
||||
if (response.data.code === 200) {
|
||||
Swal.fire({
|
||||
icon: 'success',
|
||||
title: 'Update Successful',
|
||||
timer: 2000,
|
||||
showConfirmButton: false
|
||||
});
|
||||
} else {
|
||||
Swal.fire({
|
||||
icon: 'error',
|
||||
title: 'Update Failed',
|
||||
text: response.data.message ?? 'Please check your data.',
|
||||
confirmButtonText: 'Try Again'
|
||||
});
|
||||
}
|
||||
} catch (error) {
|
||||
Swal.fire({
|
||||
icon: 'error',
|
||||
title: 'An Error Occurred',
|
||||
text: error.response?.data?.message ?? 'Please try again.',
|
||||
confirmButtonText: 'OK'
|
||||
});
|
||||
}
|
||||
}
|
||||
if (args.requestType === 'delete') {
|
||||
try {
|
||||
const response = await services.deleteSecondaryData(args.data[0].id, StorageManager.getUserId());
|
||||
await methods.populateSecondaryData(state.id);
|
||||
secondaryGrid.refresh();
|
||||
if (response.data.code === 200) {
|
||||
Swal.fire({
|
||||
icon: 'success',
|
||||
title: 'Delete Successful',
|
||||
timer: 2000,
|
||||
showConfirmButton: false
|
||||
});
|
||||
} else {
|
||||
Swal.fire({
|
||||
icon: 'error',
|
||||
title: 'Delete Failed',
|
||||
text: response.data.message ?? 'Please check your data.',
|
||||
confirmButtonText: 'Try Again'
|
||||
});
|
||||
}
|
||||
} catch (error) {
|
||||
Swal.fire({
|
||||
icon: 'error',
|
||||
title: 'An Error Occurred',
|
||||
text: error.response?.data?.message ?? 'Please try again.',
|
||||
confirmButtonText: 'OK'
|
||||
});
|
||||
}
|
||||
}
|
||||
methods.refreshSummary();
|
||||
}
|
||||
});
|
||||
secondaryGrid.obj.appendTo(secondaryGridRef.value);
|
||||
|
||||
},
|
||||
refresh: () => {
|
||||
secondaryGrid.obj.setProperties({ dataSource: state.secondaryData });
|
||||
}
|
||||
};
|
||||
|
||||
const mainModal = {
|
||||
obj: null,
|
||||
create: () => {
|
||||
mainModal.obj = new bootstrap.Modal(mainModalRef.value, {
|
||||
backdrop: 'static',
|
||||
keyboard: false
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
return {
|
||||
mainGridRef,
|
||||
mainModalRef,
|
||||
secondaryGridRef,
|
||||
numberRef,
|
||||
adjustmentDateRef,
|
||||
statusRef,
|
||||
state,
|
||||
handler,
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
Vue.createApp(App).mount('#app');
|
||||
@@ -0,0 +1,204 @@
|
||||
@page
|
||||
@attribute [Authorize(Roles = "NegativeAdjustments")]
|
||||
@{
|
||||
ViewData["Title"] = "Negative Adjustment PDF";
|
||||
}
|
||||
|
||||
<div id="app" class="row">
|
||||
<div class="col-12">
|
||||
<div class="print-indicator" v-cloak>
|
||||
<div class="content-wrapper">
|
||||
<div>
|
||||
<button id="download-pdf" class="btn btn-danger d-flex align-items-center" v-on:click="handler.downloadPDF" v-bind:disabled="state.isDownloading">
|
||||
<span class="spinner-border spinner-border-sm me-2" role="status" aria-hidden="true" v-if="state.isDownloading"></span>
|
||||
<span class="button-text" v-if="!state.isDownloading">
|
||||
<i class="bi bi-file-earmark-pdf-fill me-2"></i> Download PDF
|
||||
</span>
|
||||
</button>
|
||||
</div>
|
||||
<div id="content" class="print-area">
|
||||
<div class="company-info">
|
||||
<h2>{{ state.company.name }}</h2>
|
||||
<p>{{ state.companyAddress }}</p>
|
||||
<p>Email: {{ state.company.emailAddress }} | Phone: {{ state.company.phoneNumber }}</p>
|
||||
</div>
|
||||
|
||||
<h1>Negative Adjustment</h1>
|
||||
|
||||
<div class="info-container">
|
||||
<table class="details-table">
|
||||
<tr>
|
||||
<th colspan="2">Adjustment Information</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>Number:</strong></td>
|
||||
<td>{{ state.number }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>Date:</strong></td>
|
||||
<td>{{ state.date }}</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<table class="product-table" border="1" style="width: 100%; border-collapse: collapse;">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Warehouse</th>
|
||||
<th>Product</th>
|
||||
<th>Movement</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-for="item in state.mappedItems" :key="item.product + item.warehouse">
|
||||
<td>{{ item.warehouse }}</td>
|
||||
<td>{{ item.product }}</td>
|
||||
<td>{{ item.movement }}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<div class="summary">
|
||||
<div class="column"></div>
|
||||
<div class="column">
|
||||
<table style="width: 100%; border-collapse: collapse; margin-top: 20px;">
|
||||
<tr>
|
||||
<td style="font-weight: bold; font-size: 1.2em;">Total Movement:</td>
|
||||
<td style="text-align: right; font-weight: bold; font-size: 1.2em; color: #2c3e50;">
|
||||
{{ state.movementTotal }}
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- CSS -->
|
||||
<style>
|
||||
.print-indicator {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: flex-start;
|
||||
height: 100vh;
|
||||
background-color: #f8f9fa;
|
||||
position: relative;
|
||||
overflow-y: auto;
|
||||
padding: 30px;
|
||||
}
|
||||
|
||||
|
||||
.content-wrapper {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
gap: 20px;
|
||||
}
|
||||
|
||||
.print-area {
|
||||
width: 210mm;
|
||||
padding: 10mm;
|
||||
background-color: white;
|
||||
border: 1px dashed #cccccc;
|
||||
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
|
||||
#download-pdf {
|
||||
padding: 10px 20px;
|
||||
font-size: 16px;
|
||||
border-radius: 5px;
|
||||
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
|
||||
}
|
||||
|
||||
.company-info {
|
||||
text-align: center;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.company-info h2 {
|
||||
font-size: 24px;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.company-info p {
|
||||
margin: 5px 0;
|
||||
font-size: 14px;
|
||||
color: #555;
|
||||
}
|
||||
|
||||
h1 {
|
||||
text-align: center;
|
||||
margin-bottom: 20px;
|
||||
font-size: 28px;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.info-container {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
margin-bottom: 20px;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.details-table {
|
||||
flex: 1;
|
||||
padding: 5px 8px;
|
||||
border: 1px solid #ccc;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.details-table th, .details-table td {
|
||||
padding: 5px 10px;
|
||||
border: 1px solid #ccc;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
|
||||
.details-table th {
|
||||
background-color: #f2f2f2;
|
||||
text-align: left;
|
||||
height: 35px;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
|
||||
|
||||
.product-table {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
margin-bottom: 20px;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.product-table th, .product-table td {
|
||||
padding: 8px;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.product-table th {
|
||||
background-color: #f2f2f2;
|
||||
}
|
||||
|
||||
.summary {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
margin-top: 20px;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.summary .column {
|
||||
width: 48%;
|
||||
}
|
||||
|
||||
.summary p {
|
||||
margin: 5px 0;
|
||||
text-align: right;
|
||||
}
|
||||
</style>
|
||||
|
||||
@section scripts {
|
||||
<script src="~/FrontEnd/Pages/NegativeAdjustments/NegativeAdjustmentPdf.cshtml.js"></script>
|
||||
}
|
||||
+128
@@ -0,0 +1,128 @@
|
||||
const App = {
|
||||
setup() {
|
||||
const state = Vue.reactive({
|
||||
company: {
|
||||
name: '',
|
||||
emailAddress: '',
|
||||
phoneNumber: '',
|
||||
street: '',
|
||||
city: '',
|
||||
state: '',
|
||||
zipCode: '',
|
||||
country: ''
|
||||
},
|
||||
companyAddress: '',
|
||||
number: '',
|
||||
date: '',
|
||||
pdfTransactionList: [],
|
||||
isDownloading: false,
|
||||
mappedItems: [],
|
||||
movementTotal: 0
|
||||
});
|
||||
|
||||
const services = {
|
||||
getPDFData: async (id) => {
|
||||
try {
|
||||
const response = await AxiosManager.get('/NegativeAdjustment/GetNegativeAdjustmentSingle?id=' + id, {});
|
||||
return response;
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
const methods = {
|
||||
populatePDFData: async (id) => {
|
||||
const response = await services.getPDFData(id);
|
||||
state.pdfData = response?.data?.content?.data || {};
|
||||
state.pdfTransactionList = response?.data?.content?.transactionList || [];
|
||||
methods.bindPDFControls();
|
||||
},
|
||||
|
||||
bindPDFControls: () => {
|
||||
const company = StorageManager.getCompany() || state.company;
|
||||
state.company = {
|
||||
name: company.name,
|
||||
emailAddress: company.emailAddress,
|
||||
phoneNumber: company.phoneNumber,
|
||||
street: company.street,
|
||||
city: company.city,
|
||||
state: company.state,
|
||||
zipCode: company.zipCode,
|
||||
country: company.country
|
||||
};
|
||||
state.companyAddress = [
|
||||
company.street,
|
||||
company.city,
|
||||
company.state,
|
||||
company.zipCode,
|
||||
company.country
|
||||
].filter(Boolean).join(', ');
|
||||
|
||||
const pdfData = state.pdfData;
|
||||
state.number = pdfData?.number || '';
|
||||
state.date = DateFormatManager.formatToLocale(pdfData?.adjustmentDate) || '';
|
||||
|
||||
state.mappedItems = (state.pdfTransactionList || []).map(item => ({
|
||||
warehouse: item.warehouse?.name || '',
|
||||
product: `${item.product?.number || ''} ${item.product?.name || ''}`.trim(),
|
||||
movement: item.movement || 0,
|
||||
}));
|
||||
|
||||
let movementTotal = (state.pdfTransactionList || []).reduce((sum, item) => sum + (item.movement || 0), 0);
|
||||
state.movementTotal = NumberFormatManager.formatToLocale(movementTotal);
|
||||
}
|
||||
};
|
||||
|
||||
const handler = {
|
||||
downloadPDF: async () => {
|
||||
state.isDownloading = true;
|
||||
await new Promise(resolve => setTimeout(resolve, 500));
|
||||
|
||||
try {
|
||||
const { jsPDF } = window.jspdf;
|
||||
const doc = new jsPDF('p', 'mm', 'a4');
|
||||
const content = document.getElementById('content');
|
||||
|
||||
await html2canvas(content, {
|
||||
scale: 2,
|
||||
useCORS: true
|
||||
}).then(canvas => {
|
||||
const imgData = canvas.toDataURL('image/png');
|
||||
const imgWidth = 210;
|
||||
const pageHeight = 297;
|
||||
const imgHeight = (canvas.height * imgWidth) / canvas.width;
|
||||
let position = 0;
|
||||
|
||||
doc.addImage(imgData, 'PNG', 0, position, imgWidth, imgHeight);
|
||||
doc.save(`negative-adjustment-${state.number || 'unknown'}.pdf`);
|
||||
});
|
||||
} catch (error) {
|
||||
console.error('Error generating PDF:', error);
|
||||
} finally {
|
||||
state.isDownloading = false;
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
Vue.onMounted(async () => {
|
||||
try {
|
||||
await SecurityManager.authorizePage(['NegativeAdjustments']);
|
||||
var urlParams = new URLSearchParams(window.location.search);
|
||||
var id = urlParams.get('id');
|
||||
await methods.populatePDFData(id ?? '');
|
||||
} catch (e) {
|
||||
console.error('page init error:', e);
|
||||
} finally {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
return {
|
||||
state,
|
||||
handler,
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
Vue.createApp(App).mount('#app');
|
||||
@@ -0,0 +1,19 @@
|
||||
@page
|
||||
@attribute [Authorize(Roles = "NumberSequences")]
|
||||
@{
|
||||
ViewData["Title"] = "Number Sequence List";
|
||||
}
|
||||
|
||||
<div id="app" v-cloak>
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<div class="grid-container">
|
||||
<div ref="mainGridRef"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@section scripts {
|
||||
<script src="~/FrontEnd/Pages/NumberSequences/NumberSequenceList.cshtml.js"></script>
|
||||
}
|
||||
+114
@@ -0,0 +1,114 @@
|
||||
const App = {
|
||||
setup() {
|
||||
const state = Vue.reactive({
|
||||
mainData: [],
|
||||
deleteMode: false
|
||||
});
|
||||
|
||||
const mainGridRef = Vue.ref(null);
|
||||
|
||||
const services = {
|
||||
getMainData: async () => {
|
||||
try {
|
||||
const response = await AxiosManager.get('/NumberSequence/GetNumberSequenceList', {});
|
||||
return response;
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
const methods = {
|
||||
populateMainData: async () => {
|
||||
const response = await services.getMainData();
|
||||
const formattedData = response?.data?.content?.data.map(item => ({
|
||||
...item,
|
||||
createdAtUtc: new Date(item.createdAtUtc)
|
||||
}));
|
||||
state.mainData = formattedData;
|
||||
},
|
||||
};
|
||||
|
||||
const mainGrid = {
|
||||
obj: null,
|
||||
create: async (dataSource) => {
|
||||
mainGrid.obj = new ej.grids.Grid({
|
||||
height: '240px',
|
||||
dataSource: dataSource,
|
||||
allowFiltering: true,
|
||||
allowSorting: true,
|
||||
allowSelection: true,
|
||||
allowGrouping: true,
|
||||
allowTextWrap: true,
|
||||
allowResizing: true,
|
||||
allowPaging: true,
|
||||
allowExcelExport: true,
|
||||
filterSettings: { type: 'CheckBox' },
|
||||
sortSettings: { columns: [{ field: 'createdAtUtc', direction: 'Descending' }] },
|
||||
pageSettings: { currentPage: 1, pageSize: 50, pageSizes: ["10", "20", "50", "100", "200", "All"] },
|
||||
selectionSettings: { persistSelection: true, type: 'Single' },
|
||||
autoFit: true,
|
||||
showColumnMenu: true,
|
||||
gridLines: 'Horizontal',
|
||||
columns: [
|
||||
{ type: 'checkbox', width: 60 },
|
||||
{
|
||||
field: 'id', isPrimaryKey: true, headerText: 'Id', visible: false
|
||||
},
|
||||
{ field: 'entityName', headerText: 'Entity Name', width: 200, minWidth: 200 },
|
||||
{ field: 'prefix', headerText: 'Prefix', width: 100, minWidth: 100 },
|
||||
{ field: 'suffix', headerText: 'Suffix', width: 100, minWidth: 100 },
|
||||
{ field: 'lastUsedCount', headerText: 'Last Used Count', width: 100, minWidth: 100 },
|
||||
{ field: 'createdAtUtc', headerText: 'Created At UTC', width: 150, format: 'yyyy-MM-dd HH:mm' }
|
||||
],
|
||||
toolbar: [
|
||||
'ExcelExport', 'Search',
|
||||
{ type: 'Separator' },
|
||||
],
|
||||
beforeDataBound: () => { },
|
||||
dataBound: function () {
|
||||
mainGrid.obj.autoFitColumns(['entityName', 'prefix', 'suffix', 'lastUsedCount', 'createdAtUtc']);
|
||||
},
|
||||
excelExportComplete: () => { },
|
||||
rowSelected: () => { },
|
||||
rowDeselected: () => { },
|
||||
rowSelecting: () => {
|
||||
if (mainGrid.obj.getSelectedRecords().length) {
|
||||
mainGrid.obj.clearSelection();
|
||||
}
|
||||
},
|
||||
toolbarClick: (args) => {
|
||||
if (args.item.id === 'MainGrid_excelexport') {
|
||||
mainGrid.obj.excelExport();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
mainGrid.obj.appendTo(mainGridRef.value);
|
||||
},
|
||||
refresh: () => {
|
||||
mainGrid.obj.setProperties({ dataSource: state.mainData });
|
||||
}
|
||||
};
|
||||
|
||||
Vue.onMounted(async () => {
|
||||
try {
|
||||
await SecurityManager.authorizePage(['NumberSequences']);
|
||||
await SecurityManager.validateToken();
|
||||
await methods.populateMainData();
|
||||
await mainGrid.create(state.mainData);
|
||||
} catch (e) {
|
||||
console.error('page init error:', e);
|
||||
} finally {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
return {
|
||||
state,
|
||||
mainGridRef
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
Vue.createApp(App).mount('#app');
|
||||
@@ -0,0 +1,125 @@
|
||||
@page
|
||||
@attribute [Authorize(Roles = "PositiveAdjustments")]
|
||||
@{
|
||||
ViewData["Title"] = "Positive Adjustment List";
|
||||
}
|
||||
|
||||
<div id="app" v-cloak>
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<div class="grid-container">
|
||||
<div ref="mainGridRef"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="modal fade" ref="mainModalRef" id="MainModal" aria-hidden="true" tabindex="-1" data-bs-focus="false" data-bs-backdrop="static">
|
||||
<div class="modal-dialog modal-dialog-centered modal-xl">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title">{{ state.mainTitle }}</h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<input type="hidden" v-model="state.id" id="Id" name="Id" />
|
||||
<form>
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<h5>Main Info</h5>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="row mb-2">
|
||||
<div class="col-md-6">
|
||||
<label for="AdjustmentDate">Adjustment Date</label>
|
||||
<input ref="adjustmentDateRef">
|
||||
<label class="text-danger">{{ state.errors.adjustmentDate }}</label>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<label for="Number">Number</label>
|
||||
<input ref="numberRef" v-model="state.number" readonly>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mb-2">
|
||||
<div class="col-md-6">
|
||||
<label for="Status">Status</label>
|
||||
<div ref="statusRef"></div>
|
||||
<label class="text-danger">{{ state.errors.status }}</label>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mb-2">
|
||||
<div class="col-md-12">
|
||||
<label for="Description">Description</label>
|
||||
<textarea class="form-control" rows="3" v-model="state.description"></textarea>
|
||||
<label class="text-danger">{{ state.errors.description }}</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
<div id="ComplexDiv" :style="{ display: state.showComplexDiv ? 'block' : 'none' }">
|
||||
<div class="row mt-3">
|
||||
<div class="col-md-12">
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<h5>Delivery Item</h5>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<div class="grid-container">
|
||||
<div ref="secondaryGridRef"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mt-4">
|
||||
<div class="col-md-12">
|
||||
<div class="card shadow-sm">
|
||||
<div class="card-header text-white">
|
||||
<h5 class="mb-0">Summary</h5>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="row justify-content-end">
|
||||
<div class="col-md-6">
|
||||
<div class="d-flex justify-content-between py-2">
|
||||
<span class="fw-bold">Total Movement</span>
|
||||
<span id="TotalMovement" class="fw-bold text-success">{{ state.totalMovementFormatted }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
|
||||
<button type="button"
|
||||
id="MainSaveButton"
|
||||
class="btn"
|
||||
v-bind:class="state.deleteMode ? 'btn-danger' : 'btn-primary'"
|
||||
v-on:click="handler.handleSubmit"
|
||||
v-bind:disabled="state.isSubmitting">
|
||||
<span class="spinner-border spinner-border-sm me-2" v-if="state.isSubmitting" role="status" aria-hidden="true"></span>
|
||||
<span v-if="!state.isSubmitting">{{ state.deleteMode ? 'Delete' : 'Save' }}</span>
|
||||
<span v-else>{{ state.deleteMode ? 'Deleting...' : 'Saving...' }}</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@section scripts {
|
||||
<script src="~/FrontEnd/Pages/PositiveAdjustments/PositiveAdjustmentList.cshtml.js"></script>
|
||||
}
|
||||
+799
@@ -0,0 +1,799 @@
|
||||
const App = {
|
||||
setup() {
|
||||
const state = Vue.reactive({
|
||||
mainData: [],
|
||||
deleteMode: false,
|
||||
positiveAdjustmentStatusListLookupData: [],
|
||||
secondaryData: [],
|
||||
productListLookupData: [],
|
||||
warehouseListLookupData: [],
|
||||
mainTitle: null,
|
||||
id: '',
|
||||
number: '',
|
||||
adjustmentDate: '',
|
||||
description: '',
|
||||
status: null,
|
||||
errors: {
|
||||
adjustmentDate: '',
|
||||
status: '',
|
||||
description: ''
|
||||
},
|
||||
showComplexDiv: false,
|
||||
isSubmitting: false,
|
||||
totalMovementFormatted: '0.00'
|
||||
});
|
||||
|
||||
const mainGridRef = Vue.ref(null);
|
||||
const mainModalRef = Vue.ref(null);
|
||||
const secondaryGridRef = Vue.ref(null);
|
||||
const adjustmentDateRef = Vue.ref(null);
|
||||
const statusRef = Vue.ref(null);
|
||||
const numberRef = Vue.ref(null);
|
||||
|
||||
const validateForm = function () {
|
||||
state.errors.adjustmentDate = '';
|
||||
state.errors.status = '';
|
||||
|
||||
let isValid = true;
|
||||
|
||||
if (!state.adjustmentDate) {
|
||||
state.errors.adjustmentDate = 'Adjustment date is required.';
|
||||
isValid = false;
|
||||
}
|
||||
if (!state.status) {
|
||||
state.errors.status = 'Status is required.';
|
||||
isValid = false;
|
||||
}
|
||||
|
||||
return isValid;
|
||||
};
|
||||
|
||||
const resetFormState = () => {
|
||||
state.id = '';
|
||||
state.number = '';
|
||||
state.adjustmentDate = '';
|
||||
state.description = '';
|
||||
state.status = null;
|
||||
state.errors = {
|
||||
adjustmentDate: '',
|
||||
status: '',
|
||||
description: ''
|
||||
};
|
||||
state.secondaryData = [];
|
||||
};
|
||||
|
||||
const adjustmentDatePicker = {
|
||||
obj: null,
|
||||
create: () => {
|
||||
adjustmentDatePicker.obj = new ej.calendars.DatePicker({
|
||||
placeholder: 'Select Date',
|
||||
format: 'yyyy-MM-dd',
|
||||
value: state.adjustmentDate ? new Date(state.adjustmentDate) : null,
|
||||
change: (e) => {
|
||||
state.adjustmentDate = e.value;
|
||||
}
|
||||
});
|
||||
adjustmentDatePicker.obj.appendTo(adjustmentDateRef.value);
|
||||
},
|
||||
refresh: () => {
|
||||
if (adjustmentDatePicker.obj) {
|
||||
adjustmentDatePicker.obj.value = state.adjustmentDate ? new Date(state.adjustmentDate) : null;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Vue.watch(
|
||||
() => state.adjustmentDate,
|
||||
(newVal, oldVal) => {
|
||||
adjustmentDatePicker.refresh();
|
||||
state.errors.adjustmentDate = '';
|
||||
}
|
||||
);
|
||||
|
||||
const numberText = {
|
||||
obj: null,
|
||||
create: () => {
|
||||
numberText.obj = new ej.inputs.TextBox({
|
||||
placeholder: '[auto]',
|
||||
});
|
||||
numberText.obj.appendTo(numberRef.value);
|
||||
}
|
||||
};
|
||||
|
||||
const positiveAdjustmentStatusListLookup = {
|
||||
obj: null,
|
||||
create: () => {
|
||||
if (state.positiveAdjustmentStatusListLookupData && Array.isArray(state.positiveAdjustmentStatusListLookupData)) {
|
||||
positiveAdjustmentStatusListLookup.obj = new ej.dropdowns.DropDownList({
|
||||
dataSource: state.positiveAdjustmentStatusListLookupData,
|
||||
fields: { value: 'id', text: 'name' },
|
||||
placeholder: 'Select Status',
|
||||
allowFiltering: false,
|
||||
change: (e) => {
|
||||
state.status = e.value;
|
||||
}
|
||||
});
|
||||
positiveAdjustmentStatusListLookup.obj.appendTo(statusRef.value);
|
||||
}
|
||||
},
|
||||
refresh: () => {
|
||||
if (positiveAdjustmentStatusListLookup.obj) {
|
||||
positiveAdjustmentStatusListLookup.obj.value = state.status
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
Vue.watch(
|
||||
() => state.status,
|
||||
(newVal, oldVal) => {
|
||||
positiveAdjustmentStatusListLookup.refresh();
|
||||
state.errors.status = '';
|
||||
}
|
||||
);
|
||||
|
||||
const services = {
|
||||
getMainData: async () => {
|
||||
try {
|
||||
const response = await AxiosManager.get('/PositiveAdjustment/GetPositiveAdjustmentList', {});
|
||||
return response;
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
},
|
||||
createMainData: async (adjustmentDate, description, status, createdById) => {
|
||||
try {
|
||||
const response = await AxiosManager.post('/PositiveAdjustment/CreatePositiveAdjustment', {
|
||||
adjustmentDate, description, status, createdById
|
||||
});
|
||||
return response;
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
},
|
||||
updateMainData: async (id, adjustmentDate, description, status, updatedById) => {
|
||||
try {
|
||||
const response = await AxiosManager.post('/PositiveAdjustment/UpdatePositiveAdjustment', {
|
||||
id, adjustmentDate, description, status, updatedById
|
||||
});
|
||||
return response;
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
},
|
||||
deleteMainData: async (id, deletedById) => {
|
||||
try {
|
||||
const response = await AxiosManager.post('/PositiveAdjustment/DeletePositiveAdjustment', {
|
||||
id, deletedById
|
||||
});
|
||||
return response;
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
},
|
||||
getPositiveAdjustmentStatusListLookupData: async () => {
|
||||
try {
|
||||
const response = await AxiosManager.get('/PositiveAdjustment/GetPositiveAdjustmentStatusList', {});
|
||||
return response;
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
},
|
||||
getSecondaryData: async (moduleId) => {
|
||||
try {
|
||||
const response = await AxiosManager.get('/InventoryTransaction/PositiveAdjustmentGetInvenTransList?moduleId=' + moduleId, {});
|
||||
return response;
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
},
|
||||
createSecondaryData: async (moduleId, warehouseId, productId, movement, createdById) => {
|
||||
try {
|
||||
const response = await AxiosManager.post('/InventoryTransaction/PositiveAdjustmentCreateInvenTrans', {
|
||||
moduleId, warehouseId, productId, movement, createdById
|
||||
});
|
||||
return response;
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
},
|
||||
updateSecondaryData: async (id, warehouseId, productId, movement, updatedById) => {
|
||||
try {
|
||||
const response = await AxiosManager.post('/InventoryTransaction/PositiveAdjustmentUpdateInvenTrans', {
|
||||
id, warehouseId, productId, movement, updatedById
|
||||
});
|
||||
return response;
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
},
|
||||
deleteSecondaryData: async (id, deletedById) => {
|
||||
try {
|
||||
const response = await AxiosManager.post('/InventoryTransaction/PositiveAdjustmentDeleteInvenTrans', {
|
||||
id, deletedById
|
||||
});
|
||||
return response;
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
},
|
||||
getProductListLookupData: async () => {
|
||||
try {
|
||||
const response = await AxiosManager.get('/Product/GetProductList', {});
|
||||
return response;
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
},
|
||||
getWarehouseListLookupData: async () => {
|
||||
try {
|
||||
const response = await AxiosManager.get('/Warehouse/GetWarehouseList', {});
|
||||
return response;
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
const methods = {
|
||||
populateMainData: async () => {
|
||||
const response = await services.getMainData();
|
||||
state.mainData = response?.data?.content?.data.map(item => ({
|
||||
...item,
|
||||
adjustmentDate: new Date(item.adjustmentDate),
|
||||
createdAtUtc: new Date(item.createdAtUtc)
|
||||
}));
|
||||
},
|
||||
populatePositiveAdjustmentStatusListLookupData: async () => {
|
||||
const response = await services.getPositiveAdjustmentStatusListLookupData();
|
||||
state.positiveAdjustmentStatusListLookupData = response?.data?.content?.data;
|
||||
},
|
||||
populateProductListLookupData: async () => {
|
||||
const response = await services.getProductListLookupData();
|
||||
state.productListLookupData = response?.data?.content?.data
|
||||
.filter(product => product.physical === true)
|
||||
.map(product => ({
|
||||
...product,
|
||||
numberName: `${product.number} - ${product.name}`
|
||||
})) || [];
|
||||
},
|
||||
populateWarehouseListLookupData: async () => {
|
||||
const response = await services.getWarehouseListLookupData();
|
||||
state.warehouseListLookupData = response?.data?.content?.data.filter(warehouse => warehouse.systemWarehouse === false) || [];
|
||||
},
|
||||
populateSecondaryData: async (positiveAdjustmentId) => {
|
||||
try {
|
||||
const response = await services.getSecondaryData(positiveAdjustmentId);
|
||||
state.secondaryData = response?.data?.content?.data.map(item => ({
|
||||
...item,
|
||||
createdAtUtc: new Date(item.createdAtUtc)
|
||||
}));
|
||||
methods.refreshSummary();
|
||||
} catch (error) {
|
||||
state.secondaryData = [];
|
||||
}
|
||||
},
|
||||
refreshSummary: () => {
|
||||
const totalMovement = state.secondaryData.reduce((sum, record) => sum + (record.movement ?? 0), 0);
|
||||
state.totalMovementFormatted = NumberFormatManager.formatToLocale(totalMovement);
|
||||
},
|
||||
onMainModalHidden: () => {
|
||||
state.errors.adjustmentDate = '';
|
||||
state.errors.status = '';
|
||||
}
|
||||
};
|
||||
|
||||
const handler = {
|
||||
handleSubmit: async function () {
|
||||
try {
|
||||
state.isSubmitting = true;
|
||||
await new Promise(resolve => setTimeout(resolve, 300));
|
||||
|
||||
if (!validateForm()) {
|
||||
return;
|
||||
}
|
||||
|
||||
const response = state.id === ''
|
||||
? await services.createMainData(state.adjustmentDate, state.description, state.status, StorageManager.getUserId())
|
||||
: state.deleteMode
|
||||
? await services.deleteMainData(state.id, StorageManager.getUserId())
|
||||
: await services.updateMainData(state.id, state.adjustmentDate, state.description, state.status, StorageManager.getUserId());
|
||||
|
||||
if (response.data.code === 200) {
|
||||
await methods.populateMainData();
|
||||
mainGrid.refresh();
|
||||
|
||||
if (!state.deleteMode) {
|
||||
state.mainTitle = 'Edit Positive Adjustment';
|
||||
state.id = response?.data?.content?.data.id ?? '';
|
||||
state.number = response?.data?.content?.data.number ?? '';
|
||||
await methods.populateSecondaryData(state.id);
|
||||
secondaryGrid.refresh();
|
||||
state.showComplexDiv = true;
|
||||
|
||||
Swal.fire({
|
||||
icon: 'success',
|
||||
title: 'Save Successful',
|
||||
timer: 2000,
|
||||
showConfirmButton: false
|
||||
});
|
||||
|
||||
} else {
|
||||
Swal.fire({
|
||||
icon: 'success',
|
||||
title: 'Delete Successful',
|
||||
text: 'Form will be closed...',
|
||||
timer: 2000,
|
||||
showConfirmButton: false
|
||||
});
|
||||
setTimeout(() => {
|
||||
mainModal.obj.hide();
|
||||
resetFormState();
|
||||
}, 2000);
|
||||
}
|
||||
|
||||
} else {
|
||||
Swal.fire({
|
||||
icon: 'error',
|
||||
title: state.deleteMode ? 'Delete Failed' : 'Save Failed',
|
||||
text: response.data.message ?? 'Please check your data.',
|
||||
confirmButtonText: 'Try Again'
|
||||
});
|
||||
}
|
||||
|
||||
} catch (error) {
|
||||
Swal.fire({
|
||||
icon: 'error',
|
||||
title: 'An Error Occurred',
|
||||
text: error.response?.data?.message ?? 'Please try again.',
|
||||
confirmButtonText: 'OK'
|
||||
});
|
||||
} finally {
|
||||
state.isSubmitting = false;
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
Vue.onMounted(async () => {
|
||||
try {
|
||||
await SecurityManager.authorizePage(['PositiveAdjustments']);
|
||||
await SecurityManager.validateToken();
|
||||
|
||||
await methods.populateMainData();
|
||||
await mainGrid.create(state.mainData);
|
||||
|
||||
mainModal.create();
|
||||
mainModalRef.value?.addEventListener('hidden.bs.modal', methods.onMainModalHidden);
|
||||
await methods.populatePositiveAdjustmentStatusListLookupData();
|
||||
numberText.create();
|
||||
adjustmentDatePicker.create();
|
||||
positiveAdjustmentStatusListLookup.create();
|
||||
|
||||
await secondaryGrid.create(state.secondaryData);
|
||||
await methods.populateProductListLookupData();
|
||||
await methods.populateWarehouseListLookupData();
|
||||
|
||||
} catch (e) {
|
||||
console.error('page init error:', e);
|
||||
} finally {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
Vue.onUnmounted(() => {
|
||||
mainModalRef.value?.removeEventListener('hidden.bs.modal', methods.onMainModalHidden);
|
||||
});
|
||||
|
||||
const mainGrid = {
|
||||
obj: null,
|
||||
create: async (dataSource) => {
|
||||
mainGrid.obj = new ej.grids.Grid({
|
||||
height: '240px',
|
||||
dataSource: dataSource,
|
||||
allowFiltering: true,
|
||||
allowSorting: true,
|
||||
allowSelection: true,
|
||||
allowGrouping: true,
|
||||
allowTextWrap: true,
|
||||
allowResizing: true,
|
||||
allowPaging: true,
|
||||
allowExcelExport: true,
|
||||
filterSettings: { type: 'CheckBox' },
|
||||
sortSettings: { columns: [{ field: 'createdAtUtc', direction: 'Descending' }] },
|
||||
pageSettings: { currentPage: 1, pageSize: 50, pageSizes: ["10", "20", "50", "100", "200", "All"] },
|
||||
selectionSettings: { persistSelection: true, type: 'Single' },
|
||||
autoFit: true,
|
||||
showColumnMenu: true,
|
||||
gridLines: 'Horizontal',
|
||||
columns: [
|
||||
{ type: 'checkbox', width: 60 },
|
||||
{
|
||||
field: 'id', isPrimaryKey: true, headerText: 'Id', visible: false
|
||||
},
|
||||
{ field: 'number', headerText: 'Number', width: 150, minWidth: 150 },
|
||||
{ field: 'adjustmentDate', headerText: 'Adjustment Date', width: 150, format: 'yyyy-MM-dd' },
|
||||
{ field: 'statusName', headerText: 'Status', width: 150, minWidth: 150 },
|
||||
{ field: 'createdAtUtc', headerText: 'Created At UTC', width: 150, format: 'yyyy-MM-dd HH:mm' }
|
||||
],
|
||||
toolbar: [
|
||||
'ExcelExport', 'Search',
|
||||
{ type: 'Separator' },
|
||||
{ text: 'Add', tooltipText: 'Add', prefixIcon: 'e-add', id: 'AddCustom' },
|
||||
{ text: 'Edit', tooltipText: 'Edit', prefixIcon: 'e-edit', id: 'EditCustom' },
|
||||
{ text: 'Delete', tooltipText: 'Delete', prefixIcon: 'e-delete', id: 'DeleteCustom' },
|
||||
{ type: 'Separator' },
|
||||
{ text: 'Print PDF', tooltipText: 'Print PDF', id: 'PrintPDFCustom' },
|
||||
],
|
||||
beforeDataBound: () => { },
|
||||
dataBound: function () {
|
||||
mainGrid.obj.toolbarModule.enableItems(['EditCustom', 'DeleteCustom', 'PrintPDFCustom'], false);
|
||||
mainGrid.obj.autoFitColumns(['number', 'adjustmentDate', 'statusName', 'createdAtUtc']);
|
||||
},
|
||||
excelExportComplete: () => { },
|
||||
rowSelected: () => {
|
||||
if (mainGrid.obj.getSelectedRecords().length == 1) {
|
||||
mainGrid.obj.toolbarModule.enableItems(['EditCustom', 'DeleteCustom', 'PrintPDFCustom'], true);
|
||||
} else {
|
||||
mainGrid.obj.toolbarModule.enableItems(['EditCustom', 'DeleteCustom', 'PrintPDFCustom'], false);
|
||||
}
|
||||
},
|
||||
rowDeselected: () => {
|
||||
if (mainGrid.obj.getSelectedRecords().length == 1) {
|
||||
mainGrid.obj.toolbarModule.enableItems(['EditCustom', 'DeleteCustom', 'PrintPDFCustom'], true);
|
||||
} else {
|
||||
mainGrid.obj.toolbarModule.enableItems(['EditCustom', 'DeleteCustom', 'PrintPDFCustom'], false);
|
||||
}
|
||||
},
|
||||
rowSelecting: () => {
|
||||
if (mainGrid.obj.getSelectedRecords().length) {
|
||||
mainGrid.obj.clearSelection();
|
||||
}
|
||||
},
|
||||
toolbarClick: async (args) => {
|
||||
if (args.item.id === 'MainGrid_excelexport') {
|
||||
mainGrid.obj.excelExport();
|
||||
}
|
||||
|
||||
if (args.item.id === 'AddCustom') {
|
||||
state.deleteMode = false;
|
||||
state.mainTitle = 'Add Positive Adjustment';
|
||||
resetFormState();
|
||||
state.showComplexDiv = false;
|
||||
mainModal.obj.show();
|
||||
}
|
||||
|
||||
if (args.item.id === 'EditCustom') {
|
||||
state.deleteMode = false;
|
||||
if (mainGrid.obj.getSelectedRecords().length) {
|
||||
const selectedRecord = mainGrid.obj.getSelectedRecords()[0];
|
||||
state.mainTitle = 'Edit Positive Adjustment';
|
||||
state.id = selectedRecord.id ?? '';
|
||||
state.number = selectedRecord.number ?? '';
|
||||
state.adjustmentDate = selectedRecord.adjustmentDate ? new Date(selectedRecord.adjustmentDate) : null;
|
||||
state.description = selectedRecord.description ?? '';
|
||||
state.status = String(selectedRecord.status ?? '');
|
||||
await methods.populateSecondaryData(selectedRecord.id);
|
||||
secondaryGrid.refresh();
|
||||
state.showComplexDiv = true;
|
||||
mainModal.obj.show();
|
||||
}
|
||||
}
|
||||
|
||||
if (args.item.id === 'DeleteCustom') {
|
||||
state.deleteMode = true;
|
||||
if (mainGrid.obj.getSelectedRecords().length) {
|
||||
const selectedRecord = mainGrid.obj.getSelectedRecords()[0];
|
||||
state.mainTitle = 'Delete Positive Adjustment?';
|
||||
state.id = selectedRecord.id ?? '';
|
||||
state.number = selectedRecord.number ?? '';
|
||||
state.adjustmentDate = selectedRecord.adjustmentDate ? new Date(selectedRecord.adjustmentDate) : null;
|
||||
state.description = selectedRecord.description ?? '';
|
||||
state.status = String(selectedRecord.status ?? '');
|
||||
await methods.populateSecondaryData(selectedRecord.id);
|
||||
secondaryGrid.refresh();
|
||||
state.showComplexDiv = false;
|
||||
mainModal.obj.show();
|
||||
}
|
||||
}
|
||||
|
||||
if (args.item.id === 'PrintPDFCustom') {
|
||||
if (mainGrid.obj.getSelectedRecords().length) {
|
||||
const selectedRecord = mainGrid.obj.getSelectedRecords()[0];
|
||||
window.open('/PositiveAdjustments/PositiveAdjustmentPdf?id=' + (selectedRecord.id ?? ''), '_blank');
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
mainGrid.obj.appendTo(mainGridRef.value);
|
||||
},
|
||||
refresh: () => {
|
||||
mainGrid.obj.setProperties({ dataSource: state.mainData });
|
||||
}
|
||||
};
|
||||
|
||||
const secondaryGrid = {
|
||||
obj: null,
|
||||
create: async (dataSource) => {
|
||||
secondaryGrid.obj = new ej.grids.Grid({
|
||||
height: 400,
|
||||
dataSource: dataSource,
|
||||
editSettings: { allowEditing: true, allowAdding: true, allowDeleting: true, showDeleteConfirmDialog: true, mode: 'Normal', allowEditOnDblClick: true },
|
||||
allowFiltering: false,
|
||||
allowSorting: true,
|
||||
allowSelection: true,
|
||||
allowGrouping: false,
|
||||
allowTextWrap: true,
|
||||
allowResizing: true,
|
||||
allowPaging: false,
|
||||
allowExcelExport: true,
|
||||
filterSettings: { type: 'CheckBox' },
|
||||
sortSettings: { columns: [{ field: 'warehouseName', direction: 'Descending' }] },
|
||||
pageSettings: { currentPage: 1, pageSize: 50, pageSizes: ["10", "20", "50", "100", "200", "All"] },
|
||||
selectionSettings: { persistSelection: true, type: 'Single' },
|
||||
autoFit: false,
|
||||
showColumnMenu: false,
|
||||
gridLines: 'Horizontal',
|
||||
columns: [
|
||||
{ type: 'checkbox', width: 60 },
|
||||
{
|
||||
field: 'id', isPrimaryKey: true, headerText: 'Id', visible: false
|
||||
},
|
||||
{
|
||||
field: 'warehouseId',
|
||||
headerText: 'Warehouse',
|
||||
width: 250,
|
||||
validationRules: { required: true },
|
||||
disableHtmlEncode: false,
|
||||
valueAccessor: (field, data, column) => {
|
||||
const warehouse = state.warehouseListLookupData.find(item => item.id === data[field]);
|
||||
return warehouse ? `${warehouse.name}` : '';
|
||||
},
|
||||
editType: 'dropdownedit',
|
||||
edit: {
|
||||
create: () => {
|
||||
const warehouseElem = document.createElement('input');
|
||||
return warehouseElem;
|
||||
},
|
||||
read: () => {
|
||||
return warehouseObj.value;
|
||||
},
|
||||
destroy: function () {
|
||||
warehouseObj.destroy();
|
||||
},
|
||||
write: function (args) {
|
||||
warehouseObj = new ej.dropdowns.DropDownList({
|
||||
dataSource: state.warehouseListLookupData,
|
||||
fields: { value: 'id', text: 'name' },
|
||||
value: args.rowData.warehouseId,
|
||||
placeholder: 'Select a Warehouse',
|
||||
floatLabelType: 'Never'
|
||||
});
|
||||
warehouseObj.appendTo(args.element);
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
field: 'productId',
|
||||
headerText: 'Product',
|
||||
width: 250,
|
||||
validationRules: { required: true },
|
||||
disableHtmlEncode: false,
|
||||
valueAccessor: (field, data, column) => {
|
||||
const product = state.productListLookupData.find(item => item.id === data[field]);
|
||||
return product ? `${product.numberName}` : '';
|
||||
},
|
||||
editType: 'dropdownedit',
|
||||
edit: {
|
||||
create: () => {
|
||||
const productElem = document.createElement('input');
|
||||
return productElem;
|
||||
},
|
||||
read: () => {
|
||||
return productObj.value;
|
||||
},
|
||||
destroy: function () {
|
||||
productObj.destroy();
|
||||
},
|
||||
write: function (args) {
|
||||
productObj = new ej.dropdowns.DropDownList({
|
||||
dataSource: state.productListLookupData,
|
||||
fields: { value: 'id', text: 'numberName' },
|
||||
value: args.rowData.productId,
|
||||
change: function (e) {
|
||||
if (movementObj) {
|
||||
movementObj.value = 1;
|
||||
}
|
||||
},
|
||||
placeholder: 'Select a Product',
|
||||
floatLabelType: 'Never'
|
||||
});
|
||||
productObj.appendTo(args.element);
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
field: 'movement',
|
||||
headerText: 'Movement',
|
||||
width: 200,
|
||||
validationRules: {
|
||||
required: true,
|
||||
custom: [(args) => {
|
||||
return args['value'] > 0;
|
||||
}, 'Must be a positive number and not zero']
|
||||
},
|
||||
type: 'number', format: 'N2', textAlign: 'Right',
|
||||
edit: {
|
||||
create: () => {
|
||||
const movementElem = document.createElement('input');
|
||||
return movementElem;
|
||||
},
|
||||
read: () => {
|
||||
return movementObj.value;
|
||||
},
|
||||
destroy: function () {
|
||||
movementObj.destroy();
|
||||
},
|
||||
write: function (args) {
|
||||
movementObj = new ej.inputs.NumericTextBox({
|
||||
value: args.rowData.movement ?? 0,
|
||||
});
|
||||
movementObj.appendTo(args.element);
|
||||
}
|
||||
}
|
||||
},
|
||||
],
|
||||
toolbar: [
|
||||
'ExcelExport',
|
||||
{ type: 'Separator' },
|
||||
'Add', 'Edit', 'Delete', 'Update', 'Cancel',
|
||||
],
|
||||
beforeDataBound: () => { },
|
||||
dataBound: function () { },
|
||||
excelExportComplete: () => { },
|
||||
rowSelected: () => {
|
||||
if (secondaryGrid.obj.getSelectedRecords().length == 1) {
|
||||
secondaryGrid.obj.toolbarModule.enableItems(['Edit'], true);
|
||||
} else {
|
||||
secondaryGrid.obj.toolbarModule.enableItems(['Edit'], false);
|
||||
}
|
||||
},
|
||||
rowDeselected: () => {
|
||||
if (secondaryGrid.obj.getSelectedRecords().length == 1) {
|
||||
secondaryGrid.obj.toolbarModule.enableItems(['Edit'], true);
|
||||
} else {
|
||||
secondaryGrid.obj.toolbarModule.enableItems(['Edit'], false);
|
||||
}
|
||||
},
|
||||
rowSelecting: () => {
|
||||
if (secondaryGrid.obj.getSelectedRecords().length) {
|
||||
secondaryGrid.obj.clearSelection();
|
||||
}
|
||||
},
|
||||
toolbarClick: (args) => {
|
||||
if (args.item.id === 'SecondaryGrid_excelexport') {
|
||||
secondaryGrid.obj.excelExport();
|
||||
}
|
||||
},
|
||||
actionComplete: async (args) => {
|
||||
if (args.requestType === 'save' && args.action === 'add') {
|
||||
try {
|
||||
const response = await services.createSecondaryData(state.id, args.data.warehouseId, args.data.productId, args.data.movement, StorageManager.getUserId());
|
||||
await methods.populateSecondaryData(state.id);
|
||||
secondaryGrid.refresh();
|
||||
if (response.data.code === 200) {
|
||||
Swal.fire({
|
||||
icon: 'success',
|
||||
title: 'Save Successful',
|
||||
timer: 2000,
|
||||
showConfirmButton: false
|
||||
});
|
||||
} else {
|
||||
Swal.fire({
|
||||
icon: 'error',
|
||||
title: 'Save Failed',
|
||||
text: response.data.message ?? 'Please check your data.',
|
||||
confirmButtonText: 'Try Again'
|
||||
});
|
||||
}
|
||||
} catch (error) {
|
||||
Swal.fire({
|
||||
icon: 'error',
|
||||
title: 'An Error Occurred',
|
||||
text: error.response?.data?.message ?? 'Please try again.',
|
||||
confirmButtonText: 'OK'
|
||||
});
|
||||
}
|
||||
}
|
||||
if (args.requestType === 'save' && args.action === 'edit') {
|
||||
try {
|
||||
const response = await services.updateSecondaryData(args.data.id, args.data.warehouseId, args.data.productId, args.data.movement, StorageManager.getUserId());
|
||||
await methods.populateSecondaryData(state.id);
|
||||
secondaryGrid.refresh();
|
||||
if (response.data.code === 200) {
|
||||
Swal.fire({
|
||||
icon: 'success',
|
||||
title: 'Update Successful',
|
||||
timer: 2000,
|
||||
showConfirmButton: false
|
||||
});
|
||||
} else {
|
||||
Swal.fire({
|
||||
icon: 'error',
|
||||
title: 'Update Failed',
|
||||
text: response.data.message ?? 'Please check your data.',
|
||||
confirmButtonText: 'Try Again'
|
||||
});
|
||||
}
|
||||
} catch (error) {
|
||||
Swal.fire({
|
||||
icon: 'error',
|
||||
title: 'An Error Occurred',
|
||||
text: error.response?.data?.message ?? 'Please try again.',
|
||||
confirmButtonText: 'OK'
|
||||
});
|
||||
}
|
||||
}
|
||||
if (args.requestType === 'delete') {
|
||||
try {
|
||||
const response = await services.deleteSecondaryData(args.data[0].id, StorageManager.getUserId());
|
||||
await methods.populateSecondaryData(state.id);
|
||||
secondaryGrid.refresh();
|
||||
if (response.data.code === 200) {
|
||||
Swal.fire({
|
||||
icon: 'success',
|
||||
title: 'Delete Successful',
|
||||
timer: 2000,
|
||||
showConfirmButton: false
|
||||
});
|
||||
} else {
|
||||
Swal.fire({
|
||||
icon: 'error',
|
||||
title: 'Delete Failed',
|
||||
text: response.data.message ?? 'Please check your data.',
|
||||
confirmButtonText: 'Try Again'
|
||||
});
|
||||
}
|
||||
} catch (error) {
|
||||
Swal.fire({
|
||||
icon: 'error',
|
||||
title: 'An Error Occurred',
|
||||
text: error.response?.data?.message ?? 'Please try again.',
|
||||
confirmButtonText: 'OK'
|
||||
});
|
||||
}
|
||||
}
|
||||
methods.refreshSummary();
|
||||
}
|
||||
});
|
||||
secondaryGrid.obj.appendTo(secondaryGridRef.value);
|
||||
|
||||
},
|
||||
refresh: () => {
|
||||
secondaryGrid.obj.setProperties({ dataSource: state.secondaryData });
|
||||
}
|
||||
};
|
||||
|
||||
const mainModal = {
|
||||
obj: null,
|
||||
create: () => {
|
||||
mainModal.obj = new bootstrap.Modal(mainModalRef.value, {
|
||||
backdrop: 'static',
|
||||
keyboard: false
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
return {
|
||||
mainGridRef,
|
||||
mainModalRef,
|
||||
secondaryGridRef,
|
||||
numberRef,
|
||||
adjustmentDateRef,
|
||||
statusRef,
|
||||
state,
|
||||
handler,
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
Vue.createApp(App).mount('#app');
|
||||
@@ -0,0 +1,204 @@
|
||||
@page
|
||||
@attribute [Authorize(Roles = "PositiveAdjustments")]
|
||||
@{
|
||||
ViewData["Title"] = "Positive Adjustment PDF";
|
||||
}
|
||||
|
||||
<div id="app" class="row">
|
||||
<div class="col-12">
|
||||
<div class="print-indicator" v-cloak>
|
||||
<div class="content-wrapper">
|
||||
<div>
|
||||
<button id="download-pdf" class="btn btn-danger d-flex align-items-center" v-on:click="handler.downloadPDF" v-bind:disabled="state.isDownloading">
|
||||
<span class="spinner-border spinner-border-sm me-2" role="status" aria-hidden="true" v-if="state.isDownloading"></span>
|
||||
<span class="button-text" v-if="!state.isDownloading">
|
||||
<i class="bi bi-file-earmark-pdf-fill me-2"></i> Download PDF
|
||||
</span>
|
||||
</button>
|
||||
</div>
|
||||
<div id="content" class="print-area">
|
||||
<div class="company-info">
|
||||
<h2>{{ state.company.name }}</h2>
|
||||
<p>{{ state.companyAddress }}</p>
|
||||
<p>Email: {{ state.company.emailAddress }} | Phone: {{ state.company.phoneNumber }}</p>
|
||||
</div>
|
||||
|
||||
<h1>Positive Adjustment</h1>
|
||||
|
||||
<div class="info-container">
|
||||
<table class="details-table">
|
||||
<tr>
|
||||
<th colspan="2">Adjustment Information</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>Number:</strong></td>
|
||||
<td>{{ state.number }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>Date:</strong></td>
|
||||
<td>{{ state.date }}</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<table class="product-table" border="1" style="width: 100%; border-collapse: collapse;">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Warehouse</th>
|
||||
<th>Product</th>
|
||||
<th>Movement</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-for="item in state.mappedItems" :key="item.product + item.warehouse">
|
||||
<td>{{ item.warehouse }}</td>
|
||||
<td>{{ item.product }}</td>
|
||||
<td>{{ item.movement }}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<div class="summary">
|
||||
<div class="column"></div>
|
||||
<div class="column">
|
||||
<table style="width: 100%; border-collapse: collapse; margin-top: 20px;">
|
||||
<tr>
|
||||
<td style="font-weight: bold; font-size: 1.2em;">Total Movement:</td>
|
||||
<td style="text-align: right; font-weight: bold; font-size: 1.2em; color: #2c3e50;">
|
||||
{{ state.movementTotal }}
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- CSS -->
|
||||
<style>
|
||||
.print-indicator {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: flex-start;
|
||||
height: 100vh;
|
||||
background-color: #f8f9fa;
|
||||
position: relative;
|
||||
overflow-y: auto;
|
||||
padding: 30px;
|
||||
}
|
||||
|
||||
|
||||
.content-wrapper {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
gap: 20px;
|
||||
}
|
||||
|
||||
.print-area {
|
||||
width: 210mm;
|
||||
padding: 10mm;
|
||||
background-color: white;
|
||||
border: 1px dashed #cccccc;
|
||||
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
|
||||
#download-pdf {
|
||||
padding: 10px 20px;
|
||||
font-size: 16px;
|
||||
border-radius: 5px;
|
||||
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
|
||||
}
|
||||
|
||||
.company-info {
|
||||
text-align: center;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.company-info h2 {
|
||||
font-size: 24px;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.company-info p {
|
||||
margin: 5px 0;
|
||||
font-size: 14px;
|
||||
color: #555;
|
||||
}
|
||||
|
||||
h1 {
|
||||
text-align: center;
|
||||
margin-bottom: 20px;
|
||||
font-size: 28px;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.info-container {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
margin-bottom: 20px;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.details-table {
|
||||
flex: 1;
|
||||
padding: 5px 8px;
|
||||
border: 1px solid #ccc;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.details-table th, .details-table td {
|
||||
padding: 5px 10px;
|
||||
border: 1px solid #ccc;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
|
||||
.details-table th {
|
||||
background-color: #f2f2f2;
|
||||
text-align: left;
|
||||
height: 35px;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
|
||||
|
||||
.product-table {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
margin-bottom: 20px;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.product-table th, .product-table td {
|
||||
padding: 8px;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.product-table th {
|
||||
background-color: #f2f2f2;
|
||||
}
|
||||
|
||||
.summary {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
margin-top: 20px;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.summary .column {
|
||||
width: 48%;
|
||||
}
|
||||
|
||||
.summary p {
|
||||
margin: 5px 0;
|
||||
text-align: right;
|
||||
}
|
||||
</style>
|
||||
|
||||
@section scripts {
|
||||
<script src="~/FrontEnd/Pages/PositiveAdjustments/PositiveAdjustmentPdf.cshtml.js"></script>
|
||||
}
|
||||
+128
@@ -0,0 +1,128 @@
|
||||
const App = {
|
||||
setup() {
|
||||
const state = Vue.reactive({
|
||||
company: {
|
||||
name: '',
|
||||
emailAddress: '',
|
||||
phoneNumber: '',
|
||||
street: '',
|
||||
city: '',
|
||||
state: '',
|
||||
zipCode: '',
|
||||
country: ''
|
||||
},
|
||||
companyAddress: '',
|
||||
number: '',
|
||||
date: '',
|
||||
pdfTransactionList: [],
|
||||
isDownloading: false,
|
||||
mappedItems: [],
|
||||
movementTotal: 0
|
||||
});
|
||||
|
||||
const services = {
|
||||
getPDFData: async (id) => {
|
||||
try {
|
||||
const response = await AxiosManager.get('/PositiveAdjustment/GetPositiveAdjustmentSingle?id=' + id, {});
|
||||
return response;
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
const methods = {
|
||||
populatePDFData: async (id) => {
|
||||
const response = await services.getPDFData(id);
|
||||
state.pdfData = response?.data?.content?.data || {};
|
||||
state.pdfTransactionList = response?.data?.content?.transactionList || [];
|
||||
methods.bindPDFControls();
|
||||
},
|
||||
|
||||
bindPDFControls: () => {
|
||||
const company = StorageManager.getCompany() || state.company;
|
||||
state.company = {
|
||||
name: company.name,
|
||||
emailAddress: company.emailAddress,
|
||||
phoneNumber: company.phoneNumber,
|
||||
street: company.street,
|
||||
city: company.city,
|
||||
state: company.state,
|
||||
zipCode: company.zipCode,
|
||||
country: company.country
|
||||
};
|
||||
state.companyAddress = [
|
||||
company.street,
|
||||
company.city,
|
||||
company.state,
|
||||
company.zipCode,
|
||||
company.country
|
||||
].filter(Boolean).join(', ');
|
||||
|
||||
const pdfData = state.pdfData;
|
||||
state.number = pdfData?.number || '';
|
||||
state.date = DateFormatManager.formatToLocale(pdfData?.adjustmentDate) || '';
|
||||
|
||||
state.mappedItems = (state.pdfTransactionList || []).map(item => ({
|
||||
warehouse: item.warehouse?.name || '',
|
||||
product: `${item.product?.number || ''} ${item.product?.name || ''}`.trim(),
|
||||
movement: item.movement || 0,
|
||||
}));
|
||||
|
||||
let movementTotal = (state.pdfTransactionList || []).reduce((sum, item) => sum + (item.movement || 0), 0);
|
||||
state.movementTotal = NumberFormatManager.formatToLocale(movementTotal);
|
||||
}
|
||||
};
|
||||
|
||||
const handler = {
|
||||
downloadPDF: async () => {
|
||||
state.isDownloading = true;
|
||||
await new Promise(resolve => setTimeout(resolve, 500));
|
||||
|
||||
try {
|
||||
const { jsPDF } = window.jspdf;
|
||||
const doc = new jsPDF('p', 'mm', 'a4');
|
||||
const content = document.getElementById('content');
|
||||
|
||||
await html2canvas(content, {
|
||||
scale: 2,
|
||||
useCORS: true
|
||||
}).then(canvas => {
|
||||
const imgData = canvas.toDataURL('image/png');
|
||||
const imgWidth = 210;
|
||||
const pageHeight = 297;
|
||||
const imgHeight = (canvas.height * imgWidth) / canvas.width;
|
||||
let position = 0;
|
||||
|
||||
doc.addImage(imgData, 'PNG', 0, position, imgWidth, imgHeight);
|
||||
doc.save(`positive-adjustment-${state.number || 'unknown'}.pdf`);
|
||||
});
|
||||
} catch (error) {
|
||||
console.error('Error generating PDF:', error);
|
||||
} finally {
|
||||
state.isDownloading = false;
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
Vue.onMounted(async () => {
|
||||
try {
|
||||
await SecurityManager.authorizePage(['PositiveAdjustments']);
|
||||
var urlParams = new URLSearchParams(window.location.search);
|
||||
var id = urlParams.get('id');
|
||||
await methods.populatePDFData(id ?? '');
|
||||
} catch (e) {
|
||||
console.error('page init error:', e);
|
||||
} finally {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
return {
|
||||
state,
|
||||
handler,
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
Vue.createApp(App).mount('#app');
|
||||
@@ -0,0 +1,72 @@
|
||||
@page
|
||||
@attribute [Authorize(Roles = "ProductGroups")]
|
||||
@{
|
||||
ViewData["Title"] = "Product Group List";
|
||||
}
|
||||
|
||||
<div id="app" v-cloak>
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<div class="grid-container">
|
||||
<div ref="mainGridRef"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="modal fade" ref="mainModalRef" id="MainModal" aria-hidden="true" tabindex="-1" data-bs-focus="false" data-bs-backdrop="static">
|
||||
<div class="modal-dialog modal-dialog-centered modal-lg">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title">{{ state.mainTitle }}</h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<input type="hidden" v-model="state.id" id="Id" name="Id" />
|
||||
<form id="MainForm">
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<h5>Main Info</h5>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="row mb-2">
|
||||
<div class="col-md-6">
|
||||
<label for="Name">Name</label>
|
||||
<input ref="nameRef" v-model="state.name">
|
||||
<label class="text-danger">{{ state.errors.name }}</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mb-2">
|
||||
<div class="col-12">
|
||||
<label for="Description">Description</label>
|
||||
<textarea v-model="state.description" id="Description" name="Description" class="form-control" rows="3"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
|
||||
<button type="button"
|
||||
id="MainSaveButton"
|
||||
class="btn"
|
||||
v-bind:class="state.deleteMode ? 'btn-danger' : 'btn-primary'"
|
||||
v-on:click="handler.handleSubmit"
|
||||
v-bind:disabled="state.isSubmitting">
|
||||
<span class="spinner-border spinner-border-sm me-2" v-if="state.isSubmitting" role="status" aria-hidden="true"></span>
|
||||
<span v-if="!state.isSubmitting">{{ state.deleteMode ? 'Delete' : 'Save' }}</span>
|
||||
<span v-else>{{ state.deleteMode ? 'Deleting...' : 'Saving...' }}</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@section scripts {
|
||||
<script src="~/FrontEnd/Pages/ProductGroups/ProductGroupList.cshtml.js"></script>
|
||||
}
|
||||
@@ -0,0 +1,342 @@
|
||||
const App = {
|
||||
setup() {
|
||||
const state = Vue.reactive({
|
||||
mainData: [],
|
||||
deleteMode: false,
|
||||
mainTitle: null,
|
||||
id: '',
|
||||
name: '',
|
||||
description: '',
|
||||
errors: {
|
||||
name: ''
|
||||
},
|
||||
isSubmitting: false
|
||||
});
|
||||
|
||||
const mainGridRef = Vue.ref(null);
|
||||
const mainModalRef = Vue.ref(null);
|
||||
const nameRef = Vue.ref(null);
|
||||
|
||||
const nameText = {
|
||||
obj: null,
|
||||
create: () => {
|
||||
nameText.obj = new ej.inputs.TextBox({
|
||||
placeholder: 'Enter Name',
|
||||
});
|
||||
nameText.obj.appendTo(nameRef.value);
|
||||
},
|
||||
refresh: () => {
|
||||
if (nameText.obj) {
|
||||
nameText.obj.value = state.name;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Vue.watch(
|
||||
() => state.name,
|
||||
(newVal, oldVal) => {
|
||||
state.errors.name = '';
|
||||
nameText.refresh();
|
||||
}
|
||||
);
|
||||
|
||||
const validateForm = function () {
|
||||
state.errors.name = '';
|
||||
|
||||
let isValid = true;
|
||||
|
||||
if (!state.name) {
|
||||
state.errors.name = 'Name is required.';
|
||||
isValid = false;
|
||||
}
|
||||
|
||||
return isValid;
|
||||
};
|
||||
|
||||
const resetFormState = () => {
|
||||
state.id = '';
|
||||
state.name = '';
|
||||
state.description = '';
|
||||
state.errors = {
|
||||
name: ''
|
||||
};
|
||||
};
|
||||
|
||||
const services = {
|
||||
getMainData: async () => {
|
||||
try {
|
||||
const response = await AxiosManager.get('/ProductGroup/GetProductGroupList', {});
|
||||
return response;
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
},
|
||||
createMainData: async (name, description, createdById) => {
|
||||
try {
|
||||
const response = await AxiosManager.post('/ProductGroup/CreateProductGroup', {
|
||||
name, description, createdById
|
||||
});
|
||||
return response;
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
},
|
||||
updateMainData: async (id, name, description, updatedById) => {
|
||||
try {
|
||||
const response = await AxiosManager.post('/ProductGroup/UpdateProductGroup', {
|
||||
id, name, description, updatedById
|
||||
});
|
||||
return response;
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
},
|
||||
deleteMainData: async (id, deletedById) => {
|
||||
try {
|
||||
const response = await AxiosManager.post('/ProductGroup/DeleteProductGroup', {
|
||||
id, deletedById
|
||||
});
|
||||
return response;
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
const methods = {
|
||||
populateMainData: async () => {
|
||||
const response = await services.getMainData();
|
||||
state.mainData = response?.data?.content?.data.map(item => ({
|
||||
...item,
|
||||
createdAtUtc: new Date(item.createdAtUtc)
|
||||
}));
|
||||
},
|
||||
};
|
||||
|
||||
const handler = {
|
||||
handleSubmit: async function () {
|
||||
try {
|
||||
state.isSubmitting = true;
|
||||
await new Promise(resolve => setTimeout(resolve, 300));
|
||||
|
||||
if (!validateForm()) {
|
||||
return;
|
||||
}
|
||||
|
||||
const response = state.id === ''
|
||||
? await services.createMainData(state.name, state.description, StorageManager.getUserId())
|
||||
: state.deleteMode
|
||||
? await services.deleteMainData(state.id, StorageManager.getUserId())
|
||||
: await services.updateMainData(state.id, state.name, state.description, StorageManager.getUserId());
|
||||
|
||||
if (response.data.code === 200) {
|
||||
await methods.populateMainData();
|
||||
mainGrid.refresh();
|
||||
|
||||
if (!state.deleteMode) {
|
||||
state.mainTitle = 'Edit Product Group';
|
||||
state.id = response?.data?.content?.data.id ?? '';
|
||||
state.name = response?.data?.content?.data.name ?? '';
|
||||
state.description = response?.data?.content?.data.description ?? '';
|
||||
|
||||
Swal.fire({
|
||||
icon: 'success',
|
||||
title: state.deleteMode ? 'Delete Successful' : 'Save Successful',
|
||||
text: 'Form will be closed...',
|
||||
timer: 2000,
|
||||
showConfirmButton: false
|
||||
});
|
||||
setTimeout(() => {
|
||||
mainModal.obj.hide();
|
||||
}, 2000);
|
||||
|
||||
} else {
|
||||
Swal.fire({
|
||||
icon: 'success',
|
||||
title: 'Delete Successful',
|
||||
text: 'Form will be closed...',
|
||||
timer: 2000,
|
||||
showConfirmButton: false
|
||||
});
|
||||
setTimeout(() => {
|
||||
mainModal.obj.hide();
|
||||
resetFormState();
|
||||
}, 2000);
|
||||
}
|
||||
|
||||
} else {
|
||||
Swal.fire({
|
||||
icon: 'error',
|
||||
title: state.deleteMode ? 'Delete Failed' : 'Save Failed',
|
||||
text: response.data.message ?? 'Please check your data.',
|
||||
confirmButtonText: 'Try Again'
|
||||
});
|
||||
}
|
||||
|
||||
} catch (error) {
|
||||
Swal.fire({
|
||||
icon: 'error',
|
||||
title: 'An Error Occurred',
|
||||
text: error.response?.data?.message ?? 'Please try again.',
|
||||
confirmButtonText: 'OK'
|
||||
});
|
||||
} finally {
|
||||
state.isSubmitting = false;
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
Vue.onMounted(async () => {
|
||||
try {
|
||||
await SecurityManager.authorizePage(['ProductGroups']);
|
||||
await SecurityManager.validateToken();
|
||||
|
||||
await methods.populateMainData();
|
||||
await mainGrid.create(state.mainData);
|
||||
|
||||
nameText.create();
|
||||
mainModal.create();
|
||||
mainModalRef.value?.addEventListener('hidden.bs.modal', () => {
|
||||
resetFormState();
|
||||
});
|
||||
|
||||
} catch (e) {
|
||||
console.error('page init error:', e);
|
||||
} finally {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
Vue.onUnmounted(() => {
|
||||
mainModalRef.value?.removeEventListener('hidden.bs.modal', resetFormState);
|
||||
});
|
||||
|
||||
const mainGrid = {
|
||||
obj: null,
|
||||
create: async (dataSource) => {
|
||||
mainGrid.obj = new ej.grids.Grid({
|
||||
height: '240px',
|
||||
dataSource: dataSource,
|
||||
allowFiltering: true,
|
||||
allowSorting: true,
|
||||
allowSelection: true,
|
||||
allowGrouping: true,
|
||||
allowTextWrap: true,
|
||||
allowResizing: true,
|
||||
allowPaging: true,
|
||||
allowExcelExport: true,
|
||||
filterSettings: { type: 'CheckBox' },
|
||||
sortSettings: { columns: [{ field: 'createdAtUtc', direction: 'Descending' }] },
|
||||
pageSettings: { currentPage: 1, pageSize: 50, pageSizes: ["10", "20", "50", "100", "200", "All"] },
|
||||
selectionSettings: { persistSelection: true, type: 'Single' },
|
||||
autoFit: true,
|
||||
showColumnMenu: true,
|
||||
gridLines: 'Horizontal',
|
||||
columns: [
|
||||
{ type: 'checkbox', width: 60 },
|
||||
{
|
||||
field: 'id', isPrimaryKey: true, headerText: 'Id', visible: false
|
||||
},
|
||||
{ field: 'name', headerText: 'Name', width: 200, minWidth: 200 },
|
||||
{ field: 'description', headerText: 'Description', width: 400, minWidth: 400 },
|
||||
{ field: 'createdAtUtc', headerText: 'Created At UTC', width: 150, format: 'yyyy-MM-dd HH:mm' }
|
||||
],
|
||||
toolbar: [
|
||||
'ExcelExport', 'Search',
|
||||
{ type: 'Separator' },
|
||||
{ text: 'Add', tooltipText: 'Add', prefixIcon: 'e-add', id: 'AddCustom' },
|
||||
{ text: 'Edit', tooltipText: 'Edit', prefixIcon: 'e-edit', id: 'EditCustom' },
|
||||
{ text: 'Delete', tooltipText: 'Delete', prefixIcon: 'e-delete', id: 'DeleteCustom' },
|
||||
{ type: 'Separator' },
|
||||
],
|
||||
beforeDataBound: () => { },
|
||||
dataBound: function () {
|
||||
mainGrid.obj.toolbarModule.enableItems(['EditCustom', 'DeleteCustom'], false);
|
||||
mainGrid.obj.autoFitColumns(['name', 'description', 'createdAtUtc']);
|
||||
},
|
||||
excelExportComplete: () => { },
|
||||
rowSelected: () => {
|
||||
if (mainGrid.obj.getSelectedRecords().length == 1) {
|
||||
mainGrid.obj.toolbarModule.enableItems(['EditCustom', 'DeleteCustom'], true);
|
||||
} else {
|
||||
mainGrid.obj.toolbarModule.enableItems(['EditCustom', 'DeleteCustom'], false);
|
||||
}
|
||||
},
|
||||
rowDeselected: () => {
|
||||
if (mainGrid.obj.getSelectedRecords().length == 1) {
|
||||
mainGrid.obj.toolbarModule.enableItems(['EditCustom', 'DeleteCustom'], true);
|
||||
} else {
|
||||
mainGrid.obj.toolbarModule.enableItems(['EditCustom', 'DeleteCustom'], false);
|
||||
}
|
||||
},
|
||||
rowSelecting: () => {
|
||||
if (mainGrid.obj.getSelectedRecords().length) {
|
||||
mainGrid.obj.clearSelection();
|
||||
}
|
||||
},
|
||||
toolbarClick: async (args) => {
|
||||
if (args.item.id === 'MainGrid_excelexport') {
|
||||
mainGrid.obj.excelExport();
|
||||
}
|
||||
|
||||
if (args.item.id === 'AddCustom') {
|
||||
state.deleteMode = false;
|
||||
state.mainTitle = 'Add Product Group';
|
||||
resetFormState();
|
||||
mainModal.obj.show();
|
||||
}
|
||||
|
||||
if (args.item.id === 'EditCustom') {
|
||||
state.deleteMode = false;
|
||||
if (mainGrid.obj.getSelectedRecords().length) {
|
||||
const selectedRecord = mainGrid.obj.getSelectedRecords()[0];
|
||||
state.mainTitle = 'Edit Product Group';
|
||||
state.id = selectedRecord.id ?? '';
|
||||
state.name = selectedRecord.name ?? '';
|
||||
state.description = selectedRecord.description ?? '';
|
||||
mainModal.obj.show();
|
||||
}
|
||||
}
|
||||
|
||||
if (args.item.id === 'DeleteCustom') {
|
||||
state.deleteMode = true;
|
||||
if (mainGrid.obj.getSelectedRecords().length) {
|
||||
const selectedRecord = mainGrid.obj.getSelectedRecords()[0];
|
||||
state.mainTitle = 'Delete Product Group?';
|
||||
state.id = selectedRecord.id ?? '';
|
||||
state.name = selectedRecord.name ?? '';
|
||||
state.description = selectedRecord.description ?? '';
|
||||
mainModal.obj.show();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
mainGrid.obj.appendTo(mainGridRef.value);
|
||||
},
|
||||
refresh: () => {
|
||||
mainGrid.obj.setProperties({ dataSource: state.mainData });
|
||||
}
|
||||
};
|
||||
|
||||
const mainModal = {
|
||||
obj: null,
|
||||
create: () => {
|
||||
mainModal.obj = new bootstrap.Modal(mainModalRef.value, {
|
||||
backdrop: 'static',
|
||||
keyboard: false
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
return {
|
||||
mainGridRef,
|
||||
mainModalRef,
|
||||
nameRef,
|
||||
state,
|
||||
handler,
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
Vue.createApp(App).mount('#app');
|
||||
@@ -0,0 +1,101 @@
|
||||
@page
|
||||
@attribute [Authorize(Roles = "Products")]
|
||||
@{
|
||||
ViewData["Title"] = "Product List";
|
||||
}
|
||||
|
||||
<div id="app" v-cloak>
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<div class="grid-container">
|
||||
<div ref="mainGridRef"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="modal fade" ref="mainModalRef" id="MainModal" aria-hidden="true" tabindex="-1" data-bs-focus="false" data-bs-backdrop="static">
|
||||
<div class="modal-dialog modal-dialog-centered modal-lg">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title">{{ state.mainTitle }}</h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<input type="hidden" v-model="state.id" id="Id" name="Id" />
|
||||
<form id="MainForm">
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<h5>Main Info</h5>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="row mb-2">
|
||||
<div class="col-md-6">
|
||||
<label for="Name">Name</label>
|
||||
<input ref="nameRef" v-model="state.name">
|
||||
<label class="text-danger">{{ state.errors.name }}</label>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<label for="Number">Number</label>
|
||||
<input ref="numberRef" v-model="state.number" readonly>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mb-2">
|
||||
<div class="col-md-6">
|
||||
<label for="UnitPrice">Unit Price</label>
|
||||
<input ref="unitPriceRef" v-model="state.unitPrice">
|
||||
<label class="text-danger">{{ state.errors.unitPrice }}</label>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<label for="UnitMeasureId">Unit Measure</label>
|
||||
<div ref="unitMeasureIdRef"></div>
|
||||
<label class="text-danger">{{ state.errors.unitMeasureId }}</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mb-2">
|
||||
<div class="col-md-6">
|
||||
<label for="ProductGroupId">Product Group</label>
|
||||
<div ref="productGroupIdRef"></div>
|
||||
<label class="text-danger">{{ state.errors.productGroupId }}</label>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<div class="form-check mt-4">
|
||||
<input v-model="state.physical" id="Physical" name="Physical" type="checkbox" class="form-check-input">
|
||||
<label for="Physical" class="form-check-label">Is Physical Product?</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mb-2">
|
||||
<div class="col-12">
|
||||
<label for="Description">Description</label>
|
||||
<textarea v-model="state.description" id="Description" name="Description" class="form-control" rows="3"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
|
||||
<button type="button"
|
||||
id="MainSaveButton"
|
||||
class="btn"
|
||||
v-bind:class="state.deleteMode ? 'btn-danger' : 'btn-primary'"
|
||||
v-on:click="handler.handleSubmit"
|
||||
v-bind:disabled="state.isSubmitting">
|
||||
<span class="spinner-border spinner-border-sm me-2" v-if="state.isSubmitting" role="status" aria-hidden="true"></span>
|
||||
<span v-if="!state.isSubmitting">{{ state.deleteMode ? 'Delete' : 'Save' }}</span>
|
||||
<span v-else>{{ state.deleteMode ? 'Deleting...' : 'Saving...' }}</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@section scripts {
|
||||
<script src="~/FrontEnd/Pages/Products/ProductList.cshtml.js"></script>
|
||||
}
|
||||
@@ -0,0 +1,555 @@
|
||||
const App = {
|
||||
setup() {
|
||||
const state = Vue.reactive({
|
||||
mainData: [],
|
||||
deleteMode: false,
|
||||
productGroupListLookupData: [],
|
||||
unitMeasureListLookupData: [],
|
||||
mainTitle: null,
|
||||
id: '',
|
||||
name: '',
|
||||
number: '',
|
||||
unitPrice: '',
|
||||
description: '',
|
||||
productGroupId: null,
|
||||
unitMeasureId: null,
|
||||
physical: false,
|
||||
errors: {
|
||||
name: '',
|
||||
unitPrice: '',
|
||||
productGroupId: '',
|
||||
unitMeasureId: ''
|
||||
},
|
||||
isSubmitting: false
|
||||
});
|
||||
|
||||
const mainGridRef = Vue.ref(null);
|
||||
const mainModalRef = Vue.ref(null);
|
||||
const productGroupIdRef = Vue.ref(null);
|
||||
const unitMeasureIdRef = Vue.ref(null);
|
||||
const nameRef = Vue.ref(null);
|
||||
const numberRef = Vue.ref(null);
|
||||
const unitPriceRef = Vue.ref(null);
|
||||
|
||||
const validateForm = function () {
|
||||
state.errors.name = '';
|
||||
state.errors.unitPrice = '';
|
||||
state.errors.productGroupId = '';
|
||||
state.errors.unitMeasureId = '';
|
||||
|
||||
let isValid = true;
|
||||
|
||||
if (!state.name) {
|
||||
state.errors.name = 'Name is required.';
|
||||
isValid = false;
|
||||
}
|
||||
if (!state.unitPrice) {
|
||||
state.errors.unitPrice = 'Unit price is required.';
|
||||
isValid = false;
|
||||
} else if (!/^\d+(\.\d{1,2})?$/.test(state.unitPrice)) {
|
||||
state.errors.unitPrice = 'Unit price must be a numeric value with up to two decimal places.';
|
||||
isValid = false;
|
||||
}
|
||||
if (!state.productGroupId) {
|
||||
state.errors.productGroupId = 'ProductGroup is required.';
|
||||
isValid = false;
|
||||
}
|
||||
if (!state.unitMeasureId) {
|
||||
state.errors.unitMeasureId = 'UnitMeasure is required.';
|
||||
isValid = false;
|
||||
}
|
||||
|
||||
return isValid;
|
||||
};
|
||||
|
||||
const resetFormState = () => {
|
||||
state.id = '';
|
||||
state.name = '';
|
||||
state.number = '';
|
||||
state.unitPrice = '';
|
||||
state.description = '';
|
||||
state.productGroupId = null;
|
||||
state.unitMeasureId = null;
|
||||
state.physical = false;
|
||||
state.errors = {
|
||||
name: '',
|
||||
unitPrice: '',
|
||||
productGroupId: '',
|
||||
unitMeasureId: ''
|
||||
};
|
||||
};
|
||||
|
||||
const services = {
|
||||
getMainData: async () => {
|
||||
try {
|
||||
const response = await AxiosManager.get('/Product/GetProductList', {});
|
||||
return response;
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
},
|
||||
createMainData: async (name, unitPrice, physical, description, productGroupId, unitMeasureId, createdById) => {
|
||||
try {
|
||||
const response = await AxiosManager.post('/Product/CreateProduct', {
|
||||
name, unitPrice, physical, description, productGroupId, unitMeasureId, createdById
|
||||
});
|
||||
return response;
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
},
|
||||
updateMainData: async (id, name, unitPrice, physical, description, productGroupId, unitMeasureId, updatedById) => {
|
||||
try {
|
||||
const response = await AxiosManager.post('/Product/UpdateProduct', {
|
||||
id, name, unitPrice, physical, description, productGroupId, unitMeasureId, updatedById
|
||||
});
|
||||
return response;
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
},
|
||||
deleteMainData: async (id, deletedById) => {
|
||||
try {
|
||||
const response = await AxiosManager.post('/Product/DeleteProduct', {
|
||||
id, deletedById
|
||||
});
|
||||
return response;
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
},
|
||||
getProductGroupListLookupData: async () => {
|
||||
try {
|
||||
const response = await AxiosManager.get('/ProductGroup/GetProductGroupList', {});
|
||||
return response;
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
},
|
||||
getUnitMeasureListLookupData: async () => {
|
||||
try {
|
||||
const response = await AxiosManager.get('/UnitMeasure/GetUnitMeasureList', {});
|
||||
return response;
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
const methods = {
|
||||
populateProductGroupListLookupData: async () => {
|
||||
const response = await services.getProductGroupListLookupData();
|
||||
state.productGroupListLookupData = response?.data?.content?.data;
|
||||
},
|
||||
populateUnitMeasureListLookupData: async () => {
|
||||
const response = await services.getUnitMeasureListLookupData();
|
||||
state.unitMeasureListLookupData = response?.data?.content?.data;
|
||||
},
|
||||
populateMainData: async () => {
|
||||
const response = await services.getMainData();
|
||||
state.mainData = response?.data?.content?.data.map(item => ({
|
||||
...item,
|
||||
createdAtUtc: new Date(item.createdAtUtc)
|
||||
}));
|
||||
},
|
||||
};
|
||||
|
||||
const productGroupListLookup = {
|
||||
obj: null,
|
||||
create: () => {
|
||||
if (state.productGroupListLookupData && Array.isArray(state.productGroupListLookupData)) {
|
||||
productGroupListLookup.obj = new ej.dropdowns.DropDownList({
|
||||
dataSource: state.productGroupListLookupData,
|
||||
fields: { value: 'id', text: 'name' },
|
||||
placeholder: 'Select a Product Group',
|
||||
popupHeight: '200px',
|
||||
change: (e) => {
|
||||
state.productGroupId = e.value;
|
||||
}
|
||||
});
|
||||
productGroupListLookup.obj.appendTo(productGroupIdRef.value);
|
||||
} else {
|
||||
console.error('ProductGroup list lookup data is not available or invalid.');
|
||||
}
|
||||
},
|
||||
refresh: () => {
|
||||
if (productGroupListLookup.obj) {
|
||||
productGroupListLookup.obj.value = state.productGroupId;
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
const unitMeasureListLookup = {
|
||||
obj: null,
|
||||
create: () => {
|
||||
if (state.unitMeasureListLookupData && Array.isArray(state.unitMeasureListLookupData)) {
|
||||
unitMeasureListLookup.obj = new ej.dropdowns.DropDownList({
|
||||
dataSource: state.unitMeasureListLookupData,
|
||||
fields: { value: 'id', text: 'name' },
|
||||
placeholder: 'Select a Unit Measure',
|
||||
popupHeight: '200px',
|
||||
change: (e) => {
|
||||
state.unitMeasureId = e.value;
|
||||
}
|
||||
});
|
||||
unitMeasureListLookup.obj.appendTo(unitMeasureIdRef.value);
|
||||
} else {
|
||||
console.error('UnitMeasure list lookup data is not available or invalid.');
|
||||
}
|
||||
},
|
||||
refresh: () => {
|
||||
if (unitMeasureListLookup.obj) {
|
||||
unitMeasureListLookup.obj.value = state.unitMeasureId;
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
const nameText = {
|
||||
obj: null,
|
||||
create: () => {
|
||||
nameText.obj = new ej.inputs.TextBox({
|
||||
placeholder: 'Enter Name',
|
||||
});
|
||||
nameText.obj.appendTo(nameRef.value);
|
||||
},
|
||||
refresh: () => {
|
||||
if (nameText.obj) {
|
||||
nameText.obj.value = state.name;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const numberText = {
|
||||
obj: null,
|
||||
create: () => {
|
||||
numberText.obj = new ej.inputs.TextBox({
|
||||
placeholder: '[auto]',
|
||||
readonly: true
|
||||
});
|
||||
numberText.obj.appendTo(numberRef.value);
|
||||
},
|
||||
refresh: () => {
|
||||
if (numberText.obj) {
|
||||
numberText.obj.value = state.number;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const unitPriceNumber = {
|
||||
obj: null,
|
||||
create: () => {
|
||||
unitPriceNumber.obj = new ej.inputs.NumericTextBox({
|
||||
format: 'n2',
|
||||
placeholder: 'Enter Unit Price',
|
||||
min: 0,
|
||||
step: 0.01,
|
||||
validateDecimalOnType: true
|
||||
});
|
||||
unitPriceNumber.obj.appendTo(unitPriceRef.value);
|
||||
},
|
||||
refresh: () => {
|
||||
if (unitPriceNumber.obj) {
|
||||
unitPriceNumber.obj.value = state.unitPrice;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Vue.watch(
|
||||
() => state.name,
|
||||
(newVal, oldVal) => {
|
||||
state.errors.name = '';
|
||||
nameText.refresh();
|
||||
}
|
||||
);
|
||||
|
||||
Vue.watch(
|
||||
() => state.number,
|
||||
(newVal, oldVal) => {
|
||||
numberText.refresh();
|
||||
}
|
||||
);
|
||||
|
||||
Vue.watch(
|
||||
() => state.unitPrice,
|
||||
(newVal, oldVal) => {
|
||||
state.errors.unitPrice = '';
|
||||
unitPriceNumber.refresh();
|
||||
}
|
||||
);
|
||||
|
||||
Vue.watch(
|
||||
() => state.productGroupId,
|
||||
(newVal, oldVal) => {
|
||||
state.errors.productGroupId = '';
|
||||
productGroupListLookup.refresh();
|
||||
}
|
||||
);
|
||||
|
||||
Vue.watch(
|
||||
() => state.unitMeasureId,
|
||||
(newVal, oldVal) => {
|
||||
state.errors.unitMeasureId = '';
|
||||
unitMeasureListLookup.refresh();
|
||||
}
|
||||
);
|
||||
|
||||
const handler = {
|
||||
handleSubmit: async function () {
|
||||
try {
|
||||
state.isSubmitting = true;
|
||||
await new Promise(resolve => setTimeout(resolve, 300));
|
||||
|
||||
if (!validateForm()) {
|
||||
return;
|
||||
}
|
||||
|
||||
const response = state.id === ''
|
||||
? await services.createMainData(state.name, state.unitPrice, state.physical, state.description, state.productGroupId, state.unitMeasureId, StorageManager.getUserId())
|
||||
: state.deleteMode
|
||||
? await services.deleteMainData(state.id, StorageManager.getUserId())
|
||||
: await services.updateMainData(state.id, state.name, state.unitPrice, state.physical, state.description, state.productGroupId, state.unitMeasureId, StorageManager.getUserId());
|
||||
|
||||
if (response.data.code === 200) {
|
||||
await methods.populateMainData();
|
||||
mainGrid.refresh();
|
||||
|
||||
if (!state.deleteMode) {
|
||||
state.mainTitle = 'Edit Product';
|
||||
state.id = response?.data?.content?.data.id ?? '';
|
||||
state.number = response?.data?.content?.data.number ?? '';
|
||||
state.name = response?.data?.content?.data.name ?? '';
|
||||
state.unitPrice = response?.data?.content?.data.unitPrice ?? '';
|
||||
state.description = response?.data?.content?.data.description ?? '';
|
||||
state.productGroupId = response?.data?.content?.data.productGroupId ?? '';
|
||||
state.unitMeasureId = response?.data?.content?.data.unitMeasureId ?? '';
|
||||
state.physical = response?.data?.content?.data.physical ?? false;
|
||||
|
||||
Swal.fire({
|
||||
icon: 'success',
|
||||
title: state.deleteMode ? 'Delete Successful' : 'Save Successful',
|
||||
text: 'Form will be closed...',
|
||||
timer: 2000,
|
||||
showConfirmButton: false
|
||||
});
|
||||
setTimeout(() => {
|
||||
mainModal.obj.hide();
|
||||
}, 2000);
|
||||
|
||||
} else {
|
||||
Swal.fire({
|
||||
icon: 'success',
|
||||
title: 'Delete Successful',
|
||||
text: 'Form will be closed...',
|
||||
timer: 2000,
|
||||
showConfirmButton: false
|
||||
});
|
||||
setTimeout(() => {
|
||||
mainModal.obj.hide();
|
||||
resetFormState();
|
||||
}, 2000);
|
||||
}
|
||||
|
||||
} else {
|
||||
Swal.fire({
|
||||
icon: 'error',
|
||||
title: state.deleteMode ? 'Delete Failed' : 'Save Failed',
|
||||
text: response.data.message ?? 'Please check your data.',
|
||||
confirmButtonText: 'Try Again'
|
||||
});
|
||||
}
|
||||
|
||||
} catch (error) {
|
||||
Swal.fire({
|
||||
icon: 'error',
|
||||
title: 'An Error Occurred',
|
||||
text: error.response?.data?.message ?? 'Please try again.',
|
||||
confirmButtonText: 'OK'
|
||||
});
|
||||
} finally {
|
||||
state.isSubmitting = false;
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
Vue.onMounted(async () => {
|
||||
try {
|
||||
await SecurityManager.authorizePage(['Products']);
|
||||
await SecurityManager.validateToken();
|
||||
|
||||
await methods.populateMainData();
|
||||
await mainGrid.create(state.mainData);
|
||||
await methods.populateProductGroupListLookupData();
|
||||
productGroupListLookup.create();
|
||||
await methods.populateUnitMeasureListLookupData();
|
||||
unitMeasureListLookup.create();
|
||||
|
||||
nameText.create();
|
||||
numberText.create();
|
||||
unitPriceNumber.create();
|
||||
|
||||
mainModal.create();
|
||||
mainModalRef.value?.addEventListener('hidden.bs.modal', () => {
|
||||
resetFormState();
|
||||
});
|
||||
|
||||
} catch (e) {
|
||||
console.error('page init error:', e);
|
||||
} finally {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
Vue.onUnmounted(() => {
|
||||
mainModalRef.value?.removeEventListener('hidden.bs.modal', resetFormState);
|
||||
});
|
||||
|
||||
const mainGrid = {
|
||||
obj: null,
|
||||
create: async (dataSource) => {
|
||||
mainGrid.obj = new ej.grids.Grid({
|
||||
height: '240px',
|
||||
dataSource: dataSource,
|
||||
allowFiltering: true,
|
||||
allowSorting: true,
|
||||
allowSelection: true,
|
||||
allowGrouping: true,
|
||||
groupSettings: {
|
||||
columns: ['productGroupName']
|
||||
},
|
||||
allowTextWrap: true,
|
||||
allowResizing: true,
|
||||
allowPaging: true,
|
||||
allowExcelExport: true,
|
||||
filterSettings: { type: 'CheckBox' },
|
||||
sortSettings: { columns: [{ field: 'createdAtUtc', direction: 'Descending' }] },
|
||||
pageSettings: { currentPage: 1, pageSize: 50, pageSizes: ["10", "20", "50", "100", "200", "All"] },
|
||||
selectionSettings: { persistSelection: true, type: 'Single' },
|
||||
autoFit: true,
|
||||
showColumnMenu: true,
|
||||
gridLines: 'Horizontal',
|
||||
columns: [
|
||||
{ type: 'checkbox', width: 60 },
|
||||
{
|
||||
field: 'id', isPrimaryKey: true, headerText: 'Id', visible: false
|
||||
},
|
||||
{ field: 'number', headerText: 'Number', width: 200, minWidth: 200 },
|
||||
{ field: 'name', headerText: 'Name', width: 200, minWidth: 200 },
|
||||
{ field: 'productGroupName', headerText: 'Product Group', width: 150, minWidth: 150 },
|
||||
{ field: 'unitPrice', headerText: 'Unit Price', width: 150, minWidth: 150, format: 'N2' },
|
||||
{ field: 'unitMeasureName', headerText: 'Unit Measure', width: 150, minWidth: 150 },
|
||||
{ field: 'physical', headerText: 'Physical Product', width: 200, minWidth: 200, textAlign: 'Center', type: 'boolean', displayAsCheckBox: true },
|
||||
{ field: 'createdAtUtc', headerText: 'Created At UTC', width: 150, format: 'yyyy-MM-dd HH:mm' }
|
||||
],
|
||||
toolbar: [
|
||||
'ExcelExport', 'Search',
|
||||
{ type: 'Separator' },
|
||||
{ text: 'Add', tooltipText: 'Add', prefixIcon: 'e-add', id: 'AddCustom' },
|
||||
{ text: 'Edit', tooltipText: 'Edit', prefixIcon: 'e-edit', id: 'EditCustom' },
|
||||
{ text: 'Delete', tooltipText: 'Delete', prefixIcon: 'e-delete', id: 'DeleteCustom' },
|
||||
{ type: 'Separator' },
|
||||
],
|
||||
beforeDataBound: () => { },
|
||||
dataBound: function () {
|
||||
mainGrid.obj.toolbarModule.enableItems(['EditCustom', 'DeleteCustom'], false);
|
||||
mainGrid.obj.autoFitColumns(['number', 'name', 'productGroupName', 'unitPrice', 'unitMeasureName', 'physical', 'createdAtUtc']);
|
||||
},
|
||||
excelExportComplete: () => { },
|
||||
rowSelected: () => {
|
||||
if (mainGrid.obj.getSelectedRecords().length == 1) {
|
||||
mainGrid.obj.toolbarModule.enableItems(['EditCustom', 'DeleteCustom'], true);
|
||||
} else {
|
||||
mainGrid.obj.toolbarModule.enableItems(['EditCustom', 'DeleteCustom'], false);
|
||||
}
|
||||
},
|
||||
rowDeselected: () => {
|
||||
if (mainGrid.obj.getSelectedRecords().length == 1) {
|
||||
mainGrid.obj.toolbarModule.enableItems(['EditCustom', 'DeleteCustom'], true);
|
||||
} else {
|
||||
mainGrid.obj.toolbarModule.enableItems(['EditCustom', 'DeleteCustom'], false);
|
||||
}
|
||||
},
|
||||
rowSelecting: () => {
|
||||
if (mainGrid.obj.getSelectedRecords().length) {
|
||||
mainGrid.obj.clearSelection();
|
||||
}
|
||||
},
|
||||
toolbarClick: async (args) => {
|
||||
if (args.item.id === 'MainGrid_excelexport') {
|
||||
mainGrid.obj.excelExport();
|
||||
}
|
||||
|
||||
if (args.item.id === 'AddCustom') {
|
||||
state.deleteMode = false;
|
||||
state.mainTitle = 'Add Product';
|
||||
resetFormState();
|
||||
mainModal.obj.show();
|
||||
}
|
||||
|
||||
if (args.item.id === 'EditCustom') {
|
||||
state.deleteMode = false;
|
||||
if (mainGrid.obj.getSelectedRecords().length) {
|
||||
const selectedRecord = mainGrid.obj.getSelectedRecords()[0];
|
||||
state.mainTitle = 'Edit Product';
|
||||
state.id = selectedRecord.id ?? '';
|
||||
state.number = selectedRecord.number ?? '';
|
||||
state.name = selectedRecord.name ?? '';
|
||||
state.unitPrice = selectedRecord.unitPrice ?? '';
|
||||
state.description = selectedRecord.description ?? '';
|
||||
state.productGroupId = selectedRecord.productGroupId ?? '';
|
||||
state.unitMeasureId = selectedRecord.unitMeasureId ?? '';
|
||||
state.physical = selectedRecord.physical ?? false;
|
||||
mainModal.obj.show();
|
||||
}
|
||||
}
|
||||
|
||||
if (args.item.id === 'DeleteCustom') {
|
||||
state.deleteMode = true;
|
||||
if (mainGrid.obj.getSelectedRecords().length) {
|
||||
const selectedRecord = mainGrid.obj.getSelectedRecords()[0];
|
||||
state.mainTitle = 'Delete Product?';
|
||||
state.id = selectedRecord.id ?? '';
|
||||
state.number = selectedRecord.number ?? '';
|
||||
state.name = selectedRecord.name ?? '';
|
||||
state.unitPrice = selectedRecord.unitPrice ?? '';
|
||||
state.description = selectedRecord.description ?? '';
|
||||
state.productGroupId = selectedRecord.productGroupId ?? '';
|
||||
state.unitMeasureId = selectedRecord.unitMeasureId ?? '';
|
||||
state.physical = selectedRecord.physical ?? false;
|
||||
mainModal.obj.show();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
mainGrid.obj.appendTo(mainGridRef.value);
|
||||
},
|
||||
refresh: () => {
|
||||
mainGrid.obj.setProperties({ dataSource: state.mainData });
|
||||
}
|
||||
};
|
||||
|
||||
const mainModal = {
|
||||
obj: null,
|
||||
create: () => {
|
||||
mainModal.obj = new bootstrap.Modal(mainModalRef.value, {
|
||||
backdrop: 'static',
|
||||
keyboard: false
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
return {
|
||||
mainGridRef,
|
||||
mainModalRef,
|
||||
productGroupIdRef,
|
||||
unitMeasureIdRef,
|
||||
nameRef,
|
||||
numberRef,
|
||||
unitPriceRef,
|
||||
state,
|
||||
handler,
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
Vue.createApp(App).mount('#app');
|
||||
@@ -0,0 +1,167 @@
|
||||
@page
|
||||
@attribute [Authorize(Roles = "Profiles")]
|
||||
@{
|
||||
ViewData["Title"] = "My Profile";
|
||||
}
|
||||
|
||||
<div id="app" v-cloak>
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<div class="grid-container">
|
||||
<div ref="mainGridRef"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="modal fade" ref="mainModalRef" id="MainModal" tabindex="-1" aria-hidden="true" data-bs-backdrop="static">
|
||||
<div class="modal-dialog modal-dialog-centered modal-lg">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title">{{ state.mainTitle }}</h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<input type="hidden" v-model="state.userId" id="UserId" name="UserId" />
|
||||
<form id="MainForm">
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<h5>Main Info</h5>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="row mb-0">
|
||||
<div class="col-md-6">
|
||||
<label for="FirstName">First Name</label>
|
||||
<input ref="firstNameRef" v-model="state.firstName" type="text" class="form-control" placeholder="">
|
||||
<label class="text-danger">{{ state.errors.firstName }}</label>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<label for="LastName">Last Name</label>
|
||||
<input ref="lastNameRef" v-model="state.lastName" type="text" class="form-control" placeholder="">
|
||||
<label class="text-danger">{{ state.errors.lastName }}</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mb-0">
|
||||
<div class="col-12">
|
||||
<label for="CompanyName">Company Name</label>
|
||||
<textarea ref="companyNameRef" v-model="state.companyName" class="form-control" rows="3"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
|
||||
<button type="button"
|
||||
id="MainSaveButton"
|
||||
class="btn"
|
||||
v-bind:class="state.deleteMode ? 'btn-danger' : 'btn-primary'"
|
||||
v-on:click="handler.handleSubmit"
|
||||
v-bind:disabled="state.isSubmitting">
|
||||
<span class="spinner-border spinner-border-sm me-2" v-if="state.isSubmitting" role="status" aria-hidden="true"></span>
|
||||
<span v-if="!state.isSubmitting">{{ state.deleteMode ? 'Delete' : 'Save' }}</span>
|
||||
<span v-else>{{ state.deleteMode ? 'Deleting...' : 'Saving...' }}</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Modal untuk Change Password -->
|
||||
<div class="modal fade" ref="changePasswordModalRef" id="ChangePasswordModal" tabindex="-1" aria-hidden="true" data-bs-backdrop="static">
|
||||
<div class="modal-dialog modal-dialog-centered modal-lg">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title">{{ state.changePasswordTitle }}</h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<input type="hidden" v-model="state.userId" id="UserId" name="UserId" />
|
||||
<form id="ChangePasswordForm">
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<div class="card">
|
||||
<div class="card-header bg-primary text-white">
|
||||
Old Password
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="mb-3">
|
||||
<label for="OldPassword">Old Password</label>
|
||||
<input ref="oldPasswordRef" v-model="state.oldPassword" type="password" class="form-control" placeholder="Enter old password">
|
||||
<label class="text-danger">{{ state.errors.oldPassword }}</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<div class="card">
|
||||
<div class="card-header bg-success text-white">
|
||||
New Password
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="mb-3">
|
||||
<label for="NewPassword">New Password</label>
|
||||
<input ref="newPasswordRef" v-model="state.newPassword" type="password" class="form-control" placeholder="Enter new password">
|
||||
<label class="text-danger">{{ state.errors.newPassword }}</label>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="ConfirmNewPassword">Confirm New Password</label>
|
||||
<input ref="confirmNewPasswordRef" v-model="state.confirmNewPassword" type="password" class="form-control" placeholder="Confirm new password">
|
||||
<label class="text-danger">{{ state.errors.confirmNewPassword }}</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
|
||||
<button type="button" id="ChangePasswordSaveButton" class="btn btn-primary" v-on:click="handler.handleChangePassword">
|
||||
<span class="spinner-border spinner-border-sm me-2" v-if="state.isSubmitting" role="status" aria-hidden="true"></span>
|
||||
<span v-if="!state.isSubmitting">Save</span>
|
||||
<span v-else>Saving...</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Modal untuk Change Avatar -->
|
||||
<div class="modal fade" ref="changeAvatarModalRef" id="ChangeAvatarModal" tabindex="-1" aria-hidden="true" data-bs-backdrop="static">
|
||||
<div class="modal-dialog modal-dialog-centered modal-lg">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title">{{ state.changeAvatarTitle }}</h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<input type="hidden" v-model="state.userId" id="UserId" name="UserId" />
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<h5>Uploader Area</h5>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<form ref="imageUploadRef" id="ImageUpload" class="dropzone"></form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@section scripts {
|
||||
<script src="~/FrontEnd/Pages/Profiles/MyProfile.cshtml.js"></script>
|
||||
}
|
||||
@@ -0,0 +1,465 @@
|
||||
const App = {
|
||||
setup() {
|
||||
const state = Vue.reactive({
|
||||
mainData: [],
|
||||
userId: '',
|
||||
firstName: '',
|
||||
lastName: '',
|
||||
companyName: '',
|
||||
oldPassword: '',
|
||||
newPassword: '',
|
||||
confirmNewPassword: '',
|
||||
mainTitle: 'Edit MyProfile',
|
||||
changePasswordTitle: 'Change Password',
|
||||
changeAvatarTitle: 'Change Avatar',
|
||||
errors: {
|
||||
firstName: '',
|
||||
lastName: '',
|
||||
oldPassword: '',
|
||||
newPassword: '',
|
||||
confirmNewPassword: ''
|
||||
},
|
||||
isSubmitting: false
|
||||
});
|
||||
|
||||
const mainGridRef = Vue.ref(null);
|
||||
const mainModalRef = Vue.ref(null);
|
||||
const changePasswordModalRef = Vue.ref(null);
|
||||
const changeAvatarModalRef = Vue.ref(null);
|
||||
const firstNameRef = Vue.ref(null);
|
||||
const lastNameRef = Vue.ref(null);
|
||||
const companyNameRef = Vue.ref(null);
|
||||
const oldPasswordRef = Vue.ref(null);
|
||||
const newPasswordRef = Vue.ref(null);
|
||||
const confirmNewPasswordRef = Vue.ref(null);
|
||||
const imageUploadRef = Vue.ref(null);
|
||||
|
||||
const services = {
|
||||
getMainData: async () => {
|
||||
try {
|
||||
const response = await AxiosManager.get('/Security/GetMyProfileList?userId=' + StorageManager.getUserId(), {});
|
||||
return response;
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
},
|
||||
updateMainData: async (userId, firstName, lastName, companyName) => {
|
||||
try {
|
||||
const response = await AxiosManager.post('/Security/UpdateMyProfile', {
|
||||
userId, firstName, lastName, companyName
|
||||
});
|
||||
return response;
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
},
|
||||
updatePasswordData: async (userId, oldPassword, newPassword, confirmNewPassword) => {
|
||||
try {
|
||||
const response = await AxiosManager.post('/Security/UpdateMyProfilePassword', {
|
||||
userId, oldPassword, newPassword, confirmNewPassword
|
||||
});
|
||||
return response;
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
},
|
||||
uploadImage: async (file) => {
|
||||
const formData = new FormData();
|
||||
formData.append('file', file);
|
||||
try {
|
||||
const response = await AxiosManager.post('/FileImage/UploadImage', formData, {
|
||||
headers: {
|
||||
'Content-Type': 'multipart/form-data'
|
||||
}
|
||||
});
|
||||
return response;
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
},
|
||||
updateAvatarData: async (userId, avatar) => {
|
||||
try {
|
||||
const response = await AxiosManager.post('/Security/UpdateMyProfileAvatar', {
|
||||
userId, avatar
|
||||
});
|
||||
return response;
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
const mainGrid = {
|
||||
obj: null,
|
||||
create: async (dataSource) => {
|
||||
mainGrid.obj = new ej.grids.Grid({
|
||||
height: '240px',
|
||||
dataSource: dataSource,
|
||||
allowFiltering: true,
|
||||
allowSorting: true,
|
||||
allowSelection: true,
|
||||
allowGrouping: true,
|
||||
allowTextWrap: true,
|
||||
allowResizing: true,
|
||||
allowPaging: true,
|
||||
allowExcelExport: true,
|
||||
filterSettings: { type: 'CheckBox' },
|
||||
sortSettings: { columns: [{ field: 'firstName', direction: 'Descending' }] },
|
||||
pageSettings: { currentPage: 1, pageSize: 50, pageSizes: ["10", "20", "50", "100", "200", "All"] },
|
||||
selectionSettings: { persistSelection: true, type: 'Single' },
|
||||
autoFit: true,
|
||||
showColumnMenu: true,
|
||||
gridLines: 'Horizontal',
|
||||
columns: [
|
||||
{ type: 'checkbox', width: 60 },
|
||||
{
|
||||
field: 'id', isPrimaryKey: true, headerText: 'Id', visible: false
|
||||
},
|
||||
{ field: 'firstName', headerText: 'First Name', width: 200, minWidth: 200 },
|
||||
{ field: 'lastName', headerText: 'Last Name', width: 200, minWidth: 200 },
|
||||
{ field: 'companyName', headerText: 'Company Name', width: 400, minWidth: 400 },
|
||||
],
|
||||
toolbar: [
|
||||
'ExcelExport', 'Search',
|
||||
{ type: 'Separator' },
|
||||
{ text: 'Edit', tooltipText: 'Edit', prefixIcon: 'e-edit', id: 'EditCustom' },
|
||||
{ type: 'Separator' },
|
||||
{ text: 'Change Password', tooltipText: 'Change Password', id: 'ChangePasswordCustom' },
|
||||
{ text: 'Change Avatar', tooltipText: 'Change Avatar', id: 'ChangeAvatarCustom' },
|
||||
],
|
||||
beforeDataBound: () => { },
|
||||
dataBound: function () {
|
||||
mainGrid.obj.toolbarModule.enableItems(['EditCustom', 'ChangePasswordCustom', 'ChangeAvatarCustom'], false);
|
||||
mainGrid.obj.autoFitColumns(['firstName', 'lastName', 'companyName']);
|
||||
},
|
||||
excelExportComplete: () => { },
|
||||
rowSelected: () => {
|
||||
if (mainGrid.obj.getSelectedRecords().length === 1) {
|
||||
mainGrid.obj.toolbarModule.enableItems(['EditCustom', 'ChangePasswordCustom', 'ChangeAvatarCustom'], true);
|
||||
} else {
|
||||
mainGrid.obj.toolbarModule.enableItems(['EditCustom', 'ChangePasswordCustom', 'ChangeAvatarCustom'], false);
|
||||
}
|
||||
},
|
||||
rowDeselected: () => {
|
||||
if (mainGrid.obj.getSelectedRecords().length === 1) {
|
||||
mainGrid.obj.toolbarModule.enableItems(['EditCustom', 'ChangePasswordCustom', 'ChangeAvatarCustom'], true);
|
||||
} else {
|
||||
mainGrid.obj.toolbarModule.enableItems(['EditCustom', 'ChangePasswordCustom', 'ChangeAvatarCustom'], false);
|
||||
}
|
||||
},
|
||||
rowSelecting: () => {
|
||||
if (mainGrid.obj.getSelectedRecords().length) {
|
||||
mainGrid.obj.clearSelection();
|
||||
}
|
||||
},
|
||||
toolbarClick: (args) => {
|
||||
if (args.item.id === 'MainGrid_excelexport') {
|
||||
mainGrid.obj.excelExport();
|
||||
}
|
||||
|
||||
if (args.item.id === 'EditCustom') {
|
||||
if (mainGrid.obj.getSelectedRecords().length) {
|
||||
const selectedRecord = mainGrid.obj.getSelectedRecords()[0];
|
||||
state.userId = selectedRecord.id ?? '';
|
||||
state.firstName = selectedRecord.firstName ?? '';
|
||||
state.lastName = selectedRecord.lastName ?? '';
|
||||
state.companyName = selectedRecord.companyName ?? '';
|
||||
mainModal.obj.show();
|
||||
}
|
||||
}
|
||||
|
||||
if (args.item.id === 'ChangePasswordCustom') {
|
||||
if (mainGrid.obj.getSelectedRecords().length) {
|
||||
const selectedRecord = mainGrid.obj.getSelectedRecords()[0];
|
||||
state.userId = selectedRecord.id ?? '';
|
||||
changePasswordModal.obj.show();
|
||||
}
|
||||
}
|
||||
|
||||
if (args.item.id === 'ChangeAvatarCustom') {
|
||||
if (mainGrid.obj.getSelectedRecords().length) {
|
||||
const selectedRecord = mainGrid.obj.getSelectedRecords()[0];
|
||||
state.userId = selectedRecord.id ?? '';
|
||||
changeAvatarModal.obj.show();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
mainGrid.obj.appendTo(mainGridRef.value);
|
||||
},
|
||||
refresh: () => {
|
||||
mainGrid.obj.setProperties({ dataSource: state.mainData });
|
||||
}
|
||||
};
|
||||
|
||||
const handler = {
|
||||
handleSubmit: async () => {
|
||||
state.isSubmitting = true;
|
||||
await new Promise(resolve => setTimeout(resolve, 200));
|
||||
|
||||
state.errors.firstName = '';
|
||||
state.errors.lastName = '';
|
||||
let isValid = true;
|
||||
|
||||
// Validasi firstName
|
||||
if (!state.firstName) {
|
||||
state.errors.firstName = 'First Name is required.';
|
||||
isValid = false;
|
||||
}
|
||||
|
||||
// Validasi lastName
|
||||
if (!state.lastName) {
|
||||
state.errors.lastName = 'Last Name is required.';
|
||||
isValid = false;
|
||||
}
|
||||
|
||||
if (!isValid) {
|
||||
state.isSubmitting = false;
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const response = await services.updateMainData(state.userId, state.firstName, state.lastName, state.companyName);
|
||||
if (response.data.code === 200) {
|
||||
await methods.populateMainData();
|
||||
mainGrid.refresh();
|
||||
Swal.fire({
|
||||
icon: 'success',
|
||||
title: 'Save Successful',
|
||||
text: 'Form will be closed...',
|
||||
timer: 2000,
|
||||
showConfirmButton: false
|
||||
});
|
||||
setTimeout(() => {
|
||||
mainModal.obj.hide();
|
||||
}, 2000);
|
||||
} else {
|
||||
Swal.fire({
|
||||
icon: 'error',
|
||||
title: 'Save Failed',
|
||||
text: response.data.message ?? 'Please check your data.',
|
||||
confirmButtonText: 'Try Again'
|
||||
});
|
||||
}
|
||||
} catch (error) {
|
||||
Swal.fire({
|
||||
icon: 'error',
|
||||
title: 'An Error Occurred',
|
||||
text: error.response?.data?.message ?? 'Please try again.',
|
||||
confirmButtonText: 'OK'
|
||||
});
|
||||
} finally {
|
||||
state.isSubmitting = false;
|
||||
}
|
||||
},
|
||||
handleChangePassword: async () => {
|
||||
state.isSubmitting = true;
|
||||
await new Promise(resolve => setTimeout(resolve, 200));
|
||||
|
||||
state.errors.oldPassword = '';
|
||||
state.errors.newPassword = '';
|
||||
state.errors.confirmNewPassword = '';
|
||||
let isValid = true;
|
||||
|
||||
// old password validation
|
||||
if (!state.oldPassword) {
|
||||
state.errors.oldPassword = 'Old Password is required.';
|
||||
isValid = false;
|
||||
} else if (state.oldPassword.length < 6) {
|
||||
state.errors.oldPassword = 'Old Password must be at least 6 characters.';
|
||||
isValid = false;
|
||||
}
|
||||
|
||||
// new password validation
|
||||
if (!state.newPassword) {
|
||||
state.errors.newPassword = 'New Password is required.';
|
||||
isValid = false;
|
||||
} else if (state.newPassword.length < 6) {
|
||||
state.errors.newPassword = 'New Password must be at least 6 characters.';
|
||||
isValid = false;
|
||||
}
|
||||
|
||||
// confirm new password validation
|
||||
if (!state.confirmNewPassword) {
|
||||
state.errors.confirmNewPassword = 'Confirm New Password is required.';
|
||||
isValid = false;
|
||||
} else if (state.confirmNewPassword.length < 6) {
|
||||
state.errors.confirmNewPassword = 'Confirm New Password must be at least 6 characters.';
|
||||
isValid = false;
|
||||
}
|
||||
|
||||
if (!isValid) {
|
||||
state.isSubmitting = false;
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const response = await services.updatePasswordData(state.userId, state.oldPassword, state.newPassword, state.confirmNewPassword);
|
||||
if (response.data.code === 200) {
|
||||
Swal.fire({
|
||||
icon: 'success',
|
||||
title: 'Save Successful',
|
||||
text: 'Form will be closed...',
|
||||
timer: 2000,
|
||||
showConfirmButton: false
|
||||
});
|
||||
setTimeout(() => {
|
||||
changePasswordModal.obj.hide();
|
||||
}, 2000);
|
||||
} else {
|
||||
Swal.fire({
|
||||
icon: 'error',
|
||||
title: 'Save Failed',
|
||||
text: response.data.message ?? 'Please check your data.',
|
||||
confirmButtonText: 'Try Again'
|
||||
});
|
||||
}
|
||||
} catch (error) {
|
||||
Swal.fire({
|
||||
icon: 'error',
|
||||
title: 'An Error Occurred',
|
||||
text: error.response?.data?.message ?? 'Please try again.',
|
||||
confirmButtonText: 'OK'
|
||||
});
|
||||
} finally {
|
||||
state.isSubmitting = false;
|
||||
}
|
||||
},
|
||||
handleFileUpload: async (file) => {
|
||||
try {
|
||||
const response = await services.uploadImage(file);
|
||||
if (response.status === 200) {
|
||||
const imageName = response?.data?.content?.imageName;
|
||||
await services.updateAvatarData(state.userId, imageName);
|
||||
StorageManager.saveAvatar(imageName);
|
||||
|
||||
Swal.fire({
|
||||
icon: "success",
|
||||
title: "Upload Successful",
|
||||
text: "Your image has been uploaded successfully!",
|
||||
text: 'Page will be refreshed...',
|
||||
timer: 1000,
|
||||
showConfirmButton: false
|
||||
});
|
||||
|
||||
setTimeout(() => {
|
||||
changeAvatarModal.obj.hide();
|
||||
location.reload();
|
||||
}, 1000);
|
||||
} else {
|
||||
Swal.fire({
|
||||
icon: "error",
|
||||
title: "Upload Failed",
|
||||
text: response.message ?? "An error occurred during upload."
|
||||
});
|
||||
}
|
||||
} catch (error) {
|
||||
Swal.fire({
|
||||
icon: "error",
|
||||
title: "Upload Failed",
|
||||
text: "An unexpected error occurred."
|
||||
});
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
const methods = {
|
||||
populateMainData: async () => {
|
||||
const response = await services.getMainData();
|
||||
state.mainData = response?.data?.content?.data;
|
||||
},
|
||||
};
|
||||
|
||||
Vue.onMounted(async () => {
|
||||
Dropzone.autoDiscover = false;
|
||||
try {
|
||||
await SecurityManager.authorizePage(['Profiles']);
|
||||
await SecurityManager.validateToken();
|
||||
await methods.populateMainData();
|
||||
await mainGrid.create(state.mainData);
|
||||
|
||||
mainModal.create();
|
||||
changePasswordModal.create();
|
||||
changeAvatarModal.create();
|
||||
|
||||
initDropzone();
|
||||
|
||||
} catch (e) {
|
||||
console.error('page init error:', e);
|
||||
} finally {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
let dropzoneInitialized = false;
|
||||
const initDropzone = () => {
|
||||
if (!dropzoneInitialized && imageUploadRef.value) {
|
||||
dropzoneInitialized = true;
|
||||
const dropzoneInstance = new Dropzone(imageUploadRef.value, {
|
||||
url: "api/FileImage/UploadImage",
|
||||
paramName: "file",
|
||||
maxFilesize: 5,
|
||||
acceptedFiles: "image/*",
|
||||
addRemoveLinks: true,
|
||||
dictDefaultMessage: "Drag and drop an image here to upload",
|
||||
autoProcessQueue: false,
|
||||
init: function () {
|
||||
this.on("addedfile", async function (file) {
|
||||
await handler.handleFileUpload(file);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
const mainModal = {
|
||||
obj: null,
|
||||
create: () => {
|
||||
mainModal.obj = new bootstrap.Modal(mainModalRef.value, {
|
||||
backdrop: 'static',
|
||||
keyboard: false
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
const changePasswordModal = {
|
||||
obj: null,
|
||||
create: () => {
|
||||
changePasswordModal.obj = new bootstrap.Modal(changePasswordModalRef.value, {
|
||||
backdrop: 'static',
|
||||
keyboard: false
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
const changeAvatarModal = {
|
||||
obj: null,
|
||||
create: () => {
|
||||
changeAvatarModal.obj = new bootstrap.Modal(changeAvatarModalRef.value, {
|
||||
backdrop: 'static',
|
||||
keyboard: false
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
return {
|
||||
state,
|
||||
mainGridRef,
|
||||
mainModalRef,
|
||||
changePasswordModalRef,
|
||||
changeAvatarModalRef,
|
||||
firstNameRef,
|
||||
lastNameRef,
|
||||
companyNameRef,
|
||||
oldPasswordRef,
|
||||
newPasswordRef,
|
||||
confirmNewPasswordRef,
|
||||
imageUploadRef,
|
||||
handler
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
Vue.createApp(App).mount('#app');
|
||||
@@ -0,0 +1,143 @@
|
||||
@page
|
||||
@attribute [Authorize(Roles = "PurchaseOrders")]
|
||||
@{
|
||||
ViewData["Title"] = "Purchase Order List";
|
||||
}
|
||||
|
||||
<div id="app" v-cloak>
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<div class="grid-container">
|
||||
<div ref="mainGridRef"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="modal fade" ref="mainModalRef" id="MainModal" aria-hidden="true" tabindex="-1" data-bs-focus="false" data-bs-backdrop="static">
|
||||
<div class="modal-dialog modal-dialog-centered modal-xl">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title">{{ state.mainTitle }}</h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<input type="hidden" v-model="state.id" id="Id" name="Id" />
|
||||
<form id="MainForm">
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<h5>Main Info</h5>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="row mb-2">
|
||||
<div class="col-md-6">
|
||||
<label for="OrderDate">Order Date</label>
|
||||
<input ref="orderDateRef" />
|
||||
<label class="text-danger">{{ state.errors.orderDate }}</label>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<label for="Number">Number</label>
|
||||
<input ref="numberRef" v-model="state.number" readonly>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mb-2">
|
||||
<div class="col-md-6">
|
||||
<label for="VendorId">Vendor</label>
|
||||
<div ref="vendorIdRef"></div>
|
||||
<label class="text-danger">{{ state.errors.vendorId }}</label>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<label for="TaxId">Tax</label>
|
||||
<div ref="taxIdRef"></div>
|
||||
<label class="text-danger">{{ state.errors.taxId }}</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mb-2">
|
||||
<div class="col-md-6">
|
||||
<label for="OrderStatus">Order Status</label>
|
||||
<div ref="orderStatusRef"></div>
|
||||
<label class="text-danger">{{ state.errors.orderStatus }}</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mb-2">
|
||||
<div class="col-md-12">
|
||||
<label for="Description">Description</label>
|
||||
<textarea class="form-control" rows="3" v-model="state.description"></textarea>
|
||||
<label class="text-danger">{{ state.errors.description }}</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
<div id="ComplexDiv" :style="{ display: state.showComplexDiv ? 'block' : 'none' }">
|
||||
<div class="row mt-3">
|
||||
<div class="col-md-12">
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<h5>Purchase Order Item</h5>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<div class="grid-container">
|
||||
<div ref="secondaryGridRef"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mt-4">
|
||||
<div class="col-md-12">
|
||||
<div class="card shadow-sm">
|
||||
<div class="card-header text-white">
|
||||
<h5 class="mb-0">Payment Summary</h5>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="row justify-content-end">
|
||||
<div class="col-md-6">
|
||||
<div class="d-flex justify-content-between py-2 border-bottom">
|
||||
<span class="fw-bold">Subtotal</span>
|
||||
<span id="SubTotalAmount">{{ state.subTotalAmount }}</span>
|
||||
</div>
|
||||
<div class="d-flex justify-content-between py-2 border-bottom">
|
||||
<span class="fw-bold">Tax</span>
|
||||
<span id="TaxAmount">{{ state.taxAmount }}</span>
|
||||
</div>
|
||||
<div class="d-flex justify-content-between py-2">
|
||||
<span class="fw-bold">Total Amount</span>
|
||||
<span id="TotalAmount" class="fw-bold text-success">{{ state.totalAmount }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
|
||||
<button type="button"
|
||||
id="MainSaveButton"
|
||||
class="btn"
|
||||
v-bind:class="state.deleteMode ? 'btn-danger' : 'btn-primary'"
|
||||
v-on:click="handler.handleSubmit"
|
||||
v-bind:disabled="state.isSubmitting">
|
||||
<span class="spinner-border spinner-border-sm me-2" v-if="state.isSubmitting" role="status" aria-hidden="true"></span>
|
||||
<span v-if="!state.isSubmitting">{{ state.deleteMode ? 'Delete' : 'Save' }}</span>
|
||||
<span v-else>{{ state.deleteMode ? 'Deleting...' : 'Saving...' }}</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@section scripts {
|
||||
<script src="~/FrontEnd/Pages/PurchaseOrders/PurchaseOrderList.cshtml.js"></script>
|
||||
}
|
||||
+988
@@ -0,0 +1,988 @@
|
||||
const App = {
|
||||
setup() {
|
||||
const state = Vue.reactive({
|
||||
mainData: [],
|
||||
deleteMode: false,
|
||||
vendorListLookupData: [],
|
||||
taxListLookupData: [],
|
||||
purchaseOrderStatusListLookupData: [],
|
||||
secondaryData: [],
|
||||
productListLookupData: [],
|
||||
mainTitle: null,
|
||||
id: '',
|
||||
number: '',
|
||||
orderDate: '',
|
||||
description: '',
|
||||
vendorId: null,
|
||||
taxId: null,
|
||||
orderStatus: null,
|
||||
errors: {
|
||||
orderDate: '',
|
||||
vendorId: '',
|
||||
taxId: '',
|
||||
orderStatus: '',
|
||||
description: ''
|
||||
},
|
||||
showComplexDiv: false,
|
||||
isSubmitting: false,
|
||||
subTotalAmount: '0.00',
|
||||
taxAmount: '0.00',
|
||||
totalAmount: '0.00'
|
||||
});
|
||||
|
||||
const mainGridRef = Vue.ref(null);
|
||||
const mainModalRef = Vue.ref(null);
|
||||
const orderDateRef = Vue.ref(null);
|
||||
const numberRef = Vue.ref(null);
|
||||
const vendorIdRef = Vue.ref(null);
|
||||
const taxIdRef = Vue.ref(null);
|
||||
const orderStatusRef = Vue.ref(null);
|
||||
const secondaryGridRef = Vue.ref(null);
|
||||
|
||||
const validateForm = function () {
|
||||
state.errors.orderDate = '';
|
||||
state.errors.vendorId = '';
|
||||
state.errors.taxId = '';
|
||||
state.errors.orderStatus = '';
|
||||
|
||||
let isValid = true;
|
||||
|
||||
if (!state.orderDate) {
|
||||
state.errors.orderDate = 'Order date is required.';
|
||||
isValid = false;
|
||||
}
|
||||
if (!state.vendorId) {
|
||||
state.errors.vendorId = 'Vendor is required.';
|
||||
isValid = false;
|
||||
}
|
||||
if (!state.taxId) {
|
||||
state.errors.taxId = 'Tax is required.';
|
||||
isValid = false;
|
||||
}
|
||||
if (!state.orderStatus) {
|
||||
state.errors.orderStatus = 'Order status is required.';
|
||||
isValid = false;
|
||||
}
|
||||
|
||||
return isValid;
|
||||
};
|
||||
|
||||
const resetFormState = () => {
|
||||
state.id = '';
|
||||
state.number = '';
|
||||
state.orderDate = '';
|
||||
state.description = '';
|
||||
state.vendorId = null;
|
||||
state.taxId = null;
|
||||
state.orderStatus = null;
|
||||
state.errors = {
|
||||
orderDate: '',
|
||||
vendorId: '',
|
||||
taxId: '',
|
||||
orderStatus: '',
|
||||
description: ''
|
||||
};
|
||||
state.secondaryData = [];
|
||||
state.subTotalAmount = '0.00';
|
||||
state.taxAmount = '0.00';
|
||||
state.totalAmount = '0.00';
|
||||
state.showComplexDiv = false;
|
||||
};
|
||||
|
||||
const services = {
|
||||
getMainData: async () => {
|
||||
try {
|
||||
const response = await AxiosManager.get('/PurchaseOrder/GetPurchaseOrderList', {});
|
||||
return response;
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
},
|
||||
createMainData: async (orderDate, description, orderStatus, taxId, vendorId, createdById) => {
|
||||
try {
|
||||
const response = await AxiosManager.post('/PurchaseOrder/CreatePurchaseOrder', {
|
||||
orderDate, description, orderStatus, taxId, vendorId, createdById
|
||||
});
|
||||
return response;
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
},
|
||||
updateMainData: async (id, orderDate, description, orderStatus, taxId, vendorId, updatedById) => {
|
||||
try {
|
||||
const response = await AxiosManager.post('/PurchaseOrder/UpdatePurchaseOrder', {
|
||||
id, orderDate, description, orderStatus, taxId, vendorId, updatedById
|
||||
});
|
||||
return response;
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
},
|
||||
deleteMainData: async (id, deletedById) => {
|
||||
try {
|
||||
const response = await AxiosManager.post('/PurchaseOrder/DeletePurchaseOrder', {
|
||||
id, deletedById
|
||||
});
|
||||
return response;
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
},
|
||||
getVendorListLookupData: async () => {
|
||||
try {
|
||||
const response = await AxiosManager.get('/Vendor/GetVendorList', {});
|
||||
return response;
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
},
|
||||
getTaxListLookupData: async () => {
|
||||
try {
|
||||
const response = await AxiosManager.get('/Tax/GetTaxList', {});
|
||||
return response;
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
},
|
||||
getPurchaseOrderStatusListLookupData: async () => {
|
||||
try {
|
||||
const response = await AxiosManager.get('/PurchaseOrder/GetPurchaseOrderStatusList', {});
|
||||
return response;
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
},
|
||||
getSecondaryData: async (purchaseOrderId) => {
|
||||
try {
|
||||
const response = await AxiosManager.get('/PurchaseOrderItem/GetPurchaseOrderItemByPurchaseOrderIdList?purchaseOrderId=' + purchaseOrderId, {});
|
||||
return response;
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
},
|
||||
createSecondaryData: async (unitPrice, quantity, summary, productId, purchaseOrderId, createdById) => {
|
||||
try {
|
||||
const response = await AxiosManager.post('/PurchaseOrderItem/CreatePurchaseOrderItem', {
|
||||
unitPrice, quantity, summary, productId, purchaseOrderId, createdById
|
||||
});
|
||||
return response;
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
},
|
||||
updateSecondaryData: async (id, unitPrice, quantity, summary, productId, purchaseOrderId, updatedById) => {
|
||||
try {
|
||||
const response = await AxiosManager.post('/PurchaseOrderItem/UpdatePurchaseOrderItem', {
|
||||
id, unitPrice, quantity, summary, productId, purchaseOrderId, updatedById
|
||||
});
|
||||
return response;
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
},
|
||||
deleteSecondaryData: async (id, deletedById) => {
|
||||
try {
|
||||
const response = await AxiosManager.post('/PurchaseOrderItem/DeletePurchaseOrderItem', {
|
||||
id, deletedById
|
||||
});
|
||||
return response;
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
},
|
||||
getProductListLookupData: async () => {
|
||||
try {
|
||||
const response = await AxiosManager.get('/Product/GetProductList', {});
|
||||
return response;
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const methods = {
|
||||
populateVendorListLookupData: async () => {
|
||||
const response = await services.getVendorListLookupData();
|
||||
state.vendorListLookupData = response?.data?.content?.data;
|
||||
},
|
||||
populateTaxListLookupData: async () => {
|
||||
const response = await services.getTaxListLookupData();
|
||||
state.taxListLookupData = response?.data?.content?.data;
|
||||
},
|
||||
populatePurchaseOrderStatusListLookupData: async () => {
|
||||
const response = await services.getPurchaseOrderStatusListLookupData();
|
||||
state.purchaseOrderStatusListLookupData = response?.data?.content?.data;
|
||||
},
|
||||
populateMainData: async () => {
|
||||
const response = await services.getMainData();
|
||||
state.mainData = response?.data?.content?.data.map(item => ({
|
||||
...item,
|
||||
orderDate: new Date(item.orderDate),
|
||||
createdAtUtc: new Date(item.createdAtUtc)
|
||||
}));
|
||||
},
|
||||
populateSecondaryData: async (purchaseOrderId) => {
|
||||
try {
|
||||
const response = await services.getSecondaryData(purchaseOrderId);
|
||||
state.secondaryData = response?.data?.content?.data.map(item => ({
|
||||
...item,
|
||||
createdAtUtc: new Date(item.createdAtUtc)
|
||||
}));
|
||||
methods.refreshPaymentSummary(purchaseOrderId);
|
||||
} catch (error) {
|
||||
state.secondaryData = [];
|
||||
}
|
||||
},
|
||||
populateProductListLookupData: async () => {
|
||||
const response = await services.getProductListLookupData();
|
||||
state.productListLookupData = response?.data?.content?.data;
|
||||
},
|
||||
refreshPaymentSummary: async (id) => {
|
||||
const record = state.mainData.find(item => item.id === id);
|
||||
if (record) {
|
||||
state.subTotalAmount = NumberFormatManager.formatToLocale(record.beforeTaxAmount ?? 0);
|
||||
state.taxAmount = NumberFormatManager.formatToLocale(record.taxAmount ?? 0);
|
||||
state.totalAmount = NumberFormatManager.formatToLocale(record.afterTaxAmount ?? 0);
|
||||
}
|
||||
},
|
||||
handleFormSubmit: async () => {
|
||||
state.isSubmitting = true;
|
||||
await new Promise(resolve => setTimeout(resolve, 200));
|
||||
|
||||
if (!validateForm()) {
|
||||
state.isSubmitting = false;
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const response = state.id === ''
|
||||
? await services.createMainData(state.orderDate, state.description, state.orderStatus, state.taxId, state.vendorId, StorageManager.getUserId())
|
||||
: state.deleteMode
|
||||
? await services.deleteMainData(state.id, StorageManager.getUserId())
|
||||
: await services.updateMainData(state.id, state.orderDate, state.description, state.orderStatus, state.taxId, state.vendorId, StorageManager.getUserId());
|
||||
|
||||
if (response.data.code === 200) {
|
||||
await methods.populateMainData();
|
||||
mainGrid.refresh();
|
||||
|
||||
if (!state.deleteMode) {
|
||||
state.mainTitle = 'Edit Purchase Order';
|
||||
state.id = response?.data?.content?.data.id ?? '';
|
||||
state.number = response?.data?.content?.data.number ?? '';
|
||||
state.orderDate = response?.data?.content?.data.orderDate ? new Date(response.data.content.data.orderDate) : null;
|
||||
state.description = response?.data?.content?.data.description ?? '';
|
||||
state.vendorId = response?.data?.content?.data.vendorId ?? '';
|
||||
state.taxId = response?.data?.content?.data.taxId ?? '';
|
||||
taxListLookup.trackingChange = true;
|
||||
state.orderStatus = String(response?.data?.content?.data.orderStatus ?? '');
|
||||
state.showComplexDiv = true;
|
||||
|
||||
await methods.refreshPaymentSummary(state.id);
|
||||
|
||||
Swal.fire({
|
||||
icon: 'success',
|
||||
title: 'Save Successful',
|
||||
timer: 1000,
|
||||
showConfirmButton: false
|
||||
});
|
||||
} else {
|
||||
Swal.fire({
|
||||
icon: 'success',
|
||||
title: 'Delete Successful',
|
||||
text: 'Form will be closed...',
|
||||
timer: 2000,
|
||||
showConfirmButton: false
|
||||
});
|
||||
setTimeout(() => {
|
||||
mainModal.obj.hide();
|
||||
resetFormState();
|
||||
}, 2000);
|
||||
}
|
||||
|
||||
} else {
|
||||
Swal.fire({
|
||||
icon: 'error',
|
||||
title: state.deleteMode ? 'Delete Failed' : 'Save Failed',
|
||||
text: response.data.message ?? 'Please check your data.',
|
||||
confirmButtonText: 'Try Again'
|
||||
});
|
||||
}
|
||||
} catch (error) {
|
||||
Swal.fire({
|
||||
icon: 'error',
|
||||
title: 'An Error Occurred',
|
||||
text: error.response?.data?.message ?? 'Please try again.',
|
||||
confirmButtonText: 'OK'
|
||||
});
|
||||
} finally {
|
||||
state.isSubmitting = false;
|
||||
}
|
||||
},
|
||||
onMainModalHidden: () => {
|
||||
state.errors.orderDate = '';
|
||||
state.errors.vendorId = '';
|
||||
state.errors.taxId = '';
|
||||
state.errors.orderStatus = '';
|
||||
taxListLookup.trackingChange = false;
|
||||
}
|
||||
};
|
||||
|
||||
const vendorListLookup = {
|
||||
obj: null,
|
||||
create: () => {
|
||||
if (state.vendorListLookupData && Array.isArray(state.vendorListLookupData)) {
|
||||
vendorListLookup.obj = new ej.dropdowns.DropDownList({
|
||||
dataSource: state.vendorListLookupData,
|
||||
fields: { value: 'id', text: 'name' },
|
||||
placeholder: 'Select a Vendor',
|
||||
filterBarPlaceholder: 'Search',
|
||||
sortOrder: 'Ascending',
|
||||
allowFiltering: true,
|
||||
filtering: (e) => {
|
||||
e.preventDefaultAction = true;
|
||||
let query = new ej.data.Query();
|
||||
if (e.text !== '') {
|
||||
query = query.where('name', 'startsWith', e.text, true);
|
||||
}
|
||||
e.updateData(state.vendorListLookupData, query);
|
||||
},
|
||||
change: (e) => {
|
||||
state.vendorId = e.value;
|
||||
}
|
||||
});
|
||||
vendorListLookup.obj.appendTo(vendorIdRef.value);
|
||||
}
|
||||
},
|
||||
refresh: () => {
|
||||
if (vendorListLookup.obj) {
|
||||
vendorListLookup.obj.value = state.vendorId;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const taxListLookup = {
|
||||
obj: null,
|
||||
trackingChange: false,
|
||||
create: () => {
|
||||
if (state.taxListLookupData && Array.isArray(state.taxListLookupData)) {
|
||||
taxListLookup.obj = new ej.dropdowns.DropDownList({
|
||||
dataSource: state.taxListLookupData,
|
||||
fields: { value: 'id', text: 'name' },
|
||||
placeholder: 'Select a Tax',
|
||||
change: async (e) => {
|
||||
state.taxId = e.value;
|
||||
if (e.isInteracted && taxListLookup.trackingChange) {
|
||||
await methods.handleFormSubmit();
|
||||
}
|
||||
}
|
||||
});
|
||||
taxListLookup.obj.appendTo(taxIdRef.value);
|
||||
}
|
||||
},
|
||||
refresh: () => {
|
||||
if (taxListLookup.obj) {
|
||||
taxListLookup.obj.value = state.taxId;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const purchaseOrderStatusListLookup = {
|
||||
obj: null,
|
||||
create: () => {
|
||||
if (state.purchaseOrderStatusListLookupData && Array.isArray(state.purchaseOrderStatusListLookupData)) {
|
||||
purchaseOrderStatusListLookup.obj = new ej.dropdowns.DropDownList({
|
||||
dataSource: state.purchaseOrderStatusListLookupData,
|
||||
fields: { value: 'id', text: 'name' },
|
||||
placeholder: 'Select an Order Status',
|
||||
change: (e) => {
|
||||
state.orderStatus = e.value;
|
||||
}
|
||||
});
|
||||
purchaseOrderStatusListLookup.obj.appendTo(orderStatusRef.value);
|
||||
}
|
||||
},
|
||||
refresh: () => {
|
||||
if (purchaseOrderStatusListLookup.obj) {
|
||||
purchaseOrderStatusListLookup.obj.value = state.orderStatus;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const orderDatePicker = {
|
||||
obj: null,
|
||||
create: () => {
|
||||
orderDatePicker.obj = new ej.calendars.DatePicker({
|
||||
format: 'yyyy-MM-dd',
|
||||
value: state.orderDate ? new Date(state.orderDate) : null,
|
||||
change: (e) => {
|
||||
state.orderDate = e.value;
|
||||
}
|
||||
});
|
||||
orderDatePicker.obj.appendTo(orderDateRef.value);
|
||||
},
|
||||
refresh: () => {
|
||||
if (orderDatePicker.obj) {
|
||||
orderDatePicker.obj.value = state.orderDate ? new Date(state.orderDate) : null;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const numberText = {
|
||||
obj: null,
|
||||
create: () => {
|
||||
numberText.obj = new ej.inputs.TextBox({
|
||||
placeholder: '[auto]',
|
||||
readonly: true
|
||||
});
|
||||
numberText.obj.appendTo(numberRef.value);
|
||||
}
|
||||
};
|
||||
|
||||
Vue.watch(
|
||||
() => state.orderDate,
|
||||
(newVal, oldVal) => {
|
||||
orderDatePicker.refresh();
|
||||
state.errors.orderDate = '';
|
||||
}
|
||||
);
|
||||
|
||||
Vue.watch(
|
||||
() => state.vendorId,
|
||||
(newVal, oldVal) => {
|
||||
vendorListLookup.refresh();
|
||||
state.errors.vendorId = '';
|
||||
}
|
||||
);
|
||||
|
||||
Vue.watch(
|
||||
() => state.taxId,
|
||||
(newVal, oldVal) => {
|
||||
taxListLookup.refresh();
|
||||
state.errors.taxId = '';
|
||||
}
|
||||
);
|
||||
|
||||
Vue.watch(
|
||||
() => state.orderStatus,
|
||||
(newVal, oldVal) => {
|
||||
purchaseOrderStatusListLookup.refresh();
|
||||
state.errors.orderStatus = '';
|
||||
}
|
||||
);
|
||||
|
||||
const mainGrid = {
|
||||
obj: null,
|
||||
create: async (dataSource) => {
|
||||
mainGrid.obj = new ej.grids.Grid({
|
||||
height: '240px',
|
||||
dataSource: dataSource,
|
||||
allowFiltering: true,
|
||||
allowSorting: true,
|
||||
allowSelection: true,
|
||||
allowGrouping: true,
|
||||
groupSettings: { columns: ['vendorName'] },
|
||||
allowTextWrap: true,
|
||||
allowResizing: true,
|
||||
allowPaging: true,
|
||||
allowExcelExport: true,
|
||||
filterSettings: { type: 'CheckBox' },
|
||||
sortSettings: { columns: [{ field: 'createdAtUtc', direction: 'Descending' }] },
|
||||
pageSettings: { currentPage: 1, pageSize: 50, pageSizes: ["10", "20", "50", "100", "200", "All"] },
|
||||
selectionSettings: { persistSelection: true, type: 'Single' },
|
||||
autoFit: true,
|
||||
showColumnMenu: true,
|
||||
gridLines: 'Horizontal',
|
||||
columns: [
|
||||
{ type: 'checkbox', width: 60 },
|
||||
{
|
||||
field: 'id', isPrimaryKey: true, headerText: 'Id', visible: false
|
||||
},
|
||||
{ field: 'number', headerText: 'Number', width: 150, minWidth: 150 },
|
||||
{ field: 'orderDate', headerText: 'PO Date', width: 150, format: 'yyyy-MM-dd' },
|
||||
{ field: 'vendorName', headerText: 'Vendor', width: 200, minWidth: 200 },
|
||||
{ field: 'orderStatusName', headerText: 'Status', width: 150, minWidth: 150 },
|
||||
{ field: 'taxName', headerText: 'Tax', width: 150, minWidth: 150 },
|
||||
{ field: 'afterTaxAmount', headerText: 'Total Amount', width: 150, minWidth: 150, format: 'N2' },
|
||||
{ field: 'createdAtUtc', headerText: 'Created At UTC', width: 150, format: 'yyyy-MM-dd HH:mm' }
|
||||
],
|
||||
toolbar: [
|
||||
'ExcelExport', 'Search',
|
||||
{ type: 'Separator' },
|
||||
{ text: 'Add', tooltipText: 'Add', prefixIcon: 'e-add', id: 'AddCustom' },
|
||||
{ text: 'Edit', tooltipText: 'Edit', prefixIcon: 'e-edit', id: 'EditCustom' },
|
||||
{ text: 'Delete', tooltipText: 'Delete', prefixIcon: 'e-delete', id: 'DeleteCustom' },
|
||||
{ type: 'Separator' },
|
||||
{ text: 'Print PDF', tooltipText: 'Print PDF', id: 'PrintPDFCustom' },
|
||||
],
|
||||
beforeDataBound: () => { },
|
||||
dataBound: function () {
|
||||
mainGrid.obj.toolbarModule.enableItems(['EditCustom', 'DeleteCustom', 'PrintPDFCustom'], false);
|
||||
mainGrid.obj.autoFitColumns(['number', 'orderDate', 'vendorName', 'orderStatusName', 'taxName', 'afterTaxAmount', 'createdAtUtc']);
|
||||
},
|
||||
excelExportComplete: () => { },
|
||||
rowSelected: () => {
|
||||
if (mainGrid.obj.getSelectedRecords().length == 1) {
|
||||
mainGrid.obj.toolbarModule.enableItems(['EditCustom', 'DeleteCustom', 'PrintPDFCustom'], true);
|
||||
} else {
|
||||
mainGrid.obj.toolbarModule.enableItems(['EditCustom', 'DeleteCustom', 'PrintPDFCustom'], false);
|
||||
}
|
||||
},
|
||||
rowDeselected: () => {
|
||||
if (mainGrid.obj.getSelectedRecords().length == 1) {
|
||||
mainGrid.obj.toolbarModule.enableItems(['EditCustom', 'DeleteCustom', 'PrintPDFCustom'], true);
|
||||
} else {
|
||||
mainGrid.obj.toolbarModule.enableItems(['EditCustom', 'DeleteCustom', 'PrintPDFCustom'], false);
|
||||
}
|
||||
},
|
||||
rowSelecting: () => {
|
||||
if (mainGrid.obj.getSelectedRecords().length) {
|
||||
mainGrid.obj.clearSelection();
|
||||
}
|
||||
},
|
||||
toolbarClick: async (args) => {
|
||||
if (args.item.id === 'MainGrid_excelexport') {
|
||||
mainGrid.obj.excelExport();
|
||||
}
|
||||
|
||||
if (args.item.id === 'AddCustom') {
|
||||
state.deleteMode = false;
|
||||
state.mainTitle = 'Add Purchase Order';
|
||||
resetFormState();
|
||||
state.secondaryData = [];
|
||||
secondaryGrid.refresh();
|
||||
state.showComplexDiv = false;
|
||||
mainModal.obj.show();
|
||||
}
|
||||
|
||||
if (args.item.id === 'EditCustom') {
|
||||
state.deleteMode = false;
|
||||
if (mainGrid.obj.getSelectedRecords().length) {
|
||||
const selectedRecord = mainGrid.obj.getSelectedRecords()[0];
|
||||
state.mainTitle = 'Edit Purchase Order';
|
||||
state.id = selectedRecord.id ?? '';
|
||||
state.number = selectedRecord.number ?? '';
|
||||
state.orderDate = selectedRecord.orderDate ? new Date(selectedRecord.orderDate) : null;
|
||||
state.description = selectedRecord.description ?? '';
|
||||
state.vendorId = selectedRecord.vendorId ?? '';
|
||||
state.taxId = selectedRecord.taxId ?? '';
|
||||
taxListLookup.trackingChange = true;
|
||||
state.orderStatus = String(selectedRecord.orderStatus ?? '');
|
||||
state.showComplexDiv = true;
|
||||
|
||||
await methods.populateSecondaryData(selectedRecord.id);
|
||||
secondaryGrid.refresh();
|
||||
|
||||
mainModal.obj.show();
|
||||
}
|
||||
}
|
||||
|
||||
if (args.item.id === 'DeleteCustom') {
|
||||
state.deleteMode = true;
|
||||
if (mainGrid.obj.getSelectedRecords().length) {
|
||||
const selectedRecord = mainGrid.obj.getSelectedRecords()[0];
|
||||
state.mainTitle = 'Delete Purchase Order?';
|
||||
state.id = selectedRecord.id ?? '';
|
||||
state.number = selectedRecord.number ?? '';
|
||||
state.orderDate = selectedRecord.orderDate ? new Date(selectedRecord.orderDate) : null;
|
||||
state.description = selectedRecord.description ?? '';
|
||||
state.vendorId = selectedRecord.vendorId ?? '';
|
||||
state.taxId = selectedRecord.taxId ?? '';
|
||||
state.orderStatus = String(selectedRecord.orderStatus ?? '');
|
||||
state.showComplexDiv = false;
|
||||
|
||||
await methods.populateSecondaryData(selectedRecord.id);
|
||||
secondaryGrid.refresh();
|
||||
|
||||
mainModal.obj.show();
|
||||
}
|
||||
}
|
||||
|
||||
if (args.item.id === 'PrintPDFCustom') {
|
||||
if (mainGrid.obj.getSelectedRecords().length) {
|
||||
const selectedRecord = mainGrid.obj.getSelectedRecords()[0];
|
||||
window.open('/PurchaseOrders/PurchaseOrderPdf?id=' + (selectedRecord.id ?? ''), '_blank');
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
mainGrid.obj.appendTo(mainGridRef.value);
|
||||
},
|
||||
refresh: () => {
|
||||
mainGrid.obj.setProperties({ dataSource: state.mainData });
|
||||
}
|
||||
};
|
||||
|
||||
const secondaryGrid = {
|
||||
obj: null,
|
||||
create: async (dataSource) => {
|
||||
secondaryGrid.obj = new ej.grids.Grid({
|
||||
height: 400,
|
||||
dataSource: dataSource,
|
||||
editSettings: { allowEditing: true, allowAdding: true, allowDeleting: true, showDeleteConfirmDialog: true, mode: 'Normal', allowEditOnDblClick: true },
|
||||
allowFiltering: false,
|
||||
allowSorting: true,
|
||||
allowSelection: true,
|
||||
allowGrouping: false,
|
||||
allowTextWrap: true,
|
||||
allowResizing: true,
|
||||
allowPaging: false,
|
||||
allowExcelExport: true,
|
||||
filterSettings: { type: 'CheckBox' },
|
||||
sortSettings: { columns: [{ field: 'productName', direction: 'Descending' }] },
|
||||
pageSettings: { currentPage: 1, pageSize: 50, pageSizes: ["10", "20", "50", "100", "200", "All"] },
|
||||
selectionSettings: { persistSelection: true, type: 'Single' },
|
||||
autoFit: false,
|
||||
showColumnMenu: false,
|
||||
gridLines: 'Horizontal',
|
||||
columns: [
|
||||
{ type: 'checkbox', width: 60 },
|
||||
{
|
||||
field: 'id', isPrimaryKey: true, headerText: 'Id', visible: false
|
||||
},
|
||||
{
|
||||
field: 'productId',
|
||||
headerText: 'Product',
|
||||
width: 250,
|
||||
validationRules: { required: true },
|
||||
disableHtmlEncode: false,
|
||||
valueAccessor: (field, data, column) => {
|
||||
const product = state.productListLookupData.find(item => item.id === data[field]);
|
||||
return product ? `${product.name}` : '';
|
||||
},
|
||||
editType: 'dropdownedit',
|
||||
edit: {
|
||||
create: () => {
|
||||
let productElem = document.createElement('input');
|
||||
return productElem;
|
||||
},
|
||||
read: () => {
|
||||
return productObj.value;
|
||||
},
|
||||
destroy: () => {
|
||||
productObj.destroy();
|
||||
},
|
||||
write: (args) => {
|
||||
productObj = new ej.dropdowns.DropDownList({
|
||||
dataSource: state.productListLookupData,
|
||||
fields: { value: 'id', text: 'name' },
|
||||
value: args.rowData.productId,
|
||||
change: (e) => {
|
||||
const selectedProduct = state.productListLookupData.find(item => item.id === e.value);
|
||||
if (selectedProduct) {
|
||||
args.rowData.productId = selectedProduct.id;
|
||||
if (numberObj) {
|
||||
numberObj.value = selectedProduct.number;
|
||||
}
|
||||
if (priceObj) {
|
||||
priceObj.value = selectedProduct.unitPrice;
|
||||
}
|
||||
if (summaryObj) {
|
||||
summaryObj.value = selectedProduct.description;
|
||||
}
|
||||
if (quantityObj) {
|
||||
quantityObj.value = 1;
|
||||
const total = selectedProduct.unitPrice * quantityObj.value;
|
||||
if (totalObj) {
|
||||
totalObj.value = total;
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
placeholder: 'Select a Product',
|
||||
floatLabelType: 'Never'
|
||||
});
|
||||
productObj.appendTo(args.element);
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
field: 'unitPrice',
|
||||
headerText: 'Unit Price',
|
||||
width: 200, validationRules: { required: true }, type: 'number', format: 'N2', textAlign: 'Right',
|
||||
edit: {
|
||||
create: () => {
|
||||
let priceElem = document.createElement('input');
|
||||
return priceElem;
|
||||
},
|
||||
read: () => {
|
||||
return priceObj.value;
|
||||
},
|
||||
destroy: () => {
|
||||
priceObj.destroy();
|
||||
},
|
||||
write: (args) => {
|
||||
priceObj = new ej.inputs.NumericTextBox({
|
||||
value: args.rowData.unitPrice ?? 0,
|
||||
change: (e) => {
|
||||
if (quantityObj && totalObj) {
|
||||
const total = e.value * quantityObj.value;
|
||||
totalObj.value = total;
|
||||
}
|
||||
}
|
||||
});
|
||||
priceObj.appendTo(args.element);
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
field: 'quantity',
|
||||
headerText: 'Quantity',
|
||||
width: 200,
|
||||
validationRules: {
|
||||
required: true,
|
||||
custom: [(args) => {
|
||||
return args['value'] > 0;
|
||||
}, 'Must be a positive number and not zero']
|
||||
},
|
||||
type: 'number', format: 'N2', textAlign: 'Right',
|
||||
edit: {
|
||||
create: () => {
|
||||
let quantityElem = document.createElement('input');
|
||||
return quantityElem;
|
||||
},
|
||||
read: () => {
|
||||
return quantityObj.value;
|
||||
},
|
||||
destroy: () => {
|
||||
quantityObj.destroy();
|
||||
},
|
||||
write: (args) => {
|
||||
quantityObj = new ej.inputs.NumericTextBox({
|
||||
value: args.rowData.quantity ?? 0,
|
||||
change: (e) => {
|
||||
if (priceObj && totalObj) {
|
||||
const total = e.value * priceObj.value;
|
||||
totalObj.value = total;
|
||||
}
|
||||
}
|
||||
});
|
||||
quantityObj.appendTo(args.element);
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
field: 'total',
|
||||
headerText: 'Total',
|
||||
width: 200, validationRules: { required: false }, type: 'number', format: 'N2', textAlign: 'Right',
|
||||
edit: {
|
||||
create: () => {
|
||||
let totalElem = document.createElement('input');
|
||||
return totalElem;
|
||||
},
|
||||
read: () => {
|
||||
return totalObj.value;
|
||||
},
|
||||
destroy: () => {
|
||||
totalObj.destroy();
|
||||
},
|
||||
write: (args) => {
|
||||
totalObj = new ej.inputs.NumericTextBox({
|
||||
value: args.rowData.total ?? 0,
|
||||
readonly: true
|
||||
});
|
||||
totalObj.appendTo(args.element);
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
field: 'productNumber',
|
||||
headerText: 'Product Number',
|
||||
allowEditing: false,
|
||||
width: 180,
|
||||
edit: {
|
||||
create: () => {
|
||||
let numberElem = document.createElement('input');
|
||||
return numberElem;
|
||||
},
|
||||
read: () => {
|
||||
return numberObj.value;
|
||||
},
|
||||
destroy: () => {
|
||||
numberObj.destroy();
|
||||
},
|
||||
write: (args) => {
|
||||
numberObj = new ej.inputs.TextBox();
|
||||
numberObj.value = args.rowData.productNumber;
|
||||
numberObj.readonly = true;
|
||||
numberObj.appendTo(args.element);
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
field: 'summary',
|
||||
headerText: 'Summary',
|
||||
width: 200,
|
||||
edit: {
|
||||
create: () => {
|
||||
let summaryElem = document.createElement('input');
|
||||
return summaryElem;
|
||||
},
|
||||
read: () => {
|
||||
return summaryObj.value;
|
||||
},
|
||||
destroy: () => {
|
||||
summaryObj.destroy();
|
||||
},
|
||||
write: (args) => {
|
||||
summaryObj = new ej.inputs.TextBox();
|
||||
summaryObj.value = args.rowData.summary;
|
||||
summaryObj.appendTo(args.element);
|
||||
}
|
||||
}
|
||||
},
|
||||
],
|
||||
toolbar: [
|
||||
'ExcelExport',
|
||||
{ type: 'Separator' },
|
||||
'Add', 'Edit', 'Delete', 'Update', 'Cancel',
|
||||
],
|
||||
beforeDataBound: () => { },
|
||||
dataBound: function () { },
|
||||
excelExportComplete: () => { },
|
||||
rowSelected: () => {
|
||||
if (secondaryGrid.obj.getSelectedRecords().length == 1) {
|
||||
secondaryGrid.obj.toolbarModule.enableItems(['Edit'], true);
|
||||
} else {
|
||||
secondaryGrid.obj.toolbarModule.enableItems(['Edit'], false);
|
||||
}
|
||||
},
|
||||
rowDeselected: () => {
|
||||
if (secondaryGrid.obj.getSelectedRecords().length == 1) {
|
||||
secondaryGrid.obj.toolbarModule.enableItems(['Edit'], true);
|
||||
} else {
|
||||
secondaryGrid.obj.toolbarModule.enableItems(['Edit'], false);
|
||||
}
|
||||
},
|
||||
rowSelecting: () => {
|
||||
if (secondaryGrid.obj.getSelectedRecords().length) {
|
||||
secondaryGrid.obj.clearSelection();
|
||||
}
|
||||
},
|
||||
toolbarClick: (args) => {
|
||||
if (args.item.id === 'SecondaryGrid_excelexport') {
|
||||
secondaryGrid.obj.excelExport();
|
||||
}
|
||||
},
|
||||
actionComplete: async (args) => {
|
||||
if (args.requestType === 'save' && args.action === 'add') {
|
||||
const purchaseOrderId = state.id;
|
||||
const userId = StorageManager.getUserId();
|
||||
const data = args.data;
|
||||
|
||||
await services.createSecondaryData(data?.unitPrice, data?.quantity, data?.summary, data?.productId, purchaseOrderId, userId);
|
||||
await methods.populateSecondaryData(purchaseOrderId);
|
||||
secondaryGrid.refresh();
|
||||
|
||||
Swal.fire({
|
||||
icon: 'success',
|
||||
title: 'Save Successful',
|
||||
timer: 2000,
|
||||
showConfirmButton: false
|
||||
});
|
||||
}
|
||||
if (args.requestType === 'save' && args.action === 'edit') {
|
||||
const purchaseOrderId = state.id;
|
||||
const userId = StorageManager.getUserId();
|
||||
const data = args.data;
|
||||
|
||||
await services.updateSecondaryData(data?.id, data?.unitPrice, data?.quantity, data?.summary, data?.productId, purchaseOrderId, userId);
|
||||
await methods.populateSecondaryData(purchaseOrderId);
|
||||
secondaryGrid.refresh();
|
||||
|
||||
Swal.fire({
|
||||
icon: 'success',
|
||||
title: 'Save Successful',
|
||||
timer: 2000,
|
||||
showConfirmButton: false
|
||||
});
|
||||
}
|
||||
if (args.requestType === 'delete') {
|
||||
const purchaseOrderId = state.id;
|
||||
const userId = StorageManager.getUserId();
|
||||
const data = args.data[0];
|
||||
|
||||
await services.deleteSecondaryData(data?.id, userId);
|
||||
await methods.populateSecondaryData(purchaseOrderId);
|
||||
secondaryGrid.refresh();
|
||||
|
||||
Swal.fire({
|
||||
icon: 'success',
|
||||
title: 'Delete Successful',
|
||||
timer: 2000,
|
||||
showConfirmButton: false
|
||||
});
|
||||
}
|
||||
|
||||
await methods.populateMainData();
|
||||
mainGrid.refresh();
|
||||
await methods.refreshPaymentSummary(state.id);
|
||||
}
|
||||
});
|
||||
secondaryGrid.obj.appendTo(secondaryGridRef.value);
|
||||
},
|
||||
refresh: () => {
|
||||
secondaryGrid.obj.setProperties({ dataSource: state.secondaryData });
|
||||
}
|
||||
};
|
||||
|
||||
const mainModal = {
|
||||
obj: null,
|
||||
create: () => {
|
||||
mainModal.obj = new bootstrap.Modal(mainModalRef.value, {
|
||||
backdrop: 'static',
|
||||
keyboard: false
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
Vue.onMounted(async () => {
|
||||
try {
|
||||
await SecurityManager.authorizePage(['PurchaseOrders']);
|
||||
await SecurityManager.validateToken();
|
||||
|
||||
await methods.populateMainData();
|
||||
await mainGrid.create(state.mainData);
|
||||
|
||||
mainModal.create();
|
||||
mainModalRef.value?.addEventListener('hidden.bs.modal', methods.onMainModalHidden);
|
||||
await methods.populateVendorListLookupData();
|
||||
vendorListLookup.create();
|
||||
await methods.populateTaxListLookupData();
|
||||
taxListLookup.create();
|
||||
await methods.populatePurchaseOrderStatusListLookupData();
|
||||
purchaseOrderStatusListLookup.create();
|
||||
orderDatePicker.create();
|
||||
numberText.create();
|
||||
await methods.populateProductListLookupData();
|
||||
await secondaryGrid.create(state.secondaryData);
|
||||
} catch (e) {
|
||||
console.error('page init error:', e);
|
||||
} finally {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
Vue.onUnmounted(() => {
|
||||
mainModalRef.value?.removeEventListener('hidden.bs.modal', methods.onMainModalHidden);
|
||||
});
|
||||
|
||||
return {
|
||||
mainGridRef,
|
||||
mainModalRef,
|
||||
orderDateRef,
|
||||
numberRef,
|
||||
vendorIdRef,
|
||||
taxIdRef,
|
||||
orderStatusRef,
|
||||
secondaryGridRef,
|
||||
state,
|
||||
methods,
|
||||
handler: {
|
||||
handleSubmit: methods.handleFormSubmit
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
Vue.createApp(App).mount('#app');
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user