feat(ui): 工作台界面全部替换为element plus

This commit is contained in:
sophie committed 2026-10-29 09:38:38 +08:00
1 parent 26d213c05b
commit d5f988a16c
38 files changed
+4501 -3087

No files matched your search

@@ -5,6 +5,7 @@ backend/app/services/voucher_check/notification.py
依赖:wecom_notify、notify_config_service、ScheduleTask.notify_user_ids_json、engine_persistence。
逻辑:缺件按文件类型接收人拆成每人一封,正文只含该人负责且本批缺失的类型;
卡片标题为「销售开票附件缺件提醒」,不写业务方代号和批次号;
卡片发出后紧跟本批检核结果 Excel,收件人不用进详情才知道缺哪张票;
排程「启用通知」为总开关;技术失败仍走排程通知人;domain_notification_managed 避免通用排程重复通知。
"""
@@ -59,7 +60,7 @@ def _missing_textcard(period_month: str, items: list[dict[str, Any]]) -> tuple[s
_friendly_period_label(period_month),
"销售开票附件已检核,你负责的类型还有缺件:",
*[_missing_type_line(item) for item in items],
"请尽快补齐。完整清单见详情里的 Excel。",
"请尽快补齐。缺件明细见下一条 Excel。",
]
)
return "销售开票附件缺件提醒", body
@@ -113,6 +114,36 @@ def _persist_skip(
return send_status
def _send_excel_file(wecom_userid: str, media_id: str) -> bool:
"""
把已上传的检核结果 Excel 发给一个收件人。
核心逻辑:企微文件消息与 textcard 是两条消息,失败只记日志,不回滚已发出的卡片。
Returns:
企业微信 errcode 为 0 时为 True。
"""
from app.services.integrations.wecom.notify import send_wecom_file_message
try:
data = send_wecom_file_message(wecom_userid, media_id)
except Exception as exc:
current_app.logger.warning(
"[voucher-check] excel file failed user=%s err=%s",
wecom_userid,
exc,
)
return False
if data.get("errcode") == 0:
return True
current_app.logger.warning(
"[voucher-check] excel file failed user=%s errcode=%s errmsg=%s",
wecom_userid,
data.get("errcode"),
data.get("errmsg"),
)
return False
def send_batch_missing_summary(
*,
task: ScheduleTask,
@@ -122,11 +153,17 @@ def send_batch_missing_summary(
period_month: str,
stats: dict[str, Any],
excel_filename: str | None,
excel_bytes: bytes | None = None,
enabled: bool,
) -> str:
"""
按文件类型接收人发送缺件 textcard。
核心逻辑:每人一封,只列出该人负责且本批缺失的类型;标题写明销售开票附件,不写业务方代号和批次号。无缺件或无人可发则写审计不发空消息。
按文件类型接收人发送缺件 textcard,并附上本批检核结果 Excel。
核心逻辑:每人一封,只列出该人负责且本批缺失的类型;标题写明销售开票附件,不写业务方代号和批次号。
Excel 全批共用一份,上传一次后随卡片发给每个收件人。附件失败不挡住卡片,原因写入审计。
无缺件或无人可发则写审计不发空消息。
Args:
excel_bytes: 与排程落库同一份检核结果。为空时只发卡片。
Returns:
send_status:sent / skipped_no_missing / skipped_no_recipients / skipped_disabled / failed
@@ -213,9 +250,20 @@ def send_batch_missing_summary(
_build_jump_url,
_create_audit,
send_wecom_textcard_message,
upload_wecom_temp_media,
)
media_id = None
file_note = None
if excel_bytes and excel_filename:
try:
media_id = upload_wecom_temp_media(excel_bytes, excel_filename)
except Exception as exc:
file_note = "Excel 附件上传失败"
current_app.logger.warning("[voucher-check] excel upload failed: %s", exc)
ok_any = False
file_failed = False
sent_ids: list[int] = []
for user in users:
items = plan["user_rules"].get(int(user.id)) or []
@@ -234,6 +282,8 @@ def send_batch_missing_summary(
audit.status = "sent"
ok_any = True
sent_ids.append(int(user.id))
if media_id and not _send_excel_file(user.wecom_userid, media_id):
file_failed = True
else:
audit.error_code = str(data.get("errcode"))
audit.error_message = str(data.get("errmsg", "unknown"))[:255]
@@ -244,11 +294,16 @@ def send_batch_missing_summary(
exc,
)
skip_reason = None
if file_failed and not file_note:
file_note = "部分 Excel 附件发送失败"
reasons: list[str] = []
if not ok_any:
skip_reason = "企业微信发送失败"
reasons.append("企业微信发送失败")
elif plan["unmapped_codes"]:
skip_reason = "部分文件类型未配置接收人"
reasons.append("部分文件类型未配置接收人")
if file_note:
reasons.append(file_note)
skip_reason = ";".join(reasons) or None
persist_notification(
run_id=engine_run_id,
excel_filename=excel_filename,
+18 -3
View File
@@ -4,7 +4,7 @@ backend/app/services/voucher_check/runner.py
用途:销售一期周批次编排(上月清单、目录扫描、按票归档、缺件聚合、Excel、企微汇总)。
依赖:profile_loader、adapters、dms_client、aggregator、engine_persistence、excel_rows、notification。
逻辑:不调用 erp_po_print.fetch / oa_sales_release.fetch;PO PDF 由 accounting-voucher-po-print(周二 05:00)、销货放行单由 accounting-voucher-oa-sales-release(周二 05:30)提前写入类型目录。
命中文件复制到所有归档,同名跳过仍记 archived。
命中文件复制到所有归档,同名跳过仍记 archived。缺件通知附带与排程落库相同的检核结果 Excel。
"""
from __future__ import annotations
@@ -28,7 +28,11 @@ from app.services.voucher_check.engine_persistence import (
persist_engine_results,
)
from app.services.voucher_check.erp_repository import previous_period_bounds
from app.services.voucher_check.excel_rows import to_excel_invoice_row
from app.services.voucher_check.excel_rows import (
VOUCHER_CHECK_HEADER_LABELS,
VOUCHER_CHECK_HEADER_ORDER,
to_excel_invoice_row,
)
from app.services.voucher_check.notification import send_batch_missing_summary, send_failure_alert
from app.services.voucher_check.profile_loader import ensure_published_profile, load_profile_definition
from app.services.voucher_check.profiles.sales import required_file_rules
@@ -369,8 +373,18 @@ def run_voucher_check_batch(task: ScheduleTask, run: ScheduleRun) -> ScheduleExe
to_excel_invoice_row(item, period=period, executed_at=executed_at)
for item in stats["excel_rows"]
]
from app.services.schedule.excel_service import export_schedule_result_excel
# [STEP 4] 按文件类型接收人拆成每人一封缺件通知
# 与排程落库用同一导出,保证企微附件和事后下载是同一张表。
excel_bytes, _, _ = export_schedule_result_excel(
run_no=run.run_no,
summary={"period": period},
details=details,
header_order=list(VOUCHER_CHECK_HEADER_ORDER),
header_labels=VOUCHER_CHECK_HEADER_LABELS,
)
# [STEP 4] 按文件类型接收人拆成每人一封缺件通知,并附上本批 Excel
notify_status = send_batch_missing_summary(
task=task,
schedule_run=run,
@@ -379,6 +393,7 @@ def run_voucher_check_batch(task: ScheduleTask, run: ScheduleRun) -> ScheduleExe
period_month=period,
stats=stats,
excel_filename=excel_filename,
excel_bytes=excel_bytes,
enabled=config.notify_missing_enabled,
)
step_logs.append(
@@ -3,7 +3,7 @@ backend/tests/voucher_check/test_notify_config.py
用途:按文件类型配置缺件接收人,以及把缺件类型拆成每人一封。
依赖:pytest、Flask client、notify_config_service、notification.send_batch_missing_summary。
逻辑:GET/PUT 仅 is_platform_admin;未知规则码丢弃;发送时每人只看到自己负责且本批缺失的类型。
逻辑:GET/PUT 仅 is_platform_admin;未知规则码丢弃;发送时每人只看到自己负责且本批缺失的类型,并收到同一份 Excel。
"""
from __future__ import annotations
@@ -179,14 +179,26 @@ def test_notify_config_rejects_non_admin_headers(app, client, user_headers):
def test_send_batch_splits_one_card_per_user(app, monkeypatch):
"""缺件通知按人拆信,正文只含该人负责的缺失类型。"""
"""缺件通知按人拆信,正文只含该人负责的缺失类型,并给每人附上同一份 Excel。"""
sent: list[tuple[str, str, str]] = []
uploaded: list[tuple[bytes, str]] = []
files: list[tuple[str, str]] = []
def _fake_send(wecom_userid, title, description, jump_url):
sent.append((wecom_userid, title, description))
return {"errcode": 0}
def _fake_upload(data, filename):
uploaded.append((data, filename))
return "media-vc-1"
def _fake_file(wecom_userid, media_id):
files.append((wecom_userid, media_id))
return {"errcode": 0}
monkeypatch.setattr("app.services.integrations.wecom.notify.send_wecom_textcard_message", _fake_send)
monkeypatch.setattr("app.services.integrations.wecom.notify.upload_wecom_temp_media", _fake_upload)
monkeypatch.setattr("app.services.integrations.wecom.notify.send_wecom_file_message", _fake_file)
monkeypatch.setattr(
"app.services.integrations.wecom.notify._create_audit",
lambda *args, **kwargs: SimpleNamespace(
@@ -279,6 +291,7 @@ def test_send_batch_splits_one_card_per_user(app, monkeypatch):
},
},
excel_filename="voucher_check_sales_2026-08.xlsx",
excel_bytes=b"voucher-xlsx",
enabled=True,
)
assert status == "sent"
@@ -306,3 +319,7 @@ def test_send_batch_splits_one_card_per_user(app, monkeypatch):
assert "发票:缺" not in po_body
assert "提单" in bl_body
assert "PO订单:缺" not in bl_body
# 关键断言:同一份 Excel 只上传一次,两个收件人都收到文件消息。
assert uploaded == [(b"voucher-xlsx", "voucher_check_sales_2026-08.xlsx")]
assert files == [("wx-po-recv", "media-vc-1"), ("wx-bl-recv", "media-vc-1")]
assert "下一条 Excel" in po_body