feat: 全项目列表页操作列规范统一 + 问题.md 六条整改
- 操作列按6条标准统一(WMS 13页/MES 18页):fixed right、宽160超限折更多、一列一填充、危险操作link+二次确认置末、页面级新建移工具栏 - 修复MES物料档案启用报错:改走 POST /product-types/status 专用端点,不再被全字段必填校验拦截 - 附件归档清理由按年改为用户选月(精确到月,截止月最晚6个月前,默认当前月-6),前后端同步 - 序列号文案统一为「是=逐件录SN,否=按数量(不录SN)」,MES 下拉改单选框 - 入库货架/层/位置必填校验(InboundEntry 前端 + inbound.go 后端),杜绝有区域无货架的新脏数据 - 生产流程卡新增列表Tab(新接口 GET /process-card/list 分页),去掉筛选默认时间 - 清理遗留 assets_bak/public_bak 备份目录;更新 WMS/MES 前端构建产物(index.html)
This commit is contained in:
@@ -7,6 +7,7 @@ import (
|
||||
"html/template"
|
||||
"net/http"
|
||||
"sort"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
@@ -261,6 +262,51 @@ func ModelWorkOrdersHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
}
|
||||
}
|
||||
|
||||
// ProcessCardListHandler GET /process-card/list 流程卡列表(分页)。
|
||||
// 每个工单=一张生产流程卡;不要求任何查询条件即可返回全部(分页),解决旧版「必须知道查谁才能查」看不到全量流程卡的问题。
|
||||
// 支持 orderNo / productCode / keyword(工单号·产品编码·产品名称)筛选;返回 {list, total}。
|
||||
func ProcessCardListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
q := r.URL.Query()
|
||||
page, _ := strconv.Atoi(q.Get("page"))
|
||||
pageSize, _ := strconv.Atoi(q.Get("pageSize"))
|
||||
if page < 1 {
|
||||
page = 1
|
||||
}
|
||||
if pageSize < 1 {
|
||||
pageSize = 20
|
||||
}
|
||||
if pageSize > 200 {
|
||||
pageSize = 200
|
||||
}
|
||||
total, list, err := logic.New(svcCtx).ListProcessCards(r.Context(), page, pageSize,
|
||||
strings.TrimSpace(q.Get("orderNo")), strings.TrimSpace(q.Get("productCode")), strings.TrimSpace(q.Get("keyword")))
|
||||
if err != nil {
|
||||
httpx.Fail(w, 2409, err.Error())
|
||||
return
|
||||
}
|
||||
rows := make([]map[string]any, 0, len(list))
|
||||
for _, wo := range list {
|
||||
createdAt := ""
|
||||
if !wo.CreatedAt.IsZero() {
|
||||
createdAt = wo.CreatedAt.Format("2006-01-02 15:04")
|
||||
}
|
||||
rows = append(rows, map[string]any{
|
||||
"id": wo.ID,
|
||||
"workOrderNo": wo.WorkOrderNo,
|
||||
"productCode": wo.ProductCode,
|
||||
"productName": wo.ProductName,
|
||||
"productSerial": wo.ProductSerial,
|
||||
"status": wo.Status,
|
||||
"planQty": wo.Quantity,
|
||||
"finishedNum": wo.FinishedNum,
|
||||
"createdAt": createdAt,
|
||||
})
|
||||
}
|
||||
httpx.Ok(w, map[string]any{"list": rows, "total": total})
|
||||
}
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// 数据聚合
|
||||
// ============================================================================
|
||||
|
||||
@@ -309,6 +309,7 @@ func RegisterProductionRoutes(server *rest.Server, serverCtx *svc.ServiceContext
|
||||
{Method: http.MethodGet, Path: "/process-card/workorder", Handler: WorkOrderCardHandler(serverCtx)},
|
||||
{Method: http.MethodGet, Path: "/process-card/by-sn", Handler: SnTraceCardHandler(serverCtx)},
|
||||
{Method: http.MethodGet, Path: "/process-card/by-model", Handler: ModelWorkOrdersHandler(serverCtx)},
|
||||
{Method: http.MethodGet, Path: "/process-card/list", Handler: ProcessCardListHandler(serverCtx)},
|
||||
|
||||
// ---------- 工艺物料清单(flow_material,一份工艺定义一份清单) ----------
|
||||
{Method: http.MethodGet, Path: "/process-flows/:id/materials", Handler: production.ListFlowMaterialsHandler(serverCtx)},
|
||||
|
||||
@@ -334,6 +334,46 @@ func (s *Service) ListWorkOrders(ctx context.Context, orderNo, status, productCo
|
||||
return q.Order(ent.Desc(workorder.FieldCreatedAt), ent.Desc(workorder.FieldID)).All(ctx)
|
||||
}
|
||||
|
||||
// ListProcessCards 流程卡列表(分页):每个工单=一张生产流程卡。
|
||||
// 与 /process-card/by-model 不同,本接口不要求任何条件,支持按工单号/产品型号/关键字(工单号·产品编码·产品名称)筛选,
|
||||
// 返回 {total, list},list 元素为工单基础字段(含成品SN productSerial、创建时间),供前端「流程卡列表」Tab 展示。
|
||||
func (s *Service) ListProcessCards(ctx context.Context, page, pageSize int, orderNo, productCode, keyword string) (int64, []*ent.WorkOrder, error) {
|
||||
if page < 1 {
|
||||
page = 1
|
||||
}
|
||||
if pageSize < 1 {
|
||||
pageSize = 20
|
||||
}
|
||||
if pageSize > 200 {
|
||||
pageSize = 200
|
||||
}
|
||||
q := s.ctx.EntClient.WorkOrder.Query()
|
||||
if orderNo != "" {
|
||||
q = q.Where(workorder.WorkOrderNoContainsFold(orderNo))
|
||||
}
|
||||
if productCode != "" {
|
||||
q = q.Where(workorder.ProductCodeContainsFold(productCode))
|
||||
}
|
||||
if keyword != "" {
|
||||
kw := workorder.Or(
|
||||
workorder.WorkOrderNoContainsFold(keyword),
|
||||
workorder.ProductCodeContainsFold(keyword),
|
||||
workorder.ProductNameContainsFold(keyword),
|
||||
)
|
||||
q = q.Where(kw)
|
||||
}
|
||||
total, err := q.Count(ctx)
|
||||
if err != nil {
|
||||
return 0, nil, err
|
||||
}
|
||||
list, err := q.Order(ent.Desc(workorder.FieldCreatedAt), ent.Desc(workorder.FieldID)).
|
||||
Offset((page - 1) * pageSize).Limit(pageSize).All(ctx)
|
||||
if err != nil {
|
||||
return 0, nil, err
|
||||
}
|
||||
return total, list, nil
|
||||
}
|
||||
|
||||
func (s *Service) GetWorkOrder(ctx context.Context, id int) (*ent.WorkOrder, error) {
|
||||
if id > 0 {
|
||||
return s.ctx.EntClient.WorkOrder.Get(ctx, id)
|
||||
|
||||
Reference in New Issue
Block a user