From d8299ebf2022d114b7fee0770c448e61f1f48dc6 Mon Sep 17 00:00:00 2001 From: caohuipeng Date: Thu, 17 Sep 2026 15:43:00 +0800 Subject: [PATCH] =?UTF-8?q?feat(shipping-notice):=20=E6=88=91=E7=9A=84?= =?UTF-8?q?=E5=BE=85=E5=8A=9E=E6=94=B9=E7=89=88=E4=B8=BA=E8=A1=A8=E6=A0=BC?= =?UTF-8?q?=E5=8A=A0=E6=8A=BD=E5=B1=89=E5=B9=B6=E6=96=B0=E5=A2=9E=E5=B7=B2?= =?UTF-8?q?=E5=AE=8C=E6=88=90=E6=98=8E=E7=BB=86=E6=8A=A5=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 阶段 tab 收敛 4 个可动作阶段,计数改后端全量聚合 - 通知完成拆明细平铺报表(筛选/分页/12 列导出),批量改情境浮动条 - 同步 i18n 四语言与文档 --- backend/app/api/workspace/shipping_notice.py | 62 + .../shipping_notice/done_line_report.py | 290 +++++ .../services/shipping_notice/query_service.py | 162 ++- .../tests/test_shipping_done_line_report.py | 227 ++++ .../test_shipping_my_todo_stage_counts.py | 125 ++ docs/features/shipping-notice/technical.md | 39 + docs/funclist.md | 4 +- .../plans/2026-09-16-my-tasks-redesign.md | 89 ++ .../2026-09-16-my-tasks-redesign.html | 338 ++++++ .../workspace/api/shipping-tasks.api.ts | 110 ++ .../ShippingDoneLineReport.vue | 181 +++ .../ShippingStageTabs.vue | 63 + ...hippingTaskCenterPage.notice-batch.spec.ts | 181 ++- .../ShippingTaskCenterPage.vue | 1067 ++++++----------- .../ShippingTaskDrawer.vue | 390 ++++++ .../ShippingTaskTable.vue | 240 ++++ .../shippingTaskCenterShared.ts | 174 +++ frontend/src/locales/en/workspace.json | 84 +- frontend/src/locales/th/workspace.json | 80 ++ frontend/src/locales/zh-CN/workspace.json | 86 +- frontend/src/locales/zh-TW/workspace.json | 84 +- 21 files changed, 3315 insertions(+), 761 deletions(-) create mode 100644 backend/app/services/shipping_notice/done_line_report.py create mode 100644 backend/tests/test_shipping_done_line_report.py create mode 100644 backend/tests/test_shipping_my_todo_stage_counts.py create mode 100644 docs/superpowers/plans/2026-09-16-my-tasks-redesign.md create mode 100644 docs/superpowers/prototypes/2026-09-16-my-tasks-redesign.html create mode 100644 frontend/src/features/workspace/shipping-task-center/ShippingDoneLineReport.vue create mode 100644 frontend/src/features/workspace/shipping-task-center/ShippingStageTabs.vue create mode 100644 frontend/src/features/workspace/shipping-task-center/ShippingTaskDrawer.vue create mode 100644 frontend/src/features/workspace/shipping-task-center/ShippingTaskTable.vue create mode 100644 frontend/src/features/workspace/shipping-task-center/shippingTaskCenterShared.ts diff --git a/backend/app/api/workspace/shipping_notice.py b/backend/app/api/workspace/shipping_notice.py index 0b34aa0f..507ce52e 100644 --- a/backend/app/api/workspace/shipping_notice.py +++ b/backend/app/api/workspace/shipping_notice.py @@ -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') diff --git a/backend/app/services/shipping_notice/done_line_report.py b/backend/app/services/shipping_notice/done_line_report.py new file mode 100644 index 00000000..9b07b0bf --- /dev/null +++ b/backend/app/services/shipping_notice/done_line_report.py @@ -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 diff --git a/backend/app/services/shipping_notice/query_service.py b/backend/app/services/shipping_notice/query_service.py index 3bb53c84..ec2f17b0 100644 --- a/backend/app/services/shipping_notice/query_service.py +++ b/backend/app/services/shipping_notice/query_service.py @@ -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), + }, } diff --git a/backend/tests/test_shipping_done_line_report.py b/backend/tests/test_shipping_done_line_report.py new file mode 100644 index 00000000..439ef298 --- /dev/null +++ b/backend/tests/test_shipping_done_line_report.py @@ -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 diff --git a/backend/tests/test_shipping_my_todo_stage_counts.py b/backend/tests/test_shipping_my_todo_stage_counts.py new file mode 100644 index 00000000..7eddbc73 --- /dev/null +++ b/backend/tests/test_shipping_my_todo_stage_counts.py @@ -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 diff --git a/docs/features/shipping-notice/technical.md b/docs/features/shipping-notice/technical.md index 965a1aa0..ad7c83d1 100644 --- a/docs/features/shipping-notice/technical.md +++ b/docs/features/shipping-notice/technical.md @@ -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::`,未命中词保留词级原子;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 可靠性、监控与故障注入 diff --git a/docs/funclist.md b/docs/funclist.md index 252b6cb7..fae581ef 100644 --- a/docs/funclist.md +++ b/docs/funclist.md @@ -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 仍为唯一正式值源。 | diff --git a/docs/superpowers/plans/2026-09-16-my-tasks-redesign.md b/docs/superpowers/plans/2026-09-16-my-tasks-redesign.md new file mode 100644 index 00000000..74e89397 --- /dev/null +++ b/docs/superpowers/plans/2026-09-16-my-tasks-redesign.md @@ -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 数据源接入。 diff --git a/docs/superpowers/prototypes/2026-09-16-my-tasks-redesign.html b/docs/superpowers/prototypes/2026-09-16-my-tasks-redesign.html new file mode 100644 index 00000000..38df3d1a --- /dev/null +++ b/docs/superpowers/prototypes/2026-09-16-my-tasks-redesign.html @@ -0,0 +1,338 @@ + + + + + +我的待办 · 改版原型(方案A:列表优先 + 按需抽屉) + + + + +
+ 设计原型 · 静态稿 + 货代发货通知「我的待办」改版 + 方案 A:列表优先 + 按需抽屉 · 2026-09-16 + 仅用于评审,非实现代码 +
+ + +
+
状态 1

