60 lines
2.3 KiB
Markdown
60 lines
2.3 KiB
Markdown
# 质检物料库 · 编辑弹窗数量修正 Implementation Plan
|
||
|
||
> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking.
|
||
|
||
**Goal:** 允许在质检物料库编辑弹窗修正入库数量与剩余数量,同步物资汇总库存与入库流水,账实不符时写入 adjust 流水,不改历史出库记录。
|
||
|
||
**Architecture:** 后端 `update_batch` 增加数量修正分支(`_sum_batch_out_total` + 校验 + 入库流水同步 + 可选 adjust 流水);新增 GET 批次详情返回 `outTotal`;前端编辑弹窗联动两数量字段;变动记录 Tab 支持 adjust 筛选与展示。
|
||
|
||
**Tech Stack:** FastAPI · SQLAlchemy · Vue 3 · Element Plus · DecimalInput
|
||
|
||
**Spec:** `docs/superpowers/specs/2026-07-07-qc-material-batch-qty-edit-design.md`
|
||
|
||
---
|
||
|
||
### Task 1: 后端 CRUD — out_total 与 update_batch 数量修正
|
||
|
||
**Files:**
|
||
- Modify: `backend/app/crud/qc_material_stock_batch.py`
|
||
|
||
- [ ] 新增 `_sum_batch_out_total(db, batch_id, tenant_no) -> Tuple[Decimal, int]`
|
||
- [ ] 新增 `get_batch_detail(db, batch_id, tenant_no) -> Dict`(含 outTotal、outCount)
|
||
- [ ] `update_batch` 增加 `in_qty` / `remaining_qty` 参数与事务内数量修正逻辑
|
||
- [ ] 批次查询改用 `with_for_update()` 锁定
|
||
|
||
### Task 2: 后端 API
|
||
|
||
**Files:**
|
||
- Modify: `backend/app/api/qc.py`
|
||
|
||
- [ ] `QcMaterialBatchUpdateBody` 增加 `inQty`、`remainingQty`
|
||
- [ ] 新增 `GET /qc-material-batches/{batch_id}`
|
||
|
||
### Task 3: 变动记录 adjust 筛选
|
||
|
||
**Files:**
|
||
- Modify: `backend/app/crud/qc_material_usage.py`
|
||
|
||
- [ ] `_list_usages_query` 增加 `change_type == adjust` 分支
|
||
|
||
### Task 4: 前端 API 与编辑弹窗
|
||
|
||
**Files:**
|
||
- Modify: `web-admin/src/api/qc-material.ts`
|
||
- Modify: `web-admin/src/views/quality-inspection/qc-material/index.vue`
|
||
|
||
- [ ] 类型与 `fetchQcMaterialBatchDetail`
|
||
- [ ] 编辑弹窗可编辑数量、只读已出库/理论剩余、联动与校验、提交 payload
|
||
|
||
### Task 5: 变动记录 Tab
|
||
|
||
**Files:**
|
||
- Modify: `web-admin/src/views/quality-inspection/qc-material/QcMaterialUsageTab.vue`
|
||
|
||
- [ ] 筛选项「库存调整」、Tag 与来源文案
|
||
|
||
### Task 6: 验证
|
||
|
||
- [ ] 后端 Python 语法检查
|
||
- [ ] 前端 lint 相关文件
|