fix: 设备验收预警优化

This commit is contained in:
sophie committed 2026-10-13 15:52:09 +08:00
1 parent 7e7bcbd388
commit b8cc0cbe77
25 files changed
+1398 -193

No files matched your search

@@ -3,12 +3,14 @@ backend/app/api/equipment_acceptance/__init__.py
用途:设备验收预警的 Chat 作业面接口。
依赖:JWT 当前用户、Agent 授权、sync_service、统一成功响应。
逻辑:持有 equipment_acceptance Agent 的用户可看停留列表、发送记录和配置;同步、扫描、发送和保存配置仅平台管理员。
逻辑:持有 equipment_acceptance Agent 的用户可看停留列表、发送记录、已归档 Excel 和配置;同步、扫描、发送和保存配置仅平台管理员。
"""
from __future__ import annotations
from flask import Blueprint, g, request
from io import BytesIO
from flask import Blueprint, g, request, send_file
from app.core.auth.jwt import get_current_user
from app.core.errors import ForbiddenError, UnauthorizedError
@@ -19,7 +21,7 @@ from app.services.equipment_acceptance.config_service import (
save_acceptance_config,
)
from app.services.equipment_acceptance.alert_service import generate_alerts, send_pending_alerts
from app.services.equipment_acceptance.send_record_service import list_send_records
from app.services.equipment_acceptance.send_record_service import get_send_file, list_send_files, list_send_records
from app.services.equipment_acceptance.sync_service import (
get_acceptance_order,
list_acceptance_orders,
@@ -157,6 +159,26 @@ def send_equipment_acceptance_alerts():
return ok(send_pending_alerts(), request_id=getattr(g, "request_id", None))
@equipment_acceptance_bp.route("/send-files", methods=["GET"])
def list_equipment_acceptance_send_files():
"""列出最近按收件人归档的 Excel。不含文件字节。"""
_require_equipment_acceptance_access()
return ok({"items": list_send_files()}, request_id=getattr(g, "request_id", None))
@equipment_acceptance_bp.route("/send-files/<int:file_id>/excel", methods=["GET"])
def download_equipment_acceptance_send_file(file_id: int):
"""下载一份当时发给收件人的设备验收预警 Excel。"""
_require_equipment_acceptance_access()
row = get_send_file(file_id)
return send_file(
BytesIO(row.excel_file_data),
as_attachment=True,
download_name=row.excel_file_name or f"equipment-acceptance-alert-{file_id}.xlsx",
mimetype="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
)
@equipment_acceptance_bp.route("/sends", methods=["GET"])
def list_equipment_acceptance_sends():
"""分页查看发送记录。扫描写入后这里才有行。"""
+2
View File
@@ -242,6 +242,7 @@ from app.models.equipment_acceptance import (
EquipmentAcceptanceNode,
EquipmentAcceptanceOperator,
EquipmentAcceptanceOrder,
EquipmentAcceptanceSendFile,
EquipmentAcceptanceSendRecord,
EquipmentAcceptanceSetting,
)
@@ -445,6 +446,7 @@ __all__ = [
'EquipmentAcceptanceNode',
'EquipmentAcceptanceOperator',
'EquipmentAcceptanceSetting',
'EquipmentAcceptanceSendFile',
'EquipmentAcceptanceSendRecord',
'TransferRun',
'TransferSourceJob',
+27 -2
View File
@@ -4,8 +4,9 @@ backend/app/models/equipment_acceptance.py
用途:设备验收预警的本地同步快照和可改配置。
依赖:models.base.Base、users。
逻辑:同步服务按流程实例 request_id upsert 主表,并整批替换当前节点和操作人子表。
配置表只存四档天数和三个固定岗位的系统用户。发送时刻不在这张表。
配置表存四档天数、第 4 轮是否启用,以及三个固定岗位的系统用户。发送时刻不在这张表。
发送记录按验收单和档位留一行。已发送和已取消的姓名不回写;待发送每次扫描重算。
发给每位收件人的 Excel 另存一行,并用 send_record_ids 挂回发送记录,供表格列下载。
不保存流程编号、第二合同编号、验收日期和 isremark。
"""
@@ -14,7 +15,7 @@ from __future__ import annotations
from datetime import datetime
from typing import Optional
from sqlalchemy import JSON, BigInteger, Boolean, DateTime, ForeignKey, Index, String, Text, UniqueConstraint
from sqlalchemy import JSON, BigInteger, Boolean, DateTime, ForeignKey, Index, LargeBinary, String, Text, UniqueConstraint
from sqlalchemy.orm import Mapped, mapped_column
from app.models.base import Base
@@ -116,6 +117,7 @@ class EquipmentAcceptanceSetting(Base):
day_2: Mapped[int] = mapped_column(nullable=False, default=37)
day_3: Mapped[int] = mapped_column(nullable=False, default=44)
day_4: Mapped[int] = mapped_column(nullable=False, default=51)
round_4_enabled: Mapped[bool] = mapped_column(Boolean, nullable=False, default=False)
buyer_manager_user_id: Mapped[Optional[int]] = mapped_column(
ForeignKey("users.id", ondelete="SET NULL"), nullable=True
)
@@ -154,3 +156,26 @@ class EquipmentAcceptanceSendRecord(Base):
sent_at: Mapped[Optional[datetime]] = mapped_column(DateTime, nullable=True)
error_message: Mapped[Optional[str]] = mapped_column(Text, nullable=True)
created_at: Mapped[datetime] = mapped_column(DateTime, nullable=False)
class EquipmentAcceptanceSendFile(Base):
"""一位收件人一次发送留下的 Excel。字节与当时发给企业微信的文件相同。"""
__tablename__ = "equipment_acceptance_send_files"
__table_args__ = (
Index("ix_equipment_acceptance_send_files_created", "created_at"),
)
id: Mapped[int] = mapped_column(primary_key=True)
recipient_user_id: Mapped[Optional[int]] = mapped_column(
ForeignKey("users.id", ondelete="SET NULL"), nullable=True
)
recipient_name: Mapped[Optional[str]] = mapped_column(String(200), nullable=True)
excel_file_name: Mapped[Optional[str]] = mapped_column(String(255), nullable=True)
excel_file_data: Mapped[Optional[bytes]] = mapped_column(LargeBinary, nullable=True)
excel_file_size: Mapped[Optional[int]] = mapped_column(nullable=True)
send_record_ids: Mapped[Optional[list]] = mapped_column(JSON, nullable=True)
status: Mapped[str] = mapped_column(String(32), nullable=False, default="sent")
error_message: Mapped[Optional[str]] = mapped_column(Text, nullable=True)
sent_at: Mapped[Optional[datetime]] = mapped_column(DateTime, nullable=True)
created_at: Mapped[datetime] = mapped_column(DateTime, nullable=False)
@@ -0,0 +1,90 @@
"""
backend/app/services/equipment_acceptance/alert_notice.py
用途:把一名收件人的待发送记录收成企微汇总文案和 Excel 明细。
依赖:openpyxl。
逻辑:发送服务按企业微信账号调用。卡片只写张数,逐张明细进工作簿。不写主送、抄送。
"""
from __future__ import annotations
from io import BytesIO
from typing import Any
from openpyxl import Workbook
from openpyxl.styles import Font
NOTICE_HEADERS = (
"验收单号",
"采购单号",
"申请人",
"轮次",
"停留天数",
"当前节点",
"当前处理人",
"通知身份",
)
NOTICE_FILE_NAME = "设备验收停留提醒.xlsx"
def summary_message(lines: list[dict[str, Any]]) -> str:
"""
拼一名收件人的文字卡片。第一行写已逾期的验收单张数,不列单号。
核心逻辑:一张发送记录算一张。同一轮次的张数写在一起,顺序跟传入的明细一致。
Args:
lines: 已按发送记录去重的明细。每项含 threshold_days。
Returns:
卡片正文。没有明细时仍返回可发送的空汇总。
"""
counts: dict[int, int] = {}
order: list[int] = []
for line in lines:
day = int(line.get("threshold_days") or 0)
if day not in counts:
order.append(day)
counts[day] = 0
counts[day] += 1
detail = ",".join(f"超过 {day} 天 {counts[day]} 张" for day in order) or "无"
return f"共 {len(lines)} 张验收单已逾期。\n{detail}。\n明细见下一条文件。"
def build_notice_workbook(lines: list[dict[str, Any]]) -> bytes:
"""
生成这名收件人的验收停留明细。
核心逻辑:一行对应一张发送记录。通知身份写他为什么收到,不写主送或抄送。
Args:
lines: 验收单号、采购单号、申请人、轮次天数、停留天数、当前节点、当前处理人和通知身份。
Returns:
xlsx 字节。
"""
workbook = Workbook()
sheet = workbook.active
sheet.title = "停留提醒"
sheet.append(list(NOTICE_HEADERS))
for cell in sheet[1]:
cell.font = Font(bold=True)
for line in lines:
dwell = line.get("dwell_days")
sheet.append([
_cell(line.get("acceptance_no")),
_cell(line.get("purchase_order_no")),
_cell(line.get("applicant")),
f"超过 {int(line.get('threshold_days') or 0)} 天",
"—" if dwell is None or dwell == "" else dwell,
_cell(line.get("node_name")),
_cell(line.get("handlers")),
_cell(line.get("identity")),
])
sheet.freeze_panes = "A2"
sheet.auto_filter.ref = sheet.dimensions
output = BytesIO()
workbook.save(output)
return output.getvalue()
def _cell(value: Any) -> str:
"""空值写成横线,避免 Excel 里出现空白列。"""
text = str(value or "").strip()
return text or "—"
@@ -11,20 +11,31 @@ from __future__ import annotations
from typing import Any
def due_tiers(dwell_days: int | None, thresholds: tuple[int, int, int, int]) -> list[int]:
def due_tiers(
dwell_days: int | None,
thresholds: tuple[int, int, int, int],
*,
max_tier: int = 4,
) -> list[int]:
"""
按累计天数给出已经跨过的档位。
核心逻辑:需求是「超过 N 天」。停留刚好等于阈值时还不发。四档各自独立,一次可以跨多档。
第 4 轮关闭时最高只到第 3 档,超过第 4 档天数也不产生总经理那一轮。
Args:
dwell_days: 签核自然日。没有计时起点时为空。
thresholds: 四个天数,对应第 1 到第 4 档。
max_tier: 允许的最高档,1 到 4。第 4 轮未启用时传 3。
Returns:
档位号 1 到 4 的列表。没有跨档时为空。
档位号列表。没有跨档时为空。
"""
if dwell_days is None:
return []
return [index + 1 for index, day in enumerate(thresholds) if dwell_days > day]
return [
index + 1
for index, day in enumerate(thresholds)
if dwell_days > day and index + 1 <= max_tier
]
def make_person(
@@ -2,8 +2,9 @@
backend/app/services/equipment_acceptance/alert_service.py
用途:每日扫描生成设备验收待发送记录,并在周五按收件人发送企业微信。
依赖:同步服务、OA 人员目录、alert_plan、发送记录模型、企微通知。
逻辑:扫描先同步 E10,再按停留天数跨档。停表取消未发送记录。已发送的不重发、不改收件人。
依赖:同步服务、OA 人员目录、alert_plan、alert_notice、发送记录模型、企微通知。
逻辑:扫描先同步 E10,再按停留天数跨档。第 4 轮关闭时不生成、也不发送总经理那一轮。
周五按收件人发一条汇总卡片,紧跟着一份 Excel。卡片和文件都成功才算已发送。停表取消未发送记录。已发送的不重发、不改收件人。
"""
from __future__ import annotations
@@ -11,15 +12,23 @@ from __future__ import annotations
import logging
from datetime import datetime
from typing import Any
from zoneinfo import ZoneInfo
from app.extensions import db
from app.models.equipment_acceptance import (
EquipmentAcceptanceNode,
EquipmentAcceptanceOperator,
EquipmentAcceptanceOrder,
EquipmentAcceptanceSendFile,
EquipmentAcceptanceSendRecord,
EquipmentAcceptanceSetting,
)
from app.models.user import User
from app.services.equipment_acceptance.alert_notice import (
NOTICE_FILE_NAME,
build_notice_workbook,
summary_message,
)
from app.services.equipment_acceptance.alert_plan import (
assemble_tier,
due_tiers,
@@ -27,7 +36,7 @@ from app.services.equipment_acceptance.alert_plan import (
resolve_account,
resolve_configured_user,
)
from app.services.equipment_acceptance.config_service import reminder_days
from app.services.equipment_acceptance.config_service import is_round_4_enabled, reminder_days
from app.services.equipment_acceptance.snapshot_rules import WATCHING
_LOGGER = logging.getLogger(__name__)
@@ -61,7 +70,7 @@ def refresh_pending_alerts(
"""
按本地快照刷新待发送记录。
核心逻辑:计时中的单据跨过哪一档就保留哪一档。已发送和已取消不改。
核心逻辑:计时中的单据跨过哪一档就保留哪一档。第 4 轮关闭时最高只到第 3 档。已发送和已取消不改。
未计时或已停表的单据,把还没发出的记录改成已取消。
Args:
directory: 测试注入的人员目录和经副理。空则查询 E10。
@@ -74,6 +83,7 @@ def refresh_pending_alerts(
users_by_job = _users_by_job(_job_numbers(orders, operators, people, deputies))
roles = _configured_users()
thresholds = reminder_days()
max_tier = 4 if is_round_4_enabled() else 3
existing = {
(row.order_id, row.tier): row
for row in db.session.query(EquipmentAcceptanceSendRecord).all()
@@ -86,7 +96,16 @@ def refresh_pending_alerts(
if order.monitor_status != WATCHING:
cancelled += cancel_unsent(order.id)
continue
for draft in _drafts(order, operators.get(order.id, []), people, deputies, users_by_job, roles, thresholds):
for draft in _drafts(
order,
operators.get(order.id, []),
people,
deputies,
users_by_job,
roles,
thresholds,
max_tier=max_tier,
):
current = existing.get((order.id, draft["tier"]))
if current is not None and current.status in ("sent", "cancelled"):
continue
@@ -136,24 +155,37 @@ def send_pending_alerts() -> dict[str, Any]:
"""
把待发送记录按收件人合并成一条企业微信。
核心逻辑:同一个人本轮只收一条。解析失败的人不改发给别人。已取消和已发送不参与。
核心逻辑:同一个人本轮只收一条汇总卡片和一份 Excel。卡片只写张数,明细在文件里。
解析失败的人不改发给别人。已取消和已发送不参与。
第 4 轮关闭时,已生成的待发送第 4 轮也不发出,避免通知总经理。
卡片或附件任一失败都记失败原因,并打一条 warning 日志。
每位收件人的 Excel 都写入 equipment_acceptance_send_files,发送失败也保留。
Returns:
成功人数、失败人数,以及对应的记录条数。
"""
from app.models import Agent
from app.services.integrations.wecom.notify import send_wecom_event_message
from app.services.integrations.wecom.notify import (
send_wecom_event_message,
send_wecom_file_message,
upload_wecom_temp_media,
)
rows = (
db.session.query(EquipmentAcceptanceSendRecord)
.filter(EquipmentAcceptanceSendRecord.status == "pending")
.all()
)
if not is_round_4_enabled():
rows = [row for row in rows if row.tier != 4]
orders = {
order.id: order
for order in db.session.query(EquipmentAcceptanceOrder)
.filter(EquipmentAcceptanceOrder.id.in_([row.order_id for row in rows if row.order_id]))
.all()
} if rows else {}
order_ids = [row.order_id for row in rows if row.order_id]
nodes = _nodes_by_order(order_ids)
operators = _operators_by_order(order_ids)
users = _users_by_id(_recipient_user_ids(rows))
buckets: dict[str, list[tuple[EquipmentAcceptanceSendRecord, dict[str, Any]]]] = {}
for row in rows:
@@ -166,24 +198,58 @@ def send_pending_alerts() -> dict[str, Any]:
jump_path = f"/chat/{agent.id}" if agent is not None else "/workspace"
jump_params = {"view": "sends"} if agent is not None else None
sent_ids: set[str] = set()
failed_ids: set[str] = set()
failed_reasons: dict[str, str] = {}
for wecom_id, entries in buckets.items():
user = _audit_user(entries, users)
lines = _notice_lines(entries, orders, nodes, operators)
workbook = build_notice_workbook(lines)
archived = _archive_send_file(user, entries, workbook)
failure = ""
try:
result = send_wecom_event_message(
event_type=_EVENT,
user=user,
title="设备验收停留提醒",
content=_message(entries, orders),
content=summary_message(lines),
jump_path=jump_path,
jump_params=jump_params,
wecom_userid=wecom_id,
)
ok = bool(result.get("ok"))
except Exception:
_LOGGER.warning("equipment acceptance wecom send failed")
ok = False
(sent_ids if ok else failed_ids).add(wecom_id)
_LOGGER.exception("equipment acceptance wecom send failed")
failure = "企业微信发送异常"
result = {}
if not failure and not result.get("ok"):
failure = _wecom_failure_text(result)
_LOGGER.warning(
"equipment acceptance wecom send failed reason=%s trace_id=%s detail=%s",
result.get("reason"),
result.get("trace_id"),
failure,
)
if not failure:
try:
media_id = upload_wecom_temp_media(workbook, archived.excel_file_name or NOTICE_FILE_NAME)
file_result = send_wecom_file_message(wecom_id, media_id)
except Exception:
_LOGGER.exception("equipment acceptance wecom file upload failed")
failure = "企业微信附件上传失败"
file_result = {}
if not failure and file_result.get("errcode") != 0:
failure = _file_failure_text(file_result)
_LOGGER.warning(
"equipment acceptance wecom file failed errcode=%s errmsg=%s",
file_result.get("errcode"),
failure,
)
if failure:
failed_reasons[wecom_id] = failure
archived.status = "failed"
archived.error_message = failure
else:
sent_ids.add(wecom_id)
archived.status = "sent"
archived.sent_at = datetime.utcnow()
records_sent = 0
records_failed = 0
now = datetime.utcnow()
@@ -196,9 +262,10 @@ def send_pending_alerts() -> dict[str, Any]:
ready.discard("")
if not ready:
continue
if ready & failed_ids:
hit = [failed_reasons[item] for item in ready if item in failed_reasons]
if hit:
row.status = "failed"
row.error_message = _join_error(row.error_message, "企业微信发送失败")
row.error_message = _join_error(row.error_message, ";".join(dict.fromkeys(hit)))
records_failed += 1
elif ready <= sent_ids:
row.status = "sent"
@@ -207,7 +274,7 @@ def send_pending_alerts() -> dict[str, Any]:
db.session.commit()
return {
"sent": len(sent_ids),
"failed": len(failed_ids),
"failed": len(failed_reasons),
"records_sent": records_sent,
"records_failed": records_failed,
}
@@ -221,9 +288,11 @@ def _drafts(
users_by_job: dict[str, User],
roles: dict[str, User | None],
thresholds: tuple[int, int, int, int],
*,
max_tier: int = 4,
) -> list[dict[str, Any]]:
"""按当前处理人展开四档里已经跨过的档。"""
due = due_tiers(order.dwell_days, thresholds)
"""按当前处理人展开已经跨过、且配置允许的档。第 4 轮关闭时最高到第 3 档。"""
due = due_tiers(order.dwell_days, thresholds, max_tier=max_tier)
if not due:
return []
handlers: list[dict[str, Any]] = []
@@ -410,6 +479,21 @@ def _users_by_id(user_ids: list[int]) -> dict[int, User]:
return {row.id: row for row in rows}
def _nodes_by_order(order_ids: list[int]) -> dict[int, list[EquipmentAcceptanceNode]]:
"""取出这些验收单的当前节点名称。"""
if not order_ids:
return {}
grouped: dict[int, list[EquipmentAcceptanceNode]] = {}
rows = (
db.session.query(EquipmentAcceptanceNode)
.filter(EquipmentAcceptanceNode.order_id.in_(order_ids))
.all()
)
for row in rows:
grouped.setdefault(row.order_id, []).append(row)
return grouped
def _operators_by_order(order_ids: list[int]) -> dict[int, list[EquipmentAcceptanceOperator]]:
"""取出这些验收单的当前处理人。"""
if not order_ids:
@@ -447,28 +531,145 @@ def _audit_user(
return None
def _message(
def _archive_send_file(
user: User | None,
entries: list[tuple[EquipmentAcceptanceSendRecord, dict[str, Any]]],
workbook: bytes,
) -> EquipmentAcceptanceSendFile:
"""
把这次准备发给一名收件人的 Excel 先落库。
核心逻辑:发送成功或失败都保留同一份字节,并记下里面的发送记录,供表格列下载。不保存企微 userid。
Args:
user: 系统用户。对不上账号时只留姓名。
entries: 这名收件人的发送记录和席位,用来取展示名。
workbook: xlsx 字节。
Returns:
已加入当前事务、尚未提交的文件行。
"""
now = datetime.utcnow()
name = _recipient_display_name(user, entries)
row = EquipmentAcceptanceSendFile(
recipient_user_id=None if user is None else user.id,
recipient_name=name or None,
excel_file_name=_archive_file_name(name, now),
excel_file_data=workbook,
excel_file_size=len(workbook),
send_record_ids=[row.id for row, _person in entries if row.id],
status="pending",
created_at=now,
)
db.session.add(row)
return row
def _recipient_display_name(
user: User | None,
entries: list[tuple[EquipmentAcceptanceSendRecord, dict[str, Any]]],
) -> str:
"""优先用系统姓名,没有账号时用收件人席位上的名字。"""
if user is not None:
named = str(user.real_name or user.username or "").strip()
if named:
return named
for _row, person in entries:
named = str(person.get("name") or "").strip()
if named:
return named
return ""
def _archive_file_name(recipient_name: str, moment: datetime) -> str:
"""文件名带上海日期和收件人,避免多次发送都叫同一个名字。"""
local = moment.replace(tzinfo=ZoneInfo("UTC")).astimezone(ZoneInfo("Asia/Shanghai"))
safe = "".join(char for char in recipient_name if char not in '\\/:*?"<>|').strip() or "收件人"
return f"设备验收停留提醒-{local:%Y%m%d}-{safe}.xlsx"[:255]
def _notice_lines(
entries: list[tuple[EquipmentAcceptanceSendRecord, dict[str, Any]]],
orders: dict[int, EquipmentAcceptanceOrder],
) -> str:
"""拼一名收件人本轮要看的验收单。过长时截断。"""
lines: list[str] = []
seen: set[int] = set()
nodes: dict[int, list[EquipmentAcceptanceNode]],
operators: dict[int, list[EquipmentAcceptanceOperator]],
) -> list[dict[str, Any]]:
"""
把一名收件人的发送记录收成 Excel 行。
核心逻辑:同一条发送记录只占一行。通知身份用角色名,例如当前处理人、直接主管,不写主送或抄送。
Args:
entries: 这名收件人挂到的发送记录和对应席位。
orders: 验收单主键到快照。
nodes: 验收单主键到当前节点。
operators: 验收单主键到当前处理人。
Returns:
传给汇总文案和 Excel 的明细行。
"""
grouped: dict[int, dict[str, Any]] = {}
order_keys: list[int] = []
for row, person in entries:
if row.id in seen:
continue
seen.add(row.id)
label = str(person.get("label") or "").strip()
bucket = grouped.get(row.id)
if bucket is None:
bucket = {"row": row, "labels": []}
grouped[row.id] = bucket
order_keys.append(row.id)
if label and label not in bucket["labels"]:
bucket["labels"].append(label)
lines: list[dict[str, Any]] = []
for key in order_keys:
row = grouped[key]["row"]
order = orders.get(row.order_id or 0)
days = "—" if order is None or order.dwell_days is None else str(order.dwell_days)
role = "主送" if person.get("slot") == "to" else "抄送"
lines.append(
f"{role} {row.acceptance_no or '—'},采购单 {row.purchase_order_no or '—'},"
f"停留 {days} 天,超过 {row.threshold_days} 天"
)
text = "\n".join(lines[:12])
if len(lines) > 12:
text = f"{text}\n另有 {len(lines) - 12} 条"
return text[:500]
node_names = _unique_text(node.node_name for node in nodes.get(row.order_id or 0, []))
handler_names = _unique_text(operator.handler_name for operator in operators.get(row.order_id or 0, []))
lines.append({
"acceptance_no": row.acceptance_no,
"purchase_order_no": row.purchase_order_no,
"applicant": None if order is None else order.applicant_name,
"threshold_days": row.threshold_days,
"dwell_days": None if order is None else order.dwell_days,
"node_name": "、".join(node_names),
"handlers": "、".join(handler_names),
"identity": "、".join(grouped[key]["labels"]),
})
return lines
def _unique_text(values) -> list[str]:
"""按出现顺序去掉空白和重复名称。"""
found: list[str] = []
for value in values:
text = str(value or "").strip()
if text and text not in found:
found.append(text)
return found
def _file_failure_text(result: dict[str, Any]) -> str:
"""把企微文件消息的返回收成失败原因。不写入 userid。"""
code = result.get("errcode")
message = str(result.get("errmsg") or "").strip()
text = f"企业微信附件发送失败 {code} {message}".strip()
return text[:255]
def _wecom_failure_text(result: dict[str, Any]) -> str:
"""把企微发送结果收成页面和日志都能看的失败原因。不写入 userid。"""
reason = str(result.get("reason") or "")
if reason == "notify_disabled":
return "企业微信通知总开关已关闭"
if reason == "event_disabled":
return "未开启设备验收预警的企业微信事件"
if reason == "user_unbound":
return "收件人未绑定企业微信"
raw = result.get("raw") if isinstance(result.get("raw"), dict) else {}
if reason == "send_failed":
code = raw.get("errcode")
message = str(raw.get("errmsg") or "").strip()
text = f"企业微信返回 {code} {message}".strip()
return text[:255]
if reason == "exception":
return "企业微信发送异常"
return "企业微信发送失败"
def _join_error(current: str | None, extra: str) -> str:
@@ -1,10 +1,10 @@
"""
backend/app/services/equipment_acceptance/config_service.py
用途:读写设备验收预警配置:四档天数和三个固定岗位。
用途:读写设备验收预警配置:四档天数、第 4 轮开关和三个固定岗位。
依赖:extensions.db、EquipmentAcceptanceSetting、User、统一错误。
逻辑:配置页和停留列表调用。岗位只存系统用户主键。发送时刻不在这里,由排程 Cron 决定。
没有配置行时按冻结默认值 30/37/44/51 返回,不把姓名写进代码。
没有配置行时按冻结默认值 30/37/44/51 返回,第 4 轮默认关闭,不把姓名写进代码。
"""
from __future__ import annotations
@@ -29,6 +29,44 @@ _ROLE_FIELDS = (
_MAX_DAY = 3650
def is_round_4_enabled() -> bool:
"""
读取第 4 轮是否启用。
核心逻辑:没有配置行或字段为假时关闭。关闭后扫描不生成、发送不推出总经理那一轮。
Returns:
启用为 True。
"""
row = db.session.get(EquipmentAcceptanceSetting, _SETTING_ID)
if row is None:
return False
return bool(row.round_4_enabled)
def parse_round_4_enabled(raw: Any) -> bool:
"""
校验第 4 轮开关。
核心逻辑:缺省按关闭处理,避免旧请求误打开总经理提醒。传入值必须是布尔。
Args:
raw: 接口里的 round_4_enabled。缺省为 None。
Returns:
是否启用第 4 轮。
Raises:
ValidationError: 传入了布尔以外的值。
"""
if raw is None:
return False
if not isinstance(raw, bool):
raise ValidationError(
"第 4 轮开关必须是是否启用",
code="EQUIPMENT_ACCEPTANCE.SETTINGS_INVALID",
details={"field": "round_4_enabled"},
)
return raw
def reminder_days() -> tuple[int, int, int, int]:
"""
读取四档天数。
@@ -65,12 +103,13 @@ def get_acceptance_config(*, include_candidates: bool) -> dict[str, Any]:
Args:
include_candidates: 为 True 时附带在职用户,供选人弹窗使用。
Returns:
days、三个岗位用户主键、已选用户、候选人和更新时间。
days、第 4 轮开关、三个岗位用户主键、已选用户、候选人和更新时间。
"""
row = db.session.get(EquipmentAcceptanceSetting, _SETTING_ID)
selected_ids = _selected_ids(row)
return {
"days": list(_days_of(row)),
"round_4_enabled": False if row is None else bool(row.round_4_enabled),
"buyer_manager_user_id": None if row is None else row.buyer_manager_user_id,
"coo_user_id": None if row is None else row.coo_user_id,
"executive_user_id": None if row is None else row.executive_user_id,
@@ -82,12 +121,12 @@ def get_acceptance_config(*, include_candidates: bool) -> dict[str, Any]:
def save_acceptance_config(payload: dict[str, Any], *, updated_by: int) -> dict[str, Any]:
"""
保存四档天数和三个岗位用户。
保存四档天数、第 4 轮开关和三个岗位用户。
核心逻辑:天数必须逐档增大。岗位为空表示未选;有值时必须是已存在的系统用户。
保存后只影响以后的预警,这里不改历史发送记录。
核心逻辑:天数必须逐档增大。第 4 轮缺省为关闭。岗位为空表示未选;有值时必须是已存在的系统用户。
保存后只影响以后的预警,这里不改历史发送记录。已有的待发送第 4 轮在发送时会被跳过。
Args:
payload: days 为四个整数;三个岗位字段为用户主键或空。
payload: days 为四个整数;round_4_enabled 为布尔;三个岗位字段为用户主键或空。
updated_by: 操作人的系统用户主键。
Returns:
与读取接口相同的配置,并带候选人。
@@ -96,12 +135,14 @@ def save_acceptance_config(payload: dict[str, Any], *, updated_by: int) -> dict[
ValidationError: 天数不合法,或岗位用户不存在。
"""
days = validate_reminder_days(payload.get("days"))
round_4_enabled = parse_round_4_enabled(payload.get("round_4_enabled"))
role_ids = {field: _require_user_id(payload.get(field), field) for field in _ROLE_FIELDS}
row = db.session.get(EquipmentAcceptanceSetting, _SETTING_ID)
if row is None:
row = EquipmentAcceptanceSetting(id=_SETTING_ID)
db.session.add(row)
row.day_1, row.day_2, row.day_3, row.day_4 = days
row.round_4_enabled = round_4_enabled
row.buyer_manager_user_id = role_ids["buyer_manager_user_id"]
row.coo_user_id = role_ids["coo_user_id"]
row.executive_user_id = role_ids["executive_user_id"]
@@ -2,17 +2,20 @@
backend/app/services/equipment_acceptance/send_record_service.py
用途:分页读取设备验收预警的发送记录。
依赖:extensions.db、EquipmentAcceptanceSendRecord、utc_iso。
逻辑:由 GET /api/equipment-acceptance/sends 调用。待发送由扫描写入,本模块只读取。
依赖:extensions.db、EquipmentAcceptanceSendRecord、EquipmentAcceptanceSendFile、utc_iso。
逻辑:由发送记录列表和 Excel 下载接口调用。列表按 send_record_ids 把 Excel 挂到对应行,不读文件字节。
"""
from __future__ import annotations
from typing import Any
from sqlalchemy.orm import defer
from app.core.errors import NotFoundError
from app.core.response import utc_iso
from app.extensions import db
from app.models.equipment_acceptance import EquipmentAcceptanceSendRecord
from app.models.equipment_acceptance import EquipmentAcceptanceSendFile, EquipmentAcceptanceSendRecord
def list_send_records(*, page: int, page_size: int) -> dict[str, Any]:
@@ -36,21 +39,122 @@ def list_send_records(*, page: int, page_size: int) -> dict[str, Any]:
.limit(page_size)
.all()
)
file_rows = _file_rows_for([row.id for row in rows])
return {
"items": [send_record_payload(row) for row in rows],
"items": [
send_record_payload(row, _files_for_record(row.id, file_rows))
for row in rows
],
"total": total,
"page": page,
"page_size": page_size,
}
def send_record_payload(row: EquipmentAcceptanceSendRecord) -> dict[str, Any]:
def list_send_files(*, limit: int = 20) -> list[dict[str, Any]]:
"""
列出最近留下的收件人 Excel,不含文件字节。
核心逻辑:按创建时间倒序。发送失败的文件也返回,方便对照当时准备发出的明细。
Args:
limit: 最多返回条数,上限 50。
Returns:
文件名、收件人、状态和发送时间。
"""
limit = min(50, max(1, limit))
rows = (
db.session.query(EquipmentAcceptanceSendFile)
.order_by(EquipmentAcceptanceSendFile.created_at.desc(), EquipmentAcceptanceSendFile.id.desc())
.limit(limit)
.all()
)
return [send_file_payload(row) for row in rows]
def get_send_file(file_id: int) -> EquipmentAcceptanceSendFile:
"""
取出一份已归档的 Excel。
Args:
file_id: 文件行主键。
Returns:
含字节的文件行。
Raises:
NotFoundError: 记录不存在或没有文件内容。
"""
row = db.session.get(EquipmentAcceptanceSendFile, file_id)
if row is None or not row.excel_file_data:
raise NotFoundError("设备验收预警附件不存在")
return row
def send_file_payload(row: EquipmentAcceptanceSendFile) -> dict[str, Any]:
"""列表用的文件摘要。不返回 Excel 字节。"""
return {
"id": row.id,
"recipient_name": row.recipient_name,
"excel_file_name": row.excel_file_name,
"excel_file_size": row.excel_file_size,
"status": row.status,
"sent_at": utc_iso(row.sent_at),
"created_at": utc_iso(row.created_at),
}
def _file_rows_for(record_ids: list[int]) -> list[EquipmentAcceptanceSendFile]:
"""
取出可能挂在这些发送记录上的 Excel 摘要。
核心逻辑:延迟加载文件字节,只留下文件名和记录编号,避免列表把整份 xlsx 读进内存。
Args:
record_ids: 当前页发送记录主键。为空时不查。
Returns:
归档文件行,不含 excel_file_data。
"""
if not record_ids:
return []
return (
db.session.query(EquipmentAcceptanceSendFile)
.options(defer(EquipmentAcceptanceSendFile.excel_file_data))
.order_by(EquipmentAcceptanceSendFile.id.asc())
.all()
)
def _files_for_record(record_id: int, file_rows: list[EquipmentAcceptanceSendFile]) -> list[dict[str, Any]]:
"""
挑出包含这条发送记录的 Excel。
核心逻辑:send_record_ids 里有这条记录才挂上。没有文件名的不展示。
Args:
record_id: 发送记录主键。
file_rows: 已去掉文件字节的归档行。
Returns:
下载按钮需要的 id 和文件名。
"""
found: list[dict[str, Any]] = []
for row in file_rows:
ids = {int(item) for item in list(row.send_record_ids or []) if item}
if record_id in ids and row.excel_file_name:
found.append({
"id": row.id,
"excel_file_name": row.excel_file_name,
})
return found
def send_record_payload(
row: EquipmentAcceptanceSendRecord,
files: list[dict[str, Any]] | None = None,
) -> dict[str, Any]:
"""
把一条发送记录收成接口数据。
核心逻辑:单号和主送、抄送用写入时的快照,不回读当前岗位。
核心逻辑:单号和主送、抄送用写入时的快照,不回读当前岗位。Excel 只带文件名和主键。
Args:
row: 本地发送记录。
files: 这份记录出现过的归档 Excel。
Returns:
页签表格用的字段。
"""
@@ -68,4 +172,5 @@ def send_record_payload(row: EquipmentAcceptanceSendRecord) -> dict[str, Any]:
"sent_at": utc_iso(row.sent_at),
"error_message": row.error_message,
"created_at": utc_iso(row.created_at),
"files": files or [],
}
@@ -0,0 +1,97 @@
"""补齐设备验收预警的企微事件、第 4 轮开关和 Excel 归档。
Revision ID: eah8c9d0e1f2
Revises: b7a2b2155155
Create Date: 2026-10-13 14:30:00.000000
用途:把尚未提交的三步收成一次升级。已有库如果停在本版本,结构已经齐,不会重跑。
依赖:b7a2b2155155、app_settings、equipment_acceptance_settings、users。
逻辑:企微事件名单末尾补上 equipment_acceptance_warning;第 4 轮默认关闭;按收件人留下发送时的 Excel。
"""
from alembic import op
import sqlalchemy as sa
from sqlalchemy import text
revision = "eah8c9d0e1f2"
down_revision = "b7a2b2155155"
branch_labels = None
depends_on = None
_KEY = "WECOM_NOTIFY_EVENTS"
_EVENT = "equipment_acceptance_warning"
def _split_events(raw: str | None) -> list[str]:
"""按逗号拆开事件名单,去掉空白项。"""
return [part.strip() for part in str(raw or "").split(",") if part.strip()]
def upgrade():
"""补上企微事件、第 4 轮开关,并建立按收件人归档 Excel 的表。"""
_append_wecom_event()
op.add_column(
"equipment_acceptance_settings",
sa.Column("round_4_enabled", sa.Boolean(), nullable=False, server_default=sa.false()),
)
op.create_table(
"equipment_acceptance_send_files",
sa.Column("id", sa.Integer(), primary_key=True),
sa.Column("recipient_user_id", sa.Integer(), nullable=True),
sa.Column("recipient_name", sa.String(length=200), nullable=True),
sa.Column("excel_file_name", sa.String(length=255), nullable=True),
sa.Column("excel_file_data", sa.LargeBinary(), nullable=True),
sa.Column("excel_file_size", sa.Integer(), nullable=True),
sa.Column("send_record_ids", sa.JSON(), nullable=True),
sa.Column("status", sa.String(length=32), nullable=False),
sa.Column("error_message", sa.Text(), nullable=True),
sa.Column("sent_at", sa.DateTime(), nullable=True),
sa.Column("created_at", sa.DateTime(), nullable=False),
sa.ForeignKeyConstraint(["recipient_user_id"], ["users.id"], ondelete="SET NULL"),
)
op.create_index(
"ix_equipment_acceptance_send_files_created",
"equipment_acceptance_send_files",
["created_at"],
)
def downgrade():
"""按相反顺序去掉 Excel 归档、第 4 轮开关和企微事件。"""
op.drop_index("ix_equipment_acceptance_send_files_created", table_name="equipment_acceptance_send_files")
op.drop_table("equipment_acceptance_send_files")
op.drop_column("equipment_acceptance_settings", "round_4_enabled")
_remove_wecom_event()
def _append_wecom_event() -> None:
"""已有事件名单时在末尾补上设备验收预警。没有这一行则不插入。"""
bind = op.get_bind()
if "app_settings" not in sa.inspect(bind).get_table_names():
return
row = bind.execute(text("SELECT value FROM app_settings WHERE key = :key"), {"key": _KEY}).fetchone()
if row is None:
return
events = _split_events(row[0])
if _EVENT in events:
return
events.append(_EVENT)
bind.execute(
text("UPDATE app_settings SET value = :value, updated_at = CURRENT_TIMESTAMP WHERE key = :key"),
{"key": _KEY, "value": ",".join(events)},
)
def _remove_wecom_event() -> None:
"""从已保存的企微事件名单里去掉设备验收预警。没有这一行时不处理。"""
bind = op.get_bind()
if "app_settings" not in sa.inspect(bind).get_table_names():
return
row = bind.execute(text("SELECT value FROM app_settings WHERE key = :key"), {"key": _KEY}).fetchone()
if row is None:
return
events = [part for part in _split_events(row[0]) if part != _EVENT]
bind.execute(
text("UPDATE app_settings SET value = :value, updated_at = CURRENT_TIMESTAMP WHERE key = :key"),
{"key": _KEY, "value": ",".join(events)},
)
@@ -0,0 +1,58 @@
"""
tests/test_equipment_acceptance_alert_notice.py
用途:锁定设备验收企微汇总文案和 Excel 列。
依赖:alert_notice、openpyxl。
逻辑:不连数据库,不发企业微信。卡片只写张数。工作簿含申请人,不写主送。
"""
from io import BytesIO
import pytest
from openpyxl import load_workbook
pytestmark = pytest.mark.pure_unit
from app.services.equipment_acceptance.alert_notice import (
NOTICE_HEADERS,
build_notice_workbook,
summary_message,
)
def test_summary_counts_rounds_without_listing_orders():
"""第一行写已逾期张数。正文不出现验收单号,也不写主送。"""
text = summary_message([
{"threshold_days": 30},
{"threshold_days": 30},
{"threshold_days": 37},
])
assert text == "共 3 张验收单已逾期。\n超过 30 天 2 张,超过 37 天 1 张。\n明细见下一条文件。"
assert "主送" not in text
assert "20260210" not in text
def test_workbook_includes_applicant_and_identity():
"""Excel 列与原型一致。通知身份保留角色名,停留天数为空时写横线。"""
data = build_notice_workbook([{
"acceptance_no": "20260210000001",
"purchase_order_no": "1111",
"applicant": "孙浩",
"threshold_days": 30,
"dwell_days": None,
"node_name": "使用部门担当",
"handlers": "吴敏",
"identity": "直接主管",
}])
sheet = load_workbook(BytesIO(data)).active
assert [cell.value for cell in sheet[1]] == list(NOTICE_HEADERS)
assert [cell.value for cell in sheet[2]] == [
"20260210000001",
"1111",
"孙浩",
"超过 30 天",
"—",
"使用部门担当",
"吴敏",
"直接主管",
]
@@ -30,6 +30,7 @@ def test_due_tiers_use_strictly_greater_than_threshold():
assert due_tiers(31, _DAYS) == [1]
assert due_tiers(51, _DAYS) == [1, 2, 3]
assert due_tiers(52, _DAYS) == [1, 2, 3, 4]
assert due_tiers(52, _DAYS, max_tier=3) == [1, 2, 3]
def test_tier_one_keeps_missing_supervisor_as_failure():
@@ -1,15 +1,15 @@
"""
tests/test_equipment_acceptance_config.py
用途:锁定设备验收预警四档天数的保存前校验。
依赖:config_service.validate_reminder_days、ValidationError。
逻辑:不连数据库。默认 30/37/44/51 通过;相等、倒序、非整数和空岗位以外的天数形状被拒绝。
用途:锁定设备验收预警四档天数和第 4 轮开关的保存前校验。
依赖:config_service.validate_reminder_days、parse_round_4_enabled、ValidationError。
逻辑:不连数据库。默认 30/37/44/51 通过;相等、倒序、非整数和空岗位以外的天数形状被拒绝。第 4 轮缺省关闭。
"""
import pytest
from app.core.errors import ValidationError
from app.services.equipment_acceptance.config_service import validate_reminder_days
from app.services.equipment_acceptance.config_service import parse_round_4_enabled, validate_reminder_days
def test_default_reminder_days_pass():
@@ -30,3 +30,13 @@ def test_days_reject_bool_and_wrong_length():
validate_reminder_days([True, 37, 44, 51])
with pytest.raises(ValidationError):
validate_reminder_days([30, 37, 44])
def test_round_4_defaults_off_and_rejects_non_bool():
"""未传开关时按关闭处理。数字 1 不能当成启用,避免误通知总经理。"""
assert parse_round_4_enabled(None) is False
assert parse_round_4_enabled(False) is False
assert parse_round_4_enabled(True) is True
with pytest.raises(ValidationError) as caught:
parse_round_4_enabled(1)
assert caught.value.code == "EQUIPMENT_ACCEPTANCE.SETTINGS_INVALID"
+1 -1
View File
@@ -22,7 +22,7 @@
## 设备验收预警(2026-09)
- 从 OA 资产验收单第一次进入「使用部门担当」起按自然日累计停留;只监控未归档、有效、可以验收的流程。归档、退回、撤回、作废或无法验收立即停表。再进入时计时起点不改,仍按第一次写入的 `sbsyrjssj` 计算,不从 0 重计。`sfzfth` 不考虑从退回改回正常。
- 超过 30/37/44/51 天各发一次企业微信。担当、直接主管、经副理取当前节点处理人及其上级;采购担当取流程申请人。采购经副理、COO、总经理可在界面配置。每日扫描只生成待发送,初始每周五 18:00 按收件人汇总。
- 超过 30/37/44/51 天各发一次企业微信。第 4 轮默认关闭,配置打开后才通知总经理。担当、直接主管、经副理取当前节点处理人及其上级;采购担当取流程申请人。采购经副理、COO、总经理可在界面配置。每日扫描只生成待发送,初始每周五 18:00 按收件人发送汇总卡片和 Excel 明细。
- 规则已冻结。验收单读 E10 `ecology10.dbo.ft_gdzcysdv2`,人员 ID 经 `eteams.dbo.employee` 用工号对上系统用户。流程状态读 `wfc_requestbase.flowstatus`,`7`、`8`、`99`、`-99` 都按撤销停表。当前节点读 `wfc_currentnode` 再关联 `wfp_node`,当前处理人读 `wfc_operate.userid`。直接主管取 `employee.SUPERIOR`,经副理按 `employee.DEPARTMENT` 查 E10 部门矩阵。申请人 `sqr` 是人员 ID。退回为 `sfzfth = 0`。无法验收说明正文是 `ycsm`,只留痕。只读同步、停留列表、发送记录、每日扫描和周五企业微信已实现,入口与合同付款预警相同(内置 Chat Agent `equipment_acceptance`)。不查询、不保存 `isremark`。默认每天 06:00 扫描、每周五 18:00 按收件人发送。停表取消未发送,已发送不撤回。需求见 [设备验收预警需求](features/equipment-acceptance-warning/demand.md),数据设计见 [technical.md](features/equipment-acceptance-warning/technical.md)。
## 合同付款预警 Agent(2026-08)
@@ -76,6 +76,9 @@
}
.when { display: flex; flex-direction: column; gap: 8px; }
.when b { font-size: 12px; color: var(--muted); font-weight: 700; }
.switch { display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 700; }
.when small { color: var(--muted); font-size: 12px; }
.round.off .people { opacity: 0.45; }
.day {
display: flex;
align-items: center;
@@ -267,10 +270,12 @@
</div>
</article>
<article class="round">
<article class="round off" id="round4">
<div class="when">
<b>第 4 轮</b>
<label class="day">超过 <input value="51" /> 天</label>
<label class="switch"><input id="round4Switch" type="checkbox" /> 启用第 4 轮</label>
<small>默认关闭,不通知总经理</small>
</div>
<div class="people">
<div class="line">
@@ -305,7 +310,12 @@
<button class="save" type="button">保存配置</button>
</div>
</section>
<p class="mark">效果图,尚未接到现有页面。</p>
<p class="mark">效果图。第 4 轮开关已接到现有配置页,默认关闭。</p>
<script>
document.getElementById("round4Switch").addEventListener("change", (event) => {
document.getElementById("round4").classList.toggle("off", !event.target.checked);
});
</script>
</main>
</body>
</html>
@@ -60,6 +60,8 @@
| 超过 44 天 | COO | 采购经副理 |
| 超过 51 天 | 总经理 | COO、采购经副理 |
第 4 轮在配置里单独开关,默认关闭。关闭时不生成、也不发送总经理这一轮。打开后,下一次扫描才按超过第 4 档的天数产生待发送。前 3 轮不受这个开关影响。
人员解析:
- 担当、直接主管、经副理取**当前节点处理人**及其上级,不固定成「使用部门担当」本人。
@@ -70,7 +72,7 @@
## 6. 推送
已确认:扫描与发送分离。发送时刻做成可配置,**初始对齐合同付款预警,为每周五 18:00**(见 [合同付款预警需求](../contract-payment-plan/demand.md))。到点后按收件人合并为一条企业微信汇总。渠道只有企业微信。
已确认:扫描与发送分离。发送时刻做成可配置,**初始对齐合同付款预警,为每周五 18:00**(见 [合同付款预警需求](../contract-payment-plan/demand.md))。到点后按收件人合并为一条企业微信汇总卡片,并紧跟一份只含该收件人明细的 Excel。这份 Excel 按收件人归档,挂在发送记录表的 Excel 附件列上,点文件名再下载。卡片不逐条列出验收单,也不区分主送和抄送。渠道只有企业微信。
## 7. 数据来源
@@ -0,0 +1,279 @@
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8" />
<title>设备验收预警 · 发送效果图</title>
<style>
:root {
--ink: #142033;
--muted: #64748b;
--line: #dce4ef;
--paper: #ffffff;
--page: #f3f6fa;
--brand: #1d4e89;
--chat: #ededed;
--ok: #217346;
}
* { box-sizing: border-box; }
body {
margin: 0;
min-height: 100vh;
background: var(--page);
color: var(--ink);
font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}
.page { max-width: 1180px; margin: 0 auto; padding: 18px 20px 48px; }
h1 { margin: 0; font-size: 20px; }
.note { margin: 8px 0 0; color: var(--muted); font-size: 13px; }
.grid {
display: grid;
grid-template-columns: 380px minmax(0, 1fr);
gap: 16px;
margin-top: 16px;
align-items: start;
}
.panel {
background: var(--paper);
border: 1px solid var(--line);
border-radius: 16px;
box-shadow: 0 1px 2px rgba(20, 32, 51, 0.04);
}
.panel h2 { margin: 0; font-size: 15px; }
.panel .sub { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.head { padding: 16px 18px 0; }
.phone {
margin: 14px 18px 18px;
border-radius: 28px;
background: #111;
padding: 10px;
}
.screen {
overflow: hidden;
border-radius: 20px;
background: var(--chat);
min-height: 560px;
}
.bar {
display: flex;
align-items: center;
justify-content: center;
height: 48px;
background: #f7f7f7;
border-bottom: 1px solid #e5e5e5;
font-size: 15px;
font-weight: 700;
}
.thread { padding: 16px 14px 22px; }
.time { margin: 0 0 12px; text-align: center; color: #8a8a8a; font-size: 12px; }
.card {
background: #fff;
border-radius: 6px;
padding: 14px 14px 0;
box-shadow: 0 1px 1px rgba(0, 0, 0, 0.04);
}
.card h3 { margin: 0 0 10px; font-size: 16px; font-weight: 700; }
.card p { margin: 0; color: #3d3d3d; font-size: 14px; line-height: 1.65; white-space: pre-line; }
.more {
display: flex;
align-items: center;
justify-content: space-between;
margin-top: 12px;
padding: 10px 0 12px;
border-top: 1px solid #ececec;
color: #1f1f1f;
font-size: 14px;
}
.file {
display: flex;
align-items: center;
gap: 10px;
width: 250px;
margin-top: 10px;
padding: 10px 12px;
background: #fff;
border-radius: 6px;
}
.xls {
display: grid;
place-items: center;
width: 36px;
height: 40px;
border-radius: 4px;
background: var(--ok);
color: #fff;
font-size: 11px;
font-weight: 800;
}
.file b { display: block; font-size: 13px; font-weight: 650; }
.file span { color: #8a8a8a; font-size: 12px; }
.sheet { padding: 8px 12px 16px; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 12px; }
th, td { padding: 8px 10px; text-align: left; white-space: nowrap; }
.sheet th { background: #e8f3ec; color: #145c32; font-weight: 700; border-bottom: 1px solid #cfe3d6; }
.sheet td { border-bottom: 1px solid #edf2f7; }
.sheet tr:nth-child(even) td { background: #fbfcfd; }
.foot { padding: 0 18px 16px; color: var(--muted); font-size: 12px; }
.admin { margin-top: 16px; }
.tabs { display: flex; gap: 4px; margin-top: 14px; border-bottom: 1px solid var(--line); }
.tabs span {
margin-bottom: -1px;
padding: 8px 12px 10px;
border-bottom: 2px solid transparent;
color: var(--muted);
font-size: 14px;
font-weight: 700;
}
.tabs .on { border-color: var(--brand); color: var(--brand); }
.toolbar {
display: flex;
align-items: center;
justify-content: space-between;
gap: 12px;
padding: 12px 18px 0;
}
.toolbar p { margin: 0; color: var(--muted); font-size: 12px; }
button {
border: 1px solid var(--brand);
background: var(--brand);
color: #fff;
border-radius: 8px;
padding: 7px 12px;
font-size: 12px;
font-weight: 700;
}
.list { padding: 12px 12px 8px; overflow-x: auto; }
.list th { background: #f8fbff; color: var(--muted); font-weight: 700; }
.list td { border-bottom: 1px solid var(--line); }
.sent { color: #142033; }
.wait { color: #9a6700; font-weight: 700; }
.bad { color: #b42318; font-weight: 700; }
@media (max-width: 900px) {
.grid { grid-template-columns: 1fr; }
}
</style>
</head>
<body>
<main class="page">
<h1>设备验收预警 · 发送效果图</h1>
<p class="note">效果图,尚未接到现有页面。同一个人只收一条汇总卡片,明细在下一条 Excel。不再区分主送和抄送。</p>
<div class="grid">
<section class="panel">
<div class="head">
<h2>sophie 收到的企业微信</h2>
<p class="sub">她这一轮有 18 张单,卡片里不逐条列出。</p>
</div>
<div class="phone">
<div class="screen">
<div class="bar">设备验收预警</div>
<div class="thread">
<p class="time">19:52</p>
<article class="card">
<h3>设备验收停留提醒</h3>
<p>共 18 张验收单。
超过 30 天 12 张,超过 37 天 4 张,超过 44 天 2 张。
明细见下一条文件。</p>
<div class="more"><span>查看详情</span><span>›</span></div>
</article>
<article class="file">
<div class="xls">XLS</div>
<div>
<b>设备验收停留提醒.xlsx</b>
<span>28.4 KB</span>
</div>
</article>
</div>
</div>
</div>
</section>
<section class="panel">
<div class="head">
<h2>附件里的前 8 行</h2>
<p class="sub">只含 sophie 本人要看的单。通知身份说明她为什么会收到,不再写主送、抄送。</p>
</div>
<div class="sheet">
<table>
<thead>
<tr>
<th>验收单号</th>
<th>采购单号</th>
<th>申请人</th>
<th>轮次</th>
<th>停留天数</th>
<th>当前节点</th>
<th>当前处理人</th>
<th>通知身份</th>
</tr>
</thead>
<tbody>
<tr><td>20260210000001</td><td>1111</td><td>孙浩</td><td>超过 30 天</td><td>31</td><td>使用部门担当</td><td>吴敏</td><td>直接主管</td></tr>
<tr><td>20260211000008</td><td>CG-0881</td><td>李文</td><td>超过 30 天</td><td>33</td><td>品质担当</td><td>林可</td><td>直接主管</td></tr>
<tr><td>20260212000015</td><td>CG-0902</td><td>周洋</td><td>超过 30 天</td><td>36</td><td>公用主管</td><td>sophie</td><td>当前处理人</td></tr>
<tr><td>20260213000022</td><td>CG-0910</td><td>孙浩</td><td>超过 37 天</td><td>40</td><td>设备管理部</td><td>周宁</td><td>采购经副理</td></tr>
<tr><td>20260214000031</td><td>CG-0933</td><td>陈敏</td><td>超过 37 天</td><td>41</td><td>品质经理</td><td>何倩</td><td>采购经副理</td></tr>
<tr><td>20260215000040</td><td>CG-0948</td><td>刘洋</td><td>超过 44 天</td><td>46</td><td>COO</td><td>陈立</td><td>采购经副理</td></tr>
<tr><td>20260216000052</td><td>CG-0961</td><td>王磊</td><td>超过 30 天</td><td>32</td><td>使用部门经理</td><td>赵凯</td><td>直接主管</td></tr>
<tr><td>20260217000060</td><td>CG-0977</td><td>孙浩</td><td>超过 30 天</td><td>35</td><td>固定资产管理人</td><td>孙浩</td><td>采购担当</td></tr>
</tbody>
</table>
</div>
<p class="foot">文件内共 18 行。同一张单若第 1 轮和第 2 轮都还没发过,会各占一行。停留天数是发送当时的天数。</p>
</section>
</div>
<section class="panel admin">
<div class="tabs">
<span>停留情况</span>
<span class="on">发送记录</span>
<span>预警配置</span>
</div>
<div class="toolbar">
<p>每日扫描生成待发送。每周五 18:00 按人汇总,每人一条卡片加一份 Excel。这里仍是一条记录对应一张单的一轮。</p>
<button type="button">导出 Excel</button>
</div>
<div class="list">
<table>
<thead>
<tr>
<th>验收单号</th>
<th>采购单号</th>
<th>轮次</th>
<th>收件人</th>
<th>结果</th>
<th>发送时间</th>
</tr>
</thead>
<tbody>
<tr>
<td>20260210000001</td>
<td>1111</td>
<td>超过 30 天</td>
<td>吴敏、sophie、孙浩</td>
<td class="sent">已发送</td>
<td>2026-10-12 18:55:18</td>
</tr>
<tr>
<td>20260212000015</td>
<td>CG-0902</td>
<td>超过 37 天</td>
<td>孙经理、COO、赵琴</td>
<td class="wait">待发送</td>
<td>—</td>
</tr>
<tr>
<td>20260215000040</td>
<td>CG-0948</td>
<td>超过 44 天</td>
<td>COO、赵琴</td>
<td class="bad">发送失败</td>
<td>—</td>
</tr>
</tbody>
</table>
</div>
<p class="foot">页面上的「导出 Excel」是当前列表里的全部记录。个人在企业微信里收到的文件只含他自己的行。</p>
</section>
</main>
</body>
</html>
@@ -412,7 +412,7 @@ LEFT JOIN eteams.dbo.employee AS handler ON handler.ID = op.userid;
页面入口与合同付款预警相同:迁移写入内置 Chat Agent,`agent_code=equipment_acceptance`,`conversation_mode=task_chat`。对话页按该编码替换消息列表和输入框,页签是停留情况、发送记录和预警配置。普通用户要在用户管理里授予该 Agent 后才看得到。
`equipment_acceptance_settings` 只保留一行。`day_1` 到 `day_4` 默认 30、37、44、51,保存时必须逐档增大。`buyer_manager_user_id`、`coo_user_id`、`executive_user_id` 指向 `users.id`,姓名只在页面上显示。发送时刻不在这张表。`GET/PUT /api/equipment-acceptance/config`:有权限的用户可看,保存只给平台管理员。
`equipment_acceptance_settings` 只保留一行。`day_1` 到 `day_4` 默认 30、37、44、51,保存时必须逐档增大。`round_4_enabled` 默认关闭,关闭时扫描不生成第 4 轮,发送也会跳过已经待发送的第 4 轮。`buyer_manager_user_id`、`coo_user_id`、`executive_user_id` 指向 `users.id`,姓名只在页面上显示。发送时刻不在这张表。`GET/PUT /api/equipment-acceptance/config`:有权限的用户可看,保存只给平台管理员。
## 9. 扫描与发送
@@ -423,11 +423,11 @@ LEFT JOIN eteams.dbo.employee AS handler ON handler.ID = op.userid;
- 超过第 1 档:主送当前处理人,抄送其 `employee.SUPERIOR` 和申请人。
- 超过第 2 档:主送各处理人部门的经副理,抄送配置里的 COO 和采购经副理。
- 超过第 3 档:主送 COO,抄送采购经副理。
- 超过第 4 档:主送总经理,抄送 COO 和采购经副理。
- 超过第 4 档:主送总经理,抄送 COO 和采购经副理。配置里的第 4 轮开关默认关闭,关闭时这一档不产生、也不发送。
人员 ID 先对 `eteams.dbo.employee`,再用 `JOB_NUM` 对 `users.employee_id`,发送用 `users.wecom_userid`。矩阵 `relate_id` 和 E10 人员 ID 都不是企微 userid。没有工号、对不上用户、没绑企微、没有主管或经副理、三个岗位没选,都记在该席位上,不改发给别人。至少有一名可发的人时状态是待发送;一个都没有则整档失败。
每周五 18:00 排程 `equipment-acceptance-alert-weekly` 只发送状态为待发送的记录,不再同步。同一企微账号合并成一条文本卡片,标题「设备验收停留提醒」,事件 `equipment_acceptance_warning`。卡片过长时先留 12 行,其余写成「另有 N 条」。发送成功改为已发送。有人失败则整档改为失败,并附上「企业微信发送失败」;下次扫描会按当前处理人重算并回到待发送。已发出的企业微信不撤回。
每周五 18:00 排程 `equipment-acceptance-alert-weekly` 只发送状态为待发送的记录,不再同步。同一企微账号先收一条文本卡片,标题「设备验收停留提醒」,正文先写共多少张验收单已逾期,再写各轮次数量,事件 `equipment_acceptance_warning`。紧跟着一条文件消息《设备验收停留提醒.xlsx》,列是验收单号、采购单号、申请人、轮次、停留天数、当前节点、当前处理人、通知身份。卡片不写主送、抄送,也不逐条列出验收单。卡片和文件都成功才改为已发送。任一失败则整档改为失败,并写上卡片或附件的原因;下次扫描会按当前处理人重算并回到待发送。每位收件人的 Excel 写入 `equipment_acceptance_send_files`,并记下对应的发送记录。发送失败也保留。发送记录表用 Excel 附件列下载,同一行可有多份。已发出的企业微信不撤回。
停表(归档、退回、撤回、作废、无法验收,以及强制结束)时,待发送和解析失败且还没 `sent_at` 的行改为已取消。
+3 -3
View File
@@ -48,9 +48,9 @@
| 停留预警规则 | 需求已冻结 | 从第一次进入「使用部门担当」起按自然日累计,直到停表。只监控未归档、有效、可以验收的 OA 资产验收单。再进入仍用第一次写入的 `sbsyrjssj`,不从 0 重计。权威:[features/equipment-acceptance-warning/demand.md](features/equipment-acceptance-warning/demand.md)。 |
| 只读同步 | 已实现 | 平台管理员 `POST /api/equipment-acceptance/sync` 拉取 E10 验收单、流程状态、当前节点和操作人。按 `sfkyzcys`、`sfzfth`、`flowstatus` 3/4/5 标停表;`flowstatus` 为 7、8、99、-99 时记为已撤销并不再提醒。不查询、不保存 `isremark`。不保存 `optgroupid`、`batch_number`、`operate_log_id`。 |
| 停留列表 | 已实现 | 入口与合同付款预警相同:内置 Chat Agent `equipment_acceptance` 替换对话区。有权限的用户看列表和详情,同步按钮只给平台管理员。 |
| 预警配置 | 已实现 | 停留情况旁的「预警配置」页。四档天数默认 30/37/44/51,采购经副理、COO、总经理选择系统用户。发送时刻不在此页,以后由排程 Cron 配置,默认每周五 18:00。 |
| 发送记录 | 已实现 | Chat 页签「发送记录」。按验收单和档位列出主送、抄送、结果和发送时间。`GET /api/equipment-acceptance/sends`。管理员可立即扫描或发送。 |
| 四档企业微信升级 | 已实现 | 超过 30/37/44/51 天各发一次。担当、直接主管、经副理取当前节点处理人及其上级;采购担当取流程申请人。采购经副理、COO、总经理为可配置固定岗位。每天 06:00 同步并生成待发送,每周五 18:00 按收件人汇总一条企业微信。停表取消未发送。已发送不撤回、不重发。当前处理人就是当前节点上的 `userid`,不使用 `isremark`。设计:[features/equipment-acceptance-warning/technical.md](features/equipment-acceptance-warning/technical.md)。 |
| 预警配置 | 已实现 | 停留情况旁的「预警配置」页。四档天数默认 30/37/44/51,第 4 轮默认关闭,打开后才通知总经理。采购经副理、COO、总经理选择系统用户。发送时刻不在此页,由排程 Cron 配置,默认每周五 18:00。 |
| 发送记录 | 已实现 | Chat 页签「发送记录」。按验收单和档位列出主送、抄送、结果、Excel 附件和发送时间。发给每位收件人的 Excel 归档后挂在对应行上,点文件名下载。`GET /api/equipment-acceptance/sends`。管理员可立即扫描或发送。 |
| 四档企业微信升级 | 已实现 | 超过 30/37/44/51 天各发一次。担当、直接主管、经副理取当前节点处理人及其上级;采购担当取流程申请人。采购经副理、COO、总经理为可配置固定岗位。每天 06:00 同步并生成待发送,每周五 18:00 按收件人发送一条汇总卡片和一份 Excel 明细。停表取消未发送。已发送不撤回、不重发。当前处理人就是当前节点上的 `userid`,不使用 `isremark`。设计:[features/equipment-acceptance-warning/technical.md](features/equipment-acceptance-warning/technical.md)。 |
## 知识库同步状态校验
@@ -4,9 +4,9 @@
* 依赖:统一 requestJson;后端 /api/equipment-acceptance。
* 逻辑:Chat 作业面调用。同步只读 E10。配置只保存天数和系统用户,不保存发送时刻。
* 保存配置自行声明 Content-Type: application/json,供 Flask get_json 解析。
* 发送记录只读已落库的行,扫描尚未写入时列表为空。
* 发送记录只读已落库的行。每位收件人的 Excel 可再下载。
*/
import { requestJson } from '@/shared/api/client';
import { requestBlob, requestJson } from '@/shared/api/client';
export interface EquipmentAcceptanceNode {
node_id?: string | null;
@@ -150,6 +150,7 @@ export interface EquipmentAcceptanceSendRecord {
sent_at?: string | null;
error_message?: string | null;
created_at?: string | null;
files?: Array<{ id: number; excel_file_name?: string | null }>;
}
export interface EquipmentAcceptanceSendListResponse {
@@ -166,6 +167,33 @@ export interface EquipmentAcceptanceSendListResponse {
* @param params.pageSize - 每页条数
* @returns 当前页记录和总数
*/
export interface EquipmentAcceptanceSendFile {
id: number;
recipient_name?: string | null;
excel_file_name?: string | null;
excel_file_size?: number | null;
status: string;
sent_at?: string | null;
created_at?: string | null;
}
/**
* 列出最近按收件人归档的 Excel。不含文件内容。
* @returns 文件摘要
*/
export function listEquipmentAcceptanceSendFiles() {
return requestJson<{ items: EquipmentAcceptanceSendFile[] }>('/api/equipment-acceptance/send-files');
}
/**
* 下载一份当时发给收件人的 Excel。
* @param fileId - 归档文件主键
* @returns 文件字节和文件名
*/
export function downloadEquipmentAcceptanceSendFile(fileId: number) {
return requestBlob(`/api/equipment-acceptance/send-files/${fileId}/excel`);
}
export function listEquipmentAcceptanceSends(params?: { page?: number; pageSize?: number }) {
const search = new URLSearchParams();
if (params?.page) search.set('page', String(params.page));
@@ -185,6 +213,7 @@ export interface EquipmentAcceptanceConfigUser {
export interface EquipmentAcceptanceConfig {
days: number[];
round_4_enabled?: boolean;
buyer_manager_user_id?: number | null;
coo_user_id?: number | null;
executive_user_id?: number | null;
@@ -202,9 +231,10 @@ export function getEquipmentAcceptanceConfig() {
}
/**
* 保存四档天数和三个岗位的系统用户。仅平台管理员。
* 核心逻辑:岗位传用户主键或 null,不传姓名。
* 保存四档天数、第 4 轮开关和三个岗位的系统用户。仅平台管理员。
* 核心逻辑:岗位传用户主键或 null,不传姓名。第 4 轮关闭时不通知总经理。
* @param payload.days - 四个逐档增大的天数
* @param payload.round4Enabled - 是否启用第 4 轮
* @param payload.buyerManagerUserId - 采购经副理
* @param payload.cooUserId - COO
* @param payload.executiveUserId - 总经理对应岗位
@@ -212,6 +242,7 @@ export function getEquipmentAcceptanceConfig() {
*/
export function saveEquipmentAcceptanceConfig(payload: {
days: number[];
round4Enabled: boolean;
buyerManagerUserId: number | null;
cooUserId: number | null;
executiveUserId: number | null;
@@ -221,6 +252,7 @@ export function saveEquipmentAcceptanceConfig(payload: {
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
days: payload.days,
round_4_enabled: payload.round4Enabled,
buyer_manager_user_id: payload.buyerManagerUserId,
coo_user_id: payload.cooUserId,
executive_user_id: payload.executiveUserId,
@@ -1,8 +1,8 @@
<!--
features/equipment-acceptance/views/EquipmentAcceptanceConfigPage.vue
用途:设备验收预警配置页。编辑四档天数,并为三个固定岗位选择系统用户。
用途:设备验收预警配置页。按升级轮次编辑天数、第 4 轮开关和三个固定岗位。
依赖:equipment-acceptance.api、UserPickerDialog、userPicker.utils、vue-i18n。
逻辑:由 Chat 作业面的「预警配置」Tab 嵌入。姓名只用于展示。
逻辑:由 Chat 作业面的「预警配置」Tab 嵌入。同一岗位在多个轮次里共用一个人。
发送时刻不在本页,由排程 Cron 配置。非管理员只能查看。
-->
<script setup lang="ts">
@@ -23,15 +23,47 @@ const props = defineProps<{
}>();
type RoleKey = 'buyer_manager' | 'coo' | 'executive';
type RoundLine =
| { kind: 'plain'; tag: 'ruleTo' | 'ruleCc'; text: string; note?: string }
| { kind: 'roles'; tag: 'ruleTo' | 'ruleCc'; roles: RoleKey[] };
const ROLE_FIELDS: RoleKey[] = ['buyer_manager', 'coo', 'executive'];
const TIER_WHO = ['tierWho1', 'tierWho2', 'tierWho3', 'tierWho4'] as const;
const ROUNDS: Array<{ index: number; lines: RoundLine[] }> = [
{
index: 0,
lines: [
{ kind: 'plain', tag: 'ruleTo', text: 'ruleTo1' },
{ kind: 'plain', tag: 'ruleCc', text: 'ruleCc1', note: 'roundFixedNote' },
],
},
{
index: 1,
lines: [
{ kind: 'plain', tag: 'ruleTo', text: 'ruleTo2' },
{ kind: 'roles', tag: 'ruleCc', roles: ['coo', 'buyer_manager'] },
],
},
{
index: 2,
lines: [
{ kind: 'roles', tag: 'ruleTo', roles: ['coo'] },
{ kind: 'roles', tag: 'ruleCc', roles: ['buyer_manager'] },
],
},
{
index: 3,
lines: [
{ kind: 'roles', tag: 'ruleTo', roles: ['executive'] },
{ kind: 'roles', tag: 'ruleCc', roles: ['coo', 'buyer_manager'] },
],
},
];
const { t } = useI18n();
const msg = useMessage();
const loading = ref(false);
const saving = ref(false);
const days = ref<number[]>([30, 37, 44, 51]);
const round4Enabled = ref(false);
const roleIds = ref<Record<RoleKey, number | null>>({
buyer_manager: null,
coo: null,
@@ -54,13 +86,6 @@ const pickerSelectedIds = computed(() => {
return id ? [id] : [];
});
const ruleRows = computed(() => ([
{ to: 'ruleTo1', cc: 'ruleCc1' },
{ to: 'ruleTo2', cc: 'ruleCc2' },
{ to: 'ruleTo3', cc: 'ruleCc3' },
{ to: 'ruleTo4', cc: 'ruleCc4' },
]));
/**
* 读取当前配置。管理员响应里包含候选人。
* 核心逻辑:失败时保留页面上的默认天数,并用统一错误提示。
@@ -70,6 +95,7 @@ async function load(): Promise<void> {
try {
const result = await getEquipmentAcceptanceConfig();
days.value = result.days?.length === 4 ? [...result.days] : [30, 37, 44, 51];
round4Enabled.value = result.round_4_enabled === true;
roleIds.value = {
buyer_manager: result.buyer_manager_user_id ?? null,
coo: result.coo_user_id ?? null,
@@ -114,7 +140,7 @@ function clearRole(role: RoleKey): void {
}
/**
* 保存天数和三个岗位。天数须逐档增大。
* 保存天数、第 4 轮开关和三个岗位。天数须逐档增大。
* 核心逻辑:先在页面拦住空值和倒序,服务端再校验用户是否存在。
*/
async function save(): Promise<void> {
@@ -131,11 +157,13 @@ async function save(): Promise<void> {
try {
const result = await saveEquipmentAcceptanceConfig({
days: nextDays,
round4Enabled: round4Enabled.value,
buyerManagerUserId: roleIds.value.buyer_manager,
cooUserId: roleIds.value.coo,
executiveUserId: roleIds.value.executive,
});
days.value = [...result.days];
round4Enabled.value = result.round_4_enabled === true;
knownUsers.value = result.selected_users || [];
candidates.value = result.users || [];
msg.success(t('admin.equipmentAcceptance.configSaved'));
@@ -147,14 +175,47 @@ async function save(): Promise<void> {
}
/**
* 岗位上已选用户的展示名。没有选择时返回空串,模板改显示未选择。
* @param role - 岗位键
* @returns 姓名,有工号时附在后面
* 取出某个岗位已选的人。没有选择时为空。
* @param role - buyer_manager、coo、executive
* @returns 选人组件里的用户,或空
*/
function roleLabel(role: RoleKey): string {
function rolePerson(role: RoleKey): UserPickerPerson | undefined {
const id = roleIds.value[role];
if (!id) return '';
return userPickerLabel(people.value.get(id), id);
if (!id) return undefined;
return people.value.get(id);
}
/**
* 芯片上的姓名。没有选择时返回空串。
* @param role - 岗位键
* @returns 展示名
*/
function roleName(role: RoleKey): string {
const person = rolePerson(role);
if (!person) return '';
return userPickerLabel(person).replace(/([^)]*)$/, '') || userPickerLabel(person);
}
/**
* 姓名首字,画在圆形头像里。
* @param role - 岗位键
* @returns 一个字符
*/
function roleInitial(role: RoleKey): string {
const name = roleName(role).trim();
return name.slice(0, 1) || '?';
}
/**
* 芯片第二行:工号和岗位名。
* @param role - 岗位键
* @returns 例如 26030025 · COO
*/
function roleMeta(role: RoleKey): string {
const person = rolePerson(role);
const roleText = t(`admin.equipmentAcceptance.role.${role}`);
const employeeId = String(person?.employee_id || person?.username || '').trim();
return employeeId ? `${employeeId} · ${roleText}` : roleText;
}
onMounted(() => {
@@ -167,97 +228,95 @@ onMounted(() => {
<p class="mb-3 text-sm text-[#64748b]">{{ t('admin.equipmentAcceptance.configLead') }}</p>
<p v-if="loading" class="text-sm text-[#64748b]">{{ t('admin.equipmentAcceptance.loading') }}</p>
<template v-else>
<div class="grid grid-cols-4 gap-3">
<label
v-for="(who, index) in TIER_WHO"
:key="who"
class="rounded-xl border border-[#dce4ef] border-t-[3px] bg-white px-3 py-3"
:class="index === 0 ? 'border-t-[#93c5fd]' : index === 1 ? 'border-t-[#2563eb]' : index === 2 ? 'border-t-[#d97706]' : 'border-t-[#dc2626]'"
>
<span class="block text-xs font-bold text-[#64748b]">{{ t(`admin.equipmentAcceptance.tier${index + 1}`) }}</span>
<span class="mt-2 flex items-center gap-2">
<input
v-model.number="days[index]"
class="h-11 w-16 rounded-lg border border-[#d7dee8] bg-[#f8fafc] text-center text-xl font-bold text-[#142033] disabled:opacity-70"
type="number"
min="1"
:disabled="!editable"
/>
<span class="text-sm font-semibold text-[#94a3b8]">{{ t('admin.equipmentAcceptance.dayUnit') }}</span>
</span>
<span class="mt-2 block text-xs font-bold text-[#334155]">{{ t(`admin.equipmentAcceptance.${who}`) }}</span>
</label>
</div>
<div class="mt-3 grid gap-3 lg:grid-cols-2">
<article class="rounded-xl border border-[#dce4ef] bg-white">
<h2 class="px-4 pt-4 text-sm font-bold text-[#142033]">{{ t('admin.equipmentAcceptance.fixedRoles') }}</h2>
<div class="px-4 pb-2">
<div
v-for="role in ROLE_FIELDS"
:key="role"
class="grid grid-cols-[108px_minmax(0,1fr)] items-center gap-3 border-b border-[#dce4ef] py-3 last:border-b-0"
>
<span class="text-sm font-bold text-[#334155]">{{ t(`admin.equipmentAcceptance.role.${role}`) }}</span>
<div class="flex min-w-0 flex-wrap items-center gap-2">
<span v-if="roleLabel(role)" class="truncate text-sm text-[#142033]">{{ roleLabel(role) }}</span>
<span v-else class="text-sm text-[#94a3b8]">{{ t('admin.equipmentAcceptance.roleEmpty') }}</span>
<button
v-if="editable"
class="ml-auto rounded-lg border border-[#bfdbfe] bg-[#eaf2ff] px-2.5 py-1 text-xs font-bold text-[#1d4ed8]"
type="button"
@click="openPicker(role)"
>
{{ t('admin.equipmentAcceptance.selectUser') }}
</button>
<button
v-if="editable && roleIds[role]"
class="text-xs font-bold text-[#64748b]"
type="button"
@click="clearRole(role)"
>
{{ t('admin.equipmentAcceptance.clearUser') }}
</button>
<section class="overflow-hidden rounded-2xl border border-[#dce4ef] bg-white">
<div class="px-5 pb-2 pt-4">
<h2 class="text-sm font-bold text-[#142033]">{{ t('admin.equipmentAcceptance.configSheetTitle') }}</h2>
<p class="mt-1 text-xs text-[#64748b]">{{ t('admin.equipmentAcceptance.configSheetLead') }}</p>
</div>
<div class="px-3 pb-2">
<article
v-for="round in ROUNDS"
:key="round.index"
class="relative ml-4 grid grid-cols-1 gap-3 border-l-2 border-[#c9d4e3] py-4 pl-7 sm:grid-cols-[168px_minmax(0,1fr)] sm:gap-x-5"
:class="round.index === ROUNDS.length - 1 ? 'border-transparent' : ''"
>
<span class="absolute -left-[7px] top-6 h-3 w-3 rounded-full border-2 border-white bg-[#1d4e89] shadow-[0_0_0_1px_#c9d4e3]"></span>
<div class="flex flex-col gap-2">
<b class="text-xs text-[#64748b]">{{ t('admin.equipmentAcceptance.roundName', { n: round.index + 1 }) }}</b>
<label class="flex items-center gap-2 text-[13px] text-[#64748b]">
{{ t('admin.equipmentAcceptance.overPrefix') }}
<input
v-model.number="days[round.index]"
class="h-10 w-[72px] rounded-lg border border-[#d5dee8] bg-[#f8fafc] text-center text-[22px] font-semibold text-[#142033] disabled:opacity-70"
type="number"
min="1"
:disabled="!editable"
/>
{{ t('admin.equipmentAcceptance.dayUnit') }}
</label>
<template v-if="round.index === 3">
<label class="flex items-center gap-1.5 text-[13px] font-bold text-[#142033]">
<input v-model="round4Enabled" class="h-4 w-4 accent-[#1d4e89]" type="checkbox" :disabled="!editable" />
{{ t('admin.equipmentAcceptance.round4Enabled') }}
</label>
<small class="text-xs text-[#64748b]">{{ t('admin.equipmentAcceptance.round4ShortHint') }}</small>
</template>
</div>
<div class="flex flex-col gap-2" :class="round.index === 3 && !round4Enabled ? 'opacity-45' : ''">
<div v-for="(line, lineIndex) in round.lines" :key="`${round.index}-${lineIndex}`" class="flex items-start gap-2.5">
<span class="mt-1.5 w-9 shrink-0 text-xs font-bold text-[#64748b]">{{ t(`admin.equipmentAcceptance.${line.tag}`) }}</span>
<div class="min-w-0">
<template v-if="line.kind === 'plain'">
<p class="mt-1 text-sm font-semibold text-[#142033]">{{ t(`admin.equipmentAcceptance.${line.text}`) }}</p>
<p v-if="line.note" class="mt-1 text-xs text-[#94a3b8]">{{ t(`admin.equipmentAcceptance.${line.note}`) }}</p>
</template>
<div v-else class="flex flex-wrap gap-2">
<div
v-for="role in line.roles"
:key="role"
class="flex min-h-8 items-center gap-2 rounded-full bg-[#eef3f8] py-1 pl-1 pr-2"
>
<span class="grid h-6 w-6 place-items-center rounded-full bg-[#d7e4f2] text-xs font-bold text-[#1d4e89]">{{ roleInitial(role) }}</span>
<span class="flex flex-col leading-tight">
<strong class="text-[13px] text-[#142033]">{{ roleName(role) || t('admin.equipmentAcceptance.roleEmpty') }}</strong>
<span class="text-[11px] text-[#64748b]">{{ roleMeta(role) }}</span>
</span>
<button
v-if="editable"
class="text-xs font-bold text-[#1d4e89]"
type="button"
@click="openPicker(role)"
>
{{ roleIds[role] ? t('admin.equipmentAcceptance.replaceUser') : t('admin.equipmentAcceptance.selectUser') }}
</button>
<button
v-if="editable && roleIds[role]"
class="text-xs text-[#64748b]"
type="button"
@click="clearRole(role)"
>
{{ t('admin.equipmentAcceptance.clearUser') }}
</button>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="flex items-center justify-between gap-3 border-t border-[#dce4ef] bg-[#fafbfd] px-4 py-3">
<span class="text-xs text-[#64748b]">{{ editable ? t('admin.equipmentAcceptance.configSaveHint') : t('admin.equipmentAcceptance.configReadOnly') }}</span>
<button
v-if="editable"
class="rounded-lg bg-[#2563eb] px-3 py-1.5 text-xs font-bold text-white disabled:opacity-50"
type="button"
:disabled="saving"
@click="save"
>
{{ t('admin.equipmentAcceptance.saveConfig') }}
</button>
</div>
</article>
<article class="overflow-hidden rounded-xl border border-[#dce4ef] bg-white">
<div class="px-4 pt-4">
<h2 class="text-sm font-bold text-[#142033]">{{ t('admin.equipmentAcceptance.rulesTitle') }}</h2>
<p class="mt-1 text-xs text-[#64748b]">{{ t('admin.equipmentAcceptance.rulesLead') }}</p>
</div>
<table class="mt-3 w-full border-collapse text-left text-xs">
<thead class="bg-[#f8fbff] text-[#64748b]">
<tr>
<th class="px-3 py-2.5 font-bold">{{ t('admin.equipmentAcceptance.ruleTier') }}</th>
<th class="px-3 py-2.5 font-bold">{{ t('admin.equipmentAcceptance.ruleTo') }}</th>
<th class="px-3 py-2.5 font-bold">{{ t('admin.equipmentAcceptance.ruleCc') }}</th>
</tr>
</thead>
<tbody>
<tr v-for="(row, index) in ruleRows" :key="row.to" class="border-t border-[#dce4ef]">
<td class="px-3 py-2.5 font-bold text-[#142033]">{{ t('admin.equipmentAcceptance.ruleOver', { days: days[index] || '—' }) }}</td>
<td class="px-3 py-2.5">{{ t(`admin.equipmentAcceptance.${row.to}`) }}</td>
<td class="px-3 py-2.5">{{ t(`admin.equipmentAcceptance.${row.cc}`) }}</td>
</tr>
</tbody>
</table>
</article>
</div>
</article>
</div>
<div class="flex items-center justify-between gap-4 border-t border-[#dce4ef] bg-[#fafbfd] px-5 py-3.5">
<span class="text-xs text-[#64748b]">{{ editable ? t('admin.equipmentAcceptance.configSaveHint') : t('admin.equipmentAcceptance.configReadOnly') }}</span>
<button
v-if="editable"
class="h-9 rounded-lg bg-[#1d4e89] px-4 text-[13px] font-bold text-white disabled:opacity-50"
type="button"
:disabled="saving"
@click="save"
>
{{ t('admin.equipmentAcceptance.saveConfig') }}
</button>
</div>
</section>
</template>
<UserPickerDialog
@@ -1,17 +1,19 @@
<!--
features/equipment-acceptance/views/EquipmentAcceptanceSendsPage.vue
用途:设备验收预警发送记录页,列出每张验收单某一档的主送、抄送和结果。
依赖:equipment-acceptance.api、PaginationBar、统一消息提示、vue-i18n。
逻辑:由 Chat 作业面的「发送记录」Tab 嵌入。只读已落库记录。扫描尚未写入时显示空状态。
用途:设备验收预警发送记录页,列出每张验收单某一档的主送、抄送、Excel 附件和结果。
依赖:equipment-acceptance.api、PaginationBar、统一消息提示、vue-i18n、lucide 图标。
逻辑:由 Chat 作业面的「发送记录」Tab 嵌入。Excel 附件列点击文件名下载。发送失败时悬停图标看原因。
-->
<script setup lang="ts">
import { onMounted, ref } from 'vue';
import { CircleAlert, Download } from 'lucide-vue-next';
import { useI18n } from 'vue-i18n';
import { BusinessError } from '@/shared/api/client';
import PaginationBar from '@/shared/components/PaginationBar.vue';
import { useMessage } from '@/shared/composables/useMessage';
import { formatLocalDateTime } from '@/shared/utils/dateTime';
import {
downloadEquipmentAcceptanceSendFile,
listEquipmentAcceptanceSends,
type EquipmentAcceptanceSendRecord,
} from '../api/equipment-acceptance.api';
@@ -19,11 +21,13 @@ import {
const { t, te } = useI18n();
const msg = useMessage();
const records = ref<EquipmentAcceptanceSendRecord[]>([]);
const downloadingId = ref<number | null>(null);
const loading = ref(false);
const page = ref(1);
const pageSize = ref(20);
const total = ref(0);
const pages = ref(1);
const failureTip = ref<{ text: string; left: number; top: number } | null>(null);
/**
* 拉取当前页发送记录。
@@ -76,6 +80,55 @@ function sentText(value?: string | null): string {
return text === '-' ? '—' : text;
}
/**
* 在失败图标下方显示原因。用固定定位,避免被表格滚动容器裁掉。
* @param event - 悬停或聚焦事件
* @param message - 发送失败原因
*/
function openFailureTip(event: Event, message: string): void {
const target = event.currentTarget;
if (!(target instanceof HTMLElement)) return;
const rect = target.getBoundingClientRect();
const width = 280;
failureTip.value = {
text: message || t('admin.equipmentAcceptance.failureReasonEmpty'),
left: Math.max(8, Math.min(rect.left, window.innerWidth - width - 8)),
top: rect.bottom + 6,
};
}
/**
* 鼠标离开或失焦时关掉失败原因提示。
*/
function closeFailureTip(): void {
failureTip.value = null;
}
/**
* 下载一份已归档的收件人 Excel。
* 核心逻辑:接口返回当时发出的字节,由浏览器保存。
* @param file - 这一行上的 Excel 摘要
*/
async function downloadFile(file: { id: number; excel_file_name?: string | null }): Promise<void> {
if (downloadingId.value === file.id) return;
downloadingId.value = file.id;
try {
const { blob, filename } = await downloadEquipmentAcceptanceSendFile(file.id);
const objectUrl = URL.createObjectURL(blob);
const anchor = document.createElement('a');
anchor.href = objectUrl;
anchor.download = filename || file.excel_file_name || `equipment-acceptance-alert-${file.id}.xlsx`;
document.body.appendChild(anchor);
anchor.click();
document.body.removeChild(anchor);
URL.revokeObjectURL(objectUrl);
} catch (error) {
msg.error(error instanceof BusinessError ? error.message : t('admin.equipmentAcceptance.excelDownloadFailed'));
} finally {
downloadingId.value = null;
}
}
onMounted(() => {
void load();
});
@@ -97,6 +150,7 @@ defineExpose({ reload: load });
<th class="px-3 py-2.5 font-bold">{{ t('admin.equipmentAcceptance.ruleTo') }}</th>
<th class="px-3 py-2.5 font-bold">{{ t('admin.equipmentAcceptance.ruleCc') }}</th>
<th class="px-3 py-2.5 font-bold">{{ t('admin.equipmentAcceptance.sendResult') }}</th>
<th class="px-3 py-2.5 font-bold">{{ t('admin.equipmentAcceptance.excelColumn') }}</th>
<th class="px-3 py-2.5 font-bold">{{ t('admin.equipmentAcceptance.sentAt') }}</th>
</tr>
</thead>
@@ -108,15 +162,43 @@ defineExpose({ reload: load });
<td class="px-3 py-2.5">{{ item.to_text || '—' }}</td>
<td class="px-3 py-2.5">{{ item.cc_text || '—' }}</td>
<td class="px-3 py-2.5">
{{ statusText(item.status) }}
<span v-if="item.error_message" class="mt-1 block text-[#b42318]">
{{ item.error_message }}
<span class="inline-flex items-center gap-1" :class="item.status === 'failed' ? 'font-bold text-[#b42318]' : ''">
{{ statusText(item.status) }}
<button
v-if="item.status === 'failed'"
class="inline-flex h-[22px] w-[22px] items-center justify-center rounded-full text-[#b42318] hover:bg-[#fff1f2]"
type="button"
:aria-label="t('admin.equipmentAcceptance.failureReasonAria')"
@mouseenter="openFailureTip($event, item.error_message || '')"
@mouseleave="closeFailureTip"
@focus="openFailureTip($event, item.error_message || '')"
@blur="closeFailureTip"
>
<CircleAlert class="h-4 w-4" />
</button>
</span>
</td>
<td class="px-3 py-2.5">
<div v-if="item.files?.length" class="flex max-w-[280px] flex-col gap-1">
<button
v-for="file in item.files"
:key="file.id"
class="inline-flex min-w-0 items-center gap-1 font-semibold text-[#2563eb] disabled:opacity-50"
type="button"
:disabled="downloadingId === file.id"
:title="t('admin.equipmentAcceptance.excelColumn')"
@click="downloadFile(file)"
>
<Download class="h-3.5 w-3.5 shrink-0" />
<span class="truncate">{{ file.excel_file_name }}</span>
</button>
</div>
<span v-else>—</span>
</td>
<td class="px-3 py-2.5">{{ sentText(item.sent_at) }}</td>
</tr>
<tr v-if="!loading && !records.length">
<td colspan="7" class="px-3 py-10 text-center text-[#64748b]">
<td colspan="8" class="px-3 py-10 text-center text-[#64748b]">
{{ t('admin.equipmentAcceptance.sendsEmpty') }}
</td>
</tr>
@@ -133,5 +215,15 @@ defineExpose({ reload: load });
@update:page="() => load()"
@update:page-size="() => load()"
/>
<Teleport to="body">
<div
v-if="failureTip"
class="pointer-events-none fixed z-[80] max-w-[280px] whitespace-normal break-words rounded-lg bg-slate-900 px-2.5 py-1.5 text-xs leading-relaxed text-white shadow-lg"
role="tooltip"
:style="{ left: `${failureTip.left}px`, top: `${failureTip.top}px` }"
>
{{ failureTip.text }}
</div>
</Teleport>
</section>
</template>
+18 -1
View File
@@ -5742,6 +5742,10 @@
"tabSends": "Send records",
"tabConfig": "Alert settings",
"sendsLead": "The daily scan creates records waiting to be sent. They appear here after the Friday 18:00 summary goes out to each recipient. Names stay as they were at send time.",
"excelColumn": "Excel attachment",
"sentExcelTitle": "Sent Excel files",
"sentExcelHint": "One file per recipient. You can download the copy that was sent.",
"excelDownloadFailed": "Could not download the Excel file",
"sendsEmpty": "No send records yet",
"sendsFailed": "Failed to load send records",
"scanAlerts": "Scan alerts",
@@ -5751,6 +5755,9 @@
"scanDone": "Added {created}, updated {updated}, cancelled {cancelled}",
"sendDone": "Sent to {sent} people, {failed} failed",
"sendResult": "Result",
"failureReason": "Failure reason",
"failureReasonEmpty": "No failure reason was recorded",
"failureReasonAria": "View failure reason",
"sentAt": "Sent at",
"sendStatus": {
"pending": "Waiting to send",
@@ -5758,11 +5765,21 @@
"failed": "Failed",
"cancelled": "Cancelled"
},
"configLead": "Each tier must be longer than the one before it. Saving affects only alerts created later. The send time is set on the schedule.",
"configLead": "Each round must be longer than the one before it. Saving affects only alerts created later. The send time is set on the schedule.",
"configSheetTitle": "Escalation rounds",
"configSheetLead": "Set the day threshold on the left. The right side lists who is notified. COO, purchasing deputy manager, and general manager are each chosen once and shown on every round that uses them.",
"overPrefix": "Over",
"roundName": "Round {n}",
"roundFixedNote": "Follows the current order. No one is picked here.",
"replaceUser": "Change",
"round4ShortHint": "Off by default. The general manager is not notified.",
"tier1": "Tier 1",
"tier2": "Tier 2",
"tier3": "Tier 3",
"tier4": "Tier 4",
"round4Enabled": "Enable round 4",
"round4EnabledHint": "While this is off, the general manager is not notified. It stays off until turned on.",
"round4Off": "Off",
"tierWho1": "Current handler",
"tierWho2": "Deputy manager",
"tierWho3": "COO",
+18 -1
View File
@@ -5742,6 +5742,10 @@
"tabSends": "บันทึกการส่ง",
"tabConfig": "ตั้งค่าการเตือน",
"sendsLead": "การสแกนรายวันสร้างรายการที่รอส่ง หลังสรุปส่งทุกวันศุกร์ 18:00 ตามผู้รับแล้ว จะแสดงที่นี่ ชื่อคงตามตอนที่ส่ง",
"excelColumn": "ไฟล์แนบ Excel",
"sentExcelTitle": "ไฟล์ Excel ที่ส่งแล้ว",
"sentExcelHint": "หนึ่งไฟล์ต่อผู้รับหนึ่งคน ดาวน์โหลดสำเนาที่ส่งไปแล้วได้",
"excelDownloadFailed": "ดาวน์โหลดไฟล์ Excel ไม่สำเร็จ",
"sendsEmpty": "ยังไม่มีบันทึกการส่ง",
"sendsFailed": "โหลดบันทึกการส่งไม่สำเร็จ",
"scanAlerts": "สแกนการเตือน",
@@ -5751,6 +5755,9 @@
"scanDone": "เพิ่ม {created} รายการ อัปเดต {updated} รายการ ยกเลิก {cancelled} รายการ",
"sendDone": "ส่งถึง {sent} คน ไม่สำเร็จ {failed} คน",
"sendResult": "ผลลัพธ์",
"failureReason": "สาเหตุที่ล้มเหลว",
"failureReasonEmpty": "ไม่ได้บันทึกสาเหตุ",
"failureReasonAria": "ดูสาเหตุที่ล้มเหลว",
"sentAt": "เวลาที่ส่ง",
"sendStatus": {
"pending": "รอส่ง",
@@ -5758,11 +5765,21 @@
"failed": "ส่งไม่สำเร็จ",
"cancelled": "ยกเลิกแล้ว"
},
"configLead": "จำนวนวันแต่ละขั้นต้องมากขึ้นตามลำดับ การบันทึกมีผลเฉพาะการเตือนที่เกิดภายหลัง เวลาส่งตั้งในตารางงาน",
"configLead": "จำนวนวันแต่ละรอบต้องมากขึ้นตามลำดับ การบันทึกมีผลเฉพาะการเตือนที่เกิดภายหลัง เวลาส่งตั้งในตารางงาน",
"configSheetTitle": "รอบการยกระดับ",
"configSheetLead": "ด้านซ้ายกำหนดจำนวนวันที่เกิน ด้านขวาคือผู้รับในรอบนี้ COO รองผู้จัดการจัดซื้อ และผู้จัดการทั่วไปเลือกครั้งเดียว แล้วแสดงคนเดียวกันในทุกรอบที่ใช้",
"overPrefix": "เกิน",
"roundName": "รอบที่ {n}",
"roundFixedNote": "ตามเอกสารปัจจุบัน ไม่ต้องเลือกคนที่นี่",
"replaceUser": "เปลี่ยน",
"round4ShortHint": "ค่าเริ่มต้นคือปิด จะไม่แจ้งผู้จัดการทั่วไป",
"tier1": "ขั้นที่ 1",
"tier2": "ขั้นที่ 2",
"tier3": "ขั้นที่ 3",
"tier4": "ขั้นที่ 4",
"round4Enabled": "เปิดใช้รอบที่ 4",
"round4EnabledHint": "เมื่อปิด จะไม่แจ้งผู้จัดการทั่วไป ค่าเริ่มต้นคือปิด เปิดแล้วจึงเตือนตามจำนวนวันของขั้นที่ 4",
"round4Off": "ปิดอยู่",
"tierWho1": "ผู้ดำเนินการปัจจุบัน",
"tierWho2": "รองผู้จัดการ",
"tierWho3": "COO",
+18 -1
View File
@@ -5775,6 +5775,10 @@
"tabSends": "发送记录",
"tabConfig": "预警配置",
"sendsLead": "每日扫描生成待发送。默认每周五 18:00 按收件人汇总发出后记在这里。已发送的姓名保持发送当时的人。",
"excelColumn": "Excel 附件",
"sentExcelTitle": "已发送的 Excel",
"sentExcelHint": "每位收件人一份,可再次下载当时发出的文件。",
"excelDownloadFailed": "下载 Excel 失败",
"sendsEmpty": "还没有发送记录",
"sendsFailed": "读取发送记录失败",
"scanAlerts": "扫描预警",
@@ -5784,6 +5788,9 @@
"scanDone": "新增 {created} 条,更新 {updated} 条,取消 {cancelled} 条",
"sendDone": "已向 {sent} 人发送,{failed} 人失败",
"sendResult": "结果",
"failureReason": "失败原因",
"failureReasonEmpty": "没有记下失败原因",
"failureReasonAria": "查看失败原因",
"sentAt": "发送时间",
"sendStatus": {
"pending": "待发送",
@@ -5791,11 +5798,21 @@
"failed": "发送失败",
"cancelled": "已取消"
},
"configLead": "四档天数须逐档增大。保存后只影响以后新产生的预警。发送时刻在排程里配置。",
"configLead": "四轮天数须逐轮增大。保存后只影响以后新产生的预警。发送时刻在排程里改。",
"configSheetTitle": "升级轮次",
"configSheetLead": "左边改超过多少天。右边是这一轮的主送和抄送。COO、采购经副理、总经理各选一次,用到的轮次都显示同一个人。",
"overPrefix": "超过",
"roundName": "第 {n} 轮",
"roundFixedNote": "随当前单据变化,这里不选人",
"replaceUser": "更换",
"round4ShortHint": "默认关闭,不通知总经理",
"tier1": "第 1 档",
"tier2": "第 2 档",
"tier3": "第 3 档",
"tier4": "第 4 档",
"round4Enabled": "启用第 4 轮",
"round4EnabledHint": "关闭后不向总经理发送。默认关闭,打开后才按第 4 档天数提醒。",
"round4Off": "未启用",
"tierWho1": "当前处理人",
"tierWho2": "经副理",
"tierWho3": "COO",
+18 -1
View File
@@ -5742,6 +5742,10 @@
"tabSends": "發送記錄",
"tabConfig": "預警配置",
"sendsLead": "每日掃描產生待發送。預設每週五 18:00 按收件人彙總發出後記在這裡。已發送的姓名保持發送當時的人。",
"excelColumn": "Excel 附件",
"sentExcelTitle": "已發送的 Excel",
"sentExcelHint": "每位收件人一份,可再次下載當時發出的檔案。",
"excelDownloadFailed": "下載 Excel 失敗",
"sendsEmpty": "還沒有發送記錄",
"sendsFailed": "讀取發送記錄失敗",
"scanAlerts": "掃描預警",
@@ -5751,6 +5755,9 @@
"scanDone": "新增 {created} 條,更新 {updated} 條,取消 {cancelled} 條",
"sendDone": "已向 {sent} 人發送,{failed} 人失敗",
"sendResult": "結果",
"failureReason": "失敗原因",
"failureReasonEmpty": "沒有記下失敗原因",
"failureReasonAria": "查看失敗原因",
"sentAt": "發送時間",
"sendStatus": {
"pending": "待發送",
@@ -5758,11 +5765,21 @@
"failed": "發送失敗",
"cancelled": "已取消"
},
"configLead": "四檔天數須逐檔增大。儲存後只影響以後新產生的預警。發送時刻在排程裡配置。",
"configLead": "四輪天數須逐輪增大。儲存後只影響以後新產生的預警。發送時刻在排程裡改。",
"configSheetTitle": "升級輪次",
"configSheetLead": "左邊改超過多少天。右邊是這一輪的主送和抄送。COO、採購經副理、總經理各選一次,用到的輪次都顯示同一個人。",
"overPrefix": "超過",
"roundName": "第 {n} 輪",
"roundFixedNote": "隨目前單據變化,這裡不選人",
"replaceUser": "更換",
"round4ShortHint": "預設關閉,不通知總經理",
"tier1": "第 1 檔",
"tier2": "第 2 檔",
"tier3": "第 3 檔",
"tier4": "第 4 檔",
"round4Enabled": "啟用第 4 輪",
"round4EnabledHint": "關閉後不向總經理發送。預設關閉,打開後才按第 4 檔天數提醒。",
"round4Off": "未啟用",
"tierWho1": "目前處理人",
"tierWho2": "經副理",
"tierWho3": "COO",