mirror of
https://gitee.com/ccnetcore/Yi
synced 2026-04-27 19:53:25 +08:00
添加库存管理,入库、出库,收款、回款接口
This commit is contained in:
@@ -249,6 +249,18 @@
|
|||||||
<param name="ids"></param>
|
<param name="ids"></param>
|
||||||
<returns></returns>
|
<returns></returns>
|
||||||
</member>
|
</member>
|
||||||
|
<member name="M:Yi.Framework.ApiMicroservice.Controllers.ERP.PurchaseController.Receipt(Yi.Framework.DtoModel.ERP.Purchase.ReceiptInput)">
|
||||||
|
<summary>
|
||||||
|
收获
|
||||||
|
</summary>
|
||||||
|
<returns></returns>
|
||||||
|
</member>
|
||||||
|
<member name="M:Yi.Framework.ApiMicroservice.Controllers.ERP.PurchaseController.Collection(Yi.Framework.DtoModel.ERP.Purchase.CollectionInput)">
|
||||||
|
<summary>
|
||||||
|
回款?????甲方主动给乙方钱,乙方给货物。应该不叫回款。。。。想想叫啥优雅的名字
|
||||||
|
</summary>
|
||||||
|
<returns></returns>
|
||||||
|
</member>
|
||||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.ERP.PurchaseDetailsController.PageList(Yi.Framework.DtoModel.ERP.PurchaseDetails.PurchaseDetailsGetListInput,Yi.Framework.Common.Models.PageParModel)">
|
<member name="M:Yi.Framework.ApiMicroservice.Controllers.ERP.PurchaseDetailsController.PageList(Yi.Framework.DtoModel.ERP.PurchaseDetails.PurchaseDetailsGetListInput,Yi.Framework.Common.Models.PageParModel)">
|
||||||
<summary>
|
<summary>
|
||||||
分页查
|
分页查
|
||||||
@@ -283,6 +295,49 @@
|
|||||||
<param name="ids"></param>
|
<param name="ids"></param>
|
||||||
<returns></returns>
|
<returns></returns>
|
||||||
</member>
|
</member>
|
||||||
|
<member name="M:Yi.Framework.ApiMicroservice.Controllers.ERP.StockController.PageList(Yi.Framework.DtoModel.ERP.Stock.StockGetListInput,Yi.Framework.Common.Models.PageParModel)">
|
||||||
|
<summary>
|
||||||
|
分页查
|
||||||
|
</summary>
|
||||||
|
<returns></returns>
|
||||||
|
</member>
|
||||||
|
<member name="M:Yi.Framework.ApiMicroservice.Controllers.ERP.StockController.GetById(System.Int64)">
|
||||||
|
<summary>
|
||||||
|
单查
|
||||||
|
</summary>
|
||||||
|
<returns></returns>
|
||||||
|
</member>
|
||||||
|
<member name="M:Yi.Framework.ApiMicroservice.Controllers.ERP.StockController.InputStock(Yi.Framework.DtoModel.ERP.Stock.StockCreateUpdateInput)">
|
||||||
|
<summary>
|
||||||
|
入库
|
||||||
|
</summary>
|
||||||
|
<returns></returns>
|
||||||
|
</member>
|
||||||
|
<member name="M:Yi.Framework.ApiMicroservice.Controllers.ERP.StockController.OutputStock(Yi.Framework.DtoModel.ERP.Stock.StockCreateUpdateInput)">
|
||||||
|
<summary>
|
||||||
|
出库
|
||||||
|
</summary>
|
||||||
|
<returns></returns>
|
||||||
|
</member>
|
||||||
|
<member name="M:Yi.Framework.ApiMicroservice.Controllers.ERP.StockDetailsController.PageList(Yi.Framework.DtoModel.ERP.StockDetails.StockDetailsGetListInput,Yi.Framework.Common.Models.PageParModel)">
|
||||||
|
<summary>
|
||||||
|
分页查
|
||||||
|
</summary>
|
||||||
|
<returns></returns>
|
||||||
|
</member>
|
||||||
|
<member name="M:Yi.Framework.ApiMicroservice.Controllers.ERP.StockDetailsController.GetById(System.Int64)">
|
||||||
|
<summary>
|
||||||
|
单查
|
||||||
|
</summary>
|
||||||
|
<returns></returns>
|
||||||
|
</member>
|
||||||
|
<member name="M:Yi.Framework.ApiMicroservice.Controllers.ERP.StockDetailsController.Del(System.Collections.Generic.List{System.Int64})">
|
||||||
|
<summary>
|
||||||
|
删
|
||||||
|
</summary>
|
||||||
|
<param name="ids"></param>
|
||||||
|
<returns></returns>
|
||||||
|
</member>
|
||||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.ERP.SupplierController.GetList">
|
<member name="M:Yi.Framework.ApiMicroservice.Controllers.ERP.SupplierController.GetList">
|
||||||
<summary>
|
<summary>
|
||||||
全查
|
全查
|
||||||
|
|||||||
@@ -79,5 +79,25 @@ namespace Yi.Framework.ApiMicroservice.Controllers.ERP
|
|||||||
await _purchaseService.DeleteAsync(ids);
|
await _purchaseService.DeleteAsync(ids);
|
||||||
return Result.Success();
|
return Result.Success();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 收获
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost]
|
||||||
|
public async Task<Result> Receipt(ReceiptInput input)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 回款?????甲方主动给乙方钱,乙方给货物。应该不叫回款。。。。想想叫啥优雅的名字
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost]
|
||||||
|
public async Task<Result> Collection(CollectionInput input)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,66 @@
|
|||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using Yi.Framework.Common.Models;
|
||||||
|
using Yi.Framework.DtoModel.ERP.Stock;
|
||||||
|
using Yi.Framework.Interface.ERP;
|
||||||
|
|
||||||
|
namespace Yi.Framework.ApiMicroservice.Controllers.ERP
|
||||||
|
{
|
||||||
|
[ApiController]
|
||||||
|
[Route("api/[controller]/[action]")]
|
||||||
|
public class StockController : ControllerBase
|
||||||
|
{
|
||||||
|
private readonly ILogger<StockController> _logger;
|
||||||
|
private readonly IStockService _stockService;
|
||||||
|
public StockController(ILogger<StockController> logger, IStockService stockService)
|
||||||
|
{
|
||||||
|
_logger = logger;
|
||||||
|
_stockService = stockService;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 分页查
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpGet]
|
||||||
|
public async Task<Result> PageList([FromQuery] StockGetListInput input, [FromQuery] PageParModel page)
|
||||||
|
{
|
||||||
|
var result = await _stockService.PageListAsync(input, page);
|
||||||
|
return Result.Success().SetData(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 单查
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpGet]
|
||||||
|
[Route("{id}")]
|
||||||
|
public async Task<Result> GetById(long id)
|
||||||
|
{
|
||||||
|
var result = await _stockService.GetByIdAsync(id);
|
||||||
|
return Result.Success().SetData(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 入库
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost]
|
||||||
|
public async Task<Result> InputStock(StockCreateUpdateInput input)
|
||||||
|
{
|
||||||
|
var result = await _stockService.InputStockAsync(input);
|
||||||
|
return Result.Success().SetData(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 出库
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost]
|
||||||
|
public async Task<Result> OutputStock(StockCreateUpdateInput input)
|
||||||
|
{
|
||||||
|
var result = await _stockService.OutputStockAsync(input);
|
||||||
|
return Result.Success().SetData(result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,55 @@
|
|||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using Yi.Framework.Common.Models;
|
||||||
|
using Yi.Framework.DtoModel.ERP.StockDetails;
|
||||||
|
using Yi.Framework.Interface.ERP;
|
||||||
|
|
||||||
|
namespace Yi.Framework.ApiMicroservice.Controllers.ERP
|
||||||
|
{
|
||||||
|
[ApiController]
|
||||||
|
[Route("api/[controller]/[action]")]
|
||||||
|
public class StockDetailsController : ControllerBase
|
||||||
|
{
|
||||||
|
private readonly ILogger<StockDetailsController> _logger;
|
||||||
|
private readonly IStockDetailsService _stockDetailsService;
|
||||||
|
public StockDetailsController(ILogger<StockDetailsController> logger, IStockDetailsService stockDetailsService)
|
||||||
|
{
|
||||||
|
_logger = logger;
|
||||||
|
_stockDetailsService = stockDetailsService;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 分页查
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpGet]
|
||||||
|
public async Task<Result> PageList([FromQuery] StockDetailsGetListInput input, [FromQuery] PageParModel page)
|
||||||
|
{
|
||||||
|
var result = await _stockDetailsService.PageListAsync(input, page);
|
||||||
|
return Result.Success().SetData(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 单查
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpGet]
|
||||||
|
[Route("{id}")]
|
||||||
|
public async Task<Result> GetById(long id)
|
||||||
|
{
|
||||||
|
var result = await _stockDetailsService.GetByIdAsync(id);
|
||||||
|
return Result.Success().SetData(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 删
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="ids"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpDelete]
|
||||||
|
public async Task<Result> Del(List<long> ids)
|
||||||
|
{
|
||||||
|
await _stockDetailsService.DeleteAsync(ids);
|
||||||
|
return Result.Success();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Binary file not shown.
@@ -0,0 +1,25 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Yi.Framework.DtoModel.ERP.Purchase
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 回款
|
||||||
|
/// </summary>
|
||||||
|
public class CollectionInput
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 采购订单id
|
||||||
|
/// </summary>
|
||||||
|
public long PurchaseId { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///回款钱
|
||||||
|
/// </summary>
|
||||||
|
public float CollectionMoney { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Yi.Framework.DtoModel.ERP.Purchase
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 收货
|
||||||
|
/// </summary>
|
||||||
|
public class ReceiptInput
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 采购订单id
|
||||||
|
/// </summary>
|
||||||
|
public long PurchaseId { get; set; }
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public class ReceiptDetails
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 订单子表id
|
||||||
|
/// </summary>
|
||||||
|
public long PurchaseDatilesId { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 收货数量
|
||||||
|
/// </summary>
|
||||||
|
public long Number { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Yi.Framework.DtoModel.ERP.Stock.ConstConfig
|
||||||
|
{
|
||||||
|
public class StockConst
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
using AutoMapper;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Yi.Framework.Model.ERP.Entitys;
|
||||||
|
|
||||||
|
namespace Yi.Framework.DtoModel.ERP.Stock.MapperConfig
|
||||||
|
{
|
||||||
|
public class SuppliERProfile:Profile
|
||||||
|
{
|
||||||
|
public SuppliERProfile()
|
||||||
|
{
|
||||||
|
CreateMap<StockCreateUpdateInput, StockEntity>();
|
||||||
|
CreateMap<StockEntity, StockGetListOutput>();
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
using SqlSugar;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Yi.Framework.Model.Base;
|
||||||
|
|
||||||
|
namespace Yi.Framework.DtoModel.ERP.Stock
|
||||||
|
{
|
||||||
|
public class StockCreateUpdateInput : EntityDto<long>
|
||||||
|
{
|
||||||
|
public long WarehouseId { get; set; }
|
||||||
|
public long MaterialId { get; set; }
|
||||||
|
public long Number { get; set; }
|
||||||
|
public string? Quality { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Yi.Framework.Model.Base;
|
||||||
|
|
||||||
|
namespace Yi.Framework.DtoModel.ERP.Stock
|
||||||
|
{
|
||||||
|
public class StockGetListInput
|
||||||
|
{
|
||||||
|
|
||||||
|
public long Number { get; set; }
|
||||||
|
public string? Quality { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Yi.Framework.Model.Base;
|
||||||
|
|
||||||
|
namespace Yi.Framework.DtoModel.ERP.Stock
|
||||||
|
{
|
||||||
|
public class StockGetListOutput: EntityDto<long>
|
||||||
|
{
|
||||||
|
public string MaterialName { get; set; } = string.Empty;
|
||||||
|
public string UnitName { get; set; } = string.Empty;
|
||||||
|
public string WarehouseName { get; set; } = string.Empty;
|
||||||
|
public long Number { get; set; }
|
||||||
|
public string? Quality { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Yi.Framework.DtoModel.ERP.StockDetails.ConstConfig
|
||||||
|
{
|
||||||
|
public class StockDetailsConst
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
using AutoMapper;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Yi.Framework.Model.ERP.Entitys;
|
||||||
|
|
||||||
|
namespace Yi.Framework.DtoModel.ERP.StockDetails.MapperConfig
|
||||||
|
{
|
||||||
|
public class SuppliERProfile:Profile
|
||||||
|
{
|
||||||
|
public SuppliERProfile()
|
||||||
|
{
|
||||||
|
CreateMap<StockDetailsCreateUpdateInput, StockDetailsEntity>();
|
||||||
|
CreateMap<StockDetailsEntity, StockDetailsGetListOutput>();
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
using SqlSugar;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Yi.Framework.Model.Base;
|
||||||
|
using Yi.Framework.Model.ERP.Entitys;
|
||||||
|
|
||||||
|
namespace Yi.Framework.DtoModel.ERP.StockDetails
|
||||||
|
{
|
||||||
|
public class StockDetailsCreateUpdateInput : EntityDto<long>
|
||||||
|
{
|
||||||
|
public long WarehouseId { get; set; }
|
||||||
|
public long MaterialId { get; set; }
|
||||||
|
public long Number { get; set; }
|
||||||
|
public string? Quality { get; set; }
|
||||||
|
public StockDetailsTypeEnum StockDetailsType { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Yi.Framework.Model.Base;
|
||||||
|
using Yi.Framework.Model.ERP.Entitys;
|
||||||
|
|
||||||
|
namespace Yi.Framework.DtoModel.ERP.StockDetails
|
||||||
|
{
|
||||||
|
public class StockDetailsGetListInput
|
||||||
|
{
|
||||||
|
public long WarehouseName { get; set; }
|
||||||
|
public long MaterialName { get; set; }
|
||||||
|
public string? Quality { get; set; }
|
||||||
|
public StockDetailsTypeEnum StockDetailsType { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Yi.Framework.Model.Base;
|
||||||
|
using Yi.Framework.Model.ERP.Entitys;
|
||||||
|
|
||||||
|
namespace Yi.Framework.DtoModel.ERP.StockDetails
|
||||||
|
{
|
||||||
|
public class StockDetailsGetListOutput: EntityDto<long>
|
||||||
|
{
|
||||||
|
public long WarehouseName { get; set; }
|
||||||
|
public long MaterialName { get; set; }
|
||||||
|
public long Number { get; set; }
|
||||||
|
public string? Quality { get; set; }
|
||||||
|
public DateTime StockDetailsTime { get; set; }
|
||||||
|
public StockDetailsTypeEnum StockDetailsType { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Yi.Framework.Common.Models;
|
||||||
|
using Yi.Framework.DtoModel.ERP.StockDetails;
|
||||||
|
using Yi.Framework.Interface.Base.Crud;
|
||||||
|
|
||||||
|
namespace Yi.Framework.Interface.ERP
|
||||||
|
{
|
||||||
|
public interface IStockDetailsService : ICrudAppService<StockDetailsGetListOutput, long, StockDetailsCreateUpdateInput>
|
||||||
|
{
|
||||||
|
Task<PageModel<List<StockDetailsGetListOutput>>> PageListAsync(StockDetailsGetListInput input, PageParModel page);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Yi.Framework.Common.Models;
|
||||||
|
using Yi.Framework.DtoModel.ERP.Stock;
|
||||||
|
using Yi.Framework.Interface.Base.Crud;
|
||||||
|
|
||||||
|
namespace Yi.Framework.Interface.ERP
|
||||||
|
{
|
||||||
|
public interface IStockService : ICrudAppService<StockGetListOutput, long, StockCreateUpdateInput>
|
||||||
|
{
|
||||||
|
Task<PageModel<List<StockGetListOutput>>> PageListAsync(StockGetListInput input, PageParModel page);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Èë¿â
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="input"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task<StockGetListOutput> InputStockAsync(StockCreateUpdateInput input);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// ³ö¿â
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="input"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task<StockGetListOutput> OutputStockAsync(StockCreateUpdateInput input);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,81 @@
|
|||||||
|
using SqlSugar;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Text.Json.Serialization;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Yi.Framework.Model.Base;
|
||||||
|
|
||||||
|
namespace Yi.Framework.Model.ERP.Entitys
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 库存明细,像这种记录型的表,需要进行冗余字段保存历史记录
|
||||||
|
/// </summary>
|
||||||
|
[SugarTable("StockDetails")]
|
||||||
|
public class StockDetailsEntity : IEntity<long>, IMultiTenant
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 主键
|
||||||
|
/// </summary>
|
||||||
|
[JsonConverter(typeof(ValueToStringConverter))]
|
||||||
|
[SugarColumn(IsPrimaryKey = true)]
|
||||||
|
public long Id { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 租户id
|
||||||
|
/// </summary>
|
||||||
|
public Guid? TenantId { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 库存id
|
||||||
|
/// </summary>
|
||||||
|
public long StockId { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 仓库id
|
||||||
|
/// </summary>
|
||||||
|
public long WarehouseId { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 仓库名称
|
||||||
|
/// </summary>
|
||||||
|
public string WarehouseName { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 物料id
|
||||||
|
/// </summary>
|
||||||
|
public long MaterialId { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 物料名称
|
||||||
|
/// </summary>
|
||||||
|
public string MaterialName { get; set; }=string.Empty;
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 数量
|
||||||
|
/// </summary>
|
||||||
|
public long Number { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 品质
|
||||||
|
/// </summary>
|
||||||
|
public string? Quality { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 入库或者出库时间
|
||||||
|
/// </summary>
|
||||||
|
public DateTime StockDetailsTime { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 明细类别
|
||||||
|
/// </summary>
|
||||||
|
public StockDetailsTypeEnum StockDetailsType { get; set; }
|
||||||
|
}
|
||||||
|
public enum StockDetailsTypeEnum
|
||||||
|
{
|
||||||
|
Input = 0,//入库
|
||||||
|
Output = 1//出库
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,50 @@
|
|||||||
|
using SqlSugar;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Text.Json.Serialization;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Yi.Framework.Model.Base;
|
||||||
|
|
||||||
|
namespace Yi.Framework.Model.ERP.Entitys
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 库存
|
||||||
|
/// </summary>
|
||||||
|
[SugarTable("Stock")]
|
||||||
|
public class StockEntity : IEntity<long>, IMultiTenant
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 主键
|
||||||
|
/// </summary>
|
||||||
|
[JsonConverter(typeof(ValueToStringConverter))]
|
||||||
|
[SugarColumn(IsPrimaryKey = true)]
|
||||||
|
public long Id { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 租户id
|
||||||
|
/// </summary>
|
||||||
|
public Guid? TenantId { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 仓库id
|
||||||
|
/// </summary>
|
||||||
|
public long WarehouseId { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 物料id
|
||||||
|
/// </summary>
|
||||||
|
public long MaterialId { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 数量
|
||||||
|
/// </summary>
|
||||||
|
public long Number { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 品质
|
||||||
|
/// </summary>
|
||||||
|
public string? Quality { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -31,14 +31,14 @@ namespace Yi.Framework.Service.Base.Crud
|
|||||||
public IRepository<TEntity> Repository { get; set; }
|
public IRepository<TEntity> Repository { get; set; }
|
||||||
|
|
||||||
|
|
||||||
public async Task<List<TGetListOutputDto>> GetListAsync()
|
public virtual async Task<List<TGetListOutputDto>> GetListAsync()
|
||||||
{
|
{
|
||||||
var entitys = await Repository.GetListAsync();
|
var entitys = await Repository.GetListAsync();
|
||||||
var entityDtos = await MapToGetListOutputDtosAsync(entitys);
|
var entityDtos = await MapToGetListOutputDtosAsync(entitys);
|
||||||
return entityDtos;
|
return entityDtos;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<TGetOutputDto> GetByIdAsync(TKey id)
|
public virtual async Task<TGetOutputDto> GetByIdAsync(TKey id)
|
||||||
{
|
{
|
||||||
var entity = await GetEntityByIdAsync(id);
|
var entity = await GetEntityByIdAsync(id);
|
||||||
if (entity is null)
|
if (entity is null)
|
||||||
|
|||||||
@@ -0,0 +1,29 @@
|
|||||||
|
using AutoMapper;
|
||||||
|
using SqlSugar;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Yi.Framework.Common.Models;
|
||||||
|
using Yi.Framework.DtoModel.ERP.StockDetails;
|
||||||
|
using Yi.Framework.Interface.ERP;
|
||||||
|
using Yi.Framework.Model.ERP.Entitys;
|
||||||
|
using Yi.Framework.Repository;
|
||||||
|
using Yi.Framework.Service.Base.Crud;
|
||||||
|
|
||||||
|
namespace Yi.Framework.Service.ERP
|
||||||
|
{
|
||||||
|
public class StockDetailsService : CrudAppService<StockDetailsEntity, StockDetailsGetListOutput, long, StockDetailsCreateUpdateInput>, IStockDetailsService
|
||||||
|
{
|
||||||
|
public async Task<PageModel<List<StockDetailsGetListOutput>>> PageListAsync(StockDetailsGetListInput input, PageParModel page)
|
||||||
|
{
|
||||||
|
RefAsync<int> totalNumber = 0;
|
||||||
|
var data = await Repository._DbQueryable
|
||||||
|
.Where(u => u.StockDetailsType == input.StockDetailsType)
|
||||||
|
.WhereIF(page.StartTime is not null && page.EndTime is not null, u => u.StockDetailsTime >= page.StartTime && u.StockDetailsTime <= page.EndTime)
|
||||||
|
.ToPageListAsync(page.PageNum, page.PageSize, totalNumber);
|
||||||
|
return new PageModel<List<StockDetailsGetListOutput>> { Total = totalNumber.Value, Data = await MapToGetListOutputDtosAsync(data) };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
188
Yi.Framework.Net6/Yi.Framework.Service/ERP/StockService.cs
Normal file
188
Yi.Framework.Net6/Yi.Framework.Service/ERP/StockService.cs
Normal file
@@ -0,0 +1,188 @@
|
|||||||
|
using AutoMapper;
|
||||||
|
using SqlSugar;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Yi.Framework.Common.Exceptions;
|
||||||
|
using Yi.Framework.Common.Models;
|
||||||
|
using Yi.Framework.DtoModel.ERP.Stock;
|
||||||
|
using Yi.Framework.Interface.ERP;
|
||||||
|
using Yi.Framework.Model.ERP.Entitys;
|
||||||
|
using Yi.Framework.Repository;
|
||||||
|
using Yi.Framework.Service.Base.Crud;
|
||||||
|
|
||||||
|
namespace Yi.Framework.Service.ERP
|
||||||
|
{
|
||||||
|
public class StockService : CrudAppService<StockEntity, StockGetListOutput, long, StockCreateUpdateInput>, IStockService
|
||||||
|
{
|
||||||
|
private IRepository<StockDetailsEntity> _detailsRepository;
|
||||||
|
private ISugarUnitOfWork<UnitOfWork> _unitOfWork;
|
||||||
|
public StockService(IRepository<StockDetailsEntity> detailsRepository, ISugarUnitOfWork<UnitOfWork> unitOfWork)
|
||||||
|
{
|
||||||
|
_detailsRepository = detailsRepository;
|
||||||
|
_unitOfWork = unitOfWork;
|
||||||
|
}
|
||||||
|
public async Task<PageModel<List<StockGetListOutput>>> PageListAsync(StockGetListInput input, PageParModel page)
|
||||||
|
{
|
||||||
|
RefAsync<int> totalNumber = 0;
|
||||||
|
var data = await Repository._DbQueryable
|
||||||
|
.LeftJoin<WarehouseEntity>((stock, warehouse) => stock.WarehouseId == warehouse.Id)
|
||||||
|
.LeftJoin<MaterialEntity>((stock, warehouse, material) => stock.MaterialId == material.Id)
|
||||||
|
.Select((stock, warehouse, material) => new StockGetListOutput
|
||||||
|
{
|
||||||
|
MaterialName = material.Name,
|
||||||
|
WarehouseName = warehouse.Name,
|
||||||
|
UnitName = material.UnitName
|
||||||
|
}, true)
|
||||||
|
.ToPageListAsync(page.PageNum, page.PageSize, totalNumber);
|
||||||
|
return new PageModel<List<StockGetListOutput>> { Total = totalNumber.Value, Data = data };
|
||||||
|
}
|
||||||
|
|
||||||
|
public override async Task<StockGetListOutput> GetByIdAsync(long id)
|
||||||
|
{
|
||||||
|
return await Repository._DbQueryable
|
||||||
|
.LeftJoin<WarehouseEntity>((stock, warehouse) => stock.WarehouseId == warehouse.Id)
|
||||||
|
.LeftJoin<MaterialEntity>((stock, warehouse, material) => stock.MaterialId == material.Id)
|
||||||
|
.Select((stock, warehouse, material) => new StockGetListOutput
|
||||||
|
{
|
||||||
|
MaterialName = material.Name,
|
||||||
|
WarehouseName = warehouse.Name,
|
||||||
|
UnitName = material.UnitName
|
||||||
|
}, true)
|
||||||
|
.FirstAsync(stock => stock.Id==id);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 入库操作,需要工作单元事务操作
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="input"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public async Task<StockGetListOutput> InputStockAsync(StockCreateUpdateInput input)
|
||||||
|
{
|
||||||
|
StockGetListOutput result = new();
|
||||||
|
using (var uow = _unitOfWork.CreateContext())
|
||||||
|
{
|
||||||
|
var entity = await MapToEntityAsync(input);
|
||||||
|
//先判断是否存在该物料,如果存在,直接添加数量
|
||||||
|
var entityData = await Repository.GetFirstAsync(u => u.MaterialId == entity.MaterialId);
|
||||||
|
if (entityData is not null)
|
||||||
|
{
|
||||||
|
entityData.Number += input.Number;
|
||||||
|
await Repository.UpdateIgnoreNullAsync(entityData);
|
||||||
|
}
|
||||||
|
//添加一条库存数据
|
||||||
|
else
|
||||||
|
{
|
||||||
|
await Repository.InsertReturnSnowflakeIdAsync(entity);
|
||||||
|
}
|
||||||
|
|
||||||
|
result = await Repository._DbQueryable
|
||||||
|
.LeftJoin<WarehouseEntity>((stock, warehouse) => stock.WarehouseId == warehouse.Id)
|
||||||
|
.LeftJoin<MaterialEntity>((stock, warehouse, material) => stock.MaterialId == material.Id)
|
||||||
|
.Select((stock, warehouse, material) => new StockGetListOutput
|
||||||
|
{
|
||||||
|
MaterialName = material.Name,
|
||||||
|
WarehouseName = warehouse.Name,
|
||||||
|
UnitName = material.UnitName
|
||||||
|
}, true).FirstAsync();
|
||||||
|
|
||||||
|
//还需要进行入库明细的插入
|
||||||
|
StockDetailsEntity stockDetailsEntity = new();
|
||||||
|
stockDetailsEntity.StockId = result.Id;
|
||||||
|
stockDetailsEntity.WarehouseId = input.WarehouseId;
|
||||||
|
stockDetailsEntity.MaterialId = input.MaterialId;
|
||||||
|
stockDetailsEntity.WarehouseName = result.WarehouseName;
|
||||||
|
stockDetailsEntity.MaterialName = result.MaterialName;
|
||||||
|
stockDetailsEntity.StockDetailsTime = DateTime.Now;
|
||||||
|
stockDetailsEntity.Quality = input.Quality;
|
||||||
|
stockDetailsEntity.Number = input.Number;
|
||||||
|
stockDetailsEntity.StockDetailsType = StockDetailsTypeEnum.Input;
|
||||||
|
|
||||||
|
await _detailsRepository.InsertReturnSnowflakeIdAsync(stockDetailsEntity);
|
||||||
|
|
||||||
|
uow.Commit();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 出库操作,需要工作单元事务操作
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="input"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public async Task<StockGetListOutput> OutputStockAsync(StockCreateUpdateInput input)
|
||||||
|
{
|
||||||
|
StockGetListOutput result = new();
|
||||||
|
using (var uow = _unitOfWork.CreateContext())
|
||||||
|
{
|
||||||
|
var entity = await Repository.GetByIdAsync(input.Id);
|
||||||
|
|
||||||
|
if (entity is null)
|
||||||
|
{
|
||||||
|
throw new ApplicationException("出库失败,该库存不存在");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//先判断是否存在该物料,如果存在,直接减去数量,如果减完数量=0,直接删除该条数据,如果小于零,库存不足
|
||||||
|
var entityData = await Repository.GetFirstAsync(u => u.MaterialId == entity.MaterialId);
|
||||||
|
if (entityData is not null)
|
||||||
|
{
|
||||||
|
entityData.Number -= input.Number;
|
||||||
|
|
||||||
|
if (entityData.Number < 0)
|
||||||
|
{
|
||||||
|
throw new UserFriendlyException("库存不足");
|
||||||
|
}
|
||||||
|
else if (entityData.Number == 0)
|
||||||
|
{
|
||||||
|
await Repository.DeleteAsync(u => u.MaterialId == input.MaterialId);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
await Repository.UpdateIgnoreNullAsync(entityData);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
//不存在该物料
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new UserFriendlyException("库存未发现该物料");
|
||||||
|
}
|
||||||
|
result = await Repository._DbQueryable
|
||||||
|
.LeftJoin<WarehouseEntity>((stock, warehouse) => stock.WarehouseId == warehouse.Id)
|
||||||
|
.LeftJoin<MaterialEntity>((stock, warehouse, material) => stock.MaterialId == material.Id)
|
||||||
|
.Select((stock, warehouse, material) => new StockGetListOutput
|
||||||
|
{
|
||||||
|
MaterialName = material.Name,
|
||||||
|
WarehouseName = warehouse.Name,
|
||||||
|
UnitName = material.UnitName
|
||||||
|
}, true).FirstAsync();
|
||||||
|
|
||||||
|
//还需要进行入库明细的插入
|
||||||
|
StockDetailsEntity stockDetailsEntity = new();
|
||||||
|
stockDetailsEntity.StockId = result.Id;
|
||||||
|
stockDetailsEntity.WarehouseId = input.WarehouseId;
|
||||||
|
stockDetailsEntity.MaterialId = input.MaterialId;
|
||||||
|
stockDetailsEntity.WarehouseName = result.WarehouseName;
|
||||||
|
stockDetailsEntity.MaterialName = result.MaterialName;
|
||||||
|
stockDetailsEntity.StockDetailsTime = DateTime.Now;
|
||||||
|
stockDetailsEntity.Quality = input.Quality;
|
||||||
|
stockDetailsEntity.Number = input.Number;
|
||||||
|
stockDetailsEntity.StockDetailsType = StockDetailsTypeEnum.Output;
|
||||||
|
await _detailsRepository.InsertReturnSnowflakeIdAsync(stockDetailsEntity);
|
||||||
|
uow.Commit();
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -13,15 +13,15 @@ foreach (var entityName in entityNames)
|
|||||||
{
|
{
|
||||||
templateFactory.CreateTemplateProviders((option) =>
|
templateFactory.CreateTemplateProviders((option) =>
|
||||||
{
|
{
|
||||||
//option.Add(new ServceTemplateProvider(modelName, entityName));
|
option.Add(new ServceTemplateProvider(modelName, entityName));
|
||||||
//option.Add(new IServceTemplateProvider(modelName, entityName));
|
option.Add(new IServceTemplateProvider(modelName, entityName));
|
||||||
//option.Add(new CreateUpdateInputTemplateProvider(modelName, entityName));
|
option.Add(new CreateUpdateInputTemplateProvider(modelName, entityName));
|
||||||
//option.Add(new GetListOutputTemplateProvider(modelName, entityName));
|
option.Add(new GetListOutputTemplateProvider(modelName, entityName));
|
||||||
//option.Add(new GetListInputTemplateProvider(modelName, entityName));
|
option.Add(new GetListInputTemplateProvider(modelName, entityName));
|
||||||
//option.Add(new ConstTemplateProvider(modelName, entityName));
|
option.Add(new ConstTemplateProvider(modelName, entityName));
|
||||||
//option.Add(new ProfileTemplateProvider(modelName, entityName));
|
option.Add(new ProfileTemplateProvider(modelName, entityName));
|
||||||
option.Add(new ControllerTemplateProvider(modelName, entityName));
|
option.Add(new ControllerTemplateProvider(modelName, entityName));
|
||||||
//option.Add(new ApiTemplateProvider(modelName, entityName));
|
option.Add(new ApiTemplateProvider(modelName, entityName));
|
||||||
});
|
});
|
||||||
//开始构建模板
|
//开始构建模板
|
||||||
templateFactory.BuildTemplate();
|
templateFactory.BuildTemplate();
|
||||||
|
|||||||
45
Yi.Vue3.x.RuoYi/src/api/erp/stockApi.js
Normal file
45
Yi.Vue3.x.RuoYi/src/api/erp/stockApi.js
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
import request from '@/utils/request'
|
||||||
|
|
||||||
|
// 分页查询
|
||||||
|
export function listData(query) {
|
||||||
|
return request({
|
||||||
|
url: '/stock/pageList',
|
||||||
|
method: 'get',
|
||||||
|
params: query
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// id查询
|
||||||
|
export function getData(code) {
|
||||||
|
return request({
|
||||||
|
url: '/stock/getById/' + code,
|
||||||
|
method: 'get'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 新增
|
||||||
|
export function addData(data) {
|
||||||
|
return request({
|
||||||
|
url: '/stock/create',
|
||||||
|
method: 'post',
|
||||||
|
data: data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 修改
|
||||||
|
export function updateData(id,data) {
|
||||||
|
return request({
|
||||||
|
url: `/stock/update/${id}`,
|
||||||
|
method: 'put',
|
||||||
|
data: data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 删除
|
||||||
|
export function delData(code) {
|
||||||
|
return request({
|
||||||
|
url: '/stock/del',
|
||||||
|
method: 'delete',
|
||||||
|
data:"string"==typeof(code)?[code]:code
|
||||||
|
})
|
||||||
|
}
|
||||||
45
Yi.Vue3.x.RuoYi/src/api/erp/stockDetailsApi.js
Normal file
45
Yi.Vue3.x.RuoYi/src/api/erp/stockDetailsApi.js
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
import request from '@/utils/request'
|
||||||
|
|
||||||
|
// 分页查询
|
||||||
|
export function listData(query) {
|
||||||
|
return request({
|
||||||
|
url: '/stockDetails/pageList',
|
||||||
|
method: 'get',
|
||||||
|
params: query
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// id查询
|
||||||
|
export function getData(code) {
|
||||||
|
return request({
|
||||||
|
url: '/stockDetails/getById/' + code,
|
||||||
|
method: 'get'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 新增
|
||||||
|
export function addData(data) {
|
||||||
|
return request({
|
||||||
|
url: '/stockDetails/create',
|
||||||
|
method: 'post',
|
||||||
|
data: data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 修改
|
||||||
|
export function updateData(id,data) {
|
||||||
|
return request({
|
||||||
|
url: `/stockDetails/update/${id}`,
|
||||||
|
method: 'put',
|
||||||
|
data: data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 删除
|
||||||
|
export function delData(code) {
|
||||||
|
return request({
|
||||||
|
url: '/stockDetails/del',
|
||||||
|
method: 'delete',
|
||||||
|
data:"string"==typeof(code)?[code]:code
|
||||||
|
})
|
||||||
|
}
|
||||||
363
Yi.Vue3.x.RuoYi/src/views/erp/stock/index.vue
Normal file
363
Yi.Vue3.x.RuoYi/src/views/erp/stock/index.vue
Normal file
@@ -0,0 +1,363 @@
|
|||||||
|
<template>
|
||||||
|
|
||||||
|
<div class="app-container">
|
||||||
|
<el-form
|
||||||
|
:model="queryParams"
|
||||||
|
ref="queryRef"
|
||||||
|
:inline="true"
|
||||||
|
v-show="showSearch"
|
||||||
|
label-width="100px"
|
||||||
|
>
|
||||||
|
<el-form-item label="库存名称" prop="name" >
|
||||||
|
<el-input
|
||||||
|
v-model="queryParams.name"
|
||||||
|
placeholder="请输入库存名称"
|
||||||
|
clearable
|
||||||
|
style="width: 240px"
|
||||||
|
@keyup.enter="handleQuery"
|
||||||
|
prop="name"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="库存编号" prop="code" >
|
||||||
|
<el-input
|
||||||
|
v-model="queryParams.code"
|
||||||
|
placeholder="请输入库存编号"
|
||||||
|
clearable
|
||||||
|
style="width: 240px"
|
||||||
|
@keyup.enter="handleQuery"
|
||||||
|
prop="code"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
<!-- <el-form-item label="状态" prop="isDeleted">
|
||||||
|
<el-select
|
||||||
|
v-model="queryParams.isDeleted"
|
||||||
|
placeholder="状态"
|
||||||
|
clearable
|
||||||
|
style="width: 240px"
|
||||||
|
>
|
||||||
|
<el-option
|
||||||
|
v-for="dict in sys_normal_disable"
|
||||||
|
:key="dict.value"
|
||||||
|
:label="dict.label"
|
||||||
|
:value="dict.value"
|
||||||
|
/>
|
||||||
|
</el-select>
|
||||||
|
</el-form-item> -->
|
||||||
|
<!-- <el-form-item label="创建时间" style="width: 308px">
|
||||||
|
<el-date-picker
|
||||||
|
v-model="dateRange"
|
||||||
|
value-format="YYYY-MM-DD"
|
||||||
|
type="daterange"
|
||||||
|
range-separator="-"
|
||||||
|
start-placeholder="开始日期"
|
||||||
|
end-placeholder="结束日期"
|
||||||
|
></el-date-picker>
|
||||||
|
</el-form-item> -->
|
||||||
|
<el-form-item>
|
||||||
|
<el-button type="primary" icon="Search" @click="handleQuery"
|
||||||
|
>搜索</el-button
|
||||||
|
>
|
||||||
|
<el-button icon="Refresh" @click="resetQuery">重置</el-button>
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
|
|
||||||
|
<el-row :gutter="10" class="mb8">
|
||||||
|
<el-col :span="1.5">
|
||||||
|
<el-button
|
||||||
|
type="primary"
|
||||||
|
plain
|
||||||
|
icon="Plus"
|
||||||
|
@click="handleAdd"
|
||||||
|
v-hasPermi="['erp:stock:add']"
|
||||||
|
>新增</el-button
|
||||||
|
>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="1.5">
|
||||||
|
<el-button
|
||||||
|
type="success"
|
||||||
|
plain
|
||||||
|
icon="Edit"
|
||||||
|
:disabled="single"
|
||||||
|
@click="handleUpdate"
|
||||||
|
v-hasPermi="['erp:stock:edit']"
|
||||||
|
>修改</el-button
|
||||||
|
>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="1.5">
|
||||||
|
<el-button
|
||||||
|
type="danger"
|
||||||
|
plain
|
||||||
|
icon="Delete"
|
||||||
|
:disabled="multiple"
|
||||||
|
@click="handleDelete"
|
||||||
|
v-hasPermi="['erp:stock:remove']"
|
||||||
|
>删除</el-button
|
||||||
|
>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="1.5">
|
||||||
|
<el-button
|
||||||
|
type="warning"
|
||||||
|
plain
|
||||||
|
icon="Download"
|
||||||
|
@click="handleExport"
|
||||||
|
v-hasPermi="['erp:stock:export']"
|
||||||
|
>导出</el-button
|
||||||
|
>
|
||||||
|
</el-col>
|
||||||
|
<right-toolbar
|
||||||
|
v-model:showSearch="showSearch"
|
||||||
|
@queryTable="getList"
|
||||||
|
></right-toolbar>
|
||||||
|
</el-row>
|
||||||
|
|
||||||
|
<el-table
|
||||||
|
v-loading="loading"
|
||||||
|
:data="dataList"
|
||||||
|
@selection-change="handleSelectionChange"
|
||||||
|
>
|
||||||
|
<el-table-column type="selection" width="55" align="center" />
|
||||||
|
|
||||||
|
<!-----------------------这里开始就是数据表单的全部列------------------------>
|
||||||
|
<el-table-column label="库存编号" align="center" prop="code" />
|
||||||
|
|
||||||
|
<el-table-column label="库存名称" align="center" prop="name" :show-overflow-tooltip="true"/>
|
||||||
|
|
||||||
|
<el-table-column label="备注" align="center" prop="remarks" :show-overflow-tooltip="true"/>
|
||||||
|
<!-- <el-table-column label="状态" align="center" prop="isDeleted">
|
||||||
|
<template #default="scope">
|
||||||
|
<dict-tag
|
||||||
|
:options="sys_normal_disable"
|
||||||
|
:value="scope.row.isDeleted"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
</el-table-column> -->
|
||||||
|
<!-- <el-table-column
|
||||||
|
label="备注"
|
||||||
|
align="center"
|
||||||
|
prop="remark"
|
||||||
|
:show-overflow-tooltip="true"
|
||||||
|
/>
|
||||||
|
<el-table-column
|
||||||
|
label="创建时间"
|
||||||
|
align="center"
|
||||||
|
prop="createTime"
|
||||||
|
width="180"
|
||||||
|
>
|
||||||
|
<template #default="scope">
|
||||||
|
<span>{{ parseTime(scope.row.createTime) }}</span>
|
||||||
|
</template>
|
||||||
|
</el-table-column> -->
|
||||||
|
<el-table-column
|
||||||
|
label="操作"
|
||||||
|
align="center"
|
||||||
|
class-name="small-padding fixed-width"
|
||||||
|
>
|
||||||
|
<template #default="scope">
|
||||||
|
|
||||||
|
<el-button
|
||||||
|
type="text"
|
||||||
|
icon="Edit"
|
||||||
|
@click="handleUpdate(scope.row)"
|
||||||
|
v-hasPermi="['business:article:edit']"
|
||||||
|
>修改</el-button
|
||||||
|
>
|
||||||
|
<el-button
|
||||||
|
type="text"
|
||||||
|
icon="Delete"
|
||||||
|
@click="handleDelete(scope.row)"
|
||||||
|
v-hasPermi="['business:article:remove']"
|
||||||
|
>删除</el-button
|
||||||
|
>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
</el-table>
|
||||||
|
|
||||||
|
<pagination
|
||||||
|
v-show="total > 0"
|
||||||
|
:total="total"
|
||||||
|
v-model:page="queryParams.pageNum"
|
||||||
|
v-model:limit="queryParams.pageSize"
|
||||||
|
@pagination="getList"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<!-- ---------------------这里是新增和更新的对话框--------------------- -->
|
||||||
|
<el-dialog :title="title" v-model="open" width="600px" append-to-body>
|
||||||
|
<el-form ref="dataRef" :model="form" :rules="rules" label-width="100px">
|
||||||
|
<el-form-item label="库存编码" prop="code">
|
||||||
|
<el-input v-model="form.code" placeholder="请输入库存编码" />
|
||||||
|
</el-form-item>
|
||||||
|
|
||||||
|
<el-form-item label="库存名称" prop="name">
|
||||||
|
<el-input v-model="form.name" placeholder="请输入库存名称" />
|
||||||
|
</el-form-item>
|
||||||
|
|
||||||
|
<!-- <el-form-item label="状态" prop="isDeleted">
|
||||||
|
<el-radio-group v-model="form.isDeleted">
|
||||||
|
<el-radio
|
||||||
|
v-for="dict in sys_normal_disable"
|
||||||
|
:key="dict.value"
|
||||||
|
:label="JSON.parse(dict.value)"
|
||||||
|
>{{ dict.label }}</el-radio
|
||||||
|
>
|
||||||
|
</el-radio-group>
|
||||||
|
</el-form-item> -->
|
||||||
|
<el-form-item label="备注" prop="remarks">
|
||||||
|
<el-input
|
||||||
|
v-model="form.remarks"
|
||||||
|
type="textarea"
|
||||||
|
placeholder="请输入内容"
|
||||||
|
></el-input>
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
|
<template #footer>
|
||||||
|
<div class="dialog-footer">
|
||||||
|
<el-button type="primary" @click="submitForm">确 定</el-button>
|
||||||
|
<el-button @click="cancel">取 消</el-button>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</el-dialog>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup>
|
||||||
|
import {
|
||||||
|
listData,
|
||||||
|
getData,
|
||||||
|
delData,
|
||||||
|
addData,
|
||||||
|
updateData,
|
||||||
|
} from "@/api/erp/stockApi";
|
||||||
|
import { ref } from "@vue/reactivity";
|
||||||
|
|
||||||
|
|
||||||
|
const { proxy } = getCurrentInstance();
|
||||||
|
const { sys_normal_disable } = proxy.useDict("sys_normal_disable");
|
||||||
|
|
||||||
|
const dataList = ref([]);
|
||||||
|
const open = ref(false);
|
||||||
|
const loading = ref(true);
|
||||||
|
const showSearch = ref(true);
|
||||||
|
const ids = ref([]);
|
||||||
|
const single = ref(true);
|
||||||
|
const multiple = ref(true);
|
||||||
|
const total = ref(0);
|
||||||
|
const title = ref("");
|
||||||
|
const dateRange = ref([]);
|
||||||
|
const data = reactive({
|
||||||
|
form: {},
|
||||||
|
queryParams: {
|
||||||
|
pageNum: 1,
|
||||||
|
pageSize: 10,
|
||||||
|
name: undefined,
|
||||||
|
code: undefined,
|
||||||
|
},
|
||||||
|
rules: {
|
||||||
|
code: [{ required: true, message: "库存编号不能为空", trigger: "blur" }],
|
||||||
|
name: [{ required: true, message: "库存名称不能为空", trigger: "blur" }],
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
const { queryParams, form, rules } = toRefs(data);
|
||||||
|
|
||||||
|
/** 查询列表 */
|
||||||
|
function getList() {
|
||||||
|
loading.value = true;
|
||||||
|
listData(proxy.addDateRange(queryParams.value, dateRange.value)).then(
|
||||||
|
(response) => {
|
||||||
|
dataList.value = response.data.data;
|
||||||
|
total.value = response.data.total;
|
||||||
|
loading.value = false;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
/** 取消按钮 */
|
||||||
|
function cancel() {
|
||||||
|
open.value = false;
|
||||||
|
reset();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/** 表单重置 */
|
||||||
|
function reset() {
|
||||||
|
proxy.resetForm("dataRef");
|
||||||
|
}
|
||||||
|
/** 搜索按钮操作 */
|
||||||
|
function handleQuery() {
|
||||||
|
queryParams.value.pageNum = 1;
|
||||||
|
getList();
|
||||||
|
}
|
||||||
|
/** 重置按钮操作 */
|
||||||
|
function resetQuery() {
|
||||||
|
dateRange.value = [];
|
||||||
|
proxy.resetForm("queryRef");
|
||||||
|
handleQuery();
|
||||||
|
}
|
||||||
|
/** 新增按钮操作 */
|
||||||
|
function handleAdd() {
|
||||||
|
reset();
|
||||||
|
open.value = true;
|
||||||
|
title.value = "添加库存";
|
||||||
|
}
|
||||||
|
/** 多选框选中数据 */
|
||||||
|
function handleSelectionChange(selection) {
|
||||||
|
ids.value = selection.map((item) => item.id);
|
||||||
|
single.value = selection.length != 1;
|
||||||
|
multiple.value = !selection.length;
|
||||||
|
}
|
||||||
|
/** 修改按钮操作 */
|
||||||
|
function handleUpdate(row) {
|
||||||
|
reset();
|
||||||
|
const id = row.id || ids.value;
|
||||||
|
getData(id).then((response) => {
|
||||||
|
form.value = response.data;
|
||||||
|
open.value = true;
|
||||||
|
title.value = "修改库存";
|
||||||
|
});
|
||||||
|
}
|
||||||
|
/** 提交按钮 */
|
||||||
|
function submitForm() {
|
||||||
|
proxy.$refs["dataRef"].validate((valid) => {
|
||||||
|
if (valid) {
|
||||||
|
if (form.value.id != undefined) {
|
||||||
|
updateData(form.value.id,form.value).then((response) => {
|
||||||
|
proxy.$modal.msgSuccess("修改成功");
|
||||||
|
open.value = false;
|
||||||
|
getList();
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
addData(form.value).then((response) => {
|
||||||
|
proxy.$modal.msgSuccess("新增成功");
|
||||||
|
open.value = false;
|
||||||
|
getList();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
/** 删除按钮操作 */
|
||||||
|
function handleDelete(row) {
|
||||||
|
const delIds = row.id || ids.value;
|
||||||
|
proxy.$modal
|
||||||
|
.confirm('是否确认删除编号为"' + delIds + '"的数据项?')
|
||||||
|
.then(function () {
|
||||||
|
return delData(delIds);
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
getList();
|
||||||
|
proxy.$modal.msgSuccess("删除成功");
|
||||||
|
})
|
||||||
|
.catch(() => {});
|
||||||
|
}
|
||||||
|
/** 导出按钮操作 */
|
||||||
|
function handleExport() {}
|
||||||
|
|
||||||
|
getList();
|
||||||
|
</script>
|
||||||
Reference in New Issue
Block a user