列表态(全部 tab)

卡片列表 → 紧凑表格;右侧常驻详情面板移除
+
+
+

我的待办

按文件查看接收解析与订单生命周期进度;处理详情在订单生命周期工作台完成。

+ +
+
+
待处理(13)处理中(0)已完成(0)
+
+ 全部13 + 接收解析2 + 订单复核4 + 通知准备3 + 货代上传4 +
+
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
编号 / 客户 · PO · 文件阶段状态摘要项次/缺口货代状态
SORC-25CEF2F1FA504685订单复核
微软 · PO_6075309.pdf
订单复核复核草稿待继续编辑——
OT-20260916-769EF9D3-C680
华为 · PO_6075309 · PO_6075309.pdf
通知准备库存存在缺口,需人工处理5 项 · 缺 1—
OT-20260916-769EF9D3-C679
华为 · PO_6075310 · PO_6075310.pdf
通知准备库存存在缺口,需人工处理4 项 · 缺 2—
OT-20260916-04BCBB1A
中兴 · PO_6075312 · PO_6075312.xlsx
货代上传备货完成,可上传货代3 项待上传
OT-20260916-04BCBB1B
中兴 · PO_6075313 · PO_6075313.xlsx
货代上传已上传,待确认6 项已上传
INT-20260916-7712材料解析
东风 · DFM_PO_0091.pdf
接收解析解析完成,待确认明细——
+
‹ 上一页第 1 / 1 页下一页 ›
+
+
+ ① 阶段 tab 计数来自后端聚合(替换现在只统计当前页的五张卡片),点击即筛选;「通知完成」不再是筛选 tab——终态任务统一收进「已完成」桶,行上用角标区分:上传完成 / 复核驳回 / 已作废。
+ ② 复选框仅「货代上传」阶段的行存在,其余阶段该列为空。
+ ③ 点击行任意位置 → 打开右侧详情抽屉(状态 3 / 状态 4);行高约为原卡片一半,一屏可见 12~15 条。 +
+
+ + +
+
状态 2

