完善出库闭环和前端作业体验
This commit is contained in:
parent
3c6dfda5e5
commit
ce0fd7ec52
19
README.md
19
README.md
@ -46,14 +46,16 @@
|
||||
|
||||
### 布局与多标签页
|
||||
|
||||
- **侧边菜单 + 顶部混合布局(mix)**:Pro Layout
|
||||
- **标签栏**:位于 **`ant-layout-header`** 区域内(卡片式可关闭标签,与面包屑等区域并列)
|
||||
- **Keep-Alive**:切换标签尽可能保留表格筛选、表单与滚动位置(`react-activation`)
|
||||
- **侧边菜单 + 顶部混合布局(mix)**:Pro Layout。
|
||||
- **工作区标签栏**:位于 `ant-layout-header` 区域内,采用浅色轨道 + 胶囊标签样式。
|
||||
- **Keep-Alive**:切换标签尽可能保留表格筛选、表单与滚动位置(`react-activation`)。
|
||||
- **标签规则**:
|
||||
- 单个标签标识为 **`pathname + search`**
|
||||
- 最多打开 **12** 个标签,超出时关闭最早一条并提示
|
||||
- 关闭全部或最后一个业务标签后,回到 **主页**(`/home`),并保留「主页」标签
|
||||
- **批量关闭**(标签栏右侧「标签页 ▼」):**关闭当前**、**关闭其他**、**关闭全部**
|
||||
- 单个标签标识为归一化后的 **`pathname + search`**。
|
||||
- `/` 会归一为 `/home`,避免点击左上角图标后新增“页面”标签。
|
||||
- 首页标签固定显示 Home 图标且不可关闭。
|
||||
- 最多打开 **12** 个标签,超出时优先关闭最早的非首页标签。
|
||||
- 关闭全部或最后一个业务标签后,回到 **首页**(`/home`),并保留「首页」标签。
|
||||
- **批量关闭**:标签栏右侧更多图标提供 **关闭当前**、**关闭其他**、**关闭全部**。
|
||||
|
||||
### UI 共性
|
||||
|
||||
@ -92,8 +94,11 @@ pnpm run dev
|
||||
cd WmsLite.Web
|
||||
pnpm run lint
|
||||
pnpm run typecheck
|
||||
pnpm run build
|
||||
```
|
||||
|
||||
当前项目约定不安排自动化测试建设,阶段验收以 `dotnet build`、`pnpm run typecheck`、`pnpm run build`、`pnpm run lint` 和人工业务场景为主。
|
||||
|
||||
## 相关源码索引
|
||||
|
||||
| 主题 | 路径 |
|
||||
|
||||
@ -42,6 +42,17 @@ public class InboundOrderController : WmsLiteControllerBase
|
||||
public async Task<ActionResult<BusinessResult>> Create([FromBody] InboundOrderCreateRequest request)
|
||||
=> Ok(BusinessResult.Ok(await _service.CreateAsync(request)));
|
||||
|
||||
[HttpPost("create-header")]
|
||||
public async Task<ActionResult<BusinessResult>> CreateHeader([FromBody] OrderHeaderCreateRequest request)
|
||||
=> Ok(BusinessResult.Ok(await _service.CreateHeaderAsync(request)));
|
||||
|
||||
[HttpPost("add-line")]
|
||||
public async Task<ActionResult<BusinessResult>> AddLine([FromBody] InboundOrderAddLineRequest request)
|
||||
{
|
||||
var result = await _service.AddLineAsync(request);
|
||||
return result is null ? Ok(BusinessResult.NotFound("Resource not found.")) : Ok(BusinessResult.Ok(result));
|
||||
}
|
||||
|
||||
[HttpPost("confirm-line")]
|
||||
public async Task<ActionResult<BusinessResult>> ConfirmLine([FromBody] InboundOrderLineConfirmRequest request)
|
||||
{
|
||||
@ -98,6 +109,17 @@ public class OutboundOrderController : WmsLiteControllerBase
|
||||
public async Task<ActionResult<BusinessResult>> Create([FromBody] OutboundOrderSaveRequest request)
|
||||
=> Ok(BusinessResult.Ok(await _service.CreateAsync(request)));
|
||||
|
||||
[HttpPost("create-header")]
|
||||
public async Task<ActionResult<BusinessResult>> CreateHeader([FromBody] OrderHeaderCreateRequest request)
|
||||
=> Ok(BusinessResult.Ok(await _service.CreateHeaderAsync(request)));
|
||||
|
||||
[HttpPost("add-line")]
|
||||
public async Task<ActionResult<BusinessResult>> AddLine([FromBody] OutboundOrderAddLineRequest request)
|
||||
{
|
||||
var result = await _service.AddLineAsync(request);
|
||||
return result is null ? Ok(BusinessResult.NotFound("Resource not found.")) : Ok(BusinessResult.Ok(result));
|
||||
}
|
||||
|
||||
[HttpPost("pending")]
|
||||
public async Task<ActionResult<BusinessResult>> Pending([FromBody] OrderActionRequest request)
|
||||
{
|
||||
@ -111,6 +133,20 @@ public class OutboundOrderController : WmsLiteControllerBase
|
||||
var result = await _service.ConfirmAsync(request);
|
||||
return result is null ? Ok(BusinessResult.NotFound("Resource not found.")) : Ok(BusinessResult.Ok(result));
|
||||
}
|
||||
|
||||
[HttpPost("pick-task/confirm")]
|
||||
public async Task<ActionResult<BusinessResult>> ConfirmPickTask([FromBody] PickTaskActionRequest request)
|
||||
{
|
||||
var result = await _service.ConfirmPickTaskAsync(request);
|
||||
return result is null ? Ok(BusinessResult.NotFound("Resource not found.")) : Ok(BusinessResult.Ok(result));
|
||||
}
|
||||
|
||||
[HttpPost("cancel")]
|
||||
public async Task<ActionResult<BusinessResult>> Cancel([FromBody] OrderActionRequest request)
|
||||
{
|
||||
var result = await _service.CancelAsync(request);
|
||||
return result is null ? Ok(BusinessResult.NotFound("Resource not found.")) : Ok(BusinessResult.Ok(result));
|
||||
}
|
||||
}
|
||||
|
||||
[ApiController]
|
||||
|
||||
@ -0,0 +1,56 @@
|
||||
using FluentMigrator;
|
||||
|
||||
namespace WmsLite.Api.Database.Migrations;
|
||||
|
||||
[Migration(16, "Outbound pick task operation fields")]
|
||||
public class OutboundPickTaskOperationFields0016 : Migration
|
||||
{
|
||||
public override void Up()
|
||||
{
|
||||
if (!Schema.Table("outbound_pick_task").Exists())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!Schema.Table("outbound_pick_task").Column("picker_user_id").Exists())
|
||||
{
|
||||
Alter.Table("outbound_pick_task")
|
||||
.AddColumn("picker_user_id").AsString(128).Nullable();
|
||||
}
|
||||
|
||||
if (!Schema.Table("outbound_pick_task").Column("picked_time").Exists())
|
||||
{
|
||||
Alter.Table("outbound_pick_task")
|
||||
.AddColumn("picked_time").AsDateTime().Nullable();
|
||||
}
|
||||
|
||||
if (!Schema.Table("outbound_pick_task").Column("exception_reason").Exists())
|
||||
{
|
||||
Alter.Table("outbound_pick_task")
|
||||
.AddColumn("exception_reason").AsString(512).Nullable();
|
||||
}
|
||||
}
|
||||
|
||||
public override void Down()
|
||||
{
|
||||
if (!Schema.Table("outbound_pick_task").Exists())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (Schema.Table("outbound_pick_task").Column("exception_reason").Exists())
|
||||
{
|
||||
Delete.Column("exception_reason").FromTable("outbound_pick_task");
|
||||
}
|
||||
|
||||
if (Schema.Table("outbound_pick_task").Column("picked_time").Exists())
|
||||
{
|
||||
Delete.Column("picked_time").FromTable("outbound_pick_task");
|
||||
}
|
||||
|
||||
if (Schema.Table("outbound_pick_task").Column("picker_user_id").Exists())
|
||||
{
|
||||
Delete.Column("picker_user_id").FromTable("outbound_pick_task");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -19,6 +19,10 @@ public abstract class OrderSaveRequestBase
|
||||
public Dictionary<string, object>? Attrs { get; set; }
|
||||
}
|
||||
|
||||
public class OrderHeaderCreateRequest : OrderSaveRequestBase
|
||||
{
|
||||
}
|
||||
|
||||
public abstract class OrderPagedQueryBase : BasePagedQuery
|
||||
{
|
||||
[StringLength(128)]
|
||||
@ -36,6 +40,36 @@ public class OrderActionRequest
|
||||
public long Id { get; set; }
|
||||
}
|
||||
|
||||
public class InboundOrderAddLineRequest
|
||||
{
|
||||
[Range(1, long.MaxValue)]
|
||||
public long OrderId { get; set; }
|
||||
|
||||
[Required]
|
||||
public InboundOrderLineSaveRequest Line { get; set; } = new();
|
||||
}
|
||||
|
||||
public class OutboundOrderAddLineRequest
|
||||
{
|
||||
[Range(1, long.MaxValue)]
|
||||
public long OrderId { get; set; }
|
||||
|
||||
[Required]
|
||||
public OutboundOrderLineRequest Line { get; set; } = new();
|
||||
}
|
||||
|
||||
public class PickTaskActionRequest
|
||||
{
|
||||
[Range(1, long.MaxValue)]
|
||||
public long Id { get; set; }
|
||||
|
||||
[Range(typeof(decimal), "0.000001", "9999999999999999")]
|
||||
public decimal? PickedQty { get; set; }
|
||||
|
||||
[StringLength(512)]
|
||||
public string? ExceptionReason { get; set; }
|
||||
}
|
||||
|
||||
public class InventoryOrderLineRequest
|
||||
{
|
||||
[Required]
|
||||
@ -123,15 +157,8 @@ public class StocktakeOrderLineRequest : InventoryOrderLineRequest
|
||||
}
|
||||
|
||||
/// <summary>?????????????????? JSON?</summary>
|
||||
public class InboundOrderCreateRequest
|
||||
public class InboundOrderCreateRequest : OrderSaveRequestBase
|
||||
{
|
||||
[StringLength(64)]
|
||||
public string? BizType { get; set; }
|
||||
|
||||
[StringLength(512)]
|
||||
public string? Remark { get; set; }
|
||||
|
||||
[MinLength(1)]
|
||||
public List<InboundOrderLineSaveRequest> Lines { get; set; } = new();
|
||||
}
|
||||
|
||||
@ -188,7 +215,6 @@ public class InboundConfirmLineResultDto
|
||||
|
||||
public class OutboundOrderSaveRequest : OrderSaveRequestBase
|
||||
{
|
||||
[MinLength(1)]
|
||||
public List<OutboundOrderLineRequest> Lines { get; set; } = new();
|
||||
}
|
||||
|
||||
@ -219,9 +245,8 @@ public class OutboundOrderLineRequest
|
||||
[Range(typeof(decimal), "0.000001", "9999999999999999")]
|
||||
public decimal Qty { get; set; }
|
||||
|
||||
[Required]
|
||||
[StringLength(32)]
|
||||
public string Unit { get; set; } = string.Empty;
|
||||
public string? Unit { get; set; }
|
||||
|
||||
public Dictionary<string, object>? Attrs { get; set; }
|
||||
}
|
||||
|
||||
@ -33,6 +33,12 @@ public class OutboundPickTaskViewDto
|
||||
|
||||
public decimal PickedQty { get; set; }
|
||||
|
||||
public string? PickerUserId { get; set; }
|
||||
|
||||
public DateTime? PickedTime { get; set; }
|
||||
|
||||
public string? ExceptionReason { get; set; }
|
||||
|
||||
public string Unit { get; set; } = string.Empty;
|
||||
|
||||
public PickTaskStatus TaskStatus { get; set; }
|
||||
|
||||
@ -23,5 +23,8 @@ public enum InventoryMovementType
|
||||
Unfreeze = 6,
|
||||
|
||||
[Description("Adjust")]
|
||||
Adjust = 7
|
||||
Adjust = 7,
|
||||
|
||||
[Description("PendingOutboundRelease")]
|
||||
PendingOutboundRelease = 8
|
||||
}
|
||||
|
||||
@ -46,6 +46,15 @@ public class OutboundPickTask : BaseEntity
|
||||
[SugarColumn(ColumnName = "picked_qty", IsNullable = false, DefaultValue = "0")]
|
||||
public decimal PickedQty { get; set; }
|
||||
|
||||
[SugarColumn(ColumnName = "picker_user_id", Length = 128, IsNullable = true)]
|
||||
public string? PickerUserId { get; set; }
|
||||
|
||||
[SugarColumn(ColumnName = "picked_time", IsNullable = true)]
|
||||
public DateTime? PickedTime { get; set; }
|
||||
|
||||
[SugarColumn(ColumnName = "exception_reason", Length = 512, IsNullable = true)]
|
||||
public string? ExceptionReason { get; set; }
|
||||
|
||||
[SugarColumn(ColumnName = "unit", Length = 32, IsNullable = false)]
|
||||
public string Unit { get; set; } = string.Empty;
|
||||
|
||||
|
||||
@ -84,6 +84,8 @@ Development 见 `appsettings.Development.json` 中 `Jwt` 节。生产环境请
|
||||
| 0012 | `sys_user` 表与种子账号 |
|
||||
| 0013 | 入库单号计数器 `order_no_counter` |
|
||||
| 0014 | 业务唯一约束(partial unique index) |
|
||||
| 0015 | 出库库存分配与拣货任务 |
|
||||
| 0016 | 出库拣货任务操作字段 |
|
||||
|
||||
## 启动
|
||||
|
||||
@ -103,8 +105,28 @@ GET /api/Auth/me # 需 Bearer
|
||||
GET /api/Health # 匿名
|
||||
POST /api/Warehouse/paged-list
|
||||
POST /api/SysDictionary/map
|
||||
POST /api/InboundOrder/create-header
|
||||
POST /api/InboundOrder/add-line
|
||||
POST /api/OutboundOrder/create-header
|
||||
POST /api/OutboundOrder/add-line
|
||||
POST /api/OutboundOrder/pending
|
||||
POST /api/OutboundOrder/pick-task/confirm
|
||||
POST /api/OutboundOrder/confirm
|
||||
POST /api/OutboundOrder/cancel
|
||||
```
|
||||
|
||||
### 单据接口约定
|
||||
|
||||
- 入库、出库支持先创建 Draft 单头,再追加明细:
|
||||
- `POST /api/InboundOrder/create-header`
|
||||
- `POST /api/InboundOrder/add-line`
|
||||
- `POST /api/OutboundOrder/create-header`
|
||||
- `POST /api/OutboundOrder/add-line`
|
||||
- 出库物料行的 `unit` 可不传,服务端会按物料主数据单位写入;若客户端传入单位,必须与物料主数据一致。
|
||||
- 出库转待拣会按仓库、库区、物料和可选指定库位分配库存并生成拣货任务。
|
||||
- `POST /api/OutboundOrder/pick-task/confirm` 用于确认单个拣货任务,记录拣货人、拣货时间、已拣数量和异常原因。
|
||||
- `POST /api/OutboundOrder/cancel` 仅允许取消待处理出库单,会释放 `PendingOutboundQty` 并取消未出库任务。
|
||||
|
||||
未带 Token 访问业务接口返回 **HTTP 401**(JSON:`{ "success": false, "code": "401", ... }`)。
|
||||
|
||||
## 项目结构
|
||||
|
||||
@ -16,6 +16,8 @@ public interface IInventoryMovementService
|
||||
|
||||
Task ConfirmOutboundAsync(Inventory inventory, decimal qty, string? bizNo = null, string? remark = null);
|
||||
|
||||
Task ReleasePendingOutboundAsync(Inventory inventory, decimal qty, string? bizNo = null, string? remark = null);
|
||||
|
||||
Task FreezeAsync(Inventory inventory, decimal qty, string? bizNo = null, string? remark = null);
|
||||
|
||||
Task UnfreezeAsync(Inventory inventory, decimal qty, string? bizNo = null, string? remark = null);
|
||||
|
||||
@ -11,8 +11,12 @@ public interface IInboundOrderService
|
||||
|
||||
Task<List<InventoryOrderLineViewDto>?> GetLinesAsync(long orderId, string tenantId, string ownerCode);
|
||||
|
||||
Task<OrderViewDto> CreateHeaderAsync(OrderHeaderCreateRequest request);
|
||||
|
||||
Task<OrderViewDto> CreateAsync(InboundOrderCreateRequest request);
|
||||
|
||||
Task<InventoryOrderLineViewDto?> AddLineAsync(InboundOrderAddLineRequest request);
|
||||
|
||||
Task<InboundConfirmLineResultDto?> ConfirmLineAsync(InboundOrderLineConfirmRequest request);
|
||||
}
|
||||
|
||||
@ -24,11 +28,19 @@ public interface IOutboundOrderService
|
||||
|
||||
Task<List<OutboundPickTaskViewDto>?> GetPickTasksAsync(long orderId, string tenantId, string ownerCode);
|
||||
|
||||
Task<OrderViewDto> CreateHeaderAsync(OrderHeaderCreateRequest request);
|
||||
|
||||
Task<OrderViewDto> CreateAsync(OutboundOrderSaveRequest request);
|
||||
|
||||
Task<InventoryOrderLineViewDto?> AddLineAsync(OutboundOrderAddLineRequest request);
|
||||
|
||||
Task<OrderViewDto?> PendingAsync(OrderActionRequest request);
|
||||
|
||||
Task<OutboundPickTaskViewDto?> ConfirmPickTaskAsync(PickTaskActionRequest request);
|
||||
|
||||
Task<OrderViewDto?> ConfirmAsync(OrderActionRequest request);
|
||||
|
||||
Task<OrderViewDto?> CancelAsync(OrderActionRequest request);
|
||||
}
|
||||
|
||||
public interface ITransferOrderService
|
||||
|
||||
@ -95,6 +95,21 @@ public class InventoryMovementService : IInventoryMovementService
|
||||
await WriteTransactionAsync(before, inventory, InventoryMovementType.OutboundConfirm, -qty, bizNo, remark);
|
||||
}
|
||||
|
||||
public async Task ReleasePendingOutboundAsync(Inventory inventory, decimal qty, string? bizNo = null, string? remark = null)
|
||||
{
|
||||
EnsurePositive(qty);
|
||||
if (inventory.PendingOutboundQty < qty)
|
||||
{
|
||||
throw new BusinessException("PendingOutboundQty is not enough to release.");
|
||||
}
|
||||
|
||||
var before = Clone(inventory);
|
||||
inventory.PendingOutboundQty -= qty;
|
||||
inventory.InventoryStatus = ResolveStatus(inventory);
|
||||
await _inventoryRepository.UpdateAsync(inventory);
|
||||
await WriteTransactionAsync(before, inventory, InventoryMovementType.PendingOutboundRelease, -qty, bizNo, remark);
|
||||
}
|
||||
|
||||
public async Task FreezeAsync(Inventory inventory, decimal qty, string? bizNo = null, string? remark = null)
|
||||
{
|
||||
EnsurePositive(qty);
|
||||
|
||||
@ -284,48 +284,49 @@ public class InboundOrderService : OrderServiceBase, IInboundOrderService
|
||||
{
|
||||
var tenantId = _userContext.TenantId.Trim();
|
||||
var ownerCode = _userContext.OwnerCode.Trim();
|
||||
var orderNo = await _orderNumberGenerator.NextInboundOrderNoAsync(tenantId, ownerCode);
|
||||
|
||||
var order = new InboundOrder
|
||||
{
|
||||
TenantId = tenantId,
|
||||
OwnerCode = ownerCode,
|
||||
OrderNo = orderNo,
|
||||
BizType = request.BizType?.Trim(),
|
||||
Remark = request.Remark?.Trim(),
|
||||
Attrs = null,
|
||||
OrderStatus = OrderStatus.Draft
|
||||
};
|
||||
await _orderRepository.InsertAsync(order);
|
||||
var order = await CreateHeaderCoreAsync(tenantId, ownerCode, request);
|
||||
|
||||
for (var i = 0; i < request.Lines.Count; i++)
|
||||
{
|
||||
var line = request.Lines[i];
|
||||
await ValidateInboundLineMasterDataAsync(tenantId, ownerCode, line);
|
||||
await _lineRepository.InsertAsync(new InboundOrderLine
|
||||
{
|
||||
TenantId = order.TenantId,
|
||||
OwnerCode = order.OwnerCode,
|
||||
OrderId = order.Id,
|
||||
LineNo = i + 1,
|
||||
InventoryKind = line.InventoryKind,
|
||||
MaterialCode = line.InventoryKind == InventoryKind.Material ? line.MaterialCode?.Trim() : null,
|
||||
ContainerCode = null,
|
||||
WarehouseCode = line.WarehouseCode.Trim(),
|
||||
AreaCode = line.AreaCode.Trim(),
|
||||
LocationCode = null,
|
||||
Qty = line.Qty,
|
||||
ReceivedQty = 0,
|
||||
LineStatus = OrderLineStatus.Open,
|
||||
Unit = null,
|
||||
Attrs = line.Attrs
|
||||
});
|
||||
await InsertInboundLineAsync(order, request.Lines[i], i + 1);
|
||||
}
|
||||
|
||||
return MapOrder(order, order.OrderNo, order.BizType, order.OrderStatus, order.Remark, order.Attrs);
|
||||
});
|
||||
}
|
||||
|
||||
public async Task<OrderViewDto> CreateHeaderAsync(OrderHeaderCreateRequest request)
|
||||
{
|
||||
return await _tx.ExecuteAsync(async () =>
|
||||
{
|
||||
var order = await CreateHeaderCoreAsync(
|
||||
_userContext.TenantId.Trim(),
|
||||
_userContext.OwnerCode.Trim(),
|
||||
request);
|
||||
return MapOrder(order, order.OrderNo, order.BizType, order.OrderStatus, order.Remark, order.Attrs);
|
||||
});
|
||||
}
|
||||
|
||||
public async Task<InventoryOrderLineViewDto?> AddLineAsync(InboundOrderAddLineRequest request)
|
||||
{
|
||||
var order = await _orderRepository.GetByIdAsync(
|
||||
request.OrderId,
|
||||
_userContext.TenantId.Trim(),
|
||||
_userContext.OwnerCode.Trim());
|
||||
if (order is null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return await _tx.ExecuteAsync(async () =>
|
||||
{
|
||||
EnsureDraft(order.OrderStatus);
|
||||
var lines = await _lineRepository.GetByOrderIdAsync(order.Id);
|
||||
var line = await InsertInboundLineAsync(order, request.Line, lines.Count + 1);
|
||||
return MapInventoryLine(line);
|
||||
});
|
||||
}
|
||||
|
||||
public async Task<InboundConfirmLineResultDto?> ConfirmLineAsync(InboundOrderLineConfirmRequest request)
|
||||
{
|
||||
var tenantId = _userContext.TenantId.Trim();
|
||||
@ -530,6 +531,47 @@ public class InboundOrderService : OrderServiceBase, IInboundOrderService
|
||||
return string.Equals(aa, bb, StringComparison.Ordinal);
|
||||
}
|
||||
|
||||
private async Task<InboundOrder> CreateHeaderCoreAsync(string tenantId, string ownerCode, OrderSaveRequestBase request)
|
||||
{
|
||||
var order = new InboundOrder
|
||||
{
|
||||
TenantId = tenantId,
|
||||
OwnerCode = ownerCode,
|
||||
OrderNo = await _orderNumberGenerator.NextInboundOrderNoAsync(tenantId, ownerCode),
|
||||
BizType = request.BizType?.Trim(),
|
||||
Remark = request.Remark?.Trim(),
|
||||
Attrs = request.Attrs,
|
||||
OrderStatus = OrderStatus.Draft
|
||||
};
|
||||
await _orderRepository.InsertAsync(order);
|
||||
return order;
|
||||
}
|
||||
|
||||
private async Task<InboundOrderLine> InsertInboundLineAsync(InboundOrder order, InboundOrderLineSaveRequest line, int lineNo)
|
||||
{
|
||||
await ValidateInboundLineMasterDataAsync(order.TenantId, order.OwnerCode, line);
|
||||
var entity = new InboundOrderLine
|
||||
{
|
||||
TenantId = order.TenantId,
|
||||
OwnerCode = order.OwnerCode,
|
||||
OrderId = order.Id,
|
||||
LineNo = lineNo,
|
||||
InventoryKind = line.InventoryKind,
|
||||
MaterialCode = line.InventoryKind == InventoryKind.Material ? line.MaterialCode?.Trim() : null,
|
||||
ContainerCode = null,
|
||||
WarehouseCode = line.WarehouseCode.Trim(),
|
||||
AreaCode = line.AreaCode.Trim(),
|
||||
LocationCode = null,
|
||||
Qty = line.Qty,
|
||||
ReceivedQty = 0,
|
||||
LineStatus = OrderLineStatus.Open,
|
||||
Unit = null,
|
||||
Attrs = line.Attrs
|
||||
};
|
||||
await _lineRepository.InsertAsync(entity);
|
||||
return entity;
|
||||
}
|
||||
|
||||
private async Task ValidateInboundLineMasterDataAsync(string tenantId, string ownerCode, InboundOrderLineSaveRequest line)
|
||||
{
|
||||
var t = tenantId.Trim();
|
||||
@ -573,6 +615,7 @@ public class OutboundOrderService : OrderServiceBase, IOutboundOrderService
|
||||
private readonly IOutboundOrderLineRepository _lineRepository;
|
||||
private readonly IOutboundPickTaskRepository _pickTaskRepository;
|
||||
private readonly ILocationRepository _locationRepository;
|
||||
private readonly IMaterialRepository _materialRepository;
|
||||
private readonly IInventoryAllocationService _allocationService;
|
||||
private readonly IOrderNumberGenerator _orderNumberGenerator;
|
||||
private readonly ICurrentUserContext _userContext;
|
||||
@ -583,6 +626,7 @@ public class OutboundOrderService : OrderServiceBase, IOutboundOrderService
|
||||
IOutboundOrderLineRepository lineRepository,
|
||||
IOutboundPickTaskRepository pickTaskRepository,
|
||||
ILocationRepository locationRepository,
|
||||
IMaterialRepository materialRepository,
|
||||
IInventoryAllocationService allocationService,
|
||||
IOrderNumberGenerator orderNumberGenerator,
|
||||
IInventoryRepository inventoryRepository,
|
||||
@ -594,6 +638,7 @@ public class OutboundOrderService : OrderServiceBase, IOutboundOrderService
|
||||
_lineRepository = lineRepository;
|
||||
_pickTaskRepository = pickTaskRepository;
|
||||
_locationRepository = locationRepository;
|
||||
_materialRepository = materialRepository;
|
||||
_allocationService = allocationService;
|
||||
_orderNumberGenerator = orderNumberGenerator;
|
||||
_userContext = userContext;
|
||||
@ -643,54 +688,49 @@ public class OutboundOrderService : OrderServiceBase, IOutboundOrderService
|
||||
{
|
||||
var tenantId = _userContext.TenantId.Trim();
|
||||
var ownerCode = _userContext.OwnerCode.Trim();
|
||||
var orderNo = string.IsNullOrWhiteSpace(request.OrderNo)
|
||||
? await _orderNumberGenerator.NextOutboundOrderNoAsync(tenantId, ownerCode)
|
||||
: request.OrderNo.Trim();
|
||||
|
||||
if (await _orderRepository.GetByOrderNoAsync(tenantId, ownerCode, orderNo) is not null)
|
||||
{
|
||||
throw new BusinessException($"Outbound order '{orderNo}' already exists.");
|
||||
}
|
||||
|
||||
var order = new OutboundOrder
|
||||
{
|
||||
TenantId = tenantId,
|
||||
OwnerCode = ownerCode,
|
||||
OrderNo = orderNo,
|
||||
BizType = request.BizType?.Trim(),
|
||||
Remark = request.Remark?.Trim(),
|
||||
Attrs = request.Attrs,
|
||||
OrderStatus = OrderStatus.Draft
|
||||
};
|
||||
await _orderRepository.InsertAsync(order);
|
||||
var order = await CreateHeaderCoreAsync(tenantId, ownerCode, request);
|
||||
|
||||
for (var i = 0; i < request.Lines.Count; i++)
|
||||
{
|
||||
var line = request.Lines[i];
|
||||
await _lineRepository.InsertAsync(new OutboundOrderLine
|
||||
{
|
||||
TenantId = order.TenantId,
|
||||
OwnerCode = order.OwnerCode,
|
||||
OrderId = order.Id,
|
||||
LineNo = i + 1,
|
||||
InventoryKind = line.InventoryKind,
|
||||
MaterialCode = line.InventoryKind == InventoryKind.Material ? line.MaterialCode?.Trim() : null,
|
||||
ContainerCode = line.InventoryKind == InventoryKind.EmptyContainer ? line.ContainerCode?.Trim() : null,
|
||||
WarehouseCode = line.WarehouseCode.Trim(),
|
||||
AreaCode = line.AreaCode.Trim(),
|
||||
LocationCode = line.LocationCode?.Trim(),
|
||||
Qty = line.Qty,
|
||||
ReceivedQty = 0,
|
||||
LineStatus = OrderLineStatus.Open,
|
||||
Unit = line.Unit.Trim(),
|
||||
Attrs = line.Attrs
|
||||
});
|
||||
await InsertOutboundLineAsync(order, request.Lines[i], i + 1);
|
||||
}
|
||||
|
||||
return MapOrder(order, order.OrderNo, order.BizType, order.OrderStatus, order.Remark, order.Attrs);
|
||||
});
|
||||
}
|
||||
|
||||
public async Task<OrderViewDto> CreateHeaderAsync(OrderHeaderCreateRequest request)
|
||||
{
|
||||
return await _tx.ExecuteAsync(async () =>
|
||||
{
|
||||
var order = await CreateHeaderCoreAsync(
|
||||
_userContext.TenantId.Trim(),
|
||||
_userContext.OwnerCode.Trim(),
|
||||
request);
|
||||
return MapOrder(order, order.OrderNo, order.BizType, order.OrderStatus, order.Remark, order.Attrs);
|
||||
});
|
||||
}
|
||||
|
||||
public async Task<InventoryOrderLineViewDto?> AddLineAsync(OutboundOrderAddLineRequest request)
|
||||
{
|
||||
var order = await _orderRepository.GetByIdAsync(
|
||||
request.OrderId,
|
||||
_userContext.TenantId.Trim(),
|
||||
_userContext.OwnerCode.Trim());
|
||||
if (order is null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return await _tx.ExecuteAsync(async () =>
|
||||
{
|
||||
EnsureDraft(order.OrderStatus);
|
||||
var lines = await _lineRepository.GetByOrderIdAsync(order.Id);
|
||||
var line = await InsertOutboundLineAsync(order, request.Line, lines.Count + 1);
|
||||
return MapInventoryLine(line);
|
||||
});
|
||||
}
|
||||
|
||||
public async Task<OrderViewDto?> PendingAsync(OrderActionRequest request)
|
||||
{
|
||||
var order = await _orderRepository.GetByIdAsync(request.Id, _userContext.TenantId.Trim(), _userContext.OwnerCode.Trim());
|
||||
@ -703,6 +743,11 @@ public class OutboundOrderService : OrderServiceBase, IOutboundOrderService
|
||||
{
|
||||
EnsureDraft(order.OrderStatus);
|
||||
var lines = await _lineRepository.GetByOrderIdAsync(order.Id);
|
||||
if (lines.Count == 0)
|
||||
{
|
||||
throw new BusinessException("Outbound order must have at least one line before picking.");
|
||||
}
|
||||
|
||||
foreach (var line in lines)
|
||||
{
|
||||
var existingTasks = await _pickTaskRepository.GetByOrderLineIdAsync(line.Id);
|
||||
@ -796,17 +841,14 @@ public class OutboundOrderService : OrderServiceBase, IOutboundOrderService
|
||||
|
||||
foreach (var task in tasks)
|
||||
{
|
||||
if (task.TaskStatus != PickTaskStatus.Open)
|
||||
if (task.TaskStatus != PickTaskStatus.Picked)
|
||||
{
|
||||
throw new BusinessException("Only open pick tasks can be confirmed.");
|
||||
throw new BusinessException("All outbound pick tasks must be picked before outbound confirmation.");
|
||||
}
|
||||
|
||||
var inventory = await InventoryRepository.GetByIdAsync(task.InventoryId, order.TenantId, order.OwnerCode)
|
||||
?? throw new BusinessException("Allocated inventory not found.");
|
||||
await InventoryMovementService.ConfirmOutboundAsync(inventory, task.Qty, order.OrderNo);
|
||||
task.PickedQty = task.Qty;
|
||||
task.TaskStatus = PickTaskStatus.Picked;
|
||||
await _pickTaskRepository.UpdateAsync(task);
|
||||
}
|
||||
|
||||
var lines = await _lineRepository.GetByOrderIdAsync(order.Id);
|
||||
@ -822,6 +864,102 @@ public class OutboundOrderService : OrderServiceBase, IOutboundOrderService
|
||||
});
|
||||
}
|
||||
|
||||
public async Task<OutboundPickTaskViewDto?> ConfirmPickTaskAsync(PickTaskActionRequest request)
|
||||
{
|
||||
var task = await _pickTaskRepository.GetByIdAsync(
|
||||
request.Id,
|
||||
_userContext.TenantId.Trim(),
|
||||
_userContext.OwnerCode.Trim());
|
||||
if (task is null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return await _tx.ExecuteAsync(async () =>
|
||||
{
|
||||
if (task.TaskStatus != PickTaskStatus.Open)
|
||||
{
|
||||
throw new BusinessException("Only open pick tasks can be picked.");
|
||||
}
|
||||
|
||||
var order = await _orderRepository.GetByIdAsync(task.OrderId, task.TenantId, task.OwnerCode)
|
||||
?? throw new BusinessException("Outbound order not found.");
|
||||
EnsurePending(order.OrderStatus);
|
||||
|
||||
var pickedQty = request.PickedQty ?? task.Qty;
|
||||
if (pickedQty != task.Qty)
|
||||
{
|
||||
throw new BusinessException("Short picking is not supported yet. Please pick the full task quantity.");
|
||||
}
|
||||
|
||||
task.PickedQty = pickedQty;
|
||||
task.PickerUserId = _userContext.UserId;
|
||||
task.PickedTime = DateTime.Now;
|
||||
task.ExceptionReason = string.IsNullOrWhiteSpace(request.ExceptionReason)
|
||||
? null
|
||||
: request.ExceptionReason.Trim();
|
||||
task.TaskStatus = PickTaskStatus.Picked;
|
||||
await _pickTaskRepository.UpdateAsync(task);
|
||||
|
||||
return MapPickTask(task);
|
||||
});
|
||||
}
|
||||
|
||||
public async Task<OrderViewDto?> CancelAsync(OrderActionRequest request)
|
||||
{
|
||||
var order = await _orderRepository.GetByIdAsync(request.Id, _userContext.TenantId.Trim(), _userContext.OwnerCode.Trim());
|
||||
if (order is null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return await _tx.ExecuteAsync(async () =>
|
||||
{
|
||||
if (order.OrderStatus == OrderStatus.Completed)
|
||||
{
|
||||
throw new BusinessException("Completed outbound orders cannot be cancelled.");
|
||||
}
|
||||
|
||||
if (order.OrderStatus == OrderStatus.Cancelled)
|
||||
{
|
||||
return MapOrder(order, order.OrderNo, order.BizType, order.OrderStatus, order.Remark, order.Attrs);
|
||||
}
|
||||
|
||||
var tasks = await _pickTaskRepository.GetByOrderIdAsync(order.Id);
|
||||
foreach (var task in tasks)
|
||||
{
|
||||
if (task.TaskStatus == PickTaskStatus.Cancelled)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
var inventory = await InventoryRepository.GetByIdAsync(task.InventoryId, order.TenantId, order.OwnerCode)
|
||||
?? throw new BusinessException("Allocated inventory not found.");
|
||||
await InventoryMovementService.ReleasePendingOutboundAsync(
|
||||
inventory,
|
||||
task.Qty,
|
||||
order.OrderNo,
|
||||
"Outbound order cancelled.");
|
||||
|
||||
task.TaskStatus = PickTaskStatus.Cancelled;
|
||||
task.ExceptionReason = "Outbound order cancelled.";
|
||||
await _pickTaskRepository.UpdateAsync(task);
|
||||
}
|
||||
|
||||
var lines = await _lineRepository.GetByOrderIdAsync(order.Id);
|
||||
foreach (var line in lines)
|
||||
{
|
||||
line.LineStatus = OrderLineStatus.Open;
|
||||
line.ReceivedQty = 0;
|
||||
await _lineRepository.UpdateAsync(line);
|
||||
}
|
||||
|
||||
order.OrderStatus = OrderStatus.Cancelled;
|
||||
await _orderRepository.UpdateAsync(order);
|
||||
return MapOrder(order, order.OrderNo, order.BizType, order.OrderStatus, order.Remark, order.Attrs);
|
||||
});
|
||||
}
|
||||
|
||||
private static OutboundPickTaskViewDto MapPickTask(OutboundPickTask task)
|
||||
{
|
||||
return new OutboundPickTaskViewDto
|
||||
@ -840,11 +978,106 @@ public class OutboundOrderService : OrderServiceBase, IOutboundOrderService
|
||||
LocationCode = task.LocationCode,
|
||||
Qty = task.Qty,
|
||||
PickedQty = task.PickedQty,
|
||||
PickerUserId = task.PickerUserId,
|
||||
PickedTime = task.PickedTime,
|
||||
ExceptionReason = task.ExceptionReason,
|
||||
Unit = task.Unit,
|
||||
TaskStatus = task.TaskStatus,
|
||||
Attrs = task.Attrs
|
||||
};
|
||||
}
|
||||
|
||||
private async Task<OutboundOrder> CreateHeaderCoreAsync(string tenantId, string ownerCode, OrderSaveRequestBase request)
|
||||
{
|
||||
var orderNo = string.IsNullOrWhiteSpace(request.OrderNo)
|
||||
? await _orderNumberGenerator.NextOutboundOrderNoAsync(tenantId, ownerCode)
|
||||
: request.OrderNo.Trim();
|
||||
|
||||
if (await _orderRepository.GetByOrderNoAsync(tenantId, ownerCode, orderNo) is not null)
|
||||
{
|
||||
throw new BusinessException($"Outbound order '{orderNo}' already exists.");
|
||||
}
|
||||
|
||||
var order = new OutboundOrder
|
||||
{
|
||||
TenantId = tenantId,
|
||||
OwnerCode = ownerCode,
|
||||
OrderNo = orderNo,
|
||||
BizType = request.BizType?.Trim(),
|
||||
Remark = request.Remark?.Trim(),
|
||||
Attrs = request.Attrs,
|
||||
OrderStatus = OrderStatus.Draft
|
||||
};
|
||||
await _orderRepository.InsertAsync(order);
|
||||
return order;
|
||||
}
|
||||
|
||||
private async Task<OutboundOrderLine> InsertOutboundLineAsync(OutboundOrder order, OutboundOrderLineRequest line, int lineNo)
|
||||
{
|
||||
var unit = await ResolveOutboundLineUnitAsync(order.TenantId, order.OwnerCode, line);
|
||||
var entity = new OutboundOrderLine
|
||||
{
|
||||
TenantId = order.TenantId,
|
||||
OwnerCode = order.OwnerCode,
|
||||
OrderId = order.Id,
|
||||
LineNo = lineNo,
|
||||
InventoryKind = line.InventoryKind,
|
||||
MaterialCode = line.InventoryKind == InventoryKind.Material ? line.MaterialCode?.Trim() : null,
|
||||
ContainerCode = line.InventoryKind == InventoryKind.EmptyContainer ? line.ContainerCode?.Trim() : null,
|
||||
WarehouseCode = line.WarehouseCode.Trim(),
|
||||
AreaCode = line.AreaCode.Trim(),
|
||||
LocationCode = line.LocationCode?.Trim(),
|
||||
Qty = line.Qty,
|
||||
ReceivedQty = 0,
|
||||
LineStatus = OrderLineStatus.Open,
|
||||
Unit = unit,
|
||||
Attrs = line.Attrs
|
||||
};
|
||||
await _lineRepository.InsertAsync(entity);
|
||||
return entity;
|
||||
}
|
||||
|
||||
private async Task<string> ResolveOutboundLineUnitAsync(string tenantId, string ownerCode, OutboundOrderLineRequest line)
|
||||
{
|
||||
switch (line.InventoryKind)
|
||||
{
|
||||
case InventoryKind.Material:
|
||||
if (string.IsNullOrWhiteSpace(line.MaterialCode))
|
||||
{
|
||||
throw new BusinessException("MaterialCode is required for material lines.");
|
||||
}
|
||||
|
||||
var material = await _materialRepository.GetByCodeAsync(tenantId, ownerCode, line.MaterialCode.Trim())
|
||||
?? throw new BusinessException($"Material '{line.MaterialCode}' not found.");
|
||||
var masterUnit = material.Unit.Trim();
|
||||
if (string.IsNullOrWhiteSpace(masterUnit))
|
||||
{
|
||||
throw new BusinessException($"Material '{line.MaterialCode}' has no unit in master data.");
|
||||
}
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(line.Unit)
|
||||
&& !string.Equals(line.Unit.Trim(), masterUnit, StringComparison.Ordinal))
|
||||
{
|
||||
throw new BusinessException("Line unit does not match material master unit.");
|
||||
}
|
||||
|
||||
return masterUnit;
|
||||
case InventoryKind.EmptyContainer:
|
||||
if (string.IsNullOrWhiteSpace(line.ContainerCode))
|
||||
{
|
||||
throw new BusinessException("ContainerCode is required for empty container lines.");
|
||||
}
|
||||
|
||||
if (string.IsNullOrWhiteSpace(line.Unit))
|
||||
{
|
||||
throw new BusinessException("Unit is required for empty container lines.");
|
||||
}
|
||||
|
||||
return line.Unit.Trim();
|
||||
default:
|
||||
throw new BusinessException("Unsupported inventory kind.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class TransferOrderService : OrderServiceBase, ITransferOrderService
|
||||
|
||||
@ -1,8 +1,6 @@
|
||||
# WmsLite.Web
|
||||
|
||||
Umi Max 4 + Ant Design 5 + ProComponents 前端,对接 [WmsLite.Api](../WmsLite.Api/README.md)。
|
||||
|
||||
仓库总览见 [../README.md](../README.md)。
|
||||
Umi Max 4 + Ant Design 5 + ProComponents 前端,负责 WMS 主数据、库存、单据和作业工作台体验。后端见 [WmsLite.Api](../WmsLite.Api/README.md),仓库总览见 [../README.md](../README.md)。
|
||||
|
||||
## 技术栈
|
||||
|
||||
@ -10,44 +8,52 @@ Umi Max 4 + Ant Design 5 + ProComponents 前端,对接 [WmsLite.Api](../WmsLit
|
||||
- `@umijs/max` 4、Ant Design 5、ProComponents
|
||||
- `react-activation` 多标签 Keep-Alive
|
||||
|
||||
## 功能概览
|
||||
|
||||
### 路由
|
||||
## 路由与模块
|
||||
|
||||
| 路径 | 说明 |
|
||||
|------|------|
|
||||
| `/login` | 登录(无 Layout) |
|
||||
| `/home` | 主页(默认落地页) |
|
||||
| `/login` | 登录页,无业务 Layout |
|
||||
| `/home` | 作业工作台,展示单据与库存入口 |
|
||||
| `/base/*` | 仓库、库区、分区、库位、物料、容器 |
|
||||
| `/inventory/*` | 库存余额、库存流水 |
|
||||
| `/orders/*` | 入库、出库、移库、盘点 |
|
||||
| `/orders/*` | 入库单、出库单、移库单、盘点单 |
|
||||
| `/templates` | 系统模板 |
|
||||
|
||||
路由与标签标题:`config/config.ts`、`src/constants/routeTabTitles.ts`。
|
||||
路由配置在 `config/config.ts`,标签标题映射在 `src/constants/routeTabTitles.ts`。
|
||||
|
||||
### 认证
|
||||
## 认证与请求
|
||||
|
||||
- 登录:`POST /api/Auth/login`,成功后写入 `localStorage`:
|
||||
- `wmslite-token` — JWT
|
||||
- `wmslite-user` — 用户摘要 JSON
|
||||
- 请求自动附加 `Authorization: Bearer <token>`(`app.tsx` 拦截器 + `services/api.ts`)。
|
||||
- **401**:清除本地登录态,提示后跳转 `/login?redirect=...`。
|
||||
- **不再**向 API 注入硬编码 `tenantId` / `ownerCode`;租户由服务端 JWT 解析。
|
||||
- 全局字典 `DictionaryProvider` **仅在已登录时**加载 `/api/SysDictionary/map`。
|
||||
- 登录接口:`POST /api/Auth/login`,成功后写入 `localStorage`:
|
||||
- `wmslite-token`:JWT
|
||||
- `wmslite-user`:用户摘要 JSON
|
||||
- `services/api.ts` 和 `app.tsx` 会自动携带 `Authorization: Bearer <token>`。
|
||||
- HTTP 401 会清除本地登录状态,并跳转到 `/login?redirect=...`。
|
||||
- 前端不再向业务接口传 `tenantId` / `ownerCode`,租户和货主由后端从 JWT 解析。
|
||||
- 全局字典由 `DictionaryProvider` 在已登录状态加载 `/api/SysDictionary/map`。
|
||||
|
||||
默认开发账号:`admin` / `admin123`(见后端迁移种子)。
|
||||
默认开发账号:`admin` / `admin123`。
|
||||
|
||||
### 布局与多标签
|
||||
## 布局与多标签
|
||||
|
||||
- Mix 布局:侧边菜单 + 顶栏标签(`LayoutHeaderTabs`)。
|
||||
- Keep-Alive 保留列表筛选与滚动(`LayoutKeepAliveOutlet`)。
|
||||
- 标签 key = `pathname + search`,最多 12 个;批量关闭见顶栏「标签页 ▼」。
|
||||
- 使用 ProLayout `mix` 布局:侧边菜单 + 顶部工作区标签。
|
||||
- 标签栏由 `LayoutHeaderTabs` 渲染,采用浅色轨道 + 胶囊标签样式,和顶部 Header 融为一个整体。
|
||||
- 首页标签固定显示 Home 图标,且不可关闭。
|
||||
- 标签 key 使用归一化后的 `pathname + search`:
|
||||
- `/` 会归一化为 `/home`,避免点击左上角图标后生成“页面”标签。
|
||||
- 最多打开 12 个标签;超过上限时优先关闭最早的非首页标签。
|
||||
- 右侧更多按钮提供:关闭当前、关闭其他、关闭全部。
|
||||
- 关闭全部或关闭最后一个业务标签后,保留并跳转到 `/home`。
|
||||
- 页面内容由 `LayoutKeepAliveOutlet` 包裹,尽量保留列表筛选、表单状态和滚动位置。
|
||||
|
||||
### 通用组件
|
||||
## 主要页面体验
|
||||
|
||||
- `CrudPage` — 主数据 CRUD + 分页
|
||||
- `OrderPage` — 四类单据列表与操作
|
||||
- 类型定义:`src/types/`(`inventory.ts`、`orders.ts`、`masterData.ts`)
|
||||
- `Home`:作业工作台,展示入库、出库、移库、盘点统计卡片、作业优先级和常用入口。
|
||||
- `OrderPage`:四类单据统一页面。
|
||||
- 入库、出库支持先创建 Draft 单头,再在详情抽屉中追加明细。
|
||||
- 出库物料明细无需填写单位,由物料主数据单位自动带出。
|
||||
- 出库详情展示拣货任务,支持单任务确认拣货后再确认出库。
|
||||
- 单据状态使用颜色标签,详情抽屉顶部展示单据概要。
|
||||
- `CrudPage`:主数据通用 CRUD 页面。
|
||||
|
||||
## 本地开发
|
||||
|
||||
@ -58,9 +64,9 @@ cd ../WmsLite.Api
|
||||
dotnet run --launch-profile http
|
||||
```
|
||||
|
||||
后端默认 **http://localhost:9901**。
|
||||
后端默认地址:`http://localhost:9901`。
|
||||
|
||||
### 2. 安装依赖并启动前端
|
||||
### 2. 启动前端
|
||||
|
||||
```powershell
|
||||
cd WmsLite.Web
|
||||
@ -68,26 +74,28 @@ pnpm install
|
||||
pnpm run dev
|
||||
```
|
||||
|
||||
前端默认 **http://localhost:8000**,`/api` 代理至 `9901`(见 `config/config.ts`)。
|
||||
前端通常监听 `http://localhost:8000` 或 Umi 自动分配的下一个可用端口;`/api` 会代理到 `http://localhost:9901`。
|
||||
|
||||
### 3. 质量检查
|
||||
|
||||
```powershell
|
||||
pnpm run lint # ESLint + Stylelint(max lint)
|
||||
pnpm run typecheck # tsc --noEmit
|
||||
pnpm run build # 生产构建
|
||||
pnpm run typecheck
|
||||
pnpm run build
|
||||
pnpm run lint
|
||||
```
|
||||
|
||||
当前项目约定不新增自动化测试任务,阶段验收以 `typecheck`、`build`、`lint` 和人工业务场景为主。
|
||||
|
||||
## 目录结构
|
||||
|
||||
```
|
||||
```text
|
||||
WmsLite.Web/
|
||||
├── config/config.ts # Umi 配置、路由、代理
|
||||
├── src/
|
||||
│ ├── app.tsx # 布局、request、getInitialState、退出登录
|
||||
│ ├── app.tsx # 布局、request、initialState、退出登录
|
||||
│ ├── services/api.ts # HTTP 封装、401 处理、业务 API
|
||||
│ ├── utils/auth.ts # Token / 用户本地存储
|
||||
│ ├── contexts/ # 字典、多标签
|
||||
│ ├── contexts/ # 字典、多标签状态
|
||||
│ ├── components/ # CrudPage、OrderPage、Layout*
|
||||
│ ├── pages/ # 业务页面
|
||||
│ └── types/ # 前端 DTO 类型
|
||||
@ -95,15 +103,20 @@ WmsLite.Web/
|
||||
└── .stylelintrc.js
|
||||
```
|
||||
|
||||
## 错误处理说明
|
||||
## 关键源码
|
||||
|
||||
| 场景 | 行为 |
|
||||
| 主题 | 文件 |
|
||||
|------|------|
|
||||
| HTTP 401 | 清 token,已登录时提示「登录已失效」,跳转登录页 |
|
||||
| `success: false` 业务错误 | Toast 展示 `message`,抛 `BusinessResultError` 避免重复弹窗 |
|
||||
| 网络 / 5xx | 全局 `errorHandler` Toast |
|
||||
| 运行时布局与请求拦截 | `src/app.tsx` |
|
||||
| 标签状态与关闭逻辑 | `src/contexts/TabLayoutContext.tsx` |
|
||||
| 顶部标签栏 UI | `src/components/LayoutHeaderTabs.tsx` |
|
||||
| Keep-Alive 内容容器 | `src/components/LayoutKeepAliveOutlet.tsx` |
|
||||
| 单据页面 | `src/components/OrderPage.tsx` |
|
||||
| HTTP 封装 | `src/services/api.ts` |
|
||||
| 全局视觉样式 | `src/global.less` |
|
||||
|
||||
## 说明
|
||||
## 注意事项
|
||||
|
||||
- 超长整型 ID:响应 JSON 经 `jsonSnowflakeParse` 处理,避免 JS 精度丢失。
|
||||
- 若 API 未启动,代理会报 `ECONNREFUSED`,请先启动 `WmsLite.Api`。
|
||||
- 若 API 未启动,前端代理会报 `ECONNREFUSED`,请先启动 `WmsLite.Api`。
|
||||
- 同一路径如需打开多个实例,需要通过 query 增加实例标识,否则会复用同一个标签 key。
|
||||
- `react-activation` 对深层弹窗或 Portal 场景可能存在边界问题;若单页异常,可针对该路由调整缓存策略。
|
||||
|
||||
@ -1,11 +1,14 @@
|
||||
import { DownOutlined } from '@ant-design/icons';
|
||||
import { Button, Dropdown, Tabs } from 'antd';
|
||||
import { HomeOutlined, MoreOutlined } from '@ant-design/icons';
|
||||
import { Button, Dropdown, Tabs, Tooltip } from 'antd';
|
||||
import type { MenuProps } from 'antd';
|
||||
import React, { useMemo } from 'react';
|
||||
|
||||
import { useTabLayout } from '@/contexts/TabLayoutContext';
|
||||
|
||||
/** 挂载在 ProLayout header(ant-layout-header)内 */
|
||||
function isHomeTab(key: string) {
|
||||
return key.split('?')[0] === '/home';
|
||||
}
|
||||
|
||||
export default function LayoutHeaderTabs() {
|
||||
const {
|
||||
activeKey,
|
||||
@ -18,14 +21,29 @@ export default function LayoutHeaderTabs() {
|
||||
closeAllTabs,
|
||||
} = useTabLayout();
|
||||
|
||||
const displayItems = useMemo(
|
||||
() =>
|
||||
tabItems.map((item) => ({
|
||||
...item,
|
||||
label: (
|
||||
<span className="layout-header-tab-label" title={String(item.label)}>
|
||||
{isHomeTab(item.key) && <HomeOutlined className="layout-header-tab-home-icon" />}
|
||||
<span className="layout-header-tab-text">{item.label}</span>
|
||||
</span>
|
||||
),
|
||||
})),
|
||||
[tabItems],
|
||||
);
|
||||
|
||||
const bulkMenuItems: MenuProps['items'] = useMemo(() => {
|
||||
const hasTabs = tabs.length > 0;
|
||||
const multi = tabs.length > 1;
|
||||
const activeIsHome = isHomeTab(activeKey);
|
||||
return [
|
||||
{
|
||||
key: 'close-current',
|
||||
label: '关闭当前',
|
||||
disabled: !hasTabs,
|
||||
disabled: !hasTabs || activeIsHome,
|
||||
},
|
||||
{
|
||||
key: 'close-others',
|
||||
@ -40,7 +58,7 @@ export default function LayoutHeaderTabs() {
|
||||
danger: true,
|
||||
},
|
||||
];
|
||||
}, [tabs.length]);
|
||||
}, [activeKey, tabs.length]);
|
||||
|
||||
const bulkMenuProps: MenuProps = useMemo(
|
||||
() => ({
|
||||
@ -62,36 +80,35 @@ export default function LayoutHeaderTabs() {
|
||||
[bulkMenuItems, closeAllTabs, closeCurrentTab, closeOtherTabs],
|
||||
);
|
||||
|
||||
if (!tabItems.length) {
|
||||
if (!displayItems.length) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="layout-header-tabs-wrap" style={{ flex: 1, minWidth: 0, marginInline: 16 }}>
|
||||
<div className="layout-header-tabs-wrap">
|
||||
<Tabs
|
||||
type="editable-card"
|
||||
hideAdd
|
||||
size="small"
|
||||
activeKey={activeKey}
|
||||
items={tabItems}
|
||||
items={displayItems}
|
||||
onChange={onTabsChange}
|
||||
onEdit={onTabsEdit}
|
||||
tabBarExtraContent={{
|
||||
right: (
|
||||
<Dropdown menu={bulkMenuProps} trigger={['click']}>
|
||||
<Button type="text" size="small" aria-label="标签页批量操作">
|
||||
标签页 <DownOutlined />
|
||||
</Button>
|
||||
</Dropdown>
|
||||
<Tooltip title="标签操作">
|
||||
<Dropdown menu={bulkMenuProps} trigger={['click']}>
|
||||
<Button
|
||||
type="text"
|
||||
size="small"
|
||||
icon={<MoreOutlined />}
|
||||
className="layout-header-tabs-more"
|
||||
aria-label="标签操作"
|
||||
/>
|
||||
</Dropdown>
|
||||
</Tooltip>
|
||||
),
|
||||
}}
|
||||
tabBarStyle={{
|
||||
margin: 0,
|
||||
height: '100%',
|
||||
minHeight: 40,
|
||||
borderBottom: 'none',
|
||||
background: 'transparent',
|
||||
}}
|
||||
className="layout-header-tabs"
|
||||
/>
|
||||
</div>
|
||||
|
||||
@ -9,12 +9,15 @@ import {
|
||||
ProTable,
|
||||
} from '@ant-design/pro-components';
|
||||
import type { ColumnsType } from 'antd/es/table';
|
||||
import { Button, Drawer, Form, Input, InputNumber, message, Modal, Select, Space, Table, Typography } from 'antd';
|
||||
import { Button, Drawer, Form, Input, InputNumber, message, Modal, Popconfirm, Select, Space, Table, Tag, Typography } from 'antd';
|
||||
import type { FormListFieldData } from 'antd/es/form/FormList';
|
||||
import { EyeOutlined, PlusOutlined, ReloadOutlined } from '@ant-design/icons';
|
||||
import { CheckOutlined, EyeOutlined, PlusOutlined, ReloadOutlined } from '@ant-design/icons';
|
||||
import {
|
||||
actionRecord,
|
||||
addOrderLine,
|
||||
confirmOutboundPickTask,
|
||||
confirmInboundLine,
|
||||
createOrderHeader,
|
||||
createRecord,
|
||||
getOutboundPickTasks,
|
||||
getRecordLines,
|
||||
@ -49,6 +52,7 @@ const ORDER_ACTIONS: Record<OrderKind, OrderActionDef[]> = {
|
||||
outbound: [
|
||||
{ label: '待拣', backendAction: 'pending' },
|
||||
{ label: '确认出库', backendAction: 'confirm' },
|
||||
{ label: '取消', backendAction: 'cancel' },
|
||||
],
|
||||
transfer: [
|
||||
{ label: '待处理', backendAction: 'pending' },
|
||||
@ -137,7 +141,6 @@ function createEmptyLine(kind: OrderKind): Record<string, any> {
|
||||
areaCode: '',
|
||||
locationCode: '',
|
||||
qty: 0,
|
||||
unit: 'pcs',
|
||||
};
|
||||
case 'transfer':
|
||||
return {
|
||||
@ -181,6 +184,9 @@ function normalizeLinesForSubmit(lines: Record<string, any>[]) {
|
||||
if ('locationCode' in next && !String(next.locationCode ?? '').trim()) {
|
||||
delete next.locationCode;
|
||||
}
|
||||
if ('unit' in next && !String(next.unit ?? '').trim()) {
|
||||
delete next.unit;
|
||||
}
|
||||
if ('qty' in next) next.qty = Number(next.qty);
|
||||
if ('countedQty' in next && next.countedQty !== undefined && next.countedQty !== '')
|
||||
next.countedQty = Number(next.countedQty);
|
||||
@ -573,14 +579,12 @@ function outboundLinesEditorColumns(
|
||||
remove: (index: number | number[]) => void,
|
||||
): ColumnsType<FormListFieldData> {
|
||||
const qtyDef: LineFieldDef = { key: 'qty', title: '数量', width: 88, type: 'number', required: true };
|
||||
const unitDef: LineFieldDef = { key: 'unit', title: '单位', width: 72, type: 'text', required: true };
|
||||
return [
|
||||
{ title: '物料', key: 'materialCode', width: 220, render: (_u, rowField) => <OutboundMaterialCell rowKey={rowField.name} /> },
|
||||
{ title: '仓库', key: 'warehouseCode', width: 180, render: (_u, rowField) => <OutboundWarehouseCell rowKey={rowField.name} /> },
|
||||
{ title: '库区', key: 'areaCode', width: 170, render: (_u, rowField) => <OutboundAreaCell rowKey={rowField.name} /> },
|
||||
{ title: '指定库位', key: 'locationCode', width: 180, render: (_u, rowField) => <OutboundLocationCell rowKey={rowField.name} /> },
|
||||
{ title: '数量', key: 'qty', width: 100, render: (_u, rowField) => renderLineCell(rowField, qtyDef) },
|
||||
{ title: '单位', key: 'unit', width: 90, render: (_u, rowField) => renderLineCell(rowField, unitDef) },
|
||||
{
|
||||
title: '操作',
|
||||
key: '_op',
|
||||
@ -638,6 +642,42 @@ function lineIsFullyReceived(row: Record<string, any>) {
|
||||
return s === 'completed' || s === 'Completed' || s === 2;
|
||||
}
|
||||
|
||||
function orderIsDraft(row?: Record<string, any> | null) {
|
||||
const s = row?.orderStatus;
|
||||
return s === 'draft' || s === 'Draft' || s === 1;
|
||||
}
|
||||
|
||||
function normalizeStatusKey(value: unknown) {
|
||||
if (value === 1) return 'draft';
|
||||
if (value === 2) return 'pending';
|
||||
if (value === 3) return 'completed';
|
||||
if (value === 4) return 'cancelled';
|
||||
return String(value ?? '').trim().toLowerCase();
|
||||
}
|
||||
|
||||
function orderStatusColor(value: unknown) {
|
||||
const key = normalizeStatusKey(value);
|
||||
if (key === 'draft') return 'default';
|
||||
if (key === 'pending') return 'processing';
|
||||
if (key === 'completed') return 'success';
|
||||
if (key === 'cancelled' || key === 'canceled') return 'error';
|
||||
return 'default';
|
||||
}
|
||||
|
||||
function orderStatusFallback(value: unknown) {
|
||||
const key = normalizeStatusKey(value);
|
||||
if (key === 'draft') return '草稿';
|
||||
if (key === 'pending') return '待处理';
|
||||
if (key === 'completed') return '已完成';
|
||||
if (key === 'cancelled' || key === 'canceled') return '已取消';
|
||||
return String(value ?? '-');
|
||||
}
|
||||
|
||||
function renderOrderStatusTag(value: unknown, label?: React.ReactNode) {
|
||||
const text = label && String(label).trim() ? label : orderStatusFallback(value);
|
||||
return <Tag color={orderStatusColor(value)}>{text}</Tag>;
|
||||
}
|
||||
|
||||
function viewerColumnsForKind(kind: OrderKind): ProColumns<Record<string, any>>[] {
|
||||
if (kind === 'inbound') {
|
||||
const defs = INBOUND_LINE_FIELDS.filter((d) => d.key !== 'attrsJson');
|
||||
@ -756,8 +796,10 @@ export default function OrderPage({ title, controller, kind }: OrderPageProps) {
|
||||
const actionRef = useRef<ActionType>();
|
||||
const viewerOrderIdRef = useRef<string | number | null>(null);
|
||||
const [createOpen, setCreateOpen] = useState(false);
|
||||
const [addLineOpen, setAddLineOpen] = useState(false);
|
||||
const [viewerOpen, setViewerOpen] = useState(false);
|
||||
const [viewerLoading, setViewerLoading] = useState(false);
|
||||
const [viewerRecord, setViewerRecord] = useState<Record<string, any> | null>(null);
|
||||
const [viewerLines, setViewerLines] = useState<Record<string, any>[]>([]);
|
||||
const [viewerPickTasks, setViewerPickTasks] = useState<Record<string, any>[]>([]);
|
||||
const [viewerTitle, setViewerTitle] = useState('');
|
||||
@ -767,6 +809,7 @@ export default function OrderPage({ title, controller, kind }: OrderPageProps) {
|
||||
const [locationOptions, setLocationOptions] = useState<{ label: string; value: string }[]>([]);
|
||||
const [confirmForm] = Form.useForm();
|
||||
const [createForm] = Form.useForm();
|
||||
const [addLineForm] = Form.useForm();
|
||||
|
||||
const fetchConfirmContainerPage = useCallback(async (keyword: string) => {
|
||||
const res = await pagedList<Record<string, any>>('Container', {
|
||||
@ -813,9 +856,20 @@ export default function OrderPage({ title, controller, kind }: OrderPageProps) {
|
||||
const headerColumns = useMemo(
|
||||
() =>
|
||||
headerColumnsBase.map((col): ProColumns<OrderRow> => {
|
||||
if (col.dataIndex === 'orderNo') {
|
||||
return {
|
||||
...col,
|
||||
render: (_, row) => <span className="wms-order-no">{row.orderNo || '-'}</span>,
|
||||
};
|
||||
}
|
||||
if (col.dataIndex === 'orderStatus') {
|
||||
const valueEnum = buildValueEnum('OrderStatus');
|
||||
return Object.keys(valueEnum).length ? { ...col, valueEnum } : col;
|
||||
return {
|
||||
...col,
|
||||
...(Object.keys(valueEnum).length ? { valueEnum } : {}),
|
||||
render: (_, row) =>
|
||||
renderOrderStatusTag(row.orderStatus, resolveLabel('OrderStatus', row.orderStatus)),
|
||||
};
|
||||
}
|
||||
if (col.dataIndex === 'bizType') {
|
||||
const valueEnum = buildValueEnum(bizTypeDictCategory);
|
||||
@ -823,7 +877,7 @@ export default function OrderPage({ title, controller, kind }: OrderPageProps) {
|
||||
}
|
||||
return col;
|
||||
}),
|
||||
[buildValueEnum, bizTypeDictCategory],
|
||||
[buildValueEnum, bizTypeDictCategory, resolveLabel],
|
||||
);
|
||||
|
||||
const refreshViewerLines = useCallback(async () => {
|
||||
@ -841,6 +895,20 @@ export default function OrderPage({ title, controller, kind }: OrderPageProps) {
|
||||
}
|
||||
}, [controller, kind]);
|
||||
|
||||
const confirmPickTask = useCallback(
|
||||
async (task: Record<string, any>) => {
|
||||
if (!task.id) return;
|
||||
await confirmOutboundPickTask({
|
||||
id: task.id,
|
||||
pickedQty: Number(task.qty),
|
||||
});
|
||||
message.success('拣货已确认');
|
||||
await refreshViewerLines();
|
||||
actionRef.current?.reload();
|
||||
},
|
||||
[refreshViewerLines],
|
||||
);
|
||||
|
||||
const openConfirmInbound = useCallback(
|
||||
async (line: Record<string, any>) => {
|
||||
setConfirmLine(line);
|
||||
@ -877,6 +945,7 @@ export default function OrderPage({ title, controller, kind }: OrderPageProps) {
|
||||
const openViewer = useCallback(
|
||||
async (record: Record<string, any>) => {
|
||||
viewerOrderIdRef.current = record.id;
|
||||
setViewerRecord(record);
|
||||
setViewerTitle(`${record.orderNo || record.id}`);
|
||||
setViewerOpen(true);
|
||||
setViewerLoading(true);
|
||||
@ -946,6 +1015,15 @@ export default function OrderPage({ title, controller, kind }: OrderPageProps) {
|
||||
{ title: '应拣', dataIndex: 'qty', width: 88 },
|
||||
{ title: '已拣', dataIndex: 'pickedQty', width: 88 },
|
||||
{ title: '单位', dataIndex: 'unit', width: 72 },
|
||||
{ title: '拣货人', dataIndex: 'pickerUserId', width: 120, ellipsis: true },
|
||||
{
|
||||
title: '拣货时间',
|
||||
dataIndex: 'pickedTime',
|
||||
width: 168,
|
||||
ellipsis: true,
|
||||
render: (_, row) => row.pickedTime || '-',
|
||||
},
|
||||
{ title: '异常原因', dataIndex: 'exceptionReason', width: 160, ellipsis: true },
|
||||
{
|
||||
title: '状态',
|
||||
dataIndex: 'taskStatus',
|
||||
@ -957,8 +1035,31 @@ export default function OrderPage({ title, controller, kind }: OrderPageProps) {
|
||||
return '待拣';
|
||||
},
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
key: 'pickAction',
|
||||
width: 110,
|
||||
fixed: 'right',
|
||||
render: (_, row) => {
|
||||
const s = row.taskStatus;
|
||||
const isOpen = s === 'open' || s === 'Open' || s === 1;
|
||||
if (!isOpen) return '-';
|
||||
return (
|
||||
<Popconfirm
|
||||
title="确认该拣货任务已完成?"
|
||||
okText="确认"
|
||||
cancelText="取消"
|
||||
onConfirm={() => confirmPickTask(row)}
|
||||
>
|
||||
<Button type="link" size="small" icon={<CheckOutlined />}>
|
||||
确认拣货
|
||||
</Button>
|
||||
</Popconfirm>
|
||||
);
|
||||
},
|
||||
},
|
||||
],
|
||||
[],
|
||||
[confirmPickTask],
|
||||
);
|
||||
|
||||
const createInitialValues = useMemo(
|
||||
@ -969,6 +1070,13 @@ export default function OrderPage({ title, controller, kind }: OrderPageProps) {
|
||||
[kind],
|
||||
);
|
||||
|
||||
const addLineInitialValues = useMemo(
|
||||
() => ({ lines: [createEmptyLine(kind)] }),
|
||||
[kind],
|
||||
);
|
||||
|
||||
const canMaintainLines = kind === 'inbound' || kind === 'outbound';
|
||||
|
||||
const createModalWidth = kind === 'inbound' || kind === 'outbound' ? 1180 : 1040;
|
||||
|
||||
return (
|
||||
@ -982,7 +1090,7 @@ export default function OrderPage({ title, controller, kind }: OrderPageProps) {
|
||||
{
|
||||
title: '操作',
|
||||
valueType: 'option',
|
||||
width: kind === 'inbound' ? 140 : 220,
|
||||
width: kind === 'inbound' ? 140 : kind === 'outbound' ? 280 : 220,
|
||||
fixed: 'right',
|
||||
search: false,
|
||||
render: (_, record) => (
|
||||
@ -990,20 +1098,40 @@ export default function OrderPage({ title, controller, kind }: OrderPageProps) {
|
||||
<Button type="link" size="small" icon={<EyeOutlined />} onClick={() => openViewer(record)}>
|
||||
查看明细
|
||||
</Button>
|
||||
{actions.map((a, idx) => (
|
||||
<Button
|
||||
key={`${a.backendAction}-${idx}-${a.label}`}
|
||||
type="link"
|
||||
size="small"
|
||||
onClick={async () => {
|
||||
await actionRecord(controller, a.backendAction, record.id);
|
||||
message.success('操作成功');
|
||||
actionRef.current?.reload();
|
||||
}}
|
||||
>
|
||||
{a.label}
|
||||
</Button>
|
||||
))}
|
||||
{actions.map((a, idx) => {
|
||||
const button = (
|
||||
<Button
|
||||
key={`${a.backendAction}-${idx}-${a.label}`}
|
||||
type="link"
|
||||
size="small"
|
||||
onClick={async () => {
|
||||
await actionRecord(controller, a.backendAction, record.id);
|
||||
message.success('操作成功');
|
||||
actionRef.current?.reload();
|
||||
}}
|
||||
>
|
||||
{a.label}
|
||||
</Button>
|
||||
);
|
||||
if (a.backendAction !== 'cancel') return button;
|
||||
return (
|
||||
<Popconfirm
|
||||
key={`${a.backendAction}-${idx}-${a.label}`}
|
||||
title="取消出库单会释放已预占库存,确认继续?"
|
||||
okText="确认"
|
||||
cancelText="取消"
|
||||
onConfirm={async () => {
|
||||
await actionRecord(controller, a.backendAction, record.id);
|
||||
message.success('操作成功');
|
||||
actionRef.current?.reload();
|
||||
}}
|
||||
>
|
||||
<Button type="link" size="small">
|
||||
{a.label}
|
||||
</Button>
|
||||
</Popconfirm>
|
||||
);
|
||||
})}
|
||||
</Space>
|
||||
),
|
||||
},
|
||||
@ -1016,6 +1144,23 @@ export default function OrderPage({ title, controller, kind }: OrderPageProps) {
|
||||
<Button key="reload" icon={<ReloadOutlined />} onClick={() => actionRef.current?.reload()}>
|
||||
刷新
|
||||
</Button>,
|
||||
...(canMaintainLines
|
||||
? [
|
||||
<Button
|
||||
key="new-header"
|
||||
onClick={async () => {
|
||||
await createOrderHeader(controller, {
|
||||
bizType: `${kind}_default`,
|
||||
...(kind === 'outbound' ? { attrs: {} } : {}),
|
||||
});
|
||||
message.success('单头创建成功');
|
||||
actionRef.current?.reload();
|
||||
}}
|
||||
>
|
||||
新增单头
|
||||
</Button>,
|
||||
]
|
||||
: []),
|
||||
<Button key="new" type="primary" icon={<PlusOutlined />} onClick={() => setCreateOpen(true)}>
|
||||
新增
|
||||
</Button>,
|
||||
@ -1114,13 +1259,140 @@ export default function OrderPage({ title, controller, kind }: OrderPageProps) {
|
||||
</Form.Item>
|
||||
</ModalForm>
|
||||
|
||||
<ModalForm
|
||||
title={`新增${title}明细`}
|
||||
width={kind === 'inbound' || kind === 'outbound' ? 1180 : 1040}
|
||||
open={addLineOpen}
|
||||
initialValues={addLineInitialValues}
|
||||
key={`${kind}-add-line`}
|
||||
form={addLineForm}
|
||||
modalProps={{
|
||||
destroyOnHidden: true,
|
||||
onCancel: () => setAddLineOpen(false),
|
||||
}}
|
||||
onFinish={async (values) => {
|
||||
const orderId = viewerOrderIdRef.current;
|
||||
if (!orderId) {
|
||||
message.error('请先打开单据详情');
|
||||
return false;
|
||||
}
|
||||
|
||||
const lines = values.lines as Record<string, any>[];
|
||||
if (!lines?.length) {
|
||||
message.error('请至少添加一行明细');
|
||||
return false;
|
||||
}
|
||||
|
||||
const normalized = normalizeLinesForSubmit(lines);
|
||||
if (kind === 'inbound' && !validateInboundCreateLines(normalized)) return false;
|
||||
|
||||
for (const line of normalized) {
|
||||
await addOrderLine(controller, { orderId, line });
|
||||
}
|
||||
|
||||
message.success('明细添加成功');
|
||||
setAddLineOpen(false);
|
||||
await refreshViewerLines();
|
||||
actionRef.current?.reload();
|
||||
return true;
|
||||
}}
|
||||
>
|
||||
<Form.Item label="明细" required style={{ marginBottom: 0 }}>
|
||||
<Form.List name="lines">
|
||||
{(fields, { add, remove }) => (
|
||||
<>
|
||||
<Table<FormListFieldData>
|
||||
size="small"
|
||||
pagination={false}
|
||||
scroll={{ x: 'max-content' }}
|
||||
dataSource={fields}
|
||||
rowKey="key"
|
||||
columns={
|
||||
kind === 'inbound'
|
||||
? inboundLinesEditorColumns(fields, remove, inventoryKindInboundOpts)
|
||||
: (linesEditorColumns(kind, fields, remove) as ColumnsType<FormListFieldData>)
|
||||
}
|
||||
/>
|
||||
<Button
|
||||
type="dashed"
|
||||
block
|
||||
style={{ marginTop: 8 }}
|
||||
onClick={() => add(createEmptyLine(kind))}
|
||||
>
|
||||
新增明细行
|
||||
</Button>
|
||||
</>
|
||||
)}
|
||||
</Form.List>
|
||||
</Form.Item>
|
||||
</ModalForm>
|
||||
|
||||
<Drawer
|
||||
title={`单据明细 — ${viewerTitle}`}
|
||||
open={viewerOpen}
|
||||
width={kind === 'inbound' || kind === 'outbound' ? 1280 : 1040}
|
||||
destroyOnHidden
|
||||
onClose={() => setViewerOpen(false)}
|
||||
extra={
|
||||
canMaintainLines && orderIsDraft(viewerRecord) ? (
|
||||
<Button
|
||||
type="primary"
|
||||
size="small"
|
||||
icon={<PlusOutlined />}
|
||||
onClick={() => {
|
||||
addLineForm.resetFields();
|
||||
addLineForm.setFieldsValue(addLineInitialValues);
|
||||
setAddLineOpen(true);
|
||||
}}
|
||||
>
|
||||
新增明细
|
||||
</Button>
|
||||
) : null
|
||||
}
|
||||
onClose={() => {
|
||||
setViewerOpen(false);
|
||||
setViewerRecord(null);
|
||||
}}
|
||||
>
|
||||
<div className="wms-order-detail-head">
|
||||
<div className="wms-order-detail-title">
|
||||
<div>
|
||||
<div className="wms-order-detail-title-main">{viewerRecord?.orderNo || viewerTitle || '-'}</div>
|
||||
<Typography.Text type="secondary">{title}</Typography.Text>
|
||||
</div>
|
||||
{renderOrderStatusTag(
|
||||
viewerRecord?.orderStatus,
|
||||
resolveLabel('OrderStatus', viewerRecord?.orderStatus),
|
||||
)}
|
||||
</div>
|
||||
<div className="wms-order-detail-meta">
|
||||
<div>
|
||||
<div className="wms-order-detail-meta-label">业务类型</div>
|
||||
<div className="wms-order-detail-meta-value">
|
||||
{viewerRecord?.bizType
|
||||
? resolveLabel(bizTypeDictCategory, viewerRecord.bizType) || viewerRecord.bizType
|
||||
: '-'}
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<div className="wms-order-detail-meta-label">明细行数</div>
|
||||
<div className="wms-order-detail-meta-value">{viewerLines.length}</div>
|
||||
</div>
|
||||
{kind === 'outbound' && (
|
||||
<div>
|
||||
<div className="wms-order-detail-meta-label">拣货任务</div>
|
||||
<div className="wms-order-detail-meta-value">{viewerPickTasks.length}</div>
|
||||
</div>
|
||||
)}
|
||||
<div>
|
||||
<div className="wms-order-detail-meta-label">创建时间</div>
|
||||
<div className="wms-order-detail-meta-value">{viewerRecord?.createTime || '-'}</div>
|
||||
</div>
|
||||
<div>
|
||||
<div className="wms-order-detail-meta-label">备注</div>
|
||||
<div className="wms-order-detail-meta-value">{viewerRecord?.remark || '-'}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<ProTable<Record<string, any>>
|
||||
loading={viewerLoading}
|
||||
rowKey={(row, i) => String(row.id ?? row.lineNo ?? i)}
|
||||
@ -1133,9 +1405,7 @@ export default function OrderPage({ title, controller, kind }: OrderPageProps) {
|
||||
/>
|
||||
{kind === 'outbound' && (
|
||||
<>
|
||||
<Typography.Title level={5} style={{ marginTop: 16, marginBottom: 8 }}>
|
||||
拣货任务
|
||||
</Typography.Title>
|
||||
<div className="wms-section-title">拣货任务</div>
|
||||
<ProTable<Record<string, any>>
|
||||
loading={viewerLoading}
|
||||
rowKey={(row, i) => String(row.id ?? row.taskNo ?? i)}
|
||||
|
||||
@ -1,8 +1,9 @@
|
||||
/**
|
||||
* 多标签文案:与各业务叶子路由 pathname 对齐(参见 config/config.ts)。
|
||||
* Multi-tab labels aligned with business leaf routes in config/config.ts.
|
||||
*/
|
||||
export const ROUTE_TAB_TITLES: Record<string, string> = {
|
||||
'/home': '主页',
|
||||
'/': '首页',
|
||||
'/home': '首页',
|
||||
'/base/warehouse': '仓库',
|
||||
'/base/area': '库区',
|
||||
'/base/zone': '分区',
|
||||
@ -19,5 +20,12 @@ export const ROUTE_TAB_TITLES: Record<string, string> = {
|
||||
};
|
||||
|
||||
export function resolveRouteTabTitle(pathname: string): string {
|
||||
return ROUTE_TAB_TITLES[pathname] ?? pathname.split('/').filter(Boolean).pop() ?? '页面';
|
||||
const normalized = pathname === '/' ? '/home' : pathname;
|
||||
const known = ROUTE_TAB_TITLES[normalized];
|
||||
if (known) {
|
||||
return known;
|
||||
}
|
||||
|
||||
const lastSegment = normalized.split('/').filter(Boolean).pop();
|
||||
return lastSegment || '未知页面';
|
||||
}
|
||||
|
||||
@ -23,8 +23,26 @@ type ShellTabItem = {
|
||||
label: string;
|
||||
};
|
||||
|
||||
function normalizeRoutePath(pathname?: string) {
|
||||
const raw = pathname?.trim() || FALLBACK_ROUTE;
|
||||
if (raw === '/') {
|
||||
return FALLBACK_ROUTE;
|
||||
}
|
||||
return raw.length > 1 && raw.endsWith('/') ? raw.slice(0, -1) : raw;
|
||||
}
|
||||
|
||||
function normalizeTabKey(key: string) {
|
||||
const [pathname, search = ''] = key.split('?');
|
||||
const normalized = normalizeRoutePath(pathname);
|
||||
return search ? `${normalized}?${search}` : normalized;
|
||||
}
|
||||
|
||||
function isHomeTabKey(key: string) {
|
||||
return normalizeTabKey(key).split('?')[0] === FALLBACK_ROUTE;
|
||||
}
|
||||
|
||||
export function tabKey(location: { pathname: string; search?: string }) {
|
||||
return `${location.pathname}${location.search ?? ''}`;
|
||||
return `${normalizeRoutePath(location.pathname)}${location.search ?? ''}`;
|
||||
}
|
||||
|
||||
type TabLayoutContextValue = {
|
||||
@ -56,7 +74,7 @@ function initialTabs(location: { pathname: string; search?: string }): ShellTabI
|
||||
return [];
|
||||
}
|
||||
const key = tabKey(location);
|
||||
return [{ key, label: resolveRouteTabTitle(location.pathname) }];
|
||||
return [{ key, label: resolveRouteTabTitle(normalizeRoutePath(location.pathname)) }];
|
||||
}
|
||||
|
||||
function snapshotRoute(): { pathname: string; search: string } {
|
||||
@ -109,7 +127,7 @@ export function TabLayoutProvider(props: Readonly<{ children: React.ReactNode }>
|
||||
}
|
||||
|
||||
const key = tabKey(routeLoc);
|
||||
const label = resolveRouteTabTitle(routeLoc.pathname);
|
||||
const label = resolveRouteTabTitle(normalizeRoutePath(routeLoc.pathname));
|
||||
|
||||
setTabs((prev) => {
|
||||
const hit = prev.find((t) => t.key === key);
|
||||
@ -119,7 +137,7 @@ export function TabLayoutProvider(props: Readonly<{ children: React.ReactNode }>
|
||||
|
||||
let next = [...prev];
|
||||
if (next.length >= MAX_TABS) {
|
||||
const victim = next.find((t) => t.key !== key);
|
||||
const victim = next.find((t) => t.key !== key && !isHomeTabKey(t.key));
|
||||
if (!victim) {
|
||||
message.warning(`最多打开 ${MAX_TABS} 个标签`);
|
||||
return prev;
|
||||
@ -134,17 +152,23 @@ export function TabLayoutProvider(props: Readonly<{ children: React.ReactNode }>
|
||||
|
||||
const removeTabInternal = useCallback(
|
||||
(targetKey: string) => {
|
||||
dropTabCache(targetKey);
|
||||
const normalizedTargetKey = normalizeTabKey(targetKey);
|
||||
if (isHomeTabKey(normalizedTargetKey)) {
|
||||
history.push(FALLBACK_ROUTE);
|
||||
return;
|
||||
}
|
||||
|
||||
dropTabCache(normalizedTargetKey);
|
||||
|
||||
const currentFullKey = tabKey(routeLoc);
|
||||
const prev = tabsRef.current;
|
||||
const idx = prev.findIndex((t) => t.key === targetKey);
|
||||
const idx = prev.findIndex((t) => t.key === normalizedTargetKey);
|
||||
if (idx < 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
const nextTabs = prev.filter((t) => t.key !== targetKey);
|
||||
const wasActive = targetKey === currentFullKey;
|
||||
const nextTabs = prev.filter((t) => t.key !== normalizedTargetKey);
|
||||
const wasActive = normalizedTargetKey === currentFullKey;
|
||||
|
||||
if (nextTabs.length === 0) {
|
||||
const homeTab = { key: FALLBACK_ROUTE, label: resolveRouteTabTitle(FALLBACK_ROUTE) };
|
||||
@ -177,17 +201,21 @@ export function TabLayoutProvider(props: Readonly<{ children: React.ReactNode }>
|
||||
return;
|
||||
}
|
||||
|
||||
const keep = prev.find((t) => t.key === active);
|
||||
if (!keep) {
|
||||
const activeTab = prev.find((t) => t.key === active);
|
||||
if (!activeTab) {
|
||||
return;
|
||||
}
|
||||
|
||||
prev.forEach((t) => {
|
||||
if (t.key !== active) {
|
||||
if (t.key !== active && !isHomeTabKey(t.key)) {
|
||||
dropTabCache(t.key);
|
||||
}
|
||||
});
|
||||
setTabs([keep]);
|
||||
const homeTab = prev.find((t) => isHomeTabKey(t.key)) ?? {
|
||||
key: FALLBACK_ROUTE,
|
||||
label: resolveRouteTabTitle(FALLBACK_ROUTE),
|
||||
};
|
||||
setTabs(isHomeTabKey(active) ? [homeTab] : [homeTab, activeTab]);
|
||||
}, [dropTabCache, routeLoc.pathname, routeLoc.search]);
|
||||
|
||||
const closeAllTabs = useCallback(() => {
|
||||
@ -196,14 +224,18 @@ export function TabLayoutProvider(props: Readonly<{ children: React.ReactNode }>
|
||||
return;
|
||||
}
|
||||
|
||||
prev.forEach((t) => dropTabCache(t.key));
|
||||
prev.forEach((t) => {
|
||||
if (!isHomeTabKey(t.key)) {
|
||||
dropTabCache(t.key);
|
||||
}
|
||||
});
|
||||
const homeTab = { key: FALLBACK_ROUTE, label: resolveRouteTabTitle(FALLBACK_ROUTE) };
|
||||
setTabs([homeTab]);
|
||||
history.push(FALLBACK_ROUTE);
|
||||
}, [dropTabCache]);
|
||||
|
||||
const onTabsChange = useCallback((key: string) => {
|
||||
history.push(key);
|
||||
history.push(normalizeTabKey(key));
|
||||
}, []);
|
||||
|
||||
const onTabsEdit = useCallback(
|
||||
@ -222,7 +254,7 @@ export function TabLayoutProvider(props: Readonly<{ children: React.ReactNode }>
|
||||
tabs.map((t) => ({
|
||||
key: t.key,
|
||||
label: t.label,
|
||||
closable: true,
|
||||
closable: !isHomeTabKey(t.key),
|
||||
})),
|
||||
[tabs],
|
||||
);
|
||||
|
||||
@ -14,10 +14,22 @@ body,
|
||||
}
|
||||
|
||||
.layout-header-tabs-wrap {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
margin-inline: 16px;
|
||||
padding: 4px 6px;
|
||||
overflow: hidden;
|
||||
background: #f5f7fb;
|
||||
border: 1px solid #e8eef7;
|
||||
border-radius: 8px;
|
||||
}
|
||||
|
||||
.layout-header-tabs {
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.layout-header-tabs .ant-tabs-nav {
|
||||
height: 32px;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
@ -25,10 +37,98 @@ body,
|
||||
overflow-x: auto;
|
||||
}
|
||||
|
||||
.layout-header-tabs .ant-tabs-nav-list {
|
||||
gap: 4px;
|
||||
}
|
||||
|
||||
.layout-header-tabs .ant-tabs-nav::before {
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
.layout-header-tabs.ant-tabs-card > .ant-tabs-nav .ant-tabs-tab {
|
||||
height: 30px;
|
||||
margin: 0;
|
||||
padding: 0 10px;
|
||||
color: #526178;
|
||||
background: transparent;
|
||||
border: 1px solid transparent;
|
||||
border-radius: 6px;
|
||||
transition:
|
||||
background 0.18s ease,
|
||||
color 0.18s ease,
|
||||
border-color 0.18s ease;
|
||||
}
|
||||
|
||||
.layout-header-tabs.ant-tabs-card > .ant-tabs-nav .ant-tabs-tab:hover {
|
||||
color: #1677ff;
|
||||
background: #fff;
|
||||
border-color: #dbe7f6;
|
||||
}
|
||||
|
||||
.layout-header-tabs.ant-tabs-card > .ant-tabs-nav .ant-tabs-tab-active {
|
||||
background: #eaf3ff;
|
||||
border-color: #b9d7ff;
|
||||
}
|
||||
|
||||
.layout-header-tabs.ant-tabs-card > .ant-tabs-nav .ant-tabs-tab-active .ant-tabs-tab-btn {
|
||||
color: #0958d9;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.layout-header-tabs .ant-tabs-tab-btn {
|
||||
max-width: 148px;
|
||||
}
|
||||
|
||||
.layout-header-tab-label {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
max-width: 140px;
|
||||
min-width: 0;
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
.layout-header-tab-home-icon {
|
||||
flex: none;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.layout-header-tab-text {
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.layout-header-tabs .ant-tabs-tab-remove {
|
||||
margin-inline-start: 4px;
|
||||
color: #9aa7b8;
|
||||
opacity: 0.36;
|
||||
transition:
|
||||
color 0.18s ease,
|
||||
opacity 0.18s ease;
|
||||
}
|
||||
|
||||
.layout-header-tabs .ant-tabs-tab:hover .ant-tabs-tab-remove,
|
||||
.layout-header-tabs .ant-tabs-tab-active .ant-tabs-tab-remove {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
.layout-header-tabs .ant-tabs-tab-remove:hover {
|
||||
color: #ff4d4f;
|
||||
}
|
||||
|
||||
.layout-header-tabs .ant-tabs-extra-content {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
height: 32px;
|
||||
margin-inline-start: 4px;
|
||||
}
|
||||
|
||||
.layout-header-tabs-more {
|
||||
width: 28px;
|
||||
height: 28px;
|
||||
color: #526178;
|
||||
}
|
||||
|
||||
.crud-json-block {
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
@ -36,3 +136,174 @@ body,
|
||||
.crud-json-block .ant-form-item:last-child {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.ant-pro-layout .ant-pro-layout-content {
|
||||
background: #f4f7fb;
|
||||
}
|
||||
|
||||
.ant-pro-table .ant-pro-card,
|
||||
.ant-table-wrapper .ant-table {
|
||||
border-radius: 8px;
|
||||
}
|
||||
|
||||
.ant-table-thead > tr > th {
|
||||
color: #44546a;
|
||||
font-weight: 600;
|
||||
background: #f8fafc !important;
|
||||
}
|
||||
|
||||
.ant-table-tbody > tr:hover > td {
|
||||
background: #f5faff !important;
|
||||
}
|
||||
|
||||
.wms-home {
|
||||
padding: 24px;
|
||||
}
|
||||
|
||||
.wms-home-hero {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
justify-content: space-between;
|
||||
gap: 16px;
|
||||
margin-bottom: 16px;
|
||||
padding: 18px 20px;
|
||||
background: #fff;
|
||||
border: 1px solid #e8eef7;
|
||||
border-radius: 8px;
|
||||
box-shadow: 0 6px 18px rgb(30 64 175 / 6%);
|
||||
}
|
||||
|
||||
.wms-metric-card,
|
||||
.wms-work-card {
|
||||
border: 1px solid #e8eef7;
|
||||
border-radius: 8px;
|
||||
box-shadow: 0 6px 18px rgb(30 64 175 / 5%);
|
||||
}
|
||||
|
||||
.wms-metric-card .ant-card-body {
|
||||
min-height: 154px;
|
||||
}
|
||||
|
||||
.wms-metric-top {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
.wms-metric-icon {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 38px;
|
||||
height: 38px;
|
||||
font-size: 20px;
|
||||
border-radius: 8px;
|
||||
}
|
||||
|
||||
.wms-metric-value {
|
||||
margin-top: 14px;
|
||||
color: #152238;
|
||||
font-weight: 700;
|
||||
font-size: 30px;
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
.wms-metric-title {
|
||||
margin-top: 8px;
|
||||
color: #25324b;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.wms-metric-hint {
|
||||
display: block;
|
||||
margin-top: 4px;
|
||||
}
|
||||
|
||||
.wms-priority-row {
|
||||
display: flex;
|
||||
gap: 12px;
|
||||
padding: 12px 0;
|
||||
border-bottom: 1px solid #edf1f7;
|
||||
}
|
||||
|
||||
.wms-priority-row:last-child {
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
.wms-priority-title {
|
||||
margin-bottom: 2px;
|
||||
color: #25324b;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.wms-shortcut-btn {
|
||||
justify-content: flex-start;
|
||||
height: 38px;
|
||||
border-color: #e2e8f0;
|
||||
}
|
||||
|
||||
.wms-order-no {
|
||||
color: #1677ff;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.wms-order-detail-head {
|
||||
margin-bottom: 16px;
|
||||
padding: 14px 16px;
|
||||
background: #f8fafc;
|
||||
border: 1px solid #e8eef7;
|
||||
border-radius: 8px;
|
||||
}
|
||||
|
||||
.wms-order-detail-title {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 12px;
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
|
||||
.wms-order-detail-title-main {
|
||||
color: #152238;
|
||||
font-weight: 700;
|
||||
font-size: 18px;
|
||||
}
|
||||
|
||||
.wms-order-detail-meta {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(4, minmax(120px, 1fr));
|
||||
gap: 10px 16px;
|
||||
}
|
||||
|
||||
.wms-order-detail-meta-label {
|
||||
color: #7b8798;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.wms-order-detail-meta-value {
|
||||
margin-top: 2px;
|
||||
color: #25324b;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.wms-section-title {
|
||||
margin: 16px 0 8px;
|
||||
color: #25324b;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
@media (max-width: 768px) {
|
||||
.wms-home {
|
||||
padding: 16px;
|
||||
}
|
||||
|
||||
.wms-home-hero,
|
||||
.wms-order-detail-title {
|
||||
flex-direction: column;
|
||||
align-items: flex-start;
|
||||
}
|
||||
|
||||
.wms-order-detail-meta {
|
||||
grid-template-columns: repeat(2, minmax(120px, 1fr));
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,40 +1,201 @@
|
||||
import { Button, Card, Space, Typography } from 'antd';
|
||||
import React, { useEffect, useMemo, useState } from 'react';
|
||||
import { Button, Card, Col, Row, Skeleton, Space, Tag, Typography } from 'antd';
|
||||
import {
|
||||
ApartmentOutlined,
|
||||
ArrowDownOutlined,
|
||||
ArrowUpOutlined,
|
||||
CheckCircleOutlined,
|
||||
DatabaseOutlined,
|
||||
InboxOutlined,
|
||||
PartitionOutlined,
|
||||
SwapOutlined,
|
||||
WarningOutlined,
|
||||
} from '@ant-design/icons';
|
||||
import { history } from '@umijs/max';
|
||||
import React from 'react';
|
||||
import { pagedList } from '@/services/api';
|
||||
|
||||
const { Title, Paragraph } = Typography;
|
||||
const { Text, Title } = Typography;
|
||||
|
||||
type WorkbenchMetric = {
|
||||
key: string;
|
||||
title: string;
|
||||
value: number;
|
||||
path: string;
|
||||
color: string;
|
||||
icon: React.ReactNode;
|
||||
hint: string;
|
||||
};
|
||||
|
||||
async function fetchTotal(controller: string, params: Record<string, any> = {}) {
|
||||
const res = await pagedList(controller, { current: 1, pageSize: 1, ...params });
|
||||
return res.total || 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 应用主页(默认落地页)。
|
||||
*/
|
||||
export default function HomePage() {
|
||||
const go = (path: string) => () => history.push(path);
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [totals, setTotals] = useState({
|
||||
inbound: 0,
|
||||
outbound: 0,
|
||||
transfer: 0,
|
||||
stocktake: 0,
|
||||
inventory: 0,
|
||||
locations: 0,
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
let alive = true;
|
||||
setLoading(true);
|
||||
Promise.all([
|
||||
fetchTotal('InboundOrder'),
|
||||
fetchTotal('OutboundOrder'),
|
||||
fetchTotal('TransferOrder'),
|
||||
fetchTotal('StocktakeOrder'),
|
||||
fetchTotal('Inventory'),
|
||||
fetchTotal('Location'),
|
||||
])
|
||||
.then(([inbound, outbound, transfer, stocktake, inventory, locations]) => {
|
||||
if (!alive) return;
|
||||
setTotals({ inbound, outbound, transfer, stocktake, inventory, locations });
|
||||
})
|
||||
.finally(() => {
|
||||
if (alive) setLoading(false);
|
||||
});
|
||||
return () => {
|
||||
alive = false;
|
||||
};
|
||||
}, []);
|
||||
|
||||
const metrics = useMemo<WorkbenchMetric[]>(
|
||||
() => [
|
||||
{
|
||||
key: 'inbound',
|
||||
title: '入库单',
|
||||
value: totals.inbound,
|
||||
path: '/orders/inbound',
|
||||
color: '#1677ff',
|
||||
icon: <ArrowDownOutlined />,
|
||||
hint: '收货与入库确认',
|
||||
},
|
||||
{
|
||||
key: 'outbound',
|
||||
title: '出库单',
|
||||
value: totals.outbound,
|
||||
path: '/orders/outbound',
|
||||
color: '#fa8c16',
|
||||
icon: <ArrowUpOutlined />,
|
||||
hint: '分配、拣货与确认出库',
|
||||
},
|
||||
{
|
||||
key: 'transfer',
|
||||
title: '移库单',
|
||||
value: totals.transfer,
|
||||
path: '/orders/transfer',
|
||||
color: '#13c2c2',
|
||||
icon: <SwapOutlined />,
|
||||
hint: '库位间库存移动',
|
||||
},
|
||||
{
|
||||
key: 'stocktake',
|
||||
title: '盘点单',
|
||||
value: totals.stocktake,
|
||||
path: '/orders/stocktake',
|
||||
color: '#722ed1',
|
||||
icon: <CheckCircleOutlined />,
|
||||
hint: '库存差异确认',
|
||||
},
|
||||
],
|
||||
[totals],
|
||||
);
|
||||
|
||||
const shortcuts = [
|
||||
{ title: '库存余额', path: '/inventory/balance', icon: <DatabaseOutlined /> },
|
||||
{ title: '库存流水', path: '/inventory/transactions', icon: <PartitionOutlined /> },
|
||||
{ title: '库位管理', path: '/base/location', icon: <ApartmentOutlined /> },
|
||||
{ title: '物料档案', path: '/base/material', icon: <InboxOutlined /> },
|
||||
];
|
||||
|
||||
return (
|
||||
<div style={{ padding: 24 }}>
|
||||
<Card>
|
||||
<Title level={3}>欢迎使用 WmsLite</Title>
|
||||
<Paragraph type="secondary">
|
||||
请从左侧菜单进入各业务模块;已打开页面可在<strong>顶部标签栏</strong>切换,状态会尽可能保留。
|
||||
</Paragraph>
|
||||
<Paragraph style={{ marginBottom: 8 }}>
|
||||
常用入口:
|
||||
<Space wrap size="middle" style={{ marginLeft: 8 }}>
|
||||
<Button type="link" onClick={go('/base/warehouse')} style={{ paddingInline: 4 }}>
|
||||
仓库
|
||||
</Button>
|
||||
<Button type="link" onClick={go('/base/location')} style={{ paddingInline: 4 }}>
|
||||
库位
|
||||
</Button>
|
||||
<Button type="link" onClick={go('/inventory/balance')} style={{ paddingInline: 4 }}>
|
||||
库存余额
|
||||
</Button>
|
||||
<Button type="link" onClick={go('/orders/inbound')} style={{ paddingInline: 4 }}>
|
||||
入库单
|
||||
</Button>
|
||||
</Space>
|
||||
</Paragraph>
|
||||
</Card>
|
||||
<div className="wms-home">
|
||||
<div className="wms-home-hero">
|
||||
<div>
|
||||
<Title level={3} style={{ marginBottom: 4 }}>
|
||||
WmsLite 作业工作台
|
||||
</Title>
|
||||
<Text type="secondary">集中查看单据、库存和基础资料,优先处理当前仓库作业。</Text>
|
||||
</div>
|
||||
<Space wrap>
|
||||
<Tag color="processing">多租户</Tag>
|
||||
<Tag color="success">库存台账</Tag>
|
||||
<Tag color="warning">任务化出库</Tag>
|
||||
</Space>
|
||||
</div>
|
||||
|
||||
<Row gutter={[16, 16]}>
|
||||
{metrics.map((item) => (
|
||||
<Col xs={24} sm={12} xl={6} key={item.key}>
|
||||
<Card
|
||||
className="wms-metric-card"
|
||||
hoverable
|
||||
onClick={() => history.push(item.path)}
|
||||
styles={{ body: { padding: 18 } }}
|
||||
>
|
||||
<Skeleton loading={loading} active paragraph={false}>
|
||||
<div className="wms-metric-top">
|
||||
<span className="wms-metric-icon" style={{ color: item.color, background: `${item.color}16` }}>
|
||||
{item.icon}
|
||||
</span>
|
||||
<Button type="link" size="small" onClick={() => history.push(item.path)}>
|
||||
进入
|
||||
</Button>
|
||||
</div>
|
||||
<div className="wms-metric-value">{item.value}</div>
|
||||
<div className="wms-metric-title">{item.title}</div>
|
||||
<Text type="secondary" className="wms-metric-hint">
|
||||
{item.hint}
|
||||
</Text>
|
||||
</Skeleton>
|
||||
</Card>
|
||||
</Col>
|
||||
))}
|
||||
</Row>
|
||||
|
||||
<Row gutter={[16, 16]} style={{ marginTop: 16 }}>
|
||||
<Col xs={24} lg={16}>
|
||||
<Card title="作业优先级" className="wms-work-card">
|
||||
<div className="wms-priority-row">
|
||||
<WarningOutlined style={{ color: '#fa8c16' }} />
|
||||
<div>
|
||||
<div className="wms-priority-title">先处理出库待拣和库存异常</div>
|
||||
<Text type="secondary">出库分配会影响可用库存,建议在每日作业开始前先确认待拣和取消单据。</Text>
|
||||
</div>
|
||||
</div>
|
||||
<div className="wms-priority-row">
|
||||
<CheckCircleOutlined style={{ color: '#52c41a' }} />
|
||||
<div>
|
||||
<div className="wms-priority-title">入库单可先建单头再补明细</div>
|
||||
<Text type="secondary">适合先登记到货批次,再由仓管员逐行录入物料和数量。</Text>
|
||||
</div>
|
||||
</div>
|
||||
</Card>
|
||||
</Col>
|
||||
<Col xs={24} lg={8}>
|
||||
<Card title="常用入口" className="wms-work-card">
|
||||
<Space direction="vertical" style={{ width: '100%' }}>
|
||||
{shortcuts.map((item) => (
|
||||
<Button
|
||||
key={item.path}
|
||||
block
|
||||
icon={item.icon}
|
||||
onClick={() => history.push(item.path)}
|
||||
className="wms-shortcut-btn"
|
||||
>
|
||||
{item.title}
|
||||
</Button>
|
||||
))}
|
||||
</Space>
|
||||
</Card>
|
||||
</Col>
|
||||
</Row>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@ -177,6 +177,26 @@ export async function createRecord<T>(controller: string, values: Record<string,
|
||||
});
|
||||
}
|
||||
|
||||
export async function createOrderHeader<T>(controller: string, values: Record<string, any>): Promise<T> {
|
||||
return apiRequest<T>(`/api/${controller}/create-header`, {
|
||||
method: 'POST',
|
||||
data: values,
|
||||
});
|
||||
}
|
||||
|
||||
export async function addOrderLine<T>(
|
||||
controller: string,
|
||||
values: { orderId: string | number; line: Record<string, any> },
|
||||
): Promise<T> {
|
||||
return apiRequest<T>(`/api/${controller}/add-line`, {
|
||||
method: 'POST',
|
||||
data: {
|
||||
orderId: orderIdToApiValue(values.orderId),
|
||||
line: values.line,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
export type LocationBatchCreateResponse = {
|
||||
createdCount: number;
|
||||
skippedCodes: string[];
|
||||
@ -244,6 +264,7 @@ export const INVENTORY_MOVEMENT_TYPE = {
|
||||
ConfirmInbound: 4,
|
||||
PendingOutbound: 5,
|
||||
ConfirmOutbound: 6,
|
||||
PendingOutboundRelease: 8,
|
||||
} as const;
|
||||
|
||||
export type InventoryMovementTypeEnum =
|
||||
@ -285,6 +306,21 @@ export async function getOutboundPickTasks<T>(id: string | number): Promise<T[]>
|
||||
});
|
||||
}
|
||||
|
||||
export async function confirmOutboundPickTask<T = any>(payload: {
|
||||
id: string | number;
|
||||
pickedQty?: number;
|
||||
exceptionReason?: string;
|
||||
}): Promise<T> {
|
||||
return apiRequest<T>('/api/OutboundOrder/pick-task/confirm', {
|
||||
method: 'POST',
|
||||
data: {
|
||||
id: orderIdToApiValue(payload.id),
|
||||
...(payload.pickedQty !== undefined ? { pickedQty: payload.pickedQty } : {}),
|
||||
...(payload.exceptionReason?.trim() ? { exceptionReason: payload.exceptionReason.trim() } : {}),
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
export function parseJsonObject(
|
||||
value?: string,
|
||||
fallback: any = undefined,
|
||||
|
||||
@ -23,6 +23,10 @@
|
||||
- 已完成第一版出库库存分配:出库明细可只表达仓库、库区、物料和数量,系统在转待拣时自动按可用库存 FIFO 分配。
|
||||
- 已完成第一版拣货任务:出库转待拣时生成 `outbound_pick_task`,确认出库时按任务扣减库存并标记已拣。
|
||||
- 已保留兼容能力:出库明细填写指定库位时,只从该库位分配库存。
|
||||
- 已补齐出库任务闭环第一阶段:拣货任务支持单任务确认,确认出库前要求任务已拣;取消待拣/已拣出库单会释放预占库存并取消任务。
|
||||
- 已支持入库、出库先创建 Draft 单头,再在单据详情中追加明细。
|
||||
- 已调整出库物料单位处理:前端不再要求填写单位,后端按物料主数据单位自动写入并校验不一致输入。
|
||||
- 已完成前端作业体验第一轮整理:首页作业工作台、单据状态标签、详情概要、顶部工作区标签栏和首页固定标签。
|
||||
|
||||
### 1. 入库流程标准化
|
||||
|
||||
@ -174,38 +178,36 @@ InventoryAllocationService
|
||||
- 错误库存变动通过冲正流水修复。
|
||||
- 单据状态流转必须具备幂等和并发保护。
|
||||
|
||||
### 8. 后端测试体系补强
|
||||
### 8. 构建检查与人工验收
|
||||
|
||||
已新增库存移动服务单元测试,下一步应覆盖订单服务和关键业务闭环。
|
||||
按当前项目约定,本轮后续开发不新增自动化测试建设任务。每阶段完成后使用构建检查和人工业务场景验收兜底。
|
||||
|
||||
优先测试范围:
|
||||
固定检查:
|
||||
|
||||
- 入库确认生成库存和库存流水
|
||||
- 出库 pending 预占库存
|
||||
- 出库 confirm 扣减库存
|
||||
- 出库库存不足失败
|
||||
- 移库 pending 后来源库存占用
|
||||
- 移库 confirm 后来源扣减、目标增加
|
||||
- 单据状态非法流转失败
|
||||
- 重复请求或重复确认不会重复扣减库存
|
||||
- 租户和货主隔离
|
||||
- 后端运行 `dotnet build`。
|
||||
- 前端运行 `pnpm run typecheck`、`pnpm run build`、`pnpm run lint`。
|
||||
- 核心业务通过人工场景验收,重点覆盖库存数量、单据状态、任务状态和库存流水是否一致。
|
||||
|
||||
关键目标:
|
||||
优先人工验收范围:
|
||||
|
||||
- 业务服务层必须有单元测试。
|
||||
- 关键 API 应增加集成测试。
|
||||
- 库存数量、状态、流水三者必须一起断言。
|
||||
- 入库单可先建 Draft 单头,再追加明细并确认入库。
|
||||
- 出库单可先建 Draft 单头,再追加明细并转待拣。
|
||||
- 出库转待拣后生成拣货任务,任务确认后才能确认出库。
|
||||
- 库存不足时出库转待拣失败,库存不被部分污染。
|
||||
- 取消待拣出库单后释放预占库存。
|
||||
- 重复点击待拣、确认拣货、确认出库不会重复扣减库存。
|
||||
- 左上角图标进入首页时不会新增“页面”标签。
|
||||
|
||||
## 建议实施顺序
|
||||
|
||||
1. 补订单服务测试,确保现有逻辑可安全演进。
|
||||
2. 抽象库存分配服务,为出库任务化做准备。
|
||||
3. 改造出库流程,引入拣货任务。
|
||||
4. 改造入库流程,引入收货暂存和上架任务。
|
||||
5. 改造移库流程,引入移库任务和在途状态。
|
||||
6. 扩展库存维度,加入批次、效期、质量状态。
|
||||
7. 增强容器/LPN 能力。
|
||||
8. 补撤销、冲正、异常恢复和并发保护。
|
||||
1. 稳固当前出库任务化闭环,继续补齐幂等、异常原因和状态限制。
|
||||
2. 改造入库流程,引入收货暂存和上架任务。
|
||||
3. 改造移库流程,引入移库任务和在途状态。
|
||||
4. 扩展库存维度,加入批次、效期、质量状态。
|
||||
5. 增强容器/LPN 能力。
|
||||
6. 补撤销、冲正、异常恢复和并发保护。
|
||||
7. 整理前端作业体验,继续统一单据详情、任务视图和流水视图。
|
||||
8. 完善部署说明、业务流程文档和阶段人工验收清单。
|
||||
|
||||
## 阶段完成标准
|
||||
|
||||
@ -219,7 +221,7 @@ InventoryAllocationService
|
||||
- 基础库存分配策略:FIFO、FEFO、库区优先级
|
||||
- 初级容器/LPN 管理
|
||||
- 可追溯库存流水
|
||||
- 核心业务服务测试覆盖
|
||||
- 每阶段构建检查与人工验收记录
|
||||
|
||||
## 尚未覆盖的高级能力
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user