Merge branch 'dev' into hugo-auto-transfer
This commit is contained in:
commit
fc42bb14c9
76 files changed
+6065
-1759
No files matched your search
@@ -159,6 +159,8 @@ FREIGHT_RPA_SHARED_UPLOAD_QUEUE_DIR=/mnt/hxops-rpa-prod-data/freight_rpa/invento
|
||||
FREIGHT_RPA_SHARED_UPLOAD_TRIGGER_DIR=/mnt/hxops-rpa-prod-data/freight_rpa/inventory/upload_triggers
|
||||
# 固资履历共享盘(Linux 正式环境请优先挂载到本地目录,再通过 LOCAL_ROOT 访问)
|
||||
FIXED_ASSET_HISTORY_LOCAL_ROOT=/mnt/hxops-fixed-asset-history-prod
|
||||
# 订单交期回复 Agent(2026-10-10 上线边界):只同步订单日期 ≥ 起始日的订单行,早于边界的历史行随 erp_missing 语义自动移出工作台;留空/删除 = 全量同步(dev/test 不配置)
|
||||
ORDER_DELIVERY_SYNC_DATE_FROM=2026-10-10
|
||||
# --- 10. 运维、告警与维护工具 ---
|
||||
# 设备维保助手后端工具调用密钥
|
||||
MAINTENANCE_TOOL_API_KEY=kgea7gvqxL79tZPD6aZSe3H1FrqUCkh_QFZeaSZ4KEFR-fJVNT5lKAVEVJCJhsWu
|
||||
@@ -0,0 +1,23 @@
|
||||
## 改动说明
|
||||
|
||||
<!-- 这次改了什么、为什么改。 -->
|
||||
|
||||
## 管理端界面
|
||||
|
||||
这次改动如果碰到管理控制台、知识库配置,或已经换成 Element Plus 的页面,按 `docs/ui/ELEMENT_MIGRATION.md` §6 核对。没改界面就删掉下面的清单。
|
||||
|
||||
- [ ] 只在该页入口引入 Element 样式和 `element-trial.css`,并用 `ElConfigProvider` 包住。
|
||||
- [ ] 列表骨架符合规范 §3,左右 32px 对齐,只有一层卡片。
|
||||
- [ ] 按钮符合规范 §4.1,没有 `size="small"` 和默认按钮混在一行。
|
||||
- [ ] 表格状态是 `ElTag`,单元格没有 `text-xs` / `text-sm` / `text-muted`。
|
||||
- [ ] 筛选框没有被拉成整行,空选项不是「请选择」。
|
||||
- [ ] 弹窗宽度只有 480px 或 680px,短表单不是整屏抽屉。
|
||||
- [ ] 加载遮罩只等列表请求,数据出来后遮罩消失。
|
||||
- [ ] 删除确认与本页其他确认框是同一种。
|
||||
- [ ] 四种语言下按钮、表头、空状态、分页都能读通。
|
||||
- [ ] `html.dark` 下边框、表头、弹窗底色跟着变量变。
|
||||
- [ ] `frontend` 下 `npx vue-tsc -b --pretty false` 通过。
|
||||
|
||||
## 测试
|
||||
|
||||
<!-- 怎么验证。 -->
|
||||
Vendored
+16
@@ -353,6 +353,22 @@ pipeline {
|
||||
}
|
||||
}
|
||||
|
||||
stage('Frontend Lint') {
|
||||
when {
|
||||
expression { env.FRONTEND_CHANGED == 'true' }
|
||||
}
|
||||
steps {
|
||||
echo '[Frontend Lint] FRONTEND_CHANGED=true,执行 npm run lint(Element 规则当前为 off)'
|
||||
sh '''
|
||||
set -e
|
||||
docker run --rm \
|
||||
-v "${WORKSPACE}:/repo" \
|
||||
-w /repo \
|
||||
node:22-alpine sh -c "chmod +x scripts/ci_frontend_lint.sh && ./scripts/ci_frontend_lint.sh"
|
||||
'''
|
||||
}
|
||||
}
|
||||
|
||||
// stage('Frontend Build (CI)') {
|
||||
// when {
|
||||
// expression { env.FRONTEND_CHANGED == 'true' }
|
||||
|
||||
@@ -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():
|
||||
"""分页查看发送记录。扫描写入后这里才有行。"""
|
||||
|
||||
@@ -16,7 +16,11 @@ backend/app/api/order_delivery_reply.py
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from flask import Blueprint, g, request
|
||||
from datetime import datetime
|
||||
from io import BytesIO
|
||||
from zoneinfo import ZoneInfo
|
||||
|
||||
from flask import Blueprint, g, request, send_file
|
||||
|
||||
from app.core.auth.jwt import get_current_user
|
||||
from app.core.errors import ForbiddenError, NotFoundError, UnauthorizedError, ValidationError
|
||||
@@ -28,6 +32,8 @@ from app.services.order_delivery_reply.sync_service import OrderDeliverySyncServ
|
||||
|
||||
order_delivery_reply_bp = Blueprint("order_delivery_reply", __name__)
|
||||
|
||||
XLSX_MIME_TYPE = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
|
||||
|
||||
|
||||
def _utc_to_shanghai(value) -> str | None:
|
||||
"""
|
||||
@@ -121,6 +127,28 @@ def list_lines():
|
||||
return ok(data, request_id=getattr(g, "request_id", None))
|
||||
|
||||
|
||||
@order_delivery_reply_bp.get("/lines/export")
|
||||
def export_lines():
|
||||
"""
|
||||
导出当前筛选下的全部订单行 Excel(不分页)。
|
||||
|
||||
用途与触发时机:工作台工具栏「导出 Excel」按钮;查询参数与列表一致
|
||||
(keyword/order_date/status),导出全部命中行(服务层 EXPORT_MAX_ROWS 兜底)。
|
||||
|
||||
参数与输出约束:要求 order_delivery_reply.access 及以上;返回 xlsx 文件流(attachment,
|
||||
文件名带北京时间日期)。
|
||||
"""
|
||||
_require_access()
|
||||
content = query_service.export_lines(request.args.to_dict(flat=True))
|
||||
filename = f"订单交期回复_{datetime.now(ZoneInfo('Asia/Shanghai')):%Y%m%d}.xlsx"
|
||||
return send_file(
|
||||
BytesIO(content),
|
||||
as_attachment=True,
|
||||
download_name=filename,
|
||||
mimetype=XLSX_MIME_TYPE,
|
||||
)
|
||||
|
||||
|
||||
@order_delivery_reply_bp.get("/lines/<order_no>/<int:line_no>")
|
||||
def get_line(order_no: str, line_no: int):
|
||||
"""
|
||||
|
||||
@@ -244,6 +244,7 @@ from app.models.equipment_acceptance import (
|
||||
EquipmentAcceptanceNode,
|
||||
EquipmentAcceptanceOperator,
|
||||
EquipmentAcceptanceOrder,
|
||||
EquipmentAcceptanceSendFile,
|
||||
EquipmentAcceptanceSendRecord,
|
||||
EquipmentAcceptanceSetting,
|
||||
)
|
||||
@@ -447,6 +448,7 @@ __all__ = [
|
||||
'EquipmentAcceptanceNode',
|
||||
'EquipmentAcceptanceOperator',
|
||||
'EquipmentAcceptanceSetting',
|
||||
'EquipmentAcceptanceSendFile',
|
||||
'EquipmentAcceptanceSendRecord',
|
||||
'TransferRun',
|
||||
'TransferSourceJob',
|
||||
|
||||
@@ -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 [],
|
||||
}
|
||||
@@ -12,8 +12,10 @@ from __future__ import annotations
|
||||
|
||||
from datetime import date, datetime
|
||||
from decimal import Decimal
|
||||
from io import BytesIO
|
||||
from typing import Any
|
||||
|
||||
from openpyxl import Workbook
|
||||
from sqlalchemy import Select, func, or_, select
|
||||
|
||||
from app.extensions import db
|
||||
@@ -30,6 +32,18 @@ STATUS_FILTER_VALUES = {"replied", "not_fully_replied"}
|
||||
DEFAULT_PAGE_SIZE = 50
|
||||
MAX_PAGE_SIZE = 200
|
||||
|
||||
# 导出兜底上限:防止极端筛选全量导出失控(当前数据量 ~1k 行,远低于该值)。
|
||||
EXPORT_MAX_ROWS = 10000
|
||||
|
||||
# 导出表头(与工作台列顺序一致,交期回复批次合并为单列)。
|
||||
EXPORT_HEADERS = [
|
||||
"客户编号", "客户简称", "订单日期", "订单单号", "项次", "产品编号", "品名",
|
||||
"客户产品编号", "数量", "约定交货日", "交期回复状态", "交期回复批次",
|
||||
"业务员", "部门", "客户订单", "规格", "单位", "通知时间",
|
||||
]
|
||||
|
||||
STATUS_EXPORT_LABELS = {"not_replied": "未回复", "partial_replied": "部分回复", "replied": "已回复"}
|
||||
|
||||
|
||||
def _utc_to_shanghai(value) -> str | None:
|
||||
"""naive-UTC 时间转北京时间展示串;仅用于序列化,详情见 api 层同名 helper 注释。"""
|
||||
@@ -278,6 +292,82 @@ def list_lines(params: dict[str, Any]) -> dict[str, Any]:
|
||||
return {"items": items, "page": page, "page_size": page_size, "total": total or 0}
|
||||
|
||||
|
||||
def export_lines(params: dict[str, Any]) -> bytes:
|
||||
"""
|
||||
导出当前筛选下的全部订单行(xlsx 字节流)。
|
||||
|
||||
用途与触发时机:GET /api/order-delivery-reply/lines/export;工作台「导出 Excel」按钮。
|
||||
|
||||
核心逻辑:[STEP 1] 与 list_lines 同一筛选与默认排序,不分页(EXPORT_MAX_ROWS 兜底防失控);
|
||||
[STEP 2] 批量预取批次与锁定状态后序列化;
|
||||
[STEP 3] openpyxl 生成单工作表(中文表头同工作台列顺序,批次合并为「交期·数量」分号串,
|
||||
行状态转中文)。
|
||||
|
||||
Args:
|
||||
params: keyword / order_date / status(与列表筛选一致)。
|
||||
Returns:
|
||||
xlsx 文件字节流。
|
||||
"""
|
||||
stmt = _apply_filters(_base_query(), params).order_by(
|
||||
OrderDeliveryErpLine.order_date.asc(),
|
||||
OrderDeliveryErpLine.customer_no.asc(),
|
||||
OrderDeliveryErpLine.order_no.asc(),
|
||||
OrderDeliveryErpLine.line_no.asc(),
|
||||
OrderDeliveryErpLine.part_no.asc(),
|
||||
).limit(EXPORT_MAX_ROWS)
|
||||
|
||||
lines = list(db.session.scalars(stmt).all())
|
||||
line_ids = [line.id for line in lines]
|
||||
|
||||
batches_by_line: dict[int, list[OrderDeliveryBatch]] = {}
|
||||
states_by_line: dict[int, OrderDeliveryLineState] = {}
|
||||
if line_ids:
|
||||
for batch in db.session.scalars(
|
||||
select(OrderDeliveryBatch)
|
||||
.where(OrderDeliveryBatch.line_id.in_(line_ids))
|
||||
.order_by(OrderDeliveryBatch.line_id, OrderDeliveryBatch.seq)
|
||||
).all():
|
||||
batches_by_line.setdefault(batch.line_id, []).append(batch)
|
||||
for state in db.session.scalars(
|
||||
select(OrderDeliveryLineState).where(OrderDeliveryLineState.line_id.in_(line_ids))
|
||||
).all():
|
||||
states_by_line[state.line_id] = state
|
||||
|
||||
workbook = Workbook()
|
||||
sheet = workbook.active
|
||||
sheet.title = "订单交期回复"
|
||||
sheet.append(EXPORT_HEADERS)
|
||||
for line in lines:
|
||||
item = _serialize_line(line, batches_by_line.get(line.id, []), states_by_line.get(line.id))
|
||||
batch_text = ";".join(
|
||||
f"{batch['planned_date']}·{batch['qty']}" for batch in item["batches"] if batch["planned_date"]
|
||||
)
|
||||
sheet.append([
|
||||
item["customer_no"] or "",
|
||||
item["customer_short_name"] or "",
|
||||
item["order_date"] or "",
|
||||
item["order_no"] or "",
|
||||
item["line_no"],
|
||||
item["part_no"] or "",
|
||||
item["part_name"] or "",
|
||||
item["customer_part_no"] or "",
|
||||
item["qty"] or "",
|
||||
item["agreed_date"] or "",
|
||||
STATUS_EXPORT_LABELS.get(item["status"], item["status"]),
|
||||
batch_text,
|
||||
item["salesperson_name"] or item["salesperson_code"] or "",
|
||||
item["dept_name"] or item["dept_code"] or "",
|
||||
item["customer_po"] or "",
|
||||
item["spec"] or "",
|
||||
item["unit"] or "",
|
||||
item["notified_at"] or "",
|
||||
])
|
||||
|
||||
buffer = BytesIO()
|
||||
workbook.save(buffer)
|
||||
return buffer.getvalue()
|
||||
|
||||
|
||||
def get_line(order_no: str, line_no: int) -> dict[str, Any] | None:
|
||||
"""
|
||||
单行详情:快照 + 批次 + 锁定状态 + 该行审计事件。
|
||||
|
||||
@@ -11,6 +11,11 @@ backend/app/services/order_delivery_reply/sql.py
|
||||
# 基础 SELECT:不带分页/排序,同步服务按 oea01 keyset 分页时在外层包装。
|
||||
# 关联:oea01=oeb01;oeb04=ima01 且 oeb06=ima02;oea03=occ01;oea14=gen01;oea15=gem01。
|
||||
# 别名与 docs/features/order-delivery-reply/technical-design.md §3.5 标准 SELECT 逐列一致。
|
||||
# 可选起始日下界(2026-10-09 增补):正式环境经 ORDER_DELIVERY_SYNC_DATE_FROM 注入边界值
|
||||
# (绑定为 date,oea02 为 Oracle DATE 列),只同步订单日期 ≥ 边界的订单行;
|
||||
# 未配置边界时服务层不拼接此子句,SQL 本体保持全量口径不变。仅只读 SELECT 约束同上。
|
||||
ORDER_DELIVERY_DATE_FROM_CLAUSE = "AND a.oea02 >= :order_date_from"
|
||||
|
||||
ORDER_DELIVERY_SQL = """
|
||||
SELECT
|
||||
a.oea01 AS order_no,
|
||||
|
||||
@@ -7,6 +7,9 @@ backend/app/services/order_delivery_reply/sync_service.py
|
||||
逻辑:按 oea01 keyset 分页拉取合格订单行 → 对 (order_no, line_no) 做 upsert 且只更新 ERP 列白名单
|
||||
(绝不覆盖批次/锁定)→ 本轮未命中的本地行置 erp_missing=true(不删除)→ 写 sync_runs。
|
||||
全程模块级锁保证同时只有一个同步;失败保留上次快照并记录错误。
|
||||
可选起始日下界(2026-10-09):ORDER_DELIVERY_SYNC_DATE_FROM(YYYY-MM-DD,仅正式环境配置)——
|
||||
只同步订单日期 ≥ 边界的订单行(早于边界的历史行随 erp_missing 语义自动移出工作台);
|
||||
未配置 = 全量同步(dev/test 现状);配置非法格式 fail-closed 拒绝同步。
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
@@ -14,7 +17,7 @@ from __future__ import annotations
|
||||
import logging
|
||||
import os
|
||||
import threading
|
||||
from datetime import datetime
|
||||
from datetime import date, datetime
|
||||
from typing import Any
|
||||
|
||||
from sqlalchemy import select, update
|
||||
@@ -25,10 +28,35 @@ from app.models.order_delivery_reply import (
|
||||
OrderDeliveryErpLine,
|
||||
OrderDeliverySyncRun,
|
||||
)
|
||||
from app.services.order_delivery_reply.sql import ORDER_DELIVERY_SQL
|
||||
from app.services.order_delivery_reply.sql import ORDER_DELIVERY_DATE_FROM_CLAUSE, ORDER_DELIVERY_SQL
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def _resolve_sync_date_from() -> date | None:
|
||||
"""
|
||||
解析同步起始日下界(环境变量 ORDER_DELIVERY_SYNC_DATE_FROM,YYYY-MM-DD,可选)。
|
||||
|
||||
用途与触发时机:run_sync 每轮同步开始时调用;正式环境配置上线日起只同步
|
||||
订单日期 ≥ 边界的订单行,dev/test 不配置保持全量(需求 2026-10-09)。
|
||||
|
||||
约束:配置了但格式非法时 fail-closed 抛 ValueError 拒绝本轮同步——
|
||||
绝不允许静默回退全量把历史数据抓进正式库。
|
||||
|
||||
Returns:
|
||||
边界日期(含当日);未配置返回 None。
|
||||
"""
|
||||
raw = (os.getenv("ORDER_DELIVERY_SYNC_DATE_FROM") or "").strip()
|
||||
if not raw:
|
||||
return None
|
||||
try:
|
||||
return datetime.strptime(raw, "%Y-%m-%d").date()
|
||||
except ValueError as exc:
|
||||
raise ValueError(
|
||||
f"ORDER_DELIVERY_SYNC_DATE_FROM 格式错误(应为 YYYY-MM-DD):{raw!r};"
|
||||
"已拒绝执行同步以防止误抓边界外的历史数据"
|
||||
) from exc
|
||||
|
||||
# 同步 upsert 只允许更新这些 ERP 快照列;触碰批次/锁定列会覆盖业务回复,禁止扩充业务列进来。
|
||||
ERP_LINE_COLUMNS = (
|
||||
"order_date",
|
||||
@@ -147,27 +175,40 @@ class OrderDeliverySyncService:
|
||||
return oracledb.connect(user=user, password=password, dsn=dsn)
|
||||
|
||||
@classmethod
|
||||
def _fetch_page(cls, cursor, last_order_no: str | None) -> list[dict[str, Any]]:
|
||||
def _fetch_page(
|
||||
cls,
|
||||
cursor,
|
||||
last_order_no: str | None,
|
||||
date_from: date | None = None,
|
||||
) -> list[dict[str, Any]]:
|
||||
"""
|
||||
按 oea01 keyset 分页拉取一页订单行。
|
||||
|
||||
Args:
|
||||
cursor: oracledb 游标。
|
||||
last_order_no: 上一页最后一条订单单号;None 表示从头发起。
|
||||
date_from: 起始日下界(含);None 表示不过滤。条件拼在内层视图
|
||||
(ROWNUM 之前)——若加在外层会先截断再过滤造成每页缺行漏单。
|
||||
Returns:
|
||||
本页行字典列表(列为 sql.ORDER_DELIVERY_SQL 的别名)。
|
||||
"""
|
||||
# Oracle 空串即 NULL:首页不能带 `order_no > ''`(与 NULL 比较恒 UNKNOWN 会滤掉全部行),
|
||||
# 因此首页与续页使用两个 SQL 变体。
|
||||
binds: dict[str, Any] = {}
|
||||
date_clause = ""
|
||||
if date_from is not None:
|
||||
date_clause = f" {ORDER_DELIVERY_DATE_FROM_CLAUSE}"
|
||||
binds["order_date_from"] = date_from
|
||||
if last_order_no:
|
||||
page_sql = (
|
||||
f"SELECT * FROM ({ORDER_DELIVERY_SQL} ORDER BY a.oea01) "
|
||||
f"SELECT * FROM ({ORDER_DELIVERY_SQL}{date_clause} ORDER BY a.oea01) "
|
||||
f"WHERE order_no > :last_order_no AND ROWNUM <= {_FETCH_SIZE}"
|
||||
)
|
||||
cursor.execute(page_sql, last_order_no=last_order_no)
|
||||
binds["last_order_no"] = last_order_no
|
||||
cursor.execute(page_sql, binds)
|
||||
else:
|
||||
page_sql = f"SELECT * FROM ({ORDER_DELIVERY_SQL} ORDER BY a.oea01) WHERE ROWNUM <= {_FETCH_SIZE}"
|
||||
cursor.execute(page_sql)
|
||||
page_sql = f"SELECT * FROM ({ORDER_DELIVERY_SQL}{date_clause} ORDER BY a.oea01) WHERE ROWNUM <= {_FETCH_SIZE}"
|
||||
cursor.execute(page_sql, binds)
|
||||
columns = [col[0].lower() for col in cursor.description]
|
||||
return [dict(zip(columns, row)) for row in cursor.fetchall()]
|
||||
|
||||
@@ -230,6 +271,16 @@ class OrderDeliverySyncService:
|
||||
Returns:
|
||||
{"run_id", "status", "line_count"};并发冲突返回 status='skipped'。
|
||||
"""
|
||||
# 起始日边界先于抢锁解析:配置非法直接抛错(不写 sync_runs),防止误抓边界外历史数据
|
||||
date_from = _resolve_sync_date_from()
|
||||
if date_from:
|
||||
logger.info(
|
||||
"order-delivery-reply sync date-from boundary: %s (inclusive, order_date >= boundary)",
|
||||
date_from.isoformat(),
|
||||
)
|
||||
else:
|
||||
logger.info("order-delivery-reply sync date-from boundary: not configured (full sync)")
|
||||
|
||||
if not _sync_lock.acquire(blocking=False):
|
||||
return {"run_id": None, "status": "skipped", "line_count": 0}
|
||||
|
||||
@@ -244,7 +295,7 @@ class OrderDeliverySyncService:
|
||||
with conn.cursor() as cursor:
|
||||
last_order_no: str | None = None
|
||||
while True:
|
||||
page = cls._fetch_page(cursor, last_order_no)
|
||||
page = cls._fetch_page(cursor, last_order_no, date_from)
|
||||
if not page:
|
||||
break
|
||||
hit_keys |= cls._upsert_page(page, synced_at)
|
||||
|
||||
@@ -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"
|
||||
@@ -5,6 +5,7 @@
|
||||
| [features/](features/README.md) | **业务域**落地手册(部署、Dify、API、运维;**产品原型随域同目录**) |
|
||||
| [platform/](platform/README.md) | **平台级**设计与跨域原型(Agent 注册、进度底座、Runtime Context) |
|
||||
| [convention/](convention/) | 开发规范(提交、错误处理、环境变量、发布流程等) |
|
||||
| [ui/](ui/ELEMENT_MIGRATION.md) | 界面规范([设计系统](ui/DESIGN_SYSTEM.md)、[编码准则](ui/UI_CODING_GUIDELINES.md)、[Element 迁移](ui/ELEMENT_MIGRATION.md)) |
|
||||
| [skills/](skills/README.md) | Cursor Agent Skills 团队说明([i18n](skills/add-i18n-keys-skill.md)、[发布说明](skills/release-notes-skill.md)) |
|
||||
| [openapi/](openapi/) | Dify / 集成 OpenAPI 契约 |
|
||||
| [dify/](dify/) | Dify 集成说明 |
|
||||
|
||||
+2
-2
@@ -2,7 +2,7 @@
|
||||
|
||||
## 订单交期回复 Agent(2026-09)
|
||||
|
||||
生管在工作台按 ERP 已审核、已核准、未结案的销售订单行回复交期(可拆多批次),保存后经行内或批量企微通知对应业务员并锁定;具备只读权限的业务人员可查看,回执不改状态。系统只读 ERP,不回写。操作权限按用户功能权限划分。每天 07:00(北京时间)全量同步全部合格订单,可手动刷新。一期不做单别白名单管理,操作页不出单别列。细则见 [features/order-delivery-reply/demand.md](features/order-delivery-reply/demand.md)。
|
||||
生管在工作台按 ERP 已审核、已核准、未结案的销售订单行回复交期(可拆多批次),保存后经行内或批量企微通知对应业务员并锁定;具备只读权限的业务人员可查看,回执不改状态。系统只读 ERP,不回写。操作权限按用户功能权限划分。每天 07:00(北京时间)全量同步全部合格订单,可手动刷新;正式环境可配置同步起始日期(`ORDER_DELIVERY_SYNC_DATE_FROM`,如上线日 2026-10-10),只同步订单日期 ≥ 起始日的订单行(2026-10-09 增补)。一期不做单别白名单管理,操作页不出单别列。细则见 [features/order-delivery-reply/demand.md](features/order-delivery-reply/demand.md)。
|
||||
|
||||
定时提醒(2026-09-21 增补):07:00 同步成功后企微提醒生管查看当天回复(收件人=排程通知人配置);新日批 07:10 提醒排程——已回复行按回复交期提前 N 天(默认 3)提醒对应业务员出货,超 N 天(默认 3)未回复的行再次提醒生管;天数与生管收件人都在管理端排程表单配置,不新增配置页面。
|
||||
|
||||
@@ -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` 的行改为已取消。
|
||||
|
||||
|
||||
@@ -167,6 +167,8 @@ flowchart TD
|
||||
|
||||
一期**不按单别过滤**,上述条件命中的订单行全部同步。
|
||||
|
||||
起始日边界(2026-10-09 增补):支持配置**同步起始日期**(环境变量 `ORDER_DELIVERY_SYNC_DATE_FROM`,YYYY-MM-DD,仅正式环境配置)——只同步**订单日期 ≥ 起始日**的订单行,早于边界的历史行不抓取;未配置(dev/test)= 全量同步。配置非法格式时同步直接失败(fail-closed),不回退全量。边界外曾同步过的行按上行 erp_missing 语义自动移出工作台。
|
||||
|
||||
本地已有批次或已锁定、但本轮 ERP 不再命中的行:保留不删,标记为 ERP 已不在同步范围,默认列表不展示。
|
||||
|
||||
---
|
||||
@@ -191,6 +193,10 @@ flowchart TD
|
||||
|
||||
全选作用于当前筛选结果的**本页**。未勾选时「联合回复交期」「批量通知」不可用。
|
||||
|
||||
筛选区形态(2026-10-09 修订):取消外置字段标签,关键词/订单日期/交期回复状态三个控件与「查询」「重置」排成单行紧凑布局;字段含义由输入框占位符(关键词=「订单/产品/客户/业务员/回复人员」)与下拉选项承担,无障碍语义以 aria-label 保留;不展示「共 X 条产品行」提示,总数与分页信息由底部分页栏承载。筛选控件字号(text-sm 14px)与高度(36px)与合同付款预警搜索框一致。
|
||||
|
||||
导出 Excel(2026-10-09 增补):工具栏右侧「导出 Excel」按钮,按当前筛选条件(关键词/订单日期/状态)导出**全部命中行**(不分页),xlsx 列与列表列对应、多批次合并为「交期·数量」分号串、状态转中文;access 及以上权限可用;导出中按钮禁用防重复点击。
|
||||
|
||||
---
|
||||
|
||||
## 8. 列表列
|
||||
@@ -207,17 +213,18 @@ flowchart TD
|
||||
8. 约定交货日
|
||||
9. 交期回复状态
|
||||
10. 交期回复
|
||||
11. 交期回复人员(锁定行在姓名下附带「已通知 {业务员} + 时间」;原「通知业务部门」列已取消)
|
||||
11. 交期回复人员(2026-10-09:通知时间移至独立的「通知时间」列;取消「已通知 {业务员}」文案——业务员列已示,工号/姓名即通知对象;原「通知业务部门」列已取消)
|
||||
12. 业务员(显示姓名;副文案:部门名称)
|
||||
13. 客户订单
|
||||
14. 规格
|
||||
15. 单位
|
||||
16. 通知时间(2026-10-09 增补,所有列之后新建:锁定行展示通知时间戳、单行不折行;未锁定显示 —;导出 Excel 同步含该列)
|
||||
|
||||
(2026-09-17 增补同步条件 `NVL(oeb24,0)=0` 后,「已交数量 / 未交数量」两列信息量归零,已取消展示;数量与未交口径仍由后端派生,供回复弹窗数量守恒校验使用。)
|
||||
|
||||
不增加单别列。一期无单别管理勾选。
|
||||
|
||||
交期回复:无批次显示「回复交期」;有批次可展开;未锁定可「修改回复」;已锁定显示「交期已锁定」。
|
||||
交期回复(2026-10-09 修订为批次条形态):未回复显示**空批次条**(占位条不显示具体交期与数量);有批次逐条显示**批次条**(交期 · 数量 单位;不显示备注);动作入口为批次条前的**加号**——未回复=发起回复、未锁定可管理=修改回复,已锁定行无加号且**「交期已锁定」徽标取消**(锁定状态由无加号与交期回复人员列「已通知」体现);批次计数「N 批 · 已回复 X/Y」统计文字取消;批次 >1 时首条批次后有展开/收起箭头(▼ 展开全部批次,▲ 收起只展示第一批);全表批次条左缘对齐(首条批次前保留加号占位、展开行缩进一致)。
|
||||
|
||||
通知:列已取消(行内不设发送按钮);发送统一走工具栏「批量通知」;已通知对象与时间并入「交期回复人员」列展示。
|
||||
|
||||
@@ -234,6 +241,8 @@ flowchart TD
|
||||
|
||||
弹窗维护 1..N 批:交期必填有效日期,数量 > 0,备注 ≤ 200;各批次数量合计必须等于订单数量,否则不能保存(2026-09-23 增补);已填批次的交期/数量缺填、同一订单单号:项次的不同批次交期重复,均实时提示并随填写内容切换(2026-09-23 增补;交期重复后端 BATCH_INVALID 既有校验)。可增删批次;快速统一交期仅联合回复交期弹窗保留,单行回复/修改回复弹窗取消该快捷区,直接逐批次填写(2026-10-07 修订)。锁定行不可编辑。行上徽标展示「订单数量:X 单位」(2026-09-23 由「未交 X」改来)。
|
||||
|
||||
**批次条就地编辑(2026-10-09 增补)**:未锁定且具备 manage 权限的行,点击批次条原地变「交期 + 数量」输入(预填当前值;未回复行的空批次条点击即新增第一条批次),回车或失焦自动保存单行接口并即时刷新。校验与弹窗同口径——缺交期/缺数量、同单交期重复、合计≠订单数量时行内红字提示并阻断保存(焦点回日期框,红字持续显示至修正保存或 Esc 取消);双清空=放弃编辑;行内不含备注、不支持删除批次;多批次拆分、备注与结构调整仍走回复弹窗(加号)。保存进行中禁止并发(其他批次条/加号临时禁用)。锁定行与仅 access 权限不可就地编辑。
|
||||
|
||||
---
|
||||
|
||||
## 11. 联合回复与批量通知
|
||||
|
||||
@@ -106,7 +106,9 @@ flowchart LR
|
||||
|
||||
本轮未命中、但本地已有批次或已锁定的行:不删除,`erp_missing = true`,默认列表不展示,可提示「已不在同步范围」。
|
||||
|
||||
### 3.5 标准 SELECT
|
||||
#起始日下界(2026-10-09 增补):环境变量 `ORDER_DELIVERY_SYNC_DATE_FROM`(YYYY-MM-DD,仅正式环境配置)非空时,取数 SQL 内层视图追加 `AND a.oea02 >= :order_date_from`(oea02 为 DATE 列,绑定为 date)——只同步订单日期 ≥ 边界的订单行。条件必须拼在 ROWNUM 分页的内层视图,外层先截断再过滤会每页缺行漏单。配置非法格式 fail-closed 拒绝同步;未配置(dev/test)= 全量。边界外的行不进结果集,按既有语义标 `erp_missing` 自动移出工作台。日志输出实际生效边界。
|
||||
|
||||
## 3.5 标准 SELECT
|
||||
|
||||
```sql
|
||||
SELECT
|
||||
@@ -214,6 +216,7 @@ erDiagram
|
||||
| POST | `/notify-batch` | 批量通知勾选行;无批次或已锁定跳过 |
|
||||
| POST | `/sync` | 手动同步 |
|
||||
| GET | `/sync/latest` | 最近一次同步 |
|
||||
| GET | `/lines/export` | **导出 Excel(2026-10-09)**:按 `keyword/order_date/status` 当前筛选导出全部命中行(不分页,`EXPORT_MAX_ROWS=10000` 兜底),openpyxl 生成 xlsx(18 列同工作台列序、批次合并「交期·数量」分号串、状态转中文);access 及以上;`attachment` 文件名「订单交期回复_YYYYMMDD.xlsx」 |
|
||||
|
||||
GET `/lines` 查询:`keyword`(合并搜索:订单单号/客户订单/客户编号/客户简称/公司全名/产品编号/品名/客户产品编号/业务员(姓名、工号)/交期回复人员(姓名、工号,行状态快照 EXISTS,2026-09-23 增补)OR 命中)、`order_date`、`status`(空=`全部` / `已回复` / `未完全回复`)、`page`、`page_size`。默认排序 `order_date, customer_no, order_no, line_no, part_no` 升序。`page_size` 默认 50。全选仅本页。
|
||||
|
||||
@@ -267,7 +270,7 @@ GET `/lines` 查询:`keyword`(合并搜索:订单单号/客户订单/客
|
||||
|
||||
`frontend/src/features/order-delivery-reply/`:`constants.ts`(权限键)、`api/orderDeliveryReply.api.ts`(统一 `requestJson`)、`views/OrderDeliveryReplyPage.vue`(操作页)。交互以更新后的原型 v5 为准。工具栏:「联合回复交期」与「批量通知」分开;**通知唯一入口为「批量通知」**,列表不出「通知业务部门」列(行内不设发送按钮;已通知对象与时间并入「交期回复人员」列)。状态徽标按需求 §12,不用旧原型按数量覆盖的脚本。
|
||||
|
||||
列表(2026-09-21 修订列顺序,独立「部门」「品名」列取消)按序为:勾选、客户编号(副文案客户简称,全名 title)、订单日期、订单单号:项次、产品编号(副文案品名)、客户产品编号、数量、约定交货日、交期回复状态、交期回复、交期回复人员、业务员(副文案部门)、客户订单、规格、单位。表格浏览体验(2026-09-21):页面高度收敛至视口(滚动全部发生在表格容器内 → 列头 sticky 固定、横向滚动条常驻表格底缘);左侧冻结前四列标识区(勾选/客户编号/订单日期/订单单号:项次,冻结单元格实色背景防透出,宽度已收窄至 2/8/6/10rem);行高紧凑(表体 py-1.5,产品编号/品名/规格/客户订单/客户简称长文本单行截断 + title 悬停看全文,交期回复批次条不折行);筛选区与工具栏字号与表格统一(text-sm 14px,状态徽标例外保持 text-xs 12px 加粗)并压缩高度。列项与顺序不变。不渲染订单类型、单别、已转请购、排定交货日,亦不出「已交数量 / 未交数量」列(`NVL(oeb24,0)=0` 过滤后无信息量;未交口径仍由后端计算,供回复弹窗数量守恒校验——各批次合计必须等于订单数量,2026-09-23 由「超额仅提醒」修订);表头与工具栏提示不换行(`whitespace-nowrap`,避免窄列中文竖排)。分页复用共享 `PaginationBar`(与管理控制台-数据报表同一组件:摘要 + 每页条数 20/50/100/200 + 页码按钮)。客户列:编号 + 简称,全名作 title;产品编号列:编号 + 品名;业务员列:姓名 + 部门,同款上下两行合并展示。仅 `access` 时隐藏回复、通知、同步按钮与手动刷新。功能权限经权限组「应用权限」划分(2026-10-07 修订,见 §7.2)。一期无单别管理页。
|
||||
列表(2026-09-21 修订列顺序,独立「部门」「品名」列取消)按序为:勾选、客户编号(副文案客户简称,全名 title)、订单日期、订单单号:项次、产品编号(副文案品名)、客户产品编号、数量、约定交货日、交期回复状态、交期回复、交期回复人员、业务员(副文案部门)、客户订单、规格、单位、通知时间(2026-10-09 自交期回复人员列拆出独立列,锁定行展示单行不折行;导出 xlsx 同步含该列)。表格浏览体验(2026-09-21):页面高度收敛至视口(滚动全部发生在表格容器内 → 列头 sticky 固定、横向滚动条常驻表格底缘);左侧冻结前四列标识区(勾选/客户编号/订单日期/订单单号:项次,冻结单元格实色背景防透出,宽度已收窄至 2/8/6/10rem);行高紧凑(表体 py-1.5,产品编号/品名/规格/客户订单/客户简称长文本单行截断 + title 悬停看全文,交期回复批次条不折行);筛选区与工具栏字号与表格统一(text-sm 14px,状态徽标例外保持 text-xs 12px 加粗)并压缩高度。列项与顺序不变。不渲染订单类型、单别、已转请购、排定交货日,亦不出「已交数量 / 未交数量」列(`NVL(oeb24,0)=0` 过滤后无信息量;未交口径仍由后端计算,供回复弹窗数量守恒校验——各批次合计必须等于订单数量,2026-09-23 由「超额仅提醒」修订);表头与工具栏提示不换行(`whitespace-nowrap`,避免窄列中文竖排)。分页复用共享 `PaginationBar`(与管理控制台-数据报表同一组件:摘要 + 每页条数 20/50/100/200 + 页码按钮)。客户列:编号 + 简称,全名作 title;产品编号列:编号 + 品名;业务员列:姓名 + 部门,同款上下两行合并展示。仅 `access` 时隐藏回复、通知、同步按钮与手动刷新。功能权限经权限组「应用权限」划分(2026-10-07 修订,见 §7.2)。一期无单别管理页。
|
||||
|
||||
### 8.1 路由与入口
|
||||
|
||||
@@ -290,7 +293,14 @@ GET `/lines` 查询:`keyword`(合并搜索:订单单号/客户订单/客
|
||||
|
||||
### 8.3 i18n
|
||||
|
||||
页面文案集中于 `locales/*/workspace.json` 的 `workspace.orderDeliveryReply.*`(约 91 键/语言,含 nav 键与入口副标题 `entryHint`),四语言同步;禁止硬编码中文。
|
||||
页面文案集中于 `locales/*/workspace.json` 的 `workspace.orderDeliveryReply.*`(约 91 键/语言,含 nav 键与入口副标题 `entryHint`),四语言同步;禁止硬编码中文。(2026-10-09 增删:删除 `batchCount/repliedOf/overTag/lockedTag/totalCount`,其余键保留;加号与就地编辑的 title/aria 复用 `replyAction/editReplyAction/filterOrderDate/colQty`。)
|
||||
|
||||
### 8.4 批次条就地编辑与设计系统(2026-10-09)
|
||||
|
||||
- **交期回复列形态**:动作入口统一为批次条前加号(lucide `Plus`,title/aria 复用 `replyAction`/`editReplyAction`);未回复=空批次条(不显示时间/数量);「交期已锁定」徽标与批次计数/已回复统计文字取消(锁定状态由无加号与交期回复人员列「已通知」体现);批次 >1 时首条批次后展开/收起箭头(lucide Chevron,▼ 展开 / ▲ 收起只留第一批);全表批次条左缘对齐(首条批次前 `w-6` 加号占位、展开行 `pl-7` 缩进)。
|
||||
- **就地编辑实现**:`editingChip`(lineKey+idx 单实例)+ `chipDraft`(日期/数量)+ `chipSaving`(并发标志);点击批次条 → 原地渲染「日期+数量」输入(预填当前值并自动聚焦日期框);回车/失焦提交(`focusout` 以 `relatedTarget` 是否仍在容器内区分输入间切换);提交 = 整行批次合并(仅替换编辑条,未回复行为新增首条)→ `lineIssueText` 同口径校验(缺交期/缺数量、同单交期重复、合计≠订单数量 → `chipIssue` 红字持续显示并重聚焦日期框)→ `saveOrderDeliveryBatches` 单行接口 → `loadLines()` 刷新;双清空=放弃编辑,Esc 取消,打开弹窗自动退出就地编辑;`chipSaving` 期间禁点其他批次条、加号禁用(整行提交语义下防并发互相覆盖)。
|
||||
- **陷阱(防回归)**:Vue `v-model` 在 `type="number"` 输入框上自动把值转 number——读取草稿必须 `String()` 容错,否则 `.trim()` 抛 `TypeError` 中断整个失焦提交(表现为既不保存也无任何提示)。回归测试 `OrderDeliveryReplyPage.chipEdit.spec.ts`(jsdom 挂载整页:空批次条新增保存、缺交期红字不保存、合计不符红字不保存三用例)。
|
||||
- **设计系统(平台样式层,详见 [ui/DESIGN_SYSTEM.md](../../ui/DESIGN_SYSTEM.md))**:`style.css` 新增 `.badge-success/info/warning/error`(`--status-*` 令牌驱动);`shared/styles/utilities.css` 新增行交互态 `bg-row-selected/highlight`、`hover-row`、冻结列 `frozen-cell(--selected/--highlight)`(实色底+状态色平铺叠加,防暗色半透明令牌透出滚动内容)、`text-status-*`、`shadow-sticky-col`;页面完成 L1/L2 迁移(`surface-panel`/`dialog-*`/`input-field`/`select-field`/`badge-*`/`page-shell`,批量通知确认改共享 `DeleteConfirmDialog`,原生 `window.confirm` 废弃)。
|
||||
|
||||
---
|
||||
|
||||
|
||||
+6
-6
@@ -4,11 +4,11 @@
|
||||
|
||||
| 功能项 | 状态 | 说明 |
|
||||
| --- | --- | --- |
|
||||
| ERP 订单行同步 | 已实现 | 每天 07:00(Asia/Shanghai)排程 + 生管手动全量同步,同步成功后按任务参数「同步完成提醒收件人」提醒生管(与「通知人」互相独立,留空回退通知人);到期排程由独立 worker 进程执行(`workers/worker_scheduler.py` / 生产 `hxops-schedule-worker` 容器;2026-09-29 合并 dev 主线后 Web 进程不再兜底扫描);只拉已审核(`oeaconf='Y'`)+ 已核准(`oea49='1'`)+ 未结案(`oeb70≠Y`)+ 完全未交(`NVL(oeb24,0)=0`,已有交货的行不同步)的订单行到本地快照(`order_delivery_erp_lines`),upsert 仅更新 ERP 列白名单不覆盖回复;本轮未命中行标 `erp_missing` 不删除;失败保留上次快照并展示最近同步时间。 |
|
||||
| ERP 订单行同步 | 已实现 | 每天 07:00(Asia/Shanghai)排程 + 生管手动全量同步,同步成功后按任务参数「同步完成提醒收件人」提醒生管(与「通知人」互相独立,留空回退通知人);到期排程由独立 worker 进程执行(`workers/worker_scheduler.py` / 生产 `hxops-schedule-worker` 容器;2026-09-29 合并 dev 主线后 Web 进程不再兜底扫描);只拉已审核(`oeaconf='Y'`)+ 已核准(`oea49='1'`)+ 未结案(`oeb70≠Y`)+ 完全未交(`NVL(oeb24,0)=0`,已有交货的行不同步)的订单行到本地快照(`order_delivery_erp_lines`),upsert 仅更新 ERP 列白名单不覆盖回复;本轮未命中行标 `erp_missing` 不删除;失败保留上次快照并展示最近同步时间;正式环境支持同步起始日边界(`ORDER_DELIVERY_SYNC_DATE_FROM`,2026-10-09 增补)——只同步订单日期 ≥ 起始日的订单行,早于边界的历史行不抓取并按 `erp_missing` 语义移出工作台,配置非法格式 fail-closed 拒绝同步,未配置=全量(dev/test 现状)。 |
|
||||
| 同步完成提醒生管 | 已实现 | 07:00 排程同步成功后,按该排程任务的「通知开关 + 通知人」(管理端排程表单现成配置,人员可配置)给生管发企微提醒查看当天交期回复(复用 `send_wecom_event_message`,事件 `order_delivery_reply_notify`);通知失败不影响同步结果;已置 `domain_notification_managed` 抑制通用排程完成通知避免双重打扰。 |
|
||||
| 订单行查询台 | 已实现 | 工作台操作页筛选分页:**关键词合并搜索**(订单单号/客户订单/客户编号/客户简称/公司全名/产品编号/品名/客户产品编号/业务员/交期回复人员命中任一,2026-09-21 由三框合并、2026-09-23 增补人员搜索)+ 订单日期 + 状态(全部·已回复·未完全回复),默认排序订单日期→客户→单号→项次,分页默认 50;列顺序:客户编号(副文案简称) → 订单日期 → 订单单号:项次 → 产品编号(副文案品名) → 客户产品编号 → 数量 → 约定交货日 → 交期回复状态 → 交期回复 → 交期回复人员 → 业务员(副文案部门) → 客户订单 → 规格 → 单位(独立的部门列/品名列已取消,与业务员/产品编号合并展示);表格浏览体验:页面高度收敛至视口(列头固定、横向滚动条常驻)、左侧冻结前四列标识区(勾选/客户编号/订单日期/订单单号:项次,已收窄)、行高紧凑(长文本截断悬停看全文、批次条不折行)、筛选区与工具栏字号与表格统一并压缩高度(全页 text-sm 14px,状态徽标例外 text-xs 12px 加粗);列表不出已交/未交两列(完全未交过滤后无信息量);行状态读时推导未回复/部分回复/已回复;列表不出单别、订单类型、已转请购、排定交货日。 |
|
||||
| 订单行查询台 | 已实现 | 工作台操作页筛选分页:**关键词合并搜索**(订单单号/客户订单/客户编号/客户简称/公司全名/产品编号/品名/客户产品编号/业务员/交期回复人员命中任一,2026-09-21 由三框合并、2026-09-23 增补人员搜索)+ 订单日期 + 状态(全部·已回复·未完全回复),默认排序订单日期→客户→单号→项次,分页默认 50;列顺序:客户编号(副文案简称) → 订单日期 → 订单单号:项次 → 产品编号(副文案品名) → 客户产品编号 → 数量 → 约定交货日 → 交期回复状态 → 交期回复 → 交期回复人员 → 业务员(副文案部门) → 客户订单 → 规格 → 单位 → 通知时间(2026-10-09 自交期回复人员列拆出独立列,锁定行展示、单行不折行;独立的部门列/品名列已取消,与业务员/产品编号合并展示);表格浏览体验:页面高度收敛至视口(列头固定、横向滚动条常驻)、左侧冻结前四列标识区(勾选/客户编号/订单日期/订单单号:项次,已收窄)、行高紧凑(长文本截断悬停看全文、批次条不折行)、筛选区与工具栏字号与表格统一并压缩高度(2026-10-09 修订:筛选区取消外置字段标签改单行紧凑布局,字段含义由输入框占位符/下拉选项承担、aria-label 保留无障碍语义,关键词占位简化为「订单/产品/客户/业务员/回复人员」,「共 X 条产品行」提示取消改由分页栏承载总数;筛选控件显式 text-sm + h-9 36px/圆角 8px 与合同付款预警搜索框逐项一致;页头字号对齐合同付款预警 text-lg→md:text-xl 18/20px;状态徽标例外 text-xs 12px 加粗;2026-10-09 对齐修订:除交期回复列(批次条按既定左对齐布局)外全列内容水平居中、行内容垂直居中,列头文字全部居中,交期回复状态徽标统一等宽;**导出 Excel(2026-10-09)**:工具栏右侧「导出 Excel」按钮(蓝色主按钮+下载图标,原提示文字胶囊取消),按当前筛选条件导出全部命中行(不分页,xlsx 18 列与列表列对应、批次合并「交期·数量」分号串、状态转中文),文件名「订单交期回复_YYYYMMDD.xlsx」,access 及以上可用);列表不出已交/未交两列(完全未交过滤后无信息量);行状态读时推导未回复/部分回复/已回复;列表不出单别、订单类型、已转请购、排定交货日。 |
|
||||
| 每日提醒(出货 + 未回复) | 已实现 | 新排程 `order-delivery-remind`(日批 07:10,种子 `SCH-ORDER-DELIVERY-REMIND`):① 已回复(已锁定)行的回复交期距今 ≤「出货提醒提前天数」(默认 3,任务参数可配)时按业务员聚合发一条企微提醒安排出货,同一(行,交期)只提醒一次、发送失败次日自动补发;② 超过「未回复再次提醒天数」(默认 3,任务参数可配)仍未回复的行按收件人聚合一并企微提醒生管(收件人=任务参数「未回复提醒收件人」多选,候选全部启用用户可搜索,与运行结果通知的「通知人」互相独立,留空回退通知人),同一行每 N 天最多提醒一次;两类提醒由任务参数 `ship_remind_enabled` / `unreplied_remind_enabled`(布尔,默认开)独立启停;提醒逐行写审计 `ship_remind` / `unreplied_remind`,只读业务数据不改批次/锁定;提醒天数钳制 0-3650(防日期溢出崩溃,2026-09-22 修复)。 |
|
||||
| 单行 / 拆分回复 | 已实现 | 弹窗维护 1..20 批「交期 + 数量 + 备注」,交期必填、数量>0、备注≤200、交期不重复,支持快速统一交期(2026-10-07 修订:仅联合回复弹窗保留,单行弹窗已取消);行徽标展示「订单数量:X 单位」;**数量守恒**:各批次合计必须等于订单数量才能保存;缺交期/缺数量、同单批次交期重复均按批次序号实时提示并随填写切换(2026-09-23 由「超额仅提醒」修订,后端 422 `BATCH_QTY_TOTAL_MISMATCH` / `BATCH_INVALID` 兜底);未锁定行整表替换批次;已锁定行 409。 |
|
||||
| 单行 / 拆分回复 | 已实现 | 弹窗维护 1..20 批「交期 + 数量 + 备注」,交期必填、数量>0、备注≤200、交期不重复,支持快速统一交期(2026-10-07 修订:仅联合回复弹窗保留,单行弹窗已取消);行徽标展示「订单数量:X 单位」;**数量守恒**:各批次合计必须等于订单数量才能保存;缺交期/缺数量、同单批次交期重复均按批次序号实时提示并随填写切换(2026-09-23 由「超额仅提醒」修订,后端 422 `BATCH_QTY_TOTAL_MISMATCH` / `BATCH_INVALID` 兜底);未锁定行整表替换批次;已锁定行 409;**批次条就地编辑(2026-10-09)**:未锁定且具备 manage 权限的行点击批次条原地变「交期+数量」输入(预填当前值;未回复行为空批次条=新增第一条批次,不显示时间/数量),回车/失焦自动保存单行接口并刷新,校验与弹窗同口径(缺交期/缺数量、同单交期重复、合计≠订单数量,行内红字阻断并重聚焦日期框),双清空=放弃编辑、Esc 取消,保存中禁止并发编辑/开弹窗(防整行提交互相覆盖);批次条不显示备注,多批次/备注仍走弹窗;交期回复列形态同步调整:动作入口统一为批次条前加号、「交期已锁定」徽标与批次计数/已回复统计文字取消(锁定状态由无加号与交期回复人员列「已通知」体现)、批次>1 显示展开/收起箭头(收起只展示第一批)、全表批次条左缘对齐。回归测试 `OrderDeliveryReplyPage.chipEdit.spec.ts`。 |
|
||||
| 联合回复与批量通知 | 已实现 | 勾选多行(全选仅本页)「联合回复交期」逐行保存批次(单次≤200 行,单行失败不回滚其它行;每行各批次合计须等于订单数量,不等行按行失败);通知唯一入口为工具栏「批量通知」(列表不出通知列,已通知对象与时间并入「交期回复人员」列),对已有批次且未锁定的行逐行发送并锁定,无批次/已锁定跳过并汇总提示。 |
|
||||
| 企微通知与行级锁定 | 已实现 | 复用平台 `send_wecom_event_message`(textcard 壳 + 既有回执审计,不自绘卡片);收件人按订单业务员 `oea14`→`User.employee_id`→企微 userid,对不上该行失败不锁定;发送成功与 locked 同事务(禁止已通知未锁定);正文「您有订单号:项次{单号}:{项次}的订单需要填写/确认/查看交期。」;四类卡片按类型带参直达操作页(行通知带单号+项次定位高亮、提醒卡带状态筛选),未登录先登录后原样回跳。 |
|
||||
| 功能权限与审计 | 已实现 | 用户功能权限 `order_delivery_reply.manage`(生管可写)/ `access`(业务只读),admin 默认开,用户管理表单勾选(四语言),可选按部门一次性批量发放;保存/通知/锁定/同步/出货提醒/未回复提醒六类审计(`order_delivery_audit_events`)。单别白名单管理为后期(`slip_code` 已落库预留)。 |
|
||||
@@ -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)。 |
|
||||
|
||||
## 知识库同步状态校验
|
||||
|
||||
|
||||
@@ -12,5 +12,6 @@
|
||||
| [progress_contract_platform_prototype.html](progress_contract_platform_prototype.html) | 进度契约平台 HTML 原型 |
|
||||
| [enterprise-integration-center-prototype.md](enterprise-integration-center-prototype.md) | 企业集成中心蓝图(完整愿景,含 HTML 原型) |
|
||||
| [integration-connector-framework-design.md](integration-connector-framework-design.md) | Integration Connector Framework 设计(首期最小可行收敛版) |
|
||||
| [permission-model.md](permission-model.md) | 现网权限说明:角色包、能力键、应用授权、管理后台 |
|
||||
| [role-permission-prototype.md](role-permission-prototype.md) | 可配置角色权限包(一期约定);[可点击原型](role-permission-prototype.html) |
|
||||
| [awaiting-callback-reconciler-design.md](awaiting-callback-reconciler-design.md) | 通用「等待外部回调」对账器设计(三域超时兜底统一;设计草案,P2+ 未实施) |
|
||||
@@ -0,0 +1,140 @@
|
||||
# 系统权限说明
|
||||
|
||||
> **文档路径**:`docs/platform/permission-model.md`
|
||||
> **用途**:说明现网权限怎么判、有哪些角色包、有哪些能力键,以及哪些业务只认应用授权或平台管理员。
|
||||
> **依赖**:`permission_roles`、`permission_role_agents`、`users.role`、`user_agent_permissions`、`User.get_feature_permissions`。
|
||||
> **逻辑**:管理端在 `/admin/permissions` 配角色包;运行时登录态下发 `is_platform_admin` / `role_name` / `feature_permissions`。产品交互约定见 [role-permission-prototype.md](role-permission-prototype.md)。能力目录以 `backend/app/services/permission_roles/catalog.py` 为准。
|
||||
|
||||
---
|
||||
|
||||
## 怎么判权
|
||||
|
||||
一个人只绑一个角色。角色包决定能进哪些应用,以及进了应用之后能做哪些事。平台管理员是特例:应用入口默认全开,也能进管理后台。部门不授权。
|
||||
|
||||
登录后后端下发三样东西,前端路由守卫和后端接口用同一份结果:
|
||||
|
||||
| 字段 | 含义 |
|
||||
| --- | --- |
|
||||
| `is_platform_admin` | 是否平台管理员 |
|
||||
| `role_name` | 角色显示名 |
|
||||
| `feature_permissions` | 应用内能力键,值为布尔 |
|
||||
|
||||
三层数据:
|
||||
|
||||
| 层 | 存在哪 | 运行时怎么用 |
|
||||
| --- | --- | --- |
|
||||
| 角色包 | `users.role` 指向 `permission_roles.code` | 每人一个。改角色,或改该角色的勾选,会立刻重写这个人的应用授权 |
|
||||
| 应用入口 | `permission_role_agents`,同步到 `user_agent_permissions` | 聊天和工作台按「有没有这个 Agent」放行。平台管理员不写授权行,入口隐式全开 |
|
||||
| 应用内能力 | 角色包上的 `feature_permissions` | 已经进了应用之后,再卡统计、强制新建、台账维护这类动作 |
|
||||
|
||||
未种子权限组时,只有 `users.role = admin` 算平台管理员,能力键默认全开。种子之后以权限组上的 `is_platform_admin` 为准,不再用 `hr` 这类角色名暗示能力。种子后禁止按人单独加应用(`POST /users/:id/permissions`、批量权限、按 Agent 授权、权限申请批准加应用)。
|
||||
|
||||
主要代码:
|
||||
|
||||
- 能力目录与种子角色:`backend/app/services/permission_roles/catalog.py`
|
||||
- 有效权限计算、按角色重写授权:`backend/app/services/permission_roles/service.py`
|
||||
- 用户侧合并:`User.get_feature_permissions` / `User.is_platform_admin`(`backend/app/models/user.py`)
|
||||
- 接口装饰器:`@require_admin`、`@require_agent_permission`(`backend/app/core/decorators.py`)
|
||||
- 前端守卫:`requiresAdmin`、`requiresFeaturePermission`(`frontend/src/app/router/guards.ts`)
|
||||
|
||||
---
|
||||
|
||||
## 内置角色包
|
||||
|
||||
| 编码 | 名称 | 默认给什么 |
|
||||
| --- | --- | --- |
|
||||
| `user` | 普通用户 | 新建用户默认。只勾通用入口。企业知识库在这个聊天里切换,不单独占一列权限 |
|
||||
| `rd` | 研发应用 | 通用入口,以及名称含「专利」的应用 |
|
||||
| `hr` | 培训 HR | 通用入口、培训应用,并打开 `training_hr_manage` |
|
||||
| `shipping` | 货代专员 | 通用入口、货代应用,并打开 `shipping_notice_force_create` |
|
||||
| `admin` | 管理员 | 平台管理员。应用隐式全开,全部能力键默认打开,可进 `/admin` |
|
||||
|
||||
`user`、`hr`、`admin` 是系统角色。`rd`、`shipping` 可以再增删应用。管理员也可以在后台另建角色包。
|
||||
|
||||
---
|
||||
|
||||
## 应用内能力键
|
||||
|
||||
角色编辑里能勾的固定能力。平台管理员默认全开;角色包里可以把某一项关掉。键名与 `KNOWN_FEATURE_KEYS` 对齐。
|
||||
|
||||
### 培训
|
||||
|
||||
要先勾上内容画像为 `training` 的应用,卡片里才会出现这项。
|
||||
|
||||
| 键 | 作用 |
|
||||
| --- | --- |
|
||||
| `training_hr_manage` | HR 管理:查看统计、筛选记录、导出 Excel。没有这把钥匙只能当学员使用培训 |
|
||||
|
||||
### 货代发货通知
|
||||
|
||||
绑定 `agent_code=shipping_notice`。
|
||||
|
||||
| 键 | 作用 |
|
||||
| --- | --- |
|
||||
| `shipping_notice_force_create` | 跳过重复拦截,强制新建发货通知 |
|
||||
| `shipping_notice.audit_sensitive_read` | 查看审计里的 before / after / Diff 正文 |
|
||||
| `shipping_notice.xfa_split_rule_edit` | 维护字段拆分规则 |
|
||||
| `shipping_notice.xfa_split_rule_preview` | 预览拆分结果 |
|
||||
| `shipping_notice.xfa_split_rule_publish` | 审核并发布拆分规则 |
|
||||
|
||||
后三项主要卡在管理后台的货代模板与审计接口上:先要是平台管理员,再要有对应能力键。
|
||||
|
||||
### 设备维保
|
||||
|
||||
绑定名称含「维保」或「维修」,或 `agent_code=maintenance` 的应用。
|
||||
|
||||
| 键 | 作用 |
|
||||
| --- | --- |
|
||||
| `maintenance.ledger_write` | 维护设备台账和维修记录。没有则只能查看 |
|
||||
|
||||
### 订单交期回复
|
||||
|
||||
绑定 `agent_code=order_delivery_reply`。有 `manage` 就视为同时有 `access`。
|
||||
|
||||
| 键 | 作用 |
|
||||
| --- | --- |
|
||||
| `order_delivery_reply.access` | 只读已同步订单和回复结果 |
|
||||
| `order_delivery_reply.manage` | 生管回复交期、发送通知、手动同步 |
|
||||
|
||||
读接口要求 `access` 或 `manage`;保存、通知、同步要求 `manage`。部门批量发放只给平台管理员。前端订单交期页用 `requiresFeaturePermission=order_delivery_reply.access` 拦截(持有 `manage` 的人后端视为有 access;守卫读的是登录态里的显式布尔值,角色包须两键一并授予)。
|
||||
|
||||
---
|
||||
|
||||
## 按应用授权
|
||||
|
||||
这些业务不进能力目录。角色包勾上对应 Agent 就能看;改数据、同步、发通知再要求平台管理员。
|
||||
|
||||
聊天主链路(会话、补全、附件)统一走 `@require_agent_permission`:请求带 `agent_id`,用户在该 Agent 的授权名单里,或是平台管理员。
|
||||
|
||||
| 应用 `agent_code` | 持有该 Agent 能做 | 仅平台管理员 |
|
||||
| --- | --- | --- |
|
||||
| `contract_payment` | 查合同付款台账 | 同步 OA、强制覆盖、批量重解析、扫描预警、发送周汇总 |
|
||||
| `voucher_check` | 查检核任务和发送记录 | 强制重检、通知配置 |
|
||||
| `equipment_acceptance` | 打开设备验收预警作业面 | 从 E10 同步、修改配置 |
|
||||
| `in_transit_transfer` | 使用在途调拨接口 | 平台管理员同样放行,没有单独的只读/可写能力键 |
|
||||
|
||||
合同付款不再占用功能权限键。无授权返回业务 403,例如 `CONTRACT_PAYMENT.FORBIDDEN`;管理动作返回 `*.ADMIN_REQUIRED`。
|
||||
|
||||
---
|
||||
|
||||
## 管理后台
|
||||
|
||||
`/admin` 整棵树只认平台管理员。前端路由 `requiresAdmin`,后端 `@require_admin`。模块之间不再拆权限,能进后台就能进这些模块:
|
||||
|
||||
- 总览、用户、部门、应用、权限组
|
||||
- 知识库、排程、企业微信、关联服务、平台应用
|
||||
- 公告、快捷问题、培训配置、采购合同、集成连接器、报表
|
||||
- 货代管理:字段资产、订单 Schema、订单文档模板、客户识别规则、识别任务、库存与连接配置、运行与审计、门禁诊断
|
||||
|
||||
侧栏「管理控制台」只对 `is_platform_admin` 显示。非平台管理员访问 `/admin` 会被送回应用管理。
|
||||
|
||||
货代管理页本身是管理员页。读取敏感审计、编辑 / 预览 / 发布拆分规则,还会再查上一节的货代能力键。
|
||||
|
||||
---
|
||||
|
||||
## 按数据归属,不按角色勾选
|
||||
|
||||
| 场景 | 谁可以 |
|
||||
| --- | --- |
|
||||
| 收料归档文件下载 | 平台管理员,或该排程任务的通知接收人 |
|
||||
| 货代门禁恢复 | 读:单据属主、平台管理员,或持有该 Run 所属 Agent 的人。写:单据属主或平台管理员。管理端路由另由 `@require_admin` 保护 |
|
||||
@@ -1,47 +0,0 @@
|
||||
# 角色权限配置原型
|
||||
|
||||
> **文档路径**:`docs/platform/role-permission-prototype.md`
|
||||
> **用途**:可配置角色(权限包)一期产品原型说明;交互稿见同目录 HTML。
|
||||
> **依赖**:管理控制台「应用权限」、`permission_roles`、`users.role`、`user_agent_permissions`。
|
||||
> **逻辑**:新建用户由管理员选角色(默认普通用户);已有用户可按角色点人数筛选勾选,确定前确认影响。一期已按此实现。可点击稿:[role-permission-prototype.html](role-permission-prototype.html)
|
||||
|
||||
---
|
||||
|
||||
## 怎么打开
|
||||
|
||||
用浏览器直接打开 `docs/platform/role-permission-prototype.html`(无需启动前后端)。左侧切换:
|
||||
|
||||
| 屏 | 要看什么 |
|
||||
| --- | --- |
|
||||
| **角色配置** | 权限包列表。点「编辑」给该角色勾应用;点蓝色**人数**给该角色加人 |
|
||||
| **编辑角色** | 列出全部可授权应用;保存前确认会立刻改变该角色下所有人的入口 |
|
||||
| **用户管理** | **新建用户必须选角色**,默认普通用户;编辑用户改角色也会先确认 |
|
||||
| **权限核对** | 现行矩阵的只读形态,格子禁用 |
|
||||
| **现行应用权限** | 对照说明:为什么不再按人打勾 |
|
||||
|
||||
建议演示:
|
||||
|
||||
1. **用户管理 → 新建用户**:角色预填「普通用户」,可改成培训 HR / 研发应用等,非默认角色会再确认。
|
||||
2. **新增应用后**:先编辑对应角色勾上该应用 → 再点该角色人数,按部门筛选勾选要进这个角色的人 → **确定后弹出确认**(写清从哪些角色改入)。全选只勾草稿,不要不核对就点确认调整。
|
||||
|
||||
---
|
||||
|
||||
## 一期约定(已画进原型)
|
||||
|
||||
1. **角色 = 权限包**:可用应用 + 应用内能力;管理员单独带「可进 /admin」。
|
||||
2. **用户只选一个角色**。新建时由管理员指定,默认普通用户;部门不会自动授权。
|
||||
3. **普通用户**默认只勾 **通用入口**(企业知识库是该聊天里的库切换,不单独占一列)。
|
||||
4. **研发应用** = 通用入口 + 研发侧应用(如专利);本地尚未接入的应用之后勾进本组即可。编码仍为 `rd`。
|
||||
5. 角色编辑列出**应用管理中全部启用应用**。有功能权限的应用在卡片内用短标签配置,不另开一排长框。新增应用:勾到需要的角色上,再按需把人改进该角色。
|
||||
6. **保存角色立即对已绑该角色的用户生效**,弹窗提示人数,须确认。
|
||||
7. **管理员内置**:应用入口隐式全开;人数不可点;选人列表排除管理员。改到/改出管理员须额外确认。
|
||||
8. **已有用户批量改角色**:点人数,左部门仅筛选。勾选后确定先出确认框(从来源角色、将失去原权限)。全选不是默认操作。
|
||||
9. **取消勾选后确认** = 回到默认普通用户。编辑「普通用户」时取消勾选忽略。
|
||||
|
||||
---
|
||||
|
||||
## 一期不做
|
||||
|
||||
- 一人多角色、按人额外加应用、在核对矩阵上打勾。
|
||||
- 部门自动映射角色(部门是组织,角色是权限包;入职/调岗由管理员选或改角色)。
|
||||
- 员工自助「申请某个应用」(若保留申请,应改为申请换角色)。
|
||||
+7
-1
@@ -5,7 +5,7 @@
|
||||
- 表:`permission_roles`(code/name/feature_permissions/is_default/is_platform_admin)与 `permission_role_agents`。成员仍写在 `users.role`(加宽至 64)。运行时 Chat/工作台继续读 `user_agent_permissions` 与 `require_agent_permission`(`is_platform_admin` 旁路);非管理员的 Agent 行由角色包全量替换。排程种子 owner 与 RPA 心跳告警管理员兜底改为 join `is_platform_admin`(未种子权限组时回退 `users.role=admin`)。登录态下发 `is_platform_admin` / `role_name` / `feature_permissions`;业务门闩认标记与能力键。未种子时默认能力仅平台管理员全开,不再用 `hr` / `maintenance_manager` 角色名暗示权限(培训 FAQ 的 HR/员工身份、会话 guest、聊天 message.role、保留码 `admin` 除外)。
|
||||
- 种子:`user` 普通用户、`rd` 研发应用、`hr` 培训 HR、`shipping` 货代专员、`admin` 管理员。不再种子设备维保专员。
|
||||
- 管理 API:`/api/admin/permission-roles*`(列表、目录、CRUD、成员 preview/apply)。种子后禁止 `POST /users/:id/permissions`、`/permissions/batch`、`/agents/:id/permissions` 与权限申请批准加应用。
|
||||
- 前端:`/admin/permissions` 角色配置 + 只读矩阵;用户表单只选角色。能力键与 `User.get_feature_permissions` 对齐。详细约定见 [platform/role-permission-prototype.md](platform/role-permission-prototype.md)。
|
||||
- 前端:`/admin/permissions` 角色配置 + 只读矩阵;用户表单只选角色。能力键与 `User.get_feature_permissions` 对齐。权限分层与能力清单见 [platform/permission-model.md](platform/permission-model.md);交互约定见 [platform/role-permission-prototype.md](platform/role-permission-prototype.md)。
|
||||
- AI 工作台侧栏底部「返回聊天」上方,仅 `is_platform_admin` 渲染「管理控制台」入口(`openAdminPanel` → `/admin`);`/admin` 仍由路由守卫 `requiresAdmin` 拦截非平台管理员。
|
||||
|
||||
## 合同付款预警(2026-08)
|
||||
@@ -1529,3 +1529,9 @@ RecoveryPlan → Gate Attempt → Job → Worker/RPA → 幂等回调 → `run_t
|
||||
# 在途仓自动调拨独立架构(2026-08)
|
||||
|
||||
调拨业务域独立于 shipping_notice 订单解析:ackend/app/services/in_transit_transfer/ 承载状态机/DTO/审计/文件准备/预检/执行/恢复/通知/归档/指标,erp_adapter.py 为 ERP 唯一访问出口(SOAP 在 WSDL 冻结前 fail-closed,凭据仅来自环境/Secret)。数据落 ransfer_* 七表(迁移 it1a2b3c4d5e);异步走 ransfer 队列(workers/worker_in_transit_transfer.py);08:00/09:00 platform job 注册于 schedule。前端卡片在 rontend/src/features/chat/(TransferMessageView 自驱动),四语言文案齐备。运维手册见 [features/in-transit-transfer/technical.md](features/in-transit-transfer/technical.md)。
|
||||
|
||||
# 跨文档主题同步与前端设计系统补全(2026-10-09)
|
||||
|
||||
- **主题跨文档同步**:`shared/composables/useTheme.ts` 的 `initTheme()` 新增 `storage` 事件监听(`cleanupTheme` 对应解绑)。背景:应用管理 iframe 应用(如订单交期回复 `/apps/order-delivery-reply`)是独立文档,主题类挂在各自 `<html>` 上,父壳切换亮暗后 iframe 收不到任何通知,停留在加载时的主题。`storage` 事件只在「其他同源文档」修改 localStorage 时触发,监听 `hxops_theme_preference` 变化后同步偏好并 `applyTheme()`,父壳切换主题的所有同源 iframe 实时跟随;iframe 首次加载仍按 localStorage + `matchMedia` 初始化,行为不变。
|
||||
- **设计系统补全(规则见 [ui/DESIGN_SYSTEM.md](ui/DESIGN_SYSTEM.md))**:`style.css` 新增 `.badge-success/info/warning/error`(`--status-*` 令牌驱动,替代 rose/emerald 等原生色徽标);`shared/styles/utilities.css` 新增行交互态 `bg-row-selected/highlight`、`hover-row`(`:not()` 保证选中/高亮行不被悬停覆盖)、冻结列 `frozen-cell(--selected/--highlight)`(实色底 + 状态色平铺叠加——暗色状态令牌为半透明 rgba,直接作背景会在横向滚动时透出内容)、`text-status-success/info/warning/error`、`shadow-sticky-col`。
|
||||
- **陷阱记录**:Vue `v-model` 在 `type="number"` 输入框上自动把值转成 number,业务代码读取后调用字符串方法(如 `.trim()`)会抛 TypeError 中断整个事件处理器(现场:订单交期回复批次条就地编辑失焦不保存、无任何提示);读取统一 `String()` 容错。详见 [features/order-delivery-reply/technical-design.md](features/order-delivery-reply/technical-design.md) §8.4。
|
||||
@@ -0,0 +1,248 @@
|
||||
# Element Plus 迁移规范
|
||||
|
||||
> **用途**:管理端页面从手写 Tailwind 控件换成 Element Plus 时的唯一操作说明。后续每换一页,按本文做,不要再单页发明一套间距、字号或按钮写法。
|
||||
> **适用**:管理控制台里已经或即将换成 Element 的列表、筛选、表格、表单弹窗。
|
||||
> **不适用**:对话、文档画布、冻结列宽表(订单交期回复、发货审核等)。这些仍走 [UI_CODING_GUIDELINES.md](./UI_CODING_GUIDELINES.md),不要在同一块界面里混用两套按钮和输入框。
|
||||
> **试点**:用户管理、应用配置、知识库分组。列表和短弹窗已按本文收过。应用配置的创建/编辑表单内部还没换完,见 §8。新页面以本文为准。
|
||||
|
||||
旧页面在换完之前,继续遵守 [UI_CODING_GUIDELINES.md](./UI_CODING_GUIDELINES.md)。换到 Element 的那一块,以本文为准。
|
||||
|
||||
---
|
||||
|
||||
## 1. 接入方式
|
||||
|
||||
按页面接入,不在 `main.ts` 里 `app.use(ElementPlus)`,也不要全局注册全部组件。
|
||||
|
||||
每个改为 Element 的页面(或该页专用弹窗)需要:
|
||||
|
||||
1. 按名字导入用到的组件,例如 `ElButton`、`ElTable`、`ElDialog`。
|
||||
2. 引入样式(页面入口引一次即可,弹窗跟页面走,不必再引):
|
||||
|
||||
```ts
|
||||
import 'element-plus/dist/index.css';
|
||||
import 'element-plus/theme-chalk/dark/css-vars.css';
|
||||
import '@/features/admin/styles/element-trial.css';
|
||||
```
|
||||
|
||||
3. 用 `useElementProvider()` 取出 `elementLocale`,页面根上包 `ElConfigProvider`。亮暗靠现有 `html.dark` 加上面的暗色变量文件,不要在组件里再切一套主题算法。
|
||||
4. 使用 `v-loading` 时,在 `<script setup>` 里写 `const vLoading = ElLoading.directive`。
|
||||
5. 文案继续用现有 i18n key。新增文案必须同时补齐 zh-CN / zh-TW / en / th。
|
||||
6. 图标用 `@element-plus/icons-vue`,放进 `ElButton` 的 `icon` 属性。不要再把 `lucide-vue-next` 的图标塞进 Element 按钮。
|
||||
|
||||
`element-trial.css` 是管理端 Element 的公共皮肤,只放变量和与 Tailwind 共存的修正。某一页的列宽、筛选框宽度不要写进这个文件。
|
||||
|
||||
---
|
||||
|
||||
## 2. 先写入变量,再换页面
|
||||
|
||||
下面这些变量已经写在 `frontend/src/features/admin/styles/element-trial.css` 的 `:root, html.dark` 里。Element 暗色表在 `html.dark` 上另有一份默认值,所以必须和亮色写在一起,后引入的文件才能盖过它。页面不要再各写一套字号和颜色。
|
||||
|
||||
| 变量 | 对齐到 | 用途 |
|
||||
| --- | --- | --- |
|
||||
| `--el-font-family` | 已设为 PingFang SC / Microsoft YaHei | 控件字体 |
|
||||
| `--el-color-primary` | 已设为 `#0284c7` | 主按钮、链接、聚焦边框 |
|
||||
| `--el-font-size-large` | `18px`(现有 `.section-title`) | 页标题若改用 Element 排版时使用 |
|
||||
| `--el-font-size-base` | `14px` | 正文、按钮、输入框、表格单元格 |
|
||||
| `--el-font-size-small` | `13px` | 次要说明、统计 |
|
||||
| `--el-font-size-extra-small` | `12px` | 标签、辅助提示 |
|
||||
| `--el-text-color-primary` | `var(--text-primary)` | 标题、强调 |
|
||||
| `--el-text-color-regular` | `var(--text-secondary)` | 正文 |
|
||||
| `--el-text-color-secondary` | `var(--text-muted)` | 说明、表头、统计 |
|
||||
| `--el-text-color-placeholder` | `var(--text-muted)` | 占位符 |
|
||||
| `--el-border-color` | `var(--border-default)` | 输入框、分割线 |
|
||||
| `--el-border-color-light` / `--el-border-color-lighter` | `var(--border-subtle)` | 表格线、弱分割 |
|
||||
| `--el-bg-color` | `var(--bg-surface)` | 弹窗、表格底 |
|
||||
| `--el-fill-color-light` | `var(--bg-surface-soft)` | 表头底 |
|
||||
| `--el-border-radius-base` | `8px` | 按钮、输入框、标签 |
|
||||
| `--el-component-size` | `32px` | 默认按钮、输入框、下拉的高度 |
|
||||
|
||||
页面里禁止再用 `text-xs`、`text-sm`、`text-[13px]`、`font-semibold`、`text-primary`、`text-muted` 去改 Element 控件内部或表格单元格的字号和颜色。单元格需要强调时,用 Element 的字重变量或标签,不要回到 Tailwind 字号。
|
||||
|
||||
暗色只改上述变量在 `html.dark` 下的取值。不要写 `dark:` 工具类。
|
||||
|
||||
---
|
||||
|
||||
## 3. 列表页骨架(只有这一套)
|
||||
|
||||
```text
|
||||
section.admin-table-section 一张圆角卡片,页面上只此一层
|
||||
标题栏 section-title + section-desc + 右侧 ElSpace 按钮
|
||||
筛选条 一行控件,底部分隔线
|
||||
ElTable 表头用 Element 灰底,左右内边距与标题栏一致
|
||||
分页 右对齐,上边一条分隔线
|
||||
```
|
||||
|
||||
约定:
|
||||
|
||||
- 标题用 `.section-title`,说明用 `.section-desc`。不要在知识库这种页面单独写 `text-xl font-bold`。
|
||||
- 左右内边距统一 `32px`(标题、筛选、表格首列/末列、分页同一条边)。
|
||||
- 筛选和表格之间用一条 `var(--el-border-color-lighter)` 分隔。表头保留 Element 浅灰底,作为第二层分界。不要再在卡片里套一张卡片。
|
||||
- 统计数字放在筛选行右侧,不要单独占一行贴在表头上。
|
||||
- 分页用 `ElPagination`,`layout="total, sizes, prev, pager, next"`,`background`。页码和每页条数绑定现有的页码状态,不要另写一套 `PaginationBar`。
|
||||
|
||||
---
|
||||
|
||||
## 4. 组件怎么用
|
||||
|
||||
### 4.1 按钮
|
||||
|
||||
| 位置 | 写法 |
|
||||
| --- | --- |
|
||||
| 页头主操作(新建、创建) | `ElButton type="primary"`,带 `icon` |
|
||||
| 页头次操作(刷新、设置、跳转) | 默认 `ElButton`,带 `icon` |
|
||||
| 行内编辑、查看 | `ElButton link type="primary"` |
|
||||
| 行内删除 | `ElButton link type="danger"` |
|
||||
| 弹窗取消 | 默认 `ElButton` |
|
||||
| 弹窗确定 | `ElButton type="primary"`,提交中加 `:loading` |
|
||||
|
||||
同一工具栏里不要出现 `size="small"` 的实心按钮和默认高度按钮混排。行内有文字就用链接按钮,不要再做小图标方钮。没有文字、只能放图标时,必须带 i18n 的 `title`。
|
||||
|
||||
危险操作不要用绿色、蓝色按钮。测试、启用这类状态按钮用 `ElTag` 表达状态,操作本身仍按上表。
|
||||
|
||||
### 4.2 表格
|
||||
|
||||
- 必须设 `row-key`。
|
||||
- 空数据用 `:empty-text`,文案用已有 i18n key。
|
||||
- 状态列一律 `ElTag effect="light"`。启用 `success`,停用 `info`,警告 `warning`。不要自绘圆点,不要用 `bg-green-500` 这类 Tailwind 色。
|
||||
- 表头背景、边框色走 §2 的变量,单页不要再覆盖 `--el-table-header-bg-color`。
|
||||
- 列用 `min-width`。操作列固定 `width`,`align="right"`。
|
||||
- 服务端排序用 `sortable="custom"`,在现有的排序函数里改页码并重新请求。不要表格本地排一遍、接口再排一遍。
|
||||
- 头像不要用默认 `ElAvatar`(会变成灰色)。用户头像继续用现有品牌渐变圆标。
|
||||
|
||||
### 4.3 筛选
|
||||
|
||||
- `ElInput`、`ElSelect` 默认 `width: 100%`。必须放在限定宽度的容器里,搜索框约 `16rem`,下拉按最长文案定宽(约 `11rem`),靠左排,禁止用 `1fr` 把搜索框拉满整行。
|
||||
- 「全部 / 所有部门」这类空条件用 `placeholder` 表达。`ElSelect` 的值不要用空字符串,空着时传 `undefined`,清空后写回 `''`。否则会显示 Element 默认的「请选择」。
|
||||
- 少量互斥筛选(全部 / 有文档 / 空分组)用 `ElRadioGroup` + `ElRadioButton`,选项值用业务枚举,不要用 `label` 当值。
|
||||
- 窗口变窄时换行,不要每个控件各占一整行。
|
||||
|
||||
### 4.4 弹窗和表单
|
||||
|
||||
- 用 `ElDialog`,`align-center`,`append-to-body`,`:close-on-click-modal="false"`。
|
||||
- 短表单(大约 4 个字段以内)宽度 `480px`,一列。字段多或本来就是两列的,宽度 `680px`。不要用整屏高的抽屉装两个字段。
|
||||
- `ElForm` 使用 `label-position="top"`。
|
||||
- 标题用 `ElDialog` 的 `title`。说明放在对应 `ElFormItem` 里,字号走 §2,不要写 `text-xs text-muted`。
|
||||
- 多行文本用 `ElInput type="textarea"`,行数按内容来,一般 4 行。不要把 `.el-textarea__inner` 的边框清掉,那一层就是输入框的边框。
|
||||
- 提交按钮使用 `:loading`,防止重复提交。提交过程中不允许点遮罩关闭。
|
||||
- 只有从屏幕侧边滑出、且内容确实很长时才用 `ElDrawer`。创建、编辑这种短表单用对话框。
|
||||
|
||||
### 4.5 反馈
|
||||
|
||||
- `v-loading` 只盖住表格,并且只等列表自己的请求。目录、用户、排程等弹窗依赖放到列表返回之后再拉,不能让遮罩一直盖住已经画出来的行。
|
||||
- 删除、不可逆操作统一用 `ElMessageBox.confirm`,按钮文案和提示用现有 i18n。同一页不要同时留着 `DeleteConfirmDialog` 和 `ElMessageBox`。旧确认框在改该页时一起换掉。
|
||||
- 操作成功或失败用 `useMessage()`。需要留在页面上的结果才用 `ElAlert`。
|
||||
|
||||
### 4.6 语言
|
||||
|
||||
`useElementProvider` 已映射 zh-CN、zh-TW、en、th。新页面把 `elementLocale` 传给 `ElConfigProvider`,不要在某个弹窗里写死 `zh-cn`。
|
||||
|
||||
---
|
||||
|
||||
## 5. 不要这样做
|
||||
|
||||
- 不要在 `main.ts` 全量注册 Element。
|
||||
- 不要在同一工具栏里混用 `.btn-primary` 和 `ElButton`。
|
||||
- 不要用 `!important` 压 Tailwind。Element 是静态 CSS,用更具体的选择器。单行输入框内部的蓝竖线,只重置 `.el-input__inner`,见 `element-trial.css`。
|
||||
- 不要改全局 `svg { display }`。按钮图标的横向排列只写在 `element-trial.css` 的 `.el-button` 上。
|
||||
- 不要新增第二套组件库,也不要在已换 Element 的页面里再手写一套输入框样式。
|
||||
- 不要为了换皮去改接口、分页协议和权限判断。
|
||||
|
||||
---
|
||||
|
||||
## 6. 单页检查清单
|
||||
|
||||
换完一页,逐项核对:
|
||||
|
||||
- [ ] 只在该页入口引入 Element 样式和 `element-trial.css`,并用 `ElConfigProvider` 包住。
|
||||
- [ ] 列表骨架符合 §3,左右 32px 对齐,只有一层卡片。
|
||||
- [ ] 按钮符合 §4.1,没有 `size="small"` 和默认按钮混在一行。
|
||||
- [ ] 表格状态是 `ElTag`,单元格没有 `text-xs` / `text-sm` / `text-muted`。
|
||||
- [ ] 筛选框没有被拉成整行,空选项不是「请选择」。
|
||||
- [ ] 弹窗宽度只有 480px 或 680px,短表单不是整屏抽屉。
|
||||
- [ ] 加载遮罩只等列表请求,数据出来后遮罩消失。
|
||||
- [ ] 删除确认与本页其他确认框是同一种。
|
||||
- [ ] 四种语言下按钮、表头、空状态、分页都能读通。
|
||||
- [ ] `html.dark` 下边框、表头、弹窗底色跟着变量变。
|
||||
- [ ] `frontend` 下 `npx vue-tsc -b --pretty false` 通过。
|
||||
|
||||
改管理端界面时,把这份清单写进合并请求描述。模板在 [`.gitee/PULL_REQUEST_TEMPLATE.md`](../../.gitee/PULL_REQUEST_TEMPLATE.md)。ESLint 规则仍是关闭的,间距、弹窗宽度和暗色要靠这份清单看。
|
||||
|
||||
---
|
||||
|
||||
## 7. 和 Tailwind 共存时已经踩过的问题
|
||||
|
||||
| 现象 | 原因 | 处理 |
|
||||
| --- | --- | --- |
|
||||
| 按钮里图标和文字分成两行 | Tailwind preflight 把 `svg` 设成 `display: block` | 只在 `.el-button` 上改为横向 flex,已写在 `element-trial.css` |
|
||||
| 搜索框聚焦时内部多两条蓝竖线 | `@tailwindcss/forms` 给内部 `input` 加了边框 | 只重置 `.el-input__inner` 的边框和阴影 |
|
||||
| 多行输入框看起来没有边框 | 上一行修正误伤了 `.el-textarea__inner` | 文本域保留 Element 的内阴影边框 |
|
||||
| 筛选框每个占满一行 | `ElInput` / `ElSelect` 默认 `width: 100%` | 外层限定宽度,靠左排列 |
|
||||
| 下拉显示「请选择」 | 空字符串不是合法选项值 | 空值用 `undefined`,清空写回 `''`,文案放 `placeholder` |
|
||||
| 列表已经出来,页面仍一直转圈 | `v-loading` 绑在整页,要等用户、排程等全部返回 | 遮罩只绑列表请求 |
|
||||
| 头像变成灰色 | `ElAvatar` 默认底色 | 继续用品牌渐变圆标 |
|
||||
|
||||
---
|
||||
|
||||
## 8. 试点页和本规范的差距
|
||||
|
||||
新页面不要复制这些差距。改到对应页时收口。
|
||||
|
||||
| 页面 | 状态 |
|
||||
| --- | --- |
|
||||
| 用户管理 | 列表、筛选、三个业务弹窗、删除和改角色确认已按 §3、§4 对齐。筛选宽度和两列表单写在页面里。 |
|
||||
| 知识库分组 | 列表骨架、行内链接按钮、删除确认、创建分组、Dify 设置和健康检查已对齐。 |
|
||||
| 应用配置 | 列表、状态标签、测试弹窗、授权弹窗和删除确认已对齐。创建/编辑弹窗外壳是 680px `ElDialog`,内部字段仍是 `input-field` 和 lucide 图标。下一步只改这个弹窗内部,不要连带改保存接口。 |
|
||||
|
||||
---
|
||||
|
||||
## 9. 检测规则
|
||||
|
||||
ESLint 已经装在 `frontend`,配置是 `frontend/eslint.config.js`,规则是 `frontend/eslint-rules/no-legacy-admin-controls.js`。规则名 `hxops/no-legacy-admin-controls`,**当前严重级别是 `off`**。`npm run build` 和提交钩子不跑它。
|
||||
|
||||
`frontend/` 有改动时,Jenkins 阶段 `Frontend Lint` 会执行 `scripts/ci_frontend_lint.sh`(`npm ci` 然后 `npm run lint`)。规则仍是 `off`,这一阶段现在应当通过。生产构建阶段仍是注释掉的,lint 不在 `npm run build` 里面。
|
||||
|
||||
手动查看时,在 `frontend` 目录执行:
|
||||
|
||||
```bash
|
||||
npm run lint
|
||||
```
|
||||
|
||||
规则关闭时,这条命令应通过,不会因为历史 `<button>` 失败。
|
||||
|
||||
### 9.1 查什么
|
||||
|
||||
启用之后,检查这些文件的**全文**(不只是本次 diff):
|
||||
|
||||
- `frontend/src/features/admin/**/*.vue`
|
||||
- `frontend/src/features/kb/components/KbAdminPanel.vue`
|
||||
- `frontend/src/features/kb/components/KbGroupDrawer.vue`
|
||||
|
||||
命中下面任一写法就失败:
|
||||
|
||||
- `<button>`、`<input>`、`<select>`、`<textarea>`
|
||||
- 样式类 `btn-primary`、`btn-secondary`、`btn-ghost`、`btn-danger`、`input-field`、`select-field`
|
||||
- 从 `lucide-vue-next` 引入图标
|
||||
|
||||
对话、文档画布、冻结列表格不在上述路径里,不会被这条规则扫到。`DeleteConfirmDialog` 在 `shared/components`,也不在范围内;那个组件按自己的迁移任务换。
|
||||
|
||||
### 9.2 后期如何启用
|
||||
|
||||
等上述路径里的页面都已按本文换成 Element,再打开规则。提前打开会把尚未迁移的管理页全部判失败。
|
||||
|
||||
1. 打开 `frontend/eslint.config.js`,把 `hxops/no-legacy-admin-controls` 从 `'off'` 改为 `'error'`。
|
||||
2. 在 `frontend` 执行 `npm run lint`,修到通过。
|
||||
3. 把 `npm run lint` 接到 CI。仍然不要写进 `npm run build`,构建和风格检查分开。
|
||||
4. 若以后有新的管理端 Vue 不在 §9.1 的路径里,把路径补进 `eslint.config.js` 的 `files`。禁止列表以规则文件为准,不要在文档和脚本里各写一份不同的类名。
|
||||
5. 同时启用编辑器规则:打开 `.cursor/rules/element-admin-ui.mdc`,按文件里的说明加上 `globs`。现在这份规则没有 `globs`,并且 `alwaysApply` 是 false,不会在打开管理端文件时自动套用。
|
||||
|
||||
启用后是整文件检查。已迁移文件里再补原生按钮也会失败,不需要再维护「只查新增行」的名单。
|
||||
|
||||
---
|
||||
|
||||
## 10. 建议的切换顺序
|
||||
|
||||
1. §2 的变量已写入 `element-trial.css`。换下一页之前,在暗色下打开一张已换页面,看按钮、表格和弹窗是否跟着令牌变。
|
||||
2. 三个试点的列表和短弹窗已按 §6 收过。还剩应用配置创建/编辑表单内部,换完它再进下一页。
|
||||
3. 之后每个管理端列表按 §6 的清单换,一页一次。合并请求用 `.gitee/PULL_REQUEST_TEMPLATE.md` 里的清单。换完再开下一页。
|
||||
4. §9.1 路径里的页面都换完后,按 §9.2 把 ESLint 规则改成 `error` 并接到 CI。
|
||||
5. 对话、文档画布、冻结列表格不在本顺序里。
|
||||
@@ -3,6 +3,7 @@
|
||||
> **用途**:新功能、改版、修 UI 时必读。给 AI 写需求时,可将本文 **§0 Prompt 片段** 与 **§1 铁律** 一并粘贴进任务说明。
|
||||
> **架构详解**:见 [DESIGN_SYSTEM.md](./DESIGN_SYSTEM.md)。
|
||||
> **样式实现**:`frontend/src/styles/tokens.css`、`utilities.css`、`components-ds.css`、`style.css`。
|
||||
> **管理端换 Element Plus**:正在迁移的列表和弹窗以 [ELEMENT_MIGRATION.md](./ELEMENT_MIGRATION.md) 为准。未迁移的页面仍用本文的按钮和输入框。同一块界面不要混用两套。
|
||||
|
||||
---
|
||||
|
||||
|
||||
@@ -0,0 +1,76 @@
|
||||
/**
|
||||
* frontend/eslint-rules/no-legacy-admin-controls.js
|
||||
* 用途:管理端 Vue 里禁止再写原生表单控件、旧按钮样式和 lucide 图标。
|
||||
* 依赖:vue-eslint-parser 提供的 VElement、VAttribute,以及脚本里的 ImportDeclaration。
|
||||
* 逻辑:由 eslint.config.js 以 hxops/no-legacy-admin-controls 挂上。当前严重级别为 off。
|
||||
* 改为 error 的步骤见 docs/ui/ELEMENT_MIGRATION.md §9。
|
||||
*/
|
||||
|
||||
const LEGACY_TAGS = new Set(['button', 'input', 'select', 'textarea']);
|
||||
const LEGACY_CLASSES = [
|
||||
'btn-primary',
|
||||
'btn-secondary',
|
||||
'btn-ghost',
|
||||
'btn-danger',
|
||||
'input-field',
|
||||
'select-field',
|
||||
];
|
||||
|
||||
/**
|
||||
* 判断属性是不是 class 或 :class。
|
||||
* 核心逻辑:静态 class 的 key 是 VIdentifier;绑定 class 的 key 是 VDirectiveKey,参数名才是 class。
|
||||
* @param key vue-eslint-parser 的属性键节点
|
||||
* @returns 是 class 绑定则为 true
|
||||
*/
|
||||
function isClassAttribute(key) {
|
||||
if (key?.type === 'VIdentifier') return key.name === 'class';
|
||||
return key?.type === 'VDirectiveKey' && key.argument?.name === 'class';
|
||||
}
|
||||
|
||||
/** @type {import('eslint').Rule.RuleModule} */
|
||||
const rule = {
|
||||
meta: {
|
||||
type: 'problem',
|
||||
docs: {
|
||||
description: '管理端界面使用 Element Plus,不再新增原生控件和旧样式类',
|
||||
},
|
||||
schema: [],
|
||||
messages: {
|
||||
tag: '管理端请使用 Element Plus,不要新增 <{{name}}>。见 docs/ui/ELEMENT_MIGRATION.md。',
|
||||
klass: '管理端请使用 Element Plus,不要新增样式类 {{name}}。见 docs/ui/ELEMENT_MIGRATION.md。',
|
||||
lucide: '管理端按钮图标请使用 @element-plus/icons-vue,不要新增 lucide-vue-next。',
|
||||
},
|
||||
},
|
||||
create(context) {
|
||||
const templateVisitor = {
|
||||
VElement(node) {
|
||||
const name = node.rawName || node.name;
|
||||
if (!LEGACY_TAGS.has(name)) return;
|
||||
context.report({ node, messageId: 'tag', data: { name } });
|
||||
},
|
||||
VAttribute(node) {
|
||||
if (!isClassAttribute(node.key)) return;
|
||||
const raw = context.sourceCode.getText(node);
|
||||
for (const name of LEGACY_CLASSES) {
|
||||
if (!raw.includes(name)) continue;
|
||||
context.report({ node, messageId: 'klass', data: { name } });
|
||||
}
|
||||
},
|
||||
};
|
||||
const scriptVisitor = {
|
||||
ImportDeclaration(node) {
|
||||
if (node.source?.value !== 'lucide-vue-next') return;
|
||||
context.report({ node, messageId: 'lucide' });
|
||||
},
|
||||
};
|
||||
|
||||
// 模板节点不会出现在脚本的遍历里,必须交给 vue-eslint-parser 分开访问。
|
||||
const defineTemplateBodyVisitor = context.sourceCode.parserServices?.defineTemplateBodyVisitor;
|
||||
if (typeof defineTemplateBodyVisitor === 'function') {
|
||||
return defineTemplateBodyVisitor(templateVisitor, scriptVisitor);
|
||||
}
|
||||
return scriptVisitor;
|
||||
},
|
||||
};
|
||||
|
||||
export default rule;
|
||||
@@ -0,0 +1,43 @@
|
||||
/**
|
||||
* frontend/eslint.config.js
|
||||
* 用途:前端 ESLint 配置。目前只挂管理端 Element 迁移规则,且严重级别为 off。
|
||||
* 依赖:vue-eslint-parser、typescript-eslint、eslint-rules/no-legacy-admin-controls.js。
|
||||
* 逻辑:npm run lint 会加载本文件,但不会因为历史原生控件失败。
|
||||
* 启用步骤见 docs/ui/ELEMENT_MIGRATION.md §9。不要把 lint 接进 npm run build。
|
||||
*/
|
||||
import vueParser from 'vue-eslint-parser';
|
||||
import tseslint from 'typescript-eslint';
|
||||
import noLegacyAdminControls from './eslint-rules/no-legacy-admin-controls.js';
|
||||
|
||||
export default [
|
||||
{
|
||||
ignores: ['dist/**', 'node_modules/**', 'coverage/**'],
|
||||
},
|
||||
{
|
||||
files: [
|
||||
'src/features/admin/**/*.vue',
|
||||
'src/features/kb/components/KbAdminPanel.vue',
|
||||
'src/features/kb/components/KbGroupDrawer.vue',
|
||||
],
|
||||
languageOptions: {
|
||||
parser: vueParser,
|
||||
parserOptions: {
|
||||
parser: tseslint.parser,
|
||||
extraFileExtensions: ['.vue'],
|
||||
ecmaVersion: 'latest',
|
||||
sourceType: 'module',
|
||||
},
|
||||
},
|
||||
plugins: {
|
||||
hxops: {
|
||||
rules: {
|
||||
'no-legacy-admin-controls': noLegacyAdminControls,
|
||||
},
|
||||
},
|
||||
},
|
||||
rules: {
|
||||
// 启用时改为 'error'。步骤见 docs/ui/ELEMENT_MIGRATION.md §9。
|
||||
'hxops/no-legacy-admin-controls': 'off',
|
||||
},
|
||||
},
|
||||
];
|
||||
Generated
+1461
-4
File diff suppressed because it is too large.
Load diff
@@ -7,15 +7,18 @@
|
||||
"dev": "vite",
|
||||
"build": "vue-tsc -b && vite build",
|
||||
"preview": "vite preview",
|
||||
"lint": "eslint .",
|
||||
"test:unit": "vitest run"
|
||||
},
|
||||
"dependencies": {
|
||||
"@element-plus/icons-vue": "^2.3.2",
|
||||
"@tailwindcss/forms": "^0.5.11",
|
||||
"@tailwindcss/typography": "^0.5.19",
|
||||
"@vue-office/docx": "^1.6.3",
|
||||
"@vue-office/excel": "^1.7.14",
|
||||
"@vue-office/pdf": "^1.6.5",
|
||||
"cron-parser": "^5.5.0",
|
||||
"element-plus": "^2.14.7",
|
||||
"highlight.js": "^11.11.1",
|
||||
"html2pdf.js": "^0.14.0",
|
||||
"lucide-vue-next": "^0.575.0",
|
||||
@@ -37,12 +40,16 @@
|
||||
"@vue/test-utils": "^2.4.11",
|
||||
"@vue/tsconfig": "^0.8.1",
|
||||
"autoprefixer": "^10.4.24",
|
||||
"eslint": "^10.12.0",
|
||||
"eslint-plugin-vue": "^10.11.1",
|
||||
"jsdom": "^29.1.1",
|
||||
"postcss": "^8.5.6",
|
||||
"tailwindcss": "^3.4.17",
|
||||
"typescript": "~5.9.3",
|
||||
"typescript-eslint": "^8.71.2",
|
||||
"vite": "^8.0.0-beta.13",
|
||||
"vitest": "^4.1.8",
|
||||
"vue-eslint-parser": "^10.4.1",
|
||||
"vue-tsc": "^3.1.5"
|
||||
},
|
||||
"overrides": {
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
/**
|
||||
* features/admin/composables/useElementProvider.ts
|
||||
* 用途:管理端 Element Plus 试点的界面语言。
|
||||
* 依赖:element-plus locale、vue-i18n。
|
||||
* 逻辑:UsersPage、AgentsPage、KbAdminPanel 把 elementLocale 传给 ElConfigProvider;亮暗靠 html.dark 与 Element 暗色变量,不在这里重复切换。
|
||||
*/
|
||||
import { computed } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import zhCn from 'element-plus/es/locale/lang/zh-cn';
|
||||
import zhTw from 'element-plus/es/locale/lang/zh-tw';
|
||||
import en from 'element-plus/es/locale/lang/en';
|
||||
import th from 'element-plus/es/locale/lang/th';
|
||||
|
||||
const ELEMENT_LOCALES = {
|
||||
'zh-CN': zhCn,
|
||||
'zh-TW': zhTw,
|
||||
en,
|
||||
th,
|
||||
} as const;
|
||||
|
||||
/**
|
||||
* 取当前界面语言对应的 Element Plus 语言包。
|
||||
* 核心逻辑:未知语言回退简体中文。
|
||||
* @returns elementLocale,随 vue-i18n 语言变化
|
||||
*/
|
||||
export function useElementProvider() {
|
||||
const { locale } = useI18n();
|
||||
|
||||
const elementLocale = computed(() => {
|
||||
const key = locale.value as keyof typeof ELEMENT_LOCALES;
|
||||
return ELEMENT_LOCALES[key] ?? zhCn;
|
||||
});
|
||||
|
||||
return { elementLocale };
|
||||
}
|
||||
@@ -2,22 +2,35 @@
|
||||
* features/admin/modules/agents/AgentsPage.vue
|
||||
*
|
||||
* 用途:管理控制台的应用管理页,提供应用列表、创建/编辑弹窗、测试与授权入口。
|
||||
* 依赖:useAgentsAdmin 业务编排、AgentFormModal/AgentTestModal/AgentPermissionModal 弹窗。
|
||||
* 逻辑:页面加载后拉取应用/用户/排程数据;权限组启用后隐藏按人授权按钮。
|
||||
* 依赖:useAgentsAdmin 业务编排、Element Plus 表格与按钮、AgentFormModal/AgentTestModal/AgentPermissionModal 弹窗。
|
||||
* 逻辑:页面加载后先展示应用列表;目录、用户和排程在后台补齐。权限组启用后隐藏按人授权按钮。
|
||||
*/
|
||||
<script setup lang="ts">
|
||||
import { computed, ref, onMounted } from 'vue';
|
||||
import { ref, onMounted } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { Bot, Plus, SquarePen, Trash2, Users } from 'lucide-vue-next';
|
||||
import DeleteConfirmDialog from '@/shared/components/DeleteConfirmDialog.vue';
|
||||
import { Plus } from '@element-plus/icons-vue';
|
||||
import {
|
||||
ElButton,
|
||||
ElConfigProvider,
|
||||
ElEmpty,
|
||||
ElLoading,
|
||||
ElTable,
|
||||
ElTableColumn,
|
||||
ElTag,
|
||||
} from 'element-plus';
|
||||
import 'element-plus/dist/index.css';
|
||||
import 'element-plus/theme-chalk/dark/css-vars.css';
|
||||
import '@/features/admin/styles/element-trial.css';
|
||||
import { useElementProvider } from '@/features/admin/composables/useElementProvider';
|
||||
import AgentFormModal from './components/AgentFormModal.vue';
|
||||
import AgentPermissionModal from './components/AgentPermissionModal.vue';
|
||||
import AgentTestModal from './components/AgentTestModal.vue';
|
||||
import { useAgentsAdmin } from './composables/useAgentsAdmin';
|
||||
import { useAgentsTableColumnResize } from './composables/useAgentsTableColumnResize';
|
||||
import type { AgentRow } from '@/features/admin/types/agent.types';
|
||||
|
||||
const { t } = useI18n();
|
||||
const { elementLocale } = useElementProvider();
|
||||
const vLoading = ElLoading.directive;
|
||||
|
||||
const {
|
||||
agents,
|
||||
@@ -44,8 +57,7 @@ const {
|
||||
permissionAgent,
|
||||
permissionUserIds,
|
||||
rolesConfigured,
|
||||
showDeleteConfirmDialog,
|
||||
deleteConfirmMessage,
|
||||
rolesChecked,
|
||||
loadAll,
|
||||
resetForm,
|
||||
selectAgent,
|
||||
@@ -63,23 +75,8 @@ const {
|
||||
openPermissionModal,
|
||||
togglePermissionUser,
|
||||
savePermissions,
|
||||
closeDeleteConfirm,
|
||||
confirmDelete,
|
||||
} = useAgentsAdmin();
|
||||
|
||||
const {
|
||||
columnWidths,
|
||||
tableMinWidth,
|
||||
startColumnResize,
|
||||
resetColumnWidths,
|
||||
} = useAgentsTableColumnResize();
|
||||
|
||||
const tableHeaderColumns = computed(() => [
|
||||
{ key: 'name', label: t('admin.agent.headers.name'), align: 'left' as const },
|
||||
{ key: 'status', label: t('admin.agent.headers.status'), align: 'left' as const },
|
||||
{ key: 'actions', label: t('admin.agent.headers.actions'), align: 'right' as const },
|
||||
]);
|
||||
|
||||
/* 列表仅展示名称、状态和操作;类型/聚合/配置仍由编辑弹窗维护。 */
|
||||
const formatAgentCode = (agent: AgentRow) => agent.agent_code || 'generic';
|
||||
|
||||
@@ -153,6 +150,23 @@ const openEditDialog = (agent: Parameters<typeof selectAgent>[0]): void => {
|
||||
showFormDialog.value = true;
|
||||
};
|
||||
|
||||
/**
|
||||
* 点击表格行时打开编辑弹窗。
|
||||
* 核心逻辑:Element 行对象按 id 找回完整应用,避免把表格行类型直接交给 selectAgent。
|
||||
*/
|
||||
const onRowClick = (row: { id?: number }): void => {
|
||||
const agent = agents.value.find((item) => item.id === row.id);
|
||||
if (agent) openEditDialog(agent);
|
||||
};
|
||||
|
||||
/**
|
||||
* 当前选中应用的行样式。
|
||||
* 核心逻辑:编辑弹窗打开前,用 selectedAgentId 给对应行加上浅底。
|
||||
*/
|
||||
const agentRowClass = ({ row }: { row: AgentRow }): string => (
|
||||
selectedAgentId.value === row.id ? 'agents-row-selected' : ''
|
||||
);
|
||||
|
||||
/**
|
||||
* 保存应用表单,成功后关闭弹窗。
|
||||
* 核心逻辑:submitAgent 会处理校验、接口调用和列表刷新;仅在返回 true 时收起弹窗。
|
||||
@@ -168,134 +182,73 @@ onMounted(() => {
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<section class="admin-table-section">
|
||||
<div v-if="isLoading" class="flex items-center justify-center py-20">
|
||||
<div class="animate-spin rounded-full h-10 w-10 border-b-2 border-brand-600" />
|
||||
<ElConfigProvider :locale="elementLocale">
|
||||
<section class="admin-table-section min-h-64">
|
||||
<div class="admin-table-header admin-table-header--stacked">
|
||||
<div>
|
||||
<h2 class="section-title">{{ t('admin.agent.title') }}</h2>
|
||||
<p class="section-desc mt-1">{{ t('admin.agent.subtitle') }}</p>
|
||||
</div>
|
||||
<ElButton type="primary" :icon="Plus" @click="openCreateDialog">
|
||||
{{ t('admin.agent.new') }}
|
||||
</ElButton>
|
||||
</div>
|
||||
|
||||
<template v-else>
|
||||
<div class="admin-table-header admin-table-header--stacked">
|
||||
<div>
|
||||
<h2 class="section-title">{{ t('admin.agent.title') }}</h2>
|
||||
<p class="section-desc mt-1">{{ t('admin.agent.subtitle') }}</p>
|
||||
</div>
|
||||
<button type="button" class="btn-primary" @click="openCreateDialog">
|
||||
<Plus class="w-5 h-5" />
|
||||
<span class="font-medium">{{ t('admin.agent.new') }}</span>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="admin-table-wrap">
|
||||
<div v-if="agents.length === 0" class="admin-table-empty">
|
||||
<Bot class="w-12 h-12 mx-auto text-muted mb-3" />
|
||||
<p class="text-lg text-secondary">{{ t('admin.agent.noAgents') }}</p>
|
||||
</div>
|
||||
<table
|
||||
v-else
|
||||
class="admin-table agent-list-table table-fixed w-full"
|
||||
:style="{ minWidth: `${tableMinWidth}px` }"
|
||||
>
|
||||
<colgroup>
|
||||
<col
|
||||
v-for="(width, index) in columnWidths"
|
||||
:key="`col-${index}`"
|
||||
:style="{ width: `${width}px` }"
|
||||
/>
|
||||
</colgroup>
|
||||
<thead>
|
||||
<tr>
|
||||
<th
|
||||
v-for="(column, index) in tableHeaderColumns"
|
||||
:key="column.key"
|
||||
class="relative px-4 py-3 text-xs"
|
||||
:class="column.align === 'right' ? 'text-right' : 'text-left'"
|
||||
>
|
||||
<span class="truncate pr-2">{{ column.label }}</span>
|
||||
<button
|
||||
v-if="index < tableHeaderColumns.length - 1"
|
||||
type="button"
|
||||
class="agent-col-resize-handle"
|
||||
:title="t('admin.agent.resizeColumn')"
|
||||
@mousedown.prevent="startColumnResize(index, $event)"
|
||||
@dblclick.prevent="resetColumnWidths"
|
||||
/>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr
|
||||
v-for="agent in agents"
|
||||
:key="agent.id"
|
||||
class="group cursor-pointer"
|
||||
:class="{ 'bg-blue-50/50': selectedAgentId === agent.id }"
|
||||
@click="openEditDialog(agent)"
|
||||
<ElEmpty v-if="!isLoading && agents.length === 0" :description="t('admin.agent.noAgents')" />
|
||||
<ElTable
|
||||
v-else
|
||||
v-loading="isLoading"
|
||||
:data="agents"
|
||||
row-key="id"
|
||||
class="agents-element-table hx-admin-table"
|
||||
:row-class-name="agentRowClass"
|
||||
@row-click="onRowClick"
|
||||
>
|
||||
<ElTableColumn :label="t('admin.agent.headers.name')" min-width="280">
|
||||
<template #default="{ row }">
|
||||
<p class="truncate" :title="(row as AgentRow).name">
|
||||
{{ (row as AgentRow).name }}
|
||||
</p>
|
||||
<p
|
||||
v-if="(row as AgentRow).description"
|
||||
class="truncate hx-element-hint"
|
||||
:title="(row as AgentRow).description"
|
||||
>
|
||||
{{ (row as AgentRow).description }}
|
||||
</p>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn :label="t('admin.agent.headers.status')" width="140">
|
||||
<template #default="{ row }">
|
||||
<ElTag :type="(row as AgentRow).is_active ? 'success' : 'info'" effect="light">
|
||||
{{ (row as AgentRow).is_active ? t('admin.status.active') : t('admin.status.disabled') }}
|
||||
</ElTag>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn :label="t('admin.agent.headers.actions')" min-width="280" align="right">
|
||||
<template #default="{ row }">
|
||||
<div class="inline-flex items-center justify-end" @click.stop>
|
||||
<ElButton link type="primary" @click="openEditDialog(row as AgentRow)">
|
||||
{{ t('admin.edit') }}
|
||||
</ElButton>
|
||||
<ElButton
|
||||
v-if="rolesChecked && !rolesConfigured"
|
||||
link
|
||||
type="primary"
|
||||
@click="openPermissionModal(row as AgentRow)"
|
||||
>
|
||||
<td class="px-4 py-4 align-middle">
|
||||
<div class="agent-list-cell">
|
||||
<p class="truncate text-sm font-semibold text-primary" :title="agent.name">{{ agent.name }}</p>
|
||||
<p
|
||||
v-if="agent.description"
|
||||
class="truncate text-xs text-muted"
|
||||
:title="agent.description"
|
||||
>
|
||||
{{ agent.description }}
|
||||
</p>
|
||||
</div>
|
||||
</td>
|
||||
<td class="px-4 py-4 align-middle">
|
||||
<div class="agent-list-cell">
|
||||
<span
|
||||
class="inline-flex w-fit items-center gap-1.5 rounded-full border px-2.5 py-0.5 text-xs font-medium"
|
||||
:class="agent.is_active ? 'border-green-100 bg-green-50 text-green-700' : 'border-default bg-surface-soft text-secondary'"
|
||||
>
|
||||
<span class="h-1.5 w-1.5 shrink-0 rounded-full" :class="agent.is_active ? 'bg-green-500' : 'bg-surface-strong'" />
|
||||
{{ agent.is_active ? t('admin.status.active') : t('admin.status.disabled') }}
|
||||
</span>
|
||||
</div>
|
||||
</td>
|
||||
<td class="px-4 py-4 align-middle text-right">
|
||||
<div class="inline-flex items-center justify-end gap-2">
|
||||
<button
|
||||
type="button"
|
||||
class="inline-flex shrink-0 items-center gap-1.5 whitespace-nowrap rounded-lg bg-blue-50 px-3 py-2 text-sm font-medium text-blue-600 transition-all hover:bg-blue-100"
|
||||
:title="t('admin.edit')"
|
||||
@click.stop="openEditDialog(agent)"
|
||||
>
|
||||
<SquarePen class="w-4 h-4 shrink-0" />
|
||||
{{ t('admin.edit') }}
|
||||
</button>
|
||||
<button
|
||||
v-if="!rolesConfigured"
|
||||
type="button"
|
||||
class="inline-flex shrink-0 items-center justify-center p-2 text-blue-600 bg-blue-50 hover:bg-blue-100 rounded-lg transition-all"
|
||||
:title="t('admin.agent.manageAccess')"
|
||||
@click.stop="openPermissionModal(agent)"
|
||||
>
|
||||
<Users class="w-5 h-5 shrink-0" />
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="inline-flex shrink-0 items-center whitespace-nowrap p-2 text-emerald-600 bg-emerald-50 hover:bg-emerald-100 rounded-lg transition-all"
|
||||
:title="t('admin.agent.test')"
|
||||
@click.stop="openTestModal(agent)"
|
||||
>
|
||||
{{ t('admin.agent.test') }}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="inline-flex shrink-0 items-center justify-center p-2 text-muted hover:text-red-600 hover:bg-red-50 rounded-lg transition-all"
|
||||
:title="t('admin.agent.delete')"
|
||||
@click.stop="deleteAgent(agent.id)"
|
||||
>
|
||||
<Trash2 class="w-5 h-5 shrink-0" />
|
||||
</button>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</template>
|
||||
{{ t('admin.agent.manageAccess') }}
|
||||
</ElButton>
|
||||
<ElButton link type="primary" @click="openTestModal(row as AgentRow)">
|
||||
{{ t('admin.agent.test') }}
|
||||
</ElButton>
|
||||
<ElButton link type="danger" @click="deleteAgent((row as AgentRow).id)">
|
||||
{{ t('admin.agent.delete') }}
|
||||
</ElButton>
|
||||
</div>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
</ElTable>
|
||||
|
||||
<AgentTestModal
|
||||
:visible="showTestModal"
|
||||
@@ -342,45 +295,16 @@ onMounted(() => {
|
||||
@save="savePermissions"
|
||||
@toggle-user="togglePermissionUser"
|
||||
/>
|
||||
|
||||
<DeleteConfirmDialog
|
||||
v-model="showDeleteConfirmDialog"
|
||||
:message="deleteConfirmMessage"
|
||||
@confirm="confirmDelete"
|
||||
@cancel="closeDeleteConfirm"
|
||||
/>
|
||||
</section>
|
||||
</ElConfigProvider>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.agent-list-table {
|
||||
table-layout: fixed;
|
||||
.agents-element-table :deep(.agents-row-selected) {
|
||||
--el-table-tr-bg-color: color-mix(in srgb, #0284c7 8%, transparent);
|
||||
}
|
||||
|
||||
.agent-list-cell {
|
||||
display: flex;
|
||||
min-height: 2.5rem;
|
||||
min-width: 0;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
gap: 0.125rem;
|
||||
}
|
||||
|
||||
.agent-col-resize-handle {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
right: 0;
|
||||
z-index: 1;
|
||||
width: 8px;
|
||||
height: 100%;
|
||||
cursor: col-resize;
|
||||
border: none;
|
||||
background: transparent;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.agent-col-resize-handle:hover,
|
||||
.agent-col-resize-handle:active {
|
||||
background-color: color-mix(in srgb, var(--border-default) 65%, transparent);
|
||||
.agents-element-table :deep(.el-table__row) {
|
||||
cursor: pointer;
|
||||
}
|
||||
</style>
|
||||
@@ -2,14 +2,15 @@
|
||||
* features/admin/modules/agents/components/AgentFormModal.vue
|
||||
*
|
||||
* 用途:应用管理新增/编辑弹窗,集中承载 Agent 基础信息(含启用状态)、Dify/Iframe 配置和常见问题表单。
|
||||
* 依赖:agent.types AgentFormState、schedule.types ScheduleTask、AgentToolRunProgressConfig、vue-i18n。
|
||||
* 逻辑:父组件控制 visible/isEditing/isSaving 与保存;本组件直接编辑传入的 form(含 is_active),并通过事件通知关闭、保存、增删常见问题。
|
||||
* 依赖:element-plus 对话框、agent.types AgentFormState、schedule.types ScheduleTask、AgentToolRunProgressConfig、vue-i18n。
|
||||
* 逻辑:父组件控制 visible/isEditing/isSaving 与保存;外壳是 680px 对话框。表单内部字段仍沿用原有输入控件。
|
||||
*/
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed, ref, watch } from 'vue';
|
||||
import { ChevronDown, FileDown, FolderTree, Plus, Search, Trash2, X } from 'lucide-vue-next';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { ElButton, ElDialog } from 'element-plus';
|
||||
import type { AgentFormState, AgentGuideSummary, AgentRow } from '@/features/admin/types/agent.types';
|
||||
import type { ScheduleTask } from '@/shared/types/schedule.types';
|
||||
import type { AgentTypeCatalogEntry, IntentRouteOption } from '../composables/useAgentsAdminRegistry';
|
||||
@@ -252,22 +253,28 @@ const handleTrainingQuestionTypeChange = (form: AgentFormState, index: number) =
|
||||
.map((_, optionIndex) => String.fromCharCode(97 + optionIndex));
|
||||
question.answer = validAnswerIds.includes(question.answer) ? question.answer : (validAnswerIds[0] || 'a');
|
||||
};
|
||||
|
||||
/**
|
||||
* 关闭应用编辑弹窗。
|
||||
* @param open - 对话框是否仍打开
|
||||
*/
|
||||
function onVisibleChange(open: boolean): void {
|
||||
if (!open) emit('close');
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div v-if="visible" class="fixed inset-0 z-50 flex items-center justify-center bg-black/40 px-4 py-6 backdrop-blur-sm">
|
||||
<div class="flex max-h-[92vh] w-full max-w-5xl flex-col overflow-hidden rounded-2xl border border-default bg-surface shadow-2xl">
|
||||
<div class="flex items-start justify-between gap-4 border-b border-default px-6 py-5">
|
||||
<div>
|
||||
<h3 class="section-title">{{ isEditing ? t('admin.agent.edit') : t('admin.agent.create') }}</h3>
|
||||
<p class="section-desc mt-1">{{ t('admin.agent.subtitle') }}</p>
|
||||
</div>
|
||||
<button type="button" class="btn-icon-ds shrink-0" @click="emit('close')">
|
||||
<X class="h-5 w-5" />
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="overflow-y-auto px-6 py-6">
|
||||
<ElDialog
|
||||
:model-value="visible"
|
||||
:title="isEditing ? t('admin.agent.edit') : t('admin.agent.create')"
|
||||
width="680px"
|
||||
align-center
|
||||
append-to-body
|
||||
:close-on-click-modal="false"
|
||||
@update:model-value="onVisibleChange"
|
||||
>
|
||||
<p class="section-desc">{{ t('admin.agent.subtitle') }}</p>
|
||||
<div class="agent-form-body">
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 gap-6">
|
||||
<div class="space-y-2">
|
||||
<label class="text-xs font-bold text-muted uppercase tracking-wider">{{ t('admin.agent.fields.name') }}</label>
|
||||
@@ -890,17 +897,20 @@ const handleTrainingQuestionTypeChange = (form: AgentFormState, index: number) =
|
||||
:requires-schedule-task="requiresScheduleTask"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="flex flex-col-reverse gap-3 border-t border-default px-6 py-4 sm:flex-row sm:items-center sm:justify-end">
|
||||
<button type="button" class="btn-secondary" @click="emit('close')">
|
||||
{{ t('admin.cancel') }}
|
||||
</button>
|
||||
<button type="button" class="btn-primary btn-lg disabled:opacity-60" :disabled="isSaving" @click="emit('save')">
|
||||
<Plus v-if="!isEditing" class="w-5 h-5" />
|
||||
{{ isEditing ? t('admin.update') : t('admin.add') }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<template #footer>
|
||||
<ElButton @click="emit('close')">{{ t('admin.cancel') }}</ElButton>
|
||||
<ElButton type="primary" :loading="isSaving" @click="emit('save')">
|
||||
{{ isEditing ? t('admin.update') : t('admin.add') }}
|
||||
</ElButton>
|
||||
</template>
|
||||
</ElDialog>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.agent-form-body {
|
||||
max-height: 65vh;
|
||||
margin-top: 12px;
|
||||
overflow-y: auto;
|
||||
}
|
||||
</style>
|
||||
@@ -1,11 +1,12 @@
|
||||
/**
|
||||
* features/admin/modules/agents/components/AgentPermissionModal.vue
|
||||
*
|
||||
* 为指定 Agent 批量勾选可访问用户的权限弹窗。
|
||||
* 用途:为指定应用勾选可访问用户。
|
||||
* 依赖:element-plus、admin.types、agent.types。
|
||||
* 逻辑:AgentsPage 传入用户和已选 id;勾选变化交给父组件 togglePermissionUser。
|
||||
*/
|
||||
|
||||
<script setup lang="ts">
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { ElButton, ElCheckbox, ElDialog } from 'element-plus';
|
||||
import type { AdminUserRow } from '@/features/admin/types/admin.types';
|
||||
import type { AgentRow } from '@/features/admin/types/agent.types';
|
||||
|
||||
@@ -24,71 +25,68 @@ const emit = defineEmits<{
|
||||
}>();
|
||||
|
||||
const { t } = useI18n();
|
||||
|
||||
/**
|
||||
* 关闭弹窗。点遮罩或右上角关闭时 Element 会把打开状态写成 false。
|
||||
* @param open - 对话框是否仍打开
|
||||
*/
|
||||
function onVisibleChange(open: boolean): void {
|
||||
if (!open) emit('close');
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div v-if="visible && agent" class="admin-modal-overlay items-center">
|
||||
<div class="admin-modal-panel max-w-2xl max-h-[90vh] animate-fade-in-up">
|
||||
<div class="px-8 py-6 border-b border-subtle flex justify-between items-center">
|
||||
<div>
|
||||
<h3 class="text-lg font-bold text-primary">{{ t('admin.perm.agentModal.title') }}</h3>
|
||||
<p class="text-sm text-muted">
|
||||
{{ t('admin.perm.agentModal.agent') }}
|
||||
<span class="font-medium text-blue-600">{{ agent.name }}</span>
|
||||
</p>
|
||||
</div>
|
||||
<button type="button" class="btn-icon-ds rounded-full" @click="emit('close')">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12" />
|
||||
</svg>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="flex-1 overflow-y-auto p-8">
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
|
||||
<div
|
||||
v-for="user in users"
|
||||
:key="user.id"
|
||||
class="flex items-center gap-3 p-3 rounded-xl border transition-all cursor-pointer"
|
||||
:class="selectedUserIds.includes(user.id) ? 'border-blue-200 bg-blue-50/50' : 'border-default hover-surface-soft'"
|
||||
@click="emit('toggleUser', user.id)"
|
||||
>
|
||||
<div
|
||||
class="w-5 h-5 rounded border flex items-center justify-center transition-colors"
|
||||
:class="selectedUserIds.includes(user.id) ? 'bg-blue-600 border-blue-600' : 'bg-surface border-default'"
|
||||
>
|
||||
<svg
|
||||
v-if="selectedUserIds.includes(user.id)"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
class="h-3.5 w-3.5 text-white"
|
||||
viewBox="0 0 20 20"
|
||||
fill="currentColor"
|
||||
>
|
||||
<path fill-rule="evenodd" d="M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z" clip-rule="evenodd" />
|
||||
</svg>
|
||||
</div>
|
||||
<div>
|
||||
<div class="font-medium text-primary text-sm">{{ user.username }}</div>
|
||||
<div class="text-xs text-muted">{{ user.real_name || user.email }}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="admin-modal-footer admin-modal-footer--muted px-8 py-6">
|
||||
<button type="button" class="btn-ghost" @click="emit('close')">
|
||||
{{ t('admin.cancel') }}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
:disabled="isSaving"
|
||||
class="btn-primary disabled:opacity-50 disabled:cursor-not-allowed"
|
||||
@click="emit('save')"
|
||||
<ElDialog
|
||||
:model-value="visible && !!agent"
|
||||
:title="t('admin.perm.agentModal.title')"
|
||||
width="680px"
|
||||
align-center
|
||||
append-to-body
|
||||
:close-on-click-modal="false"
|
||||
@update:model-value="onVisibleChange"
|
||||
>
|
||||
<template v-if="agent">
|
||||
<p class="section-desc">{{ t('admin.perm.agentModal.agent') }}{{ agent.name }}</p>
|
||||
<div class="agent-perm-list">
|
||||
<ElCheckbox
|
||||
v-for="user in users"
|
||||
:key="user.id"
|
||||
:model-value="selectedUserIds.includes(user.id)"
|
||||
@change="emit('toggleUser', user.id)"
|
||||
>
|
||||
<div v-if="isSaving" class="animate-spin rounded-full h-4 w-4 border-2 border-white border-t-transparent" />
|
||||
{{ t('admin.perm.agentModal.save') }}
|
||||
</button>
|
||||
<span>{{ user.username }}</span>
|
||||
<span class="hx-element-hint">{{ user.real_name || user.email }}</span>
|
||||
</ElCheckbox>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<template #footer>
|
||||
<ElButton @click="emit('close')">{{ t('admin.cancel') }}</ElButton>
|
||||
<ElButton type="primary" :loading="isSaving" @click="emit('save')">
|
||||
{{ t('admin.perm.agentModal.save') }}
|
||||
</ElButton>
|
||||
</template>
|
||||
</ElDialog>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.agent-perm-list {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr;
|
||||
gap: 8px 16px;
|
||||
max-height: 65vh;
|
||||
margin-top: 12px;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.agent-perm-list :deep(.el-checkbox) {
|
||||
align-items: flex-start;
|
||||
height: auto;
|
||||
margin-right: 0;
|
||||
}
|
||||
|
||||
@media (max-width: 640px) {
|
||||
.agent-perm-list {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -1,11 +1,12 @@
|
||||
/**
|
||||
* features/admin/modules/agents/components/AgentTestModal.vue
|
||||
*
|
||||
* Agent 连通性测试弹窗:展示请求 URL、输出信息与分析结果。
|
||||
* 用途:应用连通性测试弹窗,展示请求地址、输出和分析结果。
|
||||
* 依赖:element-plus、agent.types。
|
||||
* 逻辑:AgentsPage 传入当前应用和测试结果;重新测试由父组件发起。
|
||||
*/
|
||||
|
||||
<script setup lang="ts">
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { ElButton, ElDialog } from 'element-plus';
|
||||
import type { AgentRow, AgentTestResult } from '@/features/admin/types/agent.types';
|
||||
|
||||
defineProps<{
|
||||
@@ -21,62 +22,98 @@ const emit = defineEmits<{
|
||||
}>();
|
||||
|
||||
const { t } = useI18n();
|
||||
|
||||
/**
|
||||
* 关闭弹窗。点遮罩或右上角关闭时 Element 会把打开状态写成 false。
|
||||
* @param open - 对话框是否仍打开
|
||||
*/
|
||||
function onVisibleChange(open: boolean): void {
|
||||
if (!open) emit('close');
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div v-if="visible && agent" class="admin-modal-overlay items-center">
|
||||
<div class="admin-modal-panel max-w-3xl max-h-[90vh] animate-fade-in-up">
|
||||
<div class="px-8 py-6 border-b border-subtle flex justify-between items-start">
|
||||
<div>
|
||||
<h3 class="text-lg font-bold text-primary">{{ t('admin.agent.testModalTitle') }}</h3>
|
||||
<p class="section-desc mt-1">
|
||||
{{ t('admin.agent.testModalAgent') }}:
|
||||
<span class="font-medium text-blue-600">{{ agent.name }}</span>
|
||||
</p>
|
||||
<ElDialog
|
||||
:model-value="visible && !!agent"
|
||||
:title="t('admin.agent.testModalTitle')"
|
||||
width="680px"
|
||||
align-center
|
||||
append-to-body
|
||||
:close-on-click-modal="false"
|
||||
@update:model-value="onVisibleChange"
|
||||
>
|
||||
<template v-if="agent">
|
||||
<p class="section-desc">
|
||||
{{ t('admin.agent.testModalAgent') }}:{{ agent.name }}
|
||||
</p>
|
||||
<div class="agent-test-body">
|
||||
<div class="agent-test-toolbar">
|
||||
<span v-if="result?.tested_at" class="hx-element-hint">{{ t('admin.agent.testedAt') }}:{{ result.tested_at }}</span>
|
||||
<ElButton type="primary" :loading="isTesting" @click="emit('retest')">
|
||||
{{ t('admin.agent.retest') }}
|
||||
</ElButton>
|
||||
</div>
|
||||
<button type="button" class="btn-icon-ds rounded-full" @click="emit('close')">✕</button>
|
||||
</div>
|
||||
|
||||
<div class="flex-1 overflow-y-auto p-8 space-y-5">
|
||||
<div class="flex items-center justify-between">
|
||||
<div class="text-sm text-secondary">
|
||||
<span v-if="result?.tested_at">{{ t('admin.agent.testedAt') }}:{{ result.tested_at }}</span>
|
||||
</div>
|
||||
<button
|
||||
type="button"
|
||||
:disabled="isTesting"
|
||||
class="btn-primary btn-sm disabled:opacity-50"
|
||||
@click="emit('retest')"
|
||||
>
|
||||
{{ isTesting ? t('admin.agent.testing') : t('admin.agent.retest') }}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div v-if="isTesting" class="text-sm text-muted">{{ t('admin.agent.testingInProgress') }}</div>
|
||||
|
||||
<p v-if="isTesting" class="hx-element-hint">{{ t('admin.agent.testingInProgress') }}</p>
|
||||
<template v-if="result">
|
||||
<div>
|
||||
<div class="text-xs font-semibold text-muted uppercase tracking-wider mb-2">{{ t('admin.agent.requestUrl') }}</div>
|
||||
<div class="hx-element-hint">{{ t('admin.agent.requestUrl') }}</div>
|
||||
<div class="admin-code-block">{{ result.request_url || '-' }}</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<div class="text-xs font-semibold text-muted uppercase tracking-wider mb-2">{{ t('admin.agent.outputInfo') }}</div>
|
||||
<pre class="admin-code-block max-h-64 overflow-y-auto whitespace-pre-wrap">{{ result.output_info || '-' }}</pre>
|
||||
<div class="hx-element-hint">{{ t('admin.agent.outputInfo') }}</div>
|
||||
<pre class="admin-code-block agent-test-output">{{ result.output_info || '-' }}</pre>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<div class="text-xs font-semibold text-muted uppercase tracking-wider mb-2">{{ t('admin.agent.analysis') }}</div>
|
||||
<div
|
||||
class="p-3 rounded-lg border text-sm"
|
||||
:class="result.success ? 'bg-green-50 border-green-200 text-green-800' : 'bg-red-50 border-red-200 text-red-800'"
|
||||
>
|
||||
<div class="hx-element-hint">{{ t('admin.agent.analysis') }}</div>
|
||||
<div class="agent-test-analysis" :class="result.success ? 'is-ok' : 'is-fail'">
|
||||
{{ result.analysis }}
|
||||
<span v-if="result.http_status">(HTTP {{ result.http_status }})</span>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</ElDialog>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.agent-test-body {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 16px;
|
||||
max-height: 65vh;
|
||||
margin-top: 12px;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.agent-test-toolbar {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.agent-test-output {
|
||||
max-height: 16rem;
|
||||
overflow-y: auto;
|
||||
white-space: pre-wrap;
|
||||
}
|
||||
|
||||
.agent-test-analysis {
|
||||
padding: 12px;
|
||||
border: 1px solid var(--el-border-color);
|
||||
border-radius: var(--el-border-radius-base);
|
||||
}
|
||||
|
||||
.agent-test-analysis.is-ok {
|
||||
color: var(--el-color-success);
|
||||
border-color: var(--el-color-success-light-5);
|
||||
background: var(--el-color-success-light-9);
|
||||
}
|
||||
|
||||
.agent-test-analysis.is-fail {
|
||||
color: var(--el-color-danger);
|
||||
border-color: var(--el-color-danger-light-5);
|
||||
background: var(--el-color-danger-light-9);
|
||||
}
|
||||
</style>
|
||||
@@ -4,10 +4,12 @@
|
||||
* Agent 管理模块的业务逻辑:列表 CRUD、连通性测试、权限分配。
|
||||
* 从原 AdminView.vue 的 agents 相关 script 抽取,供 AgentsPage 使用。
|
||||
* 权限组启用后拒绝打开按人授权弹窗,提示改到应用权限页的角色包。
|
||||
* 删除确认使用 Element MessageBox。
|
||||
*/
|
||||
|
||||
import { ref, computed } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { ElMessageBox } from 'element-plus';
|
||||
import {
|
||||
createAdminAgent,
|
||||
deleteAdminAgent,
|
||||
@@ -238,6 +240,7 @@ export function useAgentsAdmin() {
|
||||
const contentProfileOptions = ref<AdminContentProfileOption[]>([]);
|
||||
const users = ref<AdminUserRow[]>([]);
|
||||
const rolesConfigured = ref(false);
|
||||
const rolesChecked = ref(false);
|
||||
const scheduleTasks = ref<ScheduleTask[]>([]);
|
||||
const trainingExamPdfGuides = ref<AgentGuideSummary[]>([]);
|
||||
const isLoading = ref(true);
|
||||
@@ -256,9 +259,6 @@ export function useAgentsAdmin() {
|
||||
const permissionAgent = ref<AgentRow | null>(null);
|
||||
const permissionUserIds = ref<number[]>([]);
|
||||
|
||||
const showDeleteConfirmDialog = ref(false);
|
||||
const deleteConfirmMessage = ref('');
|
||||
let deleteConfirmAction: (() => Promise<void> | void) | null = null;
|
||||
|
||||
const activeUsers = () => users.value.filter((u) => u.status !== 'pending');
|
||||
|
||||
@@ -336,6 +336,8 @@ export function useAgentsAdmin() {
|
||||
} catch (e) {
|
||||
console.error('Error loading permission roles:', e);
|
||||
rolesConfigured.value = false;
|
||||
} finally {
|
||||
rolesChecked.value = true;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -364,18 +366,25 @@ export function useAgentsAdmin() {
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* 进入页面时先拉应用列表,再在后台补齐编辑弹窗要用的目录、用户和排程。
|
||||
* 核心逻辑:加载遮罩只等应用列表。权限组、用户、排程和目录在后台拉取,未返回时不盖住表格。
|
||||
*/
|
||||
const loadAll = async (): Promise<void> => {
|
||||
isLoading.value = true;
|
||||
await Promise.all([
|
||||
try {
|
||||
await loadAgents();
|
||||
} finally {
|
||||
isLoading.value = false;
|
||||
}
|
||||
void Promise.all([
|
||||
loadRegistrySchema(),
|
||||
loadIntentRouteOptions(),
|
||||
loadContentProfileOptions(),
|
||||
loadAgents(),
|
||||
loadUsers(),
|
||||
loadRolesConfigured(),
|
||||
loadScheduleTasks(),
|
||||
]);
|
||||
isLoading.value = false;
|
||||
};
|
||||
|
||||
const resetForm = (): void => {
|
||||
@@ -405,27 +414,26 @@ export function useAgentsAdmin() {
|
||||
void loadTrainingExamPdfGuides(agent.id);
|
||||
};
|
||||
|
||||
const openDeleteConfirm = (
|
||||
/**
|
||||
* 用 Element 确认框询问后再执行删除。
|
||||
* 核心逻辑:取消时 MessageBox 会 reject,这里吞掉,不调用 action。
|
||||
* @param message - 确认文案
|
||||
* @param action - 用户点确定后执行的删除
|
||||
*/
|
||||
const openDeleteConfirm = async (
|
||||
message: string,
|
||||
action: () => Promise<void> | void,
|
||||
): void => {
|
||||
deleteConfirmMessage.value = message;
|
||||
deleteConfirmAction = action;
|
||||
showDeleteConfirmDialog.value = true;
|
||||
};
|
||||
|
||||
const closeDeleteConfirm = (): void => {
|
||||
showDeleteConfirmDialog.value = false;
|
||||
deleteConfirmAction = null;
|
||||
};
|
||||
|
||||
const confirmDelete = async (): Promise<void> => {
|
||||
if (!deleteConfirmAction) return;
|
||||
): Promise<void> => {
|
||||
try {
|
||||
await deleteConfirmAction();
|
||||
} finally {
|
||||
closeDeleteConfirm();
|
||||
await ElMessageBox.confirm(message, t('common.deleteDialog.defaultTitle'), {
|
||||
type: 'warning',
|
||||
confirmButtonText: t('common.deleteDialog.confirm'),
|
||||
cancelButtonText: t('common.deleteDialog.cancel'),
|
||||
});
|
||||
} catch {
|
||||
return;
|
||||
}
|
||||
await action();
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -613,7 +621,7 @@ export function useAgentsAdmin() {
|
||||
};
|
||||
|
||||
const deleteAgent = async (id: number): Promise<void> => {
|
||||
openDeleteConfirm(t('admin.agent.confirmDelete'), async () => {
|
||||
await openDeleteConfirm(t('admin.agent.confirmDelete'), async () => {
|
||||
try {
|
||||
await deleteAdminAgent(id);
|
||||
await loadAgents();
|
||||
@@ -723,6 +731,7 @@ export function useAgentsAdmin() {
|
||||
contentProfileOptions,
|
||||
users,
|
||||
rolesConfigured,
|
||||
rolesChecked,
|
||||
scheduleTasks,
|
||||
trainingExamPdfGuides,
|
||||
activeUsers,
|
||||
@@ -739,8 +748,6 @@ export function useAgentsAdmin() {
|
||||
showPermissionModal,
|
||||
permissionAgent,
|
||||
permissionUserIds,
|
||||
showDeleteConfirmDialog,
|
||||
deleteConfirmMessage,
|
||||
loadAll,
|
||||
resetForm,
|
||||
selectAgent,
|
||||
@@ -758,7 +765,5 @@ export function useAgentsAdmin() {
|
||||
openPermissionModal,
|
||||
togglePermissionUser,
|
||||
savePermissions,
|
||||
closeDeleteConfirm,
|
||||
confirmDelete,
|
||||
};
|
||||
}
|
||||
@@ -1,24 +1,43 @@
|
||||
/**
|
||||
* features/admin/modules/users/UsersPage.vue
|
||||
* 用途:用户管理独立页面(服务端筛选分页、用户/部门列排序、批量操作)。
|
||||
* 依赖:useUsersAdmin、SortableTableHeader、PaginationBar、用户相关 Modal、adminRoleLabel、getUserAvatarLabel。
|
||||
* 逻辑:路由 /admin/users;列表经 listAdminUsersPage 按页拉取;权限组启用后只选角色、关闭按人授权。
|
||||
* 依赖:useUsersAdmin、useElementProvider、element-plus、用户相关 Modal、adminRoleLabel、getUserAvatarLabel。
|
||||
* 逻辑:路由 /admin/users;本页是 Element Plus 试点,筛选、表格、分页、工具栏和三个业务弹窗走组件库。
|
||||
* 删除和改角色用 Element 确认框。列表经 listAdminUsersPage 按页拉取。
|
||||
*/
|
||||
<script setup lang="ts">
|
||||
import { onMounted } from 'vue';
|
||||
import { computed, onMounted } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { Edit, Plus, Trash2, Users } from 'lucide-vue-next';
|
||||
import DeleteConfirmDialog from '@/shared/components/DeleteConfirmDialog.vue';
|
||||
import PaginationBar from '@/shared/components/PaginationBar.vue';
|
||||
import SortableTableHeader from '@/shared/components/SortableTableHeader.vue';
|
||||
import { Delete, Edit, Plus, User } from '@element-plus/icons-vue';
|
||||
import {
|
||||
ElButton,
|
||||
ElConfigProvider,
|
||||
ElInput,
|
||||
ElLoading,
|
||||
ElOption,
|
||||
ElPagination,
|
||||
ElSelect,
|
||||
ElSpace,
|
||||
ElTable,
|
||||
ElTableColumn,
|
||||
ElTag,
|
||||
} from 'element-plus';
|
||||
import 'element-plus/dist/index.css';
|
||||
import 'element-plus/theme-chalk/dark/css-vars.css';
|
||||
import '@/features/admin/styles/element-trial.css';
|
||||
import { adminRoleLabel } from '@/features/admin/utils/roleLabel';
|
||||
import { getUserAvatarLabel } from '@/shared/utils/user-avatar';
|
||||
import type { AdminUserRow } from '@/features/admin/types/admin.types';
|
||||
import { useElementProvider } from '@/features/admin/composables/useElementProvider';
|
||||
import BatchEditUserModal from './components/BatchEditUserModal.vue';
|
||||
import BatchPermissionModal from './components/BatchPermissionModal.vue';
|
||||
import UserFormModal from './components/UserFormModal.vue';
|
||||
import { useUsersAdmin } from './composables/useUsersAdmin';
|
||||
|
||||
const vLoading = ElLoading.directive;
|
||||
|
||||
const { t } = useI18n();
|
||||
const { elementLocale } = useElementProvider();
|
||||
|
||||
const {
|
||||
agents,
|
||||
@@ -31,290 +50,273 @@ const {
|
||||
userFilters,
|
||||
sortKey,
|
||||
sortDir,
|
||||
// hideRejected,
|
||||
selectedUserIds,
|
||||
users,
|
||||
usersTotal,
|
||||
userPage,
|
||||
userPageSize,
|
||||
userPageSizeOptions,
|
||||
usersPages,
|
||||
allPaginatedUsersSelected,
|
||||
showUserModal,
|
||||
editingUser,
|
||||
showBatchEditModal,
|
||||
batchEditForm,
|
||||
showBatchPermissionModal,
|
||||
batchPermissionForm,
|
||||
showDeleteConfirmDialog,
|
||||
deleteConfirmMessage,
|
||||
showRoleConfirm,
|
||||
roleConfirmMessage,
|
||||
loadAll,
|
||||
toggleSort,
|
||||
applyServerSort,
|
||||
openCreateUserModal,
|
||||
openEditUserModal,
|
||||
saveUser,
|
||||
// cleanRejectedUsers,
|
||||
batchDeleteUsers,
|
||||
toggleUserSelection,
|
||||
toggleAllUsers,
|
||||
openBatchEditModal,
|
||||
openBatchPermissionModal,
|
||||
submitBatchEdit,
|
||||
submitBatchPermission,
|
||||
closeDeleteConfirm,
|
||||
confirmDelete,
|
||||
confirmRoleChange,
|
||||
closeRoleConfirm,
|
||||
} = useUsersAdmin();
|
||||
|
||||
const pageSizes = computed(() => [...userPageSizeOptions]);
|
||||
|
||||
const defaultSort = computed(() => ({
|
||||
prop: sortKey.value || 'username',
|
||||
order: sortDir.value === 'desc' ? 'descending' as const : 'ascending' as const,
|
||||
}));
|
||||
|
||||
/**
|
||||
* 把 Element 表格的勾选结果写回已选用户 id。
|
||||
* @param rows - 当前保留的选中行
|
||||
*/
|
||||
function onSelectionChange(rows: AdminUserRow[]): void {
|
||||
selectedUserIds.value = rows.map((row) => row.id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 部门筛选。清空时写回空字符串,列表接口仍按「全部部门」查询。
|
||||
* @param value - 选中的部门名;清空为 undefined
|
||||
*/
|
||||
function onDepartmentChange(value: string | undefined): void {
|
||||
userFilters.value.department = value ?? '';
|
||||
}
|
||||
|
||||
/**
|
||||
* 把 Element 表头排序交给服务端查询。
|
||||
* 核心逻辑:取消排序时保持当前方向;有效排序走 applyServerSort 并回到第一页。
|
||||
* @param payload.prop - 列字段
|
||||
* @param payload.order - ascending、descending 或空
|
||||
*/
|
||||
function onSortChange(payload: { prop: string | null; order: string | null }): void {
|
||||
const field = payload.prop;
|
||||
if ((field === 'username' || field === 'department') && payload.order) {
|
||||
applyServerSort(field, payload.order === 'descending' ? 'desc' : 'asc');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 打开编辑弹窗。表格插槽行类型较宽,这里收成用户行。
|
||||
* @param row - 当前表格行
|
||||
*/
|
||||
function editUser(row: AdminUserRow): void {
|
||||
openEditUserModal(row);
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
void loadAll();
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<section class="admin-table-section">
|
||||
<div v-if="isLoading" class="flex items-center justify-center py-20">
|
||||
<div class="animate-spin rounded-full h-10 w-10 border-b-2 border-brand-600" />
|
||||
</div>
|
||||
|
||||
<template v-else>
|
||||
<div class="admin-table-header admin-table-header--stacked">
|
||||
<div>
|
||||
<h2 class="section-title">{{ t('admin.user.title') }}</h2>
|
||||
<p class="section-desc mt-1">{{ t('admin.user.subtitle') }}</p>
|
||||
<ElConfigProvider :locale="elementLocale">
|
||||
<section v-loading="isLoading" class="admin-table-section min-h-64">
|
||||
<template v-if="!isLoading">
|
||||
<div class="admin-table-header admin-table-header--stacked">
|
||||
<div>
|
||||
<h2 class="section-title">{{ t('admin.user.title') }}</h2>
|
||||
<p class="section-desc mt-1">{{ t('admin.user.subtitle') }}</p>
|
||||
</div>
|
||||
<ElSpace wrap>
|
||||
<ElButton
|
||||
v-if="selectedUserIds.length > 0"
|
||||
type="danger"
|
||||
:icon="Delete"
|
||||
@click="batchDeleteUsers"
|
||||
>
|
||||
{{ t('admin.user.batchDelete') }} ({{ selectedUserIds.length }})
|
||||
</ElButton>
|
||||
<ElButton v-if="selectedUserIds.length > 0" :icon="Edit" @click="openBatchEditModal">
|
||||
{{ t('admin.user.batchEdit') }} ({{ selectedUserIds.length }})
|
||||
</ElButton>
|
||||
<ElButton
|
||||
v-if="selectedUserIds.length > 0 && !rolesConfigured"
|
||||
:icon="User"
|
||||
@click="openBatchPermissionModal"
|
||||
>
|
||||
{{ t('admin.user.batchPermission') }} ({{ selectedUserIds.length }})
|
||||
</ElButton>
|
||||
<ElButton type="primary" :icon="Plus" @click="openCreateUserModal">
|
||||
{{ t('admin.user.addUser') }}
|
||||
</ElButton>
|
||||
</ElSpace>
|
||||
</div>
|
||||
<div class="flex flex-wrap gap-3">
|
||||
<!-- 暂隐藏:清理已拒绝
|
||||
<button
|
||||
type="button"
|
||||
class="flex items-center gap-2 px-4 py-2 bg-red-50 text-red-600 rounded-xl hover:bg-red-100 transition-all border border-red-200 text-sm font-medium"
|
||||
@click="cleanRejectedUsers"
|
||||
>
|
||||
<Trash2 class="w-4 h-4" />
|
||||
<span>{{ t('admin.user.cleanRejected') }}</span>
|
||||
</button>
|
||||
-->
|
||||
<button
|
||||
v-if="selectedUserIds.length > 0"
|
||||
type="button"
|
||||
class="flex items-center gap-2 px-4 py-2 bg-red-600 text-white rounded-xl hover:bg-red-700 transition-all shadow-lg shadow-red-200 active:scale-95 text-sm font-medium"
|
||||
@click="batchDeleteUsers"
|
||||
>
|
||||
<Trash2 class="w-4 h-4" />
|
||||
<span>{{ t('admin.user.batchDelete') }} ({{ selectedUserIds.length }})</span>
|
||||
</button>
|
||||
<button
|
||||
v-if="selectedUserIds.length > 0"
|
||||
type="button"
|
||||
class="flex items-center gap-2 px-4 py-2 bg-indigo-600 text-white rounded-xl hover:bg-indigo-700 transition-all shadow-lg shadow-indigo-200 active:scale-95 text-sm font-medium"
|
||||
@click="openBatchEditModal"
|
||||
>
|
||||
<Edit class="w-4 h-4" />
|
||||
<span>{{ t('admin.user.batchEdit') }} ({{ selectedUserIds.length }})</span>
|
||||
</button>
|
||||
<button
|
||||
v-if="selectedUserIds.length > 0 && !rolesConfigured"
|
||||
type="button"
|
||||
class="flex items-center gap-2 px-4 py-2 bg-purple-600 text-white rounded-xl hover:bg-purple-700 transition-all shadow-lg shadow-purple-200 active:scale-95 text-sm font-medium"
|
||||
@click="openBatchPermissionModal"
|
||||
>
|
||||
<Users class="w-4 h-4" />
|
||||
<span>{{ t('admin.user.batchPermission') }} ({{ selectedUserIds.length }})</span>
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="flex items-center gap-2 px-4 py-2 bg-brand-600 text-white rounded-xl hover:bg-brand-700 transition-all shadow-lg shadow-brand-200 active:scale-95 text-sm font-medium"
|
||||
@click="openCreateUserModal"
|
||||
>
|
||||
<Plus class="w-4 h-4" />
|
||||
<span class="font-medium">{{ t('admin.user.addUser') }}</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="admin-table-filters--inline gap-3">
|
||||
<input v-model="userFilters.username" :placeholder="t('admin.user.filterUsername')" class="admin-table-filter-input w-40" />
|
||||
<input v-model="userFilters.real_name" :placeholder="t('admin.user.filterRealName')" class="admin-table-filter-input w-44" />
|
||||
<select v-model="userFilters.department" class="admin-table-filter-input w-40">
|
||||
<option value="">{{ t('admin.user.allDepts') }}</option>
|
||||
<option v-for="d in departments" :key="d.id" :value="d.name">{{ d.name }}</option>
|
||||
</select>
|
||||
<!-- 暂隐藏:隐藏已拒绝
|
||||
<div class="flex items-center gap-2">
|
||||
<input id="hideRejectedUsers" v-model="hideRejected" type="checkbox" class="w-4 h-4 rounded text-brand-600 focus:ring-brand-500 border-default" />
|
||||
<label for="hideRejectedUsers" class="text-sm text-secondary select-none">{{ t('admin.user.hideRejected') }}</label>
|
||||
<div class="users-element-filters">
|
||||
<ElInput
|
||||
v-model="userFilters.username"
|
||||
clearable
|
||||
class="users-filter-username"
|
||||
:placeholder="t('admin.user.filterUsername')"
|
||||
/>
|
||||
<ElInput
|
||||
v-model="userFilters.real_name"
|
||||
clearable
|
||||
class="users-filter-name"
|
||||
:placeholder="t('admin.user.filterRealName')"
|
||||
/>
|
||||
<ElSelect
|
||||
:model-value="userFilters.department || undefined"
|
||||
class="users-filter-dept"
|
||||
clearable
|
||||
:placeholder="t('admin.user.allDepts')"
|
||||
@update:model-value="onDepartmentChange"
|
||||
>
|
||||
<ElOption v-for="department in departments" :key="department.id" :label="department.name" :value="department.name" />
|
||||
</ElSelect>
|
||||
</div>
|
||||
-->
|
||||
</div>
|
||||
|
||||
<div class="admin-table-wrap relative">
|
||||
<div
|
||||
v-if="isListLoading"
|
||||
class="absolute inset-0 z-10 flex items-center justify-center rounded-2xl bg-surface/60"
|
||||
<ElTable
|
||||
v-loading="isListLoading"
|
||||
class="hx-admin-table"
|
||||
:data="users"
|
||||
row-key="id"
|
||||
:default-sort="defaultSort"
|
||||
:empty-text="t('admin.user.noUsers')"
|
||||
@selection-change="onSelectionChange"
|
||||
@sort-change="onSortChange"
|
||||
>
|
||||
<div class="animate-spin rounded-full h-8 w-8 border-b-2 border-brand-600" />
|
||||
</div>
|
||||
<table class="admin-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="px-6 py-4 w-12 text-center">
|
||||
<input
|
||||
type="checkbox"
|
||||
class="w-4 h-4 rounded text-brand-600 focus:ring-brand-500 cursor-pointer border-default"
|
||||
:checked="allPaginatedUsersSelected"
|
||||
@change="toggleAllUsers(users)"
|
||||
/>
|
||||
</th>
|
||||
<th class="px-6 py-4 text-left text-xs">
|
||||
<SortableTableHeader
|
||||
column-key="username"
|
||||
:label="t('admin.user.headers.user')"
|
||||
:active-key="sortKey"
|
||||
:direction="sortDir"
|
||||
@sort="toggleSort"
|
||||
/>
|
||||
</th>
|
||||
<th class="px-6 py-4 text-left text-xs">{{ t('admin.user.fields.realName') }}</th>
|
||||
<th class="px-6 py-4 text-left text-xs">
|
||||
<SortableTableHeader
|
||||
column-key="department"
|
||||
:label="t('admin.user.headers.dept')"
|
||||
:active-key="sortKey"
|
||||
:direction="sortDir"
|
||||
@sort="toggleSort"
|
||||
/>
|
||||
</th>
|
||||
<th class="px-6 py-4 text-left text-xs">{{ t('admin.user.headers.role') }}</th>
|
||||
<th class="px-6 py-4 text-right text-xs">{{ t('admin.user.headers.actions') }}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-if="usersTotal === 0 && !isListLoading">
|
||||
<td colspan="6" class="px-6 admin-table-empty">{{ t('admin.user.noUsers') }}</td>
|
||||
</tr>
|
||||
<tr v-for="user in users" :key="user.id" class="group">
|
||||
<td class="px-6 py-4 text-center">
|
||||
<input
|
||||
type="checkbox"
|
||||
class="w-4 h-4 rounded text-brand-600 focus:ring-brand-500 cursor-pointer border-default"
|
||||
:checked="selectedUserIds.includes(user.id)"
|
||||
@change="toggleUserSelection(user.id)"
|
||||
/>
|
||||
</td>
|
||||
<td class="px-6 py-4">
|
||||
<div class="flex items-center">
|
||||
<div class="h-9 w-9 rounded-full bg-gradient-to-br from-brand-500 to-indigo-600 text-white flex items-center justify-center text-xs font-bold shadow-sm">
|
||||
{{ getUserAvatarLabel(user) }}
|
||||
</div>
|
||||
<div class="ml-3 text-sm font-medium text-primary">{{ user.username }}</div>
|
||||
</div>
|
||||
</td>
|
||||
<td class="px-6 py-4 text-sm text-primary">{{ user.real_name || '-' }}</td>
|
||||
<td class="px-6 py-4 text-sm text-muted">{{ user.department || '-' }}</td>
|
||||
<td class="px-6 py-4">
|
||||
<span
|
||||
class="px-2.5 py-0.5 rounded-full text-xs font-medium border"
|
||||
:class="user.is_platform_admin
|
||||
? 'bg-purple-50 text-purple-700 border-purple-100'
|
||||
: 'bg-blue-50 text-blue-700 border-blue-100'"
|
||||
>
|
||||
{{ adminRoleLabel(t, user.role, user.role_name) }}
|
||||
<ElTableColumn type="selection" width="64" reserve-selection />
|
||||
<ElTableColumn prop="username" :label="t('admin.user.headers.user')" sortable="custom" min-width="180">
|
||||
<template #default="{ row }">
|
||||
<span class="inline-flex items-center gap-3">
|
||||
<span class="users-avatar">
|
||||
{{ getUserAvatarLabel(row) }}
|
||||
</span>
|
||||
<div
|
||||
v-if="user.feature_permissions?.training_hr_manage || user.feature_permissions?.['maintenance.ledger_write']"
|
||||
class="mt-2 flex flex-wrap gap-1.5"
|
||||
>
|
||||
<span
|
||||
v-if="user.feature_permissions?.training_hr_manage"
|
||||
class="inline-flex rounded-full border border-brand-100 bg-brand-50 px-2.5 py-0.5 text-xs font-medium text-brand-700"
|
||||
>
|
||||
{{ t('admin.user.fields.trainingHrManage') }}
|
||||
</span>
|
||||
<span
|
||||
v-if="user.feature_permissions?.['maintenance.ledger_write']"
|
||||
class="inline-flex rounded-full border border-brand-100 bg-brand-50 px-2.5 py-0.5 text-xs font-medium text-brand-700"
|
||||
>
|
||||
{{ t('admin.permRoles.features.maintenance_ledger_write') }}
|
||||
</span>
|
||||
</div>
|
||||
</td>
|
||||
<td class="px-6 py-4 text-right">
|
||||
<button
|
||||
type="button"
|
||||
class="text-brand-600 hover:text-brand-900 font-medium text-xs px-3 py-1.5 rounded-lg hover:bg-brand-50 transition-colors"
|
||||
@click="openEditUserModal(user)"
|
||||
>
|
||||
{{ t('admin.edit') }}
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<span>{{ row.username }}</span>
|
||||
</span>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn prop="real_name" :label="t('admin.user.fields.realName')" min-width="120">
|
||||
<template #default="{ row }">{{ row.real_name || '-' }}</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn prop="department" :label="t('admin.user.headers.dept')" sortable="custom" min-width="140">
|
||||
<template #default="{ row }">{{ row.department || '-' }}</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn :label="t('admin.user.headers.role')" min-width="180">
|
||||
<template #default="{ row }">
|
||||
<ElTag :type="row.is_platform_admin ? 'warning' : 'primary'" effect="light">
|
||||
{{ adminRoleLabel(t, row.role, row.role_name) }}
|
||||
</ElTag>
|
||||
<div
|
||||
v-if="row.feature_permissions?.training_hr_manage || row.feature_permissions?.['maintenance.ledger_write']"
|
||||
class="mt-2 flex flex-wrap gap-1.5"
|
||||
>
|
||||
<ElTag v-if="row.feature_permissions?.training_hr_manage" size="small">
|
||||
{{ t('admin.user.fields.trainingHrManage') }}
|
||||
</ElTag>
|
||||
<ElTag v-if="row.feature_permissions?.['maintenance.ledger_write']" size="small">
|
||||
{{ t('admin.permRoles.features.maintenance_ledger_write') }}
|
||||
</ElTag>
|
||||
</div>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn :label="t('admin.user.headers.actions')" width="100" align="right">
|
||||
<template #default="{ row }">
|
||||
<ElButton link type="primary" @click="editUser(row as AdminUserRow)">{{ t('admin.edit') }}</ElButton>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
</ElTable>
|
||||
|
||||
<div class="px-4 pb-4 pt-2">
|
||||
<PaginationBar
|
||||
v-model:page="userPage"
|
||||
v-model:page-size="userPageSize"
|
||||
:total="usersTotal"
|
||||
:pages="usersPages"
|
||||
:page-size-options="[...userPageSizeOptions]"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
<div class="hx-admin-pager">
|
||||
<ElPagination
|
||||
v-model:current-page="userPage"
|
||||
v-model:page-size="userPageSize"
|
||||
:total="usersTotal"
|
||||
:page-sizes="pageSizes"
|
||||
layout="total, sizes, prev, pager, next"
|
||||
background
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<UserFormModal
|
||||
:visible="showUserModal"
|
||||
:form="editingUser"
|
||||
:agents="agents"
|
||||
:departments="departments"
|
||||
:roles="roles"
|
||||
:roles-configured="rolesConfigured"
|
||||
:is-saving="isSaving"
|
||||
@close="showUserModal = false"
|
||||
@save="saveUser"
|
||||
/>
|
||||
<UserFormModal
|
||||
:visible="showUserModal"
|
||||
:form="editingUser"
|
||||
:agents="agents"
|
||||
:departments="departments"
|
||||
:roles="roles"
|
||||
:roles-configured="rolesConfigured"
|
||||
:is-saving="isSaving"
|
||||
@close="showUserModal = false"
|
||||
@save="saveUser"
|
||||
/>
|
||||
|
||||
<BatchEditUserModal
|
||||
:visible="showBatchEditModal"
|
||||
:form="batchEditForm"
|
||||
:departments="departments"
|
||||
:roles="roles"
|
||||
:roles-configured="rolesConfigured"
|
||||
:selected-count="selectedUserIds.length"
|
||||
:is-saving="isSaving"
|
||||
@close="showBatchEditModal = false"
|
||||
@save="submitBatchEdit"
|
||||
/>
|
||||
<BatchEditUserModal
|
||||
:visible="showBatchEditModal"
|
||||
:form="batchEditForm"
|
||||
:departments="departments"
|
||||
:roles="roles"
|
||||
:roles-configured="rolesConfigured"
|
||||
:selected-count="selectedUserIds.length"
|
||||
:is-saving="isSaving"
|
||||
@close="showBatchEditModal = false"
|
||||
@save="submitBatchEdit"
|
||||
/>
|
||||
|
||||
<BatchPermissionModal
|
||||
:visible="showBatchPermissionModal"
|
||||
:form="batchPermissionForm"
|
||||
:agents="agents"
|
||||
:selected-count="selectedUserIds.length"
|
||||
:is-saving="isSaving"
|
||||
@close="showBatchPermissionModal = false"
|
||||
@save="submitBatchPermission"
|
||||
/>
|
||||
|
||||
<DeleteConfirmDialog
|
||||
v-model="showDeleteConfirmDialog"
|
||||
:message="deleteConfirmMessage"
|
||||
@confirm="confirmDelete"
|
||||
@cancel="closeDeleteConfirm"
|
||||
/>
|
||||
<DeleteConfirmDialog
|
||||
v-model="showRoleConfirm"
|
||||
:title="t('admin.permRoles.userRoleConfirmTitle')"
|
||||
:message="roleConfirmMessage"
|
||||
:confirm-text="t('admin.save')"
|
||||
confirm-tone="primary"
|
||||
:confirm-loading="isSaving"
|
||||
@confirm="confirmRoleChange"
|
||||
@cancel="closeRoleConfirm"
|
||||
/>
|
||||
</section>
|
||||
<BatchPermissionModal
|
||||
:visible="showBatchPermissionModal"
|
||||
:form="batchPermissionForm"
|
||||
:agents="agents"
|
||||
:selected-count="selectedUserIds.length"
|
||||
:is-saving="isSaving"
|
||||
@close="showBatchPermissionModal = false"
|
||||
@save="submitBatchPermission"
|
||||
/>
|
||||
</section>
|
||||
</ElConfigProvider>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.users-element-filters {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
padding: 16px 32px;
|
||||
border-bottom: 1px solid var(--el-border-color-lighter);
|
||||
}
|
||||
|
||||
.users-element-filters :deep(.el-input),
|
||||
.users-element-filters :deep(.el-select) {
|
||||
flex: none;
|
||||
}
|
||||
|
||||
.users-element-filters :deep(.users-filter-username) {
|
||||
width: 10rem;
|
||||
}
|
||||
|
||||
.users-element-filters :deep(.users-filter-name),
|
||||
.users-element-filters :deep(.users-filter-dept) {
|
||||
width: 11rem;
|
||||
}
|
||||
|
||||
.users-avatar {
|
||||
display: flex;
|
||||
height: 2.25rem;
|
||||
width: 2.25rem;
|
||||
flex: none;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
border-radius: 9999px;
|
||||
background-image: linear-gradient(to bottom right, #0ea5e9, #4f46e5);
|
||||
font-size: var(--el-font-size-extra-small);
|
||||
font-weight: 700;
|
||||
color: #fff;
|
||||
}
|
||||
</style>
|
||||
@@ -1,17 +1,19 @@
|
||||
/**
|
||||
* features/admin/modules/users/components/BatchEditUserModal.vue
|
||||
* 用途:批量编辑用户部门/角色/状态弹窗。权限组启用后角色下拉读权限组列表。
|
||||
* 依赖:admin.types、permissionRole.types、user.types、roleLabel.LEGACY_ROLE_OPTIONS。
|
||||
* 逻辑:UsersPage 传入角色列表;未选字段表示保持不变。
|
||||
* 依赖:element-plus、admin.types、permissionRole.types、user.types、roleLabel.LEGACY_ROLE_OPTIONS。
|
||||
* 逻辑:UsersPage 传入角色列表;未选字段表示保持不变。本弹窗属于用户管理 Element Plus 试点。
|
||||
*/
|
||||
<script setup lang="ts">
|
||||
import { computed } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { ElButton, ElDialog, ElForm, ElFormItem, ElOption, ElSelect } from 'element-plus';
|
||||
import type { AdminDepartmentRow } from '@/features/admin/types/admin.types';
|
||||
import type { PermissionRoleRow } from '@/features/admin/types/permissionRole.types';
|
||||
import type { BatchEditForm } from '@/features/admin/types/user.types';
|
||||
import { LEGACY_ROLE_OPTIONS } from '@/features/admin/utils/roleLabel';
|
||||
|
||||
defineProps<{
|
||||
const props = defineProps<{
|
||||
visible: boolean;
|
||||
form: BatchEditForm;
|
||||
departments: AdminDepartmentRow[];
|
||||
@@ -23,55 +25,61 @@ defineProps<{
|
||||
|
||||
const emit = defineEmits<{ close: []; save: [] }>();
|
||||
const { t } = useI18n();
|
||||
|
||||
/**
|
||||
* 角色下拉,首项为保持不变。
|
||||
*/
|
||||
const roleOptions = computed(() => {
|
||||
const keep = { value: '', label: t('admin.batchEdit.fields.keepUnchanged') };
|
||||
if (props.rolesConfigured) {
|
||||
return [keep, ...props.roles.map((role) => ({ value: role.code, label: role.name }))];
|
||||
}
|
||||
return [keep, ...LEGACY_ROLE_OPTIONS.map((option) => ({ value: option.code, label: t(option.i18nKey) }))];
|
||||
});
|
||||
|
||||
/**
|
||||
* 关闭弹窗并通知父页面收起。
|
||||
* @param open - Element 对话框的打开状态
|
||||
*/
|
||||
function onVisibleChange(open: boolean): void {
|
||||
if (!open) emit('close');
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div v-if="visible" class="admin-modal-overlay items-center">
|
||||
<div class="admin-modal-panel max-w-md animate-fade-in-up">
|
||||
<div class="px-8 py-6 border-b border-subtle">
|
||||
<h3 class="text-lg font-bold text-primary">{{ t('admin.batchEdit.title') }}</h3>
|
||||
<p class="text-sm text-muted">{{ t('admin.batchEdit.selected', { count: selectedCount }) }}</p>
|
||||
</div>
|
||||
<div class="p-8 space-y-4">
|
||||
<div class="space-y-1.5">
|
||||
<label class="block text-xs font-semibold text-muted uppercase tracking-wider">{{ t('admin.batchEdit.fields.dept') }}</label>
|
||||
<select v-model="form.department" class="input-field text-sm">
|
||||
<option value="">{{ t('admin.batchEdit.fields.keepUnchanged') }}</option>
|
||||
<option v-for="d in departments" :key="d.id" :value="d.name">{{ d.name }}</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="space-y-1.5">
|
||||
<label class="block text-xs font-semibold text-muted uppercase tracking-wider">{{ t('admin.batchEdit.fields.role') }}</label>
|
||||
<select v-if="rolesConfigured" v-model="form.role" class="input-field text-sm">
|
||||
<option value="">{{ t('admin.batchEdit.fields.keepUnchanged') }}</option>
|
||||
<option v-for="role in roles" :key="role.code" :value="role.code">{{ role.name }}</option>
|
||||
</select>
|
||||
<select v-else v-model="form.role" class="input-field text-sm">
|
||||
<option value="">{{ t('admin.batchEdit.fields.keepUnchanged') }}</option>
|
||||
<option
|
||||
v-for="option in LEGACY_ROLE_OPTIONS"
|
||||
:key="option.code"
|
||||
:value="option.code"
|
||||
>
|
||||
{{ t(option.i18nKey) }}
|
||||
</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="space-y-1.5">
|
||||
<label class="block text-xs font-semibold text-muted uppercase tracking-wider">{{ t('admin.batchEdit.fields.status') }}</label>
|
||||
<select v-model="form.status" class="input-field text-sm">
|
||||
<option value="">{{ t('admin.batchEdit.fields.keepUnchanged') }}</option>
|
||||
<option value="active">{{ t('admin.status.active') }}</option>
|
||||
<option value="disabled">{{ t('admin.status.disabled') }}</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="admin-modal-footer admin-modal-footer--muted px-8 py-6">
|
||||
<button type="button" class="btn-ghost" @click="emit('close')">{{ t('admin.cancel') }}</button>
|
||||
<button type="button" class="btn-primary disabled:opacity-50" :disabled="isSaving" @click="emit('save')">
|
||||
{{ isSaving ? t('admin.save') + '...' : t('admin.batchEdit.update') }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<ElDialog
|
||||
:model-value="visible"
|
||||
:title="t('admin.batchEdit.title')"
|
||||
width="480px"
|
||||
align-center
|
||||
append-to-body
|
||||
:close-on-click-modal="false"
|
||||
@update:model-value="onVisibleChange"
|
||||
>
|
||||
<p class="hx-element-hint">{{ t('admin.batchEdit.selected', { count: selectedCount }) }}</p>
|
||||
<ElForm label-position="top" :model="form">
|
||||
<ElFormItem :label="t('admin.batchEdit.fields.dept')">
|
||||
<ElSelect v-model="form.department" class="w-full">
|
||||
<ElOption :label="t('admin.batchEdit.fields.keepUnchanged')" value="" />
|
||||
<ElOption v-for="department in departments" :key="department.id" :label="department.name" :value="department.name" />
|
||||
</ElSelect>
|
||||
</ElFormItem>
|
||||
<ElFormItem :label="t('admin.batchEdit.fields.role')">
|
||||
<ElSelect v-model="form.role" class="w-full">
|
||||
<ElOption v-for="option in roleOptions" :key="option.value || 'keep'" :label="option.label" :value="option.value" />
|
||||
</ElSelect>
|
||||
</ElFormItem>
|
||||
<ElFormItem :label="t('admin.batchEdit.fields.status')">
|
||||
<ElSelect v-model="form.status" class="w-full">
|
||||
<ElOption :label="t('admin.batchEdit.fields.keepUnchanged')" value="" />
|
||||
<ElOption :label="t('admin.status.active')" value="active" />
|
||||
<ElOption :label="t('admin.status.disabled')" value="disabled" />
|
||||
</ElSelect>
|
||||
</ElFormItem>
|
||||
</ElForm>
|
||||
<template #footer>
|
||||
<ElButton @click="emit('close')">{{ t('admin.cancel') }}</ElButton>
|
||||
<ElButton type="primary" :loading="isSaving" @click="emit('save')">{{ t('admin.batchEdit.update') }}</ElButton>
|
||||
</template>
|
||||
</ElDialog>
|
||||
</template>
|
||||
@@ -1,9 +1,21 @@
|
||||
/**
|
||||
* features/admin/modules/users/components/BatchPermissionModal.vue
|
||||
* 批量分配/移除用户 Agent 权限弹窗。
|
||||
* 用途:批量分配、移除或覆盖用户 Agent 权限。
|
||||
* 依赖:element-plus、admin.types、user.types。
|
||||
* 逻辑:UsersPage 传入已选人数与 Agent 列表;动作为 add / remove / set。本弹窗属于用户管理 Element Plus 试点。
|
||||
*/
|
||||
<script setup lang="ts">
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import {
|
||||
ElButton,
|
||||
ElCheckbox,
|
||||
ElCheckboxGroup,
|
||||
ElDialog,
|
||||
ElForm,
|
||||
ElFormItem,
|
||||
ElRadio,
|
||||
ElRadioGroup,
|
||||
} from 'element-plus';
|
||||
import type { AdminAgentOption } from '@/features/admin/types/admin.types';
|
||||
import type { BatchPermissionForm } from '@/features/admin/types/user.types';
|
||||
|
||||
@@ -17,54 +29,46 @@ defineProps<{
|
||||
|
||||
const emit = defineEmits<{ close: []; save: [] }>();
|
||||
const { t } = useI18n();
|
||||
|
||||
/**
|
||||
* 关闭弹窗并通知父页面收起。
|
||||
* @param open - Element 对话框的打开状态
|
||||
*/
|
||||
function onVisibleChange(open: boolean): void {
|
||||
if (!open) emit('close');
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div v-if="visible" class="admin-modal-overlay items-center">
|
||||
<div class="admin-modal-panel max-w-lg animate-fade-in-up">
|
||||
<div class="px-8 py-6 border-b border-subtle">
|
||||
<h3 class="text-lg font-bold text-primary">{{ t('admin.perm.batchModal.title') }}</h3>
|
||||
<p class="text-sm text-muted">{{ t('admin.perm.batchModal.selected', { count: selectedCount }) }}</p>
|
||||
</div>
|
||||
<div class="p-8 space-y-6">
|
||||
<div class="space-y-1.5">
|
||||
<label class="block text-xs font-semibold text-muted uppercase tracking-wider">{{ t('admin.perm.batchModal.action') }}</label>
|
||||
<div class="flex gap-4">
|
||||
<label class="flex items-center gap-2 cursor-pointer">
|
||||
<input v-model="form.action" type="radio" value="add" class="text-blue-600 focus:ring-blue-500" />
|
||||
<span class="text-sm">{{ t('admin.perm.batchModal.add') }}</span>
|
||||
</label>
|
||||
<label class="flex items-center gap-2 cursor-pointer">
|
||||
<input v-model="form.action" type="radio" value="remove" class="text-blue-600 focus:ring-blue-500" />
|
||||
<span class="text-sm">{{ t('admin.perm.batchModal.remove') }}</span>
|
||||
</label>
|
||||
<label class="flex items-center gap-2 cursor-pointer">
|
||||
<input v-model="form.action" type="radio" value="set" class="text-blue-600 focus:ring-blue-500" />
|
||||
<span class="text-sm">{{ t('admin.perm.batchModal.set') }}</span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="space-y-1.5">
|
||||
<label class="block text-xs font-semibold text-muted uppercase tracking-wider">{{ t('admin.perm.batchModal.selectAgents') }}</label>
|
||||
<div class="grid grid-cols-2 gap-3 max-h-60 overflow-y-auto p-1">
|
||||
<label
|
||||
v-for="agent in agents"
|
||||
:key="agent.id"
|
||||
class="flex items-center gap-2 p-3 border border-default rounded-lg cursor-pointer hover-surface-soft transition-colors"
|
||||
:class="form.agent_ids.includes(agent.id) ? 'border-blue-500 bg-blue-50' : ''"
|
||||
>
|
||||
<input v-model="form.agent_ids" type="checkbox" :value="agent.id" class="w-4 h-4 text-blue-600 rounded focus:ring-blue-500" />
|
||||
<span class="text-sm font-medium text-secondary">{{ agent.name }}</span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="admin-modal-footer admin-modal-footer--muted px-8 py-6">
|
||||
<button type="button" class="btn-ghost" @click="emit('close')">{{ t('admin.cancel') }}</button>
|
||||
<button type="button" class="btn-primary disabled:opacity-50" :disabled="isSaving" @click="emit('save')">
|
||||
{{ isSaving ? t('admin.save') + '...' : t('admin.perm.batchModal.apply') }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<ElDialog
|
||||
:model-value="visible"
|
||||
:title="t('admin.perm.batchModal.title')"
|
||||
width="480px"
|
||||
align-center
|
||||
append-to-body
|
||||
:close-on-click-modal="false"
|
||||
@update:model-value="onVisibleChange"
|
||||
>
|
||||
<p class="hx-element-hint">{{ t('admin.perm.batchModal.selected', { count: selectedCount }) }}</p>
|
||||
<ElForm label-position="top" :model="form">
|
||||
<ElFormItem :label="t('admin.perm.batchModal.action')">
|
||||
<ElRadioGroup v-model="form.action">
|
||||
<ElRadio value="add">{{ t('admin.perm.batchModal.add') }}</ElRadio>
|
||||
<ElRadio value="remove">{{ t('admin.perm.batchModal.remove') }}</ElRadio>
|
||||
<ElRadio value="set">{{ t('admin.perm.batchModal.set') }}</ElRadio>
|
||||
</ElRadioGroup>
|
||||
</ElFormItem>
|
||||
<ElFormItem :label="t('admin.perm.batchModal.selectAgents')">
|
||||
<ElCheckboxGroup v-model="form.agent_ids" class="grid max-h-60 grid-cols-2 gap-2 overflow-y-auto">
|
||||
<ElCheckbox v-for="agent in agents" :key="agent.id" :value="agent.id">
|
||||
{{ agent.name }}
|
||||
</ElCheckbox>
|
||||
</ElCheckboxGroup>
|
||||
</ElFormItem>
|
||||
</ElForm>
|
||||
<template #footer>
|
||||
<ElButton @click="emit('close')">{{ t('admin.cancel') }}</ElButton>
|
||||
<ElButton type="primary" :loading="isSaving" @click="emit('save')">{{ t('admin.perm.batchModal.apply') }}</ElButton>
|
||||
</template>
|
||||
</ElDialog>
|
||||
</template>
|
||||
@@ -1,17 +1,30 @@
|
||||
/**
|
||||
* features/admin/modules/users/components/UserFormModal.vue
|
||||
* 用途:创建/编辑用户弹窗。权限组启用后只选角色,不再按人勾应用或功能权限。
|
||||
* 依赖:admin.types、user.types、permissionRole.types、roleLabel.LEGACY_ROLE_OPTIONS。
|
||||
* 逻辑:UsersPage 传入角色列表;未种子权限组时保留历史 Agent / 培训 HR 勾选,角色下拉用旧枚举。
|
||||
* 依赖:element-plus、admin.types、user.types、permissionRole.types、roleLabel.LEGACY_ROLE_OPTIONS。
|
||||
* 逻辑:UsersPage 传入角色列表;未种子权限组时保留历史 Agent / 功能权限勾选,角色下拉用旧枚举。
|
||||
* 本弹窗属于用户管理 Element Plus 试点。
|
||||
*/
|
||||
<script setup lang="ts">
|
||||
import { computed } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import {
|
||||
ElButton,
|
||||
ElCheckbox,
|
||||
ElCheckboxGroup,
|
||||
ElDialog,
|
||||
ElForm,
|
||||
ElFormItem,
|
||||
ElInput,
|
||||
ElOption,
|
||||
ElSelect,
|
||||
} from 'element-plus';
|
||||
import type { AdminAgentOption, AdminDepartmentRow } from '@/features/admin/types/admin.types';
|
||||
import type { PermissionRoleRow } from '@/features/admin/types/permissionRole.types';
|
||||
import type { UserFormState } from '@/features/admin/types/user.types';
|
||||
import { LEGACY_ROLE_OPTIONS } from '@/features/admin/utils/roleLabel';
|
||||
|
||||
defineProps<{
|
||||
const props = defineProps<{
|
||||
visible: boolean;
|
||||
form: UserFormState;
|
||||
agents: AdminAgentOption[];
|
||||
@@ -24,150 +37,142 @@ defineProps<{
|
||||
const emit = defineEmits<{
|
||||
close: [];
|
||||
save: [];
|
||||
'update:form': [UserFormState];
|
||||
}>();
|
||||
|
||||
const { t } = useI18n();
|
||||
|
||||
/**
|
||||
* 角色下拉。已配置权限组时用组名称,否则用历史角色枚举。
|
||||
*/
|
||||
const roleOptions = computed(() => {
|
||||
if (props.rolesConfigured) {
|
||||
return props.roles.map((role) => ({ value: role.code, label: role.name }));
|
||||
}
|
||||
return LEGACY_ROLE_OPTIONS.map((option) => ({ value: option.code, label: t(option.i18nKey) }));
|
||||
});
|
||||
|
||||
/**
|
||||
* 关闭弹窗并通知父页面收起。
|
||||
* @param open - Element 对话框的打开状态
|
||||
*/
|
||||
function onVisibleChange(open: boolean): void {
|
||||
if (!open) emit('close');
|
||||
}
|
||||
|
||||
/**
|
||||
* 部门选择。清空时写回空字符串,表示不指定部门。
|
||||
* @param value - 选中的部门名;清空为 undefined
|
||||
*/
|
||||
function onDepartmentChange(value: string | undefined): void {
|
||||
props.form.department = value ?? '';
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div v-if="visible" class="admin-modal-overlay animate-fade-in">
|
||||
<div class="admin-modal-panel max-w-2xl max-h-[92vh] scale-100">
|
||||
<div class="px-5 sm:px-8 pt-5 sm:pt-7 pb-4 border-b border-subtle">
|
||||
<h3 class="section-title">{{ form.id ? t('admin.user.editUser') : t('admin.user.createUser') }}</h3>
|
||||
</div>
|
||||
<div class="px-5 sm:px-8 py-5 space-y-5 overflow-y-auto">
|
||||
<div class="space-y-1.5">
|
||||
<label class="block text-xs font-semibold text-muted uppercase tracking-wider">
|
||||
<span v-if="!form.id" class="text-red-500 mr-0.5">*</span>{{ t('admin.user.fields.realName') }}
|
||||
</label>
|
||||
<input v-model="form.real_name" type="text" class="w-full border-default rounded-xl px-4 py-3 text-sm" />
|
||||
</div>
|
||||
<div class="space-y-1.5">
|
||||
<label class="block text-xs font-semibold text-muted uppercase tracking-wider">
|
||||
<span v-if="!form.id" class="text-red-500 mr-0.5">*</span>{{ t('admin.user.fields.employeeId') }}
|
||||
</label>
|
||||
<input v-model="form.employee_id" type="text" class="w-full border-default rounded-xl px-4 py-3 text-sm" />
|
||||
</div>
|
||||
<div class="space-y-1.5">
|
||||
<label class="block text-xs font-semibold text-muted uppercase tracking-wider">
|
||||
<span v-if="!form.id" class="text-red-500 mr-0.5">*</span>{{ t('admin.user.fields.phone') }}
|
||||
</label>
|
||||
<input v-model="form.phone_number" type="text" class="w-full border-default rounded-xl px-4 py-3 text-sm" />
|
||||
</div>
|
||||
<div v-if="!rolesConfigured" class="space-y-1.5 col-span-1 md:col-span-2">
|
||||
<label class="block text-xs font-semibold text-muted uppercase tracking-wider">{{ t('admin.user.fields.allowedAgents') }}</label>
|
||||
<div class="grid grid-cols-1 sm:grid-cols-2 gap-3 mt-2">
|
||||
<label
|
||||
v-for="agent in agents"
|
||||
:key="agent.id"
|
||||
class="flex items-center gap-2 p-3 border border-default rounded-lg cursor-pointer hover-surface-soft transition-colors"
|
||||
:class="form.agent_ids.includes(agent.id) ? 'border-blue-500 bg-blue-50' : ''"
|
||||
>
|
||||
<input v-model="form.agent_ids" type="checkbox" :value="agent.id" class="w-4 h-4 text-blue-600 rounded focus:ring-blue-500" />
|
||||
<span class="text-sm font-medium text-secondary">{{ agent.name }}</span>
|
||||
</label>
|
||||
<ElDialog
|
||||
:model-value="visible"
|
||||
:title="form.id ? t('admin.user.editUser') : t('admin.user.createUser')"
|
||||
width="680px"
|
||||
align-center
|
||||
append-to-body
|
||||
:close-on-click-modal="false"
|
||||
@update:model-value="onVisibleChange"
|
||||
>
|
||||
<div class="max-h-[65vh] overflow-y-auto pr-1">
|
||||
<ElForm class="users-element-form" label-position="top" :model="form">
|
||||
<ElFormItem :label="t('admin.user.fields.realName')" :required="!form.id">
|
||||
<ElInput v-model="form.real_name" />
|
||||
</ElFormItem>
|
||||
<ElFormItem :label="t('admin.user.fields.employeeId')" :required="!form.id">
|
||||
<ElInput v-model="form.employee_id" />
|
||||
</ElFormItem>
|
||||
<ElFormItem :label="t('admin.user.fields.phone')" :required="!form.id">
|
||||
<ElInput v-model="form.phone_number" />
|
||||
</ElFormItem>
|
||||
<ElFormItem :label="t('admin.user.fields.username')" :required="!form.id">
|
||||
<ElInput v-model="form.username" :disabled="!!form.id" />
|
||||
</ElFormItem>
|
||||
<ElFormItem :label="t('admin.user.fields.email')" :required="!form.id">
|
||||
<ElInput v-model="form.email" />
|
||||
</ElFormItem>
|
||||
<ElFormItem :label="t('admin.user.fields.department')">
|
||||
<ElSelect
|
||||
:model-value="form.department || undefined"
|
||||
class="w-full"
|
||||
clearable
|
||||
:placeholder="t('admin.user.allDepts')"
|
||||
@update:model-value="onDepartmentChange"
|
||||
>
|
||||
<ElOption v-for="department in departments" :key="department.id" :label="department.name" :value="department.name" />
|
||||
</ElSelect>
|
||||
</ElFormItem>
|
||||
<ElFormItem v-if="!rolesConfigured" class="users-form-span" :label="t('admin.user.fields.allowedAgents')">
|
||||
<ElCheckboxGroup v-model="form.agent_ids">
|
||||
<div class="grid grid-cols-1 gap-2 sm:grid-cols-2">
|
||||
<ElCheckbox v-for="agent in agents" :key="agent.id" :value="agent.id">
|
||||
{{ agent.name }}
|
||||
</ElCheckbox>
|
||||
</div>
|
||||
</ElCheckboxGroup>
|
||||
<p v-if="agents.length === 0" class="hx-element-hint">{{ t('admin.user.fields.noAgents') }}</p>
|
||||
</ElFormItem>
|
||||
<ElFormItem class="users-form-span" :label="t('admin.user.fields.role')" required>
|
||||
<ElSelect v-model="form.role" class="w-full">
|
||||
<ElOption v-for="option in roleOptions" :key="option.value" :label="option.label" :value="option.value" />
|
||||
</ElSelect>
|
||||
<p v-if="rolesConfigured" class="hx-element-hint">{{ t('admin.permRoles.userFormHint') }}</p>
|
||||
</ElFormItem>
|
||||
<ElFormItem v-if="!rolesConfigured" class="users-form-span" :label="t('admin.user.fields.featurePermissions')">
|
||||
<div class="flex flex-col gap-3">
|
||||
<ElCheckbox v-model="form.feature_permissions.training_hr_manage">
|
||||
<span class="block">{{ t('admin.user.fields.trainingHrManage') }}</span>
|
||||
<span class="hx-element-hint">{{ t('admin.user.fields.trainingHrManageHint') }}</span>
|
||||
</ElCheckbox>
|
||||
<ElCheckbox v-model="form.feature_permissions['contract_payment.access']">
|
||||
<span class="block">{{ t('admin.user.fields.contractPaymentAccess') }}</span>
|
||||
<span class="hx-element-hint">{{ t('admin.user.fields.contractPaymentAccessHint') }}</span>
|
||||
</ElCheckbox>
|
||||
<ElCheckbox v-model="form.feature_permissions['order_delivery_reply.manage']">
|
||||
<span class="block">{{ t('admin.user.fields.orderDeliveryReplyManage') }}</span>
|
||||
<span class="hx-element-hint">{{ t('admin.user.fields.orderDeliveryReplyManageHint') }}</span>
|
||||
</ElCheckbox>
|
||||
<ElCheckbox v-model="form.feature_permissions['order_delivery_reply.access']">
|
||||
<span class="block">{{ t('admin.user.fields.orderDeliveryReplyAccess') }}</span>
|
||||
<span class="hx-element-hint">{{ t('admin.user.fields.orderDeliveryReplyAccessHint') }}</span>
|
||||
</ElCheckbox>
|
||||
</div>
|
||||
<p v-if="agents.length === 0" class="text-sm text-muted italic">{{ t('admin.user.fields.noAgents') }}</p>
|
||||
</div>
|
||||
<div class="space-y-1.5">
|
||||
<label class="block text-xs font-semibold text-muted uppercase tracking-wider">
|
||||
<span v-if="!form.id" class="text-red-500 mr-0.5">*</span>{{ t('admin.user.fields.username') }}
|
||||
</label>
|
||||
<input v-model="form.username" type="text" class="w-full border-default rounded-xl px-4 py-3 text-sm" :disabled="!!form.id" />
|
||||
</div>
|
||||
<div class="space-y-1.5">
|
||||
<label class="block text-xs font-semibold text-muted uppercase tracking-wider">
|
||||
<span v-if="!form.id" class="text-red-500 mr-0.5">*</span>{{ t('admin.user.fields.email') }}
|
||||
</label>
|
||||
<input v-model="form.email" type="email" class="w-full border-default rounded-xl px-4 py-3 text-sm" />
|
||||
</div>
|
||||
<div class="space-y-1.5">
|
||||
<label class="block text-xs font-semibold text-muted uppercase tracking-wider">{{ t('admin.user.fields.department') }}</label>
|
||||
<select v-model="form.department" class="w-full border-default rounded-xl px-4 py-3 text-sm">
|
||||
<option value="">{{ t('admin.user.allDepts') }}</option>
|
||||
<option v-for="d in departments" :key="d.id" :value="d.name">{{ d.name }}</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="space-y-1.5">
|
||||
<label class="block text-xs font-semibold text-muted uppercase tracking-wider">
|
||||
<span class="text-red-500 mr-0.5">*</span>{{ t('admin.user.fields.role') }}
|
||||
</label>
|
||||
<select v-if="rolesConfigured" v-model="form.role" class="w-full border-default rounded-xl px-4 py-3 text-sm">
|
||||
<option v-for="role in roles" :key="role.code" :value="role.code">{{ role.name }}</option>
|
||||
</select>
|
||||
<select v-else v-model="form.role" class="w-full border-default rounded-xl px-4 py-3 text-sm">
|
||||
<option
|
||||
v-for="option in LEGACY_ROLE_OPTIONS"
|
||||
:key="option.code"
|
||||
:value="option.code"
|
||||
>
|
||||
{{ t(option.i18nKey) }}
|
||||
</option>
|
||||
</select>
|
||||
<p v-if="rolesConfigured" class="text-xs text-muted">{{ t('admin.permRoles.userFormHint') }}</p>
|
||||
</div>
|
||||
<div v-if="!rolesConfigured" class="space-y-2 rounded-2xl border border-default bg-surface px-4 py-4">
|
||||
<div class="text-xs font-semibold uppercase tracking-wider text-muted">{{ t('admin.user.fields.featurePermissions') }}</div>
|
||||
<label class="flex items-start gap-3 rounded-xl border border-default bg-white px-4 py-3">
|
||||
<input
|
||||
v-model="form.feature_permissions.training_hr_manage"
|
||||
type="checkbox"
|
||||
class="mt-0.5 h-4 w-4 rounded border-default text-brand-600 focus:ring-brand-500"
|
||||
/>
|
||||
<span class="space-y-1">
|
||||
<span class="block text-sm font-medium text-primary">{{ t('admin.user.fields.trainingHrManage') }}</span>
|
||||
<span class="block text-xs leading-5 text-muted">{{ t('admin.user.fields.trainingHrManageHint') }}</span>
|
||||
</span>
|
||||
</label>
|
||||
<label class="flex items-start gap-3 rounded-xl border border-default bg-white px-4 py-3">
|
||||
<input
|
||||
v-model="form.feature_permissions['contract_payment.access']"
|
||||
type="checkbox"
|
||||
class="mt-0.5 h-4 w-4 rounded border-default text-brand-600 focus:ring-brand-500"
|
||||
/>
|
||||
<span class="space-y-1">
|
||||
<span class="block text-sm font-medium text-primary">{{ t('admin.user.fields.contractPaymentAccess') }}</span>
|
||||
<span class="block text-xs leading-5 text-muted">{{ t('admin.user.fields.contractPaymentAccessHint') }}</span>
|
||||
</span>
|
||||
</label>
|
||||
<label class="flex items-start gap-3 rounded-xl border border-default bg-white px-4 py-3">
|
||||
<input
|
||||
v-model="form.feature_permissions['order_delivery_reply.manage']"
|
||||
type="checkbox"
|
||||
class="mt-0.5 h-4 w-4 rounded border-default text-brand-600 focus:ring-brand-500"
|
||||
/>
|
||||
<span class="space-y-1">
|
||||
<span class="block text-sm font-medium text-primary">{{ t('admin.user.fields.orderDeliveryReplyManage') }}</span>
|
||||
<span class="block text-xs leading-5 text-muted">{{ t('admin.user.fields.orderDeliveryReplyManageHint') }}</span>
|
||||
</span>
|
||||
</label>
|
||||
<label class="flex items-start gap-3 rounded-xl border border-default bg-white px-4 py-3">
|
||||
<input
|
||||
v-model="form.feature_permissions['order_delivery_reply.access']"
|
||||
type="checkbox"
|
||||
class="mt-0.5 h-4 w-4 rounded border-default text-brand-600 focus:ring-brand-500"
|
||||
/>
|
||||
<span class="space-y-1">
|
||||
<span class="block text-sm font-medium text-primary">{{ t('admin.user.fields.orderDeliveryReplyAccess') }}</span>
|
||||
<span class="block text-xs leading-5 text-muted">{{ t('admin.user.fields.orderDeliveryReplyAccessHint') }}</span>
|
||||
</span>
|
||||
</label>
|
||||
</div>
|
||||
<div class="space-y-1.5">
|
||||
<label class="block text-xs font-semibold text-muted uppercase tracking-wider">
|
||||
<span v-if="!form.id" class="text-red-500 mr-0.5">*</span>{{ t('admin.user.fields.password') }}
|
||||
<span v-if="form.id" class="text-muted font-normal lowercase">{{ t('admin.user.fields.passwordHint') }}</span>
|
||||
</label>
|
||||
<input v-model="form.password" type="password" class="w-full border-default rounded-xl px-4 py-3 text-sm" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="admin-modal-footer">
|
||||
<button type="button" class="btn-ghost" @click="emit('close')">{{ t('admin.cancel') }}</button>
|
||||
<button type="button" class="btn-primary disabled:opacity-70" :disabled="isSaving" @click="emit('save')">
|
||||
{{ isSaving ? t('admin.save') + '...' : t('admin.save') }}
|
||||
</button>
|
||||
</div>
|
||||
</ElFormItem>
|
||||
<ElFormItem class="users-form-span" :label="t('admin.user.fields.password')" :required="!form.id">
|
||||
<ElInput v-model="form.password" type="password" show-password />
|
||||
<p v-if="form.id" class="hx-element-hint">{{ t('admin.user.fields.passwordHint') }}</p>
|
||||
</ElFormItem>
|
||||
</ElForm>
|
||||
</div>
|
||||
</div>
|
||||
<template #footer>
|
||||
<ElButton @click="emit('close')">{{ t('admin.cancel') }}</ElButton>
|
||||
<ElButton type="primary" :loading="isSaving" @click="emit('save')">{{ t('admin.save') }}</ElButton>
|
||||
</template>
|
||||
</ElDialog>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.users-element-form {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr;
|
||||
column-gap: 16px;
|
||||
}
|
||||
|
||||
.users-element-form :deep(.el-form-item) {
|
||||
margin-bottom: 14px;
|
||||
}
|
||||
|
||||
.users-element-form :deep(.users-form-span) {
|
||||
grid-column: 1 / -1;
|
||||
}
|
||||
|
||||
@media (max-width: 640px) {
|
||||
.users-element-form {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -3,10 +3,12 @@
|
||||
* 用途:用户管理模块业务逻辑(CRUD、服务端筛选分页、用户/部门列排序、批量操作)。
|
||||
* 依赖:admin.api、useMessage、useTableSort、permissionRole.types。
|
||||
* 逻辑:UsersPage 调用本 composable;列表经 listAdminUsersPage 按页拉取,排序参数随请求下发。
|
||||
* 权限组启用后创建用户预填默认角色,改角色须确认;批量按人授权入口关闭。
|
||||
* 权限组启用后创建用户预填默认角色;删除和改角色用 Element 确认框。批量按人授权入口关闭。
|
||||
* Element Plus 表格通过 applyServerSort 写入列排序。
|
||||
*/
|
||||
import { computed, ref, watch } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { ElMessageBox } from 'element-plus';
|
||||
import {
|
||||
batchDeleteAdminUsers,
|
||||
batchUpdateAdminPermissions,
|
||||
@@ -68,10 +70,6 @@ export function useUsersAdmin() {
|
||||
const showUserModal = ref(false);
|
||||
const editingUser = ref<UserFormState>(createEmptyUserForm());
|
||||
const originalUserRole = ref('user');
|
||||
const showRoleConfirm = ref(false);
|
||||
const roleConfirmMessage = ref('');
|
||||
let pendingUserSave: (() => Promise<void>) | null = null;
|
||||
let pendingBatchSave: (() => Promise<void>) | null = null;
|
||||
|
||||
const showBatchEditModal = ref(false);
|
||||
const batchEditForm = ref<BatchEditForm>({ department: '', role: '', status: '' });
|
||||
@@ -79,9 +77,6 @@ export function useUsersAdmin() {
|
||||
const showBatchPermissionModal = ref(false);
|
||||
const batchPermissionForm = ref<BatchPermissionForm>({ agent_ids: [], action: 'add' });
|
||||
|
||||
const showDeleteConfirmDialog = ref(false);
|
||||
const deleteConfirmMessage = ref('');
|
||||
let deleteConfirmAction: (() => Promise<void> | void) | null = null;
|
||||
|
||||
/** 当前页是否已全部选中 */
|
||||
const allPaginatedUsersSelected = computed(
|
||||
@@ -194,25 +189,41 @@ export function useUsersAdmin() {
|
||||
}, 300);
|
||||
}, { deep: true });
|
||||
|
||||
const openDeleteConfirm = (message: string, action: () => Promise<void> | void): void => {
|
||||
deleteConfirmMessage.value = message;
|
||||
deleteConfirmAction = action;
|
||||
showDeleteConfirmDialog.value = true;
|
||||
};
|
||||
|
||||
const closeDeleteConfirm = (): void => {
|
||||
showDeleteConfirmDialog.value = false;
|
||||
deleteConfirmAction = null;
|
||||
/**
|
||||
* 用 Element 确认框询问后再执行删除。
|
||||
* 核心逻辑:取消时 MessageBox 会 reject,这里吞掉,不调用 action。
|
||||
* @param message - 确认文案
|
||||
* @param action - 用户点确定后执行的删除
|
||||
*/
|
||||
const openDeleteConfirm = async (message: string, action: () => Promise<void> | void): Promise<void> => {
|
||||
try {
|
||||
await ElMessageBox.confirm(message, t('common.deleteDialog.defaultTitle'), {
|
||||
type: 'warning',
|
||||
confirmButtonText: t('common.deleteDialog.confirm'),
|
||||
cancelButtonText: t('common.deleteDialog.cancel'),
|
||||
});
|
||||
} catch {
|
||||
return;
|
||||
}
|
||||
await action();
|
||||
};
|
||||
|
||||
/**
|
||||
* 执行待确认的删除操作。
|
||||
* 核心逻辑:先快照 action 并立即关闭弹窗,再 await 删除与刷新,避免异步完成前弹窗无法关闭。
|
||||
* 用 Element 确认框询问改角色,确定后执行保存。
|
||||
* 核心逻辑:与删除确认同一组件,避免一页两种确认框。取消则不保存。
|
||||
* @param message - 角色变更说明
|
||||
* @param action - 用户点确定后提交
|
||||
*/
|
||||
const confirmDelete = async (): Promise<void> => {
|
||||
const action = deleteConfirmAction;
|
||||
closeDeleteConfirm();
|
||||
if (!action) return;
|
||||
const confirmRoleThen = async (message: string, action: () => Promise<void>): Promise<void> => {
|
||||
try {
|
||||
await ElMessageBox.confirm(message, t('admin.permRoles.userRoleConfirmTitle'), {
|
||||
type: 'warning',
|
||||
confirmButtonText: t('admin.save'),
|
||||
cancelButtonText: t('admin.cancel'),
|
||||
});
|
||||
} catch {
|
||||
return;
|
||||
}
|
||||
await action();
|
||||
};
|
||||
|
||||
@@ -296,11 +307,10 @@ export function useUsersAdmin() {
|
||||
: nextRole !== originalUserRole.value;
|
||||
const touchesAdmin = isAdminRoleCode(nextRole) || isAdminRoleCode(originalUserRole.value);
|
||||
if (roleChanged) {
|
||||
roleConfirmMessage.value = touchesAdmin
|
||||
const message = touchesAdmin
|
||||
? t('admin.permRoles.userAdminConfirm')
|
||||
: t('admin.permRoles.userRoleConfirm', { role: nextRole });
|
||||
pendingUserSave = persistUser;
|
||||
showRoleConfirm.value = true;
|
||||
await confirmRoleThen(message, persistUser);
|
||||
return;
|
||||
}
|
||||
await persistUser();
|
||||
@@ -348,28 +358,6 @@ export function useUsersAdmin() {
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* 确认改角色(含管理员)后再提交。
|
||||
*/
|
||||
const confirmRoleChange = async (): Promise<void> => {
|
||||
const userSave = pendingUserSave;
|
||||
const batchSave = pendingBatchSave;
|
||||
pendingUserSave = null;
|
||||
pendingBatchSave = null;
|
||||
showRoleConfirm.value = false;
|
||||
if (userSave) {
|
||||
await userSave();
|
||||
return;
|
||||
}
|
||||
if (batchSave) await batchSave();
|
||||
};
|
||||
|
||||
const closeRoleConfirm = (): void => {
|
||||
pendingUserSave = null;
|
||||
pendingBatchSave = null;
|
||||
showRoleConfirm.value = false;
|
||||
};
|
||||
|
||||
const cleanRejectedUsers = async (): Promise<void> => {
|
||||
openDeleteConfirm(t('admin.user.confirmClean'), async () => {
|
||||
try {
|
||||
@@ -446,11 +434,10 @@ export function useUsersAdmin() {
|
||||
return;
|
||||
}
|
||||
if (data.role) {
|
||||
roleConfirmMessage.value = isAdminRoleCode(data.role)
|
||||
const message = isAdminRoleCode(data.role)
|
||||
? t('admin.permRoles.userAdminConfirm')
|
||||
: t('admin.permRoles.batchRoleConfirm');
|
||||
pendingBatchSave = () => persistBatchEdit(data);
|
||||
showRoleConfirm.value = true;
|
||||
await confirmRoleThen(message, () => persistBatchEdit(data));
|
||||
return;
|
||||
}
|
||||
await persistBatchEdit(data);
|
||||
@@ -504,6 +491,19 @@ export function useUsersAdmin() {
|
||||
scheduleLoadUsers(true);
|
||||
};
|
||||
|
||||
/**
|
||||
* 按指定列和方向重新查询第一页。
|
||||
* 核心逻辑:方向未变时不请求;变更后回到第一页再拉取。
|
||||
* @param key - username 或 department,与后端 sort_by 白名单一致
|
||||
* @param dir - asc 或 desc
|
||||
*/
|
||||
const applyServerSort = (key: UserSortKey, dir: 'asc' | 'desc'): void => {
|
||||
if (sortKey.value === key && sortDir.value === dir) return;
|
||||
sortKey.value = key;
|
||||
sortDir.value = dir;
|
||||
scheduleLoadUsers(true);
|
||||
};
|
||||
|
||||
return {
|
||||
users,
|
||||
agents,
|
||||
@@ -530,12 +530,9 @@ export function useUsersAdmin() {
|
||||
batchEditForm,
|
||||
showBatchPermissionModal,
|
||||
batchPermissionForm,
|
||||
showDeleteConfirmDialog,
|
||||
deleteConfirmMessage,
|
||||
showRoleConfirm,
|
||||
roleConfirmMessage,
|
||||
loadAll,
|
||||
toggleSort,
|
||||
applyServerSort,
|
||||
openCreateUserModal,
|
||||
openEditUserModal,
|
||||
saveUser,
|
||||
@@ -547,9 +544,5 @@ export function useUsersAdmin() {
|
||||
openBatchPermissionModal,
|
||||
submitBatchEdit,
|
||||
submitBatchPermission,
|
||||
closeDeleteConfirm,
|
||||
confirmDelete,
|
||||
confirmRoleChange,
|
||||
closeRoleConfirm,
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,110 @@
|
||||
/**
|
||||
* features/admin/styles/element-trial.css
|
||||
* 用途:管理端 Element Plus 的字体、字号、颜色、圆角、控件高度,以及和 Tailwind 共存的修正。
|
||||
* 依赖:tokens.css 的 --text-* / --bg-* / --border-*,element-plus 暗色变量,Tailwind preflight。
|
||||
* 逻辑:由 UsersPage、AgentsPage、KbAdminPanel 在暗色 CSS 之后引入,所以 html.dark 能盖过 Element 默认暗色。
|
||||
* 字号和颜色以本文变量为准。页面不要再用 text-sm / text-muted 改表格和按钮。
|
||||
*/
|
||||
|
||||
:root,
|
||||
html.dark {
|
||||
--el-color-primary: #0284c7;
|
||||
--el-color-primary-light-3: #4da3d6;
|
||||
--el-color-primary-light-5: #81c2e3;
|
||||
--el-color-primary-light-7: #b4daf0;
|
||||
--el-color-primary-light-8: #cde6f4;
|
||||
--el-color-primary-light-9: #e6f3fa;
|
||||
--el-color-primary-dark-2: #0269a0;
|
||||
--el-font-family: "PingFang SC", "Microsoft YaHei", "Segoe UI", system-ui, sans-serif;
|
||||
--el-font-size-extra-large: 20px;
|
||||
--el-font-size-large: 18px;
|
||||
--el-font-size-medium: 16px;
|
||||
--el-font-size-base: 14px;
|
||||
--el-font-size-small: 13px;
|
||||
--el-font-size-extra-small: 12px;
|
||||
--el-text-color-primary: var(--text-primary);
|
||||
--el-text-color-regular: var(--text-secondary);
|
||||
--el-text-color-secondary: var(--text-muted);
|
||||
--el-text-color-placeholder: var(--text-muted);
|
||||
--el-text-color-disabled: var(--text-muted);
|
||||
--el-border-color: var(--border-default);
|
||||
--el-border-color-light: var(--border-subtle);
|
||||
--el-border-color-lighter: var(--border-subtle);
|
||||
--el-bg-color: var(--bg-surface);
|
||||
--el-bg-color-overlay: var(--bg-surface);
|
||||
--el-fill-color-blank: var(--bg-surface);
|
||||
--el-fill-color-light: var(--bg-surface-soft);
|
||||
--el-border-radius-base: 8px;
|
||||
--el-component-size: 32px;
|
||||
}
|
||||
|
||||
.el-button {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.el-button .el-icon,
|
||||
.el-button svg {
|
||||
display: inline-flex;
|
||||
flex: none;
|
||||
}
|
||||
|
||||
/* Tailwind forms 会给单行输入框内部的 input 加边框。聚焦时左右两边会多出两条蓝线。
|
||||
多行输入框的边框就画在 .el-textarea__inner 上,不能一起清掉。 */
|
||||
.el-input__inner,
|
||||
.el-select__input,
|
||||
.el-range-input,
|
||||
.el-input__inner:hover,
|
||||
.el-select__input:hover,
|
||||
.el-range-input:hover,
|
||||
.el-input__inner:focus,
|
||||
.el-select__input:focus,
|
||||
.el-range-input:focus {
|
||||
border: 0;
|
||||
outline: none;
|
||||
background-color: transparent;
|
||||
box-shadow: none;
|
||||
--tw-ring-shadow: 0 0 #0000;
|
||||
--tw-ring-offset-shadow: 0 0 #0000;
|
||||
}
|
||||
|
||||
.el-textarea__inner {
|
||||
background-color: var(--el-input-bg-color, var(--el-fill-color-blank));
|
||||
box-shadow: 0 0 0 1px var(--el-input-border-color, var(--el-border-color)) inset;
|
||||
}
|
||||
|
||||
.el-textarea__inner:hover {
|
||||
box-shadow: 0 0 0 1px var(--el-input-hover-border-color, var(--el-border-color-hover)) inset;
|
||||
}
|
||||
|
||||
.el-textarea__inner:focus {
|
||||
outline: none;
|
||||
box-shadow: 0 0 0 1px var(--el-input-focus-border-color, var(--el-color-primary)) inset;
|
||||
--tw-ring-shadow: 0 0 #0000;
|
||||
--tw-ring-offset-shadow: 0 0 #0000;
|
||||
}
|
||||
|
||||
/* 列表首尾列与页头 32px 对齐;分页贴在表格下方 */
|
||||
.hx-admin-table .el-table__cell:first-child .cell {
|
||||
padding-left: 32px;
|
||||
}
|
||||
|
||||
.hx-admin-table .el-table__cell:last-child .cell {
|
||||
padding-right: 32px;
|
||||
}
|
||||
|
||||
.hx-admin-pager {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
padding: 12px 32px;
|
||||
border-top: 1px solid var(--el-border-color-lighter);
|
||||
}
|
||||
|
||||
/* 表单里的补充说明,字号和颜色走 Element 变量 */
|
||||
.hx-element-hint {
|
||||
margin-top: 4px;
|
||||
font-size: var(--el-font-size-extra-small);
|
||||
line-height: 1.4;
|
||||
color: var(--el-text-color-secondary);
|
||||
}
|
||||
@@ -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,
|
||||
|
||||
+166
-107
@@ -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>
|
||||
@@ -1,16 +1,20 @@
|
||||
<script setup lang="ts">
|
||||
/**
|
||||
* features/kb/components/DifyHealthDialog.vue
|
||||
* 知识库 Dify 健康检查弹窗。
|
||||
* 用途:展示知识库 Dify 连通性和本地同步计数。
|
||||
* 依赖:Element Plus、kb.api 的健康检查接口。
|
||||
* 逻辑:KbAdminPanel 打开本弹窗后拉取健康数据,失败时把文案交给父组件。结果用 Element 描述列表展示,不再套统计卡片。
|
||||
*/
|
||||
|
||||
import { ref, watch } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { ElAlert, ElButton, ElDescriptions, ElDescriptionsItem, ElDialog, ElLoading, ElTag } from 'element-plus';
|
||||
import { getKbDifyHealth, type KbDifyHealth } from '../api/kb.api';
|
||||
|
||||
const props = defineProps<{ open: boolean }>();
|
||||
const emit = defineEmits<{ close: []; error: [message: string] }>();
|
||||
const { t } = useI18n();
|
||||
const vLoading = ElLoading.directive;
|
||||
|
||||
const loading = ref(false);
|
||||
const payload = ref<KbDifyHealth | null>(null);
|
||||
@@ -30,54 +34,90 @@ watch(() => props.open, (open) => {
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div v-if="open" class="dialog-overlay" @click="close">
|
||||
<div class="dialog-panel max-w-4xl p-6" @click.stop>
|
||||
<div class="flex items-center justify-between gap-4">
|
||||
<div>
|
||||
<h3 class="section-title text-xl">{{ t('kbDifyHealth.title') }}</h3>
|
||||
<p class="section-desc mt-1">{{ t('kbDifyHealth.subtitle') }}</p>
|
||||
</div>
|
||||
<div class="flex items-center gap-3">
|
||||
<button type="button" class="btn-secondary btn-sm" @click="loadHealth">
|
||||
{{ t('common.refresh') }}
|
||||
</button>
|
||||
<button type="button" class="btn-secondary btn-sm" @click="close">
|
||||
{{ t('common.close') }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="loading" class="py-16 text-center text-sm text-muted">{{ t('kbDifyHealth.loading') }}</div>
|
||||
<div v-else-if="payload" class="mt-6 grid gap-4 md:grid-cols-2 xl:grid-cols-3">
|
||||
<div class="dialog-stat-card">
|
||||
<div class="label-field">Dify API</div>
|
||||
<div class="mt-3 text-2xl font-semibold text-primary">{{ payload.api.reachable ? t('kbDifyHealth.reachable') : t('kbDifyHealth.unreachable') }}</div>
|
||||
<div class="mt-2 break-all text-xs text-muted">{{ payload.dify_base_url || t('kbDifyHealth.notConfigured') }}</div>
|
||||
</div>
|
||||
<div class="dialog-stat-card">
|
||||
<div class="label-field">{{ t('kbDifyHealth.datasetCount') }}</div>
|
||||
<div class="mt-3 text-2xl font-semibold text-primary">{{ payload.api.dataset_count ?? '--' }}</div>
|
||||
<div class="mt-2 text-xs text-muted">{{ t('kbDifyHealth.configured') }}{{ payload.dify_api_configured ? t('common.yes') : t('common.no') }}</div>
|
||||
</div>
|
||||
<div class="dialog-stat-card">
|
||||
<div class="label-field">{{ t('kbDifyHealth.boundGroups') }}</div>
|
||||
<div class="mt-3 text-2xl font-semibold text-primary">{{ payload.local_sync_health.dataset_bound_groups }}</div>
|
||||
<div class="mt-2 text-xs text-muted">{{ t('kbDifyHealth.localSyncRecords') }}{{ payload.local_sync_health.sync_records }}</div>
|
||||
</div>
|
||||
<div class="dialog-stat-card">
|
||||
<div class="label-field">{{ t('kbDifyHealth.syncingVersions') }}</div>
|
||||
<div class="mt-3 text-2xl font-semibold text-primary">{{ payload.local_sync_health.syncing_versions }}</div>
|
||||
</div>
|
||||
<div class="dialog-stat-card">
|
||||
<div class="label-field">{{ t('kbDifyHealth.syncedVersions') }}</div>
|
||||
<div class="mt-3 text-2xl font-semibold text-primary">{{ payload.local_sync_health.synced_versions }}</div>
|
||||
</div>
|
||||
<div class="dialog-stat-card">
|
||||
<div class="label-field">{{ t('kbDifyHealth.pendingSyncJobs') }}</div>
|
||||
<div class="mt-3 text-2xl font-semibold text-primary">{{ payload.local_sync_health.pending_sync_jobs }}</div>
|
||||
<div v-if="payload.api.error" class="mt-2 text-xs text-rose-500">{{ payload.api.error }}</div>
|
||||
</div>
|
||||
</div>
|
||||
<ElDialog
|
||||
:model-value="open"
|
||||
:title="t('kbDifyHealth.title')"
|
||||
width="680px"
|
||||
align-center
|
||||
append-to-body
|
||||
:close-on-click-modal="false"
|
||||
@update:model-value="(value) => { if (!value) close(); }"
|
||||
>
|
||||
<p class="section-desc">{{ t('kbDifyHealth.subtitle') }}</p>
|
||||
<div v-loading="loading" class="dify-health-body">
|
||||
<template v-if="payload">
|
||||
<ElAlert
|
||||
v-if="payload.api.error"
|
||||
class="dify-health-alert"
|
||||
:title="payload.api.error"
|
||||
type="error"
|
||||
show-icon
|
||||
:closable="false"
|
||||
/>
|
||||
<ElDescriptions :column="1" border label-width="148px">
|
||||
<ElDescriptionsItem label="Dify API">
|
||||
<div class="dify-health-status">
|
||||
<ElTag :type="payload.api.reachable ? 'success' : 'danger'" effect="light">
|
||||
{{ payload.api.reachable ? t('kbDifyHealth.reachable') : t('kbDifyHealth.unreachable') }}
|
||||
</ElTag>
|
||||
<span class="hx-element-hint dify-health-url">{{ payload.dify_base_url || t('kbDifyHealth.notConfigured') }}</span>
|
||||
</div>
|
||||
</ElDescriptionsItem>
|
||||
<ElDescriptionsItem :label="t('kbDifyHealth.datasetCount')">
|
||||
{{ payload.api.dataset_count ?? '--' }}
|
||||
</ElDescriptionsItem>
|
||||
<ElDescriptionsItem :label="t('kbDifyHealth.configured')">
|
||||
{{ payload.dify_api_configured ? t('common.yes') : t('common.no') }}
|
||||
</ElDescriptionsItem>
|
||||
</ElDescriptions>
|
||||
<ElDescriptions class="dify-health-sync" :column="2" border label-width="148px">
|
||||
<ElDescriptionsItem :label="t('kbDifyHealth.boundGroups')">
|
||||
{{ payload.local_sync_health.dataset_bound_groups }}
|
||||
</ElDescriptionsItem>
|
||||
<ElDescriptionsItem :label="t('kbDifyHealth.localSyncRecords')">
|
||||
{{ payload.local_sync_health.sync_records }}
|
||||
</ElDescriptionsItem>
|
||||
<ElDescriptionsItem :label="t('kbDifyHealth.syncingVersions')">
|
||||
{{ payload.local_sync_health.syncing_versions }}
|
||||
</ElDescriptionsItem>
|
||||
<ElDescriptionsItem :label="t('kbDifyHealth.syncedVersions')">
|
||||
{{ payload.local_sync_health.synced_versions }}
|
||||
</ElDescriptionsItem>
|
||||
<ElDescriptionsItem :label="t('kbDifyHealth.pendingSyncJobs')" :span="2">
|
||||
{{ payload.local_sync_health.pending_sync_jobs }}
|
||||
</ElDescriptionsItem>
|
||||
</ElDescriptions>
|
||||
</template>
|
||||
</div>
|
||||
</div>
|
||||
<template #footer>
|
||||
<ElButton :loading="loading" @click="loadHealth">{{ t('common.refresh') }}</ElButton>
|
||||
<ElButton type="primary" @click="close">{{ t('common.close') }}</ElButton>
|
||||
</template>
|
||||
</ElDialog>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.dify-health-body {
|
||||
min-height: 8rem;
|
||||
margin-top: 16px;
|
||||
}
|
||||
|
||||
.dify-health-alert {
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
|
||||
.dify-health-status {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
gap: 8px 12px;
|
||||
}
|
||||
|
||||
.dify-health-url {
|
||||
word-break: break-all;
|
||||
}
|
||||
|
||||
.dify-health-sync {
|
||||
margin-top: 16px;
|
||||
}
|
||||
</style>
|
||||
@@ -2,17 +2,34 @@
|
||||
/**
|
||||
* features/kb/components/DifySettingsDialog.vue
|
||||
* 用途:提供知识库 Dify 连接及默认同步参数的查看、编辑和保存界面。
|
||||
* 依赖:Vue 响应式 API、Vue I18n、kb.api 的 Dify 设置读写接口。
|
||||
* 逻辑:KbAdminPanel 控制弹窗开关;本组件加载或保存设置后通过事件把结果反馈给父组件。
|
||||
* 依赖:Vue 响应式 API、Element Plus、Vue I18n、kb.api 的 Dify 设置读写接口。
|
||||
* 逻辑:KbAdminPanel 控制弹窗开关;本组件加载或保存设置后通过事件把结果反馈给父组件。表单按连接、检索、分段三块排,密钥默认遮挡;开关行按左标题、开关、右标题、数字四列对齐。
|
||||
*/
|
||||
|
||||
import { reactive, ref, watch } from 'vue';
|
||||
import { reactive, ref, useId, watch } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import {
|
||||
ElButton,
|
||||
ElDialog,
|
||||
ElForm,
|
||||
ElFormItem,
|
||||
ElInput,
|
||||
ElInputNumber,
|
||||
ElLoading,
|
||||
ElOption,
|
||||
ElSelect,
|
||||
ElSwitch,
|
||||
} from 'element-plus';
|
||||
import { getKbDifySettings, updateKbDifySettings } from '../api/kb.api';
|
||||
|
||||
const props = defineProps<{ open: boolean }>();
|
||||
const emit = defineEmits<{ close: []; saved: [message: string]; error: [message: string] }>();
|
||||
const { t } = useI18n();
|
||||
const vLoading = ElLoading.directive;
|
||||
const rerankLabelId = useId();
|
||||
const topKLabelId = useId();
|
||||
const scoreSwitchLabelId = useId();
|
||||
const scoreValueLabelId = useId();
|
||||
|
||||
const loading = ref(false);
|
||||
const saving = ref(false);
|
||||
@@ -108,94 +125,243 @@ watch(() => props.open, (open) => {
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div v-if="open" class="dialog-overlay" @click="close">
|
||||
<div class="dialog-panel max-w-3xl max-h-[92vh] overflow-y-auto" @click.stop>
|
||||
<div class="px-5 sm:px-8 pt-5 sm:pt-7 pb-4 border-b border-subtle flex items-center justify-between gap-4">
|
||||
<div>
|
||||
<h3 class="section-title">{{ t('kbDifySettings.title') }}</h3>
|
||||
<p class="section-desc mt-1">{{ t('kbDifySettings.subtitle') }}</p>
|
||||
</div>
|
||||
<button type="button" class="btn-secondary btn-sm" @click="close">
|
||||
{{ t('common.close') }}
|
||||
</button>
|
||||
<ElDialog
|
||||
:model-value="open"
|
||||
width="680px"
|
||||
align-center
|
||||
append-to-body
|
||||
:close-on-click-modal="false"
|
||||
@update:model-value="(value) => { if (!value) close(); }"
|
||||
>
|
||||
<template #header="{ titleId, titleClass }">
|
||||
<div class="dify-settings-heading">
|
||||
<span :id="titleId" :class="titleClass">{{ t('kbDifySettings.title') }}</span>
|
||||
<p class="dify-settings-subtitle">{{ t('kbDifySettings.subtitle') }}</p>
|
||||
</div>
|
||||
</template>
|
||||
<div v-loading="loading" class="dify-settings-body">
|
||||
<ElForm v-if="!loading" class="dify-settings-form" label-position="top" :model="form">
|
||||
<section class="dify-settings-section">
|
||||
<p class="dify-settings-section-title">{{ t('kbDifySettings.sections.connection') }}</p>
|
||||
<div class="dify-settings-panel dify-settings-stack">
|
||||
<ElFormItem :label="t('kbDifySettings.fields.baseUrl')">
|
||||
<ElInput v-model="form.DIFY_API_BASE" placeholder="https://api.dify.ai/v1" />
|
||||
</ElFormItem>
|
||||
<ElFormItem :label="t('kbDifySettings.fields.apiKey')">
|
||||
<ElInput v-model="form.DIFY_API_KEY" type="password" show-password autocomplete="off" placeholder="app-..." />
|
||||
</ElFormItem>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<div v-if="loading" class="px-5 sm:px-8 py-16 text-center text-sm text-muted">{{ t('kbDifySettings.loading') }}</div>
|
||||
<div v-else class="px-5 sm:px-8 py-5 grid gap-4 md:grid-cols-2">
|
||||
<label class="space-y-1.5">
|
||||
<span class="label-field block">{{ t('kbDifySettings.fields.baseUrl') }}</span>
|
||||
<input v-model="form.DIFY_API_BASE" class="input-field text-sm" placeholder="https://api.dify.ai/v1" />
|
||||
</label>
|
||||
<label class="space-y-1.5">
|
||||
<span class="label-field block">{{ t('kbDifySettings.fields.apiKey') }}</span>
|
||||
<input v-model="form.DIFY_API_KEY" class="input-field text-sm" placeholder="app-..." />
|
||||
</label>
|
||||
<label class="space-y-1.5">
|
||||
<span class="label-field block">{{ t('kbDifySettings.fields.permission') }}</span>
|
||||
<select v-model="form.KB_DIFY_PERMISSION" class="input-field text-sm">
|
||||
<option value="only_me">{{ t('kbDifySettings.options.permission.onlyMe') }}</option>
|
||||
<option value="all_team_members">{{ t('kbDifySettings.options.permission.allTeamMembers') }}</option>
|
||||
</select>
|
||||
</label>
|
||||
<label class="space-y-1.5">
|
||||
<span class="label-field block">{{ t('kbDifySettings.fields.indexingTechnique') }}</span>
|
||||
<select v-model="form.KB_DIFY_INDEXING_TECHNIQUE" class="input-field text-sm">
|
||||
<option value="high_quality">{{ t('kbDifySettings.options.indexingTechnique.highQuality') }}</option>
|
||||
<option value="economy">{{ t('kbDifySettings.options.indexingTechnique.economy') }}</option>
|
||||
</select>
|
||||
</label>
|
||||
<label class="space-y-1.5">
|
||||
<span class="label-field block">{{ t('kbDifySettings.fields.searchMethod') }}</span>
|
||||
<select v-model="form.KB_DIFY_SEARCH_METHOD" class="input-field text-sm">
|
||||
<option value="semantic_search">{{ t('kbDifySettings.options.searchMethod.semanticSearch') }}</option>
|
||||
<option value="hybrid_search">{{ t('kbDifySettings.options.searchMethod.hybridSearch') }}</option>
|
||||
<option value="full_text_search">{{ t('kbDifySettings.options.searchMethod.fullTextSearch') }}</option>
|
||||
</select>
|
||||
</label>
|
||||
<label class="space-y-1.5">
|
||||
<span class="label-field block">{{ t('kbDifySettings.fields.documentForm') }}</span>
|
||||
<select v-model="form.KB_DIFY_DOC_FORM" class="input-field text-sm">
|
||||
<option value="text_model">{{ t('kbDifySettings.options.documentForm.textModel') }}</option>
|
||||
</select>
|
||||
</label>
|
||||
<label class="flex items-center gap-2 space-y-0">
|
||||
<input v-model="form.KB_DIFY_RERANKING_ENABLE" type="checkbox" class="h-4 w-4" />
|
||||
<span class="label-field">{{ t('kbDifySettings.fields.rerankingEnable') }}</span>
|
||||
</label>
|
||||
<label class="space-y-1.5">
|
||||
<span class="label-field block">{{ t('kbDifySettings.fields.topK') }}</span>
|
||||
<input v-model.number="form.KB_DIFY_TOP_K" type="number" min="1" max="10" step="1" class="input-field text-sm" />
|
||||
</label>
|
||||
<label class="flex items-center gap-2 space-y-0">
|
||||
<input v-model="form.KB_DIFY_SCORE_THRESHOLD_ENABLED" type="checkbox" class="h-4 w-4" />
|
||||
<span class="label-field">{{ t('kbDifySettings.fields.scoreThresholdEnabled') }}</span>
|
||||
</label>
|
||||
<label class="space-y-1.5">
|
||||
<span class="label-field block">{{ t('kbDifySettings.fields.scoreThreshold') }}</span>
|
||||
<input v-model.number="form.KB_DIFY_SCORE_THRESHOLD" type="number" min="0" max="1" step="0.01" class="input-field text-sm" :disabled="!form.KB_DIFY_SCORE_THRESHOLD_ENABLED" />
|
||||
</label>
|
||||
<label class="space-y-1.5">
|
||||
<span class="label-field block">{{ t('kbDifySettings.fields.segmentMaxTokens') }}</span>
|
||||
<input v-model.number="form.KB_DIFY_SEGMENT_MAX_TOKENS" type="number" min="1" step="1" class="input-field text-sm" />
|
||||
</label>
|
||||
<label class="space-y-1.5">
|
||||
<span class="label-field block">{{ t('kbDifySettings.fields.segmentMaxTokensExcel') }}</span>
|
||||
<input v-model.number="form.KB_DIFY_SEGMENT_MAX_TOKENS_EXCEL" type="number" min="1" step="1" class="input-field text-sm" />
|
||||
</label>
|
||||
<label class="space-y-1.5">
|
||||
<span class="label-field block">{{ t('kbDifySettings.fields.segmentChunkOverlap') }}</span>
|
||||
<input v-model.number="form.KB_DIFY_SEGMENT_CHUNK_OVERLAP" type="number" min="0" step="1" class="input-field text-sm" />
|
||||
</label>
|
||||
</div>
|
||||
<section class="dify-settings-section">
|
||||
<p class="dify-settings-section-title">{{ t('kbDifySettings.sections.retrieval') }}</p>
|
||||
<div class="dify-settings-panel">
|
||||
<div class="dify-settings-grid">
|
||||
<ElFormItem :label="t('kbDifySettings.fields.permission')">
|
||||
<ElSelect v-model="form.KB_DIFY_PERMISSION">
|
||||
<ElOption value="only_me" :label="t('kbDifySettings.options.permission.onlyMe')" />
|
||||
<ElOption value="all_team_members" :label="t('kbDifySettings.options.permission.allTeamMembers')" />
|
||||
</ElSelect>
|
||||
</ElFormItem>
|
||||
<ElFormItem :label="t('kbDifySettings.fields.indexingTechnique')">
|
||||
<ElSelect v-model="form.KB_DIFY_INDEXING_TECHNIQUE">
|
||||
<ElOption value="high_quality" :label="t('kbDifySettings.options.indexingTechnique.highQuality')" />
|
||||
<ElOption value="economy" :label="t('kbDifySettings.options.indexingTechnique.economy')" />
|
||||
</ElSelect>
|
||||
</ElFormItem>
|
||||
<ElFormItem :label="t('kbDifySettings.fields.searchMethod')">
|
||||
<ElSelect v-model="form.KB_DIFY_SEARCH_METHOD">
|
||||
<ElOption value="semantic_search" :label="t('kbDifySettings.options.searchMethod.semanticSearch')" />
|
||||
<ElOption value="hybrid_search" :label="t('kbDifySettings.options.searchMethod.hybridSearch')" />
|
||||
<ElOption value="full_text_search" :label="t('kbDifySettings.options.searchMethod.fullTextSearch')" />
|
||||
</ElSelect>
|
||||
</ElFormItem>
|
||||
<ElFormItem :label="t('kbDifySettings.fields.documentForm')">
|
||||
<ElSelect v-model="form.KB_DIFY_DOC_FORM">
|
||||
<ElOption value="text_model" :label="t('kbDifySettings.options.documentForm.textModel')" />
|
||||
</ElSelect>
|
||||
</ElFormItem>
|
||||
</div>
|
||||
|
||||
<div class="admin-modal-footer">
|
||||
<button type="button" class="btn-ghost" @click="close">
|
||||
{{ t('common.cancel') }}
|
||||
</button>
|
||||
<button type="button" class="btn-primary" :disabled="saving" @click="save">
|
||||
{{ saving ? t('kbDifySettings.saving') : t('kbDifySettings.save') }}
|
||||
</button>
|
||||
</div>
|
||||
<div class="dify-settings-switch-grid">
|
||||
<div class="dify-settings-switch-row">
|
||||
<span :id="rerankLabelId">{{ t('kbDifySettings.fields.rerankingEnable') }}</span>
|
||||
<ElSwitch v-model="form.KB_DIFY_RERANKING_ENABLE" :aria-labelledby="rerankLabelId" />
|
||||
<span :id="topKLabelId">{{ t('kbDifySettings.fields.topK') }}</span>
|
||||
<ElInputNumber
|
||||
v-model="form.KB_DIFY_TOP_K"
|
||||
:min="1"
|
||||
:max="10"
|
||||
:step="1"
|
||||
controls-position="right"
|
||||
:aria-labelledby="topKLabelId"
|
||||
/>
|
||||
</div>
|
||||
<div class="dify-settings-switch-row">
|
||||
<span :id="scoreSwitchLabelId">{{ t('kbDifySettings.fields.scoreThresholdEnabled') }}</span>
|
||||
<ElSwitch v-model="form.KB_DIFY_SCORE_THRESHOLD_ENABLED" :aria-labelledby="scoreSwitchLabelId" />
|
||||
<span :id="scoreValueLabelId">{{ t('kbDifySettings.fields.scoreThreshold') }}</span>
|
||||
<ElInputNumber
|
||||
v-model="form.KB_DIFY_SCORE_THRESHOLD"
|
||||
:min="0"
|
||||
:max="1"
|
||||
:step="0.01"
|
||||
:precision="2"
|
||||
controls-position="right"
|
||||
:disabled="!form.KB_DIFY_SCORE_THRESHOLD_ENABLED"
|
||||
:aria-labelledby="scoreValueLabelId"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="dify-settings-section">
|
||||
<p class="dify-settings-section-title">{{ t('kbDifySettings.sections.chunking') }}</p>
|
||||
<div class="dify-settings-panel dify-settings-segments">
|
||||
<ElFormItem :label="t('kbDifySettings.fields.segmentMaxTokens')">
|
||||
<ElInputNumber v-model="form.KB_DIFY_SEGMENT_MAX_TOKENS" :min="1" :step="1" controls-position="right" />
|
||||
<p class="dify-settings-hint">{{ t('kbDifySettings.hints.maxTokens') }}</p>
|
||||
</ElFormItem>
|
||||
<ElFormItem :label="t('kbDifySettings.fields.segmentMaxTokensExcel')">
|
||||
<ElInputNumber v-model="form.KB_DIFY_SEGMENT_MAX_TOKENS_EXCEL" :min="1" :step="1" controls-position="right" />
|
||||
<p class="dify-settings-hint">{{ t('kbDifySettings.hints.maxTokens') }}</p>
|
||||
</ElFormItem>
|
||||
<ElFormItem :label="t('kbDifySettings.fields.segmentChunkOverlap')">
|
||||
<ElInputNumber v-model="form.KB_DIFY_SEGMENT_CHUNK_OVERLAP" :min="0" :step="1" controls-position="right" />
|
||||
<p class="dify-settings-hint">{{ t('kbDifySettings.hints.tokens') }}</p>
|
||||
</ElFormItem>
|
||||
</div>
|
||||
</section>
|
||||
</ElForm>
|
||||
</div>
|
||||
</div>
|
||||
<template #footer>
|
||||
<ElButton @click="close">{{ t('common.cancel') }}</ElButton>
|
||||
<ElButton type="primary" :loading="saving" @click="save">{{ t('kbDifySettings.save') }}</ElButton>
|
||||
</template>
|
||||
</ElDialog>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.dify-settings-heading {
|
||||
padding-right: 24px;
|
||||
}
|
||||
|
||||
.dify-settings-subtitle {
|
||||
margin: 4px 0 0;
|
||||
color: var(--el-text-color-secondary);
|
||||
font-size: var(--el-font-size-extra-small);
|
||||
font-weight: 400;
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
.dify-settings-body {
|
||||
min-height: 8rem;
|
||||
}
|
||||
|
||||
.dify-settings-section + .dify-settings-section {
|
||||
margin-top: 16px;
|
||||
}
|
||||
|
||||
.dify-settings-section-title {
|
||||
margin: 0 0 8px;
|
||||
color: var(--el-text-color-primary);
|
||||
font-size: var(--el-font-size-base);
|
||||
font-weight: 600;
|
||||
line-height: 1.4;
|
||||
}
|
||||
|
||||
.dify-settings-panel {
|
||||
padding: 16px;
|
||||
border: 1px solid var(--el-border-color-lighter);
|
||||
border-radius: var(--el-border-radius-base);
|
||||
}
|
||||
|
||||
.dify-settings-stack,
|
||||
.dify-settings-grid,
|
||||
.dify-settings-segments {
|
||||
display: grid;
|
||||
gap: 12px 16px;
|
||||
}
|
||||
|
||||
.dify-settings-grid,
|
||||
.dify-settings-segments {
|
||||
grid-template-columns: 1fr 1fr;
|
||||
}
|
||||
|
||||
.dify-settings-segments {
|
||||
grid-template-columns: 1fr 1fr 1fr;
|
||||
}
|
||||
|
||||
.dify-settings-form :deep(.el-form-item) {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.dify-settings-form :deep(.el-form-item__label) {
|
||||
margin-bottom: 4px;
|
||||
line-height: 1.4;
|
||||
}
|
||||
|
||||
.dify-settings-form :deep(.el-select),
|
||||
.dify-settings-stack :deep(.el-input),
|
||||
.dify-settings-segments :deep(.el-input-number) {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.dify-settings-segments :deep(.el-form-item__content) {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: stretch;
|
||||
}
|
||||
|
||||
.dify-settings-hint {
|
||||
margin: 4px 0 0;
|
||||
color: var(--el-text-color-secondary);
|
||||
font-size: var(--el-font-size-extra-small);
|
||||
line-height: 1.4;
|
||||
}
|
||||
|
||||
.dify-settings-switch-grid {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(0, 1fr) auto max-content 8.5rem;
|
||||
column-gap: 16px;
|
||||
}
|
||||
|
||||
.dify-settings-switch-row {
|
||||
display: grid;
|
||||
grid-template-columns: subgrid;
|
||||
grid-column: 1 / -1;
|
||||
align-items: center;
|
||||
margin-top: 12px;
|
||||
padding-top: 12px;
|
||||
border-top: 1px solid var(--el-border-color-lighter);
|
||||
color: var(--el-text-color-regular);
|
||||
font-size: var(--el-font-size-base);
|
||||
line-height: 1.4;
|
||||
}
|
||||
|
||||
.dify-settings-form :deep(.el-input-number .el-input__inner) {
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.dify-settings-switch-row :deep(.el-input-number) {
|
||||
width: 8.5rem;
|
||||
}
|
||||
|
||||
@media (max-width: 640px) {
|
||||
.dify-settings-grid,
|
||||
.dify-settings-segments {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
|
||||
.dify-settings-switch-grid,
|
||||
.dify-settings-switch-row {
|
||||
grid-template-columns: 1fr;
|
||||
row-gap: 8px;
|
||||
}
|
||||
|
||||
.dify-settings-switch-row :deep(.el-input-number) {
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -2,28 +2,33 @@
|
||||
/**
|
||||
* features/kb/components/KbAdminPanel.vue
|
||||
* 知识库配置面板(治理面:分组、Dify)。
|
||||
* 依赖:kb.api、DifySettingsDialog、DifyHealthDialog、DeleteConfirmDialog、Vue I18n。
|
||||
* 逻辑:管理控制台加载知识库分组;分组列表在主表格过滤排序,新增/编辑通过右侧抽屉提交。
|
||||
* 依赖:kb.api、Element Plus、DifySettingsDialog、DifyHealthDialog、Vue I18n。
|
||||
* 逻辑:管理控制台加载知识库分组;列表、表头排序、文档数筛选、分页和删除确认用 Element。排序和筛选都作用在全量数据上,再分页。新增/编辑走 KbGroupDrawer。
|
||||
*/
|
||||
|
||||
import { computed, onMounted, ref, watch } from 'vue';
|
||||
import { useRouter } from 'vue-router';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { CircleCheck, Plus, Search, Setting, Tools } from '@element-plus/icons-vue';
|
||||
import {
|
||||
Activity,
|
||||
Pencil,
|
||||
Plus,
|
||||
RefreshCw,
|
||||
Search,
|
||||
Settings,
|
||||
Trash2,
|
||||
Wrench,
|
||||
} from 'lucide-vue-next';
|
||||
ElAlert,
|
||||
ElButton,
|
||||
ElConfigProvider,
|
||||
ElInput,
|
||||
ElLoading,
|
||||
ElMessageBox,
|
||||
ElPagination,
|
||||
ElSpace,
|
||||
ElTable,
|
||||
ElTableColumn,
|
||||
} from 'element-plus';
|
||||
import 'element-plus/dist/index.css';
|
||||
import 'element-plus/theme-chalk/dark/css-vars.css';
|
||||
import '@/features/admin/styles/element-trial.css';
|
||||
import { useElementProvider } from '@/features/admin/composables/useElementProvider';
|
||||
import KbGroupDrawer, { type KbGroupFormValue } from './KbGroupDrawer.vue';
|
||||
import DifyHealthDialog from './DifyHealthDialog.vue';
|
||||
import DifySettingsDialog from './DifySettingsDialog.vue';
|
||||
import DeleteConfirmDialog from '@/shared/components/DeleteConfirmDialog.vue';
|
||||
import PaginationBar from '@/shared/components/PaginationBar.vue';
|
||||
import { WORKSPACE_PATHS } from '@/features/workspace/constants/routes';
|
||||
import {
|
||||
createKbGroup,
|
||||
@@ -35,35 +40,42 @@ import {
|
||||
import { formatDateTime } from '../utils/kb-display.utils';
|
||||
|
||||
type GroupFilterMode = 'all' | 'withDocs' | 'empty';
|
||||
type GroupSortMode = 'updatedDesc' | 'updatedAsc' | 'docsDesc' | 'docsAsc' | 'nameAsc';
|
||||
type GroupSortKey = 'name' | 'document_count' | 'updated_at';
|
||||
|
||||
const router = useRouter();
|
||||
const { t } = useI18n();
|
||||
const { elementLocale } = useElementProvider();
|
||||
const vLoading = ElLoading.directive;
|
||||
|
||||
const groups = ref<KbGroup[]>([]);
|
||||
const isSubmitting = ref(false);
|
||||
const isDeleting = ref(false);
|
||||
const isRefreshing = ref(false);
|
||||
const isRefreshing = ref(true);
|
||||
const editingGroupId = ref<number | null>(null);
|
||||
const form = ref<KbGroupFormValue>({ name: '', description: '' });
|
||||
const feedback = ref('');
|
||||
const feedbackType = ref<'success' | 'error' | ''>('');
|
||||
const settingsDialogOpen = ref(false);
|
||||
const healthDialogOpen = ref(false);
|
||||
const deleteDialogOpen = ref(false);
|
||||
const drawerOpen = ref(false);
|
||||
const deletingGroup = ref<KbGroup | null>(null);
|
||||
const searchKeyword = ref('');
|
||||
const filterMode = ref<GroupFilterMode>('all');
|
||||
const sortMode = ref<GroupSortMode>('updatedDesc');
|
||||
const sortKey = ref<GroupSortKey | ''>('updated_at');
|
||||
const sortDir = ref<'asc' | 'desc' | ''>('desc');
|
||||
const currentPage = ref(1);
|
||||
const pageSize = ref(20);
|
||||
|
||||
const filterOptions: GroupFilterMode[] = ['all', 'withDocs', 'empty'];
|
||||
const sortOptions: GroupSortMode[] = ['updatedDesc', 'updatedAsc', 'docsDesc', 'docsAsc', 'nameAsc'];
|
||||
const pageSizeOptions = [10, 20, 50, 100];
|
||||
|
||||
const totalDocuments = computed(() => groups.value.reduce((total, group) => total + (group.document_count ?? 0), 0));
|
||||
/**
|
||||
* 文档数表头筛选项。
|
||||
* 核心逻辑:不放「全部」;Element 筛选面板的重置会清空条件,等同于全部。
|
||||
*/
|
||||
const documentFilters = computed(() => [
|
||||
{ text: t('kbAdmin.filters.withDocs'), value: 'withDocs' },
|
||||
{ text: t('kbAdmin.filters.empty'), value: 'empty' },
|
||||
]);
|
||||
|
||||
const filteredGroups = computed(() => {
|
||||
const keyword = searchKeyword.value.trim().toLowerCase();
|
||||
const matched = groups.value.filter((group) => {
|
||||
@@ -77,16 +89,17 @@ const filteredGroups = computed(() => {
|
||||
return matchesKeyword && matchesFilter;
|
||||
});
|
||||
|
||||
if (!sortKey.value || !sortDir.value) return matched;
|
||||
return [...matched].sort((a, b) => {
|
||||
const docsA = a.document_count ?? 0;
|
||||
const docsB = b.document_count ?? 0;
|
||||
const updatedA = Date.parse(a.updated_at || '') || 0;
|
||||
const updatedB = Date.parse(b.updated_at || '') || 0;
|
||||
if (sortMode.value === 'updatedAsc') return updatedA - updatedB;
|
||||
if (sortMode.value === 'docsDesc') return docsB - docsA;
|
||||
if (sortMode.value === 'docsAsc') return docsA - docsB;
|
||||
if (sortMode.value === 'nameAsc') return a.name.localeCompare(b.name, undefined, { numeric: true });
|
||||
return updatedB - updatedA;
|
||||
let result = 0;
|
||||
if (sortKey.value === 'name') {
|
||||
result = a.name.localeCompare(b.name, undefined, { numeric: true });
|
||||
} else if (sortKey.value === 'document_count') {
|
||||
result = (a.document_count ?? 0) - (b.document_count ?? 0);
|
||||
} else {
|
||||
result = (Date.parse(a.updated_at || '') || 0) - (Date.parse(b.updated_at || '') || 0);
|
||||
}
|
||||
return sortDir.value === 'asc' ? result : -result;
|
||||
});
|
||||
});
|
||||
const pagedGroups = computed(() => {
|
||||
@@ -94,19 +107,33 @@ const pagedGroups = computed(() => {
|
||||
return filteredGroups.value.slice(start, start + pageSize.value);
|
||||
});
|
||||
|
||||
/**
|
||||
* 表格空状态文案。
|
||||
* 核心逻辑:一个分组都没有时提示去创建;有分组但筛选后为空时提示调整条件。
|
||||
*/
|
||||
const tableEmptyText = computed(() => (
|
||||
groups.value.length === 0 ? t('kbAdmin.groupsEmpty') : t('kbAdmin.filters.emptyResult')
|
||||
));
|
||||
|
||||
/** 格式化分组更新时间,避免管理台表格直接暴露后端 ISO 时间字符串。 */
|
||||
const formatGroupUpdatedAt = (value?: string | null) => formatDateTime(value);
|
||||
|
||||
/** 加载知识库治理页的分组数据,供页面初始渲染和操作后刷新复用。 */
|
||||
/**
|
||||
* 加载知识库治理页的分组数据,供页面初始渲染和操作后刷新复用。
|
||||
* 核心逻辑:只等分组列表;失败写入页面提示,并用 finally 关掉表格加载态。
|
||||
*/
|
||||
const loadData = async () => {
|
||||
isRefreshing.value = true;
|
||||
const groupsResult = await getKbGroupsSafe();
|
||||
if (groupsResult.ok) groups.value = groupsResult.data;
|
||||
else {
|
||||
feedback.value = groupsResult.error || t('kbAdmin.msg.loadGroupsFailed');
|
||||
feedbackType.value = 'error';
|
||||
try {
|
||||
const groupsResult = await getKbGroupsSafe();
|
||||
if (groupsResult.ok) groups.value = groupsResult.data;
|
||||
else {
|
||||
feedback.value = groupsResult.error || t('kbAdmin.msg.loadGroupsFailed');
|
||||
feedbackType.value = 'error';
|
||||
}
|
||||
} finally {
|
||||
isRefreshing.value = false;
|
||||
}
|
||||
isRefreshing.value = false;
|
||||
};
|
||||
|
||||
/** 重置分组表单到新建状态,关闭抽屉或切换新建时清空当前编辑对象。 */
|
||||
@@ -162,17 +189,27 @@ const handleSubmitGroup = async () => {
|
||||
await loadData();
|
||||
};
|
||||
|
||||
/** 打开分组删除确认弹窗,确认前不直接调用删除接口。 */
|
||||
const handleDeleteGroup = (group: KbGroup) => {
|
||||
deletingGroup.value = group;
|
||||
deleteDialogOpen.value = true;
|
||||
};
|
||||
|
||||
/** 确认删除当前选中的分组,并在成功后同步刷新列表与编辑表单状态。 */
|
||||
const handleDeleteGroupConfirm = async () => {
|
||||
if (!deletingGroup.value) return;
|
||||
/**
|
||||
* 确认后删除分组,并刷新列表。
|
||||
* 核心逻辑:Element 确认框取消会 reject,这里直接返回,不调用删除接口。
|
||||
* @param group - 待删除的分组
|
||||
*/
|
||||
const handleDeleteGroup = async (group: KbGroup) => {
|
||||
try {
|
||||
await ElMessageBox.confirm(
|
||||
t('kbAdmin.deleteDialog.message', { name: group.name }),
|
||||
t('kbAdmin.deleteDialog.title'),
|
||||
{
|
||||
type: 'warning',
|
||||
confirmButtonText: t('common.deleteDialog.confirm'),
|
||||
cancelButtonText: t('common.deleteDialog.cancel'),
|
||||
},
|
||||
);
|
||||
} catch {
|
||||
return;
|
||||
}
|
||||
isDeleting.value = true;
|
||||
const result = await deleteKbGroup(deletingGroup.value.id);
|
||||
const result = await deleteKbGroup(group.id);
|
||||
isDeleting.value = false;
|
||||
if (!result.ok) {
|
||||
feedback.value = result.error || t('kbAdmin.msg.deleteFailed');
|
||||
@@ -180,15 +217,46 @@ const handleDeleteGroupConfirm = async () => {
|
||||
return;
|
||||
}
|
||||
|
||||
if (editingGroupId.value === deletingGroup.value.id) closeDrawer();
|
||||
if (editingGroupId.value === group.id) closeDrawer();
|
||||
feedback.value = t('kbAdmin.msg.deleted');
|
||||
feedbackType.value = 'success';
|
||||
deleteDialogOpen.value = false;
|
||||
deletingGroup.value = null;
|
||||
await loadData();
|
||||
};
|
||||
|
||||
watch([searchKeyword, filterMode, sortMode, pageSize], () => {
|
||||
/**
|
||||
* 按文档数表头筛选全部分组,并回到第一页。
|
||||
* 核心逻辑:筛选发生在分页之前。未选或重置时显示全部;单选时只留有文档或空分组。
|
||||
* @param filters - Element 按 column-key 给出的已选值
|
||||
*/
|
||||
function onFilterChange(filters: Record<string, string[]>): void {
|
||||
const selected = filters.document_count ?? [];
|
||||
if (selected.length === 1 && (selected[0] === 'withDocs' || selected[0] === 'empty')) {
|
||||
filterMode.value = selected[0];
|
||||
} else {
|
||||
filterMode.value = 'all';
|
||||
}
|
||||
currentPage.value = 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* 按表头把筛选后的全部分组重排,并回到第一页。
|
||||
* 核心逻辑:排序发生在分页之前,所以翻页后顺序不变。第三次点击表头时 Element 清空排序,列表回到接口原顺序。
|
||||
* @param payload.prop - 列字段
|
||||
* @param payload.order - ascending、descending 或空
|
||||
*/
|
||||
function onSortChange(payload: { prop: string | null; order: string | null }): void {
|
||||
const field = payload.prop;
|
||||
if ((field === 'name' || field === 'document_count' || field === 'updated_at') && payload.order) {
|
||||
sortKey.value = field;
|
||||
sortDir.value = payload.order === 'ascending' ? 'asc' : 'desc';
|
||||
} else {
|
||||
sortKey.value = '';
|
||||
sortDir.value = '';
|
||||
}
|
||||
currentPage.value = 1;
|
||||
}
|
||||
|
||||
watch([searchKeyword, pageSize], () => {
|
||||
currentPage.value = 1;
|
||||
});
|
||||
|
||||
@@ -200,142 +268,98 @@ defineExpose({ loadData });
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="animate-fade-in-up">
|
||||
<div class="kb-admin-header">
|
||||
<ElConfigProvider :locale="elementLocale">
|
||||
<section class="admin-table-section">
|
||||
<div class="admin-table-header admin-table-header--stacked">
|
||||
<div class="min-w-0 flex-1">
|
||||
<h2 class="text-xl font-bold text-primary">{{ t('kbAdmin.groupsTitle') }}</h2>
|
||||
<h2 class="section-title">{{ t('kbAdmin.groupsTitle') }}</h2>
|
||||
<p class="section-desc mt-1">{{ t('kbAdmin.groupManageSubtitle') }}</p>
|
||||
</div>
|
||||
<div class="flex w-full shrink-0 flex-col gap-2 sm:w-auto sm:flex-row sm:items-center sm:justify-end">
|
||||
<div class="kb-admin-toolbar" role="toolbar" :aria-label="t('kbAdmin.toolbar')">
|
||||
<button type="button" class="kb-admin-toolbar-btn" @click="settingsDialogOpen = true" :title="t('kbAdmin.difySettings')">
|
||||
<Settings class="h-4 w-4 shrink-0" />
|
||||
<span class="whitespace-nowrap">{{ t('kbAdmin.difySettings') }}</span>
|
||||
</button>
|
||||
<button type="button" class="kb-admin-toolbar-btn" @click="healthDialogOpen = true" :title="t('kbAdmin.healthCheck')">
|
||||
<Activity class="h-4 w-4 shrink-0" />
|
||||
<span class="whitespace-nowrap">{{ t('kbAdmin.healthCheck') }}</span>
|
||||
</button>
|
||||
<button type="button" class="kb-admin-toolbar-btn" @click="loadData" :title="t('common.refresh')">
|
||||
<RefreshCw class="h-4 w-4 shrink-0" :class="{ 'animate-spin': isRefreshing }" />
|
||||
<span class="whitespace-nowrap">{{ t('common.refresh') }}</span>
|
||||
</button>
|
||||
</div>
|
||||
<button type="button" class="btn-secondary inline-flex w-full items-center justify-center gap-2 px-4 py-2.5 text-sm sm:w-auto" @click="router.push(WORKSPACE_PATHS.knowledgeBase)">
|
||||
<Wrench class="h-4 w-4 shrink-0" />
|
||||
<span class="whitespace-nowrap">{{ t('kbAdmin.goWorkspace') }}</span>
|
||||
</button>
|
||||
<button type="button" class="btn-primary inline-flex w-full items-center justify-center gap-2 px-4 py-2.5 text-sm sm:w-auto" @click="openCreateDrawer">
|
||||
<Plus class="h-4 w-4 shrink-0" />
|
||||
<span class="whitespace-nowrap">{{ t('kbAdmin.form.create') }}</span>
|
||||
</button>
|
||||
</div>
|
||||
<ElSpace wrap>
|
||||
<ElButton :icon="Setting" @click="settingsDialogOpen = true">{{ t('kbAdmin.difySettings') }}</ElButton>
|
||||
<ElButton :icon="CircleCheck" @click="healthDialogOpen = true">{{ t('kbAdmin.healthCheck') }}</ElButton>
|
||||
<ElButton :icon="Tools" @click="router.push(WORKSPACE_PATHS.knowledgeBase)">{{ t('kbAdmin.goWorkspace') }}</ElButton>
|
||||
<ElButton type="primary" :icon="Plus" @click="openCreateDrawer">{{ t('kbAdmin.form.create') }}</ElButton>
|
||||
</ElSpace>
|
||||
</div>
|
||||
|
||||
<div class="kb-admin-body">
|
||||
<section class="admin-table-section">
|
||||
<div class="admin-table-filters flex flex-col gap-4">
|
||||
<div class="grid grid-cols-1 gap-3 lg:grid-cols-[minmax(16rem,1fr)_auto_minmax(11rem,14rem)] lg:items-center">
|
||||
<label class="relative min-w-0">
|
||||
<Search class="pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted" />
|
||||
<input v-model="searchKeyword" class="input-field w-full pl-9" :placeholder="t('kbAdmin.filters.searchPlaceholder')" />
|
||||
</label>
|
||||
<div class="inline-flex w-full overflow-hidden rounded-xl border border-default bg-surface lg:w-auto">
|
||||
<button
|
||||
v-for="option in filterOptions"
|
||||
:key="option"
|
||||
type="button"
|
||||
class="min-w-0 flex-1 whitespace-nowrap px-4 py-2.5 text-sm font-medium text-secondary transition-colors hover:bg-surface-soft hover:text-primary lg:flex-none"
|
||||
:class="{ 'bg-brand-50 text-brand-700': filterMode === option }"
|
||||
@click="filterMode = option"
|
||||
>
|
||||
{{ t(`kbAdmin.filters.${option}`) }}
|
||||
</button>
|
||||
</div>
|
||||
<select v-model="sortMode" class="select-field w-full">
|
||||
<option v-for="option in sortOptions" :key="option" :value="option">
|
||||
{{ t(`kbAdmin.sort.${option}`) }}
|
||||
</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="flex flex-wrap items-center gap-3 text-xs text-muted">
|
||||
<span>{{ t('kbAdmin.stats.groups', { count: groups.length }) }}</span>
|
||||
<span>{{ t('kbAdmin.stats.documents', { count: totalDocuments }) }}</span>
|
||||
<span>{{ t('kbAdmin.stats.visible', { count: filteredGroups.length }) }}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<p v-if="feedback" class="mx-6 mt-4 rounded-xl border px-4 py-3 text-sm" :class="feedbackType === 'error' ? 'border-rose-200 bg-rose-50 text-rose-600' : 'border-emerald-200 bg-emerald-50 text-emerald-700'">
|
||||
{{ feedback }}
|
||||
</p>
|
||||
|
||||
<div v-if="groups.length === 0" class="admin-table-empty">{{ t('kbAdmin.groupsEmpty') }}</div>
|
||||
<div v-else-if="filteredGroups.length === 0" class="admin-table-empty">{{ t('kbAdmin.filters.emptyResult') }}</div>
|
||||
<div v-else>
|
||||
<div class="admin-table-wrap hidden md:block">
|
||||
<table class="admin-table table-fixed">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="w-[20%] px-6 py-3 text-xs">{{ t('kbAdmin.table.name') }}</th>
|
||||
<th class="w-[30%] px-6 py-3 text-xs">{{ t('kbAdmin.table.description') }}</th>
|
||||
<th class="w-[12%] px-6 py-3 text-xs">{{ t('kbAdmin.table.documents') }}</th>
|
||||
<th class="w-[26%] px-6 py-3 text-xs">{{ t('kbAdmin.table.updatedAt') }}</th>
|
||||
<th class="w-[12%] px-6 py-3 text-right text-xs">{{ t('kbAdmin.table.actions') }}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-for="group in pagedGroups" :key="group.id">
|
||||
<td class="px-6 py-4 align-middle"><div class="truncate font-semibold text-primary" :title="group.name">{{ group.name }}</div></td>
|
||||
<td class="px-6 py-4 align-middle text-sm text-muted">
|
||||
<div class="truncate" :title="group.description || t('kbAdmin.noDescription')">
|
||||
{{ group.description || t('kbAdmin.noDescription') }}
|
||||
</div>
|
||||
</td>
|
||||
<td class="px-6 py-4 align-middle"><span class="kb-admin-badge whitespace-nowrap">{{ group.document_count ?? 0 }}</span></td>
|
||||
<td class="px-6 py-4 align-middle text-sm text-muted"><div class="truncate" :title="formatGroupUpdatedAt(group.updated_at)">{{ formatGroupUpdatedAt(group.updated_at) }}</div></td>
|
||||
<td class="px-6 py-4 align-middle">
|
||||
<div class="flex justify-end gap-1.5">
|
||||
<button type="button" class="btn-icon-ds border border-default" @click="openEditDrawer(group)" :title="t('common.edit')"><Pencil class="h-4 w-4" /></button>
|
||||
<button type="button" class="btn-icon-ds border border-rose-200 text-rose-600 hover:bg-rose-50" @click="handleDeleteGroup(group)" :disabled="isDeleting" :title="t('common.delete')"><Trash2 class="h-4 w-4" /></button>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<div class="space-y-3 p-4 md:hidden">
|
||||
<article v-for="group in pagedGroups" :key="group.id" class="kb-admin-card">
|
||||
<div class="flex items-start justify-between gap-3">
|
||||
<div class="min-w-0">
|
||||
<h3 class="font-semibold text-primary">{{ group.name }}</h3>
|
||||
<p class="mt-1 line-clamp-2 text-sm text-muted" :title="group.description || t('kbAdmin.noDescription')">{{ group.description || t('kbAdmin.noDescription') }}</p>
|
||||
</div>
|
||||
<span class="kb-admin-badge">{{ group.document_count ?? 0 }}</span>
|
||||
</div>
|
||||
<div class="mt-3 flex items-center justify-between gap-3">
|
||||
<span class="text-xs text-muted">{{ formatGroupUpdatedAt(group.updated_at) }}</span>
|
||||
<div class="flex gap-1.5">
|
||||
<button type="button" class="btn-icon-ds border border-default" @click="openEditDrawer(group)" :title="t('common.edit')"><Pencil class="h-4 w-4" /></button>
|
||||
<button type="button" class="btn-icon-ds border border-rose-200 text-rose-600" @click="handleDeleteGroup(group)" :title="t('common.delete')"><Trash2 class="h-4 w-4" /></button>
|
||||
</div>
|
||||
</div>
|
||||
</article>
|
||||
</div>
|
||||
|
||||
<div class="border-t border-default px-6 py-4">
|
||||
<PaginationBar
|
||||
v-model:page="currentPage"
|
||||
v-model:page-size="pageSize"
|
||||
:total="filteredGroups.length"
|
||||
:page-size-options="pageSizeOptions"
|
||||
<div class="kb-admin-filters">
|
||||
<div class="kb-element-filters">
|
||||
<ElInput
|
||||
v-model="searchKeyword"
|
||||
clearable
|
||||
:prefix-icon="Search"
|
||||
:placeholder="t('kbAdmin.filters.searchPlaceholder')"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<ElAlert
|
||||
v-if="feedback"
|
||||
class="kb-admin-alert"
|
||||
:title="feedback"
|
||||
:type="feedbackType === 'error' ? 'error' : 'success'"
|
||||
show-icon
|
||||
closable
|
||||
@close="feedback = ''"
|
||||
/>
|
||||
|
||||
<ElTable
|
||||
v-loading="isRefreshing"
|
||||
class="hx-admin-table"
|
||||
:data="pagedGroups"
|
||||
row-key="id"
|
||||
:default-sort="{ prop: 'updated_at', order: 'descending' }"
|
||||
:empty-text="tableEmptyText"
|
||||
@sort-change="onSortChange"
|
||||
@filter-change="onFilterChange"
|
||||
>
|
||||
<ElTableColumn prop="name" :label="t('kbAdmin.table.name')" min-width="160" sortable="custom">
|
||||
<template #default="{ row }">
|
||||
<div class="truncate" :title="(row as KbGroup).name">{{ (row as KbGroup).name }}</div>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn :label="t('kbAdmin.table.description')" min-width="220">
|
||||
<template #default="{ row }">
|
||||
<div class="truncate hx-element-hint" :title="(row as KbGroup).description || t('kbAdmin.noDescription')">
|
||||
{{ (row as KbGroup).description || t('kbAdmin.noDescription') }}
|
||||
</div>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn
|
||||
prop="document_count"
|
||||
column-key="document_count"
|
||||
:label="t('kbAdmin.table.documents')"
|
||||
width="160"
|
||||
sortable="custom"
|
||||
:filters="documentFilters"
|
||||
:filter-multiple="false"
|
||||
>
|
||||
<template #default="{ row }">{{ (row as KbGroup).document_count ?? 0 }}</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn prop="updated_at" :label="t('kbAdmin.table.updatedAt')" min-width="180" sortable="custom">
|
||||
<template #default="{ row }">{{ formatGroupUpdatedAt((row as KbGroup).updated_at) }}</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn :label="t('kbAdmin.table.actions')" width="160" align="right">
|
||||
<template #default="{ row }">
|
||||
<ElButton link type="primary" @click="openEditDrawer(row as KbGroup)">{{ t('common.edit') }}</ElButton>
|
||||
<ElButton link type="danger" :disabled="isDeleting" @click="handleDeleteGroup(row as KbGroup)">
|
||||
{{ t('common.delete') }}
|
||||
</ElButton>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
</ElTable>
|
||||
|
||||
<div v-if="filteredGroups.length > 0" class="hx-admin-pager">
|
||||
<ElPagination
|
||||
v-model:current-page="currentPage"
|
||||
v-model:page-size="pageSize"
|
||||
:total="filteredGroups.length"
|
||||
:page-sizes="pageSizeOptions"
|
||||
layout="total, sizes, prev, pager, next"
|
||||
background
|
||||
/>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<KbGroupDrawer
|
||||
v-model:form="form"
|
||||
@@ -348,5 +372,32 @@ defineExpose({ loadData });
|
||||
|
||||
<DifySettingsDialog :open="settingsDialogOpen" @close="settingsDialogOpen = false" @saved="(message) => { feedback = message; feedbackType = 'success'; void loadData(); }" @error="(message) => { feedback = message; feedbackType = 'error'; }" />
|
||||
<DifyHealthDialog :open="healthDialogOpen" @close="healthDialogOpen = false" @error="(message) => { feedback = message; feedbackType = 'error'; }" />
|
||||
<DeleteConfirmDialog v-model="deleteDialogOpen" :title="t('kbAdmin.deleteDialog.title')" :message="t('kbAdmin.deleteDialog.message', { name: deletingGroup?.name || '' })" :confirm-loading="isDeleting" @confirm="handleDeleteGroupConfirm" @cancel="() => { deleteDialogOpen = false; deletingGroup = null; }" />
|
||||
</ElConfigProvider>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.kb-admin-filters {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
gap: 12px 24px;
|
||||
padding: 16px 32px;
|
||||
border-bottom: 1px solid var(--el-border-color-lighter);
|
||||
}
|
||||
|
||||
.kb-admin-alert {
|
||||
margin: 16px 32px 0;
|
||||
}
|
||||
|
||||
.kb-element-filters {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.kb-element-filters :deep(.el-input) {
|
||||
width: 16rem;
|
||||
flex: none;
|
||||
}
|
||||
</style>
|
||||
@@ -1,14 +1,16 @@
|
||||
<script setup lang="ts">
|
||||
/**
|
||||
* features/kb/components/KbGroupDrawer.vue
|
||||
* 知识库分组新建/编辑抽屉表单。
|
||||
* 依赖:Vue I18n、lucide-vue-next、父级 KbAdminPanel 传入的表单状态。
|
||||
* 逻辑:只负责抽屉展示、表单双向同步和提交/关闭事件;接口调用与列表刷新由父组件处理。
|
||||
* 知识库分组新建/编辑弹窗。
|
||||
* 依赖:Element Plus 对话框与表单、Vue I18n、父级 KbAdminPanel 传入的表单状态。
|
||||
* 逻辑:只负责弹窗展示、表单双向同步和提交/关闭事件;接口调用与列表刷新由父组件处理。
|
||||
* 字段只有名称和描述,用随内容增高的对话框,避免整屏抽屉留下大块空白。
|
||||
*/
|
||||
|
||||
import { computed } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { FolderPlus, X } from 'lucide-vue-next';
|
||||
import { FolderAdd } from '@element-plus/icons-vue';
|
||||
import { ElButton, ElDialog, ElForm, ElFormItem, ElInput } from 'element-plus';
|
||||
|
||||
export interface KbGroupFormValue {
|
||||
name: string;
|
||||
@@ -37,7 +39,11 @@ const submitText = computed(() => {
|
||||
return props.mode === 'edit' ? t('kbAdmin.form.saveChanges') : t('kbAdmin.form.create');
|
||||
});
|
||||
|
||||
/** 更新指定表单字段,并将完整表单值同步回父组件。 */
|
||||
/**
|
||||
* 更新指定表单字段,并将完整表单值同步回父组件。
|
||||
* @param field - 要改的字段,只能是名称或描述
|
||||
* @param value - 输入框当前文本
|
||||
*/
|
||||
const updateField = (field: keyof KbGroupFormValue, value: string) => {
|
||||
emit('update:form', {
|
||||
...props.form,
|
||||
@@ -47,81 +53,53 @@ const updateField = (field: keyof KbGroupFormValue, value: string) => {
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Teleport to="body">
|
||||
<Transition name="kb-admin-drawer">
|
||||
<div v-if="open" class="fixed inset-0 z-[100] bg-overlay backdrop-blur-sm" @click.self="emit('close')">
|
||||
<aside class="ml-auto flex h-full w-full max-w-[440px] flex-col border-l border-default bg-surface shadow-elevated">
|
||||
<header class="flex items-start justify-between gap-4 border-b border-default px-6 py-5">
|
||||
<div class="min-w-0">
|
||||
<h3 class="text-lg font-semibold text-primary">{{ formTitle }}</h3>
|
||||
<p class="section-desc mt-1">{{ formDescription }}</p>
|
||||
</div>
|
||||
<button type="button" class="btn-icon-ds shrink-0" @click="emit('close')" :title="t('common.close')">
|
||||
<X class="h-5 w-5" />
|
||||
</button>
|
||||
</header>
|
||||
|
||||
<div class="flex-1 space-y-5 overflow-y-auto px-6 py-5">
|
||||
<div>
|
||||
<label class="label-field mb-2 block">{{ t('kbAdmin.form.groupName') }}</label>
|
||||
<input
|
||||
:value="form.name"
|
||||
class="input-field"
|
||||
:placeholder="t('kbAdmin.form.groupNamePlaceholder')"
|
||||
@input="updateField('name', ($event.target as HTMLInputElement).value)"
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<label class="label-field mb-2 block">{{ t('kbAdmin.form.groupDesc') }}</label>
|
||||
<textarea
|
||||
:value="form.description"
|
||||
rows="8"
|
||||
class="input-field"
|
||||
:placeholder="t('kbAdmin.form.groupDescPlaceholder')"
|
||||
@input="updateField('description', ($event.target as HTMLTextAreaElement).value)"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<footer class="flex justify-end gap-2 border-t border-default px-6 py-4">
|
||||
<button type="button" class="btn-secondary inline-flex items-center gap-1.5 px-4 py-2 text-sm" @click="emit('close')">
|
||||
<X class="h-4 w-4 shrink-0" />
|
||||
{{ t('common.cancel') }}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="btn-primary inline-flex items-center gap-1.5 px-5 py-2 text-sm disabled:cursor-not-allowed disabled:opacity-60"
|
||||
:disabled="submitting"
|
||||
@click="emit('submit')"
|
||||
>
|
||||
<FolderPlus v-if="!submitting" class="h-4 w-4 shrink-0" />
|
||||
{{ submitText }}
|
||||
</button>
|
||||
</footer>
|
||||
</aside>
|
||||
<ElDialog
|
||||
:model-value="open"
|
||||
width="480px"
|
||||
align-center
|
||||
append-to-body
|
||||
:close-on-click-modal="!submitting"
|
||||
:close-on-press-escape="!submitting"
|
||||
:show-close="!submitting"
|
||||
@close="emit('close')"
|
||||
>
|
||||
<template #header>
|
||||
<div>
|
||||
<h3 class="text-lg font-semibold text-primary">{{ formTitle }}</h3>
|
||||
<p class="mt-1 text-sm text-muted">{{ formDescription }}</p>
|
||||
</div>
|
||||
</Transition>
|
||||
</Teleport>
|
||||
</template>
|
||||
|
||||
<ElForm class="kb-group-form" label-position="top" @submit.prevent="emit('submit')">
|
||||
<ElFormItem :label="t('kbAdmin.form.groupName')">
|
||||
<ElInput
|
||||
:model-value="form.name"
|
||||
:placeholder="t('kbAdmin.form.groupNamePlaceholder')"
|
||||
@update:model-value="updateField('name', String($event))"
|
||||
/>
|
||||
</ElFormItem>
|
||||
<ElFormItem :label="t('kbAdmin.form.groupDesc')">
|
||||
<ElInput
|
||||
:model-value="form.description"
|
||||
type="textarea"
|
||||
:rows="4"
|
||||
:placeholder="t('kbAdmin.form.groupDescPlaceholder')"
|
||||
@update:model-value="updateField('description', String($event))"
|
||||
/>
|
||||
</ElFormItem>
|
||||
</ElForm>
|
||||
|
||||
<template #footer>
|
||||
<ElButton :disabled="submitting" @click="emit('close')">{{ t('common.cancel') }}</ElButton>
|
||||
<ElButton type="primary" :icon="FolderAdd" :loading="submitting" @click="emit('submit')">
|
||||
{{ submitText }}
|
||||
</ElButton>
|
||||
</template>
|
||||
</ElDialog>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.kb-admin-drawer-enter-active,
|
||||
.kb-admin-drawer-leave-active {
|
||||
transition: opacity 0.18s ease;
|
||||
}
|
||||
|
||||
.kb-admin-drawer-enter-active aside,
|
||||
.kb-admin-drawer-leave-active aside {
|
||||
transition: transform 0.18s ease;
|
||||
}
|
||||
|
||||
.kb-admin-drawer-enter-from,
|
||||
.kb-admin-drawer-leave-to {
|
||||
opacity: 0;
|
||||
}
|
||||
|
||||
.kb-admin-drawer-enter-from aside,
|
||||
.kb-admin-drawer-leave-to aside {
|
||||
transform: translateX(100%);
|
||||
.kb-group-form :deep(.el-form-item:last-child) {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
</style>
|
||||
@@ -3,9 +3,11 @@
|
||||
* 依赖:统一 requestJson(失败抛 BusinessError);后端 /api/order-delivery-reply。
|
||||
* 逻辑:列表筛选分页、保存批次(单行/联合)、单行与批量通知、手动同步与最近同步状态。
|
||||
* 带 JSON 正文的写请求在本文件声明 Content-Type: application/json,供 Flask get_json 解析。
|
||||
* 按当前筛选导出 Excel(后端生成 xlsx,blob 触发下载)。
|
||||
*/
|
||||
|
||||
import { requestJson } from '@/shared/api/client';
|
||||
import { getAuthHeaders } from '@/shared/utils/auth';
|
||||
|
||||
/**
|
||||
* 组装带 JSON 正文的写请求。
|
||||
@@ -157,3 +159,41 @@ export const runOrderDeliverySync = () =>
|
||||
/** 最近一次同步运行记录;从未同步过返回 null。 */
|
||||
export const getLatestOrderDeliverySync = () =>
|
||||
requestJson<OrderDeliverySyncRun | null>('/api/order-delivery-reply/sync/latest');
|
||||
|
||||
/** 导出 Excel 查询参数(与列表筛选一致;导出全部命中行,不分页)。 */
|
||||
export interface OrderDeliveryExportParams {
|
||||
keyword?: string;
|
||||
order_date?: string;
|
||||
status?: '' | 'replied' | 'not_fully_replied';
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出当前筛选下的全部订单行 Excel。
|
||||
* 触发时机:工具栏「导出 Excel」按钮。后端生成 xlsx 文件流,此处 blob 触发浏览器下载,
|
||||
* 文件名「订单交期回复_YYYY-MM-DD.xlsx」(日期取本地当天);失败抛 Error(HTTP 状态码)。
|
||||
*/
|
||||
export async function exportOrderDeliveryLines(params: OrderDeliveryExportParams): Promise<void> {
|
||||
const query = new URLSearchParams();
|
||||
if (params.keyword) query.set('keyword', params.keyword);
|
||||
if (params.order_date) query.set('order_date', params.order_date);
|
||||
if (params.status) query.set('status', params.status);
|
||||
const response = await fetch(`/api/order-delivery-reply/lines/export?${query.toString()}`, {
|
||||
method: 'GET',
|
||||
headers: getAuthHeaders(),
|
||||
});
|
||||
if (!response.ok) {
|
||||
throw new Error(`Export failed: HTTP ${response.status}`);
|
||||
}
|
||||
const blob = await response.blob();
|
||||
const url = URL.createObjectURL(blob);
|
||||
const link = document.createElement('a');
|
||||
link.href = url;
|
||||
// 文件名日期取浏览器本地时区(toISOString 为 UTC,北京时间 0-8 点导出会差一天)
|
||||
const now = new Date();
|
||||
const localDate = `${now.getFullYear()}-${String(now.getMonth() + 1).padStart(2, '0')}-${String(now.getDate()).padStart(2, '0')}`;
|
||||
link.download = `订单交期回复_${localDate}.xlsx`;
|
||||
document.body.appendChild(link);
|
||||
link.click();
|
||||
link.remove();
|
||||
URL.revokeObjectURL(url);
|
||||
}
|
||||
+171
@@ -0,0 +1,171 @@
|
||||
/**
|
||||
* features/order-delivery-reply/views/OrderDeliveryReplyPage.chipEdit.spec.ts
|
||||
* 用途:锁定「批次条就地编辑」核心契约(回归用)。
|
||||
* 依赖:vitest、@vue/test-utils、vue-i18n、vue-router memory history。
|
||||
* 逻辑:完整挂载工作台页(mock API/权限/消息):
|
||||
* 1) 未回复行点击空批次条进入编辑态,填写日期+数量失焦 → 调用单行保存接口(整行批次);
|
||||
* 2) 只填数量不填日期失焦 → 不保存且行内红字提示(batchMissingDate);
|
||||
* 3) 多批次行改其中一条数量致合计≠订单数量 → 不保存且红字提示(qtyTotalMismatchLine)。
|
||||
*/
|
||||
import { describe, expect, it, vi, beforeEach } from 'vitest';
|
||||
import { flushPromises, mount } from '@vue/test-utils';
|
||||
import { createI18n } from 'vue-i18n';
|
||||
import { createRouter, createMemoryHistory } from 'vue-router';
|
||||
import OrderDeliveryReplyPage from './OrderDeliveryReplyPage.vue';
|
||||
|
||||
const hoisted = vi.hoisted(() => ({
|
||||
listMock: vi.fn(),
|
||||
saveMock: vi.fn(),
|
||||
batchMock: vi.fn(),
|
||||
notifyMock: vi.fn(),
|
||||
syncMock: vi.fn(),
|
||||
latestSyncMock: vi.fn(),
|
||||
requestJsonMock: vi.fn(),
|
||||
messageMocks: { info: vi.fn(), success: vi.fn(), warning: vi.fn(), error: vi.fn() },
|
||||
}));
|
||||
|
||||
vi.mock('@/features/order-delivery-reply/api/orderDeliveryReply.api', () => ({
|
||||
listOrderDeliveryLines: hoisted.listMock,
|
||||
saveOrderDeliveryBatches: hoisted.saveMock,
|
||||
batchReplyOrderDelivery: hoisted.batchMock,
|
||||
notifyOrderDeliveryBatch: hoisted.notifyMock,
|
||||
runOrderDeliverySync: hoisted.syncMock,
|
||||
getLatestOrderDeliverySync: hoisted.latestSyncMock,
|
||||
}));
|
||||
|
||||
vi.mock('@/shared/api/client', () => ({
|
||||
requestJson: hoisted.requestJsonMock,
|
||||
}));
|
||||
|
||||
vi.mock('@/shared/composables/useMessage', () => ({
|
||||
useMessage: () => hoisted.messageMocks,
|
||||
}));
|
||||
|
||||
vi.mock('@/features/auth/stores/auth.store', () => ({
|
||||
useAuthStore: () => ({ hasFeaturePermission: () => true }),
|
||||
}));
|
||||
|
||||
/** 两行样例:A 未回复(空批次,订单数量 1);B 部分回复(3 批次 30/50/20,订单数量 100)。 */
|
||||
const sampleLines = [
|
||||
{
|
||||
id: 1,
|
||||
order_no: '8301-T1',
|
||||
line_no: 4,
|
||||
qty: '1',
|
||||
unit: 'SET',
|
||||
status: 'not_replied' as const,
|
||||
locked: false,
|
||||
batches: [] as { seq?: number; planned_date: string; qty: string; remark?: string | null }[],
|
||||
undelivered_qty: '1',
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
order_no: '8301-T2',
|
||||
line_no: 1,
|
||||
qty: '100',
|
||||
unit: 'PCS',
|
||||
status: 'partial_replied' as const,
|
||||
locked: false,
|
||||
batches: [
|
||||
{ seq: 1, planned_date: '2026-09-04', qty: '30', remark: null },
|
||||
{ seq: 2, planned_date: '2026-09-11', qty: '50', remark: null },
|
||||
{ seq: 3, planned_date: '2026-09-23', qty: '20', remark: null },
|
||||
],
|
||||
undelivered_qty: '0',
|
||||
},
|
||||
];
|
||||
|
||||
const mountPage = async () => {
|
||||
const router = createRouter({
|
||||
history: createMemoryHistory(),
|
||||
routes: [{ path: '/:pathMatch(.*)*', component: { template: '<div />' } }],
|
||||
});
|
||||
router.push('/chat/39');
|
||||
await router.isReady();
|
||||
const i18n = createI18n({ legacy: false, locale: 'zh-CN', messages: { 'zh-CN': {} } });
|
||||
const wrapper = mount(OrderDeliveryReplyPage, {
|
||||
global: {
|
||||
plugins: [router, i18n],
|
||||
stubs: { PaginationBar: true, DeleteConfirmDialog: true },
|
||||
},
|
||||
});
|
||||
await flushPromises();
|
||||
return wrapper;
|
||||
};
|
||||
|
||||
describe('OrderDeliveryReplyPage 批次条就地编辑', () => {
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks();
|
||||
hoisted.listMock.mockResolvedValue({ items: sampleLines, page: 1, page_size: 50, total: 2 });
|
||||
hoisted.latestSyncMock.mockResolvedValue(null);
|
||||
hoisted.saveMock.mockResolvedValue({ order_no: '8301-T1', line_no: 4, batches: [], total_qty: '1' });
|
||||
hoisted.requestJsonMock.mockResolvedValue(undefined);
|
||||
});
|
||||
|
||||
it('未回复行:点击空批次条进入编辑,填写日期+数量失焦后调用单行保存', async () => {
|
||||
const wrapper = await mountPage();
|
||||
|
||||
// 未回复行(8301-T1:4)的可编辑空批次条:title 为 replyAction 键(i18n 缺失时回退键名)
|
||||
const emptyChip = wrapper.find('div[title="workspace.orderDeliveryReply.replyAction"]');
|
||||
expect(emptyChip.exists()).toBe(true);
|
||||
await emptyChip.trigger('click');
|
||||
await flushPromises();
|
||||
|
||||
// 编辑态输入条出现(data-chip-edit),自动聚焦日期框
|
||||
const editor = wrapper.find('[data-chip-edit]');
|
||||
expect(editor.exists()).toBe(true);
|
||||
const dateInput = editor.find('[data-chip-date]');
|
||||
expect((dateInput.element as HTMLInputElement).value).toBe('');
|
||||
|
||||
// 填写日期 + 数量后失焦提交
|
||||
await dateInput.setValue('2026-10-20');
|
||||
await editor.find('input[type="number"]').setValue('1');
|
||||
await editor.trigger('focusout');
|
||||
await flushPromises();
|
||||
|
||||
expect(hoisted.saveMock).toHaveBeenCalledTimes(1);
|
||||
expect(hoisted.saveMock).toHaveBeenCalledWith('8301-T1', 4, [
|
||||
{ planned_date: '2026-10-20', qty: '1', remark: null },
|
||||
]);
|
||||
});
|
||||
|
||||
it('未回复行:只填数量不填日期失焦 → 不保存且红字提示缺交期', async () => {
|
||||
const wrapper = await mountPage();
|
||||
const emptyChip = wrapper.find('div[title="workspace.orderDeliveryReply.replyAction"]');
|
||||
await emptyChip.trigger('click');
|
||||
await flushPromises();
|
||||
|
||||
const editor = wrapper.find('[data-chip-edit]');
|
||||
await editor.find('input[type="number"]').setValue('1');
|
||||
await editor.trigger('focusout');
|
||||
await flushPromises();
|
||||
|
||||
expect(hoisted.saveMock).not.toHaveBeenCalled();
|
||||
const hint = wrapper.find('p.text-status-error');
|
||||
expect(hint.exists()).toBe(true);
|
||||
expect(hint.text()).toContain('batchMissingDate');
|
||||
});
|
||||
|
||||
it('多批次行:改第 2 条数量致合计≠订单数量失焦 → 不保存且红字提示', async () => {
|
||||
const wrapper = await mountPage();
|
||||
|
||||
// B 行(8301-T2:1)首条批次条:title 为 editReplyAction 键
|
||||
const chips = wrapper.findAll('div[title="workspace.orderDeliveryReply.editReplyAction"]');
|
||||
expect(chips.length).toBeGreaterThanOrEqual(1);
|
||||
await chips[0].trigger('click');
|
||||
await flushPromises();
|
||||
|
||||
const editor = wrapper.find('[data-chip-edit]');
|
||||
// 预填首条批次当前值
|
||||
expect((editor.find('[data-chip-date]').element as HTMLInputElement).value).toBe('2026-09-04');
|
||||
// 只改数量为 60 → 30→60 后合计 130 ≠ 100
|
||||
await editor.find('input[type="number"]').setValue('60');
|
||||
await editor.trigger('focusout');
|
||||
await flushPromises();
|
||||
|
||||
expect(hoisted.saveMock).not.toHaveBeenCalled();
|
||||
const hint = wrapper.find('p.text-status-error');
|
||||
expect(hint.exists()).toBe(true);
|
||||
expect(hint.text()).toContain('qtyTotalMismatchLine');
|
||||
});
|
||||
});
|
||||
@@ -1,7 +1,8 @@
|
||||
/**
|
||||
* features/order-delivery-reply/views/OrderDeliveryReplyPage.vue
|
||||
* 用途:订单交期回复工作台操作页——筛选分页、单行/联合回复批次、单行/批量通知、手动同步。
|
||||
* 依赖:api/orderDeliveryReply.api(统一 requestJson)、useMessage、auth store(manage/access 权限)。
|
||||
* 依赖:api/orderDeliveryReply.api(统一 requestJson)、useMessage、auth store(manage/access 权限)、
|
||||
* shared DeleteConfirmDialog(批量通知二次确认)、PaginationBar。
|
||||
* 逻辑:所有数据只读本地快照;保存与通知是两步(联合回复只保存,批量通知才发送并锁定);
|
||||
* 保存/通知成功后即时刷新列表(需求 §9);仅 access 用户隐藏全部写操作。
|
||||
* 回复弹窗数量守恒(2026-09-23 由「超额仅提醒」修订):每行各批次合计必须等于订单数量
|
||||
@@ -10,10 +11,30 @@
|
||||
* wecom_trace 上报打开回执——保证「点卡片 → 登录 → 直达该 Agent 对应内容与位置」。
|
||||
* 列顺序:客户编号(简称副文案) → 订单日期 → 订单单号:项次 → 产品编号(品名副文案) →
|
||||
* 客户产品编号 → 数量 → 约定交货日 → 交期回复状态 → 交期回复 → 交期回复人员 →
|
||||
* 业务员(部门副文案) → 客户订单 → 规格 → 单位;独立的部门列/品名列已并入合并展示。
|
||||
* 业务员(部门副文案) → 客户订单 → 规格 → 单位 → 通知时间(2026-10-09 自交期回复人员列拆出);
|
||||
* 独立的部门列/品名列已并入合并展示。
|
||||
* 浏览体验:页面高度收敛至视口(滚动全部发生在表格容器内 → 列头 sticky 固定、横向滚动条
|
||||
* 常驻表格底缘);左侧冻结前四列标识区(勾选/客户编号/订单日期/订单单号:项次,
|
||||
* 冻结单元格用实色背景防透出);筛选区与工具栏字号与表格统一(text-sm 14px)并压缩高度。
|
||||
* 冻结单元格用 utilities.css 的 frozen-cell 实色基底防透出,并随行悬停/选中/直达高亮联动);
|
||||
* 筛选区无外置字段标签(提示字占位已取消,含义由 placeholder/选项承担,aria-label 保留无障碍语义),
|
||||
* 输入框/按钮显式 text-sm + h-9(36px),与合同付款预警 .contract-filter-input/.contract-filter-submit
|
||||
* (14px/600/36px/圆角8px)渲染规格逐项一致。
|
||||
* 交期回复列批次交互(2026-10-09):动作入口统一为批次条前的加号(lucide Plus,title/aria 复用
|
||||
* replyAction/editReplyAction 键)——未回复=空批次条(不显示时间/数量)+ 加号回复;
|
||||
* 已回复/部分回复=加号修改回复(仅未锁定可管理);「交期已锁定」徽标已取消(锁定状态由
|
||||
* 无加号与交期回复人员列「已通知」体现)。全表批次条左缘对齐:所有行首条批次前保留
|
||||
* w-6 加号占位,展开行其余批次条加 pl-7 缩进;>1 批时首条批次后保留展开/收起小箭头
|
||||
* (▼ 全部 / ▲ 收起只留第一批)。
|
||||
* 批次条就地编辑(2026-10-09):未锁定可管理行点击批次条原地变「日期+数量」输入(预填当前值;
|
||||
* 未回复行空批次条点击=新增第一条批次),输入条渲染后自动聚焦日期框;回车/失焦自动保存单行
|
||||
* 接口(整行批次提交,与弹窗保存同口径校验);校验失败红字持续显示并重聚焦日期框,直至修正
|
||||
* 保存或 Esc 取消;双清空=放弃编辑;批次条不显示备注内容;多批次/备注仍走加号弹窗。
|
||||
* 表格对齐(2026-10-09):除交期回复列(批次条按既定左对齐布局)外,全列内容水平居中、
|
||||
* 行内容垂直居中,列头文字全部居中;交期回复状态徽标统一等宽(min-w-68px)。
|
||||
* 设计系统(docs/ui/DESIGN_SYSTEM.md):根节点挂 page-shell;区块容器用 surface-panel;
|
||||
* 弹窗用 dialog-overlay/panel/header/body/footer;输入用 input-field/select-field;
|
||||
* 状态与交互色一律走 --status-* 令牌(badge-*/bg-row-*/frozen-cell-*),品牌强调用 brand-*。
|
||||
* 批量通知确认使用共享 DeleteConfirmDialog(confirmTone=primary),不再用原生 window.confirm。
|
||||
*/
|
||||
|
||||
<script setup lang="ts">
|
||||
@@ -24,11 +45,14 @@ import { useAuthStore } from '@/features/auth/stores/auth.store';
|
||||
import { useMessage } from '@/shared/composables/useMessage';
|
||||
import { requestJson } from '@/shared/api/client';
|
||||
import PaginationBar from '@/shared/components/PaginationBar.vue';
|
||||
import DeleteConfirmDialog from '@/shared/components/DeleteConfirmDialog.vue';
|
||||
import { ChevronDown, ChevronUp, Download, Plus } from 'lucide-vue-next';
|
||||
import {
|
||||
ORDER_DELIVERY_REPLY_MANAGE_PERMISSION,
|
||||
} from '@/features/order-delivery-reply/constants';
|
||||
import {
|
||||
batchReplyOrderDelivery,
|
||||
exportOrderDeliveryLines,
|
||||
getLatestOrderDeliverySync,
|
||||
listOrderDeliveryLines,
|
||||
notifyOrderDeliveryBatch,
|
||||
@@ -158,15 +182,13 @@ function toggleExpand(key: string) {
|
||||
}
|
||||
|
||||
/* ============ 派生展示 ============ */
|
||||
const repliedQty = (line: OrderDeliveryLine) =>
|
||||
line.batches.reduce((sum, batch) => sum + Number(batch.qty || 0), 0);
|
||||
const undelivered = (line: OrderDeliveryLine) => Number(line.undelivered_qty || 0);
|
||||
type LineStatus = OrderDeliveryLine['status'];
|
||||
/** 状态徽章:颜色走 badge-success/warning/error(--status-* 令牌,亮暗自适应)。 */
|
||||
const statusMeta = (status: LineStatus) => {
|
||||
const map: Record<LineStatus, { label: string; cls: string }> = {
|
||||
not_replied: { label: t('workspace.orderDeliveryReply.statusNotReplied'), cls: 'bg-rose-50 text-rose-600' },
|
||||
partial_replied: { label: t('workspace.orderDeliveryReply.statusPartial'), cls: 'bg-orange-50 text-orange-600' },
|
||||
replied: { label: t('workspace.orderDeliveryReply.statusReplied'), cls: 'bg-emerald-50 text-emerald-600' },
|
||||
not_replied: { label: t('workspace.orderDeliveryReply.statusNotReplied'), cls: 'badge-error' },
|
||||
partial_replied: { label: t('workspace.orderDeliveryReply.statusPartial'), cls: 'badge-warning' },
|
||||
replied: { label: t('workspace.orderDeliveryReply.statusReplied'), cls: 'badge-success' },
|
||||
};
|
||||
return map[status];
|
||||
};
|
||||
@@ -184,6 +206,7 @@ const quickDate = ref('');
|
||||
const saving = ref(false);
|
||||
|
||||
function openReplyModal(lines: OrderDeliveryLine[], title: string, mode: 'single' | 'batch') {
|
||||
cancelChipEdit(); // 打开弹窗前退出批次条就地编辑,避免弹窗与行内编辑态叠加
|
||||
modalLines.value = lines.map((line) => ({
|
||||
line,
|
||||
batches: line.batches.map((batch) => ({
|
||||
@@ -203,10 +226,12 @@ function openReplyModal(lines: OrderDeliveryLine[], title: string, mode: 'single
|
||||
}
|
||||
|
||||
function openSingleReply(line: OrderDeliveryLine) {
|
||||
if (chipSaving.value) return; // 保存进行中禁止开弹窗:弹窗按旧批次数据提交会覆盖刚保存的编辑
|
||||
openReplyModal([line], t('workspace.orderDeliveryReply.modalTitleSingle', { order: line.order_no, item: line.line_no }), 'single');
|
||||
}
|
||||
|
||||
function openBatchReply() {
|
||||
if (chipSaving.value) return;
|
||||
const lines = selectedLines.value.filter((line) => !line.locked);
|
||||
if (!lines.length) return;
|
||||
openReplyModal(lines, t('workspace.orderDeliveryReply.modalTitleBatch', { count: lines.length }), 'batch');
|
||||
@@ -316,15 +341,153 @@ async function saveReplies() {
|
||||
}
|
||||
}
|
||||
|
||||
/* ============ 批次条就地编辑(2026-10-09) ============ */
|
||||
// 未锁定且可管理的行:点击批次条原地变「日期+数量」输入,回车/失焦自动保存单行接口;
|
||||
// 校验与弹窗同口径(lineIssueText:缺交期/缺数量、同单交期重复、合计≠订单数量),红字阻断保存;
|
||||
// 双清空=放弃编辑(行内不提供删除,结构调整/备注/多批次走加号弹窗)。
|
||||
const editingChip = ref<{ key: string; idx: number } | null>(null);
|
||||
const chipDraft = reactive({ planned_date: '', qty: '' });
|
||||
const chipIssue = ref('');
|
||||
// 单行保存进行中标志:整行提交语义下,禁止并发(再点其他批次条/开弹窗),
|
||||
// 否则两个 in-flight 保存或「弹窗基于旧批次数据」会互相覆盖丢编辑
|
||||
const chipSaving = ref(false);
|
||||
|
||||
const isChipEditable = (line: OrderDeliveryLine) => canManage.value && !line.locked;
|
||||
const isChipEditing = (line: OrderDeliveryLine, idx: number) =>
|
||||
editingChip.value?.key === lineKey(line) && editingChip.value?.idx === idx;
|
||||
|
||||
function startChipEdit(line: OrderDeliveryLine, idx: number) {
|
||||
if (!isChipEditable(line) || chipSaving.value) return;
|
||||
// 未回复行批次列表为空:idx=0 表示「新增第一条批次」,同样可进入编辑
|
||||
if (line.batches.length > 0 && idx >= line.batches.length) return;
|
||||
const batch = line.batches[idx];
|
||||
editingChip.value = { key: lineKey(line), idx };
|
||||
chipDraft.planned_date = batch?.planned_date ?? '';
|
||||
chipDraft.qty = batch ? String(Number(batch.qty)) : '';
|
||||
chipIssue.value = '';
|
||||
// 输入条渲染后自动聚焦日期框,点击即可填
|
||||
void nextTick(() => {
|
||||
document.querySelector<HTMLInputElement>('[data-chip-edit] [data-chip-date]')?.focus();
|
||||
});
|
||||
}
|
||||
|
||||
function cancelChipEdit() {
|
||||
editingChip.value = null;
|
||||
chipIssue.value = '';
|
||||
}
|
||||
|
||||
/** 失焦提交:relatedTarget 仍在输入条内(日期↔数量切换)时不提交。 */
|
||||
function onChipFocusout(event: FocusEvent, line: OrderDeliveryLine, idx: number) {
|
||||
const next = event.relatedTarget as Node | null;
|
||||
if (next && (event.currentTarget as HTMLElement).contains(next)) return;
|
||||
chipCommit(line, idx);
|
||||
}
|
||||
|
||||
function chipCommit(line: OrderDeliveryLine, idx: number) {
|
||||
if (!isChipEditing(line, idx) || chipSaving.value) return;
|
||||
// 注意:v-model 在 type="number" 输入框上会自动把值转成 number,
|
||||
// 这里必须统一 String() 容错,否则 qty.trim() 抛 TypeError 中断整个失焦提交
|
||||
const date = String(chipDraft.planned_date ?? '').trim();
|
||||
const qty = String(chipDraft.qty ?? '').trim();
|
||||
// 双清空=放弃编辑;只填其一致「缺交期/缺数量」红字,保持编辑态
|
||||
if (!date && !(qty !== '' && Number(qty) > 0)) {
|
||||
cancelChipEdit();
|
||||
return;
|
||||
}
|
||||
// 整行批次合并提交,与弹窗保存完全同口径:
|
||||
// 编辑已有批次=仅替换该条;未回复行空批次条=新增第一条(line.batches 为空数组)
|
||||
const source = line.batches[idx];
|
||||
const edited: EditableBatch = { planned_date: date, qty, remark: source?.remark || '' };
|
||||
const merged: EditableBatch[] =
|
||||
idx < line.batches.length
|
||||
? line.batches.map((b, i) =>
|
||||
i === idx ? edited : { planned_date: b.planned_date, qty: String(Number(b.qty)), remark: b.remark || '' },
|
||||
)
|
||||
: [edited];
|
||||
const issue = lineIssueText({ line, batches: merged });
|
||||
if (issue) {
|
||||
chipIssue.value = issue;
|
||||
// 校验失败:保持编辑态并重新聚焦日期框,红字提示持续可见,直至修正保存或 Esc 取消
|
||||
void nextTick(() => {
|
||||
document.querySelector<HTMLInputElement>('[data-chip-edit] [data-chip-date]')?.focus();
|
||||
});
|
||||
return;
|
||||
}
|
||||
const cleaned = merged
|
||||
.filter((b) => b.planned_date && Number(b.qty) > 0)
|
||||
.map((b) => ({ planned_date: b.planned_date, qty: b.qty, remark: b.remark.trim() || null }));
|
||||
if (!cleaned.length) {
|
||||
cancelChipEdit();
|
||||
return;
|
||||
}
|
||||
void saveChipEdit(line, idx, cleaned);
|
||||
}
|
||||
|
||||
async function saveChipEdit(
|
||||
line: OrderDeliveryLine,
|
||||
idx: number,
|
||||
cleaned: { planned_date: string; qty: string; remark: string | null }[],
|
||||
) {
|
||||
const target = { key: lineKey(line), idx };
|
||||
chipSaving.value = true;
|
||||
try {
|
||||
await saveOrderDeliveryBatches(line.order_no, line.line_no, cleaned);
|
||||
msg.success(t('workspace.orderDeliveryReply.saveSingleDone'));
|
||||
// 仅当用户未切去编辑其他批次条时才退出编辑态
|
||||
if (editingChip.value?.key === target.key && editingChip.value?.idx === target.idx) {
|
||||
cancelChipEdit();
|
||||
}
|
||||
await loadLines();
|
||||
// loadLines 重建行 DOM:若用户已切去编辑其他批次条,重聚焦其日期框,
|
||||
// 否则焦点丢失后后续「失焦提交」永远不会触发(表现为填了不保存)
|
||||
if (editingChip.value) {
|
||||
void nextTick(() => {
|
||||
document.querySelector<HTMLInputElement>('[data-chip-edit] [data-chip-date]')?.focus();
|
||||
});
|
||||
}
|
||||
} catch (error) {
|
||||
msg.error(error instanceof Error ? error.message : t('workspace.orderDeliveryReply.saveFailedTitle'));
|
||||
const message = error instanceof Error ? error.message : '';
|
||||
if (message.includes('LINE_NOT_FOUND') || message.includes('不在同步范围') || message.includes('not found')) {
|
||||
editingChip.value = null;
|
||||
chipIssue.value = '';
|
||||
await loadLines();
|
||||
}
|
||||
} finally {
|
||||
chipSaving.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
/* ============ 导出 Excel(2026-10-09) ============ */
|
||||
const exporting = ref(false);
|
||||
|
||||
/** 按当前筛选(appliedFilters)导出全部命中行;后端生成 xlsx,前端 blob 触发下载。 */
|
||||
async function doExportExcel() {
|
||||
exporting.value = true;
|
||||
try {
|
||||
await exportOrderDeliveryLines({ ...appliedFilters });
|
||||
msg.success(t('workspace.orderDeliveryReply.exportDone'));
|
||||
} catch (error) {
|
||||
msg.error(error instanceof Error ? error.message : t('workspace.orderDeliveryReply.exportFailed'));
|
||||
} finally {
|
||||
exporting.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
/* ============ 通知 ============ */
|
||||
const notifying = ref(false);
|
||||
const notifyConfirmVisible = ref(false);
|
||||
|
||||
/** 批量通知入口:先弹共享 DeleteConfirmDialog(primary 语气)二次确认,确认后执行 doNotifyBatch。 */
|
||||
function requestNotifyBatch() {
|
||||
if (!notifiableSelected.value.length) return;
|
||||
notifyConfirmVisible.value = true;
|
||||
}
|
||||
|
||||
/** 批量通知:部分成功 warning 汇总,全部失败 error;提示后刷新列表让锁定即时生效。 */
|
||||
async function doNotifyBatch() {
|
||||
const lines = notifiableSelected.value;
|
||||
if (!lines.length) return;
|
||||
const ok = window.confirm(t('workspace.orderDeliveryReply.notifyBatchConfirm', { count: lines.length }));
|
||||
if (!ok) return;
|
||||
notifying.value = true;
|
||||
try {
|
||||
const summary = await notifyOrderDeliveryBatch(lines.map((line) => ({ order_no: line.order_no, line_no: line.line_no })));
|
||||
@@ -373,15 +536,16 @@ function clearHighlight() {
|
||||
}
|
||||
|
||||
const isLineHighlighted = (line: OrderDeliveryLine) => highlightKey.value === lineKey(line);
|
||||
const rowCls = (line: OrderDeliveryLine) =>
|
||||
isLineHighlighted(line) ? 'bg-amber-50' : selected.value.includes(lineKey(line)) ? 'bg-blue-50/60' : '';
|
||||
/** 冻结单元格必须实色背景(防透出滚动内容),且与整行高亮/勾选色联动;高亮优先于勾选。 */
|
||||
const frozenCellCls = (line: OrderDeliveryLine) =>
|
||||
isLineHighlighted(line)
|
||||
? 'bg-amber-100 group-hover:bg-amber-200'
|
||||
: selected.value.includes(lineKey(line))
|
||||
? 'bg-blue-100 group-hover:bg-blue-200'
|
||||
: 'bg-white group-hover:bg-slate-100';
|
||||
/** 行交互态:直达高亮(warning)优先于勾选选中(info),均走状态令牌(亮暗自适应)。 */
|
||||
const rowCls = (line: OrderDeliveryLine) => {
|
||||
if (isLineHighlighted(line)) return 'bg-row-highlight';
|
||||
return selected.value.includes(lineKey(line)) ? 'bg-row-selected' : '';
|
||||
};
|
||||
/** 冻结单元格用 utilities.css 的 frozen-cell(实色基底防透出滚动内容),状态与整行联动;高亮优先于勾选。 */
|
||||
const frozenCellCls = (line: OrderDeliveryLine) => {
|
||||
if (isLineHighlighted(line)) return 'frozen-cell frozen-cell--highlight';
|
||||
return selected.value.includes(lineKey(line)) ? 'frozen-cell frozen-cell--selected' : 'frozen-cell';
|
||||
};
|
||||
|
||||
/** 列表就绪后定位目标行:滚动到视口中央 + 高亮 8 秒;行不在当前筛选结果中时静默跳过。 */
|
||||
async function focusTargetLine(orderNo: string, lineNo: number) {
|
||||
@@ -430,15 +594,17 @@ onMounted(async () => {
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<!-- 全页统一字号:与表头一致(text-sm 14px),根容器设定基准,子元素不再覆写;
|
||||
唯一例外:交期回复状态/交期已锁定徽标保持 text-xs(12px)加粗 -->
|
||||
<!-- 高度收敛至视口(h-screen + overflow-hidden):页面自身不滚动,滚动全部在表格容器内,
|
||||
列头 sticky 固定、横向滚动条常驻表格底缘;聊天壳 iframe 与独立路由均适用 -->
|
||||
<div class="flex h-screen flex-col gap-4 overflow-hidden p-6 text-sm">
|
||||
<!-- 全页基准字号:text-sm 14px(表头/筛选区/工具栏/表格统一),子元素按需覆写;
|
||||
例外:页头标题 text-lg→md:text-xl(18/20px,与合同付款预警页头对齐)、徽章类 badge 基类自带 text-xs(12px)
|
||||
高度收敛至视口(h-screen + overflow-hidden):页面自身不滚动,滚动全部在表格容器内,
|
||||
列头 sticky 固定、横向滚动条常驻表格底缘;聊天壳 iframe 与独立路由均适用。
|
||||
page-shell:iframe 嵌入路由无外层布局壳,由本页根节点补齐 L1 页面底色与前景色 -->
|
||||
<div class="page-shell flex h-screen flex-col gap-4 overflow-hidden p-6 text-sm">
|
||||
<!-- 页头:标题 + 最近同步 + 手动刷新 -->
|
||||
<div class="flex flex-wrap items-center gap-3">
|
||||
<h1 class="font-bold text-primary">{{ t('workspace.nav.orderDeliveryReply') }}</h1>
|
||||
<span class="rounded-full px-3 py-1" :class="latestSyncFailed ? 'bg-rose-50 text-rose-600' : 'bg-blue-50 text-blue-600'">
|
||||
<!-- 页头标题字号与合同付款预警页头一致:小屏 text-lg 18px、≥768px md:text-xl 20px -->
|
||||
<h1 class="text-lg font-bold text-primary md:text-xl">{{ t('workspace.nav.orderDeliveryReply') }}</h1>
|
||||
<span class="badge whitespace-nowrap" :class="latestSyncFailed ? 'badge-error' : 'badge-info'">
|
||||
{{ latestSyncText }}
|
||||
</span>
|
||||
<div class="flex-1" />
|
||||
@@ -447,72 +613,70 @@ onMounted(async () => {
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<!-- 搜索区:合并关键词搜索(订单/产品/客户命中任一字段),字号与表格统一(text-sm),shrink-0 防压缩 -->
|
||||
<div class="flex shrink-0 flex-wrap items-end gap-3 rounded-2xl border border-default bg-surface px-4 py-2.5">
|
||||
<label class="flex flex-col gap-1 text-muted">
|
||||
{{ t('workspace.orderDeliveryReply.filterKeyword') }}
|
||||
<input v-model="filters.keyword" class="h-8 min-w-[340px] rounded-lg border border-default px-3 text-primary outline-none focus:border-blue-500" :placeholder="t('workspace.orderDeliveryReply.filterKeywordPh')" @keyup.enter="doSearch" />
|
||||
</label>
|
||||
<label class="flex flex-col gap-1 text-muted">
|
||||
{{ t('workspace.orderDeliveryReply.filterOrderDate') }}
|
||||
<input v-model="filters.order_date" type="date" class="h-8 rounded-lg border border-default px-3 text-primary outline-none focus:border-blue-500" />
|
||||
</label>
|
||||
<label class="flex flex-col gap-1 text-muted">
|
||||
{{ t('workspace.orderDeliveryReply.filterStatus') }}
|
||||
<!-- 状态筛选选择即生效(无需再点查询);其余条件仍由「查询」统一提交 -->
|
||||
<select v-model="filters.status" class="min-w-[140px] rounded-lg border border-default bg-white px-3 py-[5px] text-sm leading-5 text-primary outline-none focus:border-blue-500" @change="doSearch">
|
||||
<option value="">{{ t('workspace.orderDeliveryReply.statusAll') }}</option>
|
||||
<option value="replied">{{ t('workspace.orderDeliveryReply.statusReplied') }}</option>
|
||||
<option value="not_fully_replied">{{ t('workspace.orderDeliveryReply.statusNotFully') }}</option>
|
||||
</select>
|
||||
</label>
|
||||
<button type="button" class="btn-primary h-8" @click="doSearch">{{ t('workspace.orderDeliveryReply.search') }}</button>
|
||||
<button type="button" class="btn-ghost h-8" @click="doReset">{{ t('workspace.orderDeliveryReply.reset') }}</button>
|
||||
<div class="flex-1" />
|
||||
<span class="text-muted">{{ t('workspace.orderDeliveryReply.totalCount', { count: total }) }}</span>
|
||||
<!-- 搜索区:合并关键词搜索(订单/产品/客户命中任一字段),shrink-0 防压缩;surface-panel 为设计系统 L2 区块容器(无 hover 阴影)。
|
||||
外置字段标签已取消(2026-10-09:去掉提示字及其占位,单行紧凑布局与合同付款预警筛选一致):
|
||||
字段含义由输入框 placeholder / 选项承担,无障碍语义用 aria-label 保留(复用 filterKeyword 等 i18n 键)。
|
||||
输入控件显式 text-sm(14px)+h-9(36px):与 .contract-filter-input(14px/36px/圆角8px)渲染规格逐项一致 -->
|
||||
<div class="surface-panel flex shrink-0 flex-wrap items-center gap-3 px-4 py-2.5">
|
||||
<input v-model="filters.keyword" class="input-field h-9 w-auto min-w-[340px] rounded-lg px-3 py-1 text-sm" :placeholder="t('workspace.orderDeliveryReply.filterKeywordPh')" :aria-label="t('workspace.orderDeliveryReply.filterKeyword')" @keyup.enter="doSearch" />
|
||||
<input v-model="filters.order_date" type="date" class="input-field h-9 w-auto rounded-lg px-3 py-1 text-sm" :aria-label="t('workspace.orderDeliveryReply.filterOrderDate')" />
|
||||
<!-- 状态筛选选择即生效(无需再点查询);其余条件仍由「查询」统一提交 -->
|
||||
<select v-model="filters.status" class="select-field h-9 w-auto min-w-[140px] rounded-lg px-3 py-1 text-sm" :aria-label="t('workspace.orderDeliveryReply.filterStatus')" @change="doSearch">
|
||||
<option value="">{{ t('workspace.orderDeliveryReply.statusAll') }}</option>
|
||||
<option value="replied">{{ t('workspace.orderDeliveryReply.statusReplied') }}</option>
|
||||
<option value="not_fully_replied">{{ t('workspace.orderDeliveryReply.statusNotFully') }}</option>
|
||||
</select>
|
||||
<!-- 查询/重置:text-sm(14px)+font-semibold(600)+h-9(36px),与合同付款预警 .contract-filter-submit 完全一致 -->
|
||||
<button type="button" class="btn-primary h-9 text-sm font-semibold" @click="doSearch">{{ t('workspace.orderDeliveryReply.search') }}</button>
|
||||
<button type="button" class="btn-ghost h-9 text-sm font-semibold" @click="doReset">{{ t('workspace.orderDeliveryReply.reset') }}</button>
|
||||
</div>
|
||||
|
||||
<!-- 工具栏:全选 + 联合回复 + 批量通知(shrink-0 防压缩,py-2 紧凑高度) -->
|
||||
<div class="flex shrink-0 flex-wrap items-center gap-3 rounded-2xl border border-default bg-surface px-4 py-2">
|
||||
<div class="surface-panel flex shrink-0 flex-wrap items-center gap-3 px-4 py-2">
|
||||
<label class="flex items-center gap-2 text-primary">
|
||||
<input type="checkbox" class="h-4 w-4 rounded border-default text-blue-600" :checked="allChecked" :indeterminate.prop="someChecked" @change="togglePageAll(($event.target as HTMLInputElement).checked)" />
|
||||
<input type="checkbox" class="admin-checkbox" :checked="allChecked" :indeterminate.prop="someChecked" @change="togglePageAll(($event.target as HTMLInputElement).checked)" />
|
||||
{{ t('workspace.orderDeliveryReply.selectAll') }}
|
||||
</label>
|
||||
<span class="text-muted">{{ t('workspace.orderDeliveryReply.selectedCount', { count: selectedLines.length }) }}</span>
|
||||
<template v-if="canManage">
|
||||
<button type="button" class="btn-primary h-8" :disabled="selectedLines.length === 0" @click="openBatchReply">
|
||||
<button type="button" class="btn-primary h-9 text-sm font-semibold" :disabled="selectedLines.length === 0" @click="openBatchReply">
|
||||
{{ t('workspace.orderDeliveryReply.batchReply') }}
|
||||
</button>
|
||||
<button type="button" class="btn-primary h-8" :disabled="notifiableSelected.length === 0 || notifying" @click="doNotifyBatch">
|
||||
<button type="button" class="btn-primary h-9 text-sm font-semibold" :disabled="notifiableSelected.length === 0 || notifying" @click="requestNotifyBatch">
|
||||
{{ t('workspace.orderDeliveryReply.batchNotify') }}
|
||||
</button>
|
||||
</template>
|
||||
<div class="flex-1" />
|
||||
<span class="whitespace-nowrap rounded-full bg-slate-100 px-3 py-1 text-muted">{{ t('workspace.orderDeliveryReply.toolbarHint') }}</span>
|
||||
<!-- 导出 Excel(2026-10-09 增补,原提示文字胶囊取消):按当前筛选导出全部行 -->
|
||||
<button type="button" class="btn-primary h-9 text-sm font-semibold" :disabled="exporting" @click="doExportExcel">
|
||||
<Download class="h-4 w-4" aria-hidden="true" />
|
||||
{{ t('workspace.orderDeliveryReply.exportExcel') }}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<!-- 列表 -->
|
||||
<div class="min-h-0 flex-1 overflow-auto rounded-2xl border border-default bg-surface">
|
||||
<table class="w-full border-collapse">
|
||||
<div class="surface-panel min-h-0 flex-1 overflow-auto">
|
||||
<table class="w-full border-collapse text-center">
|
||||
<!-- z-30 高于表体冻结单元格(z-20):纵向滚动时冻结列不会盖住表头 -->
|
||||
<thead class="sticky top-0 z-30 bg-slate-50 text-muted [&_th]:whitespace-nowrap">
|
||||
<thead class="sticky top-0 z-30 bg-surface-soft text-muted [&_th]:whitespace-nowrap">
|
||||
<tr>
|
||||
<!-- 左侧冻结标识区(前四列):勾选/客户编号/订单日期/订单单号:项次,宽度固定保证偏移对齐 -->
|
||||
<th class="sticky left-0 z-30 w-8 bg-slate-50 px-2 py-2" />
|
||||
<th class="sticky left-8 z-30 w-32 min-w-[8rem] bg-slate-50 px-2 py-2 text-left">{{ t('workspace.orderDeliveryReply.colCustomer') }}</th>
|
||||
<th class="sticky left-[10rem] z-30 w-24 bg-slate-50 px-2 py-2 text-left">{{ t('workspace.orderDeliveryReply.colOrderDate') }}</th>
|
||||
<th class="sticky left-[16rem] z-30 w-40 min-w-[10rem] border-r border-default bg-slate-50 px-2 py-2 text-left shadow-[2px_0_6px_-2px_rgba(15,23,42,0.12)]">{{ t('workspace.orderDeliveryReply.colOrderLine') }}</th>
|
||||
<th class="px-2 py-2 text-left">{{ t('workspace.orderDeliveryReply.colPartNo') }}</th>
|
||||
<th class="px-2 py-2 text-left">{{ t('workspace.orderDeliveryReply.colCustomerPartNo') }}</th>
|
||||
<th class="px-2 py-2 text-right">{{ t('workspace.orderDeliveryReply.colQty') }}</th>
|
||||
<th class="px-2 py-2 text-left">{{ t('workspace.orderDeliveryReply.colAgreedDate') }}</th>
|
||||
<th class="px-2 py-2 text-left">{{ t('workspace.orderDeliveryReply.colStatus') }}</th>
|
||||
<th class="px-2 py-2 text-left">{{ t('workspace.orderDeliveryReply.colReply') }}</th>
|
||||
<th class="px-2 py-2 text-left">{{ t('workspace.orderDeliveryReply.colReplyPerson') }}</th>
|
||||
<th class="px-2 py-2 text-left">{{ t('workspace.orderDeliveryReply.colSalesperson') }}</th>
|
||||
<th class="px-2 py-2 text-left">{{ t('workspace.orderDeliveryReply.colCustomerPo') }}</th>
|
||||
<th class="px-2 py-2 text-left">{{ t('workspace.orderDeliveryReply.colSpec') }}</th>
|
||||
<th class="px-2 py-2 text-left">{{ t('workspace.orderDeliveryReply.colUnit') }}</th>
|
||||
<th class="sticky left-0 z-30 w-8 bg-surface-soft px-2 py-2" />
|
||||
<th class="sticky left-8 z-30 w-32 min-w-[8rem] bg-surface-soft px-2 py-2 text-center">{{ t('workspace.orderDeliveryReply.colCustomer') }}</th>
|
||||
<th class="sticky left-[10rem] z-30 w-24 bg-surface-soft px-2 py-2 text-center">{{ t('workspace.orderDeliveryReply.colOrderDate') }}</th>
|
||||
<th class="sticky left-[16rem] z-30 w-40 min-w-[10rem] border-r border-default bg-surface-soft px-2 py-2 text-center shadow-sticky-col">{{ t('workspace.orderDeliveryReply.colOrderLine') }}</th>
|
||||
<th class="px-2 py-2 text-center">{{ t('workspace.orderDeliveryReply.colPartNo') }}</th>
|
||||
<th class="px-2 py-2 text-center">{{ t('workspace.orderDeliveryReply.colCustomerPartNo') }}</th>
|
||||
<th class="px-2 py-2 text-center">{{ t('workspace.orderDeliveryReply.colQty') }}</th>
|
||||
<th class="px-2 py-2 text-center">{{ t('workspace.orderDeliveryReply.colAgreedDate') }}</th>
|
||||
<th class="px-2 py-2 text-center">{{ t('workspace.orderDeliveryReply.colStatus') }}</th>
|
||||
<th class="px-2 py-2 text-center">{{ t('workspace.orderDeliveryReply.colReply') }}</th>
|
||||
<th class="px-2 py-2 text-center">{{ t('workspace.orderDeliveryReply.colReplyPerson') }}</th>
|
||||
<th class="px-2 py-2 text-center">{{ t('workspace.orderDeliveryReply.colSalesperson') }}</th>
|
||||
<th class="px-2 py-2 text-center">{{ t('workspace.orderDeliveryReply.colCustomerPo') }}</th>
|
||||
<th class="px-2 py-2 text-center">{{ t('workspace.orderDeliveryReply.colSpec') }}</th>
|
||||
<th class="px-2 py-2 text-center">{{ t('workspace.orderDeliveryReply.colUnit') }}</th>
|
||||
<th class="px-2 py-2 text-center">{{ t('workspace.orderDeliveryReply.colNotifiedTime') }}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@@ -520,15 +684,15 @@ onMounted(async () => {
|
||||
v-for="line in items"
|
||||
:key="lineKey(line)"
|
||||
:data-line-key="lineKey(line)"
|
||||
class="group border-t border-default hover:bg-slate-50"
|
||||
class="hover-row border-t border-default"
|
||||
:class="rowCls(line)"
|
||||
>
|
||||
<!-- 冻结单元格必须实色背景(半透明会透出滚动内容),并用 group-hover 与整行悬停/选中/直达高亮联动 -->
|
||||
<!-- 冻结单元格:frozen-cell 实色基底(半透明会透出滚动内容),悬停/选中/直达高亮由 CSS 联动 -->
|
||||
<td
|
||||
class="sticky left-0 z-20 px-2 py-1.5"
|
||||
:class="frozenCellCls(line)"
|
||||
>
|
||||
<input type="checkbox" class="h-4 w-4 rounded border-default text-blue-600" :checked="selected.includes(lineKey(line))" @change="toggleLine(line, ($event.target as HTMLInputElement).checked)" />
|
||||
<input type="checkbox" class="admin-checkbox" :checked="selected.includes(lineKey(line))" @change="toggleLine(line, ($event.target as HTMLInputElement).checked)" />
|
||||
</td>
|
||||
<td
|
||||
class="sticky left-8 z-20 w-32 min-w-[8rem] max-w-[8rem] px-2 py-1.5"
|
||||
@@ -543,70 +707,132 @@ onMounted(async () => {
|
||||
:class="frozenCellCls(line)"
|
||||
>{{ line.order_date || '—' }}</td>
|
||||
<td
|
||||
class="sticky left-[16rem] z-20 w-40 min-w-[10rem] max-w-[10rem] overflow-hidden whitespace-nowrap border-r border-default px-2 py-1.5 font-mono shadow-[2px_0_6px_-2px_rgba(15,23,42,0.12)]"
|
||||
class="sticky left-[16rem] z-20 w-40 min-w-[10rem] max-w-[10rem] overflow-hidden whitespace-nowrap border-r border-default px-2 py-1.5 font-mono text-left shadow-sticky-col"
|
||||
:class="frozenCellCls(line)"
|
||||
>{{ line.order_no }}:{{ line.line_no }}</td>
|
||||
<td class="px-2 py-1.5" :title="line.part_name || ''">
|
||||
<div class="max-w-[10rem] truncate font-mono">{{ line.part_no || '—' }}</div>
|
||||
<div class="max-w-[14rem] truncate text-muted">{{ line.part_name || '' }}</div>
|
||||
<!-- 截断盒 mx-auto:限宽盒在列内居中(继承 text-center),截断能力保留 -->
|
||||
<div class="mx-auto max-w-[10rem] truncate font-mono">{{ line.part_no || '—' }}</div>
|
||||
<div class="mx-auto max-w-[14rem] truncate text-muted">{{ line.part_name || '' }}</div>
|
||||
</td>
|
||||
<td class="whitespace-nowrap px-2 py-1.5 font-mono">{{ line.customer_part_no || '—' }}</td>
|
||||
<td class="px-2 py-2 text-right tabular-nums">{{ line.qty ?? '—' }}</td>
|
||||
<td class="px-2 py-2 text-center tabular-nums">{{ line.qty ?? '—' }}</td>
|
||||
<td class="whitespace-nowrap px-2 py-1.5">{{ line.agreed_date || '—' }}</td>
|
||||
<td class="px-2 py-1.5">
|
||||
<span class="whitespace-nowrap rounded-full px-2.5 py-0.5 text-xs font-semibold" :class="statusMeta(line.status).cls">
|
||||
<span class="badge inline-block min-w-[68px] whitespace-nowrap text-center font-semibold" :class="statusMeta(line.status).cls">
|
||||
{{ statusMeta(line.status).label }}
|
||||
</span>
|
||||
</td>
|
||||
<!-- 交期回复:无批次=回复交期;有批次可展开;锁定=已锁定 -->
|
||||
<td class="px-2 py-1.5 align-top">
|
||||
<!-- 交期回复:动作入口为批次条前的加号(lucide Plus);未回复=空批次条(不显示时间/数量);
|
||||
所有行首条批次条前保留等宽加号占位(无动作时为透明占位)、展开行其余批次条加 pl-7 缩进,
|
||||
保证全表批次条左缘对齐;「交期已锁定」徽标已取消(锁定状态由无加号与交期回复人员列「已通知」体现);
|
||||
>1 批时首条批次后有展开/收起小箭头 -->
|
||||
<td class="px-2 py-1.5">
|
||||
<template v-if="line.batches.length === 0">
|
||||
<span class="text-muted">{{ t('workspace.orderDeliveryReply.statusNotReplied') }}</span>
|
||||
<div v-if="canManage" class="mt-0.5">
|
||||
<button type="button" class="rounded-md border border-blue-200 bg-blue-50 px-2 py-0.5 text-blue-600" @click="openSingleReply(line)">
|
||||
{{ t('workspace.orderDeliveryReply.replyAction') }}
|
||||
<div class="flex items-center gap-1">
|
||||
<button
|
||||
v-if="canManage"
|
||||
type="button"
|
||||
class="btn-ghost h-6 w-6 shrink-0 rounded-md p-0"
|
||||
:disabled="chipSaving"
|
||||
:title="t('workspace.orderDeliveryReply.replyAction')"
|
||||
:aria-label="t('workspace.orderDeliveryReply.replyAction')"
|
||||
@click="openSingleReply(line)"
|
||||
>
|
||||
<Plus class="h-4 w-4" />
|
||||
</button>
|
||||
<span v-else class="w-6 shrink-0" aria-hidden="true" />
|
||||
<!-- 未回复空批次条:可管理时可点击就地填写交期+数量(回车/失焦自动保存单行接口);不显示占位文字 -->
|
||||
<div
|
||||
v-if="isChipEditing(line, 0)"
|
||||
data-chip-edit
|
||||
class="flex items-center gap-1 rounded border-l-[3px] border-brand-500 bg-surface-soft px-1.5 py-0.5"
|
||||
:class="chipSaving ? 'opacity-60' : ''"
|
||||
@focusout="onChipFocusout($event, line, 0)"
|
||||
@keydown.enter.prevent="chipCommit(line, 0)"
|
||||
@keydown.esc.prevent="cancelChipEdit"
|
||||
>
|
||||
<input v-model="chipDraft.planned_date" data-chip-date type="date" class="h-6 w-[125px] rounded border border-default bg-surface px-1 text-sm text-primary outline-none focus:border-brand-500" :aria-label="t('workspace.orderDeliveryReply.filterOrderDate')" />
|
||||
<input v-model="chipDraft.qty" type="number" min="0" class="h-6 w-16 rounded border border-default bg-surface px-1 text-sm text-primary outline-none focus:border-brand-500" :aria-label="t('workspace.orderDeliveryReply.colQty')" @focus="($event.target as HTMLInputElement).select()" />
|
||||
<span v-if="line.unit" class="text-muted">{{ line.unit }}</span>
|
||||
</div>
|
||||
<div
|
||||
v-else-if="isChipEditable(line)"
|
||||
class="h-6 w-24 cursor-pointer rounded border-l-[3px] border-brand-500 bg-surface-soft transition-colors hover-surface-strong"
|
||||
:title="t('workspace.orderDeliveryReply.replyAction')"
|
||||
@click="startChipEdit(line, 0)"
|
||||
/>
|
||||
<div v-else class="h-6 w-24 rounded border-l-[3px] border-brand-500 bg-surface-soft" />
|
||||
</div>
|
||||
<p v-if="isChipEditing(line, 0) && chipIssue" class="mt-0.5 text-xs text-status-error">{{ chipIssue }}</p>
|
||||
</template>
|
||||
<template v-else>
|
||||
<div class="flex items-center gap-2">
|
||||
<span class="whitespace-nowrap rounded-full border border-default bg-slate-50 px-2 py-0.5 text-muted">
|
||||
{{ t('workspace.orderDeliveryReply.batchCount', { count: line.batches.length }) }} ·
|
||||
{{ t('workspace.orderDeliveryReply.repliedOf', { replied: repliedQty(line), remain: undelivered(line) }) }}
|
||||
<span v-if="repliedQty(line) > undelivered(line)" class="ml-1 font-semibold text-orange-500">{{ t('workspace.orderDeliveryReply.overTag') }}</span>
|
||||
</span>
|
||||
<button v-if="line.batches.length > 1" type="button" class="rounded-full border border-default px-2 py-0.5 text-blue-600" @click="toggleExpand(lineKey(line))">
|
||||
{{ expanded.includes(lineKey(line)) ? t('workspace.orderDeliveryReply.collapse') : t('workspace.orderDeliveryReply.expand', { count: line.batches.length - 1 }) }}
|
||||
</button>
|
||||
</div>
|
||||
<div class="mt-0.5 flex flex-col gap-0.5">
|
||||
<div class="flex flex-col gap-0.5">
|
||||
<div
|
||||
v-for="(batch, idx) in line.batches"
|
||||
:key="batch.seq ?? idx"
|
||||
v-show="expanded.includes(lineKey(line)) || idx === 0"
|
||||
class="max-w-[230px] truncate rounded border-l-[3px] border-blue-500 bg-blue-50/50 px-2 py-0.5 text-secondary"
|
||||
v-show="idx === 0 || expanded.includes(lineKey(line))"
|
||||
class="flex items-center gap-1"
|
||||
:class="idx > 0 ? 'pl-7' : ''"
|
||||
>
|
||||
{{ batch.planned_date }} · <b class="text-blue-600">{{ batch.qty }}</b> {{ line.unit }}
|
||||
<i v-if="batch.remark" class="ml-1 not-italic text-muted">{{ batch.remark }}</i>
|
||||
<template v-if="idx === 0">
|
||||
<button
|
||||
v-if="canManage && !line.locked"
|
||||
type="button"
|
||||
class="btn-ghost h-6 w-6 shrink-0 rounded-md p-0"
|
||||
:disabled="chipSaving"
|
||||
:title="t('workspace.orderDeliveryReply.editReplyAction')"
|
||||
:aria-label="t('workspace.orderDeliveryReply.editReplyAction')"
|
||||
@click="openSingleReply(line)"
|
||||
>
|
||||
<Plus class="h-4 w-4" />
|
||||
</button>
|
||||
<span v-else class="w-6 shrink-0" aria-hidden="true" />
|
||||
</template>
|
||||
<!-- 批次条:未锁定可管理行点击原地编辑(日期+数量,回车/失焦自动保存) -->
|
||||
<div
|
||||
v-if="isChipEditing(line, idx)"
|
||||
data-chip-edit
|
||||
class="flex items-center gap-1 rounded border-l-[3px] border-brand-500 bg-surface-soft px-1.5 py-0.5"
|
||||
:class="chipSaving ? 'opacity-60' : ''"
|
||||
@focusout="onChipFocusout($event, line, idx)"
|
||||
@keydown.enter.prevent="chipCommit(line, idx)"
|
||||
@keydown.esc.prevent="cancelChipEdit"
|
||||
>
|
||||
<input v-model="chipDraft.planned_date" data-chip-date type="date" class="h-6 w-[125px] rounded border border-default bg-surface px-1 text-sm text-primary outline-none focus:border-brand-500" :aria-label="t('workspace.orderDeliveryReply.filterOrderDate')" />
|
||||
<input v-model="chipDraft.qty" type="number" min="0" class="h-6 w-16 rounded border border-default bg-surface px-1 text-sm text-primary outline-none focus:border-brand-500" :aria-label="t('workspace.orderDeliveryReply.colQty')" @focus="($event.target as HTMLInputElement).select()" />
|
||||
<span v-if="line.unit" class="text-muted">{{ line.unit }}</span>
|
||||
</div>
|
||||
<div
|
||||
v-else
|
||||
class="max-w-[230px] truncate rounded border-l-[3px] border-brand-500 bg-surface-soft px-2 py-0.5 text-secondary"
|
||||
:class="isChipEditable(line) ? 'cursor-pointer transition-colors hover-surface-strong' : ''"
|
||||
:title="isChipEditable(line) ? t('workspace.orderDeliveryReply.editReplyAction') : undefined"
|
||||
@click="startChipEdit(line, idx)"
|
||||
>
|
||||
{{ batch.planned_date }} · <b class="text-brand-600">{{ batch.qty }}</b> {{ line.unit }}
|
||||
</div>
|
||||
<button
|
||||
v-if="idx === 0 && line.batches.length > 1"
|
||||
type="button"
|
||||
class="btn-ghost h-6 w-6 shrink-0 rounded-md p-0"
|
||||
:title="expanded.includes(lineKey(line)) ? t('workspace.orderDeliveryReply.collapse') : t('workspace.orderDeliveryReply.expand', { count: line.batches.length - 1 })"
|
||||
:aria-label="expanded.includes(lineKey(line)) ? t('workspace.orderDeliveryReply.collapse') : t('workspace.orderDeliveryReply.expand', { count: line.batches.length - 1 })"
|
||||
@click="toggleExpand(lineKey(line))"
|
||||
>
|
||||
<ChevronUp v-if="expanded.includes(lineKey(line))" class="h-4 w-4" />
|
||||
<ChevronDown v-else class="h-4 w-4" />
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="mt-0.5">
|
||||
<span v-if="line.locked" class="rounded-full bg-emerald-50 px-2.5 py-0.5 text-xs font-semibold text-emerald-600">{{ t('workspace.orderDeliveryReply.lockedTag') }}</span>
|
||||
<button v-else-if="canManage" type="button" class="rounded-md border border-blue-200 bg-blue-50 px-2 py-0.5 text-blue-600" @click="openSingleReply(line)">
|
||||
{{ t('workspace.orderDeliveryReply.editReplyAction') }}
|
||||
</button>
|
||||
</div>
|
||||
<p v-if="editingChip && editingChip.key === lineKey(line) && chipIssue" class="mt-0.5 text-xs text-status-error">{{ chipIssue }}</p>
|
||||
</template>
|
||||
</td>
|
||||
<!-- 交期回复人员:锁定行附带已通知对象与时间(原「通知业务部门」列已取消,信息并入此处) -->
|
||||
<!-- 交期回复人员:通知时间已拆至独立「通知时间」列(2026-10-09),本列仅工号/姓名/待通知提示 -->
|
||||
<td class="px-2 py-1.5">
|
||||
<template v-if="line.notified_employee_id || line.notified_user_name">
|
||||
<div class="font-mono">{{ line.notified_employee_id || '' }}</div>
|
||||
<div class="text-muted">{{ line.notified_user_name || '' }}</div>
|
||||
<div v-if="line.locked" class="text-emerald-600">
|
||||
{{ t('workspace.orderDeliveryReply.notifiedTag', { name: line.salesperson_name || line.salesperson_code || '' }) }}
|
||||
<span class="text-muted">{{ line.notified_at || '' }}</span>
|
||||
</div>
|
||||
</template>
|
||||
<span v-else class="text-muted">{{ t('workspace.orderDeliveryReply.pendingNotify') }}</span>
|
||||
</td>
|
||||
@@ -615,20 +841,21 @@ onMounted(async () => {
|
||||
<div class="whitespace-nowrap">{{ line.salesperson_name || line.salesperson_code || '—' }}</div>
|
||||
<div class="text-muted">{{ line.dept_name || line.dept_code || '' }}</div>
|
||||
</td>
|
||||
<td class="px-2 py-1.5 font-mono" :title="line.customer_po || ''"><span class="block max-w-[10rem] truncate">{{ line.customer_po || '—' }}</span></td>
|
||||
<td class="px-2 py-1.5" :title="line.spec || ''"><span class="block max-w-[10rem] truncate">{{ line.spec || '—' }}</span></td>
|
||||
<td class="px-2 py-1.5 font-mono" :title="line.customer_po || ''"><span class="mx-auto block max-w-[10rem] truncate">{{ line.customer_po || '—' }}</span></td>
|
||||
<td class="px-2 py-1.5" :title="line.spec || ''"><span class="mx-auto block max-w-[10rem] truncate">{{ line.spec || '—' }}</span></td>
|
||||
<td class="px-2 py-1.5">{{ line.unit || '—' }}</td>
|
||||
<!-- 通知时间(2026-10-09 自「交期回复人员」列拆出独立列):锁定行展示通知时间戳,单行不折行 -->
|
||||
<td class="whitespace-nowrap px-2 py-1.5" :class="line.locked ? 'text-status-success' : 'text-muted'">{{ line.locked ? (line.notified_at || '—') : '—' }}</td>
|
||||
</tr>
|
||||
<tr v-if="!loading && items.length === 0">
|
||||
<td colspan="15" class="px-4 py-16 text-center text-muted">{{ t('workspace.orderDeliveryReply.empty') }}</td>
|
||||
<td colspan="16" class="px-4 py-16 text-center text-muted">{{ t('workspace.orderDeliveryReply.empty') }}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<!-- 分页:复用管理控制台-数据报表的 PaginationBar(摘要 + 每页条数 + 页码按钮) -->
|
||||
<!-- 分页:复用管理控制台-数据报表的 PaginationBar(摘要 + 每页条数 + 页码按钮),组件自带字号不再强改 -->
|
||||
<PaginationBar
|
||||
class="[&_*]:!text-sm"
|
||||
:page="page"
|
||||
:page-size="pageSize"
|
||||
:total="total"
|
||||
@@ -637,30 +864,29 @@ onMounted(async () => {
|
||||
@update:page-size="changePageSize"
|
||||
/>
|
||||
|
||||
<!-- 回复弹窗 -->
|
||||
<div v-if="modalVisible" class="fixed inset-0 z-50 flex items-center justify-center bg-slate-900/40" @click.self="modalVisible = false">
|
||||
<div class="flex max-h-[88vh] w-[min(960px,94vw)] flex-col overflow-hidden rounded-2xl bg-white shadow-2xl">
|
||||
<div class="flex items-center gap-3 border-b border-default px-5 py-4">
|
||||
<!-- 回复弹窗:dialog-overlay/panel/header/body/footer 设计系统 L2 结构 -->
|
||||
<div v-if="modalVisible" class="dialog-overlay items-center" @click.self="modalVisible = false">
|
||||
<div class="dialog-panel max-h-[88vh] w-[min(960px,94vw)]">
|
||||
<div class="dialog-header">
|
||||
<h3 class="font-bold text-primary">{{ modalTitle }}</h3>
|
||||
<div class="flex-1" />
|
||||
<button type="button" class="text-muted" @click="modalVisible = false">×</button>
|
||||
<button type="button" class="btn-ghost h-8 w-8 px-0 text-lg leading-none" @click="modalVisible = false">×</button>
|
||||
</div>
|
||||
<div class="flex-1 overflow-auto px-5 py-4">
|
||||
<div class="dialog-body">
|
||||
<!-- 快速统一交期:仅联合回复弹窗显示;单行回复/修改回复弹窗已取消该区(2026-10-07),直接逐批次填写 -->
|
||||
<div v-if="modalMode === 'batch'" class="mb-4 flex flex-wrap items-end gap-3 rounded-xl border border-default bg-blue-50/40 px-4 py-3">
|
||||
<div v-if="modalMode === 'batch'" class="flex flex-wrap items-end gap-3 rounded-xl border border-default bg-surface-soft px-4 py-3">
|
||||
<label class="flex flex-col gap-1 text-muted">
|
||||
{{ t('workspace.orderDeliveryReply.quickDate') }}
|
||||
<input v-model="quickDate" type="date" class="h-9 rounded-lg border border-default px-3 text-primary" />
|
||||
<input v-model="quickDate" type="date" class="input-field h-9 w-auto rounded-lg px-3 py-1.5" />
|
||||
</label>
|
||||
<button type="button" class="h-9 rounded-lg border border-default px-3 text-primary" @click="applyQuickDate">
|
||||
<button type="button" class="btn-secondary btn-sm h-9" @click="applyQuickDate">
|
||||
{{ t('workspace.orderDeliveryReply.applyQuickDate') }}
|
||||
</button>
|
||||
<span class="text-muted">{{ t('workspace.orderDeliveryReply.modalHint') }}</span>
|
||||
</div>
|
||||
<!-- 每行批次编辑器 -->
|
||||
<div v-for="entry in modalLines" :key="lineKey(entry.line)" class="mb-4 overflow-hidden rounded-xl border border-default">
|
||||
<div class="flex flex-wrap items-center gap-2 bg-slate-50 px-3 py-2">
|
||||
<span class="rounded bg-indigo-50 px-2 py-0.5 font-semibold text-indigo-600">{{ entry.line.order_no }}</span>
|
||||
<div v-for="entry in modalLines" :key="lineKey(entry.line)" class="overflow-hidden rounded-xl border border-default">
|
||||
<div class="flex flex-wrap items-center gap-2 bg-surface-soft px-3 py-2">
|
||||
<span class="rounded bg-surface-strong px-2 py-0.5 font-semibold text-primary">{{ entry.line.order_no }}</span>
|
||||
<span>{{ t('workspace.orderDeliveryReply.itemLabel', { item: entry.line.line_no }) }}</span>
|
||||
<span class="text-muted">{{ entry.line.customer_no }} · {{ entry.line.customer_short_name }}</span>
|
||||
<span class="text-muted">{{ entry.line.part_no }} · {{ entry.line.part_name }}</span>
|
||||
@@ -669,27 +895,36 @@ onMounted(async () => {
|
||||
</span>
|
||||
</div>
|
||||
<div class="flex flex-col gap-2 px-3 py-3">
|
||||
<div v-for="(batch, idx) in entry.batches" :key="idx" class="grid grid-cols-[170px_120px_1fr_36px] items-center gap-2">
|
||||
<input v-model="batch.planned_date" type="date" class="h-9 rounded-lg border border-default px-2 text-primary" />
|
||||
<input v-model="batch.qty" type="number" min="0" :placeholder="t('workspace.orderDeliveryReply.qtyPh')" class="h-9 rounded-lg border border-default px-2 text-primary" />
|
||||
<input v-model="batch.remark" :placeholder="t('workspace.orderDeliveryReply.remarkPh')" class="h-9 rounded-lg border border-default px-2 text-primary" />
|
||||
<button type="button" class="h-9 rounded-lg bg-rose-50 text-rose-600" :title="t('workspace.orderDeliveryReply.removeBatch')" @click="entry.batches.splice(idx, 1)">✕</button>
|
||||
<div v-for="(batch, idx) in entry.batches" :key="idx" class="grid grid-cols-[170px_120px_1fr_40px] items-center gap-2">
|
||||
<input v-model="batch.planned_date" type="date" class="input-field h-9 rounded-lg px-2 py-1.5" />
|
||||
<input v-model="batch.qty" type="number" min="0" :placeholder="t('workspace.orderDeliveryReply.qtyPh')" class="input-field h-9 rounded-lg px-2 py-1.5" />
|
||||
<input v-model="batch.remark" :placeholder="t('workspace.orderDeliveryReply.remarkPh')" class="input-field h-9 rounded-lg px-2 py-1.5" />
|
||||
<button type="button" class="btn-danger btn-sm" :title="t('workspace.orderDeliveryReply.removeBatch')" @click="entry.batches.splice(idx, 1)">✕</button>
|
||||
</div>
|
||||
<button type="button" class="w-full rounded-lg border border-dashed border-slate-300 py-2 text-blue-600" @click="entry.batches.push({ planned_date: '', qty: '', remark: '' })">
|
||||
<button type="button" class="w-full rounded-lg border border-dashed border-default py-2 text-brand-600 transition-colors hover-surface-soft" @click="entry.batches.push({ planned_date: '', qty: '', remark: '' })">
|
||||
{{ t('workspace.orderDeliveryReply.addBatch') }}
|
||||
</button>
|
||||
<!-- 行级实时校验提示:缺交期/缺数量按批次序号指出,合计不等给出已填/应填;随填写实时切换 -->
|
||||
<p v-if="lineIssueText(entry)" class="text-rose-500">{{ lineIssueText(entry) }}</p>
|
||||
<p v-if="lineIssueText(entry)" class="text-status-error">{{ lineIssueText(entry) }}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex justify-end gap-3 border-t border-default bg-slate-50 px-5 py-3">
|
||||
<button type="button" class="btn-ghost" @click="modalVisible = false">{{ t('common.cancel') }}</button>
|
||||
<div class="dialog-footer">
|
||||
<button type="button" class="btn-secondary" @click="modalVisible = false">{{ t('common.cancel') }}</button>
|
||||
<button type="button" class="btn-primary" :disabled="saving" @click="saveReplies">
|
||||
{{ saving ? t('workspace.orderDeliveryReply.saving') : t('workspace.orderDeliveryReply.saveReply') }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 批量通知二次确认:共享 DeleteConfirmDialog(primary 语气,非删除;确认/取消文案用组件默认 i18n) -->
|
||||
<DeleteConfirmDialog
|
||||
v-model="notifyConfirmVisible"
|
||||
:title="t('workspace.orderDeliveryReply.batchNotify')"
|
||||
:message="t('workspace.orderDeliveryReply.notifyBatchConfirm', { count: notifiableSelected.length })"
|
||||
confirm-tone="primary"
|
||||
@confirm="doNotifyBatch"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
@@ -5745,6 +5745,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",
|
||||
@@ -5754,6 +5758,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",
|
||||
@@ -5761,11 +5768,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",
|
||||
|
||||
@@ -2,12 +2,21 @@
|
||||
"kbDifySettings": {
|
||||
"title": "Dify Settings",
|
||||
"subtitle": "Manage Dify connection and default sync parameters for the knowledge base module.",
|
||||
"sections": {
|
||||
"connection": "Connection",
|
||||
"retrieval": "Retrieval",
|
||||
"chunking": "Chunking"
|
||||
},
|
||||
"hints": {
|
||||
"maxTokens": "Max tokens",
|
||||
"tokens": "Tokens"
|
||||
},
|
||||
"loading": "Loading settings...",
|
||||
"save": "Save Settings",
|
||||
"saving": "Saving...",
|
||||
"fields": {
|
||||
"baseUrl": "Dify Base URL",
|
||||
"apiKey": "Dify API Key",
|
||||
"baseUrl": "Base URL",
|
||||
"apiKey": "API key",
|
||||
"permission": "Visibility permission",
|
||||
"indexingTechnique": "Indexing mode",
|
||||
"searchMethod": "Search Method",
|
||||
@@ -16,9 +25,9 @@
|
||||
"topK": "Result count (Top K)",
|
||||
"scoreThresholdEnabled": "Enable score threshold",
|
||||
"scoreThreshold": "Score threshold",
|
||||
"segmentMaxTokens": "Maximum tokens per segment (documents)",
|
||||
"segmentMaxTokensExcel": "Maximum tokens per segment (Excel/CSV)",
|
||||
"segmentChunkOverlap": "Overlapping tokens per segment"
|
||||
"segmentMaxTokens": "Documents",
|
||||
"segmentMaxTokensExcel": "Excel/CSV",
|
||||
"segmentChunkOverlap": "Overlap"
|
||||
},
|
||||
"options": {
|
||||
"permission": {
|
||||
@@ -52,9 +61,9 @@
|
||||
"unreachable": "Unreachable",
|
||||
"notConfigured": "Not configured",
|
||||
"datasetCount": "Dataset Count",
|
||||
"configured": "Configured: ",
|
||||
"configured": "Configured",
|
||||
"boundGroups": "Bound Groups",
|
||||
"localSyncRecords": "Local Sync Records: ",
|
||||
"localSyncRecords": "Local sync records",
|
||||
"syncingVersions": "Syncing Versions",
|
||||
"syncedVersions": "Synced Versions",
|
||||
"pendingSyncJobs": "Pending Sync Jobs",
|
||||
|
||||
@@ -999,7 +999,7 @@
|
||||
"syncSkipped": "A sync is already running; try again later",
|
||||
"syncFailedTitle": "Sync failed; last snapshot kept",
|
||||
"filterKeyword": "Keyword (order / product / customer / salesperson / replier)",
|
||||
"filterKeywordPh": "Search by order no., part no., name, customer part no., customer, salesperson, or reply person",
|
||||
"filterKeywordPh": "Order / product / customer / salesperson / reply person",
|
||||
"filterOrderDate": "Order Date",
|
||||
"filterStatus": "Reply Status",
|
||||
"statusAll": "All",
|
||||
@@ -1007,12 +1007,10 @@
|
||||
"statusNotFully": "Not fully replied",
|
||||
"statusNotReplied": "Not replied",
|
||||
"statusPartial": "Partially replied",
|
||||
"totalCount": "{count} product lines",
|
||||
"selectAll": "Select all (this page)",
|
||||
"selectedCount": "{count} lines selected",
|
||||
"batchReply": "+ Batch reply",
|
||||
"batchNotify": "Batch notify",
|
||||
"toolbarHint": "Batch reply only saves; click \"Batch notify\" to send and lock.",
|
||||
"colOrderLine": "Order : Item",
|
||||
"colOrderDate": "Order Date",
|
||||
"colCustomer": "Customer",
|
||||
@@ -1024,6 +1022,7 @@
|
||||
"colSpec": "Spec",
|
||||
"colCustomerPartNo": "Customer Part No.",
|
||||
"colAgreedDate": "Agreed Date",
|
||||
"colNotifiedTime": "Notified at",
|
||||
"colUnit": "Unit",
|
||||
"colQty": "Qty",
|
||||
"colDelivered": "Delivered",
|
||||
@@ -1032,15 +1031,13 @@
|
||||
"colReply": "Delivery Reply",
|
||||
"colNotify": "Notify",
|
||||
"colReplyPerson": "Replied By",
|
||||
"batchCount": "{count} batches",
|
||||
"repliedOf": "replied {replied}/{remain}",
|
||||
"overTag": "OVER",
|
||||
"collapse": "Collapse ▲",
|
||||
"exportDone": "Exported",
|
||||
"exportExcel": "Export Excel",
|
||||
"exportFailed": "Export failed",
|
||||
"expand": "+{count} more ▾",
|
||||
"lockedTag": "Locked",
|
||||
"replyAction": "Reply",
|
||||
"editReplyAction": "Edit reply",
|
||||
"notifiedTag": "Notified {name}",
|
||||
"replyFirst": "Reply first",
|
||||
"notifyAction": "Send notification",
|
||||
"pendingNotify": "Recorded after notify",
|
||||
|
||||
@@ -5745,6 +5745,10 @@
|
||||
"tabSends": "บันทึกการส่ง",
|
||||
"tabConfig": "ตั้งค่าการเตือน",
|
||||
"sendsLead": "การสแกนรายวันสร้างรายการที่รอส่ง หลังสรุปส่งทุกวันศุกร์ 18:00 ตามผู้รับแล้ว จะแสดงที่นี่ ชื่อคงตามตอนที่ส่ง",
|
||||
"excelColumn": "ไฟล์แนบ Excel",
|
||||
"sentExcelTitle": "ไฟล์ Excel ที่ส่งแล้ว",
|
||||
"sentExcelHint": "หนึ่งไฟล์ต่อผู้รับหนึ่งคน ดาวน์โหลดสำเนาที่ส่งไปแล้วได้",
|
||||
"excelDownloadFailed": "ดาวน์โหลดไฟล์ Excel ไม่สำเร็จ",
|
||||
"sendsEmpty": "ยังไม่มีบันทึกการส่ง",
|
||||
"sendsFailed": "โหลดบันทึกการส่งไม่สำเร็จ",
|
||||
"scanAlerts": "สแกนการเตือน",
|
||||
@@ -5754,6 +5758,9 @@
|
||||
"scanDone": "เพิ่ม {created} รายการ อัปเดต {updated} รายการ ยกเลิก {cancelled} รายการ",
|
||||
"sendDone": "ส่งถึง {sent} คน ไม่สำเร็จ {failed} คน",
|
||||
"sendResult": "ผลลัพธ์",
|
||||
"failureReason": "สาเหตุที่ล้มเหลว",
|
||||
"failureReasonEmpty": "ไม่ได้บันทึกสาเหตุ",
|
||||
"failureReasonAria": "ดูสาเหตุที่ล้มเหลว",
|
||||
"sentAt": "เวลาที่ส่ง",
|
||||
"sendStatus": {
|
||||
"pending": "รอส่ง",
|
||||
@@ -5761,11 +5768,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",
|
||||
|
||||
@@ -2,12 +2,21 @@
|
||||
"kbDifySettings": {
|
||||
"title": "ตั้งค่า Dify",
|
||||
"subtitle": "จัดการการเชื่อมต่อ Dify และค่าซิงค์เริ่มต้นของโมดูลคลังความรู้",
|
||||
"sections": {
|
||||
"connection": "การเชื่อมต่อ",
|
||||
"retrieval": "การค้นหา",
|
||||
"chunking": "การแบ่งส่วน"
|
||||
},
|
||||
"hints": {
|
||||
"maxTokens": "โทเค็นสูงสุด",
|
||||
"tokens": "โทเค็น"
|
||||
},
|
||||
"loading": "กำลังโหลดการตั้งค่า...",
|
||||
"save": "บันทึกการตั้งค่า",
|
||||
"saving": "กำลังบันทึก...",
|
||||
"fields": {
|
||||
"baseUrl": "URL พื้นฐานของ Dify",
|
||||
"apiKey": "คีย์ API ของ Dify",
|
||||
"baseUrl": "URL พื้นฐาน",
|
||||
"apiKey": "คีย์ API",
|
||||
"permission": "สิทธิ์การเข้าถึง",
|
||||
"indexingTechnique": "โหมดการทำดัชนี",
|
||||
"searchMethod": "วิธีการค้นหา",
|
||||
@@ -16,9 +25,9 @@
|
||||
"topK": "จำนวนผลลัพธ์ (Top K)",
|
||||
"scoreThresholdEnabled": "เปิดใช้เกณฑ์คะแนน",
|
||||
"scoreThreshold": "เกณฑ์คะแนน",
|
||||
"segmentMaxTokens": "โทเค็นสูงสุดต่อส่วน (เอกสารทั่วไป)",
|
||||
"segmentMaxTokensExcel": "โทเค็นสูงสุดต่อส่วน (Excel/CSV)",
|
||||
"segmentChunkOverlap": "จำนวนโทเค็นที่ซ้อนทับระหว่างส่วน"
|
||||
"segmentMaxTokens": "เอกสารทั่วไป",
|
||||
"segmentMaxTokensExcel": "Excel/CSV",
|
||||
"segmentChunkOverlap": "ส่วนซ้อน"
|
||||
},
|
||||
"options": {
|
||||
"permission": {
|
||||
@@ -52,9 +61,9 @@
|
||||
"unreachable": "เข้าถึงไม่ได้",
|
||||
"notConfigured": "ยังไม่ตั้งค่า",
|
||||
"datasetCount": "จำนวน Dataset",
|
||||
"configured": "ตั้งค่าแล้ว: ",
|
||||
"configured": "ตั้งค่าแล้ว",
|
||||
"boundGroups": "กลุ่มที่ผูกแล้ว",
|
||||
"localSyncRecords": "บันทึกซิงค์ภายใน: ",
|
||||
"localSyncRecords": "บันทึกซิงค์ภายใน",
|
||||
"syncingVersions": "เวอร์ชันที่กำลังซิงค์",
|
||||
"syncedVersions": "เวอร์ชันที่ซิงค์แล้ว",
|
||||
"pendingSyncJobs": "งานซิงค์ที่รออยู่",
|
||||
|
||||
@@ -921,7 +921,7 @@
|
||||
"syncSkipped": "มีการซิงค์กำลังทำงานอยู่ โปรดลองอีกครั้งภายหลัง",
|
||||
"syncFailedTitle": "ซิงค์ล้มเหลว ยังคงภาพรวมเดิมไว้",
|
||||
"filterKeyword": "คำค้นหา (คำสั่งซื้อ / ผลิตภัณฑ์ / ลูกค้า / พนักงานขาย / ผู้ตอบกำหนดส่ง)",
|
||||
"filterKeywordPh": "ค้นหาด้วยเลขที่คำสั่งซื้อ รหัสสินค้า ชื่อสินค้า รหัสสินค้าลูกค้า ลูกค้า พนักงานขาย หรือผู้ตอบกำหนดส่งได้",
|
||||
"filterKeywordPh": "คำสั่งซื้อ / สินค้า / ลูกค้า / พนักงานขาย / ผู้ตอบกำหนดส่ง",
|
||||
"filterOrderDate": "วันที่สั่งซื้อ",
|
||||
"filterStatus": "สถานะการตอบกลับ",
|
||||
"statusAll": "ทั้งหมด",
|
||||
@@ -929,12 +929,10 @@
|
||||
"statusNotFully": "ยังตอบไม่ครบ",
|
||||
"statusNotReplied": "ยังไม่ตอบกลับ",
|
||||
"statusPartial": "ตอบบางส่วน",
|
||||
"totalCount": "รวม {count} รายการสินค้า",
|
||||
"selectAll": "เลือกทั้งหมด (หน้านี้)",
|
||||
"selectedCount": "เลือกแล้ว {count} รายการ",
|
||||
"batchReply": "+ ตอบกลับหลายรายการ",
|
||||
"batchNotify": "แจ้งเตือนหลายรายการ",
|
||||
"toolbarHint": "การตอบกลับหลายรายการเป็นเพียงบันทึก ต้องกดแจ้งเตือนจึงจะส่งและล็อก",
|
||||
"colOrderLine": "เลขที่ : รายการ",
|
||||
"colOrderDate": "วันที่สั่งซื้อ",
|
||||
"colCustomer": "ลูกค้า",
|
||||
@@ -946,6 +944,7 @@
|
||||
"colSpec": "สเปก",
|
||||
"colCustomerPartNo": "รหัสสินค้าลูกค้า",
|
||||
"colAgreedDate": "กำหนดส่งตามข้อตกลง",
|
||||
"colNotifiedTime": "เวลาแจ้งเตือน",
|
||||
"colUnit": "หน่วย",
|
||||
"colQty": "จำนวน",
|
||||
"colDelivered": "ส่งแล้ว",
|
||||
@@ -954,15 +953,13 @@
|
||||
"colReply": "การตอบกลับกำหนดส่ง",
|
||||
"colNotify": "แจ้งเตือน",
|
||||
"colReplyPerson": "ผู้ตอบกลับ",
|
||||
"batchCount": "{count} งวด",
|
||||
"repliedOf": "ตอบแล้ว {replied}/{remain}",
|
||||
"overTag": "เกิน",
|
||||
"collapse": "ย่อ ▲",
|
||||
"exportDone": "ส่งออกสำเร็จ",
|
||||
"exportExcel": "ส่งออก Excel",
|
||||
"exportFailed": "ส่งออกล้มเหลว",
|
||||
"expand": "+{count} งวด ▾",
|
||||
"lockedTag": "ล็อกแล้ว",
|
||||
"replyAction": "ตอบกลับ",
|
||||
"editReplyAction": "แก้ไขการตอบกลับ",
|
||||
"notifiedTag": "แจ้งแล้ว {name}",
|
||||
"replyFirst": "กรุณาตอบกลับก่อน",
|
||||
"notifyAction": "ส่งการแจ้งเตือน",
|
||||
"pendingNotify": "บันทึกหลังแจ้งเตือน",
|
||||
|
||||
@@ -5778,6 +5778,10 @@
|
||||
"tabSends": "发送记录",
|
||||
"tabConfig": "预警配置",
|
||||
"sendsLead": "每日扫描生成待发送。默认每周五 18:00 按收件人汇总发出后记在这里。已发送的姓名保持发送当时的人。",
|
||||
"excelColumn": "Excel 附件",
|
||||
"sentExcelTitle": "已发送的 Excel",
|
||||
"sentExcelHint": "每位收件人一份,可再次下载当时发出的文件。",
|
||||
"excelDownloadFailed": "下载 Excel 失败",
|
||||
"sendsEmpty": "还没有发送记录",
|
||||
"sendsFailed": "读取发送记录失败",
|
||||
"scanAlerts": "扫描预警",
|
||||
@@ -5787,6 +5791,9 @@
|
||||
"scanDone": "新增 {created} 条,更新 {updated} 条,取消 {cancelled} 条",
|
||||
"sendDone": "已向 {sent} 人发送,{failed} 人失败",
|
||||
"sendResult": "结果",
|
||||
"failureReason": "失败原因",
|
||||
"failureReasonEmpty": "没有记下失败原因",
|
||||
"failureReasonAria": "查看失败原因",
|
||||
"sentAt": "发送时间",
|
||||
"sendStatus": {
|
||||
"pending": "待发送",
|
||||
@@ -5794,11 +5801,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",
|
||||
|
||||
@@ -2,12 +2,21 @@
|
||||
"kbDifySettings": {
|
||||
"title": "Dify 设置",
|
||||
"subtitle": "管理知识库模块使用的 Dify 连接和默认同步参数。",
|
||||
"sections": {
|
||||
"connection": "连接",
|
||||
"retrieval": "检索",
|
||||
"chunking": "分段"
|
||||
},
|
||||
"hints": {
|
||||
"maxTokens": "最大 Token",
|
||||
"tokens": "Token"
|
||||
},
|
||||
"loading": "正在加载设置...",
|
||||
"save": "保存设置",
|
||||
"saving": "保存中...",
|
||||
"fields": {
|
||||
"baseUrl": "Dify 基础 URL",
|
||||
"apiKey": "Dify API 密钥",
|
||||
"baseUrl": "基础 URL",
|
||||
"apiKey": "API 密钥",
|
||||
"permission": "可见权限",
|
||||
"indexingTechnique": "索引模式",
|
||||
"searchMethod": "检索方式",
|
||||
@@ -16,9 +25,9 @@
|
||||
"topK": "返回片段数(Top K)",
|
||||
"scoreThresholdEnabled": "启用相似度阈值",
|
||||
"scoreThreshold": "相似度阈值",
|
||||
"segmentMaxTokens": "普通文档分段最大 Token 数",
|
||||
"segmentMaxTokensExcel": "Excel/CSV 分段最大 Token 数",
|
||||
"segmentChunkOverlap": "分段重叠 Token 数"
|
||||
"segmentMaxTokens": "普通文档",
|
||||
"segmentMaxTokensExcel": "Excel/CSV",
|
||||
"segmentChunkOverlap": "重叠"
|
||||
},
|
||||
"options": {
|
||||
"permission": {
|
||||
@@ -52,9 +61,9 @@
|
||||
"unreachable": "不可访问",
|
||||
"notConfigured": "未配置",
|
||||
"datasetCount": "Dataset 数量",
|
||||
"configured": "配置完成:",
|
||||
"configured": "配置完成",
|
||||
"boundGroups": "已绑定分组",
|
||||
"localSyncRecords": "本地同步记录:",
|
||||
"localSyncRecords": "本地同步记录",
|
||||
"syncingVersions": "同步中版本",
|
||||
"syncedVersions": "已同步版本",
|
||||
"pendingSyncJobs": "待同步任务",
|
||||
|
||||
@@ -999,7 +999,7 @@
|
||||
"syncSkipped": "已有同步正在进行,请稍后再试",
|
||||
"syncFailedTitle": "同步失败,已保留上次快照",
|
||||
"filterKeyword": "关键词(订单 / 产品 / 客户 / 业务员 / 回复人员)",
|
||||
"filterKeywordPh": "订单单号、产品编号、品名、客户料号、客户编号、业务员、交期回复人员均可搜索",
|
||||
"filterKeywordPh": "订单/产品/客户/业务员/回复人员",
|
||||
"filterOrderDate": "订单日期",
|
||||
"filterStatus": "交期回复状态",
|
||||
"statusAll": "全部",
|
||||
@@ -1007,12 +1007,10 @@
|
||||
"statusNotFully": "未完全回复",
|
||||
"statusNotReplied": "未回复",
|
||||
"statusPartial": "部分回复",
|
||||
"totalCount": "共 {count} 条产品行",
|
||||
"selectAll": "全选(本页)",
|
||||
"selectedCount": "已勾选 {count} 行",
|
||||
"batchReply": "+ 联合回复交期",
|
||||
"batchNotify": "批量通知",
|
||||
"toolbarHint": "联合回复只保存批次;点「批量通知」才发送并锁定。",
|
||||
"colOrderLine": "订单单号:项次",
|
||||
"colOrderDate": "订单日期",
|
||||
"colCustomer": "客户编号",
|
||||
@@ -1024,6 +1022,7 @@
|
||||
"colSpec": "规格",
|
||||
"colCustomerPartNo": "客户产品编号",
|
||||
"colAgreedDate": "约定交货日",
|
||||
"colNotifiedTime": "通知时间",
|
||||
"colUnit": "单位",
|
||||
"colQty": "数量",
|
||||
"colDelivered": "已交数量",
|
||||
@@ -1032,15 +1031,13 @@
|
||||
"colReply": "交期回复",
|
||||
"colNotify": "通知业务部门",
|
||||
"colReplyPerson": "交期回复人员",
|
||||
"batchCount": "{count} 批",
|
||||
"repliedOf": "已回复 {replied}/{remain}",
|
||||
"overTag": "超",
|
||||
"collapse": "收起 ▲",
|
||||
"exportDone": "导出成功",
|
||||
"exportExcel": "导出 Excel",
|
||||
"exportFailed": "导出失败",
|
||||
"expand": "+{count} 批 ▾",
|
||||
"lockedTag": "交期已锁定",
|
||||
"replyAction": "回复交期",
|
||||
"editReplyAction": "修改回复",
|
||||
"notifiedTag": "已通知 {name}",
|
||||
"replyFirst": "请先回复交期",
|
||||
"notifyAction": "发送通知业务部门",
|
||||
"pendingNotify": "待通知后记录",
|
||||
|
||||
@@ -5745,6 +5745,10 @@
|
||||
"tabSends": "發送記錄",
|
||||
"tabConfig": "預警配置",
|
||||
"sendsLead": "每日掃描產生待發送。預設每週五 18:00 按收件人彙總發出後記在這裡。已發送的姓名保持發送當時的人。",
|
||||
"excelColumn": "Excel 附件",
|
||||
"sentExcelTitle": "已發送的 Excel",
|
||||
"sentExcelHint": "每位收件人一份,可再次下載當時發出的檔案。",
|
||||
"excelDownloadFailed": "下載 Excel 失敗",
|
||||
"sendsEmpty": "還沒有發送記錄",
|
||||
"sendsFailed": "讀取發送記錄失敗",
|
||||
"scanAlerts": "掃描預警",
|
||||
@@ -5754,6 +5758,9 @@
|
||||
"scanDone": "新增 {created} 條,更新 {updated} 條,取消 {cancelled} 條",
|
||||
"sendDone": "已向 {sent} 人發送,{failed} 人失敗",
|
||||
"sendResult": "結果",
|
||||
"failureReason": "失敗原因",
|
||||
"failureReasonEmpty": "沒有記下失敗原因",
|
||||
"failureReasonAria": "查看失敗原因",
|
||||
"sentAt": "發送時間",
|
||||
"sendStatus": {
|
||||
"pending": "待發送",
|
||||
@@ -5761,11 +5768,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",
|
||||
|
||||
@@ -2,12 +2,21 @@
|
||||
"kbDifySettings": {
|
||||
"title": "Dify 設定",
|
||||
"subtitle": "管理知識庫模組使用的 Dify 連線和預設同步參數。",
|
||||
"sections": {
|
||||
"connection": "連線",
|
||||
"retrieval": "檢索",
|
||||
"chunking": "分段"
|
||||
},
|
||||
"hints": {
|
||||
"maxTokens": "最大 Token",
|
||||
"tokens": "Token"
|
||||
},
|
||||
"loading": "正在載入設定...",
|
||||
"save": "儲存設定",
|
||||
"saving": "儲存中...",
|
||||
"fields": {
|
||||
"baseUrl": "Dify 基礎 URL",
|
||||
"apiKey": "Dify API 金鑰",
|
||||
"baseUrl": "基礎 URL",
|
||||
"apiKey": "API 金鑰",
|
||||
"permission": "可見權限",
|
||||
"indexingTechnique": "索引模式",
|
||||
"searchMethod": "檢索方式",
|
||||
@@ -16,9 +25,9 @@
|
||||
"topK": "返回片段數(Top K)",
|
||||
"scoreThresholdEnabled": "啟用相似度閾值",
|
||||
"scoreThreshold": "相似度閾值",
|
||||
"segmentMaxTokens": "一般文件分段最大 Token 數",
|
||||
"segmentMaxTokensExcel": "Excel/CSV 分段最大 Token 數",
|
||||
"segmentChunkOverlap": "分段重疊 Token 數"
|
||||
"segmentMaxTokens": "一般文件",
|
||||
"segmentMaxTokensExcel": "Excel/CSV",
|
||||
"segmentChunkOverlap": "重疊"
|
||||
},
|
||||
"options": {
|
||||
"permission": {
|
||||
@@ -52,9 +61,9 @@
|
||||
"unreachable": "不可訪問",
|
||||
"notConfigured": "未配置",
|
||||
"datasetCount": "Dataset 數量",
|
||||
"configured": "配置完成:",
|
||||
"configured": "配置完成",
|
||||
"boundGroups": "已綁定分組",
|
||||
"localSyncRecords": "本地同步記錄:",
|
||||
"localSyncRecords": "本地同步記錄",
|
||||
"syncingVersions": "同步中版本",
|
||||
"syncedVersions": "已同步版本",
|
||||
"pendingSyncJobs": "待同步任務",
|
||||
|
||||
@@ -999,7 +999,7 @@
|
||||
"syncSkipped": "已有同步正在進行,請稍後再試",
|
||||
"syncFailedTitle": "同步失敗,已保留上次快照",
|
||||
"filterKeyword": "關鍵詞(訂單 / 產品 / 客戶 / 業務員 / 回覆人員)",
|
||||
"filterKeywordPh": "訂單單號、產品編號、品名、客戶料號、客戶編號、業務員、交期回覆人員均可搜尋",
|
||||
"filterKeywordPh": "訂單/產品/客戶/業務員/回覆人員",
|
||||
"filterOrderDate": "訂單日期",
|
||||
"filterStatus": "交期回覆狀態",
|
||||
"statusAll": "全部",
|
||||
@@ -1007,12 +1007,10 @@
|
||||
"statusNotFully": "未完全回覆",
|
||||
"statusNotReplied": "未回覆",
|
||||
"statusPartial": "部分回覆",
|
||||
"totalCount": "共 {count} 條產品行",
|
||||
"selectAll": "全選(本頁)",
|
||||
"selectedCount": "已勾選 {count} 行",
|
||||
"batchReply": "+ 聯合回覆交期",
|
||||
"batchNotify": "批量通知",
|
||||
"toolbarHint": "聯合回覆只儲存批次;點「批量通知」才發送並鎖定。",
|
||||
"colOrderLine": "訂單單號:項次",
|
||||
"colOrderDate": "訂單日期",
|
||||
"colCustomer": "客戶編號",
|
||||
@@ -1024,6 +1022,7 @@
|
||||
"colSpec": "規格",
|
||||
"colCustomerPartNo": "客戶產品編號",
|
||||
"colAgreedDate": "約定交貨日",
|
||||
"colNotifiedTime": "通知時間",
|
||||
"colUnit": "單位",
|
||||
"colQty": "數量",
|
||||
"colDelivered": "已交數量",
|
||||
@@ -1032,15 +1031,13 @@
|
||||
"colReply": "交期回覆",
|
||||
"colNotify": "通知業務部門",
|
||||
"colReplyPerson": "交期回覆人員",
|
||||
"batchCount": "{count} 批",
|
||||
"repliedOf": "已回覆 {replied}/{remain}",
|
||||
"overTag": "超",
|
||||
"collapse": "收起 ▲",
|
||||
"exportDone": "匯出成功",
|
||||
"exportExcel": "匯出 Excel",
|
||||
"exportFailed": "匯出失敗",
|
||||
"expand": "+{count} 批 ▾",
|
||||
"lockedTag": "交期已鎖定",
|
||||
"replyAction": "回覆交期",
|
||||
"editReplyAction": "修改回覆",
|
||||
"notifiedTag": "已通知 {name}",
|
||||
"replyFirst": "請先回覆交期",
|
||||
"notifyAction": "發送通知業務部門",
|
||||
"pendingNotify": "待通知後記錄",
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
/**
|
||||
* shared/composables/useTheme.ts
|
||||
* 主题 preference 与 dark/light 切换(全局单例)。
|
||||
* 用途:主题 preference 与 dark/light 切换(单文档内全局单例)。
|
||||
* 逻辑:initTheme 读 localStorage + matchMedia 完成本文档初始化;同时监听 storage 事件做跨文档同步——
|
||||
* storage 事件只在「其他同源文档」触发,聊天壳父页面切换主题时,iframe 内嵌工作台页
|
||||
* (如订单交期回复 /apps/order-delivery-reply)无需刷新即可实时跟随变暗/变亮。
|
||||
*/
|
||||
import { computed, ref } from 'vue';
|
||||
|
||||
@@ -15,6 +18,7 @@ const systemPrefersDark = ref(false);
|
||||
|
||||
let initialized = false;
|
||||
let mediaListenerCleanup: (() => void) | null = null;
|
||||
let storageListenerCleanup: (() => void) | null = null;
|
||||
|
||||
const appliedTheme = computed<AppliedTheme>(() => {
|
||||
if (themePreference.value === 'system') {
|
||||
@@ -68,6 +72,19 @@ const initTheme = () => {
|
||||
media.addEventListener('change', onMediaChange);
|
||||
mediaListenerCleanup = () => media.removeEventListener('change', onMediaChange);
|
||||
|
||||
// 跨文档主题同步:本监听只在「被其他文档修改 localStorage」时触发(自身切换走 setThemePreference),
|
||||
// 使 iframe 等同源文档即时跟随父壳的亮暗切换。
|
||||
const onStorageChange = (event: StorageEvent) => {
|
||||
if (event.key !== THEME_KEY) return;
|
||||
const stored = parseTheme(event.newValue);
|
||||
if (stored) {
|
||||
themePreference.value = stored;
|
||||
applyTheme();
|
||||
}
|
||||
};
|
||||
window.addEventListener('storage', onStorageChange);
|
||||
storageListenerCleanup = () => window.removeEventListener('storage', onStorageChange);
|
||||
|
||||
const stored = parseTheme(localStorage.getItem(THEME_KEY));
|
||||
if (stored) {
|
||||
themePreference.value = stored;
|
||||
@@ -78,6 +95,8 @@ const initTheme = () => {
|
||||
const cleanupTheme = () => {
|
||||
mediaListenerCleanup?.();
|
||||
mediaListenerCleanup = null;
|
||||
storageListenerCleanup?.();
|
||||
storageListenerCleanup = null;
|
||||
initialized = false;
|
||||
};
|
||||
|
||||
|
||||
@@ -28,4 +28,38 @@
|
||||
.divide-subtle > :not([hidden]) ~ :not([hidden]) {
|
||||
border-color: var(--border-subtle);
|
||||
}
|
||||
|
||||
/* 状态前景文字:badge 之外的行内强调(如「超量」标记、成功/告警说明) */
|
||||
.text-status-success { color: var(--status-success-fg); }
|
||||
.text-status-info { color: var(--status-info-fg); }
|
||||
.text-status-warning { color: var(--status-warning-fg); }
|
||||
.text-status-error { color: var(--status-error-fg); }
|
||||
|
||||
/* 表格行交互态:选中=info、直达定位高亮=warning,状态令牌亮暗自适应 */
|
||||
.bg-row-selected { background-color: var(--status-info-bg); }
|
||||
.bg-row-highlight { background-color: var(--status-warning-bg); }
|
||||
|
||||
/* 表格行悬停:无交互态的行悬停压暗;选中/高亮行保持状态色不被悬停覆盖 */
|
||||
.hover-row:hover:not(.bg-row-selected):not(.bg-row-highlight) {
|
||||
background-color: var(--bg-surface-soft);
|
||||
}
|
||||
|
||||
/* 表格冻结列单元格:必须实色基底(防透出横向滚动内容)。
|
||||
选中/高亮态用「实色底 + 状态色平铺叠加」——暗色状态令牌为半透明 rgba,
|
||||
直接当背景色会在横向滚动时透出下层内容。 */
|
||||
.frozen-cell { background-color: var(--bg-surface); }
|
||||
.hover-row:hover:not(.bg-row-selected):not(.bg-row-highlight) .frozen-cell {
|
||||
background-color: var(--bg-surface-soft);
|
||||
}
|
||||
.frozen-cell--selected {
|
||||
background-color: var(--bg-surface);
|
||||
background-image: linear-gradient(var(--status-info-bg), var(--status-info-bg));
|
||||
}
|
||||
.frozen-cell--highlight {
|
||||
background-color: var(--bg-surface);
|
||||
background-image: linear-gradient(var(--status-warning-bg), var(--status-warning-bg));
|
||||
}
|
||||
|
||||
/* 冻结列右缘分隔阴影(与 admin-table-sticky-right-cell 同型),亮暗共用 */
|
||||
.shadow-sticky-col { box-shadow: 2px 0 6px -2px rgba(15, 23, 42, 0.12); }
|
||||
}
|
||||
@@ -189,6 +189,31 @@
|
||||
@apply px-2.5 py-0.5 rounded-full text-xs font-medium border;
|
||||
}
|
||||
|
||||
/* 徽章状态变体:颜色一律走 --status-* 令牌(亮暗自适应),禁止 rose/emerald 等原生色 */
|
||||
.badge-success {
|
||||
background-color: var(--status-success-bg);
|
||||
border-color: var(--status-success-border);
|
||||
color: var(--status-success-fg);
|
||||
}
|
||||
|
||||
.badge-info {
|
||||
background-color: var(--status-info-bg);
|
||||
border-color: var(--status-info-border);
|
||||
color: var(--status-info-fg);
|
||||
}
|
||||
|
||||
.badge-warning {
|
||||
background-color: var(--status-warning-bg);
|
||||
border-color: var(--status-warning-border);
|
||||
color: var(--status-warning-fg);
|
||||
}
|
||||
|
||||
.badge-error {
|
||||
background-color: var(--status-error-bg);
|
||||
border-color: var(--status-error-border);
|
||||
color: var(--status-error-fg);
|
||||
}
|
||||
|
||||
.glass-panel {
|
||||
@apply backdrop-blur-xl border;
|
||||
background: var(--glass-panel-bg);
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
#!/usr/bin/env bash
|
||||
# Jenkins 前端风格检查。只跑 npm run lint,不跑 build。
|
||||
# Element 规则当前是 off,本脚本应通过。启用方式见 docs/ui/ELEMENT_MIGRATION.md §9.2。
|
||||
set -euo pipefail
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
ROOT_DIR="$(cd "${SCRIPT_DIR}/.." && pwd)"
|
||||
FRONTEND_DIR="${ROOT_DIR}/frontend"
|
||||
|
||||
if [[ ! -f "${FRONTEND_DIR}/package.json" ]]; then
|
||||
echo "[ci-frontend-lint] missing ${FRONTEND_DIR}/package.json"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
cd "${FRONTEND_DIR}"
|
||||
echo "[ci-frontend-lint] npm ci"
|
||||
npm ci
|
||||
echo "[ci-frontend-lint] npm run lint"
|
||||
npm run lint
|
||||
echo "[ci-frontend-lint] OK"
|
||||
Reference in new issue
Block a user