feat(shipping-notice): 我的待办改版为表格加抽屉并新增已完成明细报表
- 阶段 tab 收敛 4 个可动作阶段,计数改后端全量聚合 - 通知完成拆明细平铺报表(筛选/分页/12 列导出),批量改情境浮动条 - 同步 i18n 四语言与文档
This commit is contained in:
1 parent
18af972d20
commit
d8299ebf20
21 files changed
+3315
-761
No files matched your search
@@ -199,6 +199,7 @@ def workspace_shipping_my_todos():
|
||||
todo_category=str(request.args.get('todo_category') or '').strip() or None,
|
||||
customer=str(request.args.get('customer') or '').strip() or None,
|
||||
task_no=str(request.args.get('task_no') or '').strip() or None,
|
||||
terminal_kind=str(request.args.get('terminal_kind') or '').strip() or None,
|
||||
))
|
||||
|
||||
|
||||
@@ -212,6 +213,67 @@ def workspace_shipping_my_todos_count():
|
||||
return _ok(count_my_todos(user.id, is_admin=is_admin))
|
||||
|
||||
|
||||
def _done_lines_report_params() -> dict[str, Any]:
|
||||
"""解析明细报表共用筛选参数(客户/料号/发货通知日期范围),供查询与导出复用。"""
|
||||
return {
|
||||
'customer': str(request.args.get('customer') or '').strip() or None,
|
||||
'part_number': str(request.args.get('part_number') or '').strip() or None,
|
||||
'notice_date_from': str(request.args.get('notice_date_from') or '').strip() or None,
|
||||
'notice_date_to': str(request.args.get('notice_date_to') or '').strip() or None,
|
||||
}
|
||||
|
||||
|
||||
@workspace_shipping_notice_bp.route('/shipping-tasks/my-todos/done-lines', methods=['GET'])
|
||||
def workspace_shipping_done_lines():
|
||||
"""
|
||||
分页列出已完成(已核验上传成功)通知的平铺明细行,供「通知完成」子视图报表。
|
||||
|
||||
核心逻辑:明细行跨 Notice 混排、不按 OT 聚合;支持 客户 / 料号 /
|
||||
发货通知日期范围 筛选;行结构为标准 12 字段 + 溯源编号(task_no/business_no)。
|
||||
"""
|
||||
user = _require_user()
|
||||
from app.services.shipping_notice.done_line_report import list_done_notice_lines
|
||||
|
||||
is_admin = str(getattr(user, 'role', '') or '').lower() == 'admin'
|
||||
try:
|
||||
page = int(request.args.get('page') or 1)
|
||||
page_size = int(request.args.get('page_size') or 20)
|
||||
except (TypeError, ValueError) as exc:
|
||||
raise ValidationError('page and page_size must be integers') from exc
|
||||
return _ok(list_done_notice_lines(
|
||||
user.id,
|
||||
is_admin=is_admin,
|
||||
page=page,
|
||||
page_size=page_size,
|
||||
**_done_lines_report_params(),
|
||||
))
|
||||
|
||||
|
||||
@workspace_shipping_notice_bp.route('/shipping-tasks/my-todos/done-lines/export', methods=['GET'])
|
||||
def workspace_shipping_done_lines_export():
|
||||
"""
|
||||
导出当前筛选下的已完成通知明细 Excel。
|
||||
|
||||
核心逻辑:固定 12 列标准格式(客户/客户编号/订单日期/订单项次/料号/数量/
|
||||
约定出货日期/客户PO/已用数量/open qty/订单单号/单价),OT 编号不落列;
|
||||
已用数量 / open qty 无数据源留空。
|
||||
"""
|
||||
user = _require_user()
|
||||
from app.services.shipping_notice.done_line_report import build_done_lines_xlsx
|
||||
|
||||
is_admin = str(getattr(user, 'role', '') or '').lower() == 'admin'
|
||||
stream, filename = build_done_lines_xlsx(
|
||||
user.id,
|
||||
is_admin=is_admin,
|
||||
**_done_lines_report_params(),
|
||||
)
|
||||
response = send_file(
|
||||
stream, as_attachment=True, download_name=filename, mimetype=EXPORT_MIME_TYPE,
|
||||
)
|
||||
response.call_on_close(stream.close)
|
||||
return response
|
||||
|
||||
|
||||
def _batch_task_nos(data: dict) -> list[str]:
|
||||
"""校验批量任务号,统一限制 100 条并去重,避免前端循环绕过服务端门禁。"""
|
||||
raw_task_nos = data.get('task_nos')
|
||||
|
||||
@@ -0,0 +1,290 @@
|
||||
"""
|
||||
backend/app/services/shipping_notice/done_line_report.py
|
||||
|
||||
用途:「我的待办」已完成(已核验上传成功)发货通知的平铺明细行报表读模型与专用导出。
|
||||
依赖:query_service 的可见性与上传成功口径(_visible_tasks_query_for_todos /
|
||||
_verified_upload_success_sql_expr);shipping_order_snapshot 冻结快照。
|
||||
逻辑:Notice(uploaded) → OT → Snapshot → SnapshotLine 展开为标准 12 字段行;页面另附
|
||||
OT/business 编号列便于溯源,导出严格 12 列不落编号。已用数量 / open_qty 当前无
|
||||
数据源,契约占位为 None(前端与 Excel 均留空)。约定出货日期取行级 required_date
|
||||
(field_values_json),缺失时回退快照表头 typed 列;订单单号取表头
|
||||
source_order_number(field_id 键)。支持 客户 / 料号 / 发货通知日期(Notice
|
||||
创建日期)筛选,按明细行分页;导出复用同一查询,行数受 DONE_LINE_EXPORT_LIMIT 防护。
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from datetime import date, datetime, time
|
||||
from io import BytesIO
|
||||
from typing import Any
|
||||
from zoneinfo import ZoneInfo
|
||||
|
||||
from openpyxl import Workbook
|
||||
from sqlalchemy import asc, desc
|
||||
|
||||
from app import db
|
||||
from app.core.errors import ValidationError
|
||||
from app.models import (
|
||||
ShippingNotice,
|
||||
ShippingOrderField,
|
||||
ShippingOrderSnapshot,
|
||||
ShippingOrderSnapshotLine,
|
||||
ShippingOrderTask,
|
||||
)
|
||||
from app.services.shipping_notice.query_service import (
|
||||
_verified_upload_success_sql_expr,
|
||||
_visible_tasks_query_for_todos,
|
||||
)
|
||||
|
||||
# 导出防护上限:超出即截断(明细行报表场景远低于该量级)。
|
||||
DONE_LINE_EXPORT_LIMIT = 10000
|
||||
|
||||
# 导出固定 12 列中文表头;顺序即业务标准格式,OT 编号不落列。
|
||||
DONE_REPORT_HEADERS: tuple[str, ...] = (
|
||||
"客户", "客户编号", "订单日期", "订单项次", "料号", "数量",
|
||||
"约定出货日期", "客户PO", "已用数量", "open qty", "订单单号", "单价",
|
||||
)
|
||||
|
||||
|
||||
def _parse_notice_date(value: Any, *, label: str) -> date:
|
||||
"""解析 YYYY-MM-DD 日期参数;非法输入抛 ValidationError,禁止静默吞掉。"""
|
||||
text = str(value or '').strip()
|
||||
if not text:
|
||||
raise ValidationError(f'{label} must be YYYY-MM-DD', code='SHIPPING.DONE_LINE_DATE_INVALID')
|
||||
try:
|
||||
return datetime.strptime(text[:10], '%Y-%m-%d').date()
|
||||
except ValueError as exc:
|
||||
raise ValidationError(f'{label} must be YYYY-MM-DD', code='SHIPPING.DONE_LINE_DATE_INVALID') from exc
|
||||
|
||||
|
||||
def _done_lines_query(
|
||||
user_id: int,
|
||||
*,
|
||||
is_admin: bool = False,
|
||||
customer: str | None = None,
|
||||
part_number: str | None = None,
|
||||
notice_date_from: Any = None,
|
||||
notice_date_to: Any = None,
|
||||
):
|
||||
"""
|
||||
构造已完成通知明细行的联表查询(Notice → OT → Snapshot → SnapshotLine)。
|
||||
|
||||
核心逻辑:仅取已核验上传成功的正式 Notice;可见性复用待办口径(非管理员仅创建者);
|
||||
客户按快照 客户名称/客户编号 模糊、料号按 行料号/客户料号 模糊、发货通知日期按
|
||||
Notice created_at 自然日闭区间过滤。
|
||||
|
||||
Raises:
|
||||
ValidationError: 日期参数非法。
|
||||
"""
|
||||
q = (
|
||||
_visible_tasks_query_for_todos(user_id, is_admin=is_admin)
|
||||
.filter(_verified_upload_success_sql_expr())
|
||||
.join(ShippingOrderTask, ShippingOrderTask.id == ShippingNotice.order_task_id)
|
||||
.join(ShippingOrderSnapshot, ShippingOrderSnapshot.task_id == ShippingOrderTask.id)
|
||||
.join(ShippingOrderSnapshotLine, ShippingOrderSnapshotLine.snapshot_id == ShippingOrderSnapshot.id)
|
||||
)
|
||||
customer_needle = str(customer or '').strip()
|
||||
if customer_needle:
|
||||
like = f"%{customer_needle}%"
|
||||
q = q.filter(
|
||||
db.or_(
|
||||
ShippingOrderSnapshot.customer_name.ilike(like),
|
||||
ShippingOrderSnapshot.customer_code.ilike(like),
|
||||
)
|
||||
)
|
||||
part_needle = str(part_number or '').strip()
|
||||
if part_needle:
|
||||
like = f"%{part_needle}%"
|
||||
q = q.filter(
|
||||
db.or_(
|
||||
ShippingOrderSnapshotLine.part_number.ilike(like),
|
||||
ShippingOrderSnapshotLine.customer_part_number.ilike(like),
|
||||
)
|
||||
)
|
||||
if notice_date_from:
|
||||
from_day = notice_date_from if isinstance(notice_date_from, date) else _parse_notice_date(notice_date_from, label='notice_date_from')
|
||||
q = q.filter(ShippingNotice.created_at >= datetime.combine(from_day, time.min))
|
||||
if notice_date_to:
|
||||
to_day = notice_date_to if isinstance(notice_date_to, date) else _parse_notice_date(notice_date_to, label='notice_date_to')
|
||||
q = q.filter(ShippingNotice.created_at <= datetime.combine(to_day, time.max))
|
||||
return q
|
||||
|
||||
|
||||
def _report_field_ids() -> dict[tuple[str, str], str]:
|
||||
"""读取报表所需的标准字段资产 id(field_code+scope 唯一),供 JSON 值回源。"""
|
||||
rows = ShippingOrderField.query.filter(
|
||||
ShippingOrderField.field_code.in_(('required_date', 'source_order_number')),
|
||||
ShippingOrderField.status == 'active',
|
||||
).all()
|
||||
return {(row.field_code, row.scope): str(row.id) for row in rows}
|
||||
|
||||
|
||||
def _date_text(value: Any) -> str | None:
|
||||
"""日期值统一为 YYYY-MM-DD 文本;date 对象取日期部分,字符串截前十位。"""
|
||||
if value in (None, ''):
|
||||
return None
|
||||
if hasattr(value, 'isoformat'):
|
||||
return str(value.isoformat())[:10]
|
||||
text = str(value).strip()
|
||||
return text[:10] or None
|
||||
|
||||
|
||||
def _num_text(value: Any) -> float | None:
|
||||
"""数量/单价序列化为 JSON number;缺失返回 None(禁止 0 冒充)。"""
|
||||
if value in (None, ''):
|
||||
return None
|
||||
return float(value)
|
||||
|
||||
|
||||
def _serialize_done_line(
|
||||
notice: ShippingNotice,
|
||||
snapshot: ShippingOrderSnapshot,
|
||||
line: ShippingOrderSnapshotLine,
|
||||
field_ids: dict[tuple[str, str], str],
|
||||
) -> dict[str, Any]:
|
||||
"""按标准 12 字段 + 溯源编号序列化一行明细;无数据源字段契约留空。"""
|
||||
required_date_field_id = field_ids.get(('required_date', 'line'))
|
||||
required_date = (
|
||||
(line.field_values_json or {}).get(required_date_field_id)
|
||||
if required_date_field_id else None
|
||||
)
|
||||
if required_date in (None, ''):
|
||||
required_date = snapshot.required_date
|
||||
source_order_field_id = field_ids.get(('source_order_number', 'header'))
|
||||
source_order_number = (
|
||||
(snapshot.header_values_json or {}).get(source_order_field_id)
|
||||
if source_order_field_id else None
|
||||
)
|
||||
return {
|
||||
# 溯源编号:仅页面展示,导出不落列。
|
||||
'task_no': notice.task_no,
|
||||
'business_no': notice.business_no,
|
||||
# 标准 12 字段。
|
||||
'customer_name': snapshot.customer_name,
|
||||
'customer_code': snapshot.customer_code,
|
||||
'order_date': _date_text(snapshot.order_date),
|
||||
'line_no': line.line_no,
|
||||
'part_number': line.part_number,
|
||||
'qty': _num_text(line.qty),
|
||||
'required_date': _date_text(required_date),
|
||||
'customer_po_number': snapshot.customer_po_number,
|
||||
'used_qty': None,
|
||||
'open_qty': None,
|
||||
'source_order_number': source_order_number,
|
||||
'unit_price': _num_text(line.unit_price),
|
||||
}
|
||||
|
||||
|
||||
def list_done_notice_lines(
|
||||
user_id: int,
|
||||
*,
|
||||
is_admin: bool = False,
|
||||
customer: str | None = None,
|
||||
part_number: str | None = None,
|
||||
notice_date_from: Any = None,
|
||||
notice_date_to: Any = None,
|
||||
page: int = 1,
|
||||
page_size: int = 20,
|
||||
) -> dict[str, Any]:
|
||||
"""
|
||||
分页列出已完成通知的平铺明细行(跨 Notice 混排,不按 OT 聚合)。
|
||||
|
||||
Returns:
|
||||
{items, page, page_size, total};item 结构见 _serialize_done_line。
|
||||
"""
|
||||
normalized_page = max(1, int(page))
|
||||
normalized_page_size = max(1, min(int(page_size), 100))
|
||||
q = _done_lines_query(
|
||||
user_id,
|
||||
is_admin=is_admin,
|
||||
customer=customer,
|
||||
part_number=part_number,
|
||||
notice_date_from=notice_date_from,
|
||||
notice_date_to=notice_date_to,
|
||||
)
|
||||
total = int(q.count())
|
||||
field_ids = _report_field_ids()
|
||||
items: list[dict[str, Any]] = []
|
||||
if total:
|
||||
offset = (normalized_page - 1) * normalized_page_size
|
||||
rows = (
|
||||
q.with_entities(ShippingNotice, ShippingOrderSnapshot, ShippingOrderSnapshotLine)
|
||||
.order_by(
|
||||
desc(ShippingNotice.created_at), desc(ShippingNotice.id),
|
||||
asc(ShippingOrderSnapshotLine.position),
|
||||
)
|
||||
.offset(offset)
|
||||
.limit(normalized_page_size)
|
||||
.all()
|
||||
)
|
||||
items = [
|
||||
_serialize_done_line(notice, snapshot, line, field_ids)
|
||||
for notice, snapshot, line in rows
|
||||
]
|
||||
return {
|
||||
'items': items,
|
||||
'page': normalized_page,
|
||||
'page_size': normalized_page_size,
|
||||
'total': total,
|
||||
}
|
||||
|
||||
|
||||
def build_done_lines_xlsx(
|
||||
user_id: int,
|
||||
*,
|
||||
is_admin: bool = False,
|
||||
customer: str | None = None,
|
||||
part_number: str | None = None,
|
||||
notice_date_from: Any = None,
|
||||
notice_date_to: Any = None,
|
||||
) -> tuple[BytesIO, str]:
|
||||
"""
|
||||
按当前筛选生成标准 12 列明细 Excel(不落 OT 编号列),返回流与下载文件名。
|
||||
|
||||
核心逻辑:与列表同源查询、不分页;超过 DONE_LINE_EXPORT_LIMIT 截断并在文件名
|
||||
带时间戳,避免同日下载互相覆盖。单元格空值写 None(留空),禁止以 0 伪装。
|
||||
"""
|
||||
q = _done_lines_query(
|
||||
user_id,
|
||||
is_admin=is_admin,
|
||||
customer=customer,
|
||||
part_number=part_number,
|
||||
notice_date_from=notice_date_from,
|
||||
notice_date_to=notice_date_to,
|
||||
)
|
||||
rows = (
|
||||
q.with_entities(ShippingNotice, ShippingOrderSnapshot, ShippingOrderSnapshotLine)
|
||||
.order_by(
|
||||
desc(ShippingNotice.created_at), desc(ShippingNotice.id),
|
||||
asc(ShippingOrderSnapshotLine.position),
|
||||
)
|
||||
.limit(DONE_LINE_EXPORT_LIMIT)
|
||||
.all()
|
||||
)
|
||||
field_ids = _report_field_ids()
|
||||
workbook = Workbook()
|
||||
sheet = workbook.active
|
||||
sheet.title = '通知明细'
|
||||
sheet.append(list(DONE_REPORT_HEADERS))
|
||||
for notice, snapshot, line in rows:
|
||||
item = _serialize_done_line(notice, snapshot, line, field_ids)
|
||||
sheet.append([
|
||||
item['customer_name'],
|
||||
item['customer_code'],
|
||||
item['order_date'],
|
||||
item['line_no'],
|
||||
item['part_number'],
|
||||
item['qty'],
|
||||
item['required_date'],
|
||||
item['customer_po_number'],
|
||||
item['used_qty'],
|
||||
item['open_qty'],
|
||||
item['source_order_number'],
|
||||
item['unit_price'],
|
||||
])
|
||||
buffer = BytesIO()
|
||||
workbook.save(buffer)
|
||||
buffer.seek(0)
|
||||
stamp = datetime.now(ZoneInfo('Asia/Shanghai')).strftime('%Y%m%d_%H%M%S')
|
||||
filename = f'done-lines-{stamp}.xlsx'
|
||||
return buffer, filename
|
||||
@@ -88,6 +88,13 @@ from app.services.shipping_notice.constants import (
|
||||
RS_SHORTAGE_REVIEW,
|
||||
)
|
||||
from app.services.shipping_notice.upload_attempt_service import latest_export_artifact
|
||||
from app.services.shipping_notice.lifecycle_projection import (
|
||||
LIFECYCLE_STAGE_BY_GATE,
|
||||
LIFECYCLE_STAGE_BY_PROCESSING_STAGE,
|
||||
)
|
||||
from app.services.shipping_notice.process_gate_contract import (
|
||||
PROCESS_GATE_REASON_OWNING_GATE,
|
||||
)
|
||||
from app.services.shipping_notice.state_machine import (
|
||||
UserMode,
|
||||
resolve_task_ui_state,
|
||||
@@ -132,6 +139,17 @@ _TODO_BUCKET_CATEGORIES: dict[str, frozenset[str]] = {
|
||||
"done": frozenset({"done"}),
|
||||
}
|
||||
|
||||
# 阶段筛选 tab 仅覆盖四个可动作阶段;「通知完成」属 done 桶终态,不做筛选维度。
|
||||
_ACTIONABLE_TODO_STAGES: tuple[str, ...] = (
|
||||
"intake_parse", "order_review", "fulfillment_prep", "freight_upload",
|
||||
)
|
||||
# 无 processing_stage 且人工原因不可映射时的 todo_category 粗兜底(与 Gate 映射语义对齐)。
|
||||
_TODO_STAGE_BY_CATEGORY_FALLBACK: dict[str, str] = {
|
||||
"review": "order_review",
|
||||
"exception": "fulfillment_prep",
|
||||
"manual_upload": "freight_upload",
|
||||
}
|
||||
|
||||
# 尚未挂 OT、仍需用户/系统关注的 Intake 解析状态(进入我的待办)。
|
||||
_ORPHAN_INTAKE_TODO_PARSE_STATUSES = frozenset({
|
||||
"created",
|
||||
@@ -2762,12 +2780,14 @@ def _todo_tasks_base_query(
|
||||
customer_needle: str,
|
||||
customer_like: str,
|
||||
task_no: str | None,
|
||||
terminal_kind: str | None = None,
|
||||
):
|
||||
"""
|
||||
构造带精确 category CASE 过滤的 Task 待办查询。
|
||||
|
||||
核心逻辑:可见性 / 客户过滤后,用 _task_todo_category_sql_expr().in_(allowed);
|
||||
done 桶另加终态粗筛。pending/processing 不再用领域标量粗筛,避免与 COUNT 分叉。
|
||||
done 桶另加终态粗筛;terminal_kind 进一步拆分 done 子视图(通知完成 / 驳回作废)。
|
||||
pending/processing 不再用领域标量粗筛,避免与 COUNT 分叉。
|
||||
"""
|
||||
q = _visible_tasks_query_for_todos(user_id, is_admin=is_admin)
|
||||
workflow_review_status = select(ShippingOrderTask.review_status).where(ShippingOrderTask.id == ShippingNotice.order_task_id).scalar_subquery()
|
||||
@@ -2817,6 +2837,17 @@ def _todo_tasks_base_query(
|
||||
),
|
||||
)
|
||||
)
|
||||
# [STEP] 终态子视图过滤:前端「通知完成 / 复核驳回·已作废」子 tab 各取所需;
|
||||
# 口径与分类 CASE 的 done 分支保持一致(上传成功优先,二者互斥)。
|
||||
if terminal_kind == "upload_complete":
|
||||
q = q.filter(upload_success)
|
||||
elif terminal_kind == "reject_void":
|
||||
q = q.filter(
|
||||
db.or_(
|
||||
workflow_review_status == RS_REJECTED,
|
||||
ShippingNotice.lifecycle_status.in_(("voided", "archived", "deleted")),
|
||||
)
|
||||
)
|
||||
return q.filter(_task_todo_category_sql_expr().in_(tuple(sorted(allowed))))
|
||||
|
||||
|
||||
@@ -2825,6 +2856,108 @@ def _active_todo_tasks_scope(user_id: int, *, is_admin: bool = False):
|
||||
return _visible_tasks_query_for_todos(user_id, is_admin=is_admin)
|
||||
|
||||
|
||||
def _classify_todo_lifecycle_stage(
|
||||
category: str,
|
||||
*,
|
||||
pending_human_reason: Any = None,
|
||||
processing_stage: Any = None,
|
||||
) -> str | None:
|
||||
"""
|
||||
按统一生命周期口径归类待办条目的阶段 tab(仅供计数,不替代 ui_state)。
|
||||
|
||||
核心逻辑:与 ``project_lifecycle`` 同优先级——processing_stage 权威 → 人工原因
|
||||
归属 Gate 兜底 → todo_category 粗兜底;结果若不是四个可动作阶段(如 completed
|
||||
映射出的 upload_complete)则返回 None,由调用方跳过,避免污染阶段 tab 计数。
|
||||
|
||||
Args:
|
||||
category: 待办分类 CASE 结果(review/exception/manual_upload/in_progress)。
|
||||
pending_human_reason: OT ``pending_human_reason`` 人工原因码(可空)。
|
||||
processing_stage: OT ``stage`` 已持久化处理阶段(可空)。
|
||||
|
||||
Returns:
|
||||
四个可动作阶段码之一;不可归入时 None。
|
||||
"""
|
||||
stage_key = str(processing_stage or '').strip().lower()
|
||||
if stage_key in LIFECYCLE_STAGE_BY_PROCESSING_STAGE:
|
||||
stage = LIFECYCLE_STAGE_BY_PROCESSING_STAGE[stage_key]
|
||||
else:
|
||||
gate = PROCESS_GATE_REASON_OWNING_GATE.get(str(pending_human_reason or '').strip())
|
||||
if gate in LIFECYCLE_STAGE_BY_GATE:
|
||||
stage = LIFECYCLE_STAGE_BY_GATE[gate]
|
||||
else:
|
||||
stage = _TODO_STAGE_BY_CATEGORY_FALLBACK.get(str(category or ''), 'fulfillment_prep')
|
||||
return stage if stage in _ACTIONABLE_TODO_STAGES else None
|
||||
|
||||
|
||||
def _my_todo_stage_counts(user_id: int, *, is_admin: bool) -> dict[str, int]:
|
||||
"""
|
||||
统计待处理桶在四个可动作阶段的分布,供前端阶段筛选 tab 展示全量计数。
|
||||
|
||||
核心逻辑:Review Case 走统一生命周期投影(候选有效性裁决 接收解析 vs 订单复核);
|
||||
孤儿 Intake 恒为接收解析;Notice / OT 分支一次取回「分类 CASE + OT stage +
|
||||
人工原因」后在 Python 侧归类,避免为计数复制一份 SQL 阶段状态机。
|
||||
|
||||
Returns:
|
||||
{intake_parse, order_review, fulfillment_prep, freight_upload}(含 0 值键)。
|
||||
"""
|
||||
counts: dict[str, int] = {code: 0 for code in _ACTIONABLE_TODO_STAGES}
|
||||
|
||||
def _bump(stage: str | None) -> None:
|
||||
if stage in counts:
|
||||
counts[str(stage)] += 1
|
||||
|
||||
# [STEP 1] 开放 Review Case:复用统一投影,禁止另写候选有效性判断。
|
||||
for case_row in _visible_open_review_cases_query(user_id, is_admin=is_admin).all():
|
||||
projection = _review_case_lifecycle_projection(case_row)
|
||||
_bump(str(projection.get('lifecycle_stage') or '').strip() or None)
|
||||
|
||||
# [STEP 2] 孤儿 Intake(未建 OT 的解析待办)恒为接收解析。
|
||||
counts["intake_parse"] += int(
|
||||
_visible_orphan_intakes_query(user_id, is_admin=is_admin).count()
|
||||
)
|
||||
|
||||
# [STEP 3] Notice 分支:分类 CASE 直接作为列取回,连同 OT stage / 人工原因归类。
|
||||
category_expr = _task_todo_category_sql_expr()
|
||||
ot_stage_subquery = select(ShippingOrderTask.stage).where(
|
||||
ShippingOrderTask.id == ShippingNotice.order_task_id,
|
||||
).scalar_subquery()
|
||||
ot_reason_subquery = select(ShippingOrderTask.pending_human_reason).where(
|
||||
ShippingOrderTask.id == ShippingNotice.order_task_id,
|
||||
).scalar_subquery()
|
||||
notice_rows = (
|
||||
_active_todo_tasks_scope(user_id, is_admin=is_admin)
|
||||
.filter(category_expr.in_(tuple(sorted(_PENDING_TODO_CATEGORIES - {"intake_parse"}))))
|
||||
.with_entities(
|
||||
category_expr.label("category"),
|
||||
ot_stage_subquery.label("ot_stage"),
|
||||
ot_reason_subquery.label("ot_reason"),
|
||||
)
|
||||
.all()
|
||||
)
|
||||
for category, ot_stage, ot_reason in notice_rows:
|
||||
_bump(_classify_todo_lifecycle_stage(
|
||||
category, pending_human_reason=ot_reason, processing_stage=ot_stage,
|
||||
))
|
||||
|
||||
# [STEP 4] OT 分支(库存准备尚未建正式 Notice)同理。
|
||||
ot_category_expr = _order_task_todo_category_sql_expr()
|
||||
ot_rows = (
|
||||
_visible_order_tasks_query_for_todos(user_id, is_admin=is_admin)
|
||||
.filter(ot_category_expr.in_(tuple(sorted(_PENDING_TODO_CATEGORIES - {"intake_parse"}))))
|
||||
.with_entities(
|
||||
ot_category_expr.label("category"),
|
||||
ShippingOrderTask.stage.label("ot_stage"),
|
||||
ShippingOrderTask.pending_human_reason.label("ot_reason"),
|
||||
)
|
||||
.all()
|
||||
)
|
||||
for category, ot_stage, ot_reason in ot_rows:
|
||||
_bump(_classify_todo_lifecycle_stage(
|
||||
category, pending_human_reason=ot_reason, processing_stage=ot_stage,
|
||||
))
|
||||
return counts
|
||||
|
||||
|
||||
def list_my_todos(
|
||||
user_id: int,
|
||||
*,
|
||||
@@ -2835,6 +2968,7 @@ def list_my_todos(
|
||||
todo_category: str | None = None,
|
||||
customer: str | None = None,
|
||||
task_no: str | None = None,
|
||||
terminal_kind: str | None = None,
|
||||
) -> dict[str, Any]:
|
||||
"""
|
||||
分页列出「我的待办」:建单前 Review Case + 未建 OT Intake + 建单后 Task。
|
||||
@@ -2851,6 +2985,7 @@ def list_my_todos(
|
||||
todo_category: 可选细分类覆盖 bucket。
|
||||
customer: 客户名/代码/来源文件名/Case 号/PO/Intake 号模糊过滤。
|
||||
task_no: 精确任务号过滤(仅 Task 项;复核/Intake 项忽略)。
|
||||
terminal_kind: done 桶终态子视图过滤(upload_complete | reject_void);其余 bucket 忽略。
|
||||
|
||||
Returns:
|
||||
{items, page, page_size, total}
|
||||
@@ -2869,6 +3004,7 @@ def list_my_todos(
|
||||
customer_like = f"%{customer_needle}%" if customer_needle else ""
|
||||
include_review_cases = "review" in allowed and not task_no
|
||||
include_orphan_intakes = "intake_parse" in allowed and not task_no
|
||||
normalized_terminal_kind = str(terminal_kind or "").strip().lower() or None
|
||||
|
||||
# [STEP 1] 多端投影为统一列:kind / entity_id / sort_at / sort_ref。
|
||||
branches = []
|
||||
@@ -2915,6 +3051,7 @@ def list_my_todos(
|
||||
customer_needle=customer_needle,
|
||||
customer_like=customer_like,
|
||||
task_no=task_no,
|
||||
terminal_kind=normalized_terminal_kind,
|
||||
)
|
||||
branches.append(
|
||||
tasks_q.with_entities(
|
||||
@@ -3053,14 +3190,17 @@ def list_my_todos(
|
||||
}
|
||||
|
||||
|
||||
def count_my_todos(user_id: int, *, is_admin: bool = False) -> dict[str, int]:
|
||||
def count_my_todos(user_id: int, *, is_admin: bool = False) -> dict[str, Any]:
|
||||
"""
|
||||
统计「我的待办」各 bucket 数量,供导航徽标使用。
|
||||
统计「我的待办」各 bucket 数量,供导航徽标与阶段筛选 tab 使用。
|
||||
|
||||
核心逻辑:开放 Review Case + 未建 OT Intake 计入 pending;Task 用 SQL CASE COUNT。
|
||||
核心逻辑:开放 Review Case + 未建 OT Intake 计入 pending;Task 用 SQL CASE COUNT;
|
||||
阶段 tab 计数与 done 终态拆分见 _my_todo_stage_counts / done_counts 组装。
|
||||
|
||||
Returns:
|
||||
{pending, processing, done, total_pending_badge}
|
||||
{pending, processing, done, total_pending_badge,
|
||||
stage_counts: {intake_parse, order_review, fulfillment_prep, freight_upload},
|
||||
done_counts: {upload_complete, reject_void}}
|
||||
"""
|
||||
workflow_review_status = select(ShippingOrderTask.review_status).where(ShippingOrderTask.id == ShippingNotice.order_task_id).scalar_subquery()
|
||||
artifact_exists = exists(select(1).select_from(ShippingExportArtifact).where(ShippingExportArtifact.task_id == ShippingNotice.id, ShippingExportArtifact.status.in_(('ready', 'uploading', 'uploaded'))))
|
||||
@@ -3077,7 +3217,7 @@ def count_my_todos(user_id: int, *, is_admin: bool = False) -> dict[str, int]:
|
||||
pending += ot_active.filter(ot_category.in_(tuple(sorted(_PENDING_TODO_CATEGORIES - {"intake_parse"})))).count()
|
||||
processing = active.filter(category_expr == "in_progress").count()
|
||||
processing += ot_active.filter(ot_category == "in_progress").count()
|
||||
done = (
|
||||
done_base = (
|
||||
_visible_tasks_query_for_todos(user_id, is_admin=is_admin)
|
||||
.filter(
|
||||
db.or_(
|
||||
@@ -3091,11 +3231,19 @@ def count_my_todos(user_id: int, *, is_admin: bool = False) -> dict[str, int]:
|
||||
)
|
||||
)
|
||||
.filter(category_expr == "done")
|
||||
.count()
|
||||
)
|
||||
done = done_base.count()
|
||||
# done 拆分:已核验上传成功 vs 复核驳回/作废归档;分类 CASE 中上传成功优先,
|
||||
# 故二者互斥,reject_void 用差值即无重叠计数。
|
||||
done_upload = done_base.filter(upload_success).count()
|
||||
return {
|
||||
"pending": pending,
|
||||
"processing": processing,
|
||||
"done": done,
|
||||
"total_pending_badge": pending,
|
||||
"stage_counts": _my_todo_stage_counts(user_id, is_admin=is_admin),
|
||||
"done_counts": {
|
||||
"upload_complete": done_upload,
|
||||
"reject_void": max(0, done - done_upload),
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,227 @@
|
||||
"""
|
||||
backend/tests/test_shipping_done_line_report.py
|
||||
|
||||
用途:已完成通知明细行报表(done-lines)查询与专用导出的单测。
|
||||
依赖:pytest、openpyxl、ShippingNotice/OT/Snapshot/Artifact 夹具、done_line_report。
|
||||
逻辑:覆盖 12 字段映射(typed 列 + field_values_json 回源与回退)、可见性(非本人不可见、
|
||||
未上传成功不进报表)、客户/料号/发货通知日期筛选、分页、导出表头与留空行为。
|
||||
"""
|
||||
|
||||
from datetime import date, datetime, timedelta
|
||||
|
||||
import pytest
|
||||
from openpyxl import load_workbook
|
||||
|
||||
from app.models import (
|
||||
ShippingNotice,
|
||||
ShippingOrderExtraction,
|
||||
ShippingOrderField,
|
||||
ShippingOrderSchema,
|
||||
ShippingOrderSchemaVersion,
|
||||
ShippingOrderSnapshot,
|
||||
ShippingOrderSnapshotLine,
|
||||
ShippingOrderTask,
|
||||
ShippingExportArtifact,
|
||||
ShippingExcelTemplate,
|
||||
ShippingInventoryParsingProfile,
|
||||
)
|
||||
from app.services.shipping_notice.done_line_report import (
|
||||
DONE_REPORT_HEADERS,
|
||||
build_done_lines_xlsx,
|
||||
list_done_notice_lines,
|
||||
)
|
||||
|
||||
|
||||
def _seed_report_fixture(db, *, owner: int):
|
||||
"""最小报表夹具:一张已完成双行通知 + 一张仅 ready 未上传的通知(应被排除)。"""
|
||||
order = ShippingOrderTask(task_no="OT-DONE-LINE", source_type="direct_pdf", user_id=owner)
|
||||
pending_order = ShippingOrderTask(task_no="OT-DONE-LINE-PENDING", source_type="direct_pdf", user_id=owner)
|
||||
notice = ShippingNotice(task_no="SN-DONE-LINE", source_type="manual", user_id=owner)
|
||||
pending_notice = ShippingNotice(task_no="SN-DONE-LINE-PENDING", source_type="manual", user_id=owner)
|
||||
db.session.add_all([order, pending_order, notice, pending_notice])
|
||||
template = ShippingExcelTemplate(
|
||||
template_code='DONELINE', display_name='DoneLine', version=1, status='published',
|
||||
storage_bucket='test', storage_key='done.xlsx', original_filename='done.xlsx',
|
||||
file_checksum='a' * 64, definition_json={},
|
||||
)
|
||||
profile = ShippingInventoryParsingProfile(
|
||||
profile_code='DONELINE', display_name='DoneLine', version=1, status='published',
|
||||
file_format='xlsx', definition_json={},
|
||||
)
|
||||
schema = ShippingOrderSchema(schema_code='DONELINE', display_name='DoneLine')
|
||||
db.session.add_all([template, profile, schema])
|
||||
db.session.flush()
|
||||
version = ShippingOrderSchemaVersion(
|
||||
schema_id=schema.id, version=1, status='published', definition_json={'fields': []},
|
||||
)
|
||||
db.session.add(version)
|
||||
db.session.flush()
|
||||
extraction = ShippingOrderExtraction(
|
||||
schema_version_id=version.id, input_snapshot_hash='b' * 64, status='accepted',
|
||||
)
|
||||
db.session.add(extraction)
|
||||
db.session.flush()
|
||||
|
||||
# 标准字段资产:约定出货日期(行级)与来源单号(表头级),值为 field_id 键 JSON。
|
||||
db.session.add(ShippingOrderField(
|
||||
id='f-req-date', field_code='required_date', scope='line', value_type='date',
|
||||
field_category='order_line', collection_mode='deterministic_context',
|
||||
asset_kind='system_standard', storage_mode='typed_column', storage_column='required_date',
|
||||
))
|
||||
db.session.add(ShippingOrderField(
|
||||
id='f-source-order', field_code='source_order_number', scope='header', value_type='string',
|
||||
field_category='order_header', collection_mode='deterministic_context',
|
||||
asset_kind='system_standard', storage_mode='json_only',
|
||||
))
|
||||
db.session.flush()
|
||||
|
||||
snapshot = ShippingOrderSnapshot(
|
||||
task_id=order.id, extraction_id=extraction.id, schema_version_id=version.id,
|
||||
order_data_version=1,
|
||||
customer_name='HYVE CS', customer_code='HC001', customer_po_number='306085',
|
||||
order_date=date(2026, 6, 1), required_date=date(2026, 6, 15),
|
||||
header_values_json={'f-source-order': '8301-2606010052'},
|
||||
)
|
||||
db.session.add(snapshot)
|
||||
db.session.flush()
|
||||
db.session.add_all([
|
||||
ShippingOrderSnapshotLine(
|
||||
snapshot_id=snapshot.id, position=1, line_no=1,
|
||||
part_number='B3-A08AR10000017-A6', qty=80, unit_price=1525.08,
|
||||
field_values_json={'f-req-date': '2026-06-15'},
|
||||
),
|
||||
ShippingOrderSnapshotLine(
|
||||
snapshot_id=snapshot.id, position=2, line_no=2,
|
||||
part_number='D4-A08AR12000001', qty=1000, unit_price=898.72,
|
||||
field_values_json={},
|
||||
),
|
||||
])
|
||||
order.order_snapshot_id = snapshot.id
|
||||
notice.order_task_id = order.id
|
||||
|
||||
extraction_two = ShippingOrderExtraction(
|
||||
schema_version_id=version.id, input_snapshot_hash='e' * 64, status='accepted',
|
||||
)
|
||||
db.session.add(extraction_two)
|
||||
db.session.flush()
|
||||
pending_snapshot = ShippingOrderSnapshot(
|
||||
task_id=pending_order.id, extraction_id=extraction_two.id, schema_version_id=version.id,
|
||||
order_data_version=1,
|
||||
customer_name='PENDING CS', customer_code='PC001',
|
||||
)
|
||||
db.session.add(pending_snapshot)
|
||||
db.session.flush()
|
||||
db.session.add(ShippingOrderSnapshotLine(
|
||||
snapshot_id=pending_snapshot.id, position=1, line_no=1, part_number='X-1', qty=1,
|
||||
))
|
||||
pending_order.order_snapshot_id = pending_snapshot.id
|
||||
pending_notice.order_task_id = pending_order.id
|
||||
|
||||
def add_artifact(target, *, artifact_no: str, status: str) -> None:
|
||||
"""为 Notice 建立报表口径所需的最小 Artifact。"""
|
||||
db.session.add(ShippingExportArtifact(
|
||||
artifact_no=artifact_no, task_id=target.id, template_id=template.id,
|
||||
order_schema_version_id=version.id, order_extraction_id=extraction.id,
|
||||
inventory_parsing_profile_id=profile.id, input_checksum='c' * 64,
|
||||
file_path=f'/tmp/{artifact_no}.xlsx', file_name=f'{artifact_no}.xlsx',
|
||||
file_checksum='d' * 64, file_size=1, status=status,
|
||||
))
|
||||
|
||||
add_artifact(notice, artifact_no='ART-DONE-LINE', status='uploaded')
|
||||
add_artifact(pending_notice, artifact_no='ART-DONE-LINE-PENDING', status='ready')
|
||||
db.session.commit()
|
||||
return notice
|
||||
|
||||
|
||||
def test_list_done_notice_lines_maps_standard_fields(app):
|
||||
"""明细行平铺不按 OT 聚合;12 字段含 JSON 回源与表头回退,无数据源字段留空。"""
|
||||
with app.app_context():
|
||||
from app import db
|
||||
|
||||
owner = 88
|
||||
_seed_report_fixture(db, owner=owner)
|
||||
|
||||
result = list_done_notice_lines(owner, page=1, page_size=20)
|
||||
# 断言:仅 uploaded 通知进入报表;两行明细平铺,OT 不聚合。
|
||||
assert result["total"] == 2
|
||||
assert {item["line_no"] for item in result["items"]} == {1, 2}
|
||||
first = next(item for item in result["items"] if item["line_no"] == 1)
|
||||
# 断言:溯源编号 + 标准 12 字段映射。
|
||||
assert first["task_no"] == "SN-DONE-LINE"
|
||||
assert first["customer_name"] == "HYVE CS"
|
||||
assert first["customer_code"] == "HC001"
|
||||
assert first["order_date"] == "2026-06-01"
|
||||
assert first["part_number"] == "B3-A08AR10000017-A6"
|
||||
assert first["qty"] == 80.0
|
||||
# 行级 field_values_json 有值时优先于快照表头 typed 列。
|
||||
assert first["required_date"] == "2026-06-15"
|
||||
assert first["customer_po_number"] == "306085"
|
||||
assert first["source_order_number"] == "8301-2606010052"
|
||||
assert first["unit_price"] == 1525.08
|
||||
# 已用数量 / open qty 当前无数据源,契约留空。
|
||||
assert first["used_qty"] is None
|
||||
assert first["open_qty"] is None
|
||||
second = next(item for item in result["items"] if item["line_no"] == 2)
|
||||
# 断言:行级无 required_date 时回退快照表头 typed 列。
|
||||
assert second["required_date"] == "2026-06-15"
|
||||
assert second["source_order_number"] == "8301-2606010052"
|
||||
|
||||
# 断言:其他用户不可见(非管理员仅创建者)。
|
||||
assert list_done_notice_lines(999)["total"] == 0
|
||||
|
||||
|
||||
def test_list_done_notice_lines_filters_and_pagination(app):
|
||||
"""客户/料号/发货通知日期筛选与按明细行分页生效。"""
|
||||
with app.app_context():
|
||||
from app import db
|
||||
|
||||
owner = 89
|
||||
_seed_report_fixture(db, owner=owner)
|
||||
|
||||
# 客户模糊(大小写不敏感)。
|
||||
assert list_done_notice_lines(owner, customer="hyve")["total"] == 2
|
||||
assert list_done_notice_lines(owner, customer="不存在")["total"] == 0
|
||||
# 料号模糊(命中单行)。
|
||||
part_page = list_done_notice_lines(owner, part_number="B3-")
|
||||
assert part_page["total"] == 1
|
||||
assert part_page["items"][0]["part_number"] == "B3-A08AR10000017-A6"
|
||||
# 发货通知日期范围:今天闭区间命中;未来区间为空。
|
||||
today = datetime.utcnow().date()
|
||||
assert list_done_notice_lines(
|
||||
owner, notice_date_from=today.isoformat(), notice_date_to=today.isoformat(),
|
||||
)["total"] == 2
|
||||
tomorrow = (today + timedelta(days=1)).isoformat()
|
||||
assert list_done_notice_lines(owner, notice_date_from=tomorrow)["total"] == 0
|
||||
# 按明细行分页。
|
||||
page_one = list_done_notice_lines(owner, page=1, page_size=1)
|
||||
page_two = list_done_notice_lines(owner, page=2, page_size=1)
|
||||
assert page_one["total"] == 2
|
||||
assert {page_one["items"][0]["line_no"], page_two["items"][0]["line_no"]} == {1, 2}
|
||||
|
||||
|
||||
def test_build_done_lines_xlsx_writes_fixed_twelve_columns(app):
|
||||
"""导出严格 12 列标准格式:OT 编号不落列,无数据源列留空。"""
|
||||
with app.app_context():
|
||||
from app import db
|
||||
|
||||
owner = 90
|
||||
_seed_report_fixture(db, owner=owner)
|
||||
|
||||
stream, filename = build_done_lines_xlsx(owner)
|
||||
assert filename.startswith("done-lines-") and filename.endswith(".xlsx")
|
||||
workbook = load_workbook(stream)
|
||||
sheet = workbook.active
|
||||
rows = list(sheet.iter_rows(values_only=True))
|
||||
# 断言:表头为固定 12 列中文标准格式。
|
||||
assert tuple(rows[0]) == DONE_REPORT_HEADERS
|
||||
# 断言:两行明细,且不含 OT 编号列;数量/单价写数值,无数据源列留空。
|
||||
assert len(rows) == 3
|
||||
first_data = rows[1]
|
||||
assert first_data[0] == "HYVE CS"
|
||||
assert first_data[3] == 1
|
||||
assert first_data[4] == "B3-A08AR10000017-A6"
|
||||
assert first_data[5] == 80.0
|
||||
assert first_data[8] is None
|
||||
assert first_data[9] is None
|
||||
assert first_data[10] == "8301-2606010052"
|
||||
assert first_data[11] == 1525.08
|
||||
@@ -0,0 +1,125 @@
|
||||
"""
|
||||
backend/tests/test_shipping_my_todo_stage_counts.py
|
||||
|
||||
用途:「我的待办」count 聚合扩展单测(阶段 tab 计数 + 已完成子终态拆分)。
|
||||
依赖:pytest、ShippingNotice / ShippingOrderTask / Artifact 夹具、query_service.count_my_todos。
|
||||
逻辑:覆盖 processing_stage 权威 / 人工原因归属 Gate / todo_category 兜底三路阶段归类;
|
||||
done 桶拆分为已核验上传成功与 复核驳回/作废 两类终态计数。
|
||||
"""
|
||||
|
||||
import pytest
|
||||
|
||||
from app.models import (
|
||||
ShippingNotice,
|
||||
ShippingOrderTask,
|
||||
ShippingExportArtifact,
|
||||
ShippingExcelTemplate,
|
||||
ShippingInventoryParsingProfile,
|
||||
ShippingOrderSchema,
|
||||
ShippingOrderSchemaVersion,
|
||||
ShippingOrderExtraction,
|
||||
)
|
||||
from app.services.shipping_notice.constants import RS_REJECTED
|
||||
from app.services.shipping_notice.query_service import count_my_todos, list_my_todos
|
||||
|
||||
|
||||
def test_count_my_todos_reports_stage_counts_and_done_breakdown(app):
|
||||
"""阶段 tab 计数按权威口径归类;done 拆分为上传成功与驳回作废两类。"""
|
||||
with app.app_context():
|
||||
from app import db
|
||||
|
||||
owner = 77
|
||||
# [STEP] 四个待处理条目分别覆盖三路归类路径:
|
||||
# OT.stage 权威(waiting_review→订单复核)、原因映射(upload_rpa_failed→货代上传、
|
||||
# inventory_source_unresolved→通知准备)、类别兜底(artifact ready 人工上传→货代上传)。
|
||||
review_task = ShippingOrderTask(
|
||||
task_no="OT-STAGE-REVIEW", stage="waiting_review",
|
||||
source_type="direct_pdf", user_id=owner,
|
||||
)
|
||||
upload_rpa_task = ShippingOrderTask(
|
||||
task_no="OT-STAGE-UPLOAD-RPA", pending_human_reason="upload_rpa_failed",
|
||||
source_type="direct_pdf", user_id=owner,
|
||||
)
|
||||
inventory_task = ShippingOrderTask(
|
||||
task_no="OT-STAGE-INVENTORY", pending_human_reason="inventory_source_unresolved",
|
||||
source_type="direct_pdf", user_id=owner,
|
||||
)
|
||||
rejected_task = ShippingOrderTask(
|
||||
task_no="OT-STAGE-REJECTED", review_status=RS_REJECTED,
|
||||
source_type="direct_pdf", user_id=owner,
|
||||
)
|
||||
manual_task = ShippingOrderTask(
|
||||
task_no="OT-STAGE-MANUAL", source_type="direct_pdf", user_id=owner,
|
||||
)
|
||||
manual_notice = ShippingNotice(task_no="SN-STAGE-MANUAL", source_type="manual", user_id=owner)
|
||||
done_notice = ShippingNotice(task_no="SN-STAGE-DONE", source_type="manual", user_id=owner)
|
||||
rejected_notice = ShippingNotice(task_no="SN-STAGE-REJECTED", source_type="manual", user_id=owner)
|
||||
db.session.add_all([
|
||||
review_task, upload_rpa_task, inventory_task, rejected_task, manual_task,
|
||||
manual_notice, done_notice, rejected_notice,
|
||||
])
|
||||
template = ShippingExcelTemplate(
|
||||
template_code='STAGE', display_name='Stage', version=1, status='published',
|
||||
storage_bucket='test', storage_key='stage.xlsx', original_filename='stage.xlsx',
|
||||
file_checksum='a' * 64, definition_json={},
|
||||
)
|
||||
profile = ShippingInventoryParsingProfile(
|
||||
profile_code='STAGE', display_name='Stage', version=1, status='published',
|
||||
file_format='xlsx', definition_json={},
|
||||
)
|
||||
schema = ShippingOrderSchema(schema_code='STAGE', display_name='Stage')
|
||||
db.session.add_all([template, profile, schema])
|
||||
db.session.flush()
|
||||
version = ShippingOrderSchemaVersion(
|
||||
schema_id=schema.id, version=1, status='published', definition_json={},
|
||||
)
|
||||
db.session.add(version)
|
||||
db.session.flush()
|
||||
extraction = ShippingOrderExtraction(
|
||||
schema_version_id=version.id, input_snapshot_hash='b' * 64, status='accepted',
|
||||
)
|
||||
db.session.add(extraction)
|
||||
db.session.flush()
|
||||
manual_notice.order_task_id = manual_task.id
|
||||
rejected_notice.order_task_id = rejected_task.id
|
||||
|
||||
def add_artifact(notice, *, artifact_no: str, status: str) -> ShippingExportArtifact:
|
||||
"""为 Notice 建立待办分类所需的最小正式 Excel Artifact。"""
|
||||
artifact = ShippingExportArtifact(
|
||||
artifact_no=artifact_no, task_id=notice.id, template_id=template.id,
|
||||
order_schema_version_id=version.id, order_extraction_id=extraction.id,
|
||||
inventory_parsing_profile_id=profile.id, input_checksum='c' * 64,
|
||||
file_path=f'/tmp/{artifact_no}.xlsx', file_name=f'{artifact_no}.xlsx',
|
||||
file_checksum='d' * 64, file_size=1, status=status,
|
||||
)
|
||||
db.session.add(artifact)
|
||||
return artifact
|
||||
|
||||
# 人工上传待登记(ready→manual_upload);已完成(uploaded→done/upload_complete);
|
||||
# 驳回终态(ready 但 OT 复核驳回→done/reject_void)。
|
||||
add_artifact(manual_notice, artifact_no='ART-STAGE-MANUAL', status='ready')
|
||||
add_artifact(done_notice, artifact_no='ART-STAGE-DONE-UP', status='uploaded')
|
||||
add_artifact(rejected_notice, artifact_no='ART-STAGE-REJ', status='ready')
|
||||
db.session.commit()
|
||||
|
||||
counts = count_my_todos(owner)
|
||||
|
||||
# 断言:四个待处理条目按权威口径落入正确阶段 tab。
|
||||
assert counts["pending"] == 4
|
||||
assert counts["stage_counts"] == {
|
||||
"intake_parse": 0,
|
||||
"order_review": 1,
|
||||
"fulfillment_prep": 1,
|
||||
"freight_upload": 2,
|
||||
}
|
||||
# 断言:done 拆分——uploaded Artifact 计上传成功,OT 复核驳回计驳回作废。
|
||||
assert counts["done"] == 2
|
||||
assert counts["done_counts"] == {"upload_complete": 1, "reject_void": 1}
|
||||
|
||||
# 断言:terminal_kind 子视图过滤——两个终态子 tab 各自只取对应集合,互不重叠。
|
||||
upload_page = list_my_todos(owner, bucket="done", terminal_kind="upload_complete")
|
||||
assert {item["task_no"] for item in upload_page["items"]} == {"SN-STAGE-DONE"}
|
||||
reject_page = list_my_todos(owner, bucket="done", terminal_kind="reject_void")
|
||||
assert {item["task_no"] for item in reject_page["items"]} == {"SN-STAGE-REJECTED"}
|
||||
# 无过滤参数时保持既有行为:done 全量。
|
||||
assert list_my_todos(owner, bucket="done")["total"] == 2
|
||||
@@ -5,6 +5,41 @@
|
||||
> **同步维护**:流程、字段规则、人工确认节点等变更时,**须同时更新本文件与** **`business.md`**。\
|
||||
> **Dify 文档维护原则**:Dify 编排仅在本文件维护,且以**节点级配置**为准;重点维护各节点的职责、输入、输出、条件、Tool 绑定与连线关系,不再额外维护独立 DSL 解读文档。\
|
||||
|
||||
## 我的待办改版:列表优先 + 按需抽屉 + 已完成明细报表(2026-09-16)
|
||||
|
||||
任务中心「我的待办」(`/workspace/shipping-notice/my-tasks`)布局与数据契约改版,设计稿见 [`docs/superpowers/prototypes/2026-09-16-my-tasks-redesign.html`](../../superpowers/prototypes/2026-09-16-my-tasks-redesign.html),实施计划见 [`docs/superpowers/plans/2026-09-16-my-tasks-redesign.md`](../../superpowers/plans/2026-09-16-my-tasks-redesign.md)。
|
||||
|
||||
**布局**:移除右侧常驻详情面板,改为紧凑表格行 + 点击行弹出右侧抽屉(`ShippingTaskDrawer`,分诊决策面板:头部阶段/阻断、逐行明细 `notice_line_summary` 全量列、文件区、底部深链操作;Esc/遮罩关闭)。组件拆分:`ShippingStageTabs`(阶段筛选 tab)、`ShippingTaskTable`(表格 + 批量浮动条)、`ShippingTaskDrawer`、`ShippingDoneLineReport`(通知完成明细报表),共享口径在 `shippingTaskCenterShared.ts`。
|
||||
|
||||
**阶段与桶**:阶段筛选 tab 收敛为四个可动作阶段(`intake_parse/order_review/fulfillment_prep/freight_upload`),计数来自后端 `my-todos/count` 聚合扩展字段 `stage_counts`(Review Case 走统一生命周期投影、Intake 恒为接收解析、Notice/OT 以 processing_stage 权威 → 人工原因归属 Gate → 类别兜底归类);「通知完成」不再是筛选维度,done 桶拆子视图 tab(`done_counts`:`upload_complete` / `reject_void`)。
|
||||
|
||||
**已完成桶**:默认子视图「通知完成」为跨 OT 平铺的明细行报表(`GET /shipping-tasks/my-todos/done-lines`),行 = 标准 12 字段(客户/客户编号/订单日期/订单项次/料号/数量/约定出货日期/客户PO/已用数量/open qty/订单单号/单价)+ 页面溯源列(`business_no||task_no`);筛选支持 客户 / 料号 / 发货通知日期(Notice created_at)范围,按明细行分页;导出 `GET .../done-lines/export` 严格 12 列中文表头(OT 不落列,openpyxl 直写,不注册模板)。已用数量/open qty 后端暂无数据源,契约留空;约定出货日期取行级 `required_date`(缺失回退快照表头列)、订单单号取表头 `source_order_number`(field_id 键)、单价取行 `unit_price`。「复核驳回 / 已作废」子视图走既有任务表 + 抽屉,`my-todos` 新增 `terminal_kind` 参数(`upload_complete|reject_void`)服务端过滤。
|
||||
|
||||
**批量操作**:仅「货代上传」阶段的正式 Notice 行有复选框(`isFreightUploadRow`),勾选 ≥1 后浮出深色操作条(下载 ZIP / 确认已上传 / 发起 RPA / 清除),无常驻工具栏;修复批量按钮 i18n 裸 key(`workspace.shippingNotice.batch.*` 此前误挂 `schedule.batch`,已在四语言归位补齐)。新增页面文案(表格/终态角标/子视图/抽屉/报表列头等)已同步 zh-CN / zh-TW / en / th。
|
||||
|
||||
## 阻塞原因具体化:资格快照回退 + 原因/动作语义分离(2026-09-17)
|
||||
|
||||
**背景**:批次中心与工作台「当前任务」对建单前 Review Case 一律显示兜底文案「当前步骤需要人工处理」(同卡重复两遍),而具体原因(如 `customer_unresolved`「客户尚未确认」)早已随资格评估持久化在 `draft.validation_result_json.issues[].explainability`,只是从未进入 `blocking_reason` 通道。
|
||||
|
||||
**后端**(`reconciliation_projector.py`,单一裁决点):`project_review_case_projection_bundle` 在 automation 未携带具体原因码时,回退到 validation 快照的首要 blocking issue(跳过降级为 `unknown_business_failure` 的条目),透传冻结 explainability 契约的 `code / message / next_action / details(field_code, line_index, owning_gate_code)`——不新造任何文案映射;`project_case_blocking_reason` 的 fail-closed 兜底键从不存在的 `shipping.review.blocked_generic` 修正为前端真实存在的 `chat.shippingProcessing.reasonCode.unknown`。`BlockingReason` TypedDict 新增 `message` / `next_action` 可选字段(加法变更,向后兼容)。
|
||||
|
||||
**前端**:①`shippingProcessingLabels.isGenericBlockingReason` 升级判定(Gate 三命名空间任一命中或契约 `message` 非空即具体原因),新增 `resolveBlockingReasonText`(i18n_key → reasonCode → Gate 命名空间 → message,通用兜底返回空串);②批次中心卡(`ShippingConversationProcessingCard`)原因行改用该解析链,未知码不再渲染「当前步骤需要人工处理」空话,workbench 模式下任务卡头原因行由文件行页脚独家承载(去重);③工作台「当前任务」卡(`ReviewCurrentProcessingCard`)「下一步」优先消费 `blocking_reason.next_action` 渲染 `processGate.actionCodes.*` 建议动作(语义=做什么,而非为什么),且具体阻断原因在场时隐藏泛化的 Run 级 statusDetail。原因(客户尚未确认)与动作(确认客户)全链路文案均复用既有契约与四语言目录,未新增文案键。
|
||||
|
||||
**补充收口(同日)**:联调发现两处断点——①批次中心叶子摘要路径(`shipping_processing_projection._leaf`)对建单前 Case 直接下发 `{'code': f'review_case_{status}'}`(前端解析为「订单草稿待处理」状态文案);现新增 `_review_case_blocking_reason` 回退:`reason` 为 `review_case_*` 时从闭包内已批量加载的 `drafts_by_id` 取当前 Draft 校验快照,透传首要资格 issue(零额外查询),无可用 issue 保持状态码兜底。②API 归一化层(`normalizeShippingProcessing.normalizeBlockingReason`)白名单剥离了 `message`/`next_action`,致工作台「下一步」退化为原因文案;现保留两个透传字段(camel/snake 兼容)。
|
||||
|
||||
## CheckPoint 遗留 step_key 彻底清除(2026-09-17)
|
||||
|
||||
**背景缺陷**:`set_task_step_progress`(`tool_common.py`)历史上把 CheckPoint 时代 step_key(`step1_notice_submit` / `step2_parse_confirm` / `step3_inventory_prepare` / `step5_match_inventory` / `step6_generate_file` / `step7_upload_freight`)直接写入 `OT.stage` 与 `OT.current_step`。库存 RPA 失败上报曾把已建单 OT 的 `stage=order_creating` 踩回 `step3_inventory_prepare`;该值不在冻结 15 阶契约(`SHIPPING_PROCESSING_STAGES`)内,工作台投影回退到 Run 的识别期阶段 `candidate_creating`,五阶段步进器因此把已建单订单拉回「接收解析」(`project_lifecycle` 的 processing_stage 权威高于 Gate)。
|
||||
|
||||
**彻底清除(不留兼容层)**:
|
||||
|
||||
- **写路径**:`set_task_step_progress` 入参 `step_key` 改名 `stage`,必须传 15 阶契约码(非法值 `ValueError` 立即失败);`current_step` 与 `current_step_progress` 载荷字段同步改存/改名 `stage`;`OT.stage` 写入带**只进不退守卫**(按 `shipping_processing_stage_index`,仅允许推进或平齐,禁止回退),进度上报永远无法再拉低阶段。
|
||||
- **29 个调用点**全部改传契约码:库存准备/映射/RPA → `inventory_fetching`;库存匹配/文件入库 → `inventory_matching`;Excel 生成 → `excel_generating`;货代上传 → `freight_uploading`;通知重提交/解析确认 → `order_creating` / `waiting_review`。
|
||||
- **读路径别名全部删除**:`lifecycle_projection.LIFECYCLE_STAGE_BY_PROCESSING_STAGE` 与 `processing_projection_invariants._USER_STAGE_TO_CODE` 中的 4 个 stepN_* 别名条目移除,映射表只认契约码;`map_notice_to_processing_status_stage` 对 `current_step` 的子串/前缀启发式(`'upload' in step` / `startswith('step7')` 等)改为契约码精确匹配。
|
||||
- **存量数据**:不落数据迁移——各环境确认无需要清洗的 stepN_* 存量,写路径切换后不再产生新遗留值。
|
||||
- **前端**:`ShippingCurrentStepProgress.step_key` 字段改名 `stage`(无组件消费该字段,仅类型同步)。
|
||||
- **测试**:跨面一致性新增守护用例 `test_stage_mapping_rejects_checkpoint_legacy_keys`(阶段映射禁止任何 stepN_* 键);各测试夹具的遗留字面量已替换为契约码。
|
||||
|
||||
## 五阶段 UI 状态契约(2026-08)
|
||||
|
||||
业务人员只看到五个阶段:`intake_parse`(接收解析)→ `order_review`(订单复核)→ `fulfillment_prep`(通知准备)→ `freight_upload`(货代上传)→ `upload_complete`(通知完成)。`ui_state` 是唯一前端读模型;Gate/Execution 是业务门禁真相。正式 Task 的操作使用 `ui_state.actions.primary/secondary`,批次 / 生命周期投影的操作使用 `ui_state.primary_action/secondary_actions`;两者均由后端下发,前端不得根据领域字段自行推导阶段或按钮;`process_status` 已删除。
|
||||
@@ -399,6 +434,8 @@ L1 字段级:目标单元格 + 表头 + 相邻单元格
|
||||
|
||||
**版面签名证据一致性(2026-08-04)**:表头签名不再扫描整页顶部或按表高固定比例猜测,而是直接冻结模板既有 `header_layout.region`;运行时对每个候选在同一区域独立取证。新旧 PDF 坐标证据统一按视觉行和纯几何词间距恢复表头词组,避免 `boundary_before` 有无造成同文件签名漂移;列中心和列宽由表头词组边界产生,不再使用全表单字符连续聚类。只有同时达到模板最低分和证据覆盖率的候选才参与唯一性与 Margin 决胜。
|
||||
|
||||
**表头身份原子按 Schema 别名归一(2026-09-16)**:无必选锚点模板的两道表头硬门禁——原子集全等互斥(`profile_header_discriminator_conflict`)与软评分硬门槛(`profile_header_signature_conflict`,score<0.35)——在传入 Run 冻结 Schema 编译的表头契约(`compile_table_header_contract().header_to_field`)后,签名侧与观测侧 token 均先按别名归一为字段语义类(`schema_canonical_header_atoms` / `schema_canonical_header_tokens`:贪心最长别名短语匹配,命中归并为 `field::<code>`,未命中词保留词级原子;casefold 后跨字段碰撞的别名短语弃用)再比较/评分。**同字段同义列名不再误杀**(如 `Requested Arrival Date` ≡ `Requested Ship Date`,含 provider 单元格粘连与空格噪声),原子全等互斥的互斥强度与 0.35 硬门槛本身不变;二次机会仅在无锚点前提、契约非空且原始分<0.35 时参与门槛(`effective=max(原始,canonical)`),七维上报的 `header_semantic_position` 维持原始分。别名的同义词治理唯一入口是 Schema 字段 `aliases`(发布碰撞校验沿用);`header_to_field=None` 的调用路径行为不变,已发布模板签名无需重冻结。背景:PO_6075316 因日期列名变体全模板 0 分转人工空单;测试环境 Schema v1(行 id=4)已原位补 `Requested Ship Date` 别名(checksum 同步重算)。
|
||||
|
||||
**邮件补充重建规则(2026-07-31)**:邮件表头只能按当前 Run 冻结 Schema 的显式别名映射;行级 `reservation_id` 包含真实业务表头 `External reservation ID`。只要 Intake 保留原始 `body_html_tables`,Run 冻结时必须按自己的 Schema 重新解析完整补充表,不能复用上传阶段缺字段但已有部分行的旧结果;没有 HTML 时才复用已有完整结果或安全回退纵向纯文本解析。**关联收紧(2026-09-15)**:`mpn_fallback` 仅适用于补充行 PO 缺失且料号唯一命中;有 PO 且与 PDF 不一致不得补充。预约号允许短数字行序后缀归一(如 `35354-1` → `35354`)。**无 PO 表头(2026-09-16)**:分配表缺 PO 列但已映射料号或预约号时仍解析补充行(`po_header_missing` 仅作可观测标记);无身份列时仍整表跳过。
|
||||
|
||||
**`llm_extraction` 回退语义(2026-08-01)**:订单字段标记为 `llm_extraction` 表示“确定性解析无法取值时允许 LLM 补充”,不表示必须使用 LLM。通用解析门禁应依据字段是否已有完整、无冲突的确定性证据裁决;已取得必填 Header/Line 值时可直通,缺失时由 `required_field_missing` 转入 LLM/人工复核。
|
||||
@@ -1366,6 +1403,8 @@ OpenCV 当前结论:可保留为 L0/L2 的严格有框表候选和后续人工
|
||||
- 管理端只列出当前 published Schema 中 `enabled=true`、Header 文本类型且 `available_for_customer_identity=true` 的字段。规则集发布时重新校验字段仍可用,不能仅依赖草稿创建时状态。
|
||||
- Resolver 只读取 Candidate 所属 Extraction 中 accepted/corroborated Header FieldValue。EML From、模板指纹、原始 LLM 输出和 Candidate 摘要均不能作为旁路证据。
|
||||
- 规则快照冻结 `context_field_id` 与完整 `field_config`;字段退役、删除或新 Schema 移除引用字段时由定义和草稿/发布规则快照共同阻断。
|
||||
- 客户命中分三级(2026-09-17 起,`shadow-v3`):① canonical 等值(NFKC+casefold+剔除非字母数字,中文保留;吸收标点/空白/大小写打印差异);② 完整包含(注册指纹整体出现在提取值中,指纹 canonical 长度 ≥8);③ 截断包含(提取值疑似指纹截断片段,同 8 字符下限)。证据归一化在导入、影子识别与自动确认复核三处共用 `normalize_identity_evidence_value`(兜底分支折叠内部空白/换行)。邮箱/域名指纹只做精确等值,禁止包含比较;短于 8 字符的指纹由等值路径承担,不享受包含兜底。
|
||||
- 自动确认边界:①级唯一命中且证据 `auto_match_allowed` → `unique_strong_match`;②级唯一且授权 → `unique_containment_match`(审计证据带 `match_kind=containment_strong`);③级与未授权证据永不自动确认,只进入复核面板候选建议。等值命中存在时包含命中不参与裁决;任务期协调器与复核「重新识别」按钮共用 `resolve_auto_customer_decision` 同一裁决,质量门禁分母包含两类唯一命中。
|
||||
- 本阶段为不兼容升级:迁移清空旧定义、规则集、证据、影子匹配及其审计快照,然后物理删除旧适配器列;不提供运行时兼容映射。
|
||||
|
||||
### 阶段 4 可靠性、监控与故障注入
|
||||
|
||||
+3
-1
@@ -22,6 +22,8 @@
|
||||
- 订单复核:核对订单并确认正式建单。
|
||||
- 通知准备:库存处理、匹配和生成发货通知 Excel;一个 `shipping_notice` 对应一张发货通知单、一个单号和一个 Excel,可包含多条订单明细;RPA 超时优先重新读取已产生的库存结果,用户可再明确选择重新获取库存(RPA)。
|
||||
- 货代上传:下载 Excel、RPA 上传、按发货通知单号人工确认已上传、失败恢复和未知结果核对;未知结果禁止自动重试。
|
||||
- 我的待办改版(2026-09-16):紧凑表格 + 按需详情抽屉;阶段筛选 tab 计数后端全量聚合(仅四个可动作阶段);批量操作仅货代上传阶段可勾选、勾选后浮动操作条;已完成桶拆子视图——「通知完成」为跨单平铺明细报表(客户/料号/发货通知日期筛选,按明细行分页,导出严格 12 列标准 Excel),「复核驳回/已作废」为任务表 + 抽屉。
|
||||
- 阻塞原因具体化(2026-09-17):批次中心/工作台对建单前 Case 回退消费草稿校验快照的首要阻断 issue(冻结 explainability 契约透传 code/message/next_action),展示「客户尚未确认」等具体原因;「下一步」渲染建议动作文案;通用兜底码不再渲染,同卡重复原因行去重。
|
||||
- 通知完成:只读展示已核验的上传成功证据;仅 Task 聚合、全部预约单与成功 Upload Attempt 同时满足时显示并计入完成。
|
||||
- 通知完成:上传通知或登记上传回执;仅服务端确认的上传 Attempt 成功后显示完成结果。
|
||||
- 货代发货会话主区域为批次进度中心:有会话即全屏常驻展示(不可关闭),无会话显示欢迎页与附件提交入口;历史会话点击直达中心
|
||||
@@ -117,7 +119,7 @@
|
||||
| EML 正文补充表合并(阶段 2) | 已实现 | 正文 HTML 表解析为带 DOM 单元格证据的 PO 级补充事实,不创建独立订单或执行 Unit;按 `PO + MPN`、受限 PO 降级补 Reservation/Allocation/库存来源提示,支持 `External reservation ID` 等冻结 Schema 显式别名;每个 Run 从原始 HTML 重建,避免旧的部分解析结果遮蔽新规则;PDF 数量保持权威,歧义统一进入人工复核 |
|
||||
| PDF 模板 PO 拆分与严格拒识(阶段 3) | 已实现 | 已批准模板中每条明细均有唯一 PO 证据时,单 PDF 自动拆为多个独立订单;表级多 PO 未能归属明细、模板歧义、漂移和证据不足统一转人工复核,Route Decision 分别审计四类表计数 |
|
||||
| 订单模板版本中心(阶段 0-7) | 已实现 | 订单文档模板按 `profile_code` 聚合版本族;已落地独立版本详情、历史只读样本画布、服务端语义差异、审计记录页签、实际使用页签,以及阶段 7 的 blind test 隔离与发布治理;只读画布完整展示必需锚点及各受控标签区域的冻结识别值,必需锚点可对照配置值、识别值和匹配状态;标注取字、运行匹配与版本诊断统一按视觉行恢复字符阅读顺序;标注 Reservation ID 专区的模板跨页以 `Vendor Comments` 至首次 `Terms and Condition(s)` 作为语义边界读取预约单号,未标注模板保持原解析路径 |
|
||||
| **订单模板版面签名 Matcher** | 代码已落地(待真实样本灰度) | 版面签名存 ValidationRun;Profile 轻量引用;Matcher 三态证据 + Top-N 解析验证;表头签名直接消费既有 `header_layout.region`,签名生成与运行时统一视觉词组和坐标口径;跨模板发布门禁与发布检查页;重识别亲和性校验签名;`SHIPPING_NOTICE_PROFILE_LAYOUT_SIGNATURE_REQUIRED` 控制全量切换。说明:[order-profile-layout-signature.md](features/shipping-notice/order-profile-layout-signature.md) |
|
||||
| **订单模板版面签名 Matcher** | 代码已落地(待真实样本灰度) | 版面签名存 ValidationRun;Profile 轻量引用;Matcher 三态证据 + Top-N 解析验证;表头签名直接消费既有 `header_layout.region`,签名生成与运行时统一视觉词组和坐标口径;跨模板发布门禁与发布检查页;重识别亲和性校验签名;表头身份原子按 Run 冻结 Schema 别名归一,同字段同义列名(如 Requested Arrival/Ship Date)不再触发表头硬互斥;`SHIPPING_NOTICE_PROFILE_LAYOUT_SIGNATURE_REQUIRED` 控制全量切换。说明:[order-profile-layout-signature.md](features/shipping-notice/order-profile-layout-signature.md) |
|
||||
| **XFA 数据路径 Profile(统一回退)** | 代码收口(2026-08-18) | datasets + 拆分规则为首选;失败进入普通 PDF 共用 PDFium/Widget/OCR 证据链,保留 `fallback_from`、原因码与 `value_source`,回退候选固定 Review、禁止 STP;Dify 主链:**NONE**。 |
|
||||
| **XFA 统一视觉标注 + 字段拆分** | 统一入口已收口 | 普通 PDF/XFA 共用 Editor、`/pdf-automark` Job、保存、验证和发布 DTO;`value_binding` + `visual_binding`、RE2、统一 CQ/STP;XFA 仅在首选 datasets 取值与拆分规则上保留适配器差异。 |
|
||||
| **XFA 可见值回读补偿** | 已实现(2026-08-25) | 编辑器在原生坐标、服务端 OCR 与唯一 Widget 无值后,OCR 同一 PDF.js XFA 画布的受控裁剪图(`xfa_rendered_ocr`);仍无值保留值框并提示诊断,可继续绑定 datasets。裁剪图不持久化,datasets 仍为唯一正式值源。 |
|
||||
|
||||
@@ -0,0 +1,89 @@
|
||||
# 实施计划:我的待办改版(列表优先 + 按需抽屉 + 已完成明细报表)
|
||||
|
||||
日期:2026-09-16 分支:`hugo-shipping-notice` 设计稿:`docs/superpowers/prototypes/2026-09-16-my-tasks-redesign.html`
|
||||
|
||||
## 背景与目标
|
||||
|
||||
货代发货通知「我的待办」页(`/workspace/shipping-notice/my-tasks`)当前为「卡片列表 + 常驻右侧详情」布局,存在:列表卡片过重、详情面板信息重复低价值、阶段卡片只统计当前页失真、批量工具栏常驻且 i18n key 缺失显示原始 key 等问题。本次改版目标:
|
||||
|
||||
1. 列表改为紧凑表格 + 按需抽屉(待处理/处理中/驳回作废);
|
||||
2. 阶段筛选收敛为 4 个可动作阶段,计数后端全量聚合;
|
||||
3. 「已完成」桶拆子视图:通知完成 = 明细平铺报表(可筛选、按明细行分页、导出 Excel);复核驳回/已作废 = OT 级列表 + 抽屉;
|
||||
4. 批量操作改为情境式浮动条(仅货代上传阶段、勾选后出现);
|
||||
5. 顺带修复 batch i18n key 错位。
|
||||
|
||||
## 已确认的设计决策
|
||||
|
||||
- 待处理列表:紧凑表格行 = [复选框(仅货代上传)] 编号+类别角标+副行(客户·PO·文件) / 阶段徽章 / 状态摘要(阻断红色) / 项次·缺口 / 货代状态;点行开抽屉。
|
||||
- 阶段 tab:`全部 | 接收解析 | 订单复核 | 通知准备 | 货代上传`,计数来自后端聚合(待处理桶),点击即筛选。
|
||||
- 抽屉:头部(编号/客户/PO/阶段/阻断) + 逐行明细(notice_line_summary 全量列) + 文件区 + 底部操作(沿用 ui_state 权限裁决;review/intake 分支迁入)。
|
||||
- 已完成桶子视图 tab:`通知完成(N) | 复核驳回/已作废(M)`。
|
||||
- 通知完成报表:明细行平铺不按 OT 聚合;页面首列 OT 编号;列 = OT编号 + 标准12字段(客户/客户编号/订单日期/订单项次/料号/数量/约定出货日期/客户PO/已用数量/open qty/订单单号/单价);筛选 = 客户 + 料号 + 发货通知日期范围;按明细行分页。
|
||||
- 导出 Excel:**严格 12 列**(不带 OT 列),专用平铺导出器(不注册模板、不走 per-Notice 模板机制);已用数量/open qty 暂留空。
|
||||
- 字段映射:约定出货日期→`required_date`;订单单号→`source_order_number`;单价→`unit_price`(Schema 未启用则为空);料号→`part_number`。
|
||||
- 批量:无常驻工具栏;货代上传行有复选框,勾选≥1 浮出深色操作条(下载 Excel/确认上传/发起 RPA),全选仅作用当前筛选结果。
|
||||
- 无数据库结构变更、无迁移、无新增依赖。
|
||||
|
||||
## 任务清单(TDD,顺序执行)
|
||||
|
||||
### T1 后端:count 接口扩展(阶段聚合 + 已完成子计数)
|
||||
- `query_service.count_my_todos` 返回结构增加:
|
||||
- `stage_counts: {intake_parse, order_review, fulfillment_prep, freight_upload}`(待处理桶按生命周期阶段聚合,复用既有 lifecycle stage SQL/投影口径);
|
||||
- `done_counts: {upload_complete, reject_or_void}`(done 桶:已核验上传成功 vs 复核驳回∪作废/归档)。
|
||||
- API `GET /shipping-tasks/my-todos/count`(`api/workspace/shipping_notice.py`)透传新字段;保持既有 key(pending/processing/done/total_pending_badge)不变。
|
||||
- 测试:`backend/tests/` 新增/扩展 count 聚合用例(覆盖四阶段计数与 done 两种终态归类)。
|
||||
- 验证:`pytest` 相关用例绿。
|
||||
|
||||
### T2 后端:my-todos 列表支持终态过滤参数
|
||||
- `list_my_todos` 增加可选参数 `terminal_kind`(仅 bucket=done 时生效):`upload_complete` → 仅已核验上传成功;`reject_void` → 仅 复核驳回 ∪ 作废/归档。
|
||||
- 测试:参数过滤用例。
|
||||
- 验证:`pytest` 绿。
|
||||
|
||||
### T3 后端:已完成明细行级查询接口
|
||||
- 新增 service 查询(query_service 或独立模块):跨已完成 Notice 平铺行明细,join 冻结 ShippingOrderSnapshot 行字段。
|
||||
- 返回行字段:`task_no(OT编号), customer_name, customer_code, order_date, line_no, part_number, qty, required_date, customer_po_number, used_qty(None), open_qty(None), source_order_number, unit_price`。
|
||||
- 筛选:`customer`(名称/简码模糊)、`part_number`(模糊)、`notice_date_from/to`(发货通知日期=Notice 创建日期范围);`page/page_size`(默认 20,上限 100)+ `total`。
|
||||
- API:`GET /api/workspace/shipping-tasks/my-todos/done-lines`。
|
||||
- 测试:行字段映射(含字段缺失留空)、筛选、分页用例。
|
||||
- 验证:`pytest` 绿。
|
||||
|
||||
### T4 后端:专用平铺导出器(12 列 xlsx)
|
||||
- 新增导出函数:同 T3 查询(不分页,行数上限 10000 防护),固定写 12 列中文表头,OT 不落列;openpyxl 沿用项目内既有用法。
|
||||
- API:`GET /api/workspace/shipping-tasks/my-todos/done-lines/export`(同筛选参数,流式返回 xlsx)。
|
||||
- 测试:生成的 workbook 表头/行值/空值断言。
|
||||
- 验证:`pytest` 绿。
|
||||
|
||||
### T5 前端:API 层与类型
|
||||
- `features/workspace/api/shipping-tasks.api.ts`:count 返回类型扩展 + done-lines 查询 + 导出下载(复用既有下载工具)。
|
||||
- `features/chat/types/shipping.api.types.ts`:新增行明细类型 `ShippingDoneLineItem` 等。
|
||||
- 验证:`npm run build` 通过(类型层面)。
|
||||
|
||||
### T6 前端:主页面拆分重构(列表态/抽屉态/批量浮动条)
|
||||
- 新组件(`features/workspace/shipping-task-center/`):
|
||||
- `ShippingStageTabs.vue`:阶段 tab(后端计数、点击筛选);
|
||||
- `ShippingTaskTable.vue`:紧凑表格行 + 复选框列(仅货代上传)+ 批量浮动条插槽;
|
||||
- `ShippingTaskDrawer.vue`:抽屉(task/review/intake 三分支 + 文件区 + 操作区,迁移自现页面 1086-1273 行逻辑)。
|
||||
- `ShippingTaskCenterPage.vue`:移除右侧常驻详情与五张阶段卡片;接入新组件;保留桶切换、筛选、分页、轮询(`shippingTaskCenterPolling` 不动)。
|
||||
- 测试:更新 `ShippingTaskCenterPage.notice-batch.spec.ts`(浮动条出现条件、仅货代上传可勾选)+ 新增抽屉渲染测试。
|
||||
- 验证:`npm run test` 相关用例绿;`npm run build` 通过。
|
||||
|
||||
### T7 前端:已完成桶子视图与明细报表
|
||||
- 新组件 `ShippingDoneLineReport.vue`:子视图 tab(通知完成/复核驳回·已作废,计数来自 T1);
|
||||
- 通知完成:13 列表格(OT编号+12字段,横向滚动)+ 客户/料号/发货通知日期筛选 + 按行分页 + 导出按钮(T4 接口);
|
||||
- 复核驳回/已作废:走既有任务列表(T2 参数)+ 抽屉。
|
||||
- 验证:`npm run test` + `npm run build`。
|
||||
|
||||
### T8 i18n 四语言
|
||||
- 修复:`schedule.batch.*` 12 个 key 复制/迁移到各语言 `workspace.json` 的 `shippingNotice.batch`(zh-TW/th 当前整块缺失,按 zh-CN 补齐翻译)。
|
||||
- 新增:阶段 tab、抽屉、报表列头、筛选、终态角标、导出等文案,zh-CN/zh-TW/en/th 四语言同步。
|
||||
- 验证:脚本断言四语言 key 集合一致;页面无裸 key。
|
||||
|
||||
### T9 回归与收尾
|
||||
- 后端:`pytest backend/tests` 全量相关目录通过。
|
||||
- 前端:`npm run test`、`npm run build` 通过。
|
||||
- 文档:`docs/features/shipping-notice/technical.md` 增补改版说明;`funclist.md` 若涉及功能条目变化则同步。
|
||||
- 提交拆分:后端(T1-T4)、前端(T5-T7)、i18n(T8)、文档(T9) 分开提交,遵循 Conventional Commits。
|
||||
|
||||
## 明确不做
|
||||
|
||||
- 虚拟滚动 / 服务端排序 / 保存视图 / 列自定义 / 看板;数据库迁移;新增第三方依赖;通知完成报表行点击行为(后续增量);已用数量、open qty 数据源接入。
|
||||
@@ -0,0 +1,338 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>我的待办 · 改版原型(方案A:列表优先 + 按需抽屉)</title>
|
||||
<style>
|
||||
:root{
|
||||
--blue:#2f7bff; --blue-weak:#eaf1ff; --bg:#f4f6fa; --line:#e5e9f2;
|
||||
--red:#e5484d; --red-weak:#fdecec; --text:#1f2733; --sub:#6b7686;
|
||||
--green:#188a4c; --green-weak:#e6f7ec; --amber:#b26a00; --amber-weak:#fff4e0;
|
||||
--purple:#7a4fd3; --purple-weak:#f1e9ff;
|
||||
}
|
||||
*{box-sizing:border-box;margin:0;padding:0}
|
||||
body{background:#e9edf4;color:var(--text);font-family:"Segoe UI","Microsoft YaHei",system-ui,sans-serif;padding-bottom:80px}
|
||||
|
||||
.proto-banner{position:sticky;top:0;z-index:99;background:#111c33;color:#c6d2e8;padding:10px 22px;font-size:13px;display:flex;gap:12px;align-items:center;flex-wrap:wrap}
|
||||
.proto-banner b{color:#fff}
|
||||
.proto-banner .pill{background:var(--blue);color:#fff;border-radius:999px;padding:2px 10px;font-size:12px;white-space:nowrap}
|
||||
.proto-banner .warn{color:#ffd479;font-size:12px}
|
||||
|
||||
.screen{max-width:1220px;margin:40px auto 0;padding:0 22px}
|
||||
.screen-head{display:flex;align-items:baseline;gap:10px;margin-bottom:12px;flex-wrap:wrap}
|
||||
.chip{background:var(--blue);color:#fff;border-radius:6px;font-weight:700;font-size:13px;padding:2px 9px}
|
||||
.screen-head h2{font-size:17px}
|
||||
.screen-head span{font-size:13px;color:var(--sub)}
|
||||
.frame{background:#fff;border:1px solid var(--line);border-radius:14px;box-shadow:0 10px 30px rgba(31,39,51,.08);overflow:hidden}
|
||||
.notes{margin:10px 4px 0;font-size:12.5px;color:#5b6779;line-height:1.9}
|
||||
.notes i{font-style:normal;color:var(--blue);font-weight:700}
|
||||
|
||||
/* ---- 页面骨架 ---- */
|
||||
.topbar{display:flex;justify-content:space-between;align-items:flex-start;padding:20px 22px 8px}
|
||||
.topbar h1{font-size:22px}
|
||||
.topbar p{font-size:13px;color:var(--sub);margin-top:4px}
|
||||
.seg{display:inline-flex;background:#eef1f7;border-radius:10px;padding:3px;margin:10px 22px 0}
|
||||
.seg button{border:0;background:transparent;padding:7px 18px;border-radius:8px;font-size:13.5px;color:var(--sub);cursor:default}
|
||||
.seg button.on{background:#fff;color:var(--text);font-weight:600;box-shadow:0 1px 4px rgba(31,39,51,.12)}
|
||||
.buckets{display:flex;gap:8px;padding:14px 22px 4px}
|
||||
.bucket{border:1px solid var(--line);background:#fff;border-radius:999px;padding:6px 16px;font-size:13px;color:var(--sub)}
|
||||
.bucket.on{background:var(--blue);border-color:var(--blue);color:#fff;font-weight:600}
|
||||
.stages{display:flex;gap:8px;padding:12px 22px;border-bottom:1px solid var(--line);flex-wrap:wrap}
|
||||
.stage{border:1px solid var(--line);border-radius:999px;padding:5px 14px;font-size:13px;color:var(--sub);background:#fff}
|
||||
.stage b{margin-left:4px}
|
||||
.stage.on{background:var(--blue-weak);border-color:var(--blue);color:var(--blue);font-weight:600}
|
||||
.filters{display:flex;gap:10px;align-items:center;padding:14px 22px;border-bottom:1px solid var(--line);flex-wrap:wrap}
|
||||
.filters select,.filters input{border:1px solid var(--line);border-radius:8px;padding:7px 10px;font-size:13px;color:var(--sub);background:#fff}
|
||||
.filters input{width:190px}
|
||||
.filters .grow{flex:1}
|
||||
.btn{border:1px solid var(--line);background:#fff;border-radius:8px;padding:7px 14px;font-size:13px;color:var(--text)}
|
||||
.btn.primary{background:var(--blue);border-color:var(--blue);color:#fff;font-weight:600}
|
||||
.btn.ghost{color:var(--blue);border-color:#c9dcff}
|
||||
.btn.dark{background:#1b2740;border-color:#1b2740;color:#fff}
|
||||
.btn.sm{padding:5px 11px;font-size:12.5px}
|
||||
|
||||
/* ---- 表格 ---- */
|
||||
table{width:100%;border-collapse:collapse;font-size:13px}
|
||||
th{ text-align:left;color:var(--sub);font-weight:500;padding:10px 14px;border-bottom:1px solid var(--line);background:#fafbfd;white-space:nowrap}
|
||||
td{padding:9px 14px;border-bottom:1px solid #f0f3f8;vertical-align:middle}
|
||||
tr.row:hover td{background:#f7faff}
|
||||
.no{font-weight:600;letter-spacing:.2px}
|
||||
.no .tag{font-weight:400}
|
||||
.sub{color:var(--sub);font-size:12px;margin-top:3px;font-weight:400}
|
||||
.tag{display:inline-block;font-size:11px;color:var(--amber);background:var(--amber-weak);border-radius:4px;padding:1px 6px;margin-left:8px;vertical-align:1px}
|
||||
.tag.blue{color:#3b6fd4;background:#eef4ff}
|
||||
.badge{display:inline-block;padding:2px 10px;border-radius:999px;font-size:12px;white-space:nowrap}
|
||||
.st-intake{background:#eef4ff;color:#3b6fd4}
|
||||
.st-review{background:var(--amber-weak);color:var(--amber)}
|
||||
.st-prepare{background:#e8f3ff;color:#1677d9}
|
||||
.st-upload{background:var(--purple-weak);color:var(--purple)}
|
||||
.st-done{background:var(--green-weak);color:var(--green)}
|
||||
.st-reject{background:var(--red-weak);color:var(--red)}
|
||||
.st-void{background:#eef1f7;color:var(--sub)}
|
||||
.block{color:var(--red)}
|
||||
.short{color:var(--red);font-weight:700}
|
||||
.muted{color:var(--sub)}
|
||||
.pager{display:flex;justify-content:center;align-items:center;gap:18px;padding:14px;font-size:13px;color:var(--sub)}
|
||||
|
||||
/* ---- 批量浮动条 ---- */
|
||||
.batchbar{display:flex;align-items:center;gap:12px;background:#1b2740;color:#e8eefb;padding:10px 18px;font-size:13px}
|
||||
.batchbar .cnt{background:var(--blue);border-radius:999px;padding:2px 12px;font-weight:600}
|
||||
.batchbar .sp{flex:1}
|
||||
|
||||
/* ---- 抽屉态 ---- */
|
||||
.split{position:relative;height:820px;background:var(--bg)}
|
||||
.backdrop{position:absolute;inset:0;overflow:hidden;opacity:.38;filter:grayscale(.2)}
|
||||
.scrim{position:absolute;inset:0;background:rgba(23,32,51,.35)}
|
||||
.drawer{position:absolute;top:0;right:0;bottom:0;width:540px;max-width:94%;background:#fff;box-shadow:-16px 0 40px rgba(15,23,42,.25);display:flex;flex-direction:column}
|
||||
.d-head{padding:18px 22px 12px;border-bottom:1px solid var(--line)}
|
||||
.d-head .t{display:flex;justify-content:space-between;align-items:center}
|
||||
.d-head .t h3{font-size:17px;letter-spacing:.2px}
|
||||
.d-head .x{border:0;background:#eef1f7;border-radius:8px;width:28px;height:28px;color:var(--sub);font-size:14px}
|
||||
.d-head .meta{font-size:12.5px;color:var(--sub);margin-top:6px}
|
||||
.d-body{flex:1;overflow:auto;padding:16px 22px}
|
||||
.banner{background:var(--red-weak);border:1px solid #f5c6c8;color:var(--red);border-radius:10px;padding:10px 14px;font-size:13px;margin-bottom:16px}
|
||||
.sec{font-size:13px;font-weight:700;margin:18px 0 8px;display:flex;align-items:center;gap:8px}
|
||||
.sec::after{content:"";flex:1;height:1px;background:var(--line)}
|
||||
.mini td,.mini th{padding:7px 10px;font-size:12.5px}
|
||||
.mini td.num{font-variant-numeric:tabular-nums}
|
||||
.chip-red{background:var(--red-weak);color:var(--red);border-radius:4px;padding:1px 7px;font-size:11.5px;font-weight:700}
|
||||
.chip-gray{background:#eef1f7;color:var(--sub);border-radius:4px;padding:1px 7px;font-size:11.5px}
|
||||
.file{display:flex;align-items:center;gap:10px;border:1px solid var(--line);border-radius:10px;padding:9px 12px;font-size:13px;margin-bottom:8px}
|
||||
.file .ic{width:30px;height:30px;border-radius:8px;background:#eef4ff;color:#3b6fd4;display:flex;align-items:center;justify-content:center;font-size:12px;font-weight:700}
|
||||
.file .sp{flex:1}
|
||||
.file a{color:var(--blue);font-size:12.5px;text-decoration:none}
|
||||
.d-foot{border-top:1px solid var(--line);padding:14px 22px;display:flex;flex-direction:column;gap:10px;background:#fff}
|
||||
.d-foot .r1{display:flex;gap:10px}
|
||||
.d-foot select{border:1px solid var(--line);border-radius:8px;padding:8px 10px;font-size:13px;color:var(--text)}
|
||||
.d-foot .r1 .btn.primary{flex:1}
|
||||
.d-foot .r2{display:flex;gap:10px;align-items:center}
|
||||
.link{color:var(--blue);font-size:12.5px;text-decoration:none}
|
||||
.d-foot .hint{font-size:11.5px;color:var(--sub)}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div class="proto-banner">
|
||||
<span class="pill">设计原型 · 静态稿</span>
|
||||
<b>货代发货通知「我的待办」改版</b>
|
||||
<span>方案 A:列表优先 + 按需抽屉 · 2026-09-16</span>
|
||||
<span class="warn">仅用于评审,非实现代码</span>
|
||||
</div>
|
||||
|
||||
<!-- ================= 状态 1:列表态 ================= -->
|
||||
<div class="screen">
|
||||
<div class="screen-head"><span class="chip">状态 1</span><h2>列表态(全部 tab)</h2><span>卡片列表 → 紧凑表格;右侧常驻详情面板移除</span></div>
|
||||
<div class="frame">
|
||||
<div class="topbar">
|
||||
<div><h1>我的待办</h1><p>按文件查看接收解析与订单生命周期进度;处理详情在订单生命周期工作台完成。</p></div>
|
||||
<button class="btn">⟳ 刷新</button>
|
||||
</div>
|
||||
<div class="seg"><button class="on">我的待办</button><button>我的识别</button></div>
|
||||
<div class="buckets"><span class="bucket on">待处理(13)</span><span class="bucket">处理中(0)</span><span class="bucket">已完成(0)</span></div>
|
||||
<div class="stages">
|
||||
<span class="stage on">全部<b>13</b></span>
|
||||
<span class="stage">接收解析<b>2</b></span>
|
||||
<span class="stage">订单复核<b>4</b></span>
|
||||
<span class="stage">通知准备<b>3</b></span>
|
||||
<span class="stage">货代上传<b>4</b></span>
|
||||
</div>
|
||||
<div class="filters">
|
||||
<select><option>待办类型:全部</option></select>
|
||||
<input placeholder="客户名称或简码">
|
||||
<input placeholder="SN 编号">
|
||||
<span class="grow"></span>
|
||||
<button class="btn primary">应用筛选</button>
|
||||
<button class="btn">重置</button>
|
||||
</div>
|
||||
<table>
|
||||
<thead><tr>
|
||||
<th style="width:36px"></th><th>编号 / 客户 · PO · 文件</th><th style="width:90px">阶段</th>
|
||||
<th>状态摘要</th><th style="width:96px">项次/缺口</th><th style="width:88px">货代状态</th>
|
||||
</tr></thead>
|
||||
<tbody>
|
||||
<tr class="row"><td></td>
|
||||
<td><div class="no">SORC-25CEF2F1FA504685<span class="tag">订单复核</span></div><div class="sub">微软 · PO_6075309.pdf</div></td>
|
||||
<td><span class="badge st-review">订单复核</span></td><td>复核草稿待继续编辑</td><td class="muted">—</td><td class="muted">—</td></tr>
|
||||
<tr class="row"><td></td>
|
||||
<td><div class="no">OT-20260916-769EF9D3-C680</div><div class="sub">华为 · PO_6075309 · PO_6075309.pdf</div></td>
|
||||
<td><span class="badge st-prepare">通知准备</span></td><td class="block">库存存在缺口,需人工处理</td><td><b>5 项</b> · <span class="short">缺 1</span></td><td class="muted">—</td></tr>
|
||||
<tr class="row"><td></td>
|
||||
<td><div class="no">OT-20260916-769EF9D3-C679</div><div class="sub">华为 · PO_6075310 · PO_6075310.pdf</div></td>
|
||||
<td><span class="badge st-prepare">通知准备</span></td><td class="block">库存存在缺口,需人工处理</td><td><b>4 项</b> · <span class="short">缺 2</span></td><td class="muted">—</td></tr>
|
||||
<tr class="row"><td><input type="checkbox"></td>
|
||||
<td><div class="no">OT-20260916-04BCBB1A</div><div class="sub">中兴 · PO_6075312 · PO_6075312.xlsx</div></td>
|
||||
<td><span class="badge st-upload">货代上传</span></td><td>备货完成,可上传货代</td><td><b>3 项</b></td><td>待上传</td></tr>
|
||||
<tr class="row"><td><input type="checkbox"></td>
|
||||
<td><div class="no">OT-20260916-04BCBB1B</div><div class="sub">中兴 · PO_6075313 · PO_6075313.xlsx</div></td>
|
||||
<td><span class="badge st-upload">货代上传</span></td><td>已上传,待确认</td><td><b>6 项</b></td><td>已上传</td></tr>
|
||||
<tr class="row"><td></td>
|
||||
<td><div class="no">INT-20260916-7712<span class="tag blue">材料解析</span></div><div class="sub">东风 · DFM_PO_0091.pdf</div></td>
|
||||
<td><span class="badge st-intake">接收解析</span></td><td>解析完成,待确认明细</td><td class="muted">—</td><td class="muted">—</td></tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="pager">‹ 上一页<span>第 1 / 1 页</span>下一页 ›</div>
|
||||
</div>
|
||||
<div class="notes">
|
||||
<i>①</i> 阶段 tab 计数来自后端聚合(替换现在只统计当前页的五张卡片),点击即筛选;<b>「通知完成」不再是筛选 tab</b>——终态任务统一收进「已完成」桶,行上用角标区分:上传完成 / 复核驳回 / 已作废。<br>
|
||||
<i>②</i> 复选框仅「货代上传」阶段的行存在,其余阶段该列为空。<br>
|
||||
<i>③</i> 点击行任意位置 → 打开右侧详情抽屉(状态 3 / 状态 4);行高约为原卡片一半,一屏可见 12~15 条。
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- ================= 状态 2:批量态 ================= -->
|
||||
<div class="screen">
|
||||
<div class="screen-head"><span class="chip">状态 2</span><h2>批量操作态</h2><span>仅货代上传 tab;勾选 ≥1 后操作条浮出,无常驻工具栏</span></div>
|
||||
<div class="frame">
|
||||
<div class="stages">
|
||||
<span class="stage">全部<b>13</b></span>
|
||||
<span class="stage">接收解析<b>2</b></span>
|
||||
<span class="stage">订单复核<b>4</b></span>
|
||||
<span class="stage">通知准备<b>3</b></span>
|
||||
<span class="stage on">货代上传<b>4</b></span>
|
||||
<span class="stage">通知完成<b>0</b></span>
|
||||
</div>
|
||||
<div class="batchbar">
|
||||
<span class="cnt">已选 2 张</span>
|
||||
<button class="btn sm dark">⬇ 批量下载 Excel</button>
|
||||
<button class="btn sm dark">✓ 批量确认已上传</button>
|
||||
<button class="btn sm dark">▲ 批量发起 RPA</button>
|
||||
<span class="sp"></span>
|
||||
<button class="btn sm" style="background:transparent;color:#9fb0d0;border-color:#3a4a6e">清除选择</button>
|
||||
</div>
|
||||
<table>
|
||||
<thead><tr>
|
||||
<th style="width:36px"><input type="checkbox" checked></th><th>编号 / 客户 · PO · 文件</th><th style="width:90px">阶段</th>
|
||||
<th>状态摘要</th><th style="width:96px">项次/缺口</th><th style="width:88px">货代状态</th>
|
||||
</tr></thead>
|
||||
<tbody>
|
||||
<tr class="row"><td><input type="checkbox" checked></td>
|
||||
<td><div class="no">OT-20260916-04BCBB1A</div><div class="sub">中兴 · PO_6075312 · PO_6075312.xlsx</div></td>
|
||||
<td><span class="badge st-upload">货代上传</span></td><td>备货完成,可上传货代</td><td><b>3 项</b></td><td>待上传</td></tr>
|
||||
<tr class="row"><td><input type="checkbox" checked></td>
|
||||
<td><div class="no">OT-20260916-04BCBB1B</div><div class="sub">中兴 · PO_6075313 · PO_6075313.xlsx</div></td>
|
||||
<td><span class="badge st-upload">货代上传</span></td><td>已上传,待确认</td><td><b>6 项</b></td><td>已上传</td></tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="pager">‹ 上一页<span>第 1 / 1 页</span>下一页 ›</div>
|
||||
</div>
|
||||
<div class="notes">
|
||||
<i>①</i> 深色浮动操作条只在勾选 ≥1 行后出现,替代现在常驻(且 i18n 缺失、显示原始 key)的工具栏。<br>
|
||||
<i>②</i> 表头复选框 = 全选当前筛选结果;离开本阶段 tab 或清除后自动收起。<br>
|
||||
<i>③</i> 按钮文案使用修复后的 <code>shippingNotice.batch.*</code> 四语言 key。
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- ================= 状态 3:抽屉态 ================= -->
|
||||
<div class="screen">
|
||||
<div class="screen-head"><span class="chip">状态 3</span><h2>详情抽屉态</h2><span>点击列表行滑出;逐行明细 = 分诊决策依据</span></div>
|
||||
<div class="frame">
|
||||
<div class="split">
|
||||
<div class="backdrop">
|
||||
<div class="topbar"><div><h1>我的待办</h1><p>按文件查看接收解析与订单生命周期进度。</p></div></div>
|
||||
<div class="buckets"><span class="bucket on">待处理(13)</span></div>
|
||||
<table>
|
||||
<thead><tr><th style="width:36px"></th><th>编号 / 客户 · PO · 文件</th><th style="width:90px">阶段</th><th>状态摘要</th></tr></thead>
|
||||
<tbody>
|
||||
<tr><td></td><td><div class="no">SORC-25CEF2F1FA504685<span class="tag">订单复核</span></div></td><td><span class="badge st-review">订单复核</span></td><td>复核草稿待继续编辑</td></tr>
|
||||
<tr><td></td><td><div class="no" style="outline:2px solid #2f7bff;outline-offset:-2px;border-radius:6px">OT-20260916-769EF9D3-C680</div></td><td><span class="badge st-prepare">通知准备</span></td><td>库存存在缺口</td></tr>
|
||||
<tr><td></td><td><div class="no">OT-20260916-769EF9D3-C679</div></td><td><span class="badge st-prepare">通知准备</span></td><td>库存存在缺口</td></tr>
|
||||
<tr><td><input type="checkbox"></td><td><div class="no">OT-20260916-04BCBB1A</div></td><td><span class="badge st-upload">货代上传</span></td><td>备货完成</td></tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div class="scrim"></div>
|
||||
<div class="drawer">
|
||||
<div class="d-head">
|
||||
<div class="t"><h3>OT-20260916-769EF9D3-C680</h3><button class="x">✕</button></div>
|
||||
<div class="meta">华为 · PO_6075309 · PO_6075309.pdf</div>
|
||||
<div style="margin-top:8px"><span class="badge st-prepare">通知准备 · 当前阶段</span></div>
|
||||
</div>
|
||||
<div class="d-body">
|
||||
<div class="banner">⚠ 阻断:库存存在缺口,需要人工处理 —— 处理详情请在订单生命周期工作台完成。</div>
|
||||
|
||||
<div class="sec">逐行明细(notice_line_summary)</div>
|
||||
<table class="mini">
|
||||
<thead><tr><th>行</th><th>料号</th><th>客户料号</th><th>预约号</th><th>本次发货</th><th>可用库存</th><th>缺口</th><th>状态</th></tr></thead>
|
||||
<tbody>
|
||||
<tr><td class="num">01</td><td>9527-100-A</td><td>HW-100-A</td><td>R20260916-01</td><td class="num">100</td><td class="num">100</td><td class="num">0</td><td><span class="chip-gray">在库</span></td></tr>
|
||||
<tr><td class="num">02</td><td>9527-200-B</td><td>HW-200-B</td><td>R20260916-02</td><td class="num">50</td><td class="num">30</td><td class="num short">20</td><td><span class="chip-red">缺料</span></td></tr>
|
||||
<tr><td class="num">03</td><td>9527-150-C</td><td>—</td><td>—</td><td class="num">20</td><td class="num">20</td><td class="num">0</td><td><span class="chip-gray">在库</span></td></tr>
|
||||
<tr><td class="num">04</td><td>9527-400-D</td><td>HW-400-D</td><td>R20260916-04</td><td class="num">10</td><td class="num">10</td><td class="num">0</td><td><span class="chip-gray">在库</span></td></tr>
|
||||
<tr><td class="num">05</td><td>9527-050-E</td><td>—</td><td>—</td><td class="num">5</td><td class="num">0</td><td class="num short">5</td><td><span class="chip-red">缺料</span></td></tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<div class="sec">文件</div>
|
||||
<div class="file"><span class="ic">源</span>PO_6075309.pdf<span class="sp"></span><a href="#">查看</a></div>
|
||||
<div class="file"><span class="ic">Excel</span>HW-PO_6075309.xlsx(导出)<span class="sp"></span><a href="#">⬇ 下载</a></div>
|
||||
</div>
|
||||
<div class="d-foot">
|
||||
<div class="r1">
|
||||
<select><option>阶段目标:通知准备</option><option>货代上传</option></select>
|
||||
<button class="btn primary">进入订单生命周期工作台</button>
|
||||
</div>
|
||||
<div class="r2">
|
||||
<button class="btn ghost">打开 Chat 会话</button>
|
||||
<a class="link" href="#">重试自动推进</a>
|
||||
<span class="hint">入口与按钮按后端 ui_state 权限裁决显示</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="notes">
|
||||
<i>①</i> 抽屉承载原卡片里塞不下的明细:逐行料号 / 预约号 / 发货量 / 可用量 / 缺口 —— 不用跳转即可判断「这张单能不能走」。<br>
|
||||
<i>②</i> 底部操作条沿用现有三分支逻辑(review / intake / task),权限仍由后端 ui_state 决定。<br>
|
||||
<i>③</i> Esc / 点遮罩 / ✕ 关闭;移动端抽屉全屏。
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- ================= 状态 4:已完成桶(通知完成明细报表) ================= -->
|
||||
<div class="screen">
|
||||
<div class="screen-head"><span class="chip">状态 4</span><h2>已完成桶:通知完成 → 明细报表</h2><span>明细平铺不按 OT 聚合;OT 编号仅页面展示,导出严格 12 列</span></div>
|
||||
<div class="frame">
|
||||
<div class="topbar">
|
||||
<div><h1>我的待办</h1><p>按文件查看接收解析与订单生命周期进度;处理详情在订单生命周期工作台完成。</p></div>
|
||||
<button class="btn">⟳ 刷新</button>
|
||||
</div>
|
||||
<div class="seg"><button class="on">我的待办</button><button>我的识别</button></div>
|
||||
<div class="buckets"><span class="bucket">待处理(13)</span><span class="bucket">处理中(0)</span><span class="bucket on">已完成(45)</span></div>
|
||||
<div class="stages">
|
||||
<span class="stage on">通知完成<b>42</b></span>
|
||||
<span class="stage">复核驳回 / 已作废<b>3</b></span>
|
||||
</div>
|
||||
<div class="filters">
|
||||
<select><option>客户:全部</option></select>
|
||||
<input placeholder="日期范围">
|
||||
<input placeholder="料号">
|
||||
<span class="grow"></span>
|
||||
<button class="btn primary">⬇ 导出 Excel(当前筛选)</button>
|
||||
</div>
|
||||
<div style="overflow-x:auto">
|
||||
<table style="min-width:1560px">
|
||||
<thead><tr>
|
||||
<th>OT 编号</th><th>客户</th><th>客户编号</th><th>订单日期</th><th>订单项次</th><th>料号</th><th>数量</th>
|
||||
<th>约定出货日期</th><th>客户PO</th><th>已用数量</th><th>open qty</th><th>订单单号</th><th>单价</th>
|
||||
</tr></thead>
|
||||
<tbody>
|
||||
<tr class="row"><td class="no">OT-20260916-769EF9D3-C672</td><td>HYVE CS</td><td>HC001</td><td>06-01</td><td>1</td><td>B3-A08AR10000017-A6</td><td class="num">80</td><td>06-15</td><td>306085</td><td class="num">80</td><td class="num">0</td><td>8301-2606010052</td><td class="num">1525.08</td></tr>
|
||||
<tr class="row"><td class="no">OT-20260916-769EF9D3-C672</td><td>FLEX-SLC</td><td>FS002</td><td>06-01</td><td>2</td><td>D4-A08AR12000001</td><td class="num">1000</td><td>06-15</td><td>269T23413</td><td></td><td></td><td>8301-2606010041</td><td class="num">898.72</td></tr>
|
||||
<tr class="row"><td class="no">OT-20260916-769EF9D3-C672</td><td>FLEX-SLC</td><td>FS002</td><td>06-01</td><td>3</td><td>B3-AR1000270A1</td><td class="num">1000</td><td>06-15</td><td>269T23415</td><td></td><td></td><td>8301-2606010043</td><td class="num">50.43</td></tr>
|
||||
<tr class="row"><td class="no">OT-20260916-769EF9D3-C671</td><td>HYVE CS</td><td>HC001</td><td>06-01</td><td>1</td><td>B3-A08AR10000017-A6</td><td class="num">200</td><td>06-18</td><td>306085</td><td class="num">200</td><td class="num">0</td><td>8301-2606010038</td><td class="num">1520.00</td></tr>
|
||||
<tr class="row"><td class="no">OT-20260916-04BCBB09</td><td>FLEX-SLC</td><td>FS002</td><td>06-02</td><td>1</td><td>D4-A08AR12000009</td><td class="num">500</td><td>06-20</td><td>269T23420</td><td class="num">500</td><td class="num">0</td><td>8301-2606010035</td><td class="num">899.50</td></tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div class="pager">‹ 上一页<span>第 1 / 9 页(按明细行分页)</span>下一页 ›</div>
|
||||
</div>
|
||||
<div class="notes">
|
||||
<i>①</i> 已完成桶子视图:`通知完成`=明细报表(平铺、无抽屉、无行级操作);`复核驳回 / 已作废`=仍是 OT 级任务列表 + 抽屉(查驳回原因 / 源文件,可重新处理)。<br>
|
||||
<i>②</i> <b>OT 编号仅页面首列展示,导出 Excel 严格按标准 12 字段</b>(客户/客户编号/订单日期/订单项次/料号/数量/约定出货日期/客户PO/已用数量/open qty/订单单号/单价),OT 只作查询参数不落列。<br>
|
||||
<i>③</i> 已用数量 / open qty 暂留空待接入数据源;默认映射:约定出货日期→required_date、订单单号→source_order_number、单价→unit_price。<br>
|
||||
<i>④</i> 后端新增:明细行级查询(跨 OT 分页/筛选)+ 多 OT 合并导出生成器(复用模板映射引擎);子视图计数并入 count 聚合接口。
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -24,11 +24,57 @@ export interface ShippingMyTodosCount {
|
||||
processing: number;
|
||||
done: number;
|
||||
total_pending_badge: number;
|
||||
/** 待处理桶按可动作生命周期阶段的全量聚合计数(阶段筛选 tab)。 */
|
||||
stage_counts?: {
|
||||
intake_parse: number;
|
||||
order_review: number;
|
||||
fulfillment_prep: number;
|
||||
freight_upload: number;
|
||||
};
|
||||
/** done 桶终态拆分:通知完成 vs 复核驳回/作废。 */
|
||||
done_counts?: {
|
||||
upload_complete: number;
|
||||
reject_void: number;
|
||||
};
|
||||
}
|
||||
|
||||
/** 已完成通知明细行(通知完成报表):标准 12 字段 + 溯源编号。 */
|
||||
export interface ShippingDoneLineItem {
|
||||
task_no: string;
|
||||
business_no: string | null;
|
||||
customer_name: string | null;
|
||||
customer_code: string | null;
|
||||
order_date: string | null;
|
||||
line_no: number;
|
||||
part_number: string | null;
|
||||
qty: number | null;
|
||||
required_date: string | null;
|
||||
customer_po_number: string | null;
|
||||
/** 无数据源,契约占位恒为 null(页面与导出留空)。 */
|
||||
used_qty: number | null;
|
||||
open_qty: number | null;
|
||||
source_order_number: string | null;
|
||||
unit_price: number | null;
|
||||
}
|
||||
|
||||
export interface ShippingDoneLinesPage {
|
||||
items: ShippingDoneLineItem[];
|
||||
page: number;
|
||||
page_size: number;
|
||||
total: number;
|
||||
}
|
||||
|
||||
export interface ShippingDoneLineFilters {
|
||||
customer?: string;
|
||||
part_number?: string;
|
||||
notice_date_from?: string;
|
||||
notice_date_to?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页拉取「我的待办」。
|
||||
* @param params.bucket - pending | processing | done
|
||||
* @param params.terminal_kind - done 桶终态子视图(upload_complete | reject_void)
|
||||
*/
|
||||
export function listWorkspaceShippingMyTodos(params?: {
|
||||
bucket?: 'pending' | 'processing' | 'done' | string;
|
||||
@@ -37,6 +83,7 @@ export function listWorkspaceShippingMyTodos(params?: {
|
||||
todo_category?: string;
|
||||
customer?: string;
|
||||
task_no?: string;
|
||||
terminal_kind?: string;
|
||||
}) {
|
||||
const sp = new URLSearchParams();
|
||||
if (params?.bucket) sp.set('bucket', params.bucket);
|
||||
@@ -45,6 +92,7 @@ export function listWorkspaceShippingMyTodos(params?: {
|
||||
if (params?.todo_category) sp.set('todo_category', params.todo_category);
|
||||
if (params?.customer) sp.set('customer', params.customer);
|
||||
if (params?.task_no) sp.set('task_no', params.task_no);
|
||||
if (params?.terminal_kind) sp.set('terminal_kind', params.terminal_kind);
|
||||
const q = sp.toString();
|
||||
return requestJson<ShippingMyTodosPage>(
|
||||
`/api/workspace/shipping-tasks/my-todos${q ? `?${q}` : ''}`,
|
||||
@@ -58,6 +106,68 @@ export function countWorkspaceShippingMyTodos() {
|
||||
return requestJson<ShippingMyTodosCount>('/api/workspace/shipping-tasks/my-todos/count');
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页拉取已完成通知的平铺明细行(通知完成报表)。
|
||||
* 明细行跨 Notice 混排、不按 OT 聚合,仅含已核验上传成功的通知。
|
||||
*/
|
||||
export function listWorkspaceShippingDoneLines(params?: {
|
||||
page?: number;
|
||||
page_size?: number;
|
||||
} & ShippingDoneLineFilters) {
|
||||
const sp = new URLSearchParams();
|
||||
if (params?.page) sp.set('page', String(params.page));
|
||||
if (params?.page_size) sp.set('page_size', String(params.page_size));
|
||||
if (params?.customer) sp.set('customer', params.customer);
|
||||
if (params?.part_number) sp.set('part_number', params.part_number);
|
||||
if (params?.notice_date_from) sp.set('notice_date_from', params.notice_date_from);
|
||||
if (params?.notice_date_to) sp.set('notice_date_to', params.notice_date_to);
|
||||
const q = sp.toString();
|
||||
return requestJson<ShippingDoneLinesPage>(
|
||||
`/api/workspace/shipping-tasks/my-todos/done-lines${q ? `?${q}` : ''}`,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 下载当前筛选下的已完成通知明细 Excel(固定 12 列标准格式,不含 OT 编号)。
|
||||
* 核心逻辑:浏览器受控 a[download] 下载,后端复核可见性与筛选参数。
|
||||
*/
|
||||
export async function downloadWorkspaceShippingDoneLinesExcel(
|
||||
filters?: ShippingDoneLineFilters,
|
||||
): Promise<void> {
|
||||
const sp = new URLSearchParams();
|
||||
if (filters?.customer) sp.set('customer', filters.customer);
|
||||
if (filters?.part_number) sp.set('part_number', filters.part_number);
|
||||
if (filters?.notice_date_from) sp.set('notice_date_from', filters.notice_date_from);
|
||||
if (filters?.notice_date_to) sp.set('notice_date_to', filters.notice_date_to);
|
||||
const q = sp.toString();
|
||||
const url = `/api/workspace/shipping-tasks/my-todos/done-lines/export${q ? `?${q}` : ''}`;
|
||||
const { getAuthHeaders } = await import('@/shared/utils/auth');
|
||||
const res = await fetch(url, { headers: getAuthHeaders() });
|
||||
if (!res.ok) {
|
||||
const body = await res.json().catch(() => ({}));
|
||||
throw new Error(
|
||||
(body as { error?: string; message?: string })?.error
|
||||
|| (body as { message?: string })?.message
|
||||
|| res.statusText,
|
||||
);
|
||||
}
|
||||
const disposition = res.headers.get('content-disposition');
|
||||
const blob = await res.blob();
|
||||
const objectUrl = URL.createObjectURL(blob);
|
||||
const anchor = document.createElement('a');
|
||||
anchor.href = objectUrl;
|
||||
const rawName = disposition?.match(/filename\*?=(?:UTF-8'')?["']?([^;"'\n]+)/)?.[1] || 'done-lines.xlsx';
|
||||
try {
|
||||
anchor.download = decodeURIComponent(rawName);
|
||||
} catch {
|
||||
anchor.download = rawName;
|
||||
}
|
||||
document.body.appendChild(anchor);
|
||||
anchor.click();
|
||||
document.body.removeChild(anchor);
|
||||
URL.revokeObjectURL(objectUrl);
|
||||
}
|
||||
|
||||
export {
|
||||
downloadWorkspaceShippingExcelFile,
|
||||
markWorkspaceShippingManualUploaded,
|
||||
|
||||
@@ -0,0 +1,181 @@
|
||||
<!--
|
||||
features/workspace/shipping-task-center/ShippingDoneLineReport.vue
|
||||
用途:已完成桶「通知完成」子视图——跨 OT 平铺的明细行报表(13 列 + 筛选 + 导出)。
|
||||
依赖:shipping-tasks.api 类型;导出下载由父级执行。
|
||||
逻辑:只读报表(无抽屉、无行操作);首列 OT/business 编号仅页面展示,
|
||||
导出为固定 12 列标准格式(后端裁决);分页按明细行计。
|
||||
-->
|
||||
<script setup lang="ts">
|
||||
import { Download } from 'lucide-vue-next';
|
||||
import type { ShippingDoneLineItem } from '@/features/workspace/api/shipping-tasks.api';
|
||||
import type { ShippingDoneLineFilters } from '@/features/workspace/api/shipping-tasks.api';
|
||||
|
||||
const props = defineProps<{
|
||||
items: ShippingDoneLineItem[];
|
||||
total: number;
|
||||
page: number;
|
||||
pageSize: number;
|
||||
loading?: boolean;
|
||||
exportBusy?: boolean;
|
||||
filters?: ShippingDoneLineFilters;
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
(event: 'update:filters', value: ShippingDoneLineFilters): void;
|
||||
(event: 'apply'): void;
|
||||
(event: 'page-change', page: number): void;
|
||||
(event: 'export'): void;
|
||||
}>();
|
||||
|
||||
const totalPages = () => Math.max(1, Math.ceil(props.total / props.pageSize));
|
||||
|
||||
function setFilter(key: keyof ShippingDoneLineFilters, event: Event) {
|
||||
const value = String((event.target as HTMLInputElement).value || '');
|
||||
emit('update:filters', { ...props.filters, [key]: value });
|
||||
}
|
||||
|
||||
function onExport(): void {
|
||||
emit('export');
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="space-y-3">
|
||||
<div class="flex flex-wrap items-end gap-3 rounded-2xl border border-default bg-surface px-4 py-3">
|
||||
<label class="space-y-1">
|
||||
<span class="text-xs font-medium text-muted">{{ $t('workspace.shippingNotice.myTodos.doneReport.filters.customer') }}</span>
|
||||
<input
|
||||
type="text"
|
||||
class="input-field text-sm min-w-[10rem]"
|
||||
:value="filters?.customer || ''"
|
||||
:placeholder="$t('workspace.shippingNotice.myTodos.filters.customerPlaceholder')"
|
||||
data-testid="done-lines-filter-customer"
|
||||
@change="setFilter('customer', $event)"
|
||||
@keyup.enter="emit('apply')"
|
||||
>
|
||||
</label>
|
||||
<label class="space-y-1">
|
||||
<span class="text-xs font-medium text-muted">{{ $t('workspace.shippingNotice.myTodos.doneReport.filters.partNumber') }}</span>
|
||||
<input
|
||||
type="text"
|
||||
class="input-field text-sm min-w-[10rem]"
|
||||
:value="filters?.part_number || ''"
|
||||
data-testid="done-lines-filter-part"
|
||||
@change="setFilter('part_number', $event)"
|
||||
@keyup.enter="emit('apply')"
|
||||
>
|
||||
</label>
|
||||
<label class="space-y-1">
|
||||
<span class="text-xs font-medium text-muted">{{ $t('workspace.shippingNotice.myTodos.doneReport.filters.dateFrom') }}</span>
|
||||
<input
|
||||
type="date"
|
||||
class="input-field text-sm"
|
||||
:value="filters?.notice_date_from || ''"
|
||||
data-testid="done-lines-filter-date-from"
|
||||
@change="setFilter('notice_date_from', $event)"
|
||||
>
|
||||
</label>
|
||||
<label class="space-y-1">
|
||||
<span class="text-xs font-medium text-muted">{{ $t('workspace.shippingNotice.myTodos.doneReport.filters.dateTo') }}</span>
|
||||
<input
|
||||
type="date"
|
||||
class="input-field text-sm"
|
||||
:value="filters?.notice_date_to || ''"
|
||||
data-testid="done-lines-filter-date-to"
|
||||
@change="setFilter('notice_date_to', $event)"
|
||||
>
|
||||
</label>
|
||||
<div class="flex gap-2">
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-xl bg-brand-600 px-3 py-1.5 text-sm font-medium text-white hover:bg-brand-700 disabled:opacity-50"
|
||||
:disabled="loading"
|
||||
@click="emit('apply')"
|
||||
>
|
||||
{{ $t('workspace.shippingNotice.myTodos.filters.apply') }}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="inline-flex items-center gap-1.5 rounded-xl border border-brand-300 px-3 py-1.5 text-sm font-medium text-brand-700 hover:bg-brand-50 disabled:opacity-50"
|
||||
:disabled="exportBusy || loading || !total"
|
||||
data-testid="done-lines-export"
|
||||
@click="onExport"
|
||||
>
|
||||
<Download class="h-3.5 w-3.5" />
|
||||
{{ $t('workspace.shippingNotice.myTodos.doneReport.export') }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="loading" class="rounded-2xl border border-dashed border-default py-10 text-center text-sm text-muted">
|
||||
{{ $t('workspace.shippingNotice.loading') }}
|
||||
</div>
|
||||
<div v-else-if="!items.length" class="rounded-2xl border border-dashed border-default py-10 text-center text-sm text-muted">
|
||||
{{ $t('workspace.shippingNotice.myTodos.empty') }}
|
||||
</div>
|
||||
<div v-else class="overflow-x-auto rounded-2xl border border-default bg-surface">
|
||||
<table class="w-full min-w-[1200px] border-collapse text-[13px]" data-testid="done-lines-table">
|
||||
<thead>
|
||||
<tr class="border-b border-default bg-surface-soft/60 text-left text-xs text-muted">
|
||||
<th class="px-3 py-2.5 font-medium">{{ $t('workspace.shippingNotice.myTodos.doneReport.columns.taskNo') }}</th>
|
||||
<th class="px-3 py-2.5 font-medium">{{ $t('workspace.shippingNotice.myTodos.doneReport.columns.customer') }}</th>
|
||||
<th class="px-3 py-2.5 font-medium">{{ $t('workspace.shippingNotice.myTodos.doneReport.columns.customerCode') }}</th>
|
||||
<th class="px-3 py-2.5 font-medium">{{ $t('workspace.shippingNotice.myTodos.doneReport.columns.orderDate') }}</th>
|
||||
<th class="px-3 py-2.5 font-medium">{{ $t('workspace.shippingNotice.myTodos.doneReport.columns.lineNo') }}</th>
|
||||
<th class="px-3 py-2.5 font-medium">{{ $t('workspace.shippingNotice.myTodos.doneReport.columns.partNumber') }}</th>
|
||||
<th class="px-3 py-2.5 font-medium">{{ $t('workspace.shippingNotice.myTodos.doneReport.columns.qty') }}</th>
|
||||
<th class="px-3 py-2.5 font-medium">{{ $t('workspace.shippingNotice.myTodos.doneReport.columns.requiredDate') }}</th>
|
||||
<th class="px-3 py-2.5 font-medium">{{ $t('workspace.shippingNotice.myTodos.doneReport.columns.customerPo') }}</th>
|
||||
<th class="px-3 py-2.5 font-medium">{{ $t('workspace.shippingNotice.myTodos.doneReport.columns.usedQty') }}</th>
|
||||
<th class="px-3 py-2.5 font-medium">{{ $t('workspace.shippingNotice.myTodos.doneReport.columns.openQty') }}</th>
|
||||
<th class="px-3 py-2.5 font-medium">{{ $t('workspace.shippingNotice.myTodos.doneReport.columns.sourceOrderNo') }}</th>
|
||||
<th class="px-3 py-2.5 font-medium">{{ $t('workspace.shippingNotice.myTodos.doneReport.columns.unitPrice') }}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr
|
||||
v-for="line in items"
|
||||
:key="`${line.task_no}-${line.line_no}`"
|
||||
class="border-b border-[#f0f3f8]"
|
||||
>
|
||||
<td class="px-3 py-2 font-mono text-xs font-semibold text-primary">
|
||||
{{ line.business_no || line.task_no }}
|
||||
</td>
|
||||
<td class="px-3 py-2">{{ line.customer_name || '—' }}</td>
|
||||
<td class="px-3 py-2">{{ line.customer_code || '—' }}</td>
|
||||
<td class="px-3 py-2 tabular-nums">{{ line.order_date || '—' }}</td>
|
||||
<td class="px-3 py-2 tabular-nums">{{ line.line_no }}</td>
|
||||
<td class="px-3 py-2 font-mono">{{ line.part_number || '—' }}</td>
|
||||
<td class="px-3 py-2 tabular-nums">{{ line.qty ?? '' }}</td>
|
||||
<td class="px-3 py-2 tabular-nums">{{ line.required_date || '—' }}</td>
|
||||
<td class="px-3 py-2">{{ line.customer_po_number || '—' }}</td>
|
||||
<td class="px-3 py-2 tabular-nums">{{ line.used_qty ?? '' }}</td>
|
||||
<td class="px-3 py-2 tabular-nums">{{ line.open_qty ?? '' }}</td>
|
||||
<td class="px-3 py-2 font-mono">{{ line.source_order_number || '—' }}</td>
|
||||
<td class="px-3 py-2 tabular-nums">{{ line.unit_price ?? '' }}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<div v-if="totalPages() > 1" class="flex items-center justify-between gap-2 text-xs text-muted">
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-lg border border-default px-2 py-1 disabled:opacity-50"
|
||||
:disabled="page <= 1 || loading"
|
||||
@click="emit('page-change', page - 1)"
|
||||
>
|
||||
{{ $t('workspace.shippingNotice.pagination.previous') }}
|
||||
</button>
|
||||
<span>{{ page }}/{{ totalPages() }}</span>
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-lg border border-default px-2 py-1 disabled:opacity-50"
|
||||
:disabled="page >= totalPages() || loading"
|
||||
@click="emit('page-change', page + 1)"
|
||||
>
|
||||
{{ $t('workspace.shippingNotice.pagination.next') }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,63 @@
|
||||
<!--
|
||||
features/workspace/shipping-task-center/ShippingStageTabs.vue
|
||||
用途:阶段筛选 tab(全部 + 四个可动作阶段),计数来自后端全量聚合。
|
||||
依赖:shippingTaskCenterShared 的 ACTIONABLE_TODO_STAGES 口径。
|
||||
逻辑:点击切换筛选并向上同步;「通知完成」不再作为筛选维度(归 done 桶终态子视图)。
|
||||
-->
|
||||
<script setup lang="ts">
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { ACTIONABLE_TODO_STAGES, type LifecycleStageCode } from './shippingTaskCenterShared';
|
||||
|
||||
const { t } = useI18n();
|
||||
|
||||
const props = defineProps<{
|
||||
modelValue: 'all' | LifecycleStageCode;
|
||||
/** 后端聚合的阶段计数(缺省按 0 展示)。 */
|
||||
counts?: Partial<Record<LifecycleStageCode, number>>;
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
(event: 'update:modelValue', value: 'all' | LifecycleStageCode): void;
|
||||
}>();
|
||||
|
||||
function countOf(stage: LifecycleStageCode): number {
|
||||
return Number(props.counts?.[stage] ?? 0);
|
||||
}
|
||||
|
||||
function stageLabel(stage: LifecycleStageCode): string {
|
||||
return t(`workspace.shippingNotice.myTodos.lifecycleStages.${stage}`);
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div
|
||||
class="flex flex-wrap gap-2"
|
||||
data-testid="my-todos-lifecycle-stage-filter"
|
||||
>
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-full px-3.5 py-1.5 text-sm font-medium transition-colors"
|
||||
:class="modelValue === 'all'
|
||||
? 'bg-brand-600 text-white'
|
||||
: 'border border-default text-secondary hover:bg-surface-soft'"
|
||||
data-testid="my-todos-stage-filter-all"
|
||||
@click="emit('update:modelValue', 'all')"
|
||||
>
|
||||
{{ $t('workspace.shippingNotice.myTodos.filters.all') }}
|
||||
</button>
|
||||
<button
|
||||
v-for="stage in ACTIONABLE_TODO_STAGES"
|
||||
:key="stage"
|
||||
type="button"
|
||||
class="rounded-full px-3.5 py-1.5 text-sm font-medium transition-colors"
|
||||
:class="modelValue === stage
|
||||
? 'bg-brand-600 text-white'
|
||||
: 'border border-default text-secondary hover:bg-surface-soft'"
|
||||
:data-testid="`my-todos-stage-filter-${stage}`"
|
||||
@click="emit('update:modelValue', stage)"
|
||||
>
|
||||
{{ stageLabel(stage) }}
|
||||
<span class="ml-1 font-mono text-xs opacity-80">{{ countOf(stage) }}</span>
|
||||
</button>
|
||||
</div>
|
||||
</template>
|
||||
+151
-30
@@ -1,8 +1,10 @@
|
||||
/**
|
||||
* features/workspace/shipping-task-center/ShippingTaskCenterPage.notice-batch.spec.ts
|
||||
* 用途:验收任务中心只按发货通知单 business_no 展示与执行货代批量操作。
|
||||
* 用途:验收任务中心改版——紧凑表格、货代上传阶段限定批量、阶段 tab 后端计数、
|
||||
* done 桶子视图(通知完成明细报表 / 驳回作废任务表)与详情抽屉。
|
||||
* 依赖:ShippingTaskCenterPage、货代 API、我的待办 API、Vue Test Utils。
|
||||
* 逻辑:正式 Notice 可选择并传 business_nos;Review/Intake 不能进入选择集;列表行只显示服务端投影的通知明细。
|
||||
* 逻辑:批量仅正式 Notice 且货代上传阶段可选;明细行详情进抽屉(Teleport 到 body);
|
||||
* 通知完成子视图消费 done-lines 平铺报表;驳回作废子视图带 terminal_kind 过滤。
|
||||
*/
|
||||
import { afterEach, describe, expect, it, vi } from 'vitest';
|
||||
import { flushPromises, mount } from '@vue/test-utils';
|
||||
@@ -14,6 +16,11 @@ const batchConfirm = vi.fn(async () => ({ results: [{ status: 'confirmed' }] }))
|
||||
const batchRpa = vi.fn(async () => ({ results: [{ status: 'accepted' }] }));
|
||||
const downloadArchive = vi.fn(async () => undefined);
|
||||
const listTodos = vi.fn(async () => ({ items: [], page: 1, page_size: 20, total: 0 }));
|
||||
const listDoneLines = vi.fn(async () => ({ items: [], page: 1, page_size: 50, total: 0 }));
|
||||
const downloadDoneLinesExcel = vi.fn(async () => undefined);
|
||||
const countTodos = vi.fn(async () => ({
|
||||
pending: 0, processing: 0, done: 0, total_pending_badge: 0,
|
||||
}));
|
||||
|
||||
vi.mock('@/features/chat/api/shipping.api', () => ({
|
||||
SHIPPING_NOTICE_AGENT_CODE: 'shipping_notice',
|
||||
@@ -26,7 +33,9 @@ vi.mock('@/features/chat/api/shipping.api', () => ({
|
||||
|
||||
vi.mock('@/features/workspace/api/shipping-tasks.api', () => ({
|
||||
listWorkspaceShippingMyTodos: (...args: unknown[]) => listTodos(...args),
|
||||
countWorkspaceShippingMyTodos: vi.fn(async () => ({ pending: 0, processing: 0, done: 0, total_pending_badge: 0 })),
|
||||
countWorkspaceShippingMyTodos: (...args: unknown[]) => countTodos(...args),
|
||||
listWorkspaceShippingDoneLines: (...args: unknown[]) => listDoneLines(...args),
|
||||
downloadWorkspaceShippingDoneLinesExcel: (...args: unknown[]) => downloadDoneLinesExcel(...args),
|
||||
}));
|
||||
|
||||
vi.mock('@/features/workspace/composables/useShippingTodoBadge', () => ({
|
||||
@@ -53,6 +62,7 @@ const i18n = createI18n({
|
||||
subtitle: '按文件查看进度',
|
||||
lifecycleStages: {
|
||||
filterLabel: '阶段',
|
||||
viewStage: '查看阶段',
|
||||
intake_parse: '接收解析',
|
||||
order_review: '订单复核',
|
||||
fulfillment_prep: '通知准备',
|
||||
@@ -60,6 +70,12 @@ const i18n = createI18n({
|
||||
upload_complete: '通知完成',
|
||||
},
|
||||
buckets: { pending: '待处理', processing: '处理中', done: '已完成' },
|
||||
subTabs: { uploadComplete: '通知完成', rejectVoid: '复核驳回 / 已作废' },
|
||||
table: {
|
||||
no: '编号', stage: '阶段', summary: '状态摘要', lines: '项次',
|
||||
lineUnit: '项', shortage: '缺 {count}', freightStatus: '货代状态',
|
||||
},
|
||||
terminal: { uploadComplete: '上传完成', rejectVoid: '复核驳回' },
|
||||
filters: {
|
||||
todoCategory: '待办类型', all: '全部', review: '待复核', exception: '异常',
|
||||
manualUpload: '人工上传', intakeParse: '接收解析', customer: '客户',
|
||||
@@ -75,9 +91,44 @@ const i18n = createI18n({
|
||||
intakeParseBadge: '材料解析',
|
||||
progressSummary: '当前阶段:{stage}',
|
||||
progressBlocker: '当前阻断:{reason}',
|
||||
viewStage: '查看阶段',
|
||||
drawer: {
|
||||
details: '逐行明细',
|
||||
files: '文件',
|
||||
close: '关闭',
|
||||
exportExcel: '导出 Excel',
|
||||
lineTable: {
|
||||
lineNo: '行', partNumber: '料号', customerPartNumber: '客户料号',
|
||||
reservationId: '预约号', shipmentQty: '本次发货', availableQty: '可用库存',
|
||||
shortageQty: '缺口', status: '状态',
|
||||
},
|
||||
},
|
||||
doneReport: {
|
||||
export: '导出 Excel(当前筛选)',
|
||||
exportStarted: '已开始下载',
|
||||
filters: { customer: '客户', partNumber: '料号', dateFrom: '通知日期起', dateTo: '通知日期止' },
|
||||
columns: {
|
||||
taskNo: 'OT 编号', customer: '客户', customerCode: '客户编号', orderDate: '订单日期',
|
||||
lineNo: '订单项次', partNumber: '料号', qty: '数量', requiredDate: '约定出货日期',
|
||||
customerPo: '客户PO', usedQty: '已用数量', openQty: 'open qty',
|
||||
sourceOrderNo: '订单单号', unitPrice: '单价',
|
||||
},
|
||||
},
|
||||
},
|
||||
openChat: '打开对话',
|
||||
batch: {
|
||||
selectAll: '全选当前页通知单',
|
||||
selected: '已选 {count} 张',
|
||||
download: '批量下载 Excel',
|
||||
confirm: '批量确认已上传',
|
||||
rpa: '批量发起 RPA',
|
||||
clearSelection: '清除选择',
|
||||
downloadStarted: '已开始下载',
|
||||
success: '成功 {count} 张',
|
||||
partialResult: '部分成功 {accepted}/{accepted}/{blocked}',
|
||||
},
|
||||
todo: { adminViewOnlyShort: '只读' },
|
||||
actions: { failed: '操作失败' },
|
||||
pagination: { previous: '上一页', next: '下一页' },
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -90,12 +141,17 @@ const routes = [{
|
||||
component: ShippingTaskCenterPage,
|
||||
}];
|
||||
|
||||
/** 待处理货代上传阶段 Notice:批量可选 + 列表投影。 */
|
||||
function notice(businessNo: string, poNumber: string, partNumber: string) {
|
||||
return {
|
||||
id: Number(businessNo.slice(-2)), task_no: `SN-${businessNo}`, business_no: businessNo,
|
||||
item_kind: 'task', todo_ref: `SN-${businessNo}`, source_type: 'post_ot_fulfillment_wave',
|
||||
po_number: poNumber, customer_name: 'Customer', upload_status: 'pending',
|
||||
notice_line_summary: [{ line_no: '10', part_number: partNumber, shipment_qty: '4', available_qty: '9' }],
|
||||
ui_state: { stage: { code: 'freight_upload', label: '货代上传' }, lifecycle_entries: [] },
|
||||
notice_line_summary: [
|
||||
{ line_no: '10', part_number: partNumber, shipment_qty: '4', available_qty: '9' },
|
||||
{ line_no: '20', part_number: `${partNumber}-B`, shipment_qty: '2', available_qty: '9', shortage_qty: 1 },
|
||||
],
|
||||
artifact_summary: { export_file_name: `${businessNo}.xlsx` },
|
||||
};
|
||||
}
|
||||
@@ -115,12 +171,17 @@ async function mountPage() {
|
||||
});
|
||||
}
|
||||
|
||||
function drawerText(): string {
|
||||
return document.body.querySelector('[data-testid="my-todos-drawer"]')?.textContent || '';
|
||||
}
|
||||
|
||||
describe('ShippingTaskCenterPage notice batch operations', () => {
|
||||
afterEach(() => {
|
||||
vi.clearAllMocks();
|
||||
document.body.innerHTML = '';
|
||||
});
|
||||
|
||||
it('only makes formal Notices selectable and displays each Notice projection', async () => {
|
||||
it('only makes freight-upload Notices selectable and shows line details in drawer', async () => {
|
||||
listTodos.mockResolvedValueOnce({
|
||||
items: [
|
||||
notice('WYC26082301', 'PO-100', 'PART-A'),
|
||||
@@ -132,13 +193,20 @@ describe('ShippingTaskCenterPage notice batch operations', () => {
|
||||
const wrapper = await mountPage();
|
||||
await flushPromises();
|
||||
|
||||
// 断言:货代上传阶段 Notice 可勾选;Review/Intake 行无复选框。
|
||||
expect(wrapper.get('[aria-label="WYC26082301"]').exists()).toBe(true);
|
||||
expect(wrapper.get('[aria-label="WYC26082302"]').exists()).toBe(true);
|
||||
expect(wrapper.find('[aria-label="SNRC-30"]').exists()).toBe(false);
|
||||
// 断言:表格副行展示 客户 · PO · 文件。
|
||||
expect(wrapper.text()).toContain('PO-100');
|
||||
expect(wrapper.text()).toContain('PART-A');
|
||||
expect(wrapper.text()).toContain('PART-B');
|
||||
expect(wrapper.text()).toContain('WYC26082301.xlsx');
|
||||
// 断言:点行打开抽屉,逐行明细承载料号(列表不再堆明细)。
|
||||
await wrapper.get('[data-testid="my-todos-row-WYC26082301"]').trigger('click');
|
||||
await flushPromises();
|
||||
expect(document.body.querySelector('[data-testid="my-todos-drawer"]')).not.toBeNull();
|
||||
const drawer = drawerText();
|
||||
expect(drawer).toContain('PART-A');
|
||||
expect(drawer).toContain('PART-A-B');
|
||||
wrapper.unmount();
|
||||
});
|
||||
|
||||
@@ -152,53 +220,106 @@ describe('ShippingTaskCenterPage notice batch operations', () => {
|
||||
await wrapper.get('[aria-label="WYC26082301"]').setValue(true);
|
||||
await wrapper.get('[aria-label="WYC26082302"]').setValue(true);
|
||||
|
||||
const toolbar = wrapper.get('[data-testid="shipping-notice-batch-toolbar"]');
|
||||
const buttons = toolbar.findAll('button');
|
||||
// 断言:勾选后浮出操作条,三个动作按序对应 download/confirm/rpa。
|
||||
// 每次 action 后列表会静默重载(表格重挂载),因此逐次重新查询按钮。
|
||||
const toolbarButtons = () => wrapper
|
||||
.get('[data-testid="shipping-notice-batch-toolbar"]')
|
||||
.findAll('button');
|
||||
const buttons = toolbarButtons();
|
||||
expect(buttons.length).toBeGreaterThanOrEqual(3);
|
||||
await buttons[0].trigger('click');
|
||||
expect(downloadArchive).toHaveBeenCalledWith(['WYC26082301', 'WYC26082302']);
|
||||
|
||||
await buttons[1].trigger('click');
|
||||
await flushPromises();
|
||||
await toolbarButtons()[1].trigger('click');
|
||||
await flushPromises();
|
||||
expect(batchConfirm).toHaveBeenCalledWith(['WYC26082301', 'WYC26082302']);
|
||||
|
||||
await buttons[2].trigger('click');
|
||||
await toolbarButtons()[2].trigger('click');
|
||||
await flushPromises();
|
||||
expect(batchRpa).toHaveBeenCalledWith(['WYC26082301', 'WYC26082302']);
|
||||
wrapper.unmount();
|
||||
});
|
||||
|
||||
it('keeps all five lifecycle stage filters on one wide-screen row', async () => {
|
||||
it('renders one row of stage tabs covering all plus four actionable stages', async () => {
|
||||
const wrapper = await mountPage();
|
||||
await flushPromises();
|
||||
|
||||
const track = wrapper.get('[data-testid="my-todos-lifecycle-stage-filter"]');
|
||||
expect(track.classes()).toContain('xl:grid-cols-5');
|
||||
// 断言:全部 + 四个可动作阶段;「通知完成」不再是筛选维度。
|
||||
expect(track.findAll('button')).toHaveLength(5);
|
||||
expect(track.text()).toContain('货代上传');
|
||||
expect(track.text()).not.toContain('通知完成');
|
||||
expect(track.text()).not.toContain('workspace.shippingNotice.myTodos.lifecycleStages.freight_upload');
|
||||
wrapper.unmount();
|
||||
});
|
||||
|
||||
it('counts a pending review item from its backend stage even without an enterable lifecycle entry', async () => {
|
||||
listTodos.mockResolvedValueOnce({
|
||||
items: [{
|
||||
item_kind: 'review_case',
|
||||
task_no: '',
|
||||
review_run_no: 'RUN-1',
|
||||
review_case_no: 'CASE-1',
|
||||
ui_state: {
|
||||
stage: { code: 'order_review', label: '订单复核', index: 2, total: 5 },
|
||||
lifecycle_entries: [],
|
||||
},
|
||||
}],
|
||||
page: 1,
|
||||
page_size: 20,
|
||||
total: 1,
|
||||
it('shows backend aggregated stage counts instead of current-page counting', async () => {
|
||||
countTodos.mockResolvedValueOnce({
|
||||
pending: 13, processing: 0, done: 0, total_pending_badge: 13,
|
||||
stage_counts: { intake_parse: 2, order_review: 4, fulfillment_prep: 3, freight_upload: 4 },
|
||||
done_counts: { upload_complete: 0, reject_void: 0 },
|
||||
});
|
||||
listTodos.mockResolvedValueOnce({ items: [], page: 1, page_size: 20, total: 0 });
|
||||
const wrapper = await mountPage();
|
||||
await flushPromises();
|
||||
|
||||
expect(wrapper.get('[data-testid="my-todos-stage-filter-order_review"]').text()).toContain('1');
|
||||
// 断言:阶段计数来自后端聚合(当前页为空列表也显示全量计数)。
|
||||
expect(wrapper.get('[data-testid="my-todos-stage-filter-order_review"]').text()).toContain('4');
|
||||
expect(wrapper.get('[data-testid="my-todos-stage-filter-fulfillment_prep"]').text()).toContain('3');
|
||||
wrapper.unmount();
|
||||
});
|
||||
|
||||
it('defaults done bucket to the flat done-lines report and exports current filters', async () => {
|
||||
listDoneLines.mockResolvedValue({
|
||||
items: [{
|
||||
task_no: 'SN-DONE-1', business_no: 'BIZ-1', customer_name: 'HYVE CS', customer_code: 'HC001',
|
||||
order_date: '2026-06-01', line_no: 1, part_number: 'B3-A08AR1', qty: 80,
|
||||
required_date: '2026-06-15', customer_po_number: '306085', used_qty: null,
|
||||
open_qty: null, source_order_number: '8301-1', unit_price: 1525.08,
|
||||
}],
|
||||
page: 1, page_size: 50, total: 1,
|
||||
});
|
||||
const wrapper = await mountPage();
|
||||
await flushPromises();
|
||||
await wrapper.get('[data-testid="my-todos-bucket-done"]').trigger('click');
|
||||
await flushPromises();
|
||||
|
||||
// 断言:done 桶默认进入通知完成明细报表,消费 done-lines 接口。
|
||||
expect(listDoneLines).toHaveBeenCalled();
|
||||
const table = wrapper.get('[data-testid="done-lines-table"]');
|
||||
expect(table.text()).toContain('B3-A08AR1');
|
||||
expect(table.text()).toContain('8301-1');
|
||||
// 断言:导出按钮把当前筛选交给受控下载。
|
||||
await wrapper.get('[data-testid="done-lines-export"]').trigger('click');
|
||||
await flushPromises();
|
||||
expect(downloadDoneLinesExcel).toHaveBeenCalled();
|
||||
wrapper.unmount();
|
||||
});
|
||||
|
||||
it('loads reject_void sub tab with terminal_kind filter and badges rows', async () => {
|
||||
listTodos.mockResolvedValue({
|
||||
items: [{
|
||||
id: 41, task_no: 'SN-REJ-1', business_no: 'BIZ-R1', item_kind: 'task',
|
||||
todo_ref: 'SN-REJ-1', todo_category: 'done',
|
||||
ui_state: { stage: { code: 'upload_complete', label: '通知完成' }, lifecycle_entries: [] },
|
||||
}],
|
||||
page: 1, page_size: 20, total: 1,
|
||||
});
|
||||
const wrapper = await mountPage();
|
||||
await flushPromises();
|
||||
await wrapper.get('[data-testid="my-todos-bucket-done"]').trigger('click');
|
||||
await flushPromises();
|
||||
const subtabs = wrapper.findAll('[data-testid="my-todos-done-subtabs"] button');
|
||||
await subtabs[1].trigger('click');
|
||||
await flushPromises();
|
||||
|
||||
// 断言:驳回/作废子视图按 terminal_kind 拉任务表,行带终态角标。
|
||||
expect(listTodos).toHaveBeenCalledWith(expect.objectContaining({
|
||||
bucket: 'done',
|
||||
terminal_kind: 'reject_void',
|
||||
}));
|
||||
expect(wrapper.get('[data-testid="my-todos-row-BIZ-R1"]').text()).toContain('复核驳回');
|
||||
wrapper.unmount();
|
||||
});
|
||||
});
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,390 @@
|
||||
<!--
|
||||
features/workspace/shipping-task-center/ShippingTaskDrawer.vue
|
||||
用途:任务详情抽屉——分诊决策面板(头部阻断 + 逐行明细 + 文件 + 底部操作)。
|
||||
依赖:shippingTaskCenterShared(阶段口径)、gateReasonLabel。
|
||||
逻辑:review/intake/task 三分支迁移自原任务中心右侧入口卡,行为与深链契约不变;
|
||||
深链/重试只向上 emit,由页面统一执行;阶段目标下拉仍由后端
|
||||
ui_state.lifecycle_entries 裁决(current/available 才可进)。
|
||||
-->
|
||||
<script setup lang="ts">
|
||||
import { computed, onBeforeUnmount, ref, watch } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { Download, ExternalLink, RefreshCw, X } from 'lucide-vue-next';
|
||||
import type {
|
||||
ShippingTaskDetail,
|
||||
ShippingTaskSummary,
|
||||
} from '@/features/chat/api/shipping.api';
|
||||
import {
|
||||
canOpenIntakeParse,
|
||||
defaultLifecycleTarget,
|
||||
lifecycleEntriesOf,
|
||||
lifecycleEntryFor,
|
||||
lifecycleEntryIsEnterable,
|
||||
todoBlockerText,
|
||||
todoDisplayNo,
|
||||
type LifecycleStageCode,
|
||||
type TodoLike,
|
||||
} from './shippingTaskCenterShared';
|
||||
|
||||
const { t, te } = useI18n();
|
||||
|
||||
const props = defineProps<{
|
||||
open: boolean;
|
||||
item: ShippingTaskSummary | ShippingTaskDetail | null;
|
||||
loading?: boolean;
|
||||
chatAgentId: number | null;
|
||||
/** 重试 STP 进行中(页面持有状态)。 */
|
||||
stpRetrying?: boolean;
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
(event: 'close'): void;
|
||||
(event: 'open-intake', item: TodoLike): void;
|
||||
(event: 'open-processing', item: TodoLike, stage: Exclude<LifecycleStageCode, 'intake_parse'>): void;
|
||||
(event: 'open-chat', item: TodoLike): void;
|
||||
(event: 'retry-stp', item: TodoLike): void;
|
||||
}>();
|
||||
|
||||
type EnterableStage = Exclude<LifecycleStageCode, 'intake_parse'>;
|
||||
const stageTarget = ref<EnterableStage>('order_review');
|
||||
|
||||
const isReviewItem = computed(() => {
|
||||
const item = props.item as ShippingTaskSummary | null;
|
||||
if (!item) return false;
|
||||
return item.item_kind === 'review_case' || Boolean(item.review_run_no && !item.task_no);
|
||||
});
|
||||
const isIntakeItem = computed(() => {
|
||||
const item = props.item as ShippingTaskSummary | null;
|
||||
if (!item) return false;
|
||||
return item.item_kind === 'order_intake'
|
||||
|| Boolean(item.intake_no && !item.task_no && !item.review_run_no);
|
||||
});
|
||||
|
||||
const displayNo = computed(() => {
|
||||
if (!props.item) return '—';
|
||||
if ('task_no' in props.item && props.item.task_no
|
||||
&& !isReviewItem.value && !isIntakeItem.value) {
|
||||
return String(props.item.task_no);
|
||||
}
|
||||
return todoDisplayNo(props.item as ShippingTaskSummary);
|
||||
});
|
||||
|
||||
const subTitle = computed(() => {
|
||||
const item = props.item;
|
||||
if (!item) return '';
|
||||
const segments = [
|
||||
String(item.customer_name || '').trim(),
|
||||
String(item.po_number || '').trim() ? `PO ${String(item.po_number).trim()}` : '',
|
||||
String(item.source_file_name || '').trim()
|
||||
|| String(item.artifact_summary?.export_file_name || '').trim(),
|
||||
].filter(Boolean);
|
||||
return segments.join(' · ');
|
||||
});
|
||||
|
||||
const stageLabel = computed(() => {
|
||||
const item = props.item;
|
||||
if (!item) return '';
|
||||
const code = String(item.ui_state?.stage?.code || '').trim();
|
||||
const key = code ? `workspace.shippingNotice.myTodos.lifecycleStages.${code}` : '';
|
||||
if (key && te(key)) return t(key);
|
||||
return String(item.ui_state?.stage?.label || '');
|
||||
});
|
||||
|
||||
const blocker = computed(() => (props.item ? todoBlockerText(props.item, t, te) : ''));
|
||||
|
||||
const summaryMessage = computed(() => String(
|
||||
props.item?.ui_state?.summary?.message
|
||||
|| props.item?.ui_state?.summary?.current_todo
|
||||
|| '',
|
||||
));
|
||||
|
||||
const stageTargetOptions = computed(() => {
|
||||
if (!props.item) return [];
|
||||
return lifecycleEntriesOf(props.item)
|
||||
.filter((entry) => entry.code !== 'intake_parse')
|
||||
.map((entry) => ({
|
||||
code: entry.code as EnterableStage,
|
||||
disabled: entry.state !== 'current' && entry.state !== 'available',
|
||||
}));
|
||||
});
|
||||
|
||||
/** 后端仅授权 current/available;目标不可进时主按钮禁用。 */
|
||||
function canOpenProcessing(stage: EnterableStage | null): boolean {
|
||||
const item = props.item;
|
||||
if (!item) return false;
|
||||
const runNo = String(item.review_run_no || '').trim();
|
||||
const agentId = Number(item.owner_agent_id || props.chatAgentId || 0);
|
||||
const target = stage || defaultLifecycleTarget(item);
|
||||
if (!target) return false;
|
||||
return Boolean(runNo && agentId && lifecycleEntryIsEnterable(lifecycleEntryFor(item, target)));
|
||||
}
|
||||
|
||||
const canOpenIntake = computed(() => canOpenIntakeParse(props.item, props.chatAgentId));
|
||||
|
||||
/** 摘要允许动作里是否含 STP 自动推进重试(与工作台底栏同一契约)。 */
|
||||
const canRetryStp = computed(() => {
|
||||
const item = props.item as ShippingTaskSummary | null;
|
||||
if (!item || item.can_handle === false) return false;
|
||||
if (!String(item.review_case_no || '').trim()) return false;
|
||||
const summaryActions = item.ui_state?.summary?.allowed_actions || [];
|
||||
const actions = [item.ui_state?.actions?.primary, ...(item.ui_state?.actions?.secondary || [])]
|
||||
.filter(Boolean)
|
||||
.map((action) => String(action?.code || ''));
|
||||
return summaryActions.includes('retry_stp_auto_create') || actions.includes('retry_stp_auto_create');
|
||||
});
|
||||
|
||||
const exportFileName = computed(() => String(
|
||||
props.item?.artifact_summary?.export_file_name || '',
|
||||
));
|
||||
|
||||
const lineRows = computed(() => {
|
||||
const item = props.item as ShippingTaskSummary | null;
|
||||
return Array.isArray(item?.notice_line_summary) ? item!.notice_line_summary : [];
|
||||
});
|
||||
|
||||
watch(() => props.item, (item) => {
|
||||
if (!item) return;
|
||||
const stage = defaultLifecycleTarget(item);
|
||||
if (stage) stageTarget.value = stage;
|
||||
}, { immediate: true });
|
||||
|
||||
function onEsc(event: KeyboardEvent) {
|
||||
if (event.key === 'Escape') emit('close');
|
||||
}
|
||||
|
||||
// Esc 关闭抽屉;打开时挂监听,关闭/卸载时移除,避免监听串扰。
|
||||
watch(() => props.open, (open) => {
|
||||
if (open) document.addEventListener('keydown', onEsc);
|
||||
else document.removeEventListener('keydown', onEsc);
|
||||
}, { immediate: true });
|
||||
|
||||
onBeforeUnmount(() => document.removeEventListener('keydown', onEsc));
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Teleport to="body">
|
||||
<div
|
||||
v-if="open"
|
||||
class="fixed inset-0 z-50 flex"
|
||||
data-testid="my-todos-drawer"
|
||||
>
|
||||
<div
|
||||
class="flex-1 bg-[rgba(23,32,51,0.35)]"
|
||||
data-testid="my-todos-drawer-scrim"
|
||||
@click="emit('close')"
|
||||
/>
|
||||
<aside class="flex w-[34rem] max-w-[94vw] flex-col bg-surface shadow-2xl">
|
||||
<div class="border-b border-default px-5 py-4">
|
||||
<div class="flex items-start justify-between gap-3">
|
||||
<h3 class="break-all font-mono text-base font-bold text-primary" data-testid="my-todos-drawer-title">
|
||||
{{ displayNo }}
|
||||
</h3>
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-lg bg-surface-soft px-2 py-1 text-xs text-secondary hover:bg-surface-soft/70"
|
||||
:aria-label="$t('workspace.shippingNotice.myTodos.drawer.close')"
|
||||
data-testid="my-todos-drawer-close"
|
||||
@click="emit('close')"
|
||||
>
|
||||
<X class="h-4 w-4" />
|
||||
</button>
|
||||
</div>
|
||||
<p v-if="subTitle" class="mt-1 text-xs text-muted">{{ subTitle }}</p>
|
||||
<div class="mt-2 flex flex-wrap items-center gap-2">
|
||||
<span
|
||||
v-if="stageLabel"
|
||||
class="rounded-full bg-brand-50 px-2.5 py-0.5 text-xs font-medium text-brand-800"
|
||||
data-testid="my-todos-drawer-stage"
|
||||
>
|
||||
{{ stageLabel }}
|
||||
</span>
|
||||
<span
|
||||
v-if="isReviewItem"
|
||||
class="rounded bg-amber-50 px-1.5 py-0.5 text-[10px] text-amber-700"
|
||||
>{{ $t('workspace.shippingNotice.myTodos.openReview') }}</span>
|
||||
<span
|
||||
v-else-if="isIntakeItem"
|
||||
class="rounded bg-violet-50 px-1.5 py-0.5 text-[10px] text-violet-700"
|
||||
>{{ $t('workspace.shippingNotice.myTodos.intakeParseBadge') }}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="flex-1 overflow-y-auto px-5 py-4">
|
||||
<div v-if="loading" class="py-16 text-center text-sm text-muted">
|
||||
{{ $t('workspace.shippingNotice.loading') }}
|
||||
</div>
|
||||
<template v-else-if="item">
|
||||
<div
|
||||
v-if="blocker"
|
||||
class="mb-4 rounded-xl border border-red-200 bg-red-50 px-3.5 py-2.5 text-[13px] text-red-700"
|
||||
data-testid="my-todos-progress-blocker"
|
||||
>
|
||||
{{ $t('workspace.shippingNotice.myTodos.progressBlocker', { reason: blocker }) }}
|
||||
</div>
|
||||
<p
|
||||
v-if="stageLabel"
|
||||
class="mb-2 text-sm font-medium text-primary"
|
||||
data-testid="my-todos-progress-summary"
|
||||
>
|
||||
{{ $t('workspace.shippingNotice.myTodos.progressSummary', { stage: stageLabel }) }}
|
||||
</p>
|
||||
<p v-if="summaryMessage" class="text-sm text-secondary">{{ summaryMessage }}</p>
|
||||
|
||||
<template v-if="lineRows.length">
|
||||
<h4 class="mb-2 mt-5 text-[13px] font-bold text-primary">
|
||||
{{ $t('workspace.shippingNotice.myTodos.drawer.details') }}
|
||||
</h4>
|
||||
<div class="overflow-x-auto rounded-xl border border-default">
|
||||
<table class="w-full border-collapse text-xs" data-testid="my-todos-drawer-lines">
|
||||
<thead>
|
||||
<tr class="border-b border-default bg-surface-soft/60 text-left text-muted">
|
||||
<th class="px-2.5 py-2 font-medium">{{ $t('workspace.shippingNotice.myTodos.drawer.lineTable.lineNo') }}</th>
|
||||
<th class="px-2.5 py-2 font-medium">{{ $t('workspace.shippingNotice.myTodos.drawer.lineTable.partNumber') }}</th>
|
||||
<th class="px-2.5 py-2 font-medium">{{ $t('workspace.shippingNotice.myTodos.drawer.lineTable.customerPartNumber') }}</th>
|
||||
<th class="px-2.5 py-2 font-medium">{{ $t('workspace.shippingNotice.myTodos.drawer.lineTable.reservationId') }}</th>
|
||||
<th class="px-2.5 py-2 font-medium">{{ $t('workspace.shippingNotice.myTodos.drawer.lineTable.shipmentQty') }}</th>
|
||||
<th class="px-2.5 py-2 font-medium">{{ $t('workspace.shippingNotice.myTodos.drawer.lineTable.availableQty') }}</th>
|
||||
<th class="px-2.5 py-2 font-medium">{{ $t('workspace.shippingNotice.myTodos.drawer.lineTable.shortageQty') }}</th>
|
||||
<th class="px-2.5 py-2 font-medium">{{ $t('workspace.shippingNotice.myTodos.drawer.lineTable.status') }}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr
|
||||
v-for="line in lineRows"
|
||||
:key="`${line.line_no}-${line.part_number}`"
|
||||
class="border-b border-[#f0f3f8]"
|
||||
>
|
||||
<td class="px-2.5 py-2 font-mono">{{ line.line_no }}</td>
|
||||
<td class="px-2.5 py-2 font-mono">{{ line.part_number || '—' }}</td>
|
||||
<td class="px-2.5 py-2">{{ line.customer_part_number || '—' }}</td>
|
||||
<td class="px-2.5 py-2 font-mono">{{ line.reservation_id || '—' }}</td>
|
||||
<td class="px-2.5 py-2 tabular-nums">{{ line.shipment_qty ?? '—' }}</td>
|
||||
<td class="px-2.5 py-2 tabular-nums">{{ line.available_qty ?? '—' }}</td>
|
||||
<td
|
||||
class="px-2.5 py-2 tabular-nums"
|
||||
:class="Number(line.shortage_qty || 0) > 0 ? 'font-bold text-red-600' : ''"
|
||||
>
|
||||
{{ line.shortage_qty ?? '—' }}
|
||||
</td>
|
||||
<td class="px-2.5 py-2">{{ line.inventory_status || '—' }}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<template v-if="exportFileName">
|
||||
<h4 class="mb-2 mt-5 text-[13px] font-bold text-primary">
|
||||
{{ $t('workspace.shippingNotice.myTodos.drawer.files') }}
|
||||
</h4>
|
||||
<div class="rounded-xl border border-default px-3 py-2 text-[13px] text-secondary">
|
||||
<span class="mr-2 rounded bg-brand-50 px-1.5 py-0.5 text-[10px] text-brand-800">Excel</span>
|
||||
{{ exportFileName }}
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<p class="mt-5 text-xs text-muted">
|
||||
{{ $t('workspace.shippingNotice.myTodos.openProcessingHint') }}
|
||||
</p>
|
||||
</template>
|
||||
<div v-else class="py-16 text-center text-sm text-muted">
|
||||
{{ $t('workspace.shippingNotice.selectCase') }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="item && !loading" class="space-y-2.5 border-t border-default px-5 py-4">
|
||||
<div class="flex flex-wrap gap-2">
|
||||
<label class="sr-only" for="drawer-stage-target">{{ $t('workspace.shippingNotice.myTodos.lifecycleStages.viewStage') }}</label>
|
||||
<select
|
||||
v-if="stageTargetOptions.length"
|
||||
id="drawer-stage-target"
|
||||
v-model="stageTarget"
|
||||
class="input-field max-w-40 text-sm"
|
||||
data-testid="my-todos-lifecycle-stage-target"
|
||||
>
|
||||
<option
|
||||
v-for="option in stageTargetOptions"
|
||||
:key="option.code"
|
||||
:value="option.code"
|
||||
:disabled="option.disabled"
|
||||
>
|
||||
{{ $t(`workspace.shippingNotice.myTodos.lifecycleStages.${option.code}`) }}
|
||||
</option>
|
||||
</select>
|
||||
<button
|
||||
v-if="canOpenIntake"
|
||||
type="button"
|
||||
class="inline-flex items-center gap-1.5 rounded-xl bg-brand-600 px-4 py-2 text-sm font-medium text-white hover:bg-brand-700 disabled:opacity-50"
|
||||
data-testid="my-todos-open-intake-parse"
|
||||
@click="emit('open-intake', item)"
|
||||
>
|
||||
<ExternalLink class="h-3.5 w-3.5" />
|
||||
{{ $t('workspace.shippingNotice.myTodos.openIntakeParse') }}
|
||||
</button>
|
||||
<button
|
||||
v-else-if="!isIntakeItem"
|
||||
type="button"
|
||||
class="inline-flex items-center gap-1.5 rounded-xl bg-brand-600 px-4 py-2 text-sm font-medium text-white hover:bg-brand-700 disabled:opacity-50"
|
||||
:disabled="!canOpenProcessing(stageTarget)"
|
||||
data-testid="my-todos-open-order-processing"
|
||||
@click="emit('open-processing', item, stageTarget)"
|
||||
>
|
||||
<ExternalLink class="h-3.5 w-3.5" />
|
||||
{{ $t('workspace.shippingNotice.myTodos.openLifecycleWorkbench') }}
|
||||
</button>
|
||||
<button
|
||||
v-else
|
||||
type="button"
|
||||
class="inline-flex items-center gap-1.5 rounded-xl bg-brand-600 px-4 py-2 text-sm font-medium text-white hover:bg-brand-700 disabled:opacity-50"
|
||||
:disabled="!(item.owner_agent_id || chatAgentId)"
|
||||
data-testid="my-todos-open-intake-conversation"
|
||||
@click="emit('open-chat', item)"
|
||||
>
|
||||
<ExternalLink class="h-3.5 w-3.5" />
|
||||
{{ $t('workspace.shippingNotice.myTodos.openConversation') }}
|
||||
</button>
|
||||
<button
|
||||
v-if="chatAgentId && !isIntakeItem"
|
||||
type="button"
|
||||
class="inline-flex items-center gap-1 rounded-xl border border-default px-3 py-1.5 text-xs font-medium text-secondary hover:bg-surface-soft"
|
||||
@click="emit('open-chat', item)"
|
||||
>
|
||||
<ExternalLink class="h-3.5 w-3.5" />
|
||||
{{ $t('workspace.shippingNotice.openChat') }}
|
||||
</button>
|
||||
</div>
|
||||
<div class="flex flex-wrap items-center gap-3">
|
||||
<button
|
||||
v-if="canRetryStp"
|
||||
type="button"
|
||||
class="inline-flex items-center gap-1.5 rounded-xl border border-amber-400 bg-amber-50 px-4 py-2 text-sm font-medium text-amber-950 hover:bg-amber-100 disabled:opacity-50 dark:border-amber-700 dark:bg-amber-950/40 dark:text-amber-100"
|
||||
:disabled="stpRetrying"
|
||||
data-testid="my-todos-retry-stp-auto-create"
|
||||
@click="emit('retry-stp', item)"
|
||||
>
|
||||
<RefreshCw class="h-3.5 w-3.5" />
|
||||
{{ $t('chat.shippingOrderReview.autoProgress.retryStp') }}
|
||||
</button>
|
||||
<a
|
||||
v-if="exportFileName"
|
||||
class="inline-flex cursor-pointer items-center gap-1 text-xs text-brand-700 hover:underline"
|
||||
:href="`/api/workspace/shipping-notices/${encodeURIComponent(String(item.business_no || ''))}/export`"
|
||||
target="_blank"
|
||||
rel="noopener"
|
||||
>
|
||||
<Download class="h-3.5 w-3.5" />
|
||||
{{ $t('workspace.shippingNotice.myTodos.drawer.exportExcel') }}
|
||||
</a>
|
||||
<p
|
||||
v-if="!canOpenIntake && !canOpenProcessing(stageTarget) && !isIntakeItem"
|
||||
class="text-xs text-amber-700 dark:text-amber-300"
|
||||
data-testid="my-todos-open-processing-unavailable"
|
||||
>
|
||||
{{ $t('workspace.shippingNotice.myTodos.openProcessingUnavailable') }}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</aside>
|
||||
</div>
|
||||
</Teleport>
|
||||
</template>
|
||||
@@ -0,0 +1,240 @@
|
||||
<!--
|
||||
features/workspace/shipping-task-center/ShippingTaskTable.vue
|
||||
用途:任务中心紧凑表格(一行一待办):编号/阶段/状态摘要/项次缺口/货代状态。
|
||||
依赖:shippingTaskCenterShared(编号、阶段、批量可选口径)。
|
||||
逻辑:行点击向上冒泡选中;复选框仅「货代上传」阶段的正式 Notice 行存在;
|
||||
勾选 ≥1 后浮出深色批量操作条(低频操作不常驻);分页由父级渲染。
|
||||
-->
|
||||
<script setup lang="ts">
|
||||
import { computed } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { CheckSquare, Download, Upload, X } from 'lucide-vue-next';
|
||||
import type { ShippingTaskSummary } from '@/features/chat/api/shipping.api';
|
||||
import {
|
||||
isFreightUploadRow,
|
||||
lifecycleStageCodeOf,
|
||||
todoBlockerText,
|
||||
todoDisplayNo,
|
||||
todoItemKey,
|
||||
todoLineBrief,
|
||||
todoSubTitleText,
|
||||
todoTitleText,
|
||||
} from './shippingTaskCenterShared';
|
||||
|
||||
const { t, te } = useI18n();
|
||||
|
||||
const props = defineProps<{
|
||||
items: ShippingTaskSummary[];
|
||||
/** 当前选中行主键(抽屉联动)。 */
|
||||
selectedKey?: string | null;
|
||||
/** 是否渲染复选框列(仅待处理桶)。 */
|
||||
selectable?: boolean;
|
||||
/** 已勾选 business_no 集合。 */
|
||||
selectedBusinessNos?: string[];
|
||||
/** 批量动作进行中标记,禁用按钮。 */
|
||||
batchBusy?: 'download' | 'confirm' | 'rpa' | null;
|
||||
/** done 桶行统一终态角标(驳回/作废子视图由服务端过滤保证)。 */
|
||||
terminalBadge?: 'upload_complete' | 'reject_void' | null;
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
(event: 'select', item: ShippingTaskSummary): void;
|
||||
(event: 'toggle', item: ShippingTaskSummary): void;
|
||||
(event: 'toggle-all'): void;
|
||||
(event: 'clear-selection'): void;
|
||||
(event: 'batch', action: 'download' | 'confirm' | 'rpa'): void;
|
||||
}>();
|
||||
|
||||
const selectedSet = computed(() => new Set(props.selectedBusinessNos || []));
|
||||
const selectableRows = computed(() => props.items.filter((item) => isFreightUploadRow(item)));
|
||||
const hasSelection = computed(() => (props.selectedBusinessNos?.length || 0) > 0);
|
||||
const allSelectableChecked = computed(() => (
|
||||
selectableRows.value.length > 0
|
||||
&& selectableRows.value.every((item) => selectedSet.value.has(String(item.business_no)))
|
||||
));
|
||||
|
||||
/** 阶段徽章文案:优先本地化阶段名,后端 label 兜底。 */
|
||||
function stageLabel(item: ShippingTaskSummary): string {
|
||||
const code = lifecycleStageCodeOf(item);
|
||||
const key = code ? `workspace.shippingNotice.myTodos.lifecycleStages.${code}` : '';
|
||||
if (key && te(key)) return t(key);
|
||||
return String(item.ui_state?.stage?.label || '—');
|
||||
}
|
||||
|
||||
function rowTitle(item: ShippingTaskSummary): string {
|
||||
return todoTitleText(item);
|
||||
}
|
||||
|
||||
function rowBlocker(item: ShippingTaskSummary): string {
|
||||
return todoBlockerText(item, t, te);
|
||||
}
|
||||
|
||||
function lineBriefText(item: ShippingTaskSummary): string {
|
||||
const brief = todoLineBrief(item);
|
||||
if (!brief.total) return '—';
|
||||
return `${brief.total} ${t('workspace.shippingNotice.myTodos.table.lineUnit')}`;
|
||||
}
|
||||
|
||||
function onToggleAll(): void {
|
||||
emit('toggle-all');
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="overflow-hidden rounded-2xl border border-default bg-surface">
|
||||
<div
|
||||
v-if="hasSelection"
|
||||
class="flex flex-wrap items-center gap-2 bg-[#1b2740] px-4 py-2.5 text-sm text-slate-100"
|
||||
data-testid="shipping-notice-batch-toolbar"
|
||||
>
|
||||
<span class="rounded-full bg-brand-600 px-3 py-0.5 text-xs font-semibold">
|
||||
{{ $t('workspace.shippingNotice.batch.selected', { count: selectedBusinessNos?.length || 0 }) }}
|
||||
</span>
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-lg border border-white/20 px-2.5 py-1 text-xs hover:bg-white/10 disabled:opacity-50"
|
||||
:disabled="Boolean(batchBusy)"
|
||||
@click="emit('batch', 'download')"
|
||||
>
|
||||
<Download class="mr-1 inline h-3.5 w-3.5" />
|
||||
{{ $t('workspace.shippingNotice.batch.download') }}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-lg border border-white/20 px-2.5 py-1 text-xs hover:bg-white/10 disabled:opacity-50"
|
||||
:disabled="Boolean(batchBusy)"
|
||||
@click="emit('batch', 'confirm')"
|
||||
>
|
||||
<CheckSquare class="mr-1 inline h-3.5 w-3.5" />
|
||||
{{ $t('workspace.shippingNotice.batch.confirm') }}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-lg border border-white/20 px-2.5 py-1 text-xs hover:bg-white/10 disabled:opacity-50"
|
||||
:disabled="Boolean(batchBusy)"
|
||||
@click="emit('batch', 'rpa')"
|
||||
>
|
||||
<Upload class="mr-1 inline h-3.5 w-3.5" />
|
||||
{{ $t('workspace.shippingNotice.batch.rpa') }}
|
||||
</button>
|
||||
<span class="flex-1" />
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-lg px-2.5 py-1 text-xs text-slate-300 hover:text-white"
|
||||
@click="emit('clear-selection')"
|
||||
>
|
||||
<X class="mr-1 inline h-3.5 w-3.5" />
|
||||
{{ $t('workspace.shippingNotice.batch.clearSelection') }}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="overflow-x-auto">
|
||||
<table class="w-full border-collapse text-sm">
|
||||
<thead>
|
||||
<tr class="border-b border-default bg-surface-soft/60 text-left text-xs text-muted">
|
||||
<th v-if="selectable" class="w-10 px-3 py-2.5">
|
||||
<input
|
||||
type="checkbox"
|
||||
:checked="allSelectableChecked"
|
||||
:aria-label="$t('workspace.shippingNotice.batch.selectAll')"
|
||||
@change="onToggleAll"
|
||||
>
|
||||
</th>
|
||||
<th class="px-3 py-2.5 font-medium">{{ $t('workspace.shippingNotice.myTodos.table.no') }}</th>
|
||||
<th class="w-24 px-3 py-2.5 font-medium">{{ $t('workspace.shippingNotice.myTodos.table.stage') }}</th>
|
||||
<th class="px-3 py-2.5 font-medium">{{ $t('workspace.shippingNotice.myTodos.table.summary') }}</th>
|
||||
<th class="w-28 px-3 py-2.5 font-medium">{{ $t('workspace.shippingNotice.myTodos.table.lines') }}</th>
|
||||
<th class="w-24 px-3 py-2.5 font-medium">{{ $t('workspace.shippingNotice.myTodos.table.freightStatus') }}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr
|
||||
v-for="item in items"
|
||||
:key="todoItemKey(item)"
|
||||
class="cursor-pointer border-b border-[#f0f3f8] transition-colors hover:bg-brand-50/40"
|
||||
:class="selectedKey === todoItemKey(item) ? 'bg-brand-50/70 dark:bg-brand-950/30' : ''"
|
||||
:data-testid="`my-todos-row-${todoDisplayNo(item)}`"
|
||||
@click="emit('select', item)"
|
||||
>
|
||||
<td v-if="selectable" class="px-3 py-2.5 align-middle">
|
||||
<input
|
||||
v-if="isFreightUploadRow(item)"
|
||||
type="checkbox"
|
||||
:checked="selectedSet.has(String(item.business_no))"
|
||||
:aria-label="String(item.business_no)"
|
||||
@click.stop
|
||||
@change="emit('toggle', item)"
|
||||
>
|
||||
</td>
|
||||
<td class="max-w-[22rem] px-3 py-2.5 align-middle">
|
||||
<div class="flex items-center gap-2">
|
||||
<span class="truncate font-mono text-[13px] font-semibold text-primary">{{ todoDisplayNo(item) }}</span>
|
||||
<span
|
||||
v-if="item.todo_category === 'review' || item.item_kind === 'review_case'"
|
||||
class="shrink-0 rounded bg-amber-50 px-1.5 py-0.5 text-[10px] text-amber-700"
|
||||
>
|
||||
{{ $t('workspace.shippingNotice.myTodos.openReview') }}
|
||||
</span>
|
||||
<span
|
||||
v-else-if="item.todo_category === 'intake_parse' || item.item_kind === 'order_intake'"
|
||||
class="shrink-0 rounded bg-violet-50 px-1.5 py-0.5 text-[10px] text-violet-700"
|
||||
>
|
||||
{{ $t('workspace.shippingNotice.myTodos.intakeParseBadge') }}
|
||||
</span>
|
||||
<span
|
||||
v-else-if="item.can_handle === false"
|
||||
class="shrink-0 rounded bg-slate-100 px-1.5 py-0.5 text-[10px] text-slate-600"
|
||||
>
|
||||
{{ $t('workspace.shippingNotice.todo.adminViewOnlyShort') }}
|
||||
</span>
|
||||
<span
|
||||
v-else-if="terminalBadge === 'upload_complete'"
|
||||
class="shrink-0 rounded bg-emerald-50 px-1.5 py-0.5 text-[10px] text-emerald-700"
|
||||
>
|
||||
{{ $t('workspace.shippingNotice.myTodos.terminal.uploadComplete') }}
|
||||
</span>
|
||||
<span
|
||||
v-else-if="terminalBadge === 'reject_void'"
|
||||
class="shrink-0 rounded bg-red-50 px-1.5 py-0.5 text-[10px] text-red-700"
|
||||
>
|
||||
{{ $t('workspace.shippingNotice.myTodos.terminal.rejectVoid') }}
|
||||
</span>
|
||||
</div>
|
||||
<div class="mt-0.5 truncate text-xs text-muted">{{ todoSubTitleText(item) || '—' }}</div>
|
||||
</td>
|
||||
<td class="px-3 py-2.5 align-middle">
|
||||
<span class="whitespace-nowrap rounded-full bg-brand-50 px-2 py-0.5 text-xs text-brand-800">
|
||||
{{ stageLabel(item) }}
|
||||
</span>
|
||||
</td>
|
||||
<td class="max-w-[18rem] px-3 py-2.5 align-middle">
|
||||
<div class="truncate text-[13px] text-secondary">{{ rowTitle(item) }}</div>
|
||||
<div
|
||||
v-if="rowBlocker(item)"
|
||||
class="mt-0.5 truncate text-xs text-red-600"
|
||||
data-testid="my-todos-row-blocker"
|
||||
>
|
||||
{{ rowBlocker(item) }}
|
||||
</div>
|
||||
</td>
|
||||
<td class="px-3 py-2.5 align-middle text-xs">
|
||||
<template v-if="item.business_no">
|
||||
<span>{{ lineBriefText(item) }}</span>
|
||||
<span
|
||||
v-if="todoLineBrief(item).shortage"
|
||||
class="ml-1 font-semibold text-red-600"
|
||||
>
|
||||
{{ $t('workspace.shippingNotice.myTodos.table.shortage', { count: todoLineBrief(item).shortage }) }}
|
||||
</span>
|
||||
</template>
|
||||
<span v-else class="text-muted">—</span>
|
||||
</td>
|
||||
<td class="px-3 py-2.5 align-middle text-xs text-secondary">
|
||||
{{ item.business_no ? (item.upload_status || '—') : '—' }}
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,174 @@
|
||||
/**
|
||||
* features/workspace/shipping-task-center/shippingTaskCenterShared.ts
|
||||
* 用途:任务中心列表 / 表格 / 抽屉共用的纯函数与类型(阶段口径、编号、选择)。
|
||||
* 依赖:chat shipping.api 类型、gateReasonLabel。
|
||||
* 逻辑:阶段只消费后端 ui_state.lifecycle_entries / ui_state.stage(与页面同口径);
|
||||
* 本模块不发起请求、不操作路由,供 TaskTable / Drawer / Page 复用。
|
||||
*/
|
||||
import type { ShippingTaskDetail, ShippingTaskSummary } from '@/features/chat/api/shipping.api';
|
||||
import { resolveGateReasonLabel } from '@/features/shipping-progress/gateReasonLabel';
|
||||
|
||||
export type LifecycleStageCode = 'intake_parse' | 'order_review' | 'fulfillment_prep'
|
||||
| 'freight_upload' | 'upload_complete';
|
||||
|
||||
/** 五阶段完整序列(抽屉阶段下拉消费后端 entries,仍需全集做过滤)。 */
|
||||
export const LIFECYCLE_STAGES: LifecycleStageCode[] = [
|
||||
'intake_parse',
|
||||
'order_review',
|
||||
'fulfillment_prep',
|
||||
'freight_upload',
|
||||
'upload_complete',
|
||||
];
|
||||
|
||||
/** 阶段筛选 tab 仅覆盖四个可动作阶段;「通知完成」归 done 桶终态。 */
|
||||
export const ACTIONABLE_TODO_STAGES: Exclude<LifecycleStageCode, 'upload_complete'>[] = [
|
||||
'intake_parse',
|
||||
'order_review',
|
||||
'fulfillment_prep',
|
||||
'freight_upload',
|
||||
];
|
||||
|
||||
export type TodoLike = ShippingTaskSummary | ShippingTaskDetail;
|
||||
|
||||
/**
|
||||
* 待办列表项稳定主键:复核用 case_no,Intake 用 intake_no,任务用 task_no。
|
||||
*/
|
||||
export function todoItemKey(item: ShippingTaskSummary): string {
|
||||
if (item.item_kind === 'review_case' || item.review_case_no) {
|
||||
return String(item.todo_ref || item.review_case_no || item.review_run_no || '');
|
||||
}
|
||||
if (item.item_kind === 'order_intake' || item.intake_no) {
|
||||
return String(item.todo_ref || item.intake_no || '');
|
||||
}
|
||||
return String(item.todo_ref || item.task_no || '');
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表展示编号:复核显示 case_no,Intake 显示 intake_no,任务显示业务编号/SN。
|
||||
*/
|
||||
export function todoDisplayNo(item: ShippingTaskSummary): string {
|
||||
if (item.item_kind === 'review_case' || item.review_case_no) {
|
||||
return String(item.review_case_no || item.review_run_no || item.todo_ref || '—');
|
||||
}
|
||||
if (item.item_kind === 'order_intake' || item.intake_no) {
|
||||
return String(item.intake_no || item.todo_ref || '—');
|
||||
}
|
||||
return String(item.business_no || item.task_no || item.todo_ref || '—');
|
||||
}
|
||||
|
||||
/**
|
||||
* 读取后端已裁决的生命周期入口;缺失即无授权,绝不按 task/case/intake 身份补造入口。
|
||||
*/
|
||||
export function lifecycleEntriesOf(item: TodoLike) {
|
||||
const entries = item.ui_state?.lifecycle_entries;
|
||||
if (!Array.isArray(entries)) return [];
|
||||
return entries.filter((entry) => LIFECYCLE_STAGES.includes(entry.code as LifecycleStageCode));
|
||||
}
|
||||
|
||||
/** 当前阶段只取后端标为 current 的入口,必要时回退 ui_state.stage(仅统计口径)。 */
|
||||
export function lifecycleStageCodeOf(item: TodoLike): LifecycleStageCode | null {
|
||||
const current = lifecycleEntriesOf(item).find((entry) => entry.state === 'current');
|
||||
if (current) return current.code as LifecycleStageCode;
|
||||
// [AUTHORITY] 待人工处理的 Review Case 可能没有可进入工作台的 lifecycle entry,
|
||||
// 但后端仍会下发 ui_state.stage 作为当前业务阶段;统计与筛选必须保留该阶段。
|
||||
const stage = String(item.ui_state?.stage?.code || '').trim();
|
||||
return LIFECYCLE_STAGES.includes(stage as LifecycleStageCode)
|
||||
? stage as LifecycleStageCode
|
||||
: null;
|
||||
}
|
||||
|
||||
/** 可进入工作台的业务阶段仅由后端 entry.state 授权。 */
|
||||
export function lifecycleEntryFor(
|
||||
item: TodoLike,
|
||||
stage: Exclude<LifecycleStageCode, 'intake_parse'>,
|
||||
) {
|
||||
return lifecycleEntriesOf(item).find((entry) => entry.code === stage) || null;
|
||||
}
|
||||
|
||||
/** 后端仅以 current / available 表示可进入工作台;未知状态一律拒绝深链。 */
|
||||
export function lifecycleEntryIsEnterable(
|
||||
entry: ReturnType<typeof lifecycleEntryFor>,
|
||||
): boolean {
|
||||
return entry?.state === 'current' || entry?.state === 'available';
|
||||
}
|
||||
|
||||
/** 阶段目标下拉默认值:优先 current,其次 available。 */
|
||||
export function defaultLifecycleTarget(
|
||||
item: TodoLike,
|
||||
): Exclude<LifecycleStageCode, 'intake_parse'> | null {
|
||||
const current = lifecycleEntriesOf(item).find(
|
||||
(entry) => entry.code !== 'intake_parse' && entry.state === 'current',
|
||||
);
|
||||
const available = lifecycleEntriesOf(item).find(
|
||||
(entry) => entry.code !== 'intake_parse' && entry.state === 'available',
|
||||
);
|
||||
return (current || available)?.code as Exclude<LifecycleStageCode, 'intake_parse'> | undefined || null;
|
||||
}
|
||||
|
||||
/** 接收解析入口只消费后端独立授权 + run/agent 前提,不从阶段名称推导可写权限。 */
|
||||
export function canOpenIntakeParse(item: TodoLike | null, chatAgentId: number | null): boolean {
|
||||
if (!item) return false;
|
||||
const runNo = String(item.review_run_no || '').trim();
|
||||
const agentId = Number(item.owner_agent_id || chatAgentId || 0);
|
||||
return Boolean(
|
||||
runNo
|
||||
&& agentId
|
||||
&& item.ui_state?.intake_parse_authorized === true,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 行状态摘要标题:后端待办标题优先,逐级回退到阶段标签。
|
||||
*/
|
||||
export function todoTitleText(item: ShippingTaskSummary): string {
|
||||
return String(
|
||||
item.ui_state?.todo?.title
|
||||
|| item.ui_state?.summary?.current_todo
|
||||
|| item.ui_state?.summary?.title
|
||||
|| item.ui_state?.stage?.label
|
||||
|| '—',
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 行阻断原因文本:优先后端 reason.message,其次 Gate 原因码的本地化标签。
|
||||
* 空串表示当前无阻断(调用方据此决定红色高亮)。
|
||||
*/
|
||||
export function todoBlockerText(
|
||||
item: TodoLike,
|
||||
t: (key: string, named?: Record<string, unknown>) => string,
|
||||
te: (key: string) => boolean,
|
||||
): string {
|
||||
const reason = item.ui_state?.reason;
|
||||
const text = String(reason?.message || '').trim();
|
||||
if (text) return text;
|
||||
const code = String(reason?.code || '').trim();
|
||||
if (!code) return '';
|
||||
return resolveGateReasonLabel(code, { t, te });
|
||||
}
|
||||
|
||||
/** 表格副行:客户 · PO · 源文件/导出文件,缺省段自动跳过。 */
|
||||
export function todoSubTitleText(item: ShippingTaskSummary): string {
|
||||
const segments = [
|
||||
String(item.customer_name || '').trim(),
|
||||
String(item.po_number || '').trim() ? `PO ${String(item.po_number).trim()}` : '',
|
||||
String(item.source_file_name || '').trim()
|
||||
|| String(item.artifact_summary?.export_file_name || '').trim(),
|
||||
].filter(Boolean);
|
||||
return segments.join(' · ');
|
||||
}
|
||||
|
||||
/** 项次/缺口摘要:total 项 + 缺 n(缺口>0 的行数)。 */
|
||||
export function todoLineBrief(item: ShippingTaskSummary): { total: number; shortage: number } {
|
||||
const lines = Array.isArray(item.notice_line_summary) ? item.notice_line_summary : [];
|
||||
const shortage = lines.filter((line) => Number(line.shortage_qty || 0) > 0).length;
|
||||
return { total: lines.length, shortage };
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量可选行:正式 Notice 且处于货代上传阶段(业务约束:批量操作仅该阶段可用)。
|
||||
*/
|
||||
export function isFreightUploadRow(item: ShippingTaskSummary): boolean {
|
||||
return Boolean(String(item.business_no || '').trim())
|
||||
&& lifecycleStageCodeOf(item) === 'freight_upload';
|
||||
}
|
||||
@@ -280,8 +280,8 @@
|
||||
"customerTaskMissing": "Task number missing — cannot open customer confirm. Refresh and try again.",
|
||||
"genericBlocking": "This step needs manual attention",
|
||||
"unknownStep": "Current step",
|
||||
"continueAction": "Continue",
|
||||
"recoveryTargets": "Prerequisite recovery",
|
||||
"continueAction": "Continue",
|
||||
"recoveryTargets": "Prerequisite recovery",
|
||||
"actionSubmitted": "Action submitted",
|
||||
"submitting": "Submitting…",
|
||||
"readOnlyUseFooter": "Use the footer action bar to proceed",
|
||||
@@ -522,6 +522,75 @@
|
||||
"taskNoPlaceholder": "SN number",
|
||||
"apply": "Apply filters",
|
||||
"reset": "Reset"
|
||||
},
|
||||
"batch": {
|
||||
"selectAll": "Select all filtered notices",
|
||||
"selected": "{count} selected",
|
||||
"download": "Batch download Excel",
|
||||
"confirm": "Batch confirm uploaded",
|
||||
"rpa": "Batch start RPA",
|
||||
"clearSelection": "Clear selection",
|
||||
"downloadStarted": "Export download started",
|
||||
"success": "{action}: {count} succeeded",
|
||||
"partialResult": "{action}: {accepted} succeeded, {blocked} not accepted"
|
||||
},
|
||||
"table": {
|
||||
"no": "No.",
|
||||
"stage": "Stage",
|
||||
"summary": "Status summary",
|
||||
"lines": "Lines",
|
||||
"lineUnit": "lines",
|
||||
"shortage": "{count} short",
|
||||
"freightStatus": "Freight status"
|
||||
},
|
||||
"terminal": {
|
||||
"uploadComplete": "Uploaded",
|
||||
"rejectVoid": "Rejected"
|
||||
},
|
||||
"subTabs": {
|
||||
"uploadComplete": "Completed",
|
||||
"rejectVoid": "Rejected / Voided"
|
||||
},
|
||||
"drawer": {
|
||||
"details": "Line details",
|
||||
"files": "Files",
|
||||
"close": "Close",
|
||||
"exportExcel": "Export Excel",
|
||||
"lineTable": {
|
||||
"lineNo": "Line",
|
||||
"partNumber": "Part No.",
|
||||
"customerPartNumber": "Customer part",
|
||||
"reservationId": "Reservation",
|
||||
"shipmentQty": "Ship qty",
|
||||
"availableQty": "Available",
|
||||
"shortageQty": "Shortage",
|
||||
"status": "Status"
|
||||
}
|
||||
},
|
||||
"doneReport": {
|
||||
"export": "Export Excel (current filters)",
|
||||
"exportStarted": "Detail Excel download started",
|
||||
"filters": {
|
||||
"customer": "Customer",
|
||||
"partNumber": "Part No.",
|
||||
"dateFrom": "Notice date from",
|
||||
"dateTo": "Notice date to"
|
||||
},
|
||||
"columns": {
|
||||
"taskNo": "OT No.",
|
||||
"customer": "Customer",
|
||||
"customerCode": "Customer code",
|
||||
"orderDate": "Order date",
|
||||
"lineNo": "Order line",
|
||||
"partNumber": "Part No.",
|
||||
"qty": "Qty",
|
||||
"requiredDate": "Agreed ship date",
|
||||
"customerPo": "Customer PO",
|
||||
"usedQty": "Used qty",
|
||||
"openQty": "Open qty",
|
||||
"sourceOrderNo": "Source order no.",
|
||||
"unitPrice": "Unit price"
|
||||
}
|
||||
}
|
||||
},
|
||||
"risk": {
|
||||
@@ -765,6 +834,17 @@
|
||||
"total": "{count} total",
|
||||
"previous": "Previous",
|
||||
"next": "Next"
|
||||
},
|
||||
"batch": {
|
||||
"selectAll": "Select all filtered notices",
|
||||
"selected": "{count} selected",
|
||||
"download": "Batch download Excel",
|
||||
"confirm": "Batch confirm uploaded",
|
||||
"rpa": "Batch start RPA",
|
||||
"clearSelection": "Clear selection",
|
||||
"downloadStarted": "Export download started",
|
||||
"success": "{action}: {count} succeeded",
|
||||
"partialResult": "{action}: {accepted} succeeded, {blocked} not accepted"
|
||||
}
|
||||
},
|
||||
"profile": {
|
||||
|
||||
@@ -456,6 +456,75 @@
|
||||
"taskNoPlaceholder": "หมายเลข SN",
|
||||
"apply": "ใช้ตัวกรอง",
|
||||
"reset": "รีเซ็ต"
|
||||
},
|
||||
"batch": {
|
||||
"selectAll": "เลือกทั้งหมดตามตัวกรอง",
|
||||
"selected": "เลือกแล้ว {count} รายการ",
|
||||
"download": "ดาวน์โหลด Excel เป็นชุด",
|
||||
"confirm": "ยืนยันการอัปโหลดเป็นชุด",
|
||||
"rpa": "เริ่ม RPA เป็นชุด",
|
||||
"clearSelection": "ล้างการเลือก",
|
||||
"downloadStarted": "เริ่มดาวน์โหลดไฟล์ส่งออกแล้ว",
|
||||
"success": "{action}: สำเร็จ {count} รายการ",
|
||||
"partialResult": "{action}: สำเร็จ {accepted} รายการ ไม่ได้รับ {blocked} รายการ"
|
||||
},
|
||||
"table": {
|
||||
"no": "หมายเลข",
|
||||
"stage": "ขั้นตอน",
|
||||
"summary": "สรุปสถานะ",
|
||||
"lines": "รายการ",
|
||||
"lineUnit": "รายการ",
|
||||
"shortage": "ขาด {count}",
|
||||
"freightStatus": "สถานะขนส่ง"
|
||||
},
|
||||
"terminal": {
|
||||
"uploadComplete": "อัปโหลดสำเร็จ",
|
||||
"rejectVoid": "ถูกปฏิเสธ"
|
||||
},
|
||||
"subTabs": {
|
||||
"uploadComplete": "แจ้งฝากส่งเสร็จ",
|
||||
"rejectVoid": "ปฏิเสธ / ยกเลิก"
|
||||
},
|
||||
"drawer": {
|
||||
"details": "รายละเอียดรายการ",
|
||||
"files": "ไฟล์",
|
||||
"close": "ปิด",
|
||||
"exportExcel": "ส่งออก Excel",
|
||||
"lineTable": {
|
||||
"lineNo": "ลำดับ",
|
||||
"partNumber": "รหัสสินค้า",
|
||||
"customerPartNumber": "รหัสสินค้าลูกค้า",
|
||||
"reservationId": "เลขจอง",
|
||||
"shipmentQty": "จำนวนส่ง",
|
||||
"availableQty": "คงเหลือ",
|
||||
"shortageQty": "ขาด",
|
||||
"status": "สถานะ"
|
||||
}
|
||||
},
|
||||
"doneReport": {
|
||||
"export": "ส่งออก Excel (ตามตัวกรอง)",
|
||||
"exportStarted": "เริ่มดาวน์โหลด Excel รายละเอียดแล้ว",
|
||||
"filters": {
|
||||
"customer": "ลูกค้า",
|
||||
"partNumber": "รหัสสินค้า",
|
||||
"dateFrom": "วันที่แจ้งฝากส่งจาก",
|
||||
"dateTo": "ถึง"
|
||||
},
|
||||
"columns": {
|
||||
"taskNo": "เลข OT",
|
||||
"customer": "ลูกค้า",
|
||||
"customerCode": "รหัสลูกค้า",
|
||||
"orderDate": "วันที่สั่งซื้อ",
|
||||
"lineNo": "ลำดับรายการ",
|
||||
"partNumber": "รหัสสินค้า",
|
||||
"qty": "จำนวน",
|
||||
"requiredDate": "วันส่งมอบตกลง",
|
||||
"customerPo": "PO ลูกค้า",
|
||||
"usedQty": "จำนวนที่ใช้",
|
||||
"openQty": "open qty",
|
||||
"sourceOrderNo": "เลขที่ออเดอร์ต้นทาง",
|
||||
"unitPrice": "ราคาต่อหน่วย"
|
||||
}
|
||||
}
|
||||
},
|
||||
"risk": {
|
||||
@@ -699,6 +768,17 @@
|
||||
"total": "ทั้งหมด {count}",
|
||||
"previous": "ก่อนหน้า",
|
||||
"next": "ถัดไป"
|
||||
},
|
||||
"batch": {
|
||||
"selectAll": "เลือกทั้งหมดตามตัวกรอง",
|
||||
"selected": "เลือกแล้ว {count} รายการ",
|
||||
"download": "ดาวน์โหลด Excel เป็นชุด",
|
||||
"confirm": "ยืนยันการอัปโหลดเป็นชุด",
|
||||
"rpa": "เริ่ม RPA เป็นชุด",
|
||||
"clearSelection": "ล้างการเลือก",
|
||||
"downloadStarted": "เริ่มดาวน์โหลดไฟล์ส่งออกแล้ว",
|
||||
"success": "{action}: สำเร็จ {count} รายการ",
|
||||
"partialResult": "{action}: สำเร็จ {accepted} รายการ ไม่ได้รับ {blocked} รายการ"
|
||||
}
|
||||
},
|
||||
"mobileTabs": {
|
||||
|
||||
@@ -280,8 +280,8 @@
|
||||
"customerTaskMissing": "缺少任务编号,无法打开客户确认,请刷新后重试",
|
||||
"genericBlocking": "当前步骤需要人工处理",
|
||||
"unknownStep": "当前步骤",
|
||||
"continueAction": "继续处理",
|
||||
"recoveryTargets": "前置恢复",
|
||||
"continueAction": "继续处理",
|
||||
"recoveryTargets": "前置恢复",
|
||||
"actionSubmitted": "操作已提交",
|
||||
"submitting": "提交中…",
|
||||
"readOnlyUseFooter": "请使用底部操作栏继续处理",
|
||||
@@ -522,6 +522,75 @@
|
||||
"taskNoPlaceholder": "SN 编号",
|
||||
"apply": "应用筛选",
|
||||
"reset": "重置"
|
||||
},
|
||||
"batch": {
|
||||
"selectAll": "全选当前筛选通知单",
|
||||
"selected": "已选 {count} 张",
|
||||
"download": "批量下载 Excel",
|
||||
"confirm": "批量确认已上传",
|
||||
"rpa": "批量发起 RPA",
|
||||
"clearSelection": "清除选择",
|
||||
"downloadStarted": "已开始下载导出包",
|
||||
"success": "{action}:成功 {count} 张",
|
||||
"partialResult": "{action}:成功 {accepted} 张,未受理 {blocked} 张"
|
||||
},
|
||||
"table": {
|
||||
"no": "编号",
|
||||
"stage": "阶段",
|
||||
"summary": "状态摘要",
|
||||
"lines": "项次",
|
||||
"lineUnit": "项",
|
||||
"shortage": "缺 {count}",
|
||||
"freightStatus": "货代状态"
|
||||
},
|
||||
"terminal": {
|
||||
"uploadComplete": "上传完成",
|
||||
"rejectVoid": "复核驳回"
|
||||
},
|
||||
"subTabs": {
|
||||
"uploadComplete": "通知完成",
|
||||
"rejectVoid": "复核驳回 / 已作废"
|
||||
},
|
||||
"drawer": {
|
||||
"details": "逐行明细",
|
||||
"files": "文件",
|
||||
"close": "关闭",
|
||||
"exportExcel": "导出 Excel",
|
||||
"lineTable": {
|
||||
"lineNo": "行",
|
||||
"partNumber": "料号",
|
||||
"customerPartNumber": "客户料号",
|
||||
"reservationId": "预约号",
|
||||
"shipmentQty": "本次发货",
|
||||
"availableQty": "可用库存",
|
||||
"shortageQty": "缺口",
|
||||
"status": "状态"
|
||||
}
|
||||
},
|
||||
"doneReport": {
|
||||
"export": "导出 Excel(当前筛选)",
|
||||
"exportStarted": "已开始下载明细 Excel",
|
||||
"filters": {
|
||||
"customer": "客户",
|
||||
"partNumber": "料号",
|
||||
"dateFrom": "通知日期起",
|
||||
"dateTo": "通知日期止"
|
||||
},
|
||||
"columns": {
|
||||
"taskNo": "OT 编号",
|
||||
"customer": "客户",
|
||||
"customerCode": "客户编号",
|
||||
"orderDate": "订单日期",
|
||||
"lineNo": "订单项次",
|
||||
"partNumber": "料号",
|
||||
"qty": "数量",
|
||||
"requiredDate": "约定出货日期",
|
||||
"customerPo": "客户PO",
|
||||
"usedQty": "已用数量",
|
||||
"openQty": "open qty",
|
||||
"sourceOrderNo": "订单单号",
|
||||
"unitPrice": "单价"
|
||||
}
|
||||
}
|
||||
},
|
||||
"risk": {
|
||||
@@ -765,6 +834,17 @@
|
||||
"total": "共 {count} 条",
|
||||
"previous": "上一页",
|
||||
"next": "下一页"
|
||||
},
|
||||
"batch": {
|
||||
"selectAll": "全选当前筛选通知单",
|
||||
"selected": "已选 {count} 张",
|
||||
"download": "批量下载 Excel",
|
||||
"confirm": "批量确认已上传",
|
||||
"rpa": "批量发起 RPA",
|
||||
"clearSelection": "清除选择",
|
||||
"downloadStarted": "已开始下载导出包",
|
||||
"success": "{action}:成功 {count} 张",
|
||||
"partialResult": "{action}:成功 {accepted} 张,未受理 {blocked} 张"
|
||||
}
|
||||
},
|
||||
"profile": {
|
||||
@@ -780,7 +860,7 @@
|
||||
"casdoorNotMatchedNeedLocalUser": "Casdoor 登录成功,但未匹配到本地账号。请让管理员在本地用户表创建同名 username 或相同 email 的账号。",
|
||||
"localAccountDisabled": "该本地账号已被禁用,请联系管理员启用后再登录。"
|
||||
},
|
||||
"voucherCheck": {
|
||||
"voucherCheck": {
|
||||
"title": "立账凭证检核任务",
|
||||
"subtitle": "每周二增量检核上一个自然月;扫描销售开票附件类型目录后按 invoice 归档,并汇总缺件。",
|
||||
"period": "资料所属期间",
|
||||
|
||||
@@ -280,8 +280,8 @@
|
||||
"customerTaskMissing": "缺少任務編號,無法開啟客戶確認,請重新整理後再試",
|
||||
"genericBlocking": "目前步驟需要人工處理",
|
||||
"unknownStep": "目前步驟",
|
||||
"continueAction": "繼續處理",
|
||||
"recoveryTargets": "前置恢復",
|
||||
"continueAction": "繼續處理",
|
||||
"recoveryTargets": "前置恢復",
|
||||
"actionSubmitted": "操作已提交",
|
||||
"submitting": "提交中…",
|
||||
"readOnlyUseFooter": "請使用底部操作列繼續處理",
|
||||
@@ -522,6 +522,75 @@
|
||||
"taskNoPlaceholder": "SN 編號",
|
||||
"apply": "套用篩選",
|
||||
"reset": "重置"
|
||||
},
|
||||
"batch": {
|
||||
"selectAll": "全選當前篩選通知單",
|
||||
"selected": "已選 {count} 張",
|
||||
"download": "批量下載 Excel",
|
||||
"confirm": "批量確認已上傳",
|
||||
"rpa": "批量發起 RPA",
|
||||
"clearSelection": "清除選擇",
|
||||
"downloadStarted": "已開始下載導出包",
|
||||
"success": "{action}:成功 {count} 張",
|
||||
"partialResult": "{action}:成功 {accepted} 張,未受理 {blocked} 張"
|
||||
},
|
||||
"table": {
|
||||
"no": "編號",
|
||||
"stage": "階段",
|
||||
"summary": "狀態摘要",
|
||||
"lines": "項次",
|
||||
"lineUnit": "項",
|
||||
"shortage": "缺 {count}",
|
||||
"freightStatus": "貨代狀態"
|
||||
},
|
||||
"terminal": {
|
||||
"uploadComplete": "上傳完成",
|
||||
"rejectVoid": "複核駁回"
|
||||
},
|
||||
"subTabs": {
|
||||
"uploadComplete": "通知完成",
|
||||
"rejectVoid": "複核駁回 / 已作廢"
|
||||
},
|
||||
"drawer": {
|
||||
"details": "逐行明細",
|
||||
"files": "文件",
|
||||
"close": "關閉",
|
||||
"exportExcel": "導出 Excel",
|
||||
"lineTable": {
|
||||
"lineNo": "行",
|
||||
"partNumber": "料號",
|
||||
"customerPartNumber": "客戶料號",
|
||||
"reservationId": "預約號",
|
||||
"shipmentQty": "本次發貨",
|
||||
"availableQty": "可用庫存",
|
||||
"shortageQty": "缺口",
|
||||
"status": "狀態"
|
||||
}
|
||||
},
|
||||
"doneReport": {
|
||||
"export": "導出 Excel(當前篩選)",
|
||||
"exportStarted": "已開始下載明細 Excel",
|
||||
"filters": {
|
||||
"customer": "客戶",
|
||||
"partNumber": "料號",
|
||||
"dateFrom": "通知日期起",
|
||||
"dateTo": "通知日期止"
|
||||
},
|
||||
"columns": {
|
||||
"taskNo": "OT 編號",
|
||||
"customer": "客戶",
|
||||
"customerCode": "客戶編號",
|
||||
"orderDate": "訂單日期",
|
||||
"lineNo": "訂單項次",
|
||||
"partNumber": "料號",
|
||||
"qty": "數量",
|
||||
"requiredDate": "約定出貨日期",
|
||||
"customerPo": "客戶PO",
|
||||
"usedQty": "已用數量",
|
||||
"openQty": "open qty",
|
||||
"sourceOrderNo": "訂單單號",
|
||||
"unitPrice": "單價"
|
||||
}
|
||||
}
|
||||
},
|
||||
"risk": {
|
||||
@@ -765,6 +834,17 @@
|
||||
"total": "共 {count} 條",
|
||||
"previous": "上一頁",
|
||||
"next": "下一頁"
|
||||
},
|
||||
"batch": {
|
||||
"selectAll": "全選當前篩選通知單",
|
||||
"selected": "已選 {count} 張",
|
||||
"download": "批量下載 Excel",
|
||||
"confirm": "批量確認已上傳",
|
||||
"rpa": "批量發起 RPA",
|
||||
"clearSelection": "清除選擇",
|
||||
"downloadStarted": "已開始下載導出包",
|
||||
"success": "{action}:成功 {count} 張",
|
||||
"partialResult": "{action}:成功 {accepted} 張,未受理 {blocked} 張"
|
||||
}
|
||||
},
|
||||
"profile": {
|
||||
|
||||
Reference in new issue
Block a user