批量操作态

仅货代上传 tab;勾选 ≥1 后操作条浮出,无常驻工具栏
+
+
+ 全部13 + 接收解析2 + 订单复核4 + 通知准备3 + 货代上传4 + 通知完成0 +
+
+ 已选 2 张 + + + + + +
+ + + + + + + + + + + + + +
编号 / 客户 · PO · 文件阶段状态摘要项次/缺口货代状态
OT-20260916-04BCBB1A
中兴 · PO_6075312 · PO_6075312.xlsx
货代上传备货完成,可上传货代3 项待上传
OT-20260916-04BCBB1B
中兴 · PO_6075313 · PO_6075313.xlsx
货代上传已上传,待确认6 项已上传
+
‹ 上一页第 1 / 1 页下一页 ›
+
+
+ ① 深色浮动操作条只在勾选 ≥1 行后出现,替代现在常驻(且 i18n 缺失、显示原始 key)的工具栏。
+ ② 表头复选框 = 全选当前筛选结果;离开本阶段 tab 或清除后自动收起。
+ ③ 按钮文案使用修复后的 shippingNotice.batch.* 四语言 key。 +
+
+ + +
+
状态 3

详情抽屉态

点击列表行滑出;逐行明细 = 分诊决策依据
+
+
+
+

我的待办

按文件查看接收解析与订单生命周期进度。

+
待处理(13)
+ + + + + + + + +
编号 / 客户 · PO · 文件阶段状态摘要
SORC-25CEF2F1FA504685订单复核
订单复核复核草稿待继续编辑
OT-20260916-769EF9D3-C680
通知准备库存存在缺口
OT-20260916-769EF9D3-C679
通知准备库存存在缺口
OT-20260916-04BCBB1A
货代上传备货完成
+
+
+
+
+

OT-20260916-769EF9D3-C680

+
华为 · PO_6075309 · PO_6075309.pdf
+
通知准备 · 当前阶段
+
+
+ + +
逐行明细(notice_line_summary)
+ + + + + + + + + +
行料号客户料号预约号本次发货可用库存缺口状态
019527-100-AHW-100-AR20260916-011001000在库
029527-200-BHW-200-BR20260916-02503020缺料
039527-150-C——20200在库
049527-400-DHW-400-DR20260916-0410100在库
059527-050-E——505缺料
+ +
文件
+
源PO_6075309.pdf查看
+
ExcelHW-PO_6075309.xlsx(导出)⬇ 下载
+
+
+
+ + +
+
+ + 重试自动推进 + 入口与按钮按后端 ui_state 权限裁决显示 +
+
+
+
+
+
+ ① 抽屉承载原卡片里塞不下的明细:逐行料号 / 预约号 / 发货量 / 可用量 / 缺口 —— 不用跳转即可判断「这张单能不能走」。
+ ② 底部操作条沿用现有三分支逻辑(review / intake / task),权限仍由后端 ui_state 决定。
+ ③ Esc / 点遮罩 / ✕ 关闭;移动端抽屉全屏。 +
+
+ + +
+
状态 4

已完成桶:通知完成 → 明细报表

明细平铺不按 OT 聚合;OT 编号仅页面展示,导出严格 12 列
+
+
+

我的待办

按文件查看接收解析与订单生命周期进度;处理详情在订单生命周期工作台完成。

+ +
+
+
待处理(13)处理中(0)已完成(45)
+
+ 通知完成42 + 复核驳回 / 已作废3 +
+
+ + + + + +
+
+ + + + + + + + + + + + +
OT 编号客户客户编号订单日期订单项次料号数量约定出货日期客户PO已用数量open qty订单单号单价
OT-20260916-769EF9D3-C672HYVE CSHC00106-011B3-A08AR10000017-A68006-153060858008301-26060100521525.08
OT-20260916-769EF9D3-C672FLEX-SLCFS00206-012D4-A08AR12000001100006-15269T234138301-2606010041898.72
OT-20260916-769EF9D3-C672FLEX-SLCFS00206-013B3-AR1000270A1100006-15269T234158301-260601004350.43
OT-20260916-769EF9D3-C671HYVE CSHC00106-011B3-A08AR10000017-A620006-1830608520008301-26060100381520.00
OT-20260916-04BCBB09FLEX-SLCFS00206-021D4-A08AR1200000950006-20269T2342050008301-2606010035899.50
+
+
‹ 上一页第 1 / 9 页(按明细行分页)下一页 ›
+
+
+ ① 已完成桶子视图:`通知完成`=明细报表(平铺、无抽屉、无行级操作);`复核驳回 / 已作废`=仍是 OT 级任务列表 + 抽屉(查驳回原因 / 源文件,可重新处理)。
+ ② OT 编号仅页面首列展示,导出 Excel 严格按标准 12 字段(客户/客户编号/订单日期/订单项次/料号/数量/约定出货日期/客户PO/已用数量/open qty/订单单号/单价),OT 只作查询参数不落列。
+ ③ 已用数量 / open qty 暂留空待接入数据源;默认映射:约定出货日期→required_date、订单单号→source_order_number、单价→unit_price。
+ ④ 后端新增:明细行级查询(跨 OT 分页/筛选)+ 多 OT 合并导出生成器(复用模板映射引擎);子视图计数并入 count 聚合接口。 +
+
+ + + diff --git a/frontend/src/features/workspace/api/shipping-tasks.api.ts b/frontend/src/features/workspace/api/shipping-tasks.api.ts index aaf3c609..01b0bb26 100644 --- a/frontend/src/features/workspace/api/shipping-tasks.api.ts +++ b/frontend/src/features/workspace/api/shipping-tasks.api.ts @@ -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( `/api/workspace/shipping-tasks/my-todos${q ? `?${q}` : ''}`, @@ -58,6 +106,68 @@ export function countWorkspaceShippingMyTodos() { return requestJson('/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( + `/api/workspace/shipping-tasks/my-todos/done-lines${q ? `?${q}` : ''}`, + ); +} + +/** + * 下载当前筛选下的已完成通知明细 Excel(固定 12 列标准格式,不含 OT 编号)。 + * 核心逻辑:浏览器受控 a[download] 下载,后端复核可见性与筛选参数。 + */ +export async function downloadWorkspaceShippingDoneLinesExcel( + filters?: ShippingDoneLineFilters, +): Promise { + 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, diff --git a/frontend/src/features/workspace/shipping-task-center/ShippingDoneLineReport.vue b/frontend/src/features/workspace/shipping-task-center/ShippingDoneLineReport.vue new file mode 100644 index 00000000..10e0f5de --- /dev/null +++ b/frontend/src/features/workspace/shipping-task-center/ShippingDoneLineReport.vue @@ -0,0 +1,181 @@ + + + + diff --git a/frontend/src/features/workspace/shipping-task-center/ShippingStageTabs.vue b/frontend/src/features/workspace/shipping-task-center/ShippingStageTabs.vue new file mode 100644 index 00000000..f8d48170 --- /dev/null +++ b/frontend/src/features/workspace/shipping-task-center/ShippingStageTabs.vue @@ -0,0 +1,63 @@ + + + + diff --git a/frontend/src/features/workspace/shipping-task-center/ShippingTaskCenterPage.notice-batch.spec.ts b/frontend/src/features/workspace/shipping-task-center/ShippingTaskCenterPage.notice-batch.spec.ts index 683a0f9d..2ed380fd 100644 --- a/frontend/src/features/workspace/shipping-task-center/ShippingTaskCenterPage.notice-batch.spec.ts +++ b/frontend/src/features/workspace/shipping-task-center/ShippingTaskCenterPage.notice-batch.spec.ts @@ -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(); }); }); diff --git a/frontend/src/features/workspace/shipping-task-center/ShippingTaskCenterPage.vue b/frontend/src/features/workspace/shipping-task-center/ShippingTaskCenterPage.vue index 2bb66024..86ceccde 100644 --- a/frontend/src/features/workspace/shipping-task-center/ShippingTaskCenterPage.vue +++ b/frontend/src/features/workspace/shipping-task-center/ShippingTaskCenterPage.vue @@ -1,17 +1,19 @@ -/** - * features/workspace/shipping-task-center/ShippingTaskCenterPage.vue - * 用途:发货「任务中心」壳——Pending|Processing|Done + 识别 Run 续办表;列表入口 + STP 重试。 - * 依赖:shipping-tasks.api(my-todos)、shipping.api(详情/STP retry)、ShippingRunProgressTable、 - * useShippingTodoBadge、useMessage、shippingProcessingLabels。 - * 逻辑:选中项展示入口卡 + 五阶段筛选 + 统一进度紧凑摘要;主按钮深链「订单生命周期工作台」; - * review_case 在 failed/manual_fallback 时提供「重试自动推进」(与底栏同一 API/幂等键); - * 不内嵌 ShippingTaskWorkbench;生命周期筛选、禁用与深链只消费后端 - * ui_state.lifecycle_entries;轮询只跟系统 running,silent 刷新不闪加载。 - */ + + + diff --git a/frontend/src/features/workspace/shipping-task-center/ShippingTaskTable.vue b/frontend/src/features/workspace/shipping-task-center/ShippingTaskTable.vue new file mode 100644 index 00000000..187be00c --- /dev/null +++ b/frontend/src/features/workspace/shipping-task-center/ShippingTaskTable.vue @@ -0,0 +1,240 @@ + + + + diff --git a/frontend/src/features/workspace/shipping-task-center/shippingTaskCenterShared.ts b/frontend/src/features/workspace/shipping-task-center/shippingTaskCenterShared.ts new file mode 100644 index 00000000..031931a5 --- /dev/null +++ b/frontend/src/features/workspace/shipping-task-center/shippingTaskCenterShared.ts @@ -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[] = [ + '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, +) { + return lifecycleEntriesOf(item).find((entry) => entry.code === stage) || null; +} + +/** 后端仅以 current / available 表示可进入工作台;未知状态一律拒绝深链。 */ +export function lifecycleEntryIsEnterable( + entry: ReturnType, +): boolean { + return entry?.state === 'current' || entry?.state === 'available'; +} + +/** 阶段目标下拉默认值:优先 current,其次 available。 */ +export function defaultLifecycleTarget( + item: TodoLike, +): Exclude | 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 | 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, + 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'; +} diff --git a/frontend/src/locales/en/workspace.json b/frontend/src/locales/en/workspace.json index 73329ca5..b32fbd4a 100644 --- a/frontend/src/locales/en/workspace.json +++ b/frontend/src/locales/en/workspace.json @@ -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": { diff --git a/frontend/src/locales/th/workspace.json b/frontend/src/locales/th/workspace.json index 063e7322..fd214951 100644 --- a/frontend/src/locales/th/workspace.json +++ b/frontend/src/locales/th/workspace.json @@ -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": { diff --git a/frontend/src/locales/zh-CN/workspace.json b/frontend/src/locales/zh-CN/workspace.json index 27c91369..3989b32f 100644 --- a/frontend/src/locales/zh-CN/workspace.json +++ b/frontend/src/locales/zh-CN/workspace.json @@ -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": "资料所属期间", diff --git a/frontend/src/locales/zh-TW/workspace.json b/frontend/src/locales/zh-TW/workspace.json index 5007a463..a8e98763 100644 --- a/frontend/src/locales/zh-TW/workspace.json +++ b/frontend/src/locales/zh-TW/workspace.json @@ -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": {