Merge branch 'dev' into hugo-shipping-notice
This commit is contained in:
commit
9f5493185d
29 files changed
+3957
-12
No files matched your search
@@ -25,6 +25,7 @@ def register_blueprints(app: Flask) -> None:
|
||||
from app.api.integration import integration_bp
|
||||
from app.api.internal_jobs import internal_jobs_bp
|
||||
from app.api.speech import speech_bp
|
||||
from app.api.training import training_admin_bp, training_user_bp
|
||||
|
||||
# [STEP 2] 已分包骨架(Wave 3:kb、schedule 等)
|
||||
from app.api.kb import knowledge_base_bp
|
||||
@@ -40,6 +41,7 @@ def register_blueprints(app: Flask) -> None:
|
||||
app.register_blueprint(admin_bp, url_prefix='/api/admin')
|
||||
app.register_blueprint(agents_bp, url_prefix='/api/agents')
|
||||
app.register_blueprint(user_bp, url_prefix='/api/user')
|
||||
app.register_blueprint(training_user_bp, url_prefix='/api/user')
|
||||
app.register_blueprint(knowledge_base_bp, url_prefix='/api/kb')
|
||||
app.register_blueprint(integration_bp, url_prefix='/api/integration')
|
||||
app.register_blueprint(schedule_admin_bp, url_prefix='/api/admin')
|
||||
@@ -50,3 +52,4 @@ def register_blueprints(app: Flask) -> None:
|
||||
app.register_blueprint(shipping_notice_bp, url_prefix='/api/shipping-notice')
|
||||
app.register_blueprint(file_check_bp, url_prefix='/api/file-check')
|
||||
app.register_blueprint(speech_bp, url_prefix='/api/speech')
|
||||
app.register_blueprint(training_admin_bp, url_prefix='/api/admin')
|
||||
@@ -0,0 +1,121 @@
|
||||
"""
|
||||
backend/app/api/training.py
|
||||
|
||||
用途:提供新人培训用户侧进度接口与管理端统计导出接口。
|
||||
依赖:JWT 当前用户解析、training_service、Flask Blueprint/send_file。
|
||||
逻辑:员工端负责读写个人培训进度;管理端负责真实记录查询、统计与 Excel 导出。
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from io import BytesIO
|
||||
|
||||
from flask import Blueprint, jsonify, request, send_file
|
||||
|
||||
from app.core.auth.jwt import get_current_user
|
||||
from app.core.errors import ForbiddenError, UnauthorizedError
|
||||
from app.services.training_service import (
|
||||
export_training_records_excel,
|
||||
get_user_training_record,
|
||||
list_training_records,
|
||||
serialize_training_record,
|
||||
summarize_training_records,
|
||||
upsert_user_training_record,
|
||||
)
|
||||
|
||||
training_user_bp = Blueprint("training_user", __name__)
|
||||
training_admin_bp = Blueprint("training_admin", __name__)
|
||||
|
||||
|
||||
def _require_user():
|
||||
"""确保当前请求存在登录用户。"""
|
||||
user = get_current_user()
|
||||
if not user:
|
||||
raise UnauthorizedError()
|
||||
return user
|
||||
|
||||
|
||||
def _require_training_admin():
|
||||
"""确保当前用户具备培训管理权限。"""
|
||||
user = _require_user()
|
||||
if user.role not in {"admin", "hr"}:
|
||||
raise ForbiddenError("Training admin privilege required")
|
||||
return user
|
||||
|
||||
|
||||
@training_user_bp.route("/training-record", methods=["GET"])
|
||||
def get_my_training_record():
|
||||
"""读取当前用户的培训进度;未创建时返回 null data。"""
|
||||
user = _require_user()
|
||||
record = get_user_training_record(user.id)
|
||||
return jsonify(serialize_training_record(record) if record else None)
|
||||
|
||||
|
||||
@training_user_bp.route("/training-record/progress", methods=["PUT"])
|
||||
def save_my_training_record():
|
||||
"""保存当前用户培训进度,用于视频完成、答题推进与结算归档。"""
|
||||
user = _require_user()
|
||||
payload = request.get_json() or {}
|
||||
record = upsert_user_training_record(user, payload)
|
||||
return jsonify(serialize_training_record(record))
|
||||
|
||||
|
||||
@training_admin_bp.route("/training-records", methods=["GET"])
|
||||
def list_admin_training_records():
|
||||
"""列出培训记录,支持关键字、部门、状态筛选。"""
|
||||
_require_training_admin()
|
||||
keyword = request.args.get("keyword")
|
||||
department = request.args.get("department")
|
||||
status = request.args.get("status")
|
||||
|
||||
result = list_training_records(keyword=keyword, department=department, status=status)
|
||||
all_records = list_training_records()
|
||||
department_options = sorted({str(item.department or "").strip() for item in all_records.records if str(item.department or "").strip()})
|
||||
|
||||
page = max(1, request.args.get("page", type=int) or 1)
|
||||
page_size = max(1, min(200, request.args.get("page_size", type=int) or max(result.total, 1)))
|
||||
start = (page - 1) * page_size
|
||||
end = start + page_size
|
||||
items = result.records[start:end]
|
||||
pages = max(1, (result.total + page_size - 1) // page_size) if result.total else 1
|
||||
|
||||
return jsonify(
|
||||
{
|
||||
"items": [serialize_training_record(item) for item in items],
|
||||
"total": result.total,
|
||||
"page": page,
|
||||
"page_size": page_size,
|
||||
"pages": pages,
|
||||
"department_options": department_options,
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
@training_admin_bp.route("/training-records/stats", methods=["GET"])
|
||||
def get_admin_training_stats():
|
||||
"""返回培训记录聚合统计,供 HR 面板展示。"""
|
||||
_require_training_admin()
|
||||
result = list_training_records(
|
||||
keyword=request.args.get("keyword"),
|
||||
department=request.args.get("department"),
|
||||
status=request.args.get("status"),
|
||||
)
|
||||
return jsonify(summarize_training_records(result.records))
|
||||
|
||||
|
||||
@training_admin_bp.route("/training-records/export", methods=["GET"])
|
||||
def export_admin_training_records():
|
||||
"""导出培训记录为 Excel。"""
|
||||
_require_training_admin()
|
||||
result = list_training_records(
|
||||
keyword=request.args.get("keyword"),
|
||||
department=request.args.get("department"),
|
||||
status=request.args.get("status"),
|
||||
)
|
||||
file_data, file_name = export_training_records_excel(result.records)
|
||||
return send_file(
|
||||
BytesIO(file_data),
|
||||
as_attachment=True,
|
||||
download_name=file_name,
|
||||
mimetype="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
||||
)
|
||||
@@ -23,6 +23,7 @@ from app.models.shipping import (
|
||||
ShippingTaskEvent,
|
||||
ShippingTaskInventoryLink,
|
||||
)
|
||||
from app.models.training import TrainingRecord
|
||||
from app.models.user import LoginAudit, User, UserDefaultAgent, UserFavoriteAgent, UserHomepageConfig
|
||||
from app.models.wecom import WecomCallbackAudit, WecomNotifyAudit
|
||||
|
||||
@@ -64,4 +65,5 @@ __all__ = [
|
||||
'ShippingTaskInventoryLink',
|
||||
'ShippingInventoryMapping',
|
||||
'AgentGuide',
|
||||
'TrainingRecord',
|
||||
]
|
||||
@@ -0,0 +1,48 @@
|
||||
"""
|
||||
backend/app/models/training.py
|
||||
|
||||
用途:定义新人入职培训记录模型,承载学员当前培训进度、成绩结算与 HR 统计来源。
|
||||
依赖:models.base.Base、SQLAlchemy 映射、users 主表外键。
|
||||
逻辑:每个用户维护一条当前培训记录;前端学习流与管理端统计都基于该表读写。
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from datetime import date, datetime
|
||||
from typing import Optional
|
||||
|
||||
from sqlalchemy import Boolean, Date, DateTime, ForeignKey, Integer, JSON, String
|
||||
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
||||
|
||||
from app.models.base import Base
|
||||
|
||||
|
||||
class TrainingRecord(Base):
|
||||
"""新人入职培训当前记录。"""
|
||||
|
||||
__tablename__ = "training_records"
|
||||
|
||||
id: Mapped[int] = mapped_column(primary_key=True)
|
||||
user_id: Mapped[int] = mapped_column(ForeignKey("users.id"), unique=True, index=True, nullable=False)
|
||||
employee_id: Mapped[Optional[str]] = mapped_column(String(50), nullable=True, index=True)
|
||||
name: Mapped[Optional[str]] = mapped_column(String(100), nullable=True, index=True)
|
||||
department: Mapped[Optional[str]] = mapped_column(String(100), nullable=True, index=True)
|
||||
join_date: Mapped[Optional[date]] = mapped_column(Date, nullable=True, index=True)
|
||||
stage: Mapped[str] = mapped_column(String(20), nullable=False, default="video", index=True)
|
||||
current_question_index: Mapped[int] = mapped_column(Integer, nullable=False, default=0)
|
||||
score: Mapped[int] = mapped_column(Integer, nullable=False, default=0)
|
||||
passed: Mapped[bool] = mapped_column(Boolean, nullable=False, default=False, index=True)
|
||||
attempt_count: Mapped[int] = mapped_column(Integer, nullable=False, default=0)
|
||||
answer_details: Mapped[list[dict] | None] = mapped_column(JSON, nullable=True)
|
||||
started_at: Mapped[datetime] = mapped_column(DateTime, nullable=False, default=datetime.utcnow)
|
||||
completion_time: Mapped[Optional[datetime]] = mapped_column(DateTime, nullable=True, index=True)
|
||||
created_at: Mapped[datetime] = mapped_column(DateTime, nullable=False, default=datetime.utcnow, index=True)
|
||||
updated_at: Mapped[datetime] = mapped_column(
|
||||
DateTime,
|
||||
nullable=False,
|
||||
default=datetime.utcnow,
|
||||
onupdate=datetime.utcnow,
|
||||
index=True,
|
||||
)
|
||||
|
||||
user = relationship("User", back_populates="training_record")
|
||||
@@ -78,6 +78,11 @@ class User(Base):
|
||||
|
||||
reset_token: Mapped[Optional[str]] = mapped_column(String(100), nullable=True)
|
||||
reset_token_expiry: Mapped[Optional[datetime]] = mapped_column(DateTime, nullable=True)
|
||||
training_record: Mapped[Optional['TrainingRecord']] = relationship(
|
||||
'TrainingRecord',
|
||||
back_populates='user',
|
||||
uselist=False,
|
||||
)
|
||||
|
||||
def set_password(self, password: str) -> None:
|
||||
"""设置密码哈希。"""
|
||||
|
||||
@@ -0,0 +1,240 @@
|
||||
"""
|
||||
backend/app/services/training_service.py
|
||||
|
||||
用途:封装新人培训记录的序列化、进度保存、列表筛选、统计与导出能力。
|
||||
依赖:app.models.TrainingRecord/User、app.extensions.db、openpyxl。
|
||||
逻辑:API 层仅做鉴权与参数解析;本模块负责把前端培训状态转成数据库记录并提供 HR 侧聚合结果。
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from dataclasses import dataclass
|
||||
from datetime import date, datetime
|
||||
from io import BytesIO
|
||||
from typing import Any, Iterable, Optional
|
||||
|
||||
from openpyxl import Workbook
|
||||
from sqlalchemy import select
|
||||
|
||||
from app.core.errors import ValidationError
|
||||
from app.extensions import db
|
||||
from app.models import TrainingRecord, User
|
||||
|
||||
TRAINING_STAGES = {"video", "summary", "exam", "result"}
|
||||
|
||||
|
||||
def _parse_iso_date(value: Any) -> Optional[date]:
|
||||
text = str(value or "").strip()
|
||||
if not text:
|
||||
return None
|
||||
try:
|
||||
return date.fromisoformat(text)
|
||||
except ValueError as exc:
|
||||
raise ValidationError("join_date must be YYYY-MM-DD", details={"field": "join_date"}) from exc
|
||||
|
||||
|
||||
def _normalize_answer_details(value: Any) -> list[dict]:
|
||||
if value in (None, ""):
|
||||
return []
|
||||
if not isinstance(value, list):
|
||||
raise ValidationError("answer_details must be an array", details={"field": "answer_details"})
|
||||
normalized: list[dict] = []
|
||||
for index, item in enumerate(value):
|
||||
if not isinstance(item, dict):
|
||||
raise ValidationError(
|
||||
"answer_details item must be an object",
|
||||
details={"field": "answer_details", "index": index},
|
||||
)
|
||||
normalized.append(
|
||||
{
|
||||
"question_id": str(item.get("question_id") or item.get("questionId") or ""),
|
||||
"selected_option_id": str(item.get("selected_option_id") or item.get("selectedOptionId") or ""),
|
||||
"correct": bool(item.get("correct", False)),
|
||||
}
|
||||
)
|
||||
return normalized
|
||||
|
||||
|
||||
def _derive_status(record: TrainingRecord) -> str:
|
||||
if bool(record.passed):
|
||||
return "passed"
|
||||
if record.stage == "result":
|
||||
return "failed"
|
||||
return "in_progress"
|
||||
|
||||
|
||||
def serialize_training_record(record: TrainingRecord) -> dict[str, Any]:
|
||||
"""将培训记录序列化为前端可直接消费的结构。"""
|
||||
return {
|
||||
"id": record.id,
|
||||
"user_id": record.user_id,
|
||||
"employee_id": record.employee_id,
|
||||
"name": record.name,
|
||||
"department": record.department,
|
||||
"join_date": record.join_date.isoformat() if record.join_date else None,
|
||||
"stage": record.stage,
|
||||
"current_question_index": int(record.current_question_index or 0),
|
||||
"score": int(record.score or 0),
|
||||
"passed": bool(record.passed),
|
||||
"attempt_count": int(record.attempt_count or 0),
|
||||
"answer_details": list(record.answer_details or []),
|
||||
"started_at": record.started_at.isoformat() if record.started_at else None,
|
||||
"completion_time": record.completion_time.isoformat() if record.completion_time else None,
|
||||
"created_at": record.created_at.isoformat() if record.created_at else None,
|
||||
"updated_at": record.updated_at.isoformat() if record.updated_at else None,
|
||||
"status": _derive_status(record),
|
||||
}
|
||||
|
||||
|
||||
def _apply_user_snapshot(record: TrainingRecord, user: User) -> None:
|
||||
record.employee_id = (user.employee_id or "").strip() or None
|
||||
record.name = (user.real_name or "").strip() or (user.username or "").strip() or None
|
||||
record.department = (user.department or "").strip() or None
|
||||
|
||||
|
||||
def get_user_training_record(user_id: int) -> Optional[TrainingRecord]:
|
||||
"""查询指定用户当前培训记录。"""
|
||||
stmt = select(TrainingRecord).where(TrainingRecord.user_id == user_id)
|
||||
return db.session.execute(stmt).scalar_one_or_none()
|
||||
|
||||
|
||||
def upsert_user_training_record(user: User, payload: dict[str, Any]) -> TrainingRecord:
|
||||
"""
|
||||
保存当前用户培训进度。
|
||||
|
||||
Args:
|
||||
user: 当前登录用户。
|
||||
payload: 前端上传的培训进度快照。
|
||||
Returns:
|
||||
已保存的 TrainingRecord。
|
||||
"""
|
||||
stage = str(payload.get("stage") or "video").strip() or "video"
|
||||
if stage not in TRAINING_STAGES:
|
||||
raise ValidationError("stage is invalid", details={"field": "stage", "allowed": sorted(TRAINING_STAGES)})
|
||||
|
||||
current_question_index = int(payload.get("current_question_index") or payload.get("currentQuestionIndex") or 0)
|
||||
score = int(payload.get("score") or 0)
|
||||
attempt_count = int(payload.get("attempt_count") or payload.get("attemptCount") or 0)
|
||||
if current_question_index < 0:
|
||||
raise ValidationError("current_question_index must be >= 0", details={"field": "current_question_index"})
|
||||
if score < 0:
|
||||
raise ValidationError("score must be >= 0", details={"field": "score"})
|
||||
if attempt_count < 0:
|
||||
raise ValidationError("attempt_count must be >= 0", details={"field": "attempt_count"})
|
||||
|
||||
answer_details = _normalize_answer_details(payload.get("answer_details") or payload.get("answerDetails"))
|
||||
passed = bool(payload.get("passed")) or (stage == "result" and score >= 90)
|
||||
join_date = _parse_iso_date(payload.get("join_date") or payload.get("joinDate"))
|
||||
|
||||
record = get_user_training_record(user.id)
|
||||
if not record:
|
||||
record = TrainingRecord(
|
||||
user_id=user.id,
|
||||
join_date=join_date or date.today(),
|
||||
started_at=datetime.utcnow(),
|
||||
)
|
||||
db.session.add(record)
|
||||
elif join_date:
|
||||
record.join_date = join_date
|
||||
|
||||
_apply_user_snapshot(record, user)
|
||||
record.stage = stage
|
||||
record.current_question_index = current_question_index
|
||||
record.score = score
|
||||
record.passed = passed
|
||||
record.attempt_count = attempt_count
|
||||
record.answer_details = answer_details
|
||||
|
||||
if stage == "result":
|
||||
record.completion_time = datetime.utcnow()
|
||||
if not record.started_at:
|
||||
record.started_at = datetime.utcnow()
|
||||
else:
|
||||
record.completion_time = None
|
||||
if stage in {"summary", "exam"} and not record.started_at:
|
||||
record.started_at = datetime.utcnow()
|
||||
|
||||
db.session.commit()
|
||||
return record
|
||||
|
||||
|
||||
@dataclass
|
||||
class TrainingListResult:
|
||||
records: list[TrainingRecord]
|
||||
total: int
|
||||
|
||||
|
||||
def list_training_records(*, keyword: str | None = None, department: str | None = None, status: str | None = None) -> TrainingListResult:
|
||||
"""按筛选条件列出培训记录。"""
|
||||
query = db.session.query(TrainingRecord).order_by(TrainingRecord.updated_at.desc(), TrainingRecord.id.desc())
|
||||
records = query.all()
|
||||
|
||||
keyword_text = str(keyword or "").strip().lower()
|
||||
department_text = str(department or "").strip()
|
||||
status_text = str(status or "").strip()
|
||||
|
||||
filtered: list[TrainingRecord] = []
|
||||
for record in records:
|
||||
record_status = _derive_status(record)
|
||||
if keyword_text:
|
||||
searchable = " ".join(
|
||||
[
|
||||
str(record.name or ""),
|
||||
str(record.employee_id or ""),
|
||||
]
|
||||
).lower()
|
||||
if keyword_text not in searchable:
|
||||
continue
|
||||
if department_text and department_text != "all" and (record.department or "") != department_text:
|
||||
continue
|
||||
if status_text and status_text != "all" and record_status != status_text:
|
||||
continue
|
||||
filtered.append(record)
|
||||
|
||||
return TrainingListResult(records=filtered, total=len(filtered))
|
||||
|
||||
|
||||
def summarize_training_records(records: Iterable[TrainingRecord]) -> dict[str, int]:
|
||||
"""统计培训记录聚合指标。"""
|
||||
data = list(records)
|
||||
total = len(data)
|
||||
passed = sum(1 for item in data if _derive_status(item) == "passed")
|
||||
failed = sum(1 for item in data if _derive_status(item) == "failed")
|
||||
in_progress = sum(1 for item in data if _derive_status(item) == "in_progress")
|
||||
scored_items = [int(item.score or 0) for item in data if item.score is not None]
|
||||
average_score = round(sum(scored_items) / len(scored_items)) if scored_items else 0
|
||||
return {
|
||||
"total": total,
|
||||
"passed": passed,
|
||||
"failed": failed,
|
||||
"in_progress": in_progress,
|
||||
"pass_rate": round((passed / total) * 100) if total else 0,
|
||||
"average_score": average_score,
|
||||
}
|
||||
|
||||
|
||||
def export_training_records_excel(records: Iterable[TrainingRecord]) -> tuple[bytes, str]:
|
||||
"""将培训记录导出为 Excel 文件。"""
|
||||
workbook = Workbook()
|
||||
worksheet = workbook.active
|
||||
worksheet.title = "training"
|
||||
worksheet.append(["入职日期", "完成日期", "部门", "姓名", "工号", "分数", "考试次数", "状态"])
|
||||
|
||||
for record in records:
|
||||
worksheet.append(
|
||||
[
|
||||
record.join_date.isoformat() if record.join_date else "",
|
||||
record.completion_time.date().isoformat() if record.completion_time else "",
|
||||
record.department or "",
|
||||
record.name or "",
|
||||
record.employee_id or "",
|
||||
record.score if record.score is not None else "",
|
||||
record.attempt_count or 0,
|
||||
_derive_status(record),
|
||||
]
|
||||
)
|
||||
|
||||
buffer = BytesIO()
|
||||
workbook.save(buffer)
|
||||
filename = f"training_records_{datetime.utcnow().date().isoformat()}.xlsx"
|
||||
return buffer.getvalue(), filename
|
||||
@@ -0,0 +1,74 @@
|
||||
"""Add training records table.
|
||||
|
||||
Purpose:
|
||||
Persist onboarding training progress, final score and HR export source data.
|
||||
Dependencies:
|
||||
Alembic revision fb2c3d4e5f6a.
|
||||
Flow:
|
||||
Frontend learner flow updates one current record per user; admin endpoints
|
||||
read the same table for stats and Excel export.
|
||||
|
||||
Revision ID: fc3d4e5f6a7b
|
||||
Revises: fb2c3d4e5f6a
|
||||
Create Date: 2026-06-30 22:30:00.000000
|
||||
"""
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
revision = "fc3d4e5f6a7b"
|
||||
down_revision = "fb2c3d4e5f6a"
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
"""Create training_records table."""
|
||||
op.create_table(
|
||||
"training_records",
|
||||
sa.Column("id", sa.Integer(), nullable=False),
|
||||
sa.Column("user_id", sa.Integer(), nullable=False),
|
||||
sa.Column("employee_id", sa.String(length=50), nullable=True),
|
||||
sa.Column("name", sa.String(length=100), nullable=True),
|
||||
sa.Column("department", sa.String(length=100), nullable=True),
|
||||
sa.Column("join_date", sa.Date(), nullable=True),
|
||||
sa.Column("stage", sa.String(length=20), nullable=False),
|
||||
sa.Column("current_question_index", sa.Integer(), nullable=False, server_default="0"),
|
||||
sa.Column("score", sa.Integer(), nullable=False, server_default="0"),
|
||||
sa.Column("passed", sa.Boolean(), nullable=False, server_default=sa.text("false")),
|
||||
sa.Column("attempt_count", sa.Integer(), nullable=False, server_default="0"),
|
||||
sa.Column("answer_details", sa.JSON(), nullable=True),
|
||||
sa.Column("started_at", sa.DateTime(), nullable=False),
|
||||
sa.Column("completion_time", sa.DateTime(), nullable=True),
|
||||
sa.Column("created_at", sa.DateTime(), nullable=False),
|
||||
sa.Column("updated_at", sa.DateTime(), nullable=False),
|
||||
sa.ForeignKeyConstraint(["user_id"], ["users.id"]),
|
||||
sa.PrimaryKeyConstraint("id"),
|
||||
sa.UniqueConstraint("user_id", name="uq_training_records_user_id"),
|
||||
)
|
||||
op.create_index("ix_training_records_user_id", "training_records", ["user_id"], unique=True)
|
||||
op.create_index("ix_training_records_employee_id", "training_records", ["employee_id"], unique=False)
|
||||
op.create_index("ix_training_records_name", "training_records", ["name"], unique=False)
|
||||
op.create_index("ix_training_records_department", "training_records", ["department"], unique=False)
|
||||
op.create_index("ix_training_records_join_date", "training_records", ["join_date"], unique=False)
|
||||
op.create_index("ix_training_records_stage", "training_records", ["stage"], unique=False)
|
||||
op.create_index("ix_training_records_passed", "training_records", ["passed"], unique=False)
|
||||
op.create_index("ix_training_records_completion_time", "training_records", ["completion_time"], unique=False)
|
||||
op.create_index("ix_training_records_created_at", "training_records", ["created_at"], unique=False)
|
||||
op.create_index("ix_training_records_updated_at", "training_records", ["updated_at"], unique=False)
|
||||
|
||||
|
||||
def downgrade():
|
||||
"""Drop training_records table."""
|
||||
op.drop_index("ix_training_records_updated_at", table_name="training_records")
|
||||
op.drop_index("ix_training_records_created_at", table_name="training_records")
|
||||
op.drop_index("ix_training_records_completion_time", table_name="training_records")
|
||||
op.drop_index("ix_training_records_passed", table_name="training_records")
|
||||
op.drop_index("ix_training_records_stage", table_name="training_records")
|
||||
op.drop_index("ix_training_records_join_date", table_name="training_records")
|
||||
op.drop_index("ix_training_records_department", table_name="training_records")
|
||||
op.drop_index("ix_training_records_name", table_name="training_records")
|
||||
op.drop_index("ix_training_records_employee_id", table_name="training_records")
|
||||
op.drop_index("ix_training_records_user_id", table_name="training_records")
|
||||
op.drop_table("training_records")
|
||||
@@ -7,6 +7,18 @@
|
||||
| 意见反馈入库 | 已实现 | 用户在 Workspace/Chat 提交意见后写入 `general_feedbacks`,后台报表可查看 |
|
||||
| 反馈企业微信群通知 | 已实现 | 反馈入库后通过 `WECOM_FEEDBACK_BOT_WEBHOOK` 即时推送到企业微信群;未配置 webhook 时静默跳过,不影响用户提交 |
|
||||
|
||||
## 新人培训 Agent
|
||||
|
||||
| 功能项 | 状态 | 说明 |
|
||||
| --- | --- | --- |
|
||||
| Chat 内培训工作区 | 前端已实现 | 在培训 Agent 聊天页顶部提供视频学习、知识点复盘、逐题考试、成绩结算的一体化工作区 |
|
||||
| Chat 内 HR 管理面板 | 已实现 | 管理角色可在同一聊天页查看真实培训统计、筛选记录并导出 Excel |
|
||||
| 培训题库前端内置 | 前端已实现 | 内置 20 道新人试卷题目,支持一题一答、即时反馈、未通过重考 |
|
||||
| 管理端培训模式配置 | 前端已实现 | Agent 管理表单支持显式开启培训工作区,并可一键套用培训默认配置 |
|
||||
| 首页培训推荐入口 | 前端已实现 | 当 Agent 开启培训模式后,工作台首页会在应用列表上方展示培训强入口卡片 |
|
||||
| 培训记录后端落库 | 已实现 | 已新增培训记录模型、迁移与用户/管理端 API,考试进度、结果、统计与导出均可走后端数据源 |
|
||||
| 培训业务闭环整改清单 | 已文档化 | 见 [docs/新人入职培训Agent_闭环整改清单.md](新人入职培训Agent_闭环整改清单.md) |
|
||||
|
||||
## 1. 功能总览
|
||||
|
||||
| 模块 | 功能项 | 状态 | 优先级 |
|
||||
|
||||
@@ -0,0 +1,238 @@
|
||||
# 新人入职培训 Agent 闭环整改清单
|
||||
|
||||
## 1. 文档目的
|
||||
|
||||
本文档用于整理“新员工入职培训”Agent 当前实现状态、与产品方案之间的闭环差距,以及后续的整改任务拆分,供产品、前端、后端、联调和测试统一对齐。
|
||||
|
||||
权威方案来源见 [新人入职培训Agent_产品设计文档](新人入职培训Agent_产品设计文档.md)。
|
||||
|
||||
## 2. 当前状态总结
|
||||
|
||||
### 2.1 已完成的前端闭环
|
||||
|
||||
- 已支持培训 Agent 专属入口和聊天页识别。
|
||||
- 已支持 Chat 内的欢迎语、视频占位符、知识点复盘、逐题考试、结果结算和补考入口。
|
||||
- 已支持前端内置 20 题题库、一题一答、即时反馈和分数累计。
|
||||
- 已支持聊天流与工作区联动,用户可在 Chat 内完成主要培训交互。
|
||||
- 已支持管理端开启培训模式,并提供首页培训推荐入口。
|
||||
- 已支持 HR 管理面板的前端展示、筛选和导出入口。
|
||||
|
||||
### 2.2 本轮已完成的真实数据闭环
|
||||
|
||||
- 已新增培训记录模型 `TrainingRecord`,用于保存学员当前培训阶段、当前题号、分数、补考次数和答题明细。
|
||||
- 已新增 Alembic 迁移,培训记录表结构可随版本发布落地。
|
||||
- 已新增员工侧接口:
|
||||
- 获取我的培训进度
|
||||
- 保存我的培训进度
|
||||
- 已新增管理侧接口:
|
||||
- 培训记录列表
|
||||
- 培训统计
|
||||
- Excel 导出
|
||||
- 已将前端培训工作区切换为真实后端数据源,支持:
|
||||
- 视频完成后保存阶段
|
||||
- 开始考试后保存当前轮次
|
||||
- 答题过程中保存答题明细和当前题号
|
||||
- 结算后保存最终成绩
|
||||
- 刷新页面后恢复培训进度
|
||||
- HR 面板读取真实后端记录和统计
|
||||
- HR Excel 导出读取真实后端记录
|
||||
- 已支持从 Agent `extra_config.training_video_url` 读取培训视频地址,未配置时回退到默认演示视频。
|
||||
|
||||
### 2.3 当前仍属于演示态的部分
|
||||
|
||||
- 视频资源仍是演示占位或预留容器,未接入正式培训素材。
|
||||
- 题库、知识点、及格线等规则主要固化在前端资源中,未配置化。
|
||||
- HR 权限当前更接近前端展示开关,未形成完整后端权限隔离。
|
||||
|
||||
## 3. 对照产品方案的闭环差距
|
||||
|
||||
### 3.1 数据闭环差距
|
||||
|
||||
- 培训记录表、迁移、提交接口、统计接口和导出接口已落地。
|
||||
- 当前仍缺少“多次考试历史明细”与“题库版本快照”这类更细粒度审计数据。
|
||||
|
||||
### 3.2 权限闭环差距
|
||||
|
||||
- 产品方案要求 HR 可查全局培训数据,普通员工不可查。
|
||||
- 当前实现主要按前端角色显示 HR 面板,缺少后端强校验。
|
||||
- 缺少 `is_hr` 或同等级权限标识注入,Agent 与接口层没有统一权限判断依据。
|
||||
|
||||
### 3.3 流程闭环差距
|
||||
|
||||
- 当前已支持刷新页面后恢复培训进度,且结果页与 HR 管理视图可共享同一份后端记录。
|
||||
- 仍缺少“跨设备继续考试”“考试历史回放”“多次考试明细查询”等增强流程能力。
|
||||
|
||||
### 3.4 配置闭环差距
|
||||
|
||||
- 视频地址、题库、知识点、及格线、欢迎语仍主要依赖前端静态内容。
|
||||
- HR 无法通过后台配置灵活维护培训内容。
|
||||
- 培训规则变更需要改代码并重新发版。
|
||||
|
||||
### 3.5 质量闭环差距
|
||||
|
||||
- 缺少培训主流程自动化测试。
|
||||
- 缺少培训相关后端接口测试。
|
||||
- 缺少异常流测试,例如刷新恢复、补考、权限拒绝、防作弊等。
|
||||
|
||||
## 4. P0 / P1 / P2 整改清单
|
||||
|
||||
### 4.1 P0:必须优先完成
|
||||
|
||||
#### 数据闭环
|
||||
|
||||
- 新增培训结果数据模型,至少包含:
|
||||
- `user_id`
|
||||
- `employee_id`
|
||||
- `department`
|
||||
- `score`
|
||||
- `passed`
|
||||
- `attempt_count`
|
||||
- `start_time`
|
||||
- `completion_time`
|
||||
- `answer_details`
|
||||
- 补齐 Alembic 迁移脚本。
|
||||
- 新增成绩提交接口,考试结束后由前端或 Agent 调用提交。
|
||||
- 新增 HR 统计接口,支持总人数、通过率、未完成人数、平均分等聚合统计。
|
||||
- 新增 Excel 导出接口,字段需覆盖:
|
||||
- 入职日期
|
||||
- 完成日期
|
||||
- 部门
|
||||
- 姓名
|
||||
- 工号
|
||||
- 分数
|
||||
|
||||
#### 权限闭环
|
||||
|
||||
- 明确 HR 权限来源,不再只依赖前端 `admin` 视图判断。
|
||||
- 后端统一注入 `is_hr` 或培训数据查看权限字段。
|
||||
- 普通员工访问统计/导出时,后端直接拒绝并返回统一错误码。
|
||||
- 前端 HR 管理面板按真实权限显示。
|
||||
|
||||
#### 流程闭环
|
||||
|
||||
- 考试结束后真实落库,不再只保留前端本地记录。
|
||||
- 未通过时记录补考次数与最近一次成绩。
|
||||
- 通过后更新真实完成状态,供员工视图与 HR 视图共用。
|
||||
- 页面刷新、重新进入后可恢复培训进度和考试状态。
|
||||
|
||||
### 4.2 P1:建议在 P0 后尽快完成
|
||||
|
||||
#### 配置闭环
|
||||
|
||||
- 视频地址改为后台可配置。
|
||||
- 题库、知识点、及格线从前端资源迁移为后台配置或 Agent 配置。
|
||||
- 支持管理端维护培训内容,而不是每次改题都发版。
|
||||
- Agent 培训模式配置扩展为:
|
||||
- 视频链接
|
||||
- 题库版本
|
||||
- 通过线
|
||||
- 欢迎语模板
|
||||
|
||||
#### 质量闭环
|
||||
|
||||
- 补前端回归测试:
|
||||
- 进入培训
|
||||
- 看完视频
|
||||
- 开始考试
|
||||
- 连续答题
|
||||
- 结算
|
||||
- 补考
|
||||
- 补后端接口测试:
|
||||
- 提交成绩
|
||||
- 查询统计
|
||||
- 导出 Excel
|
||||
- 权限拦截
|
||||
- 补异常流测试:
|
||||
- 刷新页面恢复
|
||||
- 切换 Agent
|
||||
- 未答完退出后再次进入
|
||||
- 补防作弊测试:
|
||||
- 提前索要答案
|
||||
- 跳题
|
||||
- 请求完整题库
|
||||
|
||||
### 4.3 P2:体验和运营优化
|
||||
|
||||
- 通过后生成培训完成凭证或完成总结卡片。
|
||||
- 增加 HR 维度筛选,例如部门、时间范围、通过状态。
|
||||
- 增加考试历史记录与最近一次成绩查看。
|
||||
- 增加题库版本管理与培训记录审计。
|
||||
|
||||
## 5. 任务拆分建议
|
||||
|
||||
### 5.1 前端任务
|
||||
|
||||
- 对接真实提交接口,替换本地模拟落库。
|
||||
- 对接真实统计接口和导出接口,替换前端样例 HR 数据。
|
||||
- 增加培训进度恢复逻辑。
|
||||
- 增加权限分流,员工与 HR 看到不同数据能力。
|
||||
- 保持现有聊天卡片体验不变,逐步将数据源切换到后端。
|
||||
|
||||
### 5.2 后端任务
|
||||
|
||||
- 新增培训记录模型与迁移。
|
||||
- 新增培训服务与 API:
|
||||
- 提交成绩
|
||||
- 查询统计
|
||||
- 导出 Excel
|
||||
- 获取个人培训进度
|
||||
- 增加培训权限校验。
|
||||
- 增加培训配置读取能力,支持视频、题库、通过线动态化。
|
||||
- 为培训 API 接入统一错误处理契约。
|
||||
|
||||
### 5.3 联调任务
|
||||
|
||||
- 明确前后端字段契约:
|
||||
- 当前题号
|
||||
- 总题数
|
||||
- 分数
|
||||
- 是否通过
|
||||
- 补考次数
|
||||
- 完成时间
|
||||
- 明确提交时机:
|
||||
- 每题即时提交
|
||||
- 或考试结束统一提交
|
||||
- 明确页面刷新后的恢复策略。
|
||||
- 明确 HR 权限字段和上下文注入方式。
|
||||
|
||||
### 5.4 测试任务
|
||||
|
||||
- 员工正常流:欢迎语 -> 视频 -> 复盘 -> 考试 -> 通过。
|
||||
- 员工失败流:未通过 -> 重考 -> 通过。
|
||||
- 恢复流:中途退出后再次进入恢复进度。
|
||||
- 权限流:普通员工禁止查看全局统计和导出。
|
||||
- HR 流:统计查询正确、Excel 字段正确。
|
||||
- 防作弊流:不能提前拿到未答题目的正确答案。
|
||||
|
||||
## 6. 建议实施顺序
|
||||
|
||||
### 第一阶段
|
||||
|
||||
- 培训记录模型
|
||||
- 数据迁移
|
||||
- 提交接口
|
||||
- 统计接口
|
||||
- 导出接口
|
||||
- HR 权限打通
|
||||
|
||||
### 第二阶段
|
||||
|
||||
- 前端对接真实数据
|
||||
- 培训进度恢复
|
||||
- 补考历史与完成状态一致性
|
||||
- 视频和题库配置化
|
||||
|
||||
### 第三阶段
|
||||
|
||||
- 自动化测试
|
||||
- 防作弊加强
|
||||
- 审计与体验优化
|
||||
|
||||
## 7. 一句话结论
|
||||
|
||||
当前“新员工培训”已经完成前端交互闭环,但距离产品文档要求的真实业务闭环,仍需优先补齐以下四块:
|
||||
|
||||
- 后端落库
|
||||
- 真实统计导出
|
||||
- HR 权限隔离
|
||||
- 正式培训素材与配置化
|
||||
@@ -0,0 +1,200 @@
|
||||
/**
|
||||
* features/chat/api/training.api.ts
|
||||
* 用途:培训工作区专用 HTTP API,负责员工进度读取/保存、HR 记录查询、统计和导出。
|
||||
* 依赖:shared/api/client、auth headers、training.types。
|
||||
* 逻辑:把后端 training 领域的 snake_case 返回值统一映射成前端工作区需要的 camelCase 结构。
|
||||
*/
|
||||
import { requestJson } from '@/shared/api/client';
|
||||
import { getAuthHeaders } from '@/shared/utils/auth';
|
||||
import type { TrainingAnswerRecord, TrainingProgressRecord, TrainingRecord, TrainingStage, TrainingStats } from '../training/training.types';
|
||||
|
||||
type TrainingRecordApi = {
|
||||
id: number;
|
||||
user_id?: number;
|
||||
employee_id?: string | null;
|
||||
name?: string | null;
|
||||
department?: string | null;
|
||||
join_date?: string | null;
|
||||
stage?: TrainingStage;
|
||||
current_question_index?: number;
|
||||
score?: number;
|
||||
passed?: boolean;
|
||||
attempt_count?: number;
|
||||
answer_details?: Array<{
|
||||
question_id?: string;
|
||||
selected_option_id?: string;
|
||||
correct?: boolean;
|
||||
}>;
|
||||
completion_time?: string | null;
|
||||
updated_at?: string | null;
|
||||
started_at?: string | null;
|
||||
status?: TrainingRecord['status'];
|
||||
};
|
||||
|
||||
type TrainingListApi = {
|
||||
items: TrainingRecordApi[];
|
||||
total: number;
|
||||
page: number;
|
||||
page_size: number;
|
||||
pages: number;
|
||||
department_options: string[];
|
||||
};
|
||||
|
||||
type TrainingStatsApi = {
|
||||
total: number;
|
||||
passed: number;
|
||||
failed: number;
|
||||
in_progress: number;
|
||||
pass_rate: number;
|
||||
average_score: number;
|
||||
};
|
||||
|
||||
export interface TrainingRecordQuery {
|
||||
keyword?: string;
|
||||
department?: string;
|
||||
status?: 'all' | 'passed' | 'failed' | 'in_progress';
|
||||
page?: number;
|
||||
page_size?: number;
|
||||
}
|
||||
|
||||
export interface SaveTrainingProgressPayload {
|
||||
stage: TrainingStage;
|
||||
currentQuestionIndex: number;
|
||||
score: number;
|
||||
passed: boolean;
|
||||
attemptCount: number;
|
||||
answerDetails: TrainingAnswerRecord[];
|
||||
joinDate?: string | null;
|
||||
}
|
||||
|
||||
const authHeaders = () => ({ headers: getAuthHeaders() });
|
||||
const jsonAuthHeaders = () => ({ headers: { 'Content-Type': 'application/json', ...getAuthHeaders() } });
|
||||
|
||||
function mapAnswerDetails(items?: TrainingRecordApi['answer_details']): TrainingAnswerRecord[] {
|
||||
return Array.isArray(items)
|
||||
? items.map((item) => ({
|
||||
questionId: String(item.question_id || ''),
|
||||
selectedOptionId: String(item.selected_option_id || ''),
|
||||
correct: Boolean(item.correct),
|
||||
}))
|
||||
: [];
|
||||
}
|
||||
|
||||
function mapTrainingProgressRecord(data: TrainingRecordApi): TrainingProgressRecord {
|
||||
return {
|
||||
id: data.id,
|
||||
name: String(data.name || ''),
|
||||
employeeId: String(data.employee_id || ''),
|
||||
department: String(data.department || ''),
|
||||
joinDate: String(data.join_date || ''),
|
||||
completionDate: data.completion_time ? String(data.completion_time).slice(0, 10) : null,
|
||||
score: typeof data.score === 'number' ? data.score : null,
|
||||
attempts: Number(data.attempt_count || 0),
|
||||
status: data.status || 'in_progress',
|
||||
stage: (data.stage || 'video') as TrainingStage,
|
||||
currentQuestionIndex: Number(data.current_question_index || 0),
|
||||
passed: Boolean(data.passed),
|
||||
answerDetails: mapAnswerDetails(data.answer_details),
|
||||
startedAt: data.started_at || null,
|
||||
completionTime: data.completion_time || null,
|
||||
updatedAt: data.updated_at || null,
|
||||
};
|
||||
}
|
||||
|
||||
function mapTrainingRecord(data: TrainingRecordApi): TrainingRecord {
|
||||
const progress = mapTrainingProgressRecord(data);
|
||||
return {
|
||||
id: progress.id,
|
||||
name: progress.name,
|
||||
employeeId: progress.employeeId,
|
||||
department: progress.department,
|
||||
joinDate: progress.joinDate,
|
||||
completionDate: progress.completionDate,
|
||||
score: progress.score,
|
||||
attempts: progress.attempts,
|
||||
status: progress.status,
|
||||
};
|
||||
}
|
||||
|
||||
function buildQueryString(query: TrainingRecordQuery = {}) {
|
||||
const params = new URLSearchParams();
|
||||
if (query.keyword) params.set('keyword', query.keyword);
|
||||
if (query.department) params.set('department', query.department);
|
||||
if (query.status) params.set('status', query.status);
|
||||
if (query.page) params.set('page', String(query.page));
|
||||
if (query.page_size) params.set('page_size', String(query.page_size));
|
||||
return params.toString();
|
||||
}
|
||||
|
||||
export async function getMyTrainingProgress(): Promise<TrainingProgressRecord | null> {
|
||||
const data = await requestJson<TrainingRecordApi | null>('/api/user/training-record', authHeaders());
|
||||
return data ? mapTrainingProgressRecord(data) : null;
|
||||
}
|
||||
|
||||
export async function saveMyTrainingProgress(payload: SaveTrainingProgressPayload): Promise<TrainingProgressRecord> {
|
||||
const data = await requestJson<TrainingRecordApi>('/api/user/training-record/progress', {
|
||||
method: 'PUT',
|
||||
...jsonAuthHeaders(),
|
||||
body: JSON.stringify({
|
||||
stage: payload.stage,
|
||||
current_question_index: payload.currentQuestionIndex,
|
||||
score: payload.score,
|
||||
passed: payload.passed,
|
||||
attempt_count: payload.attemptCount,
|
||||
answer_details: payload.answerDetails.map((item) => ({
|
||||
question_id: item.questionId,
|
||||
selected_option_id: item.selectedOptionId,
|
||||
correct: item.correct,
|
||||
})),
|
||||
join_date: payload.joinDate || undefined,
|
||||
}),
|
||||
});
|
||||
return mapTrainingProgressRecord(data);
|
||||
}
|
||||
|
||||
export async function listTrainingRecords(query: TrainingRecordQuery = {}) {
|
||||
const qs = buildQueryString(query);
|
||||
const data = await requestJson<TrainingListApi>(`/api/admin/training-records${qs ? `?${qs}` : ''}`, authHeaders());
|
||||
return {
|
||||
items: data.items.map(mapTrainingRecord),
|
||||
total: data.total,
|
||||
page: data.page,
|
||||
pageSize: data.page_size,
|
||||
pages: data.pages,
|
||||
departmentOptions: data.department_options || [],
|
||||
};
|
||||
}
|
||||
|
||||
export async function getTrainingStats(query: TrainingRecordQuery = {}): Promise<TrainingStats> {
|
||||
const qs = buildQueryString(query);
|
||||
const data = await requestJson<TrainingStatsApi>(`/api/admin/training-records/stats${qs ? `?${qs}` : ''}`, authHeaders());
|
||||
return {
|
||||
total: Number(data.total || 0),
|
||||
passed: Number(data.passed || 0),
|
||||
failed: Number(data.failed || 0),
|
||||
inProgress: Number(data.in_progress || 0),
|
||||
passRate: Number(data.pass_rate || 0),
|
||||
averageScore: Number(data.average_score || 0),
|
||||
};
|
||||
}
|
||||
|
||||
export async function exportTrainingRecords(query: TrainingRecordQuery = {}): Promise<void> {
|
||||
const qs = buildQueryString(query);
|
||||
const response = await fetch(`/api/admin/training-records/export${qs ? `?${qs}` : ''}`, {
|
||||
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;
|
||||
link.download = `training_records_${new Date().toISOString().slice(0, 10)}.xlsx`;
|
||||
document.body.appendChild(link);
|
||||
link.click();
|
||||
link.remove();
|
||||
URL.revokeObjectURL(url);
|
||||
}
|
||||
@@ -174,9 +174,9 @@ watch(
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<footer class="safe-bottom sticky bottom-0 z-20 bg-transparent p-3 md:p-6">
|
||||
<footer class="safe-bottom z-20 shrink-0 bg-transparent p-2 md:p-3">
|
||||
<div class="relative mx-auto max-w-4xl">
|
||||
<div class="flex flex-col rounded-2xl bg-surface p-2 shadow-[0_0_15px_rgba(0,0,0,0.05)] transition-all">
|
||||
<div class="flex flex-col rounded-2xl bg-surface p-1.5 shadow-[0_0_15px_rgba(0,0,0,0.05)] transition-all">
|
||||
<div
|
||||
v-if="isShippingNoticeAgent && shippingFocusTaskNo"
|
||||
class="mb-2 flex items-center gap-2 rounded-xl bg-brand-500 px-3 py-2 text-xs font-medium text-white"
|
||||
@@ -198,8 +198,8 @@ watch(
|
||||
v-model="inputValue"
|
||||
rows="1"
|
||||
:placeholder="isVoiceTranscribing ? $t('chat.voiceTranscribing') : isVoiceRecording ? $t('chat.voiceListening') : shippingFocusTaskNo ? $t('chat.shippingNoticeUi.focusInputPlaceholder', { taskId: shippingFocusTaskNo }) : $t('chat.askAnything')"
|
||||
class="w-full resize-none border-none bg-transparent px-3 py-2 text-[15px] leading-relaxed text-primary placeholder-slate-400 focus:border-transparent focus:outline-none focus:ring-0"
|
||||
style="min-height: 44px; max-height: 220px;"
|
||||
class="w-full resize-none border-none bg-transparent px-2.5 py-1.5 text-[15px] leading-relaxed text-primary placeholder-slate-400 focus:border-transparent focus:outline-none focus:ring-0"
|
||||
style="min-height: 40px; max-height: 220px;"
|
||||
:disabled="isVoiceTranscribing"
|
||||
spellcheck="false"
|
||||
autocorrect="off"
|
||||
@@ -253,7 +253,7 @@ watch(
|
||||
<span>点发送开始处理</span>
|
||||
</div>
|
||||
|
||||
<div class="mt-2 flex items-center justify-between px-2 pb-1">
|
||||
<div class="mt-1.5 flex items-center justify-between px-1.5 pb-0.5">
|
||||
<div class="flex items-center gap-3">
|
||||
<button
|
||||
type="button"
|
||||
|
||||
@@ -10,6 +10,7 @@ import ChatMessageBubble, { type ChatMessageBubbleHandlers } from './messages/Ch
|
||||
import ToolRunProgressCard from './ToolRunProgressCard.vue';
|
||||
import type { LeaveMessageHandlers } from './messages/LeaveMessageBlock.vue';
|
||||
import type { ShippingMappingHandlers } from './messages/ShippingInventoryMappingMessage.vue';
|
||||
import type { TrainingHandlers } from './messages/TrainingExamQuestionMessage.vue';
|
||||
import type { ChatMessage } from '../types/chat.types';
|
||||
import type { ToolRunProgress } from '../api/toolRunProgress.api';
|
||||
|
||||
@@ -31,6 +32,7 @@ const {
|
||||
handlers: ChatMessageBubbleHandlers;
|
||||
leaveHandlers: LeaveMessageHandlers;
|
||||
shippingHandlers: ShippingMappingHandlers;
|
||||
trainingHandlers: TrainingHandlers;
|
||||
shouldRenderMessage: (msg: ChatMessage) => boolean;
|
||||
shouldShowToolRunProgressAfterMessage: (msg: ChatMessage, index: number) => boolean;
|
||||
getMessageRunProgress: (msg: ChatMessage) => ToolRunProgress | null;
|
||||
@@ -39,6 +41,8 @@ const {
|
||||
toolRunProgress: ToolRunProgress | null;
|
||||
toolRunProgressTitle: string;
|
||||
showScrollToBottom: boolean;
|
||||
hideWelcomePanel?: boolean;
|
||||
pinMessagesToBottom?: boolean;
|
||||
/** 供父级滚动逻辑绑定 main 元素 */
|
||||
scrollContainerHolder: { el: Ref<HTMLElement | null> };
|
||||
}>();
|
||||
@@ -74,9 +78,9 @@ const getMessageKey = (msg: ChatMessage, index: number) => (
|
||||
class="flex-1 p-3 md:p-8"
|
||||
:class="messages.length === 0 ? 'overflow-hidden md:overflow-y-auto' : 'overflow-y-auto scrollbar-thin'"
|
||||
>
|
||||
<div :class="messages.length === 0 ? 'h-full' : 'flex min-h-full flex-col justify-end'">
|
||||
<div :class="messages.length === 0 ? 'h-full' : pinMessagesToBottom === false ? 'min-h-full' : 'flex min-h-full flex-col justify-end'">
|
||||
<ChatWelcomePanel
|
||||
v-if="messages.length === 0"
|
||||
v-if="messages.length === 0 && !hideWelcomePanel"
|
||||
:agent-name="agentName"
|
||||
:suggested-questions-style="suggestedQuestionsStyle"
|
||||
:styled-sections="styledSections"
|
||||
@@ -97,6 +101,7 @@ const getMessageKey = (msg: ChatMessage, index: number) => (
|
||||
:handlers="handlers"
|
||||
:leave-handlers="leaveHandlers"
|
||||
:shipping-handlers="shippingHandlers"
|
||||
:training-handlers="trainingHandlers"
|
||||
@copy="emit('copy', { message: msg, index })"
|
||||
@edit="emit('edit', $event)"
|
||||
@resend="emit('resend', $event)"
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
* 逻辑:本文件只做页面结构编排;发货批次进度样式与任务续办交互下沉到独立面板组件。
|
||||
*/
|
||||
<script setup lang="ts">
|
||||
import { computed, ref, watch } from 'vue';
|
||||
import { Loader2 } from 'lucide-vue-next';
|
||||
import ChatShell from '@/shared/layouts/ChatShell.vue';
|
||||
import ChatSidebar from '@/features/chat/components/ChatSidebar.vue';
|
||||
@@ -14,9 +15,19 @@ import ChatMobileHeader from '@/features/chat/components/ChatMobileHeader.vue';
|
||||
import ChatBrowserPanel from '@/features/chat/components/ChatBrowserPanel.vue';
|
||||
import ShippingBatchProgressPanel from '@/features/chat/components/ShippingBatchProgressPanel.vue';
|
||||
import ShippingBatchWorkspaceDrawer from '@/features/chat/components/ShippingBatchWorkspaceDrawer.vue';
|
||||
import TrainingWorkspacePanel from '@/features/chat/components/TrainingWorkspacePanel.vue';
|
||||
import { useChatPageContext } from '@/features/chat/composables/chat.context';
|
||||
import { matchesTrainingAgent } from '@/features/chat/composables/useTrainingWorkspace';
|
||||
|
||||
const page = useChatPageContext();
|
||||
const isTrainingAgentPage = computed(() => matchesTrainingAgent(page.currentAgent));
|
||||
const hideWelcomePanel = computed(() => isTrainingAgentPage.value);
|
||||
const isTrainingWorkspaceExpanded = ref(false);
|
||||
|
||||
// 切换 Agent 时,重置工作区展开状态,确保每次进入都是收起状态(聊天优先)
|
||||
watch(() => page.currentAgentId, () => {
|
||||
isTrainingWorkspaceExpanded.value = false;
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -84,8 +95,18 @@ const page = useChatPageContext();
|
||||
</div>
|
||||
|
||||
<template v-else>
|
||||
<div class="flex min-h-0 flex-1">
|
||||
<div class="flex min-h-0 flex-1 flex-col">
|
||||
<div class="flex min-h-0 min-w-0 flex-1">
|
||||
<div class="flex min-h-0 min-w-0 flex-1 flex-col">
|
||||
<TrainingWorkspacePanel
|
||||
:current-agent="page.currentAgent"
|
||||
:current-user="page.currentUser"
|
||||
:has-messages="page.messages.length > 0"
|
||||
:training="page.training"
|
||||
@send-chat-prompt="page.handleSend($event)"
|
||||
@push-local-assistant-message="page.pushLocalAssistantMessage($event)"
|
||||
@update:expanded="isTrainingWorkspaceExpanded = $event"
|
||||
/>
|
||||
|
||||
<ShippingBatchProgressPanel
|
||||
v-if="page.isShippingNoticeAgent && (page.shippingBatchSummary || page.activeShippingTaskDetail)"
|
||||
:conversation-workspace="page.shippingConversationWorkspace"
|
||||
@@ -99,6 +120,7 @@ const page = useChatPageContext();
|
||||
/>
|
||||
|
||||
<ChatMessageList
|
||||
v-show="!isTrainingWorkspaceExpanded"
|
||||
:messages="page.messages"
|
||||
:agent-name="page.currentAgent?.name || 'AI'"
|
||||
:suggested-questions-style="page.suggestedQuestionsStyle"
|
||||
@@ -112,6 +134,7 @@ const page = useChatPageContext();
|
||||
:handlers="page.messageBubbleHandlers"
|
||||
:leave-handlers="page.leaveMessageHandlers"
|
||||
:shipping-handlers="page.shippingMappingHandlers"
|
||||
:training-handlers="page.trainingHandlers"
|
||||
:should-render-message="page.shouldRenderMessage"
|
||||
:should-show-tool-run-progress-after-message="page.shouldShowToolRunProgressAfterMessage"
|
||||
:get-message-run-progress="page.getMessageRunProgress"
|
||||
@@ -120,6 +143,8 @@ const page = useChatPageContext();
|
||||
:tool-run-progress="page.toolRunProgress"
|
||||
:tool-run-progress-title="page.toolRunProgressTitle"
|
||||
:show-scroll-to-bottom="page.showScrollToBottom"
|
||||
:hide-welcome-panel="hideWelcomePanel"
|
||||
:pin-messages-to-bottom="!isTrainingAgentPage"
|
||||
:scroll-container-holder="page.scrollContainerHolder"
|
||||
@copy="page.copyToClipboard($event.message, $event.index)"
|
||||
@edit="page.input = $event"
|
||||
@@ -131,6 +156,7 @@ const page = useChatPageContext();
|
||||
/>
|
||||
|
||||
<ChatInputBar
|
||||
v-show="!isTrainingWorkspaceExpanded"
|
||||
:key="`${page.currentAgentId}-${page.conversationId || 'draft'}-${page.messages.length}`"
|
||||
v-model="page.input"
|
||||
v-model:selected-kb="page.selectedKb"
|
||||
|
||||
@@ -0,0 +1,819 @@
|
||||
<script setup lang="ts">
|
||||
/**
|
||||
* features/chat/components/TrainingWorkspacePanel.vue
|
||||
* 用途:在培训 Agent 的聊天页顶部提供“学员考试流 + HR 管理流”一体化工作区。
|
||||
* 依赖:useTrainingWorkspace、lucide 图标、聊天页 currentAgent/currentUser。
|
||||
* 逻辑:只在培训 Agent 下渲染;学员端负责前端交互闭环,HR 端负责本地筛选统计与 Excel 导出,并可把上下文同步回聊天区。
|
||||
*/
|
||||
import { computed, reactive, ref, watch, type ShallowUnwrapRef } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import {
|
||||
BarChart3,
|
||||
BookOpen,
|
||||
CheckCircle2,
|
||||
ChevronDown,
|
||||
ChevronUp,
|
||||
ClipboardCheck,
|
||||
Download,
|
||||
PlayCircle,
|
||||
RefreshCcw,
|
||||
Send,
|
||||
ShieldCheck,
|
||||
Target,
|
||||
Users,
|
||||
XCircle,
|
||||
} from 'lucide-vue-next';
|
||||
import { useTrainingWorkspace } from '@/features/chat/composables/useTrainingWorkspace';
|
||||
|
||||
const props = defineProps<{
|
||||
currentAgent: Record<string, unknown> | null;
|
||||
currentUser: Record<string, unknown> | null;
|
||||
hasMessages: boolean;
|
||||
training: ShallowUnwrapRef<ReturnType<typeof useTrainingWorkspace>>;
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
'send-chat-prompt': [prompt: string];
|
||||
'push-local-assistant-message': [content: string];
|
||||
'update:expanded': [expanded: boolean];
|
||||
}>();
|
||||
|
||||
const { t } = useI18n();
|
||||
|
||||
const workspace = reactive(props.training);
|
||||
|
||||
// 将 workspace 内部控制弹窗的状态同步给组件本地变量(如果需要,或者直接用 workspace.showVideoModal)
|
||||
const showVideoModal = computed({
|
||||
get: () => workspace.showVideoModal,
|
||||
set: (val) => { workspace.showVideoModal = val; }
|
||||
});
|
||||
const lastVideoTime = ref(0);
|
||||
|
||||
const stageStep = computed(() => {
|
||||
if (workspace.stage === 'video') return 1;
|
||||
if (workspace.stage === 'summary') return 2;
|
||||
if (workspace.stage === 'exam') return 3;
|
||||
return 4;
|
||||
});
|
||||
|
||||
const stageItems = computed(() => ([
|
||||
{ key: 'video', label: 'chat.training.steps.video', icon: PlayCircle },
|
||||
{ key: 'summary', label: 'chat.training.steps.summary', icon: BookOpen },
|
||||
{ key: 'exam', label: 'chat.training.steps.exam', icon: ClipboardCheck },
|
||||
{ key: 'result', label: 'chat.training.steps.result', icon: ShieldCheck },
|
||||
]));
|
||||
|
||||
const userExpandedOverride = ref(false);
|
||||
|
||||
const handleVideoTimeUpdate = (e: Event) => {
|
||||
const video = e.target as HTMLVideoElement;
|
||||
if (!video.seeking) {
|
||||
lastVideoTime.value = video.currentTime;
|
||||
}
|
||||
};
|
||||
|
||||
const handleVideoSeeking = (e: Event) => {
|
||||
const video = e.target as HTMLVideoElement;
|
||||
if (video.currentTime > lastVideoTime.value + 1) {
|
||||
video.currentTime = lastVideoTime.value;
|
||||
}
|
||||
};
|
||||
|
||||
const handleVideoEnded = () => {
|
||||
showVideoModal.value = false;
|
||||
workspace.markVideoCompleted();
|
||||
};
|
||||
|
||||
const setWorkspaceExpanded = (expanded: boolean, manual = false) => {
|
||||
workspaceExpanded.value = expanded;
|
||||
emit('update:expanded', expanded);
|
||||
if (manual) {
|
||||
userExpandedOverride.value = expanded;
|
||||
} else if (!expanded) {
|
||||
userExpandedOverride.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
const sendPrompt = (prompt: string) => {
|
||||
setWorkspaceExpanded(false);
|
||||
emit('send-chat-prompt', prompt);
|
||||
};
|
||||
|
||||
const currentAnswerLabel = computed(() => {
|
||||
const question = workspace.currentQuestion;
|
||||
if (!question) return '';
|
||||
return question.options?.find((item) => item.id === workspace.selectedOptionId)?.label || '';
|
||||
});
|
||||
|
||||
// 默认进入 Chat 聊天页面(即收起工作区状态)
|
||||
const workspaceExpanded = ref(false);
|
||||
|
||||
const autoSyncInitialPrompt = () => {
|
||||
if (workspace.isTrainingAgent && workspace.isHydrated && !props.hasMessages) {
|
||||
emit('push-local-assistant-message', workspace.learnerChatPrompt);
|
||||
}
|
||||
};
|
||||
|
||||
// 监听 Agent 切换,重置所有本地交互状态,确保每次进入都是初始、收起且触发引导的状态
|
||||
watch(
|
||||
() => props.currentAgent?.id,
|
||||
() => {
|
||||
userExpandedOverride.value = false;
|
||||
workspaceExpanded.value = false;
|
||||
emit('update:expanded', false);
|
||||
},
|
||||
{ immediate: true }
|
||||
);
|
||||
|
||||
watch(() => props.hasMessages, () => {
|
||||
// 如果用户没有手动展开,且消息状态变化,我们保持在聊天模式(收起工作区)
|
||||
if (!userExpandedOverride.value) {
|
||||
workspaceExpanded.value = false;
|
||||
emit('update:expanded', false);
|
||||
}
|
||||
});
|
||||
|
||||
watch(
|
||||
() => workspace.isHydrated,
|
||||
(ready) => {
|
||||
if (ready && workspace.isTrainingAgent && !props.hasMessages) {
|
||||
autoSyncInitialPrompt();
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
const isCompactMode = computed(() => !workspaceExpanded.value);
|
||||
|
||||
const compactSummary = computed(() => {
|
||||
if (workspace.activeView === 'admin') {
|
||||
return `${workspace.stats.total}${t('chat.training.hr.stats.total')} / ${workspace.stats.passRate}% ${t('chat.training.hr.stats.passRate')}`;
|
||||
}
|
||||
if (workspace.stage === 'video') return t('chat.training.video.title');
|
||||
if (workspace.stage === 'summary') return t('chat.training.summary.title');
|
||||
if (workspace.stage === 'exam') {
|
||||
return t('chat.training.exam.questionCounter', {
|
||||
current: workspace.answeredCount + 1,
|
||||
total: workspace.totalQuestionCount,
|
||||
});
|
||||
}
|
||||
return workspace.isPassed ? t('chat.training.result.passTitle') : t('chat.training.result.failTitle');
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<section
|
||||
v-if="workspace.isTrainingAgent"
|
||||
class="mx-auto w-full max-w-6xl rounded-3xl border border-brand-100 bg-gradient-to-br from-white via-brand-50/30 to-slate-50 shadow-sm"
|
||||
:class="workspaceExpanded ? 'mb-0 min-h-0 flex-1 overflow-y-auto' : 'mb-4 min-w-0 flex-none'"
|
||||
>
|
||||
<div
|
||||
v-if="isCompactMode"
|
||||
class="flex flex-col gap-2 bg-white/90 px-4 py-2.5 backdrop-blur-sm md:px-5"
|
||||
>
|
||||
<div class="flex flex-col gap-2 xl:flex-row xl:items-center xl:justify-between">
|
||||
<div class="min-w-0">
|
||||
<div class="flex flex-wrap items-center gap-2">
|
||||
<div class="inline-flex items-center gap-2 rounded-full bg-brand-50 px-3 py-1 text-[11px] font-semibold text-brand-700">
|
||||
<BookOpen class="h-3.5 w-3.5" />
|
||||
{{ $t('chat.training.badge') }}
|
||||
</div>
|
||||
<div class="text-sm font-semibold text-primary md:text-base">
|
||||
{{ $t('chat.training.title') }}
|
||||
</div>
|
||||
</div>
|
||||
<div class="mt-1.5 flex flex-wrap gap-2">
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-full px-3 py-1.5 text-xs font-medium transition"
|
||||
:class="workspace.activeView === 'learner' ? 'bg-brand-600 text-white' : 'bg-surface-soft text-secondary hover:bg-slate-100'"
|
||||
@click="workspace.activeView = 'learner'"
|
||||
>
|
||||
{{ $t('chat.training.tabs.learner') }}
|
||||
</button>
|
||||
<button
|
||||
v-if="workspace.isAdminViewer"
|
||||
type="button"
|
||||
class="rounded-full px-3 py-1.5 text-xs font-medium transition"
|
||||
:class="workspace.activeView === 'admin' ? 'bg-brand-600 text-white' : 'bg-surface-soft text-secondary hover:bg-slate-100'"
|
||||
@click="workspace.activeView = 'admin'"
|
||||
>
|
||||
{{ $t('chat.training.tabs.admin') }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="flex flex-wrap items-center justify-end gap-2">
|
||||
<button
|
||||
v-if="workspace.stage === 'video'"
|
||||
type="button"
|
||||
class="inline-flex min-h-9 items-center gap-2 rounded-xl border border-brand-200 bg-brand-50 px-3 py-2 text-xs font-medium text-brand-700 transition hover:bg-brand-100"
|
||||
@click="showVideoModal = true"
|
||||
>
|
||||
<PlayCircle class="h-4 w-4" />
|
||||
{{ $t('chat.training.steps.video') }}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="inline-flex min-h-9 items-center gap-2 rounded-xl border border-default bg-white px-3 py-2 text-xs font-medium text-secondary transition hover:bg-surface-soft"
|
||||
@click="sendPrompt(workspace.learnerChatPrompt)"
|
||||
>
|
||||
<Send class="h-4 w-4" />
|
||||
{{ $t('chat.training.actions.syncLearnerToChat') }}
|
||||
</button>
|
||||
<button
|
||||
v-if="workspace.isAdminViewer"
|
||||
type="button"
|
||||
class="inline-flex min-h-9 items-center gap-2 rounded-xl border border-brand-200 bg-brand-50 px-3 py-2 text-xs font-medium text-brand-700 transition hover:bg-brand-100"
|
||||
@click="sendPrompt(workspace.managementChatPrompt)"
|
||||
>
|
||||
<BarChart3 class="h-4 w-4" />
|
||||
{{ $t('chat.training.actions.syncHrToChat') }}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="inline-flex h-9 items-center gap-2 rounded-xl border border-default bg-white px-3.5 text-xs font-medium leading-none text-secondary transition hover:bg-surface-soft"
|
||||
@click="setWorkspaceExpanded(true, true)"
|
||||
>
|
||||
<ChevronDown class="h-4 w-4 shrink-0" />
|
||||
<span class="leading-none">{{ $t('chat.training.actions.expandWorkspace') }}</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="flex flex-col gap-2 rounded-2xl border border-brand-100 bg-brand-50/40 px-4 py-2.5 md:flex-row md:items-center md:justify-between">
|
||||
<div class="min-w-0">
|
||||
<div class="truncate text-sm font-semibold text-primary">
|
||||
{{ compactSummary }}
|
||||
</div>
|
||||
<div class="mt-1 text-xs leading-5 text-secondary">
|
||||
<template v-if="workspace.activeView === 'admin'">
|
||||
{{ $t('chat.training.hr.filters.keywordLabel') }}: {{ workspace.hrKeyword || $t('chat.training.hr.filters.noLimit') }}
|
||||
· {{ $t('chat.training.hr.filters.departmentLabel') }}:
|
||||
{{ workspace.hrDepartmentFilter === 'all' ? $t('chat.training.hr.filters.allDepartments') : workspace.hrDepartmentFilter }}
|
||||
</template>
|
||||
<template v-else>
|
||||
{{ $t('chat.training.progressPercent') }}: {{ workspace.learnerProgressPercent }}%
|
||||
· {{ $t('chat.training.learnerCard.name') }}: {{ workspace.currentUserName }}
|
||||
</template>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex flex-wrap items-center gap-2 text-xs">
|
||||
<div class="rounded-full bg-white px-3 py-1.5 font-medium text-primary shadow-sm">
|
||||
{{ workspace.activeView === 'admin' ? `${$t('chat.training.hr.stats.passRate')} ${workspace.stats.passRate}%` : `${$t('chat.training.progressPercent')} ${workspace.learnerProgressPercent}%` }}
|
||||
</div>
|
||||
<div class="rounded-full bg-white px-3 py-1.5 font-medium text-primary shadow-sm">
|
||||
{{ workspace.activeView === 'admin' ? `${$t('chat.training.hr.stats.total')} ${workspace.stats.total}` : `${$t('chat.training.result.scoreLabel')} ${workspace.score}` }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-else class="flex flex-col gap-2 bg-white/90 px-4 py-2.5 backdrop-blur-sm md:px-5">
|
||||
<div class="flex flex-col gap-2 xl:flex-row xl:items-center xl:justify-between">
|
||||
<div class="min-w-0">
|
||||
<div class="flex flex-wrap items-center gap-2">
|
||||
<div class="inline-flex items-center gap-2 rounded-full bg-brand-50 px-3 py-1 text-[11px] font-semibold text-brand-700">
|
||||
<BookOpen class="h-3.5 w-3.5" />
|
||||
{{ $t('chat.training.badge') }}
|
||||
</div>
|
||||
<div class="text-sm font-semibold text-primary md:text-base">
|
||||
{{ $t('chat.training.title') }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mt-1.5 flex flex-wrap gap-2">
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-full px-3 py-1.5 text-xs font-medium transition"
|
||||
:class="workspace.activeView === 'learner' ? 'bg-brand-600 text-white' : 'bg-surface-soft text-secondary hover:bg-slate-100'"
|
||||
@click="workspace.activeView = 'learner'"
|
||||
>
|
||||
{{ $t('chat.training.tabs.learner') }}
|
||||
</button>
|
||||
<button
|
||||
v-if="workspace.isAdminViewer"
|
||||
type="button"
|
||||
class="rounded-full px-3 py-1.5 text-xs font-medium transition"
|
||||
:class="workspace.activeView === 'admin' ? 'bg-brand-600 text-white' : 'bg-surface-soft text-secondary hover:bg-slate-100'"
|
||||
@click="workspace.activeView = 'admin'"
|
||||
>
|
||||
{{ $t('chat.training.tabs.admin') }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="flex flex-wrap items-center justify-end gap-2">
|
||||
<button
|
||||
type="button"
|
||||
class="inline-flex min-h-9 items-center gap-2 rounded-xl border border-default bg-white px-3 py-2 text-xs font-medium text-secondary transition hover:bg-surface-soft"
|
||||
@click="sendPrompt(workspace.learnerChatPrompt)"
|
||||
>
|
||||
<Send class="h-4 w-4" />
|
||||
{{ $t('chat.training.actions.syncLearnerToChat') }}
|
||||
</button>
|
||||
<button
|
||||
v-if="workspace.isAdminViewer"
|
||||
type="button"
|
||||
class="inline-flex min-h-9 items-center gap-2 rounded-xl border border-brand-200 bg-brand-50 px-3 py-2 text-xs font-medium text-brand-700 transition hover:bg-brand-100"
|
||||
@click="sendPrompt(workspace.managementChatPrompt)"
|
||||
>
|
||||
<BarChart3 class="h-4 w-4" />
|
||||
{{ $t('chat.training.actions.syncHrToChat') }}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="inline-flex h-9 items-center gap-2 rounded-xl border border-default bg-white px-3.5 text-xs font-medium leading-none text-secondary transition hover:bg-surface-soft"
|
||||
@click="setWorkspaceExpanded(false, true)"
|
||||
>
|
||||
<ChevronUp class="h-4 w-4 shrink-0" />
|
||||
<span class="leading-none">{{ $t('chat.training.actions.collapseWorkspace') }}</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="flex flex-col gap-2 rounded-2xl border border-brand-100 bg-brand-50/40 px-4 py-2.5 md:flex-row md:items-center md:justify-between">
|
||||
<div class="min-w-0">
|
||||
<div class="truncate text-sm font-semibold text-primary">
|
||||
{{ compactSummary }}
|
||||
</div>
|
||||
<div class="mt-1 text-xs leading-5 text-secondary">
|
||||
<template v-if="workspace.activeView === 'admin'">
|
||||
{{ $t('chat.training.hr.filters.keywordLabel') }}: {{ workspace.hrKeyword || $t('chat.training.hr.filters.noLimit') }}
|
||||
· {{ $t('chat.training.hr.filters.departmentLabel') }}:
|
||||
{{ workspace.hrDepartmentFilter === 'all' ? $t('chat.training.hr.filters.allDepartments') : workspace.hrDepartmentFilter }}
|
||||
</template>
|
||||
<template v-else>
|
||||
{{ $t('chat.training.progressPercent') }}: {{ workspace.learnerProgressPercent }}%
|
||||
· {{ $t('chat.training.learnerCard.name') }}: {{ workspace.currentUserName }}
|
||||
</template>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex flex-wrap items-center gap-2 text-xs">
|
||||
<div class="rounded-full bg-white px-3 py-1.5 font-medium text-primary shadow-sm">
|
||||
{{ workspace.activeView === 'admin' ? `${$t('chat.training.hr.stats.passRate')} ${workspace.stats.passRate}%` : `${$t('chat.training.progressPercent')} ${workspace.learnerProgressPercent}%` }}
|
||||
</div>
|
||||
<div class="rounded-full bg-white px-3 py-1.5 font-medium text-primary shadow-sm">
|
||||
{{ workspace.activeView === 'admin' ? `${$t('chat.training.hr.stats.total')} ${workspace.stats.total}` : `${$t('chat.training.result.scoreLabel')} ${workspace.score}` }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="!isCompactMode && workspace.activeView === 'learner'" class="grid gap-3 p-4 md:grid-cols-[minmax(0,1.25fr)_232px] md:p-5 lg:gap-4 lg:grid-cols-[minmax(0,1.4fr)_260px] 2xl:grid-cols-[minmax(0,1.55fr)_300px]">
|
||||
<div class="min-w-0 space-y-4">
|
||||
<div class="rounded-2xl border border-default bg-white p-4 shadow-sm">
|
||||
<div class="flex flex-col gap-2.5 lg:flex-row lg:items-start lg:justify-between">
|
||||
<div>
|
||||
<div class="text-xs font-semibold uppercase tracking-[0.18em] text-brand-600">
|
||||
{{ $t('chat.training.progressLabel') }}
|
||||
</div>
|
||||
<div class="mt-1 text-xs leading-5 text-secondary md:text-sm">
|
||||
{{ $t('chat.training.progressHint') }}
|
||||
</div>
|
||||
</div>
|
||||
<div class="rounded-xl bg-surface-soft px-3 py-2 text-center">
|
||||
<div class="text-xs text-muted">{{ $t('chat.training.progressPercent') }}</div>
|
||||
<div class="text-lg font-semibold leading-none text-primary">{{ workspace.learnerProgressPercent }}%</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mt-3 grid grid-cols-2 gap-2 lg:grid-cols-4">
|
||||
<div
|
||||
v-for="(item, index) in stageItems"
|
||||
:key="item.key"
|
||||
class="rounded-xl border px-3 py-2.5 transition cursor-pointer hover:border-brand-300"
|
||||
:class="stageStep >= index + 1 ? 'border-brand-200 bg-brand-50/70' : 'border-default bg-surface-soft/70'"
|
||||
@click="workspace.stage = item.key as any"
|
||||
>
|
||||
<div class="flex items-center gap-2">
|
||||
<div
|
||||
class="flex h-8 w-8 shrink-0 items-center justify-center rounded-lg"
|
||||
:class="stageStep >= index + 1 ? 'bg-brand-600 text-white' : 'bg-white text-muted'"
|
||||
>
|
||||
<component :is="item.icon" class="h-4 w-4" />
|
||||
</div>
|
||||
<div class="min-w-0">
|
||||
<div class="text-[11px] font-semibold uppercase tracking-[0.16em] text-muted">
|
||||
{{ String(index + 1).padStart(2, '0') }}
|
||||
</div>
|
||||
<div class="whitespace-normal text-sm font-medium leading-5 text-primary">{{ $t(item.label) }}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="workspace.stage === 'video'" class="rounded-2xl border border-default bg-white p-4 shadow-sm">
|
||||
<div class="flex flex-col gap-3 md:flex-row md:items-center md:justify-between">
|
||||
<div>
|
||||
<h3 class="text-base font-semibold text-primary md:text-lg">{{ $t('chat.training.video.title') }}</h3>
|
||||
<p class="mt-1 text-sm leading-6 text-secondary">{{ $t('chat.training.video.description') }}</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="mt-3 relative group cursor-pointer overflow-hidden rounded-2xl border border-default bg-slate-900 shadow-lg aspect-video flex items-center justify-center" @click="showVideoModal = true">
|
||||
<img src="https://coresg-normal.trae.ai/api/ide/v1/text_to_image?prompt=Professional%20corporate%20training%20video%20cover%2C%20high-quality%2C%20modern%20office%20background%2C%20play%20button%20overlay&image_size=landscape_16_9" class="absolute inset-0 w-full h-full object-cover opacity-60 group-hover:scale-105 transition-transform duration-500" />
|
||||
<div class="relative z-10 flex flex-col items-center gap-3">
|
||||
<div class="h-16 w-16 flex items-center justify-center rounded-full bg-white/20 backdrop-blur-md border border-white/30 group-hover:bg-brand-600 group-hover:border-brand-500 transition-all duration-300">
|
||||
<PlayCircle class="h-8 w-8 text-white fill-white/20" />
|
||||
</div>
|
||||
<span class="text-white font-medium drop-shadow-md">{{ $t('chat.training.video.playerTitle') }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-else-if="workspace.stage === 'summary'" class="rounded-2xl border border-default bg-white p-4 shadow-sm">
|
||||
<div class="flex flex-col gap-3 md:flex-row md:items-start md:justify-between">
|
||||
<div>
|
||||
<h3 class="text-base font-semibold text-primary md:text-lg">{{ $t('chat.training.summary.title') }}</h3>
|
||||
<p class="mt-1 text-sm leading-6 text-secondary">{{ $t('chat.training.summary.description') }}</p>
|
||||
</div>
|
||||
<button
|
||||
type="button"
|
||||
class="inline-flex items-center justify-center gap-2 rounded-xl bg-brand-600 px-4 py-2.5 text-sm font-medium text-white transition hover:bg-brand-700"
|
||||
@click="workspace.startExam"
|
||||
>
|
||||
<Target class="h-4 w-4" />
|
||||
{{ $t('chat.training.summary.startExam') }}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="mt-3 grid gap-3 md:grid-cols-2">
|
||||
<div class="rounded-2xl border border-brand-100 bg-brand-50/50 p-3.5">
|
||||
<div class="text-sm font-semibold text-primary">{{ $t('chat.training.summary.keyPoints') }}</div>
|
||||
<ul class="mt-2.5 space-y-1.5 text-sm leading-6 text-secondary">
|
||||
<li v-for="point in workspace.summaryPoints" :key="point" class="flex gap-2">
|
||||
<span class="mt-1.5 h-1.5 w-1.5 rounded-full bg-brand-500" />
|
||||
<span>{{ point }}</span>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="rounded-2xl border border-default bg-surface-soft p-3.5">
|
||||
<div class="text-sm font-semibold text-primary">{{ $t('chat.training.summary.mustKnow') }}</div>
|
||||
<ul class="mt-2.5 space-y-1.5 text-sm leading-6 text-secondary">
|
||||
<li v-for="point in workspace.summaryChecklist" :key="point" class="flex gap-2">
|
||||
<CheckCircle2 class="mt-1 h-4 w-4 shrink-0 text-emerald-500" />
|
||||
<span>{{ point }}</span>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-else-if="workspace.stage === 'exam' && workspace.currentQuestion" class="rounded-2xl border border-default bg-white p-4 shadow-sm">
|
||||
<div class="flex flex-col gap-3 md:flex-row md:items-center md:justify-between">
|
||||
<div>
|
||||
<div class="text-xs font-semibold uppercase tracking-[0.18em] text-brand-600">
|
||||
{{ $t('chat.training.exam.title') }}
|
||||
</div>
|
||||
<h3 class="mt-1 text-lg font-semibold text-primary">
|
||||
{{ $t('chat.training.exam.questionCounter', { current: workspace.answeredCount + 1, total: workspace.totalQuestionCount }) }}
|
||||
</h3>
|
||||
</div>
|
||||
<div class="flex flex-wrap gap-2 text-sm text-secondary">
|
||||
<div class="rounded-xl bg-surface-soft px-3 py-1.5">
|
||||
{{ $t('chat.training.exam.currentScore', { score: workspace.score }) }}
|
||||
</div>
|
||||
<div class="rounded-xl bg-surface-soft px-3 py-1.5">
|
||||
{{ $t('chat.training.exam.passLine') }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mt-4 rounded-2xl border border-brand-100 bg-brand-50/40 p-3.5">
|
||||
<div class="text-base font-semibold leading-7 text-primary">
|
||||
{{ workspace.currentQuestion.prompt }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mt-3 grid gap-2.5">
|
||||
<button
|
||||
v-for="option in workspace.currentQuestion.options"
|
||||
:key="option.id"
|
||||
type="button"
|
||||
class="rounded-2xl border px-4 py-2.5 text-left text-sm transition"
|
||||
:class="[
|
||||
workspace.selectedOptionId === option.id
|
||||
? workspace.answerLocked
|
||||
? option.id === workspace.currentQuestion.answer
|
||||
? 'border-emerald-300 bg-emerald-50 text-emerald-700'
|
||||
: 'border-red-300 bg-red-50 text-red-700'
|
||||
: 'border-brand-300 bg-brand-50 text-brand-700'
|
||||
: workspace.answerLocked && option.id === workspace.currentQuestion.answer
|
||||
? 'border-emerald-300 bg-emerald-50 text-emerald-700'
|
||||
: 'border-default bg-white text-secondary hover:border-brand-200 hover:bg-brand-50/40',
|
||||
]"
|
||||
:disabled="workspace.answerLocked"
|
||||
@click="workspace.selectAnswer(option.id)"
|
||||
>
|
||||
<div class="flex items-start justify-between gap-3">
|
||||
<span>{{ option.label }}</span>
|
||||
<CheckCircle2
|
||||
v-if="workspace.answerLocked && option.id === workspace.currentQuestion.answer"
|
||||
class="mt-0.5 h-4 w-4 shrink-0 text-emerald-500"
|
||||
/>
|
||||
</div>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div
|
||||
v-if="workspace.answerLocked"
|
||||
class="mt-4 rounded-2xl border p-3.5"
|
||||
:class="workspace.currentFeedbackCorrect ? 'border-emerald-200 bg-emerald-50/70' : 'border-red-200 bg-red-50/70'"
|
||||
>
|
||||
<div class="flex items-center gap-2 text-sm font-semibold" :class="workspace.currentFeedbackCorrect ? 'text-emerald-700' : 'text-red-700'">
|
||||
<CheckCircle2 v-if="workspace.currentFeedbackCorrect" class="h-4 w-4" />
|
||||
<XCircle v-else class="h-4 w-4" />
|
||||
{{ workspace.currentFeedbackCorrect ? $t('chat.training.exam.correctFeedback') : $t('chat.training.exam.wrongFeedback') }}
|
||||
</div>
|
||||
<div class="mt-2 text-sm leading-6 text-secondary">
|
||||
{{ $t('chat.training.exam.selectedAnswer', { answer: currentAnswerLabel || '--' }) }}
|
||||
</div>
|
||||
<div class="mt-1 text-sm leading-6 text-secondary">
|
||||
{{ $t('chat.training.exam.correctAnswer', { answer: workspace.currentQuestion.options?.find((item) => item.id === workspace.currentQuestion?.answer)?.label || '--' }) }}
|
||||
</div>
|
||||
<div class="mt-2 text-sm leading-6 text-secondary">
|
||||
{{ workspace.currentQuestion.explanation }}
|
||||
</div>
|
||||
<div class="mt-3">
|
||||
<button
|
||||
type="button"
|
||||
class="inline-flex items-center gap-2 rounded-xl bg-brand-600 px-4 py-2.5 text-sm font-medium text-white transition hover:bg-brand-700"
|
||||
@click="workspace.moveToNextQuestion"
|
||||
>
|
||||
<ClipboardCheck class="h-4 w-4" />
|
||||
{{
|
||||
workspace.answeredCount >= workspace.totalQuestionCount
|
||||
? $t('chat.training.exam.finishExam')
|
||||
: $t('chat.training.exam.nextQuestion')
|
||||
}}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-else class="rounded-2xl border border-default bg-white p-4 shadow-sm">
|
||||
<div class="flex flex-col gap-3 md:flex-row md:items-center md:justify-between">
|
||||
<div>
|
||||
<div class="inline-flex items-center gap-2 rounded-full px-3 py-1 text-xs font-semibold"
|
||||
:class="workspace.isPassed ? 'bg-emerald-50 text-emerald-700' : 'bg-amber-50 text-amber-700'"
|
||||
>
|
||||
<ShieldCheck class="h-3.5 w-3.5" />
|
||||
{{ workspace.isPassed ? $t('chat.training.result.passedTag') : $t('chat.training.result.failedTag') }}
|
||||
</div>
|
||||
<h3 class="mt-2.5 text-lg font-semibold text-primary md:text-xl">
|
||||
{{ workspace.isPassed ? $t('chat.training.result.passTitle') : $t('chat.training.result.failTitle') }}
|
||||
</h3>
|
||||
<p class="mt-2 text-sm leading-6 text-secondary">
|
||||
{{ workspace.isPassed ? $t('chat.training.result.passDescription') : $t('chat.training.result.failDescription') }}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="grid grid-cols-2 gap-2 text-center">
|
||||
<div class="rounded-2xl bg-surface-soft px-4 py-2.5">
|
||||
<div class="text-xs text-muted">{{ $t('chat.training.result.scoreLabel') }}</div>
|
||||
<div class="text-xl font-semibold text-primary">{{ workspace.score }}</div>
|
||||
</div>
|
||||
<div class="rounded-2xl bg-surface-soft px-4 py-2.5">
|
||||
<div class="text-xs text-muted">{{ $t('chat.training.result.attemptsLabel') }}</div>
|
||||
<div class="text-xl font-semibold text-primary">{{ workspace.attemptCount }}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mt-3 grid gap-2.5 md:grid-cols-3">
|
||||
<div class="rounded-2xl border border-default bg-surface-soft p-3.5">
|
||||
<div class="text-xs text-muted">{{ $t('chat.training.result.correctCount') }}</div>
|
||||
<div class="mt-1 text-lg font-semibold text-primary">{{ workspace.correctCount }}</div>
|
||||
</div>
|
||||
<div class="rounded-2xl border border-default bg-surface-soft p-3.5">
|
||||
<div class="text-xs text-muted">{{ $t('chat.training.result.wrongCount') }}</div>
|
||||
<div class="mt-1 text-lg font-semibold text-primary">{{ workspace.wrongCount }}</div>
|
||||
</div>
|
||||
<div class="rounded-2xl border border-default bg-surface-soft p-3.5">
|
||||
<div class="text-xs text-muted">{{ $t('chat.training.result.completionDate') }}</div>
|
||||
<div class="mt-1 text-lg font-semibold text-primary">{{ workspace.completionDate || '--' }}</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mt-4 flex flex-wrap gap-2.5">
|
||||
<button
|
||||
v-if="!workspace.isPassed"
|
||||
type="button"
|
||||
class="inline-flex items-center gap-2 rounded-xl bg-brand-600 px-4 py-2.5 text-sm font-medium text-white transition hover:bg-brand-700"
|
||||
@click="workspace.restartExam"
|
||||
>
|
||||
<RefreshCcw class="h-4 w-4" />
|
||||
{{ $t('chat.training.result.retryExam') }}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="inline-flex items-center gap-2 rounded-xl border border-default bg-white px-4 py-2.5 text-sm font-medium text-secondary transition hover:bg-surface-soft"
|
||||
@click="sendPrompt(workspace.learnerChatPrompt)"
|
||||
>
|
||||
<Send class="h-4 w-4" />
|
||||
{{ $t('chat.training.result.sendToChat') }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="min-w-0 md:sticky md:top-4 md:self-start">
|
||||
<div class="rounded-2xl border border-default bg-white p-3 shadow-sm">
|
||||
<div class="flex items-center gap-2">
|
||||
<Users class="h-4 w-4 text-brand-600" />
|
||||
<div class="text-sm font-semibold text-primary">{{ $t('chat.training.learnerCard.title') }}</div>
|
||||
</div>
|
||||
<div class="mt-2.5 grid gap-1.5 text-sm text-secondary">
|
||||
<div class="flex items-center justify-between rounded-xl bg-surface-soft px-3 py-2">
|
||||
<span>{{ $t('chat.training.learnerCard.name') }}</span>
|
||||
<span class="font-medium text-primary">{{ workspace.currentUserName }}</span>
|
||||
</div>
|
||||
<div class="flex items-center justify-between rounded-xl bg-surface-soft px-3 py-2">
|
||||
<span>{{ $t('chat.training.learnerCard.employeeId') }}</span>
|
||||
<span class="font-medium text-primary">{{ workspace.currentUserEmployeeId }}</span>
|
||||
</div>
|
||||
<div class="flex items-center justify-between rounded-xl bg-surface-soft px-3 py-2">
|
||||
<span>{{ $t('chat.training.learnerCard.department') }}</span>
|
||||
<span class="font-medium text-primary">{{ workspace.currentUserDepartment }}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="my-3 h-px bg-slate-100" />
|
||||
|
||||
<div class="text-sm font-semibold text-primary">{{ $t('chat.training.rules.title') }}</div>
|
||||
<ul class="mt-2 grid gap-1 text-xs leading-5 text-secondary">
|
||||
<li class="flex gap-2">
|
||||
<CheckCircle2 class="mt-0.5 h-3.5 w-3.5 shrink-0 text-emerald-500" />
|
||||
<span>{{ $t('chat.training.rules.rule1') }}</span>
|
||||
</li>
|
||||
<li class="flex gap-2">
|
||||
<CheckCircle2 class="mt-0.5 h-3.5 w-3.5 shrink-0 text-emerald-500" />
|
||||
<span>{{ $t('chat.training.rules.rule2') }}</span>
|
||||
</li>
|
||||
<li class="flex gap-2">
|
||||
<CheckCircle2 class="mt-0.5 h-3.5 w-3.5 shrink-0 text-emerald-500" />
|
||||
<span>{{ $t('chat.training.rules.rule3') }}</span>
|
||||
</li>
|
||||
<li class="flex gap-2">
|
||||
<CheckCircle2 class="mt-0.5 h-3.5 w-3.5 shrink-0 text-emerald-500" />
|
||||
<span>{{ $t('chat.training.rules.rule4') }}</span>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-else-if="!isCompactMode" class="space-y-4 p-4 md:p-5">
|
||||
<div class="grid gap-3 sm:grid-cols-2 xl:grid-cols-5">
|
||||
<div class="rounded-2xl border border-default bg-white p-3.5 shadow-sm">
|
||||
<div class="text-xs text-muted">{{ $t('chat.training.hr.stats.total') }}</div>
|
||||
<div class="mt-1.5 text-xl font-semibold text-primary">{{ workspace.stats.total }}</div>
|
||||
</div>
|
||||
<div class="rounded-2xl border border-default bg-white p-3.5 shadow-sm">
|
||||
<div class="text-xs text-muted">{{ $t('chat.training.hr.stats.passed') }}</div>
|
||||
<div class="mt-1.5 text-xl font-semibold text-emerald-600">{{ workspace.stats.passed }}</div>
|
||||
</div>
|
||||
<div class="rounded-2xl border border-default bg-white p-3.5 shadow-sm">
|
||||
<div class="text-xs text-muted">{{ $t('chat.training.hr.stats.failed') }}</div>
|
||||
<div class="mt-1.5 text-xl font-semibold text-amber-600">{{ workspace.stats.failed }}</div>
|
||||
</div>
|
||||
<div class="rounded-2xl border border-default bg-white p-3.5 shadow-sm">
|
||||
<div class="text-xs text-muted">{{ $t('chat.training.hr.stats.inProgress') }}</div>
|
||||
<div class="mt-1.5 text-xl font-semibold text-blue-600">{{ workspace.stats.inProgress }}</div>
|
||||
</div>
|
||||
<div class="rounded-2xl border border-default bg-white p-3.5 shadow-sm">
|
||||
<div class="text-xs text-muted">{{ $t('chat.training.hr.stats.passRate') }}</div>
|
||||
<div class="mt-1.5 text-xl font-semibold text-primary">{{ workspace.stats.passRate }}%</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="rounded-2xl border border-default bg-white p-4 shadow-sm">
|
||||
<div class="flex flex-col gap-3">
|
||||
<div class="grid gap-3 xl:grid-cols-3">
|
||||
<label class="space-y-1.5">
|
||||
<span class="text-xs font-semibold uppercase tracking-[0.14em] text-muted">{{ $t('chat.training.hr.filters.keywordLabel') }}</span>
|
||||
<input
|
||||
v-model="workspace.hrKeyword"
|
||||
type="text"
|
||||
class="w-full rounded-xl border border-default bg-surface px-3 py-2.5 text-sm text-primary outline-none transition focus:border-brand-300"
|
||||
:placeholder="$t('chat.training.hr.filters.keywordPlaceholder')"
|
||||
/>
|
||||
</label>
|
||||
<label class="space-y-1.5">
|
||||
<span class="text-xs font-semibold uppercase tracking-[0.14em] text-muted">{{ $t('chat.training.hr.filters.statusLabel') }}</span>
|
||||
<select
|
||||
v-model="workspace.hrStatusFilter"
|
||||
class="w-full rounded-xl border border-default bg-surface px-3 py-2.5 text-sm text-primary outline-none transition focus:border-brand-300"
|
||||
>
|
||||
<option value="all">{{ $t('chat.training.hr.filters.allStatuses') }}</option>
|
||||
<option value="passed">{{ $t('chat.training.hr.status.passed') }}</option>
|
||||
<option value="failed">{{ $t('chat.training.hr.status.failed') }}</option>
|
||||
<option value="in_progress">{{ $t('chat.training.hr.status.in_progress') }}</option>
|
||||
</select>
|
||||
</label>
|
||||
<label class="space-y-1.5">
|
||||
<span class="text-xs font-semibold uppercase tracking-[0.14em] text-muted">{{ $t('chat.training.hr.filters.departmentLabel') }}</span>
|
||||
<select
|
||||
v-model="workspace.hrDepartmentFilter"
|
||||
class="w-full rounded-xl border border-default bg-surface px-3 py-2.5 text-sm text-primary outline-none transition focus:border-brand-300"
|
||||
>
|
||||
<option value="all">{{ $t('chat.training.hr.filters.allDepartments') }}</option>
|
||||
<option v-for="department in workspace.departmentOptions" :key="department" :value="department">
|
||||
{{ department }}
|
||||
</option>
|
||||
</select>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="flex flex-wrap items-center justify-end gap-2">
|
||||
<button
|
||||
type="button"
|
||||
class="inline-flex h-10 items-center gap-2 rounded-xl border border-default bg-white px-4 text-xs font-medium text-secondary transition hover:bg-surface-soft sm:text-sm"
|
||||
@click="sendPrompt(workspace.managementChatPrompt)"
|
||||
>
|
||||
<Send class="h-4 w-4" />
|
||||
{{ $t('chat.training.hr.actions.askAgent') }}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="inline-flex h-10 items-center gap-2 rounded-xl bg-brand-600 px-4 text-xs font-medium text-white transition hover:bg-brand-700 sm:text-sm"
|
||||
@click="workspace.exportRecords"
|
||||
>
|
||||
<Download class="h-4 w-4" />
|
||||
{{ $t('chat.training.hr.actions.export') }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mt-4 overflow-x-auto rounded-2xl border border-default">
|
||||
<table class="min-w-full border-collapse text-sm">
|
||||
<thead class="bg-surface-soft">
|
||||
<tr>
|
||||
<th class="border-b border-default px-3 py-2.5 text-left font-semibold text-primary">{{ $t('chat.training.hr.columns.joinDate') }}</th>
|
||||
<th class="border-b border-default px-3 py-2.5 text-left font-semibold text-primary">{{ $t('chat.training.hr.columns.completionDate') }}</th>
|
||||
<th class="border-b border-default px-3 py-2.5 text-left font-semibold text-primary">{{ $t('chat.training.hr.columns.department') }}</th>
|
||||
<th class="border-b border-default px-3 py-2.5 text-left font-semibold text-primary">{{ $t('chat.training.hr.columns.name') }}</th>
|
||||
<th class="border-b border-default px-3 py-2.5 text-left font-semibold text-primary">{{ $t('chat.training.hr.columns.employeeId') }}</th>
|
||||
<th class="border-b border-default px-3 py-2.5 text-left font-semibold text-primary">{{ $t('chat.training.hr.columns.score') }}</th>
|
||||
<th class="border-b border-default px-3 py-2.5 text-left font-semibold text-primary">{{ $t('chat.training.hr.columns.attempts') }}</th>
|
||||
<th class="border-b border-default px-3 py-2.5 text-left font-semibold text-primary">{{ $t('chat.training.hr.columns.status') }}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-for="record in workspace.filteredRecords" :key="record.id" class="odd:bg-white even:bg-surface-soft/30">
|
||||
<td class="border-b border-default px-3 py-2.5 text-secondary">{{ record.joinDate }}</td>
|
||||
<td class="border-b border-default px-3 py-2.5 text-secondary">{{ record.completionDate || '--' }}</td>
|
||||
<td class="border-b border-default px-3 py-2.5 text-secondary">{{ record.department }}</td>
|
||||
<td class="border-b border-default px-3 py-2.5 font-medium text-primary">{{ record.name }}</td>
|
||||
<td class="border-b border-default px-3 py-2.5 text-secondary">{{ record.employeeId }}</td>
|
||||
<td class="border-b border-default px-3 py-2.5 text-secondary">{{ record.score ?? '--' }}</td>
|
||||
<td class="border-b border-default px-3 py-2.5 text-secondary">{{ record.attempts }}</td>
|
||||
<td class="border-b border-default px-3 py-2.5">
|
||||
<span
|
||||
class="inline-flex rounded-full px-2.5 py-1 text-xs font-semibold"
|
||||
:class="record.status === 'passed'
|
||||
? 'bg-emerald-50 text-emerald-700'
|
||||
: record.status === 'failed'
|
||||
? 'bg-amber-50 text-amber-700'
|
||||
: 'bg-blue-50 text-blue-700'"
|
||||
>
|
||||
{{ $t(`chat.training.hr.status.${record.status}`) }}
|
||||
</span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr v-if="workspace.filteredRecords.length === 0">
|
||||
<td colspan="8" class="px-4 py-6 text-center text-sm text-muted">
|
||||
{{ $t('chat.training.hr.empty') }}
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<Teleport to="body">
|
||||
<div v-if="showVideoModal" class="fixed inset-0 z-[100] flex items-center justify-center bg-slate-950/80 p-4 backdrop-blur-sm" @click.self="showVideoModal = false">
|
||||
<div class="relative w-full max-w-4xl overflow-hidden rounded-3xl bg-black shadow-2xl">
|
||||
<button @click="showVideoModal = false" class="absolute top-4 right-4 z-10 h-10 w-10 flex items-center justify-center rounded-full bg-white/10 text-white hover:bg-white/20 transition backdrop-blur-md">
|
||||
<XCircle class="h-6 w-6" />
|
||||
</button>
|
||||
<div class="aspect-video bg-black">
|
||||
<video
|
||||
controls
|
||||
autoplay
|
||||
class="h-full w-full"
|
||||
@timeupdate="handleVideoTimeUpdate"
|
||||
@seeking="handleVideoSeeking"
|
||||
@ended="handleVideoEnded"
|
||||
>
|
||||
<source :src="workspace.videoUrl" type="video/mp4">
|
||||
Your browser does not support the video tag.
|
||||
</video>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</Teleport>
|
||||
</template>
|
||||
@@ -11,6 +11,10 @@ import LeaveMessageBlock, { type LeaveMessageHandlers } from './LeaveMessageBloc
|
||||
import ShippingInventoryMappingMessage, { type ShippingMappingHandlers } from './ShippingInventoryMappingMessage.vue';
|
||||
import ShippingMatchResultCard from './ShippingMatchResultCard.vue';
|
||||
import ShippingParseReviewMessage, { type ShippingParseReviewHandlers } from './ShippingParseReviewMessage.vue';
|
||||
import TrainingExamQuestionMessage, { type TrainingHandlers } from './TrainingExamQuestionMessage.vue';
|
||||
import TrainingVideoMessage from './TrainingVideoMessage.vue';
|
||||
import TrainingSummaryMessage from './TrainingSummaryMessage.vue';
|
||||
import TrainingResultCard from './TrainingResultCard.vue';
|
||||
import type { ChatMessage, InlineDownloadFile, SourceFileLink } from '../../types/chat.types';
|
||||
import type { ShippingInventoryMappingFormPayload, ShippingMatchResultPayload } from '../../types/shipping.types';
|
||||
|
||||
@@ -57,6 +61,7 @@ const {
|
||||
handlers: ChatMessageBubbleHandlers;
|
||||
leaveHandlers: LeaveMessageHandlers;
|
||||
shippingHandlers: ShippingMappingHandlers;
|
||||
trainingHandlers: TrainingHandlers;
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
@@ -73,6 +78,35 @@ const isLeaveMessage = computed(() =>
|
||||
|| message.type === 'leave-result',
|
||||
);
|
||||
|
||||
const isTrainingExamMessage = computed(() => {
|
||||
if (message.role !== 'assistant') return false;
|
||||
// 必须是最后一条助手消息,且包含题目特征文字(确保只在当前正在进行的题目上显示交互组件)
|
||||
if (!isLastMessage.value) return false;
|
||||
const content = message.content || '';
|
||||
return content.includes('正在进行新人培训考试')
|
||||
|| (content.includes('第') && content.includes('题') && (content.includes('共') || content.includes('/')));
|
||||
});
|
||||
|
||||
const isTrainingVideoMessage = computed(() => {
|
||||
if (message.role !== 'assistant') return false;
|
||||
// 只要包含特定引导文案,就显示视频占位符,不限于最后一条消息
|
||||
const content = message.content || '';
|
||||
return content.includes('专属入职培训助手') || (content.includes('看视频') && content.includes('已看完'));
|
||||
});
|
||||
|
||||
const isTrainingSummaryMessage = computed(() => {
|
||||
if (message.role !== 'assistant') return false;
|
||||
const content = message.content || '';
|
||||
return content.includes('完成视频学习') || content.includes('复盘重点知识') || content.includes('复盘知识点') || content.includes('总结重点知识');
|
||||
});
|
||||
|
||||
const isTrainingResultMessage = computed(() => {
|
||||
if (message.role !== 'assistant') return false;
|
||||
// 只要是结果文案,就显示结算卡片,不限于最后一条消息
|
||||
const content = message.content || '';
|
||||
return content.includes('考试结束') || content.includes('顺利通过新人考核');
|
||||
});
|
||||
|
||||
const retrieverResources = computed(() => handlers.getDisplayRetrieverResources(message));
|
||||
const sourceLinks = computed(() => handlers.getSourceLinks(retrieverResources.value));
|
||||
|
||||
@@ -480,13 +514,51 @@ function handleInlineDownload(file: InlineDownloadFile): void {
|
||||
:action-button-class="handlers.shippingActionButtonClass"
|
||||
:on-action-click="(action) => handlers.onShippingActionClick(message, action)"
|
||||
/>
|
||||
<TrainingExamQuestionMessage
|
||||
v-else-if="isTrainingExamMessage && trainingHandlers.getQuestion()"
|
||||
:question="trainingHandlers.getQuestion()!"
|
||||
:current-question-index="trainingHandlers.getCurrentQuestionIndex()"
|
||||
:answered-count="trainingHandlers.getAnsweredCount()"
|
||||
:total-count="trainingHandlers.getTotalCount()"
|
||||
:score="trainingHandlers.getScore()"
|
||||
:selected-option-id="trainingHandlers.getSelectedOptionId()"
|
||||
:answer-locked="trainingHandlers.getAnswerLocked()"
|
||||
:feedback-correct="trainingHandlers.getFeedbackCorrect()"
|
||||
:answer-label="trainingHandlers.getAnswerLabel()"
|
||||
:is-thinking="isThinking"
|
||||
@select="trainingHandlers.onSelect"
|
||||
@next="trainingHandlers.onNext"
|
||||
/>
|
||||
<TrainingResultCard
|
||||
v-else-if="isTrainingResultMessage"
|
||||
:score="trainingHandlers.getScore()"
|
||||
:is-passed="trainingHandlers.getScore() >= 90"
|
||||
:correct-count="trainingHandlers.getCorrectCount()"
|
||||
:wrong-count="trainingHandlers.getWrongCount()"
|
||||
:is-thinking="isThinking"
|
||||
@restart="trainingHandlers.onRestartExam"
|
||||
/>
|
||||
|
||||
<div
|
||||
v-else-if="renderedMarkdown"
|
||||
class="chat-markdown prose prose-sm max-w-none leading-7 text-primary prose-a:text-blue-600 prose-p:my-1 prose-li:my-0.5 prose-ol:my-2 prose-ul:my-2 prose-headings:my-2 prose-hr:my-3 prose-code:rounded prose-code:bg-slate-100 prose-code:px-1 prose-code:text-blue-700 prose-pre:my-3 prose-pre:border prose-pre:border-slate-700 prose-pre:bg-slate-900 prose-pre:text-slate-100 prose-th:border prose-th:border-slate-200 prose-th:bg-slate-50 prose-th:px-3 prose-th:py-2 prose-th:text-left prose-td:border prose-td:border-slate-200 prose-td:px-3 prose-td:py-2"
|
||||
@click="handlers.onMarkdownClick"
|
||||
ref="markdownContainer"
|
||||
class="markdown-body chat-markdown min-w-0 break-words text-sm leading-relaxed"
|
||||
v-html="renderedMarkdown"
|
||||
/>
|
||||
|
||||
<TrainingVideoMessage
|
||||
v-if="isTrainingVideoMessage"
|
||||
:is-thinking="isThinking"
|
||||
@play="trainingHandlers.onPlayVideo"
|
||||
/>
|
||||
<TrainingSummaryMessage
|
||||
v-if="isTrainingSummaryMessage"
|
||||
:summary-points="trainingHandlers.getSummaryPoints()"
|
||||
:summary-checklist="trainingHandlers.getSummaryChecklist()"
|
||||
:is-thinking="isThinking"
|
||||
@start-exam="trainingHandlers.onStartExam"
|
||||
/>
|
||||
|
||||
<div v-if="actionableInlineFileEntries.length > 0" class="mt-4">
|
||||
<div class="flex flex-wrap gap-2">
|
||||
<button
|
||||
|
||||
@@ -0,0 +1,151 @@
|
||||
/**
|
||||
* features/chat/components/messages/TrainingExamQuestionMessage.vue
|
||||
* 用途:在聊天气泡中渲染交互式答题选择器,支持单选题与判断题。
|
||||
* 逻辑:由 ChatMessageBubble 内部调用;展示当前题目内容、选项,并在答题后展示即时反馈与“下一题”操作。
|
||||
*/
|
||||
<script setup lang="ts">
|
||||
import { CheckCircle2, XCircle, ClipboardCheck } from 'lucide-vue-next';
|
||||
import type { TrainingQuestion } from '@/features/chat/training/training.types';
|
||||
|
||||
export interface TrainingHandlers {
|
||||
getQuestion: () => TrainingQuestion | null;
|
||||
getCurrentQuestionIndex: () => number;
|
||||
getAnsweredCount: () => number;
|
||||
getTotalCount: () => number;
|
||||
getScore: () => number;
|
||||
getSelectedOptionId: () => string;
|
||||
getAnswerLocked: () => boolean;
|
||||
getFeedbackCorrect: () => boolean;
|
||||
getAnswerLabel: () => string;
|
||||
onSelect: (optionId: string) => void;
|
||||
onNext: () => void;
|
||||
onPlayVideo: () => void;
|
||||
onStartExam: () => void;
|
||||
onRestartExam: () => void;
|
||||
getCorrectCount: () => number;
|
||||
getWrongCount: () => number;
|
||||
getSummaryPoints: () => string[];
|
||||
getSummaryChecklist: () => string[];
|
||||
}
|
||||
|
||||
const props = defineProps<{
|
||||
question: TrainingQuestion;
|
||||
currentQuestionIndex: number;
|
||||
answeredCount: number;
|
||||
totalCount: number;
|
||||
score: number;
|
||||
selectedOptionId: string;
|
||||
answerLocked: boolean;
|
||||
feedbackCorrect: boolean;
|
||||
answerLabel: string;
|
||||
isThinking: boolean;
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
select: [optionId: string];
|
||||
next: [];
|
||||
}>();
|
||||
|
||||
const passLine = 90;
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="my-2 flex flex-col gap-4 rounded-2xl border border-brand-100 bg-white p-4 shadow-sm ring-1 ring-brand-50/50">
|
||||
<!-- 头部进度与分数 -->
|
||||
<div class="flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between">
|
||||
<div>
|
||||
<div class="text-[11px] font-bold uppercase tracking-[0.15em] text-brand-600/80">
|
||||
第三步:逐题考试
|
||||
</div>
|
||||
<h3 class="mt-1 text-lg font-bold text-slate-800">
|
||||
第 {{ currentQuestionIndex + 1 }} / {{ totalCount }} 题
|
||||
</h3>
|
||||
</div>
|
||||
<div class="flex flex-wrap gap-2 text-[13px]">
|
||||
<div class="rounded-lg bg-slate-50 px-3 py-1.5 font-medium text-slate-600 border border-slate-100 flex items-center gap-2">
|
||||
<span>当前分数:</span>
|
||||
<span class="text-slate-800 font-bold">{{ score }} 分</span>
|
||||
</div>
|
||||
<div class="rounded-lg bg-slate-50 px-3 py-1.5 font-medium text-slate-600 border border-slate-100 flex items-center gap-2">
|
||||
<span>及格线:</span>
|
||||
<span class="text-slate-800 font-bold">{{ passLine }} 分</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 题目正文 -->
|
||||
<div class="rounded-xl bg-brand-50/30 p-4 border border-brand-100/50">
|
||||
<div class="text-[15px] font-bold leading-7 text-slate-800">
|
||||
{{ question.prompt }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 选项列表 -->
|
||||
<div class="grid gap-2.5">
|
||||
<button
|
||||
v-for="option in question.options"
|
||||
:key="option.id"
|
||||
type="button"
|
||||
class="group relative flex items-center justify-between rounded-2xl border px-5 py-3.5 text-left text-[14px] transition-all duration-200"
|
||||
:class="[
|
||||
selectedOptionId === option.id
|
||||
? answerLocked
|
||||
? option.id === question.answer
|
||||
? 'border-emerald-300 bg-emerald-50 text-emerald-700 ring-4 ring-emerald-500/5'
|
||||
: 'border-red-300 bg-red-50 text-red-700 ring-4 ring-red-500/5'
|
||||
: 'border-brand-300 bg-brand-50 text-brand-700 ring-4 ring-brand-500/5'
|
||||
: answerLocked && option.id === question.answer
|
||||
? 'border-emerald-200 bg-emerald-50/50 text-emerald-600'
|
||||
: 'border-slate-200 bg-white text-slate-600 hover:border-brand-200 hover:bg-brand-50/30 hover:text-brand-700',
|
||||
]"
|
||||
:disabled="answerLocked || isThinking"
|
||||
@click="emit('select', option.id)"
|
||||
>
|
||||
<span class="font-medium">{{ option.label }}</span>
|
||||
<CheckCircle2
|
||||
v-if="answerLocked && option.id === question.answer"
|
||||
class="h-5 w-5 shrink-0 text-emerald-500"
|
||||
/>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<!-- 答题反馈 -->
|
||||
<div
|
||||
v-if="answerLocked"
|
||||
class="mt-1 animate-in fade-in slide-in-from-top-2 duration-300 rounded-2xl border p-4"
|
||||
:class="feedbackCorrect ? 'border-emerald-100 bg-emerald-50/60' : 'border-red-100 bg-red-50/60'"
|
||||
>
|
||||
<div class="flex items-center gap-2 text-sm font-bold" :class="feedbackCorrect ? 'text-emerald-700' : 'text-red-700'">
|
||||
<CheckCircle2 v-if="feedbackCorrect" class="h-4 w-4" />
|
||||
<XCircle v-else class="h-4 w-4" />
|
||||
{{ feedbackCorrect ? '回答正确,继续下一题' : '回答错误' }}
|
||||
</div>
|
||||
|
||||
<div class="mt-3 space-y-2 text-[13px] leading-6 text-slate-600">
|
||||
<div class="flex gap-2">
|
||||
<span class="font-medium text-slate-500 shrink-0">你的答案:</span>
|
||||
<span class="font-medium" :class="feedbackCorrect ? 'text-emerald-600' : 'text-red-600'">{{ answerLabel || '--' }}</span>
|
||||
</div>
|
||||
<div v-if="!feedbackCorrect" class="flex gap-2">
|
||||
<span class="font-medium text-slate-500 shrink-0">正确答案:</span>
|
||||
<span class="text-emerald-600 font-medium">{{ question.options?.find(o => o.id === question.answer)?.label || '--' }}</span>
|
||||
</div>
|
||||
<div class="mt-2 pl-2 border-l-2 border-slate-200/60 text-slate-500/90">
|
||||
{{ question.explanation }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mt-4">
|
||||
<button
|
||||
type="button"
|
||||
class="inline-flex items-center gap-2 rounded-xl bg-brand-600 px-5 py-2.5 text-[14px] font-bold text-white shadow-lg shadow-brand-500/20 transition-all hover:bg-brand-700 hover:-translate-y-0.5 active:translate-y-0 disabled:opacity-50 disabled:translate-y-0"
|
||||
:disabled="isThinking"
|
||||
@click="emit('next')"
|
||||
>
|
||||
<ClipboardCheck class="h-4 w-4" />
|
||||
{{ answeredCount >= totalCount - 1 ? '完成考试并查看结果' : '下一题' }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,88 @@
|
||||
/**
|
||||
* features/chat/components/messages/TrainingResultCard.vue
|
||||
* 用途:在聊天气泡中渲染考试结算结果。
|
||||
*/
|
||||
<script setup lang="ts">
|
||||
import { ShieldCheck, XCircle, RotateCcw, CheckCircle2 } from 'lucide-vue-next';
|
||||
|
||||
defineProps<{
|
||||
score: number;
|
||||
isPassed: boolean;
|
||||
correctCount: number;
|
||||
wrongCount: number;
|
||||
isThinking: boolean;
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
restart: [];
|
||||
}>();
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="my-2 flex flex-col gap-5 rounded-2xl border border-brand-100 bg-white p-5 shadow-sm ring-1 ring-brand-50/50">
|
||||
<!-- 状态头部 -->
|
||||
<div class="flex items-center justify-between">
|
||||
<div class="flex items-center gap-2.5">
|
||||
<div
|
||||
class="flex h-10 w-10 items-center justify-center rounded-xl"
|
||||
:class="isPassed ? 'bg-emerald-100 text-emerald-600' : 'bg-red-100 text-red-600'"
|
||||
>
|
||||
<ShieldCheck v-if="isPassed" class="h-6 w-6" />
|
||||
<XCircle v-else class="h-6 w-6" />
|
||||
</div>
|
||||
<div>
|
||||
<div class="text-[11px] font-bold uppercase tracking-[0.15em] text-slate-500">
|
||||
第四步:结算结果
|
||||
</div>
|
||||
<h3 class="text-lg font-bold text-slate-800">
|
||||
{{ isPassed ? '恭喜,你已通过考核!' : '很遗憾,考试未通过' }}
|
||||
</h3>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
class="rounded-full px-3 py-1 text-xs font-bold uppercase"
|
||||
:class="isPassed ? 'bg-emerald-50 text-emerald-700 border border-emerald-100' : 'bg-red-50 text-red-700 border border-red-100'"
|
||||
>
|
||||
{{ isPassed ? 'PASSED' : 'FAILED' }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 分数展示 -->
|
||||
<div class="grid grid-cols-3 gap-3">
|
||||
<div class="rounded-2xl bg-slate-50 p-4 border border-slate-100 text-center">
|
||||
<div class="text-[11px] font-bold text-slate-400 uppercase">{{ $t('chat.training.result.scoreLabel') }}</div>
|
||||
<div class="mt-1 text-2xl font-black text-brand-600">{{ score }}</div>
|
||||
</div>
|
||||
<div class="rounded-2xl bg-emerald-50/50 p-4 border border-emerald-100/50 text-center">
|
||||
<div class="text-[11px] font-bold text-emerald-500 uppercase">{{ $t('chat.training.result.correctCount') }}</div>
|
||||
<div class="mt-1 text-2xl font-black text-emerald-600">{{ correctCount }}</div>
|
||||
</div>
|
||||
<div class="rounded-2xl bg-red-50/50 p-4 border border-red-100/50 text-center">
|
||||
<div class="text-[11px] font-bold text-red-400 uppercase">答错</div>
|
||||
<div class="mt-1 text-2xl font-black text-red-500">{{ wrongCount }}</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 描述语 -->
|
||||
<div class="text-sm leading-relaxed text-slate-600">
|
||||
{{ isPassed ? $t('chat.training.result.passDescription') : $t('chat.training.result.failDescription') }}
|
||||
</div>
|
||||
|
||||
<!-- 操作 -->
|
||||
<div v-if="!isPassed" class="pt-2">
|
||||
<button
|
||||
type="button"
|
||||
class="inline-flex w-full items-center justify-center gap-2 rounded-xl bg-slate-800 px-5 py-3 text-sm font-bold text-white transition-all hover:bg-slate-900 active:scale-[0.98] disabled:opacity-50"
|
||||
:disabled="isThinking"
|
||||
@click="emit('restart')"
|
||||
>
|
||||
<RotateCcw class="h-4 w-4" />
|
||||
重新考试
|
||||
</button>
|
||||
</div>
|
||||
<div v-else class="flex items-center gap-2 text-emerald-600 font-medium text-sm">
|
||||
<CheckCircle2 class="h-4 w-4" />
|
||||
成绩已同步至 HR 管理系统
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,87 @@
|
||||
/**
|
||||
* features/chat/components/messages/TrainingSummaryMessage.vue
|
||||
* 用途:在聊天气泡中渲染“知识点复盘”卡片。
|
||||
* 逻辑:展示重点知识和考前必知,并提供“开始考试”按钮。
|
||||
*/
|
||||
<script setup lang="ts">
|
||||
import { BookOpen, CheckCircle2, ClipboardCheck } from 'lucide-vue-next';
|
||||
|
||||
defineProps<{
|
||||
summaryPoints: string[];
|
||||
summaryChecklist: string[];
|
||||
isThinking: boolean;
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
startExam: [];
|
||||
}>();
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="my-2 flex flex-col gap-4 rounded-2xl border border-brand-100 bg-white p-4 shadow-sm ring-1 ring-brand-50/50">
|
||||
<!-- 头部 -->
|
||||
<div class="flex flex-col gap-1 sm:flex-row sm:items-center sm:justify-between">
|
||||
<div class="flex items-center gap-2">
|
||||
<div class="flex h-8 w-8 items-center justify-center rounded-lg bg-brand-50 text-brand-600">
|
||||
<BookOpen class="h-5 w-5" />
|
||||
</div>
|
||||
<div>
|
||||
<h3 class="text-base font-bold text-slate-800">
|
||||
{{ $t('chat.training.summary.title') }}
|
||||
</h3>
|
||||
<p class="text-[12px] text-slate-500">
|
||||
{{ $t('chat.training.summary.description') }}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<button
|
||||
type="button"
|
||||
class="mt-2 inline-flex items-center gap-2 rounded-xl bg-brand-600 px-4 py-2 text-[13px] font-bold text-white shadow-md shadow-brand-500/20 transition-all hover:bg-brand-700 sm:mt-0"
|
||||
:disabled="isThinking"
|
||||
@click="emit('startExam')"
|
||||
>
|
||||
<ClipboardCheck class="h-4 w-4" />
|
||||
{{ $t('chat.training.summary.startExam') }}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<!-- 内容网格 -->
|
||||
<div class="grid gap-4 md:grid-cols-2">
|
||||
<!-- 重点知识 -->
|
||||
<div class="rounded-xl bg-brand-50/30 p-4 border border-brand-100/50">
|
||||
<h4 class="mb-3 flex items-center gap-2 text-[14px] font-bold text-brand-700">
|
||||
<div class="h-1.5 w-1.5 rounded-full bg-brand-500"></div>
|
||||
{{ $t('chat.training.summary.keyPoints') }}
|
||||
</h4>
|
||||
<ul class="space-y-2.5">
|
||||
<li
|
||||
v-for="(point, i) in summaryPoints"
|
||||
:key="i"
|
||||
class="flex gap-2 text-[13px] leading-6 text-slate-600"
|
||||
>
|
||||
<span class="text-brand-400 font-bold">•</span>
|
||||
<span>{{ point }}</span>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<!-- 考前必知 -->
|
||||
<div class="rounded-xl bg-slate-50/50 p-4 border border-slate-100">
|
||||
<h4 class="mb-3 flex items-center gap-2 text-[14px] font-bold text-slate-700">
|
||||
<div class="h-1.5 w-1.5 rounded-full bg-slate-400"></div>
|
||||
{{ $t('chat.training.summary.mustKnow') }}
|
||||
</h4>
|
||||
<ul class="space-y-2.5">
|
||||
<li
|
||||
v-for="(item, i) in summaryChecklist"
|
||||
:key="i"
|
||||
class="flex gap-2 text-[13px] leading-6 text-slate-600"
|
||||
>
|
||||
<CheckCircle2 class="mt-1 h-3.5 w-3.5 shrink-0 text-emerald-500/80" />
|
||||
<span>{{ item }}</span>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,37 @@
|
||||
/**
|
||||
* features/chat/components/messages/TrainingVideoMessage.vue
|
||||
* 用途:在聊天气泡中渲染培训视频占位符。
|
||||
* 逻辑:点击占位符触发视频播放弹窗(复用工作区逻辑)。
|
||||
*/
|
||||
<script setup lang="ts">
|
||||
import { PlayCircle } from 'lucide-vue-next';
|
||||
|
||||
defineProps<{
|
||||
isThinking: boolean;
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
play: [];
|
||||
}>();
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="my-1.5 flex flex-col gap-3 rounded-2xl border border-brand-100 bg-white p-3 shadow-sm ring-1 ring-brand-50/30">
|
||||
<div
|
||||
class="relative group cursor-pointer overflow-hidden rounded-xl border border-default bg-slate-900 shadow-sm aspect-video flex items-center justify-center"
|
||||
:class="{ 'opacity-50 pointer-events-none': isThinking }"
|
||||
@click="emit('play')"
|
||||
>
|
||||
<img
|
||||
src="https://coresg-normal.trae.ai/api/ide/v1/text_to_image?prompt=Professional%20corporate%20training%20video%20cover%2C%20high-quality%2C%20modern%20office%20background%2C%20play%20button%20overlay&image_size=landscape_16_9"
|
||||
class="absolute inset-0 w-full h-full object-cover opacity-60 group-hover:scale-105 transition-transform duration-500"
|
||||
/>
|
||||
<div class="relative z-10 flex flex-col items-center gap-2">
|
||||
<div class="h-12 w-12 flex items-center justify-center rounded-full bg-white/20 backdrop-blur-md border border-white/30 group-hover:bg-brand-600 group-hover:border-brand-500 transition-all duration-300">
|
||||
<PlayCircle class="h-6 w-6 text-white fill-white/20" />
|
||||
</div>
|
||||
<span class="text-white text-xs font-medium drop-shadow-md">点击播放视频</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -18,6 +18,9 @@ export type AgentSuggestedQuestionItem = {
|
||||
const DEFAULT_KB = '企业知识库';
|
||||
const ERP_KB = 'ERP知识库';
|
||||
const ERP_KB_ENABLED_AGENT_NAMES = new Set(['固资管理']);
|
||||
const TRAINING_AGENT_NAME_PATTERN = /(培训|考试|入职)/;
|
||||
|
||||
const isTrainingAgentName = (name: string) => TRAINING_AGENT_NAME_PATTERN.test(name);
|
||||
|
||||
const DEFAULT_AGENT_DESCRIPTIONS: Record<string, string> = {
|
||||
人事规章: '我是你的7x24小时专属HR政策助手。无需手动检索文档,只需用日常说话的方式提问,我能从公司最新、最全的规章制度中,为你精准提取并总结答案。',
|
||||
@@ -48,6 +51,15 @@ const DEFAULT_AGENT_SUGGESTED_QUESTIONS: Record<string, { style: 'plain' | 'styl
|
||||
},
|
||||
};
|
||||
|
||||
const TRAINING_AGENT_DESCRIPTION = '我是你的新人培训助手,会在同一个聊天页面内带你完成视频学习、知识点复盘、逐题考试和结果复盘。';
|
||||
|
||||
const TRAINING_AGENT_QUESTIONS: AgentSuggestedQuestionItem[] = [
|
||||
{ question: '开始新人培训', group: '培训流程' },
|
||||
{ question: '我已看完视频,请总结知识点', group: '培训流程' },
|
||||
{ question: '开始考试', group: '培训流程' },
|
||||
{ question: '导出本月培训成绩', group: 'HR 管理' },
|
||||
];
|
||||
|
||||
const normalizeAgentSuggestedQuestions = (value: unknown): AgentSuggestedQuestionItem[] => {
|
||||
if (!Array.isArray(value)) return [];
|
||||
return value
|
||||
@@ -118,6 +130,7 @@ export function useChatAgent(options: UseChatAgentOptions) {
|
||||
|
||||
const agentDescription = computed(() => {
|
||||
const text = String(currentAgent.value?.description || '').trim();
|
||||
if (!text && isTrainingAgentName(currentAgentName.value)) return TRAINING_AGENT_DESCRIPTION;
|
||||
return text || DEFAULT_AGENT_DESCRIPTIONS[currentAgentName.value] || '';
|
||||
});
|
||||
|
||||
@@ -125,6 +138,7 @@ export function useChatAgent(options: UseChatAgentOptions) {
|
||||
const style = String(currentAgent.value?.extra_config?.suggested_questions_style || '').trim().toLowerCase();
|
||||
if (style === 'styled') return 'styled';
|
||||
if (style === 'plain') return 'plain';
|
||||
if (isTrainingAgentName(currentAgentName.value)) return 'styled';
|
||||
return DEFAULT_AGENT_SUGGESTED_QUESTIONS[currentAgentName.value]?.style || 'plain';
|
||||
});
|
||||
|
||||
@@ -133,6 +147,7 @@ export function useChatAgent(options: UseChatAgentOptions) {
|
||||
currentAgent.value?.suggested_questions ?? currentAgent.value?.extra_config?.suggested_questions,
|
||||
);
|
||||
if (configured.length > 0) return configured;
|
||||
if (isTrainingAgentName(currentAgentName.value)) return TRAINING_AGENT_QUESTIONS;
|
||||
return DEFAULT_AGENT_SUGGESTED_QUESTIONS[currentAgentName.value]?.questions || [];
|
||||
});
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* features/chat/composables/useChatPage.ts
|
||||
* 对话页主编排:组合 SSE、Agent、附件、请假/出货、路由同步与 page/* 子模块。
|
||||
*/
|
||||
import { computed, markRaw, ref, watch } from 'vue';
|
||||
import { computed, markRaw, nextTick, ref, watch } from 'vue';
|
||||
import { storeToRefs } from 'pinia';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { useRoute, useRouter } from 'vue-router';
|
||||
@@ -26,6 +26,7 @@ import { useChatSessions } from './useChatSessions';
|
||||
import { useChatShipping } from './useChatShipping';
|
||||
import { useChatSourceFiles } from './useChatSourceFiles';
|
||||
import { useChatStore } from '../stores/chat.store';
|
||||
import { useTrainingWorkspace, matchesTrainingAgent } from './useTrainingWorkspace';
|
||||
import {
|
||||
createChatPageConversationApi,
|
||||
createChatPageLocalMessageApi,
|
||||
@@ -34,6 +35,7 @@ import {
|
||||
createLeaveMessageHandlers,
|
||||
createShippingMappingHandlers,
|
||||
createShippingPickerRefHolder,
|
||||
createTrainingHandlers,
|
||||
useChatPageDialogs,
|
||||
useChatPageUser,
|
||||
useChatPageVoice,
|
||||
@@ -212,6 +214,34 @@ export function useChatPage() {
|
||||
currentAgentId,
|
||||
});
|
||||
|
||||
const pushLocalAssistantMessage = async (content: string) => {
|
||||
const msgText = String(content || '').trim();
|
||||
if (!msgText) return;
|
||||
const isFirstMessage = messages.value.length === 0;
|
||||
const isTraining = matchesTrainingAgent(agent.currentAgent.value);
|
||||
|
||||
// 如果是培训 Agent 的首条消息(欢迎语),强制重置滚动贴底状态,防止自动滚到底部
|
||||
if (isFirstMessage && isTraining) {
|
||||
scroll.isNearBottom.value = false;
|
||||
}
|
||||
|
||||
const assistantMsg: ChatMessage = {
|
||||
role: 'assistant',
|
||||
type: 'text',
|
||||
content: msgText,
|
||||
local_id: newLocalMessageId('local-assistant'),
|
||||
local_only: true,
|
||||
};
|
||||
messages.value.push(assistantMsg);
|
||||
await saveLocalMessageToBackend(assistantMsg);
|
||||
|
||||
// 再次确保滚到顶部展示欢迎语
|
||||
if (isFirstMessage && isTraining) {
|
||||
await nextTick();
|
||||
scroll.scrollToTop();
|
||||
}
|
||||
};
|
||||
|
||||
const presetQuestion = computed(() => {
|
||||
const q = route.query.preset;
|
||||
return typeof q === 'string' ? q : '';
|
||||
@@ -286,6 +316,27 @@ export function useChatPage() {
|
||||
t,
|
||||
});
|
||||
|
||||
const pushLocalUserMessage = async (content: string) => {
|
||||
const msgText = String(content || '').trim();
|
||||
if (!msgText) return;
|
||||
const userMsg: ChatMessage = {
|
||||
role: 'user',
|
||||
type: 'text',
|
||||
content: msgText,
|
||||
local_id: newLocalMessageId('local-user'),
|
||||
local_only: true,
|
||||
};
|
||||
messages.value.push(userMsg);
|
||||
await saveLocalMessageToBackend(userMsg);
|
||||
};
|
||||
|
||||
const training = useTrainingWorkspace({
|
||||
currentAgent: computed(() => agent.currentAgent.value),
|
||||
currentUser: computed(() => currentUser.value),
|
||||
pushLocalAssistantMessage,
|
||||
pushLocalUserMessage,
|
||||
});
|
||||
|
||||
const markdown = createChatPageMarkdownApi({
|
||||
messages,
|
||||
isThinking,
|
||||
@@ -361,6 +412,7 @@ export function useChatPage() {
|
||||
|
||||
const leaveMessageHandlers = createLeaveMessageHandlers(leave);
|
||||
const shippingMappingHandlers = createShippingMappingHandlers(shipping);
|
||||
const trainingHandlers = createTrainingHandlers(training);
|
||||
const shippingPickerRefHolder = markRaw(createShippingPickerRefHolder(shipping.shippingInventoryPickerRef));
|
||||
const shippingNoticePickerRefHolder = markRaw(createShippingPickerRefHolder(shipping.shippingNoticePickerRef));
|
||||
|
||||
@@ -452,9 +504,11 @@ export function useChatPage() {
|
||||
isVoiceRecording: voice.isVoiceRecording,
|
||||
isVoiceTranscribing: voice.isVoiceTranscribing,
|
||||
handleVoiceFeatureClick: voice.handleVoiceFeatureClick,
|
||||
training,
|
||||
...leave,
|
||||
leaveMessageHandlers,
|
||||
shippingMappingHandlers,
|
||||
trainingHandlers,
|
||||
shippingPickerRefHolder,
|
||||
shippingNoticePickerRefHolder,
|
||||
shouldShowThinkingBubble: markdown.shouldShowThinkingBubble,
|
||||
@@ -462,6 +516,7 @@ export function useChatPage() {
|
||||
shouldRenderMessage: markdown.shouldRenderMessage,
|
||||
canSendMessage: sendApi.canSendMessage,
|
||||
handleSend: sendApi.handleSend,
|
||||
pushLocalAssistantMessage,
|
||||
copyToClipboard: sendApi.copyToClipboard,
|
||||
regenerate: sendApi.regenerate,
|
||||
handleOpenFeedback: dialogs.handleOpenFeedback,
|
||||
|
||||
@@ -66,6 +66,17 @@ export function useChatScroll(options: UseChatScrollOptions) {
|
||||
});
|
||||
};
|
||||
|
||||
const scrollToTop = async () => {
|
||||
await nextTick();
|
||||
const el = container.value;
|
||||
if (!el) return;
|
||||
el.scrollTo({
|
||||
top: 0,
|
||||
behavior: 'auto',
|
||||
});
|
||||
isNearBottom.value = false;
|
||||
};
|
||||
|
||||
const scrollToUserQuestion = async () => {
|
||||
if (scrollToBottomFrame !== null) {
|
||||
window.cancelAnimationFrame(scrollToBottomFrame);
|
||||
@@ -139,6 +150,7 @@ export function useChatScroll(options: UseChatScrollOptions) {
|
||||
showScrollToBottom,
|
||||
scrollToBottom,
|
||||
scrollToBottomSmooth,
|
||||
scrollToTop,
|
||||
scrollToUserQuestion,
|
||||
scheduleScrollToBottom,
|
||||
setupThinkingScrollWatch,
|
||||
|
||||
@@ -0,0 +1,480 @@
|
||||
/**
|
||||
* features/chat/composables/useTrainingWorkspace.ts
|
||||
* 用途:封装新人培训 Agent 的工作区状态,包括学员考试流、进度持久化与 HR 真实统计导出。
|
||||
* 依赖:Vue reactivity、vue-i18n、training.api,以及 training.types。
|
||||
* 逻辑:仅在培训 Agent 下启用;学员端按“视频 -> 知识点 -> 一题一答 -> 结算”推进,并把进度同步到后端。
|
||||
*/
|
||||
import { computed, ref, watch, type ComputedRef } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import {
|
||||
exportTrainingRecords,
|
||||
getMyTrainingProgress,
|
||||
getTrainingStats,
|
||||
listTrainingRecords,
|
||||
saveMyTrainingProgress,
|
||||
} from '@/features/chat/api/training.api';
|
||||
import type {
|
||||
TrainingAnswerRecord,
|
||||
TrainingQuestion,
|
||||
TrainingQuestionOption,
|
||||
TrainingProgressRecord,
|
||||
TrainingRecord,
|
||||
TrainingRecordStatus,
|
||||
TrainingStage,
|
||||
TrainingStats,
|
||||
TrainingWorkspaceView,
|
||||
} from '@/features/chat/training/training.types';
|
||||
|
||||
type TrainingAgentLike = {
|
||||
name?: string | null;
|
||||
extra_config?: Record<string, unknown> | null;
|
||||
} | null | undefined;
|
||||
|
||||
type TrainingUserLike = {
|
||||
role?: string | null;
|
||||
username?: string | null;
|
||||
real_name?: string | null;
|
||||
employee_id?: string | null;
|
||||
department?: string | null;
|
||||
} | null | undefined;
|
||||
|
||||
export interface UseTrainingWorkspaceOptions {
|
||||
currentAgent: ComputedRef<TrainingAgentLike>;
|
||||
currentUser: ComputedRef<TrainingUserLike>;
|
||||
pushLocalAssistantMessage?: (content: string) => Promise<void>;
|
||||
pushLocalUserMessage?: (content: string) => Promise<void>;
|
||||
}
|
||||
|
||||
const TRAINING_AGENT_NAME_PATTERN = /(培训|考试|入职)/;
|
||||
const DEFAULT_TRAINING_VIDEO_URL = 'https://www.w3schools.com/html/mov_bbb.mp4';
|
||||
|
||||
/**
|
||||
* 判断当前 Agent 是否应启用“培训工作区”。
|
||||
* AI 触发时机:当需要把培训 UI 只挂在指定 Agent 上时使用,优先读 extra_config 显式开关,避免误伤其他聊天场景。
|
||||
*/
|
||||
export function matchesTrainingAgent(agent: TrainingAgentLike): boolean {
|
||||
const extraConfig = agent?.extra_config || {};
|
||||
const explicitFlags = [
|
||||
extraConfig.training_workspace_enabled,
|
||||
extraConfig.training_mode,
|
||||
extraConfig.training_agent,
|
||||
];
|
||||
if (explicitFlags.some((value) => value === true || value === 'true')) {
|
||||
return true;
|
||||
}
|
||||
const name = String(agent?.name || '').trim();
|
||||
return TRAINING_AGENT_NAME_PATTERN.test(name);
|
||||
}
|
||||
|
||||
const formatDate = (value: Date) => value.toISOString().slice(0, 10);
|
||||
|
||||
export function useTrainingWorkspace(options: UseTrainingWorkspaceOptions) {
|
||||
const { currentAgent, currentUser, pushLocalAssistantMessage, pushLocalUserMessage } = options;
|
||||
const { t, tm } = useI18n();
|
||||
|
||||
const isTrainingAgent = computed(() => matchesTrainingAgent(currentAgent.value));
|
||||
const isAdminViewer = computed(() => ['admin', 'hr'].includes(String(currentUser.value?.role || '')));
|
||||
const activeView = ref<TrainingWorkspaceView>('learner');
|
||||
|
||||
const stage = ref<TrainingStage>('video');
|
||||
const currentQuestionIndex = ref(0);
|
||||
const score = ref(0);
|
||||
const attemptCount = ref(0);
|
||||
const selectedOptionId = ref('');
|
||||
const answerLocked = ref(false);
|
||||
const currentFeedbackCorrect = ref(false);
|
||||
const answerRecords = ref<TrainingAnswerRecord[]>([]);
|
||||
const completionDate = ref<string | null>(null);
|
||||
const currentJoinDate = ref<string | null>(null);
|
||||
const isHydrated = ref(false);
|
||||
|
||||
const hrKeyword = ref('');
|
||||
const hrStatusFilter = ref<'all' | TrainingRecordStatus>('all');
|
||||
const hrDepartmentFilter = ref('all');
|
||||
const records = ref<TrainingRecord[]>([]);
|
||||
const departmentOptions = ref<string[]>([]);
|
||||
const stats = ref<TrainingStats>({
|
||||
total: 0,
|
||||
passed: 0,
|
||||
failed: 0,
|
||||
inProgress: 0,
|
||||
passRate: 0,
|
||||
averageScore: 0,
|
||||
});
|
||||
let persistQueue: Promise<void> = Promise.resolve();
|
||||
|
||||
watch(isTrainingAgent, (enabled) => {
|
||||
if (!enabled) {
|
||||
activeView.value = 'learner';
|
||||
isHydrated.value = false;
|
||||
}
|
||||
});
|
||||
|
||||
const summaryPoints = computed(() => {
|
||||
const raw = tm('chat.training.summaryPoints');
|
||||
return Array.isArray(raw) ? raw.map((item) => String(item)) : [];
|
||||
});
|
||||
|
||||
const summaryChecklist = computed(() => {
|
||||
const raw = tm('chat.training.summaryChecklist');
|
||||
return Array.isArray(raw) ? raw.map((item) => String(item)) : [];
|
||||
});
|
||||
|
||||
const rawQuestionBank = computed(() => {
|
||||
const raw = tm('chat.training.questionBank');
|
||||
return Array.isArray(raw) ? raw as Array<Record<string, unknown>> : [];
|
||||
});
|
||||
|
||||
const booleanOptions = computed<TrainingQuestionOption[]>(() => {
|
||||
const raw = tm('chat.training.booleanOptions');
|
||||
if (!Array.isArray(raw)) return [];
|
||||
return raw.map((item) => ({
|
||||
id: String((item as Record<string, unknown>).id || ''),
|
||||
label: String((item as Record<string, unknown>).label || ''),
|
||||
}));
|
||||
});
|
||||
|
||||
const questionBank = computed<TrainingQuestion[]>(() => rawQuestionBank.value.map((item) => {
|
||||
const type = String(item.type || 'single') as TrainingQuestion['type'];
|
||||
const rawOptions = Array.isArray(item.options) ? item.options : [];
|
||||
const options = type === 'boolean'
|
||||
? booleanOptions.value
|
||||
: rawOptions.map((option) => ({
|
||||
id: String((option as Record<string, unknown>).id || ''),
|
||||
label: String((option as Record<string, unknown>).label || ''),
|
||||
}));
|
||||
|
||||
return {
|
||||
id: String(item.id || ''),
|
||||
type,
|
||||
prompt: String(item.prompt || ''),
|
||||
answer: String(item.answer || ''),
|
||||
explanation: String(item.explanation || ''),
|
||||
options,
|
||||
};
|
||||
}));
|
||||
|
||||
const currentQuestion = computed(() => questionBank.value[currentQuestionIndex.value] || null);
|
||||
const totalQuestionCount = computed(() => questionBank.value.length);
|
||||
const answeredCount = computed(() => answerRecords.value.length);
|
||||
const correctCount = computed(() => answerRecords.value.filter((item) => item.correct).length);
|
||||
const wrongCount = computed(() => answerRecords.value.filter((item) => !item.correct).length);
|
||||
const isPassed = computed(() => score.value >= 90);
|
||||
|
||||
const learnerProgressPercent = computed(() => {
|
||||
if (stage.value === 'video') return 25;
|
||||
if (stage.value === 'summary') return 50;
|
||||
if (stage.value === 'result') return 100;
|
||||
const base = 50;
|
||||
const examProgress = totalQuestionCount.value > 0
|
||||
? Math.round((answeredCount.value / totalQuestionCount.value) * 50)
|
||||
: 0;
|
||||
return Math.min(100, base + examProgress);
|
||||
});
|
||||
|
||||
const currentUserName = computed(() => (
|
||||
String(currentUser.value?.real_name || '').trim()
|
||||
|| String(currentUser.value?.username || '').trim()
|
||||
|| t('chat.training.defaultLearnerName')
|
||||
));
|
||||
const currentUserEmployeeId = computed(() => String(currentUser.value?.employee_id || '').trim() || '--');
|
||||
const currentUserDepartment = computed(() => String(currentUser.value?.department || '').trim() || t('chat.training.unknownDepartment'));
|
||||
const filteredRecords = computed(() => records.value);
|
||||
|
||||
/**
|
||||
* 重置考试状态,为首次开考或再次补考共用。
|
||||
* AI 触发时机:当前端需要严格模拟“未通过必须重考”的培训流程时使用,确保上一轮答题状态不会污染下一轮。
|
||||
*/
|
||||
const resetExamState = () => {
|
||||
currentQuestionIndex.value = 0;
|
||||
score.value = 0;
|
||||
selectedOptionId.value = '';
|
||||
answerLocked.value = false;
|
||||
currentFeedbackCorrect.value = false;
|
||||
answerRecords.value = [];
|
||||
completionDate.value = null;
|
||||
};
|
||||
|
||||
const syncAnswerStateForCurrentQuestion = () => {
|
||||
const questionId = currentQuestion.value?.id;
|
||||
const currentAnswer = questionId
|
||||
? answerRecords.value.find((item) => item.questionId === questionId)
|
||||
: null;
|
||||
selectedOptionId.value = currentAnswer?.selectedOptionId || '';
|
||||
answerLocked.value = Boolean(currentAnswer);
|
||||
currentFeedbackCorrect.value = Boolean(currentAnswer?.correct);
|
||||
};
|
||||
|
||||
const applyProgressRecord = (record: TrainingProgressRecord | null) => {
|
||||
if (!record) {
|
||||
stage.value = 'video';
|
||||
resetExamState();
|
||||
currentJoinDate.value = null;
|
||||
return;
|
||||
}
|
||||
stage.value = record.stage;
|
||||
currentQuestionIndex.value = record.currentQuestionIndex;
|
||||
score.value = Number(record.score || 0);
|
||||
attemptCount.value = Number(record.attempts || 0);
|
||||
answerRecords.value = Array.isArray(record.answerDetails) ? record.answerDetails : [];
|
||||
completionDate.value = record.completionDate;
|
||||
currentJoinDate.value = record.joinDate || null;
|
||||
syncAnswerStateForCurrentQuestion();
|
||||
};
|
||||
|
||||
const buildProgressPayload = () => ({
|
||||
stage: stage.value,
|
||||
currentQuestionIndex: currentQuestionIndex.value,
|
||||
score: score.value,
|
||||
passed: isPassed.value,
|
||||
attemptCount: attemptCount.value,
|
||||
answerDetails: answerRecords.value,
|
||||
joinDate: currentJoinDate.value || formatDate(new Date()),
|
||||
});
|
||||
|
||||
const persistProgress = async () => {
|
||||
if (!isTrainingAgent.value) return;
|
||||
persistQueue = persistQueue.catch(() => undefined).then(async () => {
|
||||
try {
|
||||
const saved = await saveMyTrainingProgress(buildProgressPayload());
|
||||
currentJoinDate.value = saved.joinDate || currentJoinDate.value;
|
||||
completionDate.value = saved.completionDate;
|
||||
if (isAdminViewer.value) {
|
||||
void loadAdminRecords();
|
||||
}
|
||||
} catch {
|
||||
// 保持本地培训流程可继续,避免接口波动阻断考试进行。
|
||||
}
|
||||
});
|
||||
await persistQueue;
|
||||
};
|
||||
|
||||
const loadTrainingProgress = async () => {
|
||||
if (!isTrainingAgent.value) return;
|
||||
try {
|
||||
const record = await getMyTrainingProgress();
|
||||
applyProgressRecord(record);
|
||||
} catch {
|
||||
applyProgressRecord(null);
|
||||
} finally {
|
||||
isHydrated.value = true;
|
||||
}
|
||||
};
|
||||
|
||||
const loadAdminRecords = async () => {
|
||||
if (!isTrainingAgent.value || !isAdminViewer.value) return;
|
||||
try {
|
||||
const query = {
|
||||
keyword: hrKeyword.value || undefined,
|
||||
department: hrDepartmentFilter.value === 'all' ? undefined : hrDepartmentFilter.value,
|
||||
status: hrStatusFilter.value,
|
||||
};
|
||||
const [recordData, statsData] = await Promise.all([
|
||||
listTrainingRecords(query),
|
||||
getTrainingStats(query),
|
||||
]);
|
||||
records.value = recordData.items;
|
||||
departmentOptions.value = recordData.departmentOptions;
|
||||
stats.value = statsData;
|
||||
} catch {
|
||||
records.value = [];
|
||||
departmentOptions.value = [];
|
||||
stats.value = {
|
||||
total: 0,
|
||||
passed: 0,
|
||||
failed: 0,
|
||||
inProgress: 0,
|
||||
passRate: 0,
|
||||
averageScore: 0,
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
watch(currentAgent, (agent) => {
|
||||
if (!matchesTrainingAgent(agent)) {
|
||||
records.value = [];
|
||||
departmentOptions.value = [];
|
||||
stats.value = {
|
||||
total: 0,
|
||||
passed: 0,
|
||||
failed: 0,
|
||||
inProgress: 0,
|
||||
passRate: 0,
|
||||
averageScore: 0,
|
||||
};
|
||||
return;
|
||||
}
|
||||
isHydrated.value = false;
|
||||
void loadTrainingProgress();
|
||||
}, { immediate: true });
|
||||
|
||||
watch(
|
||||
[isTrainingAgent, isAdminViewer, hrKeyword, hrStatusFilter, hrDepartmentFilter],
|
||||
([enabled, canView]) => {
|
||||
if (!enabled || !canView) return;
|
||||
void loadAdminRecords();
|
||||
},
|
||||
{ immediate: true },
|
||||
);
|
||||
|
||||
const markVideoCompleted = () => {
|
||||
stage.value = 'summary';
|
||||
// 立即推入本地助手消息(复盘卡片)
|
||||
void pushLocalAssistantMessage?.(learnerChatPrompt.value);
|
||||
void persistProgress();
|
||||
};
|
||||
|
||||
const startExam = () => {
|
||||
stage.value = 'exam';
|
||||
attemptCount.value += 1;
|
||||
resetExamState();
|
||||
// 立即推入第一题的消息引导
|
||||
void pushLocalAssistantMessage?.(learnerChatPrompt.value);
|
||||
void persistProgress();
|
||||
};
|
||||
|
||||
const selectAnswer = (optionId: string) => {
|
||||
if (answerLocked.value || !currentQuestion.value) return;
|
||||
selectedOptionId.value = optionId;
|
||||
const isCorrect = optionId === currentQuestion.value.answer;
|
||||
currentFeedbackCorrect.value = isCorrect;
|
||||
if (isCorrect) {
|
||||
score.value += 5;
|
||||
}
|
||||
answerRecords.value.push({
|
||||
questionId: currentQuestion.value.id,
|
||||
selectedOptionId: optionId,
|
||||
correct: isCorrect,
|
||||
});
|
||||
answerLocked.value = true;
|
||||
|
||||
// 推入用户选择的答案到聊天流
|
||||
const label = currentQuestion.value.options?.find(o => o.id === optionId)?.label || optionId;
|
||||
void pushLocalUserMessage?.(label);
|
||||
void persistProgress();
|
||||
};
|
||||
|
||||
/**
|
||||
* 进入下一题或结束考试。
|
||||
* AI 触发时机:当用户答完一题后,前端必须只推进一题并即时结算,保证“一题一答一反馈”的 HR 规则被严格执行。
|
||||
*/
|
||||
const moveToNextQuestion = () => {
|
||||
if (!answerLocked.value) return;
|
||||
if (currentQuestionIndex.value >= totalQuestionCount.value - 1) {
|
||||
stage.value = 'result';
|
||||
completionDate.value = formatDate(new Date());
|
||||
// 推入结果消息
|
||||
void pushLocalAssistantMessage?.(learnerChatPrompt.value);
|
||||
void persistProgress();
|
||||
return;
|
||||
}
|
||||
currentQuestionIndex.value += 1;
|
||||
selectedOptionId.value = '';
|
||||
answerLocked.value = false;
|
||||
currentFeedbackCorrect.value = false;
|
||||
// 推入下一题消息
|
||||
void pushLocalAssistantMessage?.(learnerChatPrompt.value);
|
||||
void persistProgress();
|
||||
};
|
||||
|
||||
const restartExam = () => {
|
||||
stage.value = 'summary';
|
||||
resetExamState();
|
||||
// 重新推回复盘卡片
|
||||
void pushLocalAssistantMessage?.(learnerChatPrompt.value);
|
||||
void persistProgress();
|
||||
};
|
||||
|
||||
const exportRecords = async () => {
|
||||
await exportTrainingRecords({
|
||||
keyword: hrKeyword.value || undefined,
|
||||
department: hrDepartmentFilter.value === 'all' ? undefined : hrDepartmentFilter.value,
|
||||
status: hrStatusFilter.value,
|
||||
});
|
||||
};
|
||||
|
||||
const managementChatPrompt = computed(() => {
|
||||
const parts = [
|
||||
t('chat.training.chatPrompts.hrSummaryPrefix'),
|
||||
`${t('chat.training.hr.filters.keywordLabel')}: ${hrKeyword.value || t('chat.training.hr.filters.noLimit')}`,
|
||||
`${t('chat.training.hr.filters.statusLabel')}: ${hrStatusFilter.value === 'all' ? t('chat.training.hr.filters.allStatuses') : t(`chat.training.hr.status.${hrStatusFilter.value}`)}`,
|
||||
`${t('chat.training.hr.filters.departmentLabel')}: ${hrDepartmentFilter.value === 'all' ? t('chat.training.hr.filters.allDepartments') : hrDepartmentFilter.value}`,
|
||||
`${t('chat.training.hr.stats.passRate')}: ${stats.value.passRate}%`,
|
||||
];
|
||||
return parts.join(';');
|
||||
});
|
||||
|
||||
const learnerChatPrompt = computed(() => {
|
||||
// 阶段 1:破冰与视频导学
|
||||
if (stage.value === 'video') {
|
||||
return `👋 欢迎加入公司!我是你的专属入职培训助手。今天的培训分为三个步骤:看视频 ➡️ 知识点复习 ➡️ 随堂测试(90分及格)。\n\n▶️ 请先点击观看 [入职培训视频]。观看完毕后,请回复【已看完】。`;
|
||||
}
|
||||
// 阶段 2:知识点串讲
|
||||
if (stage.value === 'summary') {
|
||||
return `${t('chat.training.chatPrompts.afterVideo')}\n\n参考知识点:\n${summaryPoints.value.map((p, i) => `${i + 1}. ${p}`).join('\n')}`;
|
||||
}
|
||||
// 阶段 4:结算
|
||||
if (stage.value === 'result') {
|
||||
return isPassed.value
|
||||
? t('chat.training.chatPrompts.afterPass', { score: score.value })
|
||||
: t('chat.training.chatPrompts.afterFail', { score: score.value });
|
||||
}
|
||||
// 阶段 3:互动测试
|
||||
return t('chat.training.chatPrompts.examInProgress', {
|
||||
index: currentQuestionIndex.value + 1,
|
||||
total: totalQuestionCount.value,
|
||||
question: currentQuestion.value?.prompt || '',
|
||||
});
|
||||
});
|
||||
|
||||
const showVideoModal = ref(false);
|
||||
const videoUrl = computed(() => {
|
||||
const extraConfig = currentAgent.value?.extra_config || {};
|
||||
const customUrl = String(extraConfig.training_video_url || extraConfig.video_url || '').trim();
|
||||
return customUrl || DEFAULT_TRAINING_VIDEO_URL;
|
||||
});
|
||||
|
||||
return {
|
||||
isTrainingAgent,
|
||||
isAdminViewer,
|
||||
isHydrated,
|
||||
activeView,
|
||||
stage,
|
||||
currentQuestionIndex,
|
||||
currentQuestion,
|
||||
totalQuestionCount,
|
||||
answeredCount,
|
||||
score,
|
||||
attemptCount,
|
||||
selectedOptionId,
|
||||
answerLocked,
|
||||
currentFeedbackCorrect,
|
||||
answerRecords,
|
||||
completionDate,
|
||||
summaryPoints,
|
||||
summaryChecklist,
|
||||
learnerProgressPercent,
|
||||
correctCount,
|
||||
wrongCount,
|
||||
isPassed,
|
||||
currentUserName,
|
||||
currentUserEmployeeId,
|
||||
currentUserDepartment,
|
||||
hrKeyword,
|
||||
hrStatusFilter,
|
||||
hrDepartmentFilter,
|
||||
departmentOptions,
|
||||
filteredRecords,
|
||||
stats,
|
||||
learnerChatPrompt,
|
||||
managementChatPrompt,
|
||||
markVideoCompleted,
|
||||
startExam,
|
||||
selectAnswer,
|
||||
moveToNextQuestion,
|
||||
restartExam,
|
||||
exportRecords,
|
||||
showVideoModal,
|
||||
videoUrl,
|
||||
};
|
||||
}
|
||||
@@ -3,8 +3,10 @@
|
||||
*/
|
||||
import type { LeaveMessageHandlers } from '../components/messages/LeaveMessageBlock.vue';
|
||||
import type { ShippingMappingHandlers } from '../components/messages/ShippingInventoryMappingMessage.vue';
|
||||
import type { TrainingHandlers } from '../components/messages/TrainingExamQuestionMessage.vue';
|
||||
import type { useChatLeave } from '../composables/useChatLeave';
|
||||
import type { useChatShipping } from '../composables/useChatShipping';
|
||||
import type { useTrainingWorkspace } from '../composables/useTrainingWorkspace';
|
||||
import type { Ref } from 'vue';
|
||||
|
||||
type LeaveHandlerSource = Pick<
|
||||
@@ -41,6 +43,8 @@ type ShippingHandlerSource = Pick<
|
||||
| 'removeShippingParseReviewLine'
|
||||
>;
|
||||
|
||||
type TrainingHandlerSource = ReturnType<typeof useTrainingWorkspace>;
|
||||
|
||||
/** 请假消息块 handlers(LeaveMessageBlock) */
|
||||
export function createLeaveMessageHandlers(leave: LeaveHandlerSource): LeaveMessageHandlers {
|
||||
return {
|
||||
@@ -81,6 +85,38 @@ export function createShippingMappingHandlers(shipping: ShippingHandlerSource):
|
||||
};
|
||||
}
|
||||
|
||||
/** 培训答题块 handlers(TrainingExamQuestionMessage) */
|
||||
export function createTrainingHandlers(workspace: TrainingHandlerSource): TrainingHandlers {
|
||||
return {
|
||||
getQuestion: () => workspace.currentQuestion.value,
|
||||
getCurrentQuestionIndex: () => workspace.currentQuestionIndex.value,
|
||||
getAnsweredCount: () => workspace.answeredCount.value,
|
||||
getTotalCount: () => workspace.totalQuestionCount.value,
|
||||
getScore: () => workspace.score.value,
|
||||
getSelectedOptionId: () => workspace.selectedOptionId.value,
|
||||
getAnswerLocked: () => workspace.answerLocked.value,
|
||||
getFeedbackCorrect: () => workspace.currentFeedbackCorrect.value,
|
||||
getAnswerLabel: () => {
|
||||
const q = workspace.currentQuestion.value;
|
||||
if (!q) return '';
|
||||
return q.options?.find((o) => o.id === workspace.selectedOptionId.value)?.label || '';
|
||||
},
|
||||
onSelect: workspace.selectAnswer,
|
||||
onNext: workspace.moveToNextQuestion,
|
||||
onPlayVideo: () => {
|
||||
// 通过 DOM 事件或状态传递触发视频播放,这里我们直接让 workspace 标记视频模态框展示
|
||||
// 注意:这里需要确保 TrainingWorkspacePanel 监听了对应的状态
|
||||
workspace.showVideoModal.value = true;
|
||||
},
|
||||
onStartExam: workspace.startExam,
|
||||
onRestartExam: workspace.restartExam,
|
||||
getCorrectCount: () => workspace.correctCount.value,
|
||||
getWrongCount: () => workspace.wrongCount.value,
|
||||
getSummaryPoints: () => workspace.summaryPoints.value,
|
||||
getSummaryChecklist: () => workspace.summaryChecklist.value,
|
||||
};
|
||||
}
|
||||
|
||||
/** 隐藏 file input ref 包裹,避免 template 自动解包 Ref */
|
||||
export function createShippingPickerRefHolder(pickerRef: Ref<HTMLInputElement | null>) {
|
||||
return { pickerRef };
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
/**
|
||||
* features/chat/training/training.types.ts
|
||||
* 用途:定义入职培训聊天工作区的题库、考试进度、HR 统计记录等共享类型。
|
||||
* 依赖:被 useTrainingWorkspace 与 TrainingWorkspacePanel 共同引用。
|
||||
* 逻辑:统一约束“学员考试流”和“HR 管理流”的前端数据结构,避免组件内散落匿名对象。
|
||||
*/
|
||||
|
||||
export type TrainingStage = 'video' | 'summary' | 'exam' | 'result';
|
||||
|
||||
export type TrainingWorkspaceView = 'learner' | 'admin';
|
||||
|
||||
export type TrainingQuestionType = 'single' | 'boolean';
|
||||
|
||||
export interface TrainingQuestionOption {
|
||||
id: string;
|
||||
label: string;
|
||||
}
|
||||
|
||||
export interface TrainingQuestion {
|
||||
id: string;
|
||||
type: TrainingQuestionType;
|
||||
prompt: string;
|
||||
answer: string;
|
||||
explanation: string;
|
||||
options?: TrainingQuestionOption[];
|
||||
}
|
||||
|
||||
export interface TrainingAnswerRecord {
|
||||
questionId: string;
|
||||
selectedOptionId: string;
|
||||
correct: boolean;
|
||||
}
|
||||
|
||||
export type TrainingRecordStatus = 'passed' | 'failed' | 'in_progress';
|
||||
|
||||
export interface TrainingRecord {
|
||||
id: string | number;
|
||||
name: string;
|
||||
employeeId: string;
|
||||
department: string;
|
||||
joinDate: string;
|
||||
completionDate: string | null;
|
||||
score: number | null;
|
||||
attempts: number;
|
||||
status: TrainingRecordStatus;
|
||||
}
|
||||
|
||||
export interface TrainingProgressRecord extends TrainingRecord {
|
||||
stage: TrainingStage;
|
||||
currentQuestionIndex: number;
|
||||
passed: boolean;
|
||||
answerDetails: TrainingAnswerRecord[];
|
||||
startedAt: string | null;
|
||||
completionTime: string | null;
|
||||
updatedAt: string | null;
|
||||
}
|
||||
|
||||
export interface TrainingStats {
|
||||
total: number;
|
||||
passed: number;
|
||||
failed: number;
|
||||
inProgress: number;
|
||||
passRate: number;
|
||||
averageScore: number;
|
||||
}
|
||||
@@ -468,5 +468,249 @@
|
||||
"range": "Showing {start}-{end} of {total}",
|
||||
"empty": "No matching data"
|
||||
}
|
||||
},
|
||||
"training": {
|
||||
"badge": "Onboarding Training Workspace",
|
||||
"title": "Onboarding Training Agent",
|
||||
"subtitle": "Complete video learning, knowledge review, one-question-at-a-time testing, and HR reporting in the same chat page.",
|
||||
"tabs": {
|
||||
"learner": "Learner",
|
||||
"admin": "HR Admin"
|
||||
},
|
||||
"actions": {
|
||||
"syncLearnerToChat": "Sync learner context to chat",
|
||||
"syncHrToChat": "Sync HR filters to chat",
|
||||
"expandWorkspace": "Expand workspace",
|
||||
"collapseWorkspace": "Collapse workspace"
|
||||
},
|
||||
"steps": {
|
||||
"video": "Watch Video",
|
||||
"summary": "Review Key Points",
|
||||
"exam": "Take Exam",
|
||||
"result": "View Result"
|
||||
},
|
||||
"progressLabel": "Training Progress",
|
||||
"progressHint": "The employee is considered complete only after finishing the video, summary review, and exam steps.",
|
||||
"progressPercent": "Completion",
|
||||
"stepNo": "Step {value}",
|
||||
"defaultLearnerName": "Current learner",
|
||||
"unknownDepartment": "Department pending",
|
||||
"video": {
|
||||
"title": "Step 1: Watch the training video",
|
||||
"description": "Employees first complete the onboarding video, then move on to the knowledge review and exam.",
|
||||
"completeAction": "I finished watching the video",
|
||||
"playerTitle": "Video player slot",
|
||||
"playerHint": "This area can later connect to an enterprise video URL or internal player. The frontend container and completion action are already prepared."
|
||||
},
|
||||
"summary": {
|
||||
"title": "Step 2: Review the key points",
|
||||
"description": "Based on the HR exam paper, the system summarizes the most important points before the employee starts the test.",
|
||||
"startExam": "Start Exam",
|
||||
"keyPoints": "Key points",
|
||||
"mustKnow": "Must know before the exam"
|
||||
},
|
||||
"exam": {
|
||||
"title": "Step 3: One-question-at-a-time exam",
|
||||
"questionCounter": "Question {current} / {total}",
|
||||
"currentScore": "Current score: {score}",
|
||||
"passLine": "Pass line: 90 points",
|
||||
"correctFeedback": "Correct. Move on to the next question.",
|
||||
"wrongFeedback": "Incorrect. The correct answer is now shown.",
|
||||
"selectedAnswer": "Your answer: {answer}",
|
||||
"correctAnswer": "Correct answer: {answer}",
|
||||
"nextQuestion": "Next Question",
|
||||
"finishExam": "Finish Exam"
|
||||
},
|
||||
"result": {
|
||||
"passedTag": "Passed",
|
||||
"failedTag": "Retake required",
|
||||
"passTitle": "Congratulations, you passed the onboarding exam",
|
||||
"failTitle": "This attempt did not meet the requirement",
|
||||
"passDescription": "The frontend pass-state interaction is complete. Once the backend is connected, it can write training records and the completion date.",
|
||||
"failDescription": "According to HR rules, any score below 90 requires a full retake until the learner passes.",
|
||||
"scoreLabel": "Final score",
|
||||
"attemptsLabel": "Attempts",
|
||||
"correctCount": "Correct answers",
|
||||
"wrongCount": "Wrong answers",
|
||||
"completionDate": "Completion date",
|
||||
"retryExam": "Retake Exam",
|
||||
"sendToChat": "Send review to chat"
|
||||
},
|
||||
"learnerCard": {
|
||||
"title": "Current learner",
|
||||
"name": "Name",
|
||||
"employeeId": "Employee ID",
|
||||
"department": "Department"
|
||||
},
|
||||
"rules": {
|
||||
"title": "Exam rules",
|
||||
"rule1": "There are 20 questions, 5 points each, with a full score of 100.",
|
||||
"rule2": "The system enforces one question, one answer, one feedback. Wrong answers show the correct answer immediately.",
|
||||
"rule3": "Any score below 90 is treated as failed and requires a retake.",
|
||||
"rule4": "HR can view statistics and export Excel from the same chat page."
|
||||
},
|
||||
"hr": {
|
||||
"stats": {
|
||||
"total": "Participants",
|
||||
"passed": "Passed",
|
||||
"failed": "Failed",
|
||||
"inProgress": "In progress",
|
||||
"passRate": "Pass rate"
|
||||
},
|
||||
"filters": {
|
||||
"keywordLabel": "Name / ID",
|
||||
"keywordPlaceholder": "Filter by name or employee ID",
|
||||
"statusLabel": "Status",
|
||||
"departmentLabel": "Department",
|
||||
"allStatuses": "All statuses",
|
||||
"allDepartments": "All departments",
|
||||
"noLimit": "No limit"
|
||||
},
|
||||
"columns": {
|
||||
"joinDate": "Join date",
|
||||
"completionDate": "Completion date",
|
||||
"department": "Department",
|
||||
"name": "Name",
|
||||
"employeeId": "Employee ID",
|
||||
"score": "Score",
|
||||
"attempts": "Attempts",
|
||||
"status": "Status"
|
||||
},
|
||||
"status": {
|
||||
"passed": "Passed",
|
||||
"failed": "Failed",
|
||||
"in_progress": "In progress"
|
||||
},
|
||||
"actions": {
|
||||
"askAgent": "Ask agent for analysis",
|
||||
"export": "Export Excel"
|
||||
},
|
||||
"empty": "No training records match the current filters."
|
||||
},
|
||||
"chatPrompts": {
|
||||
"hrSummaryPrefix": "Based on the current filters, summarize the onboarding training data and list the exceptions.",
|
||||
"afterVideo": "I finished the onboarding training video. Please summarize the key knowledge points based on the exam scope.",
|
||||
"afterSummary": "I finished reviewing the knowledge points. Please switch to exam mode and ask the first question.",
|
||||
"afterPass": "I passed the onboarding training exam with a score of {score}. Please help me generate a short completion summary.",
|
||||
"afterFail": "I scored {score} in the onboarding training exam and did not pass. Please summarize the weak points and prepare a retake reminder.",
|
||||
"examInProgress": "I am taking the onboarding training exam and am currently on question {index}/{total}. Please stay in proctor mode and continue."
|
||||
},
|
||||
"summaryPoints": [
|
||||
"Salary is paid on the 15th of each month, and attendance or leave requests must go through OA.",
|
||||
"The cafeteria uses the Zhongmi meal-ordering system, and missed punches require an OA correction process.",
|
||||
"5S stands for sort, set in order, shine, standardize, and sustain.",
|
||||
"In case of fire, call 119 immediately and use a fire extinguisher from the upwind side.",
|
||||
"QC080000 is the hazardous substance process management standard, and RoHS focuses on environmental requirements for electronic products."
|
||||
],
|
||||
"summaryChecklist": [
|
||||
"Only the current question is shown during the exam to avoid exposing the whole answer set at once.",
|
||||
"A wrong answer must immediately show the correct answer and a short explanation.",
|
||||
"Only scores of 90 or above count as passing.",
|
||||
"The admin view must be able to export join date, completion date, department, name, employee ID, and score."
|
||||
],
|
||||
"booleanOptions": [
|
||||
{ "id": "true", "label": "True" },
|
||||
{ "id": "false", "label": "False" }
|
||||
],
|
||||
"questionBank": [
|
||||
{
|
||||
"id": "q1",
|
||||
"type": "single",
|
||||
"prompt": "On which day of the month is salary paid?",
|
||||
"answer": "c",
|
||||
"explanation": "According to the onboarding exam, salary is paid on the 15th of each month.",
|
||||
"options": [
|
||||
{ "id": "a", "label": "A. 8th" },
|
||||
{ "id": "b", "label": "B. 9th" },
|
||||
{ "id": "c", "label": "C. 15th" },
|
||||
{ "id": "d", "label": "D. 27th" }
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "q2",
|
||||
"type": "single",
|
||||
"prompt": "Which system is used for cafeteria meal ordering?",
|
||||
"answer": "b",
|
||||
"explanation": "The company cafeteria uses the Zhongmi meal-ordering system, not OA or ERP.",
|
||||
"options": [
|
||||
{ "id": "a", "label": "A. OA" },
|
||||
{ "id": "b", "label": "B. Zhongmi ordering system" },
|
||||
{ "id": "c", "label": "C. ERP" }
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "q3",
|
||||
"type": "single",
|
||||
"prompt": "Which of the following are company products?",
|
||||
"answer": "abcd",
|
||||
"explanation": "All four options listed in the exam belong to the company product scope.",
|
||||
"options": [
|
||||
{ "id": "abcd", "label": "A/B/C/D All of the above" },
|
||||
{ "id": "ab", "label": "A/B" },
|
||||
{ "id": "cd", "label": "C/D" },
|
||||
{ "id": "a", "label": "A only" }
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "q4",
|
||||
"type": "single",
|
||||
"prompt": "Which OA form should be used for leave?",
|
||||
"answer": "c",
|
||||
"explanation": "Leave must use the OA leave application form.",
|
||||
"options": [
|
||||
{ "id": "a", "label": "A. Overtime request" },
|
||||
{ "id": "b", "label": "B. Contact form" },
|
||||
{ "id": "c", "label": "C. Leave application" },
|
||||
{ "id": "d", "label": "D. Employee request form" }
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "q5",
|
||||
"type": "single",
|
||||
"prompt": "What is QC080000?",
|
||||
"answer": "a",
|
||||
"explanation": "QC080000 is the hazardous substance process management certification standard.",
|
||||
"options": [
|
||||
{ "id": "a", "label": "A. Hazardous substance process management standard" },
|
||||
{ "id": "b", "label": "B. Occupational health and safety management system" },
|
||||
{ "id": "c", "label": "C. Environmental management system" }
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "q6",
|
||||
"type": "single",
|
||||
"prompt": "What does 5S refer to?",
|
||||
"answer": "a",
|
||||
"explanation": "The standard 5S terms are sort, set in order, shine, standardize, and sustain.",
|
||||
"options": [
|
||||
{ "id": "a", "label": "A. Sort, set in order, shine, standardize, sustain" },
|
||||
{ "id": "b", "label": "B. Sort, set in order, clean up, standardize, sustain" }
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "q7",
|
||||
"type": "single",
|
||||
"prompt": "Where should you stand when using a fire extinguisher?",
|
||||
"answer": "a",
|
||||
"explanation": "You should stand on the upwind side when using a fire extinguisher.",
|
||||
"options": [
|
||||
{ "id": "a", "label": "A. Upwind side" },
|
||||
{ "id": "b", "label": "B. Downwind side" }
|
||||
]
|
||||
},
|
||||
{ "id": "q8", "type": "boolean", "prompt": "Normal attendance requires clock-in, and overtime must be applied for in advance.", "answer": "true", "explanation": "Both attendance and overtime follow the company attendance policy." },
|
||||
{ "id": "q9", "type": "boolean", "prompt": "If you forget to clock in, you need an OA correction request.", "answer": "true", "explanation": "Missed punches must be corrected through the OA process." },
|
||||
{ "id": "q10", "type": "boolean", "prompt": "Monthly salary is calculated from the 21st of the previous month to the 20th of the current month.", "answer": "true", "explanation": "The exam explicitly defines this payroll calculation cycle." },
|
||||
{ "id": "q11", "type": "boolean", "prompt": "Cafeteria meals require advance booking, and face recognition can be used for dining.", "answer": "true", "explanation": "Advance booking and face-recognition dining are both supported." },
|
||||
{ "id": "q12", "type": "boolean", "prompt": "In the event of fire or explosion, you should immediately call 119.", "answer": "true", "explanation": "Calling the fire emergency number is the first step in this scenario." },
|
||||
{ "id": "q13", "type": "boolean", "prompt": "Dormitory residents must maintain fire awareness and must not install wires privately or use high-power appliances.", "answer": "true", "explanation": "This is a mandatory dormitory fire-safety rule." },
|
||||
{ "id": "q14", "type": "boolean", "prompt": "Following safety production regulations is a safety obligation of employees.", "answer": "true", "explanation": "Safety compliance is both a rule and an employee obligation." },
|
||||
{ "id": "q15", "type": "boolean", "prompt": "Employee badges may be lent to others freely.", "answer": "false", "explanation": "A badge is a personal identity credential and may not be lent out." },
|
||||
{ "id": "q16", "type": "boolean", "prompt": "RoHS mainly regulates materials and processes in electrical and electronic products to better protect human health and the environment.", "answer": "true", "explanation": "RoHS focuses on restricting hazardous substances and improving environmental protection." },
|
||||
{ "id": "q17", "type": "boolean", "prompt": "Our company's HSF policy is: green design, eco-friendly purchasing; resource conservation, green output.", "answer": "true", "explanation": "This is the HSF policy statement provided in the exam." },
|
||||
{ "id": "q18", "type": "boolean", "prompt": "EHS stands for Environment, Health, and Safety.", "answer": "true", "explanation": "EHS is the standard abbreviation for environment, health, and safety." },
|
||||
{ "id": "q19", "type": "boolean", "prompt": "External documents do not need to be controlled or managed by the organization.", "answer": "false", "explanation": "External documents also need controlled management." },
|
||||
{ "id": "q20", "type": "boolean", "prompt": "Product-related requirements should include legal and regulatory requirements as well as customer requirements.", "answer": "true", "explanation": "Product requirements must cover both regulations and customer requirements." }
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -468,5 +468,249 @@
|
||||
"range": "แสดง {start}-{end} จากทั้งหมด {total}",
|
||||
"empty": "ไม่พบข้อมูลที่ตรงเงื่อนไข"
|
||||
}
|
||||
},
|
||||
"training": {
|
||||
"badge": "พื้นที่อบรมพนักงานใหม่",
|
||||
"title": "Onboarding Training Agent",
|
||||
"subtitle": "ทำวิดีโอเรียนรู้ ทบทวนความรู้ สอบทีละข้อ และดูสถิติ HR ได้ในหน้าแชตเดียวกัน",
|
||||
"tabs": {
|
||||
"learner": "ผู้เรียน",
|
||||
"admin": "HR Admin"
|
||||
},
|
||||
"actions": {
|
||||
"syncLearnerToChat": "ส่งบริบทผู้เรียนเข้าแชต",
|
||||
"syncHrToChat": "ส่งตัวกรอง HR เข้าแชต",
|
||||
"expandWorkspace": "ขยายพื้นที่ทำงาน",
|
||||
"collapseWorkspace": "ย่อพื้นที่ทำงาน"
|
||||
},
|
||||
"steps": {
|
||||
"video": "ดูวิดีโอ",
|
||||
"summary": "ทบทวนความรู้",
|
||||
"exam": "ทำข้อสอบ",
|
||||
"result": "ผลลัพธ์"
|
||||
},
|
||||
"progressLabel": "ความคืบหน้า",
|
||||
"progressHint": "ต้องดูวิดีโอ ทบทวนความรู้ และทำข้อสอบครบ จึงจะถือว่าจบการอบรม",
|
||||
"progressPercent": "เปอร์เซ็นต์เสร็จสิ้น",
|
||||
"stepNo": "ขั้นตอน {value}",
|
||||
"defaultLearnerName": "ผู้เรียนปัจจุบัน",
|
||||
"unknownDepartment": "ยังไม่ได้ระบุแผนก",
|
||||
"video": {
|
||||
"title": "ขั้นตอน 1: ดูวิดีโออบรม",
|
||||
"description": "พนักงานใหม่ต้องดูวิดีโออบรมก่อน แล้วจึงเข้าสู่การทบทวนความรู้และการสอบ",
|
||||
"completeAction": "ฉันดูวิดีโอเสร็จแล้ว",
|
||||
"playerTitle": "ตำแหน่งตัวเล่นวิดีโอ",
|
||||
"playerHint": "ส่วนนี้สามารถเชื่อมต่อกับลิงก์วิดีโอภายในบริษัทหรือเครื่องเล่นภายในได้ในภายหลัง"
|
||||
},
|
||||
"summary": {
|
||||
"title": "ขั้นตอน 2: ทบทวนประเด็นสำคัญ",
|
||||
"description": "ระบบสรุปประเด็นที่มักออกสอบจากชุดข้อสอบของ HR เพื่อช่วยให้พนักงานทบทวนก่อนสอบ",
|
||||
"startExam": "เริ่มสอบ",
|
||||
"keyPoints": "ประเด็นสำคัญ",
|
||||
"mustKnow": "สิ่งที่ต้องรู้ก่อนสอบ"
|
||||
},
|
||||
"exam": {
|
||||
"title": "ขั้นตอน 3: สอบทีละข้อ",
|
||||
"questionCounter": "ข้อ {current} / {total}",
|
||||
"currentScore": "คะแนนปัจจุบัน: {score}",
|
||||
"passLine": "ผ่านเมื่อได้ 90 คะแนน",
|
||||
"correctFeedback": "ตอบถูก ไปข้อถัดไปได้",
|
||||
"wrongFeedback": "ตอบผิด ระบบแสดงคำตอบที่ถูกต้องแล้ว",
|
||||
"selectedAnswer": "คำตอบของคุณ: {answer}",
|
||||
"correctAnswer": "คำตอบที่ถูกต้อง: {answer}",
|
||||
"nextQuestion": "ข้อถัดไป",
|
||||
"finishExam": "จบการสอบ"
|
||||
},
|
||||
"result": {
|
||||
"passedTag": "ผ่านแล้ว",
|
||||
"failedTag": "ต้องสอบใหม่",
|
||||
"passTitle": "ยินดีด้วย คุณผ่านการสอบอบรมพนักงานใหม่แล้ว",
|
||||
"failTitle": "การสอบครั้งนี้ยังไม่ผ่านเกณฑ์",
|
||||
"passDescription": "ฝั่งหน้าเว็บรองรับสถานะผ่านแล้ว และสามารถเชื่อมต่อหลังบ้านเพื่อบันทึกผลได้ในขั้นถัดไป",
|
||||
"failDescription": "ตามกฎของ HR หากได้ต่ำกว่า 90 คะแนน ต้องสอบใหม่จนกว่าจะผ่าน",
|
||||
"scoreLabel": "คะแนนสุดท้าย",
|
||||
"attemptsLabel": "จำนวนครั้งที่สอบ",
|
||||
"correctCount": "จำนวนข้อที่ถูก",
|
||||
"wrongCount": "จำนวนข้อที่ผิด",
|
||||
"completionDate": "วันที่เสร็จสิ้น",
|
||||
"retryExam": "สอบใหม่",
|
||||
"sendToChat": "ส่งผลทบทวนเข้าแชต"
|
||||
},
|
||||
"learnerCard": {
|
||||
"title": "ผู้เรียนปัจจุบัน",
|
||||
"name": "ชื่อ",
|
||||
"employeeId": "รหัสพนักงาน",
|
||||
"department": "แผนก"
|
||||
},
|
||||
"rules": {
|
||||
"title": "กติกาการสอบ",
|
||||
"rule1": "มีทั้งหมด 20 ข้อ ข้อละ 5 คะแนน เต็ม 100 คะแนน",
|
||||
"rule2": "ระบบทำงานแบบหนึ่งข้อหนึ่งคำตอบหนึ่งฟีดแบ็ก และจะแสดงคำตอบที่ถูกเมื่อผู้ใช้ตอบผิด",
|
||||
"rule3": "หากได้ต่ำกว่า 90 คะแนน ถือว่าไม่ผ่านและต้องสอบใหม่",
|
||||
"rule4": "HR สามารถดูสถิติและส่งออก Excel ได้จากหน้าแชตเดียวกัน"
|
||||
},
|
||||
"hr": {
|
||||
"stats": {
|
||||
"total": "จำนวนผู้เข้าอบรม",
|
||||
"passed": "ผ่านแล้ว",
|
||||
"failed": "ไม่ผ่าน",
|
||||
"inProgress": "กำลังดำเนินการ",
|
||||
"passRate": "อัตราการผ่าน"
|
||||
},
|
||||
"filters": {
|
||||
"keywordLabel": "ชื่อ / รหัสพนักงาน",
|
||||
"keywordPlaceholder": "กรองตามชื่อหรือรหัสพนักงาน",
|
||||
"statusLabel": "สถานะ",
|
||||
"departmentLabel": "แผนก",
|
||||
"allStatuses": "ทุกสถานะ",
|
||||
"allDepartments": "ทุกแผนก",
|
||||
"noLimit": "ไม่จำกัด"
|
||||
},
|
||||
"columns": {
|
||||
"joinDate": "วันที่เริ่มงาน",
|
||||
"completionDate": "วันที่เสร็จสิ้น",
|
||||
"department": "แผนก",
|
||||
"name": "ชื่อ",
|
||||
"employeeId": "รหัสพนักงาน",
|
||||
"score": "คะแนน",
|
||||
"attempts": "จำนวนครั้ง",
|
||||
"status": "สถานะ"
|
||||
},
|
||||
"status": {
|
||||
"passed": "ผ่านแล้ว",
|
||||
"failed": "ไม่ผ่าน",
|
||||
"in_progress": "กำลังดำเนินการ"
|
||||
},
|
||||
"actions": {
|
||||
"askAgent": "ให้ Agent วิเคราะห์",
|
||||
"export": "ส่งออก Excel"
|
||||
},
|
||||
"empty": "ไม่พบข้อมูลการอบรมตามตัวกรองปัจจุบัน"
|
||||
},
|
||||
"chatPrompts": {
|
||||
"hrSummaryPrefix": "โปรดสรุปข้อมูลการอบรมพนักงานใหม่จากตัวกรองปัจจุบันและระบุรายชื่อที่มีความเสี่ยง",
|
||||
"afterVideo": "ฉันดูวิดีโออบรมพนักงานใหม่เสร็จแล้ว โปรดสรุปประเด็นสำคัญตามขอบเขตข้อสอบ",
|
||||
"afterSummary": "ฉันทบทวนความรู้เสร็จแล้ว โปรดเริ่มโหมดสอบและถามข้อแรก",
|
||||
"afterPass": "ฉันผ่านการสอบอบรมพนักงานใหม่ด้วยคะแนน {score} โปรดช่วยสรุปการอบรมให้สั้น ๆ",
|
||||
"afterFail": "ฉันได้คะแนน {score} ในการสอบอบรมพนักงานใหม่และยังไม่ผ่าน โปรดสรุปจุดอ่อนและเตือนให้สอบใหม่",
|
||||
"examInProgress": "ฉันกำลังสอบอบรมพนักงานใหม่ ตอนนี้อยู่ที่ข้อ {index}/{total} โปรดทำหน้าที่เป็นผู้คุมสอบและถามต่อ"
|
||||
},
|
||||
"summaryPoints": [
|
||||
"เงินเดือนจ่ายทุกวันที่ 15 ของเดือน และการลาหรือการลงเวลาต้องทำผ่าน OA",
|
||||
"โรงอาหารใช้ระบบสั่งอาหาร Zhongmi และการลืมลงเวลาต้องแก้ผ่าน OA",
|
||||
"5S ประกอบด้วยการสะสาง สะดวก สะอาด สุขลักษณะ และสร้างนิสัย",
|
||||
"เมื่อเกิดไฟไหม้ต้องโทร 119 ทันที และใช้ถังดับเพลิงจากด้านเหนือลม",
|
||||
"QC080000 คือมาตรฐานการจัดการกระบวนการสารอันตราย และ RoHS เน้นข้อกำหนดด้านสิ่งแวดล้อมของผลิตภัณฑ์อิเล็กทรอนิกส์"
|
||||
],
|
||||
"summaryChecklist": [
|
||||
"ระหว่างสอบ ระบบจะแสดงเฉพาะคำถามปัจจุบันเท่านั้น",
|
||||
"หากตอบผิด ระบบต้องแสดงคำตอบที่ถูกและคำอธิบายสั้น ๆ ทันที",
|
||||
"ต้องได้ 90 คะแนนขึ้นไปจึงจะถือว่าผ่าน",
|
||||
"ฝั่งจัดการต้องส่งออกวันที่เริ่มงาน วันที่เสร็จสิ้น แผนก ชื่อ รหัสพนักงาน และคะแนนได้"
|
||||
],
|
||||
"booleanOptions": [
|
||||
{ "id": "true", "label": "ถูก" },
|
||||
{ "id": "false", "label": "ผิด" }
|
||||
],
|
||||
"questionBank": [
|
||||
{
|
||||
"id": "q1",
|
||||
"type": "single",
|
||||
"prompt": "เงินเดือนจ่ายในวันที่เท่าไรของเดือน?",
|
||||
"answer": "c",
|
||||
"explanation": "ตามข้อสอบอบรมพนักงานใหม่ เงินเดือนจ่ายในวันที่ 15 ของทุกเดือน",
|
||||
"options": [
|
||||
{ "id": "a", "label": "A. วันที่ 8" },
|
||||
{ "id": "b", "label": "B. วันที่ 9" },
|
||||
{ "id": "c", "label": "C. วันที่ 15" },
|
||||
{ "id": "d", "label": "D. วันที่ 27" }
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "q2",
|
||||
"type": "single",
|
||||
"prompt": "ระบบที่ใช้สั่งอาหารในโรงอาหารคืออะไร?",
|
||||
"answer": "b",
|
||||
"explanation": "โรงอาหารของบริษัทใช้ระบบสั่งอาหาร Zhongmi",
|
||||
"options": [
|
||||
{ "id": "a", "label": "A. OA" },
|
||||
{ "id": "b", "label": "B. ระบบสั่งอาหาร Zhongmi" },
|
||||
{ "id": "c", "label": "C. ERP" }
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "q3",
|
||||
"type": "single",
|
||||
"prompt": "ข้อใดคือผลิตภัณฑ์ของบริษัท?",
|
||||
"answer": "abcd",
|
||||
"explanation": "ตัวเลือกทั้งสี่ข้อเป็นกลุ่มผลิตภัณฑ์ของบริษัทตามข้อสอบ",
|
||||
"options": [
|
||||
{ "id": "abcd", "label": "A/B/C/D ทั้งหมด" },
|
||||
{ "id": "ab", "label": "A/B" },
|
||||
{ "id": "cd", "label": "C/D" },
|
||||
{ "id": "a", "label": "เฉพาะ A" }
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "q4",
|
||||
"type": "single",
|
||||
"prompt": "หากต้องการลา ต้องเปิดเอกสาร OA แบบใด?",
|
||||
"answer": "c",
|
||||
"explanation": "การลาต้องใช้แบบฟอร์มใบลาของ OA",
|
||||
"options": [
|
||||
{ "id": "a", "label": "A. ใบขอโอที" },
|
||||
{ "id": "b", "label": "B. ใบติดต่อ" },
|
||||
{ "id": "c", "label": "C. ใบลางาน" },
|
||||
{ "id": "d", "label": "D. ใบคำขอพนักงาน" }
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "q5",
|
||||
"type": "single",
|
||||
"prompt": "QC080000 คืออะไร?",
|
||||
"answer": "a",
|
||||
"explanation": "QC080000 คือมาตรฐานการจัดการกระบวนการสารอันตราย",
|
||||
"options": [
|
||||
{ "id": "a", "label": "A. มาตรฐานการจัดการสารอันตราย" },
|
||||
{ "id": "b", "label": "B. ระบบอาชีวอนามัยและความปลอดภัย" },
|
||||
{ "id": "c", "label": "C. ระบบการจัดการสิ่งแวดล้อม" }
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "q6",
|
||||
"type": "single",
|
||||
"prompt": "5S หมายถึงอะไร?",
|
||||
"answer": "a",
|
||||
"explanation": "5S หมายถึงสะสาง สะดวก สะอาด สุขลักษณะ และสร้างนิสัย",
|
||||
"options": [
|
||||
{ "id": "a", "label": "A. สะสาง สะดวก สะอาด สุขลักษณะ สร้างนิสัย" },
|
||||
{ "id": "b", "label": "B. สะสาง สะดวก ทำความสะอาด สุขลักษณะ สร้างนิสัย" }
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "q7",
|
||||
"type": "single",
|
||||
"prompt": "ควรยืนด้านใดเมื่อใช้ถังดับเพลิง?",
|
||||
"answer": "a",
|
||||
"explanation": "ต้องยืนด้านเหนือลมเมื่อใช้ถังดับเพลิง",
|
||||
"options": [
|
||||
{ "id": "a", "label": "A. ด้านเหนือลม" },
|
||||
{ "id": "b", "label": "B. ด้านใต้ลม" }
|
||||
]
|
||||
},
|
||||
{ "id": "q8", "type": "boolean", "prompt": "การเข้างานปกติต้องลงเวลา และการทำโอทีต้องยื่นคำขอล่วงหน้า", "answer": "true", "explanation": "การเข้างานและโอทีต้องปฏิบัติตามกฎการลงเวลาของบริษัท" },
|
||||
{ "id": "q9", "type": "boolean", "prompt": "หากลืมลงเวลา ต้องยื่นคำขอแก้ไขผ่าน OA", "answer": "true", "explanation": "การลืมลงเวลาต้องแก้ไขผ่านกระบวนการ OA" },
|
||||
{ "id": "q10", "type": "boolean", "prompt": "เงินเดือนคำนวณตั้งแต่วันที่ 21 ของเดือนก่อนถึงวันที่ 20 ของเดือนปัจจุบัน", "answer": "true", "explanation": "ข้อสอบระบุรอบการคำนวณเงินเดือนนี้ไว้อย่างชัดเจน" },
|
||||
{ "id": "q11", "type": "boolean", "prompt": "การรับประทานอาหารในโรงอาหารต้องจองล่วงหน้า และสามารถใช้การสแกนใบหน้าได้", "answer": "true", "explanation": "โรงอาหารรองรับทั้งการจองล่วงหน้าและการสแกนใบหน้า" },
|
||||
{ "id": "q12", "type": "boolean", "prompt": "เมื่อเกิดไฟไหม้หรือระเบิด ควรโทร 119 ทันที", "answer": "true", "explanation": "การแจ้งหน่วยดับเพลิงเป็นขั้นตอนแรกที่ถูกต้อง" },
|
||||
{ "id": "q13", "type": "boolean", "prompt": "ผู้พักอาศัยในหอพักต้องระวังเรื่องไฟ และห้ามต่อสายไฟเองหรือใช้เครื่องใช้ไฟฟ้ากำลังสูง", "answer": "true", "explanation": "นี่คือข้อบังคับด้านความปลอดภัยจากอัคคีภัยในหอพัก" },
|
||||
{ "id": "q14", "type": "boolean", "prompt": "การปฏิบัติตามกฎความปลอดภัยในการผลิตเป็นหน้าที่ของพนักงาน", "answer": "true", "explanation": "การปฏิบัติตามกฎความปลอดภัยเป็นทั้งข้อกำหนดและหน้าที่ของพนักงาน" },
|
||||
{ "id": "q15", "type": "boolean", "prompt": "บัตรพนักงานสามารถให้ผู้อื่นยืมใช้ได้อย่างอิสระ", "answer": "false", "explanation": "บัตรพนักงานเป็นเอกสารยืนยันตัวตนส่วนบุคคล ห้ามให้ยืม" },
|
||||
{ "id": "q16", "type": "boolean", "prompt": "RoHS ใช้กำหนดมาตรฐานวัสดุและกระบวนการของผลิตภัณฑ์ไฟฟ้าและอิเล็กทรอนิกส์เพื่อปกป้องสุขภาพและสิ่งแวดล้อม", "answer": "true", "explanation": "เป้าหมายหลักของ RoHS คือการจำกัดสารอันตรายและลดความเสี่ยงต่อสิ่งแวดล้อม" },
|
||||
{ "id": "q17", "type": "boolean", "prompt": "นโยบาย HSF ของบริษัทคือ ออกแบบสีเขียว จัดซื้อเป็นมิตรต่อสิ่งแวดล้อม ประหยัดทรัพยากร และผลิตอย่างเป็นมิตรต่อสิ่งแวดล้อม", "answer": "true", "explanation": "นี่คือข้อความนโยบาย HSF ตามที่ระบุในข้อสอบ" },
|
||||
{ "id": "q18", "type": "boolean", "prompt": "EHS หมายถึง Environment, Health, Safety", "answer": "true", "explanation": "EHS เป็นตัวย่อมาตรฐานของสิ่งแวดล้อม สุขภาพ และความปลอดภัย" },
|
||||
{ "id": "q19", "type": "boolean", "prompt": "เอกสารจากภายนอกไม่จำเป็นต้องถูกควบคุมหรือจัดการโดยองค์กร", "answer": "false", "explanation": "เอกสารจากภายนอกก็ต้องมีการควบคุมเช่นกัน" },
|
||||
{ "id": "q20", "type": "boolean", "prompt": "ข้อกำหนดที่เกี่ยวข้องกับผลิตภัณฑ์ควรรวมถึงข้อกำหนดตามกฎหมายและข้อกำหนดของลูกค้า", "answer": "true", "explanation": "ข้อกำหนดของผลิตภัณฑ์ต้องครอบคลุมทั้งกฎหมายและความต้องการของลูกค้า" }
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -468,5 +468,327 @@
|
||||
"range": "显示第 {start}-{end} 条,共 {total} 条",
|
||||
"empty": "暂无符合条件的数据"
|
||||
}
|
||||
},
|
||||
"training": {
|
||||
"badge": "新人培训工作区",
|
||||
"title": "新人入职培训 Agent",
|
||||
"subtitle": "在同一个 Chat 页面内完成视频学习、知识点复盘、逐题考试以及 HR 管理统计。",
|
||||
"tabs": {
|
||||
"learner": "学员端",
|
||||
"admin": "HR 管理"
|
||||
},
|
||||
"actions": {
|
||||
"syncLearnerToChat": "同步学员上下文到聊天",
|
||||
"syncHrToChat": "同步 HR 筛选到聊天",
|
||||
"expandWorkspace": "展开工作区",
|
||||
"collapseWorkspace": "收起工作区"
|
||||
},
|
||||
"steps": {
|
||||
"video": "观看视频",
|
||||
"summary": "复盘知识点",
|
||||
"exam": "逐题考试",
|
||||
"result": "结算结果"
|
||||
},
|
||||
"progressLabel": "培训进度",
|
||||
"progressHint": "按 HR 要求完成视频、知识点、考试三个环节后才能视为完成。",
|
||||
"progressPercent": "完成度",
|
||||
"stepNo": "步骤 {value}",
|
||||
"defaultLearnerName": "当前学员",
|
||||
"unknownDepartment": "待补充部门",
|
||||
"video": {
|
||||
"title": "第一步:观看培训视频",
|
||||
"description": "员工先完成入职培训视频学习,再进入知识点复盘和考试环节。",
|
||||
"completeAction": "我已完成视频学习",
|
||||
"playerTitle": "视频播放位",
|
||||
"playerHint": "这里可接入企业视频链接或内部播放器。当前前端已预留完整容器与学习完成按钮。"
|
||||
},
|
||||
"summary": {
|
||||
"title": "第二步:知识点复盘",
|
||||
"description": "根据 HR 提供的试卷,系统先提炼考试重点,帮助员工在答题前完成记忆强化。",
|
||||
"startExam": "开始考试",
|
||||
"keyPoints": "重点知识",
|
||||
"mustKnow": "考前必知"
|
||||
},
|
||||
"exam": {
|
||||
"title": "第三步:逐题考试",
|
||||
"questionCounter": "第 {current} / {total} 题",
|
||||
"currentScore": "当前分数:{score} 分",
|
||||
"passLine": "及格线:90 分",
|
||||
"correctFeedback": "回答正确,继续下一题",
|
||||
"wrongFeedback": "回答错误,已显示正确答案",
|
||||
"selectedAnswer": "你的答案:{answer}",
|
||||
"correctAnswer": "正确答案:{answer}",
|
||||
"nextQuestion": "下一题",
|
||||
"finishExam": "完成考试"
|
||||
},
|
||||
"result": {
|
||||
"passedTag": "已通过",
|
||||
"failedTag": "需补考",
|
||||
"passTitle": "恭喜,你已通过新人培训考试",
|
||||
"failTitle": "本次考试未达标,需要重新考试",
|
||||
"passDescription": "前端已完成通过态交互,后续接入后端后可直接回写培训记录与完成日期。",
|
||||
"failDescription": "按照 HR 规则,未达到 90 分必须重新考试,直到最终通过为止。",
|
||||
"scoreLabel": "最终得分",
|
||||
"attemptsLabel": "考试次数",
|
||||
"correctCount": "答对题数",
|
||||
"wrongCount": "答错题数",
|
||||
"completionDate": "完成日期",
|
||||
"retryExam": "重新考试",
|
||||
"sendToChat": "发送复盘到聊天"
|
||||
},
|
||||
"learnerCard": {
|
||||
"title": "当前学员",
|
||||
"name": "姓名",
|
||||
"employeeId": "工号",
|
||||
"department": "部门"
|
||||
},
|
||||
"rules": {
|
||||
"title": "考试规则",
|
||||
"rule1": "共 20 题,每题 5 分,满分 100 分。",
|
||||
"rule2": "系统按“一题一答一反馈”执行,答错立即展示正确答案。",
|
||||
"rule3": "低于 90 分判定为未通过,必须重新考试。",
|
||||
"rule4": "HR 管理端可在同一聊天页查看统计并导出 Excel。"
|
||||
},
|
||||
"hr": {
|
||||
"stats": {
|
||||
"total": "参训人数",
|
||||
"passed": "已通过",
|
||||
"failed": "未通过",
|
||||
"inProgress": "进行中",
|
||||
"passRate": "通过率"
|
||||
},
|
||||
"filters": {
|
||||
"keywordLabel": "姓名 / 工号",
|
||||
"keywordPlaceholder": "输入姓名或工号筛选",
|
||||
"statusLabel": "状态",
|
||||
"departmentLabel": "部门",
|
||||
"allStatuses": "全部状态",
|
||||
"allDepartments": "全部部门",
|
||||
"noLimit": "不限"
|
||||
},
|
||||
"columns": {
|
||||
"joinDate": "入职日期",
|
||||
"completionDate": "完成日期",
|
||||
"department": "部门",
|
||||
"name": "姓名",
|
||||
"employeeId": "工号",
|
||||
"score": "分数",
|
||||
"attempts": "考试次数",
|
||||
"status": "状态"
|
||||
},
|
||||
"status": {
|
||||
"passed": "已通过",
|
||||
"failed": "未通过",
|
||||
"in_progress": "进行中"
|
||||
},
|
||||
"actions": {
|
||||
"askAgent": "让 Agent 生成分析",
|
||||
"export": "导出 Excel"
|
||||
},
|
||||
"empty": "当前筛选条件下暂无培训记录。"
|
||||
},
|
||||
"chatPrompts": {
|
||||
"hrSummaryPrefix": "请基于当前筛选条件,帮我总结新人培训数据并给出异常名单。",
|
||||
"afterVideo": "我已完成新人培训视频,请结合考试范围帮我总结重点知识。",
|
||||
"afterSummary": "我已完成知识点复盘,请切换到考试模式并开始第一题。",
|
||||
"afterPass": "我已经通过新人培训考试,得分 {score} 分,请帮我生成一段培训完成总结。",
|
||||
"afterFail": "我本次新人培训考试得分 {score} 分,未达到及格线,请帮我总结错题重点并安排重考提醒。",
|
||||
"examInProgress": "我正在进行新人培训考试,目前做到第 {index}/{total} 题。题目是:{question}。请保持考官模式,评价我的表现并引导我继续。"
|
||||
},
|
||||
"summaryPoints": [
|
||||
"工资每月 15 号发放,考勤与请假均需要走 OA 流程。",
|
||||
"餐厅订餐使用中米新订餐系统,忘记刷卡需走 OA 补刷卡流程。",
|
||||
"5S 包括整理、整顿、清扫、清洁和素养,属于现场管理基础要求。",
|
||||
"发生火灾时要第一时间拨打 119,并使用灭火器站在上风口操作。",
|
||||
"QC080000 对应有害物质过程管理体系,RoHS 关注电子电气产品环保要求。"
|
||||
],
|
||||
"summaryChecklist": [
|
||||
"答题时系统只展示当前题目,避免一次性泄露完整答案。",
|
||||
"答错题目必须立即看到标准答案和简短解析。",
|
||||
"考试结束后只有分数达到 90 分才算通过。",
|
||||
"管理端需要能导出入职日期、完成日期、部门、姓名、工号和分数。"
|
||||
],
|
||||
"booleanOptions": [
|
||||
{ "id": "true", "label": "正确" },
|
||||
{ "id": "false", "label": "错误" }
|
||||
],
|
||||
"questionBank": [
|
||||
{
|
||||
"id": "q1",
|
||||
"type": "single",
|
||||
"prompt": "工资每月几号发放?",
|
||||
"answer": "a",
|
||||
"explanation": "根据新人培训试卷答案,工资固定在每月 8 号发放。",
|
||||
"options": [
|
||||
{ "id": "a", "label": "A. 8号" },
|
||||
{ "id": "b", "label": "B. 9号" },
|
||||
{ "id": "c", "label": "C. 15号" },
|
||||
{ "id": "d", "label": "D. 27号" }
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "q2",
|
||||
"type": "single",
|
||||
"prompt": "餐厅订餐的系统是?",
|
||||
"answer": "b",
|
||||
"explanation": "公司餐厅订餐使用中米新订餐系统,不是 OA 或 ERP。",
|
||||
"options": [
|
||||
{ "id": "a", "label": "A. OA" },
|
||||
{ "id": "b", "label": "B. 中米新订餐系统" },
|
||||
{ "id": "c", "label": "C. ERP" }
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "q3",
|
||||
"type": "single",
|
||||
"prompt": "公司的产品有?",
|
||||
"answer": "abcd",
|
||||
"explanation": "试卷给出的四个选项都是公司产品范畴,前端以组合选项形式展示为全选。",
|
||||
"options": [
|
||||
{ "id": "abcd", "label": "A/B/C/D 全部都是" },
|
||||
{ "id": "ab", "label": "A/B" },
|
||||
{ "id": "cd", "label": "C/D" },
|
||||
{ "id": "a", "label": "仅 A" }
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "q4",
|
||||
"type": "single",
|
||||
"prompt": "请假需要开什么 OA 单?",
|
||||
"answer": "c",
|
||||
"explanation": "请假必须发起 OA 请假申请单,不能使用加班申请单或联络单。",
|
||||
"options": [
|
||||
{ "id": "a", "label": "A. 加班申请单" },
|
||||
{ "id": "b", "label": "B. 联络单" },
|
||||
{ "id": "c", "label": "C. 请假申请单" },
|
||||
{ "id": "d", "label": "D. 员工需求单" }
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "q5",
|
||||
"type": "single",
|
||||
"prompt": "QC080000 是什么?",
|
||||
"answer": "a",
|
||||
"explanation": "QC080000 对应有害物质过程管理体系认证标准。",
|
||||
"options": [
|
||||
{ "id": "a", "label": "A. 有害物质过程管理体系认证标准" },
|
||||
{ "id": "b", "label": "B. 职业健康安全管理体系" },
|
||||
{ "id": "c", "label": "C. 环境管理体系" }
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "q6",
|
||||
"type": "single",
|
||||
"prompt": "5S 指的是?",
|
||||
"answer": "a",
|
||||
"explanation": "5S 标准表述为整理、整顿、清扫、清洁和素养。",
|
||||
"options": [
|
||||
{ "id": "a", "label": "A. 整理、整顿、清扫、清洁和素养" },
|
||||
{ "id": "b", "label": "B. 整理、整顿、打扫、清洁和素养" }
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "q7",
|
||||
"type": "single",
|
||||
"prompt": "使用灭火器应站在火源的哪里?",
|
||||
"answer": "a",
|
||||
"explanation": "使用灭火器要站在上风口,避免烟雾和火势倒灌。",
|
||||
"options": [
|
||||
{ "id": "a", "label": "A. 上风口" },
|
||||
{ "id": "b", "label": "B. 下风口" }
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "q8",
|
||||
"type": "boolean",
|
||||
"prompt": "正常出勤必须打卡,加班需要提前申请提报。",
|
||||
"answer": "true",
|
||||
"explanation": "出勤和加班都需要遵循公司考勤制度,这是基础要求。"
|
||||
},
|
||||
{
|
||||
"id": "q9",
|
||||
"type": "boolean",
|
||||
"prompt": "忘记刷卡需要 OA 开补刷卡单。",
|
||||
"answer": "true",
|
||||
"explanation": "漏打卡需要通过 OA 补刷卡流程修正考勤记录。"
|
||||
},
|
||||
{
|
||||
"id": "q10",
|
||||
"type": "boolean",
|
||||
"prompt": "每月工资从上月 21 日至本月 20 日为止计算。",
|
||||
"answer": "true",
|
||||
"explanation": "试卷中明确了工资核算周期的起止时间。"
|
||||
},
|
||||
{
|
||||
"id": "q11",
|
||||
"type": "boolean",
|
||||
"prompt": "餐厅用餐需提前预定,可以直接刷脸用餐。",
|
||||
"answer": "true",
|
||||
"explanation": "公司餐厅支持提前预定并刷脸用餐。"
|
||||
},
|
||||
{
|
||||
"id": "q12",
|
||||
"type": "boolean",
|
||||
"prompt": "发生火灾、爆炸事故时,应立即拨打 119。",
|
||||
"answer": "true",
|
||||
"explanation": "火灾事故首先要联系消防,119 是基本应急要求。"
|
||||
},
|
||||
{
|
||||
"id": "q13",
|
||||
"type": "boolean",
|
||||
"prompt": "住宿人员应保持高度防火意识,不准私拉乱接电线和使用高功率电器。",
|
||||
"answer": "true",
|
||||
"explanation": "宿舍防火是红线要求,私拉电线和使用大功率电器都被禁止。"
|
||||
},
|
||||
{
|
||||
"id": "q14",
|
||||
"type": "boolean",
|
||||
"prompt": "遵守安全生产规章制度是从业人员应履行的安全生产义务。",
|
||||
"answer": "true",
|
||||
"explanation": "安全制度不仅是要求,也是员工必须履行的义务。"
|
||||
},
|
||||
{
|
||||
"id": "q15",
|
||||
"type": "boolean",
|
||||
"prompt": "工牌可以随意借由他人使用。",
|
||||
"answer": "false",
|
||||
"explanation": "工牌属于个人身份凭证,严禁外借。"
|
||||
},
|
||||
{
|
||||
"id": "q16",
|
||||
"type": "boolean",
|
||||
"prompt": "RoHS 主要用于规范电子电气产品的材料及工艺标准,使之更加有利于人体健康及环境保护。",
|
||||
"answer": "true",
|
||||
"explanation": "RoHS 的核心目标就是限制有害物质、降低环境与人体风险。"
|
||||
},
|
||||
{
|
||||
"id": "q17",
|
||||
"type": "boolean",
|
||||
"prompt": "我们公司的 HSF 方针是:绿色设计,环保采购;节约资源,绿色产出。",
|
||||
"answer": "true",
|
||||
"explanation": "这是试卷给出的公司 HSF 方针原文。"
|
||||
},
|
||||
{
|
||||
"id": "q18",
|
||||
"type": "boolean",
|
||||
"prompt": "EHS(Environment、Health、Safety)指环境健康安全。",
|
||||
"answer": "true",
|
||||
"explanation": "EHS 是环境、健康、安全三个维度的统一简称。"
|
||||
},
|
||||
{
|
||||
"id": "q19",
|
||||
"type": "boolean",
|
||||
"prompt": "对于外来文件,组织不需对其进行控制与管理。",
|
||||
"answer": "false",
|
||||
"explanation": "外来文件同样需要受控管理,确保版本和使用正确。"
|
||||
},
|
||||
{
|
||||
"id": "q20",
|
||||
"type": "boolean",
|
||||
"prompt": "与产品有关的要求应包括有关法律法规规定的要求及顾客的要求等。",
|
||||
"answer": "true",
|
||||
"explanation": "产品要求必须同时覆盖法规和客户要求,这是质量体系基础。"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -468,5 +468,249 @@
|
||||
"range": "顯示第 {start}-{end} 條,共 {total} 條",
|
||||
"empty": "暫無符合條件的資料"
|
||||
}
|
||||
},
|
||||
"training": {
|
||||
"badge": "新人培訓工作區",
|
||||
"title": "新人入職培訓 Agent",
|
||||
"subtitle": "在同一個 Chat 頁面內完成影片學習、知識點複盤、逐題考試與 HR 管理統計。",
|
||||
"tabs": {
|
||||
"learner": "學員端",
|
||||
"admin": "HR 管理"
|
||||
},
|
||||
"actions": {
|
||||
"syncLearnerToChat": "同步學員上下文到聊天",
|
||||
"syncHrToChat": "同步 HR 篩選到聊天",
|
||||
"expandWorkspace": "展開工作區",
|
||||
"collapseWorkspace": "收起工作區"
|
||||
},
|
||||
"steps": {
|
||||
"video": "觀看影片",
|
||||
"summary": "複盤知識點",
|
||||
"exam": "逐題考試",
|
||||
"result": "結算結果"
|
||||
},
|
||||
"progressLabel": "培訓進度",
|
||||
"progressHint": "需依 HR 要求完成影片、知識點、考試三個環節後才算完成。",
|
||||
"progressPercent": "完成度",
|
||||
"stepNo": "步驟 {value}",
|
||||
"defaultLearnerName": "當前學員",
|
||||
"unknownDepartment": "待補充部門",
|
||||
"video": {
|
||||
"title": "第一步:觀看培訓影片",
|
||||
"description": "員工先完成入職培訓影片學習,再進入知識點複盤與考試環節。",
|
||||
"completeAction": "我已完成影片學習",
|
||||
"playerTitle": "影片播放區",
|
||||
"playerHint": "此處可接入企業影片連結或內部播放器。當前前端已預留完整容器與完成按鈕。"
|
||||
},
|
||||
"summary": {
|
||||
"title": "第二步:知識點複盤",
|
||||
"description": "根據 HR 提供的試卷,系統先提煉考試重點,幫助員工在答題前完成記憶強化。",
|
||||
"startExam": "開始考試",
|
||||
"keyPoints": "重點知識",
|
||||
"mustKnow": "考前必知"
|
||||
},
|
||||
"exam": {
|
||||
"title": "第三步:逐題考試",
|
||||
"questionCounter": "第 {current} / {total} 題",
|
||||
"currentScore": "當前分數:{score} 分",
|
||||
"passLine": "及格線:90 分",
|
||||
"correctFeedback": "回答正確,繼續下一題",
|
||||
"wrongFeedback": "回答錯誤,已顯示正確答案",
|
||||
"selectedAnswer": "你的答案:{answer}",
|
||||
"correctAnswer": "正確答案:{answer}",
|
||||
"nextQuestion": "下一題",
|
||||
"finishExam": "完成考試"
|
||||
},
|
||||
"result": {
|
||||
"passedTag": "已通過",
|
||||
"failedTag": "需補考",
|
||||
"passTitle": "恭喜,你已通過新人培訓考試",
|
||||
"failTitle": "本次考試未達標,需要重新考試",
|
||||
"passDescription": "前端已完成通過態互動,後續接入後端後可直接回寫培訓記錄與完成日期。",
|
||||
"failDescription": "依照 HR 規則,低於 90 分必須重新考試,直到最終通過。",
|
||||
"scoreLabel": "最終得分",
|
||||
"attemptsLabel": "考試次數",
|
||||
"correctCount": "答對題數",
|
||||
"wrongCount": "答錯題數",
|
||||
"completionDate": "完成日期",
|
||||
"retryExam": "重新考試",
|
||||
"sendToChat": "發送複盤到聊天"
|
||||
},
|
||||
"learnerCard": {
|
||||
"title": "當前學員",
|
||||
"name": "姓名",
|
||||
"employeeId": "工號",
|
||||
"department": "部門"
|
||||
},
|
||||
"rules": {
|
||||
"title": "考試規則",
|
||||
"rule1": "共 20 題,每題 5 分,滿分 100 分。",
|
||||
"rule2": "系統依「一題一答一回饋」執行,答錯立即顯示正確答案。",
|
||||
"rule3": "低於 90 分視為未通過,必須重新考試。",
|
||||
"rule4": "HR 管理端可在同一聊天頁查看統計並匯出 Excel。"
|
||||
},
|
||||
"hr": {
|
||||
"stats": {
|
||||
"total": "參訓人數",
|
||||
"passed": "已通過",
|
||||
"failed": "未通過",
|
||||
"inProgress": "進行中",
|
||||
"passRate": "通過率"
|
||||
},
|
||||
"filters": {
|
||||
"keywordLabel": "姓名 / 工號",
|
||||
"keywordPlaceholder": "輸入姓名或工號篩選",
|
||||
"statusLabel": "狀態",
|
||||
"departmentLabel": "部門",
|
||||
"allStatuses": "全部狀態",
|
||||
"allDepartments": "全部部門",
|
||||
"noLimit": "不限"
|
||||
},
|
||||
"columns": {
|
||||
"joinDate": "入職日期",
|
||||
"completionDate": "完成日期",
|
||||
"department": "部門",
|
||||
"name": "姓名",
|
||||
"employeeId": "工號",
|
||||
"score": "分數",
|
||||
"attempts": "考試次數",
|
||||
"status": "狀態"
|
||||
},
|
||||
"status": {
|
||||
"passed": "已通過",
|
||||
"failed": "未通過",
|
||||
"in_progress": "進行中"
|
||||
},
|
||||
"actions": {
|
||||
"askAgent": "讓 Agent 生成分析",
|
||||
"export": "匯出 Excel"
|
||||
},
|
||||
"empty": "當前篩選條件下暫無培訓記錄。"
|
||||
},
|
||||
"chatPrompts": {
|
||||
"hrSummaryPrefix": "請根據當前篩選條件,幫我總結新人培訓數據並列出異常名單。",
|
||||
"afterVideo": "我已完成新人培訓影片,請結合考試範圍幫我總結重點知識。",
|
||||
"afterSummary": "我已完成知識點複盤,請切換到考試模式並開始第一題。",
|
||||
"afterPass": "我已通過新人培訓考試,得分 {score} 分,請幫我生成一段培訓完成總結。",
|
||||
"afterFail": "我本次新人培訓考試得分 {score} 分,未達及格線,請幫我總結錯題重點並安排重考提醒。",
|
||||
"examInProgress": "我正在進行新人培訓考試,目前做到第 {index}/{total} 題,請保持考官模式繼續出題。"
|
||||
},
|
||||
"summaryPoints": [
|
||||
"工資每月 15 號發放,考勤與請假均需走 OA 流程。",
|
||||
"餐廳訂餐使用中米新訂餐系統,忘記刷卡需走 OA 補刷卡流程。",
|
||||
"5S 包括整理、整頓、清掃、清潔和素養,是現場管理基礎要求。",
|
||||
"發生火災時要第一時間撥打 119,並在上風口使用滅火器。",
|
||||
"QC080000 對應有害物質過程管理體系,RoHS 關注電子電氣產品環保要求。"
|
||||
],
|
||||
"summaryChecklist": [
|
||||
"答題時系統只展示當前題目,避免一次性洩露完整答案。",
|
||||
"答錯題目必須立即看到標準答案與簡短解析。",
|
||||
"考試結束後只有分數達到 90 分才算通過。",
|
||||
"管理端需要能匯出入職日期、完成日期、部門、姓名、工號和分數。"
|
||||
],
|
||||
"booleanOptions": [
|
||||
{ "id": "true", "label": "正確" },
|
||||
{ "id": "false", "label": "錯誤" }
|
||||
],
|
||||
"questionBank": [
|
||||
{
|
||||
"id": "q1",
|
||||
"type": "single",
|
||||
"prompt": "工資每月幾號發放?",
|
||||
"answer": "c",
|
||||
"explanation": "根據新人培訓試卷,工資固定在每月 15 號發放。",
|
||||
"options": [
|
||||
{ "id": "a", "label": "A. 8號" },
|
||||
{ "id": "b", "label": "B. 9號" },
|
||||
{ "id": "c", "label": "C. 15號" },
|
||||
{ "id": "d", "label": "D. 27號" }
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "q2",
|
||||
"type": "single",
|
||||
"prompt": "餐廳訂餐的系統是?",
|
||||
"answer": "b",
|
||||
"explanation": "公司餐廳訂餐使用中米新訂餐系統,不是 OA 或 ERP。",
|
||||
"options": [
|
||||
{ "id": "a", "label": "A. OA" },
|
||||
{ "id": "b", "label": "B. 中米新訂餐系統" },
|
||||
{ "id": "c", "label": "C. ERP" }
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "q3",
|
||||
"type": "single",
|
||||
"prompt": "公司的產品有?",
|
||||
"answer": "abcd",
|
||||
"explanation": "試卷給出的四個選項都屬於公司產品範疇,前端以組合選項呈現為全選。",
|
||||
"options": [
|
||||
{ "id": "abcd", "label": "A/B/C/D 全部都是" },
|
||||
{ "id": "ab", "label": "A/B" },
|
||||
{ "id": "cd", "label": "C/D" },
|
||||
{ "id": "a", "label": "僅 A" }
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "q4",
|
||||
"type": "single",
|
||||
"prompt": "請假需要開什麼 OA 單?",
|
||||
"answer": "c",
|
||||
"explanation": "請假必須發起 OA 請假申請單,不能使用加班申請單或聯絡單。",
|
||||
"options": [
|
||||
{ "id": "a", "label": "A. 加班申請單" },
|
||||
{ "id": "b", "label": "B. 聯絡單" },
|
||||
{ "id": "c", "label": "C. 請假申請單" },
|
||||
{ "id": "d", "label": "D. 員工需求單" }
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "q5",
|
||||
"type": "single",
|
||||
"prompt": "QC080000 是什麼?",
|
||||
"answer": "a",
|
||||
"explanation": "QC080000 對應有害物質過程管理體系認證標準。",
|
||||
"options": [
|
||||
{ "id": "a", "label": "A. 有害物質過程管理體系認證標準" },
|
||||
{ "id": "b", "label": "B. 職業健康安全管理體系" },
|
||||
{ "id": "c", "label": "C. 環境管理體系" }
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "q6",
|
||||
"type": "single",
|
||||
"prompt": "5S 指的是?",
|
||||
"answer": "a",
|
||||
"explanation": "5S 標準表述為整理、整頓、清掃、清潔和素養。",
|
||||
"options": [
|
||||
{ "id": "a", "label": "A. 整理、整頓、清掃、清潔和素養" },
|
||||
{ "id": "b", "label": "B. 整理、整頓、打掃、清潔和素養" }
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "q7",
|
||||
"type": "single",
|
||||
"prompt": "使用滅火器應站在火源的哪裡?",
|
||||
"answer": "a",
|
||||
"explanation": "使用滅火器要站在上風口,避免煙霧與火勢倒灌。",
|
||||
"options": [
|
||||
{ "id": "a", "label": "A. 上風口" },
|
||||
{ "id": "b", "label": "B. 下風口" }
|
||||
]
|
||||
},
|
||||
{ "id": "q8", "type": "boolean", "prompt": "正常出勤必須打卡,加班需要提前申請提報。", "answer": "true", "explanation": "出勤與加班都需要遵循公司考勤制度。" },
|
||||
{ "id": "q9", "type": "boolean", "prompt": "忘記刷卡需要 OA 開補刷卡單。", "answer": "true", "explanation": "漏打卡需要透過 OA 補刷卡流程修正考勤記錄。" },
|
||||
{ "id": "q10", "type": "boolean", "prompt": "每月工資從上月 21 日至本月 20 日為止計算。", "answer": "true", "explanation": "試卷中明確了工資核算週期的起止時間。" },
|
||||
{ "id": "q11", "type": "boolean", "prompt": "餐廳用餐需提前預定,可以直接刷臉用餐。", "answer": "true", "explanation": "公司餐廳支援提前預定並刷臉用餐。" },
|
||||
{ "id": "q12", "type": "boolean", "prompt": "發生火災、爆炸事故時,應立即撥打 119。", "answer": "true", "explanation": "火災事故首先要聯絡消防,119 是基本應急要求。" },
|
||||
{ "id": "q13", "type": "boolean", "prompt": "住宿人員應保持高度防火意識,不准私拉亂接電線和使用高功率電器。", "answer": "true", "explanation": "宿舍防火是紅線要求,私拉電線和使用大功率電器都被禁止。" },
|
||||
{ "id": "q14", "type": "boolean", "prompt": "遵守安全生產規章制度是從業人員應履行的安全生產義務。", "answer": "true", "explanation": "安全制度不僅是要求,也是員工必須履行的義務。" },
|
||||
{ "id": "q15", "type": "boolean", "prompt": "工牌可以隨意借由他人使用。", "answer": "false", "explanation": "工牌屬於個人身份憑證,嚴禁外借。" },
|
||||
{ "id": "q16", "type": "boolean", "prompt": "RoHS 主要用於規範電子電氣產品的材料及工藝標準,使之更加有利於人體健康及環境保護。", "answer": "true", "explanation": "RoHS 的核心目標就是限制有害物質、降低環境與人體風險。" },
|
||||
{ "id": "q17", "type": "boolean", "prompt": "我們公司的 HSF 方針是:綠色設計,環保採購;節約資源,綠色產出。", "answer": "true", "explanation": "這是試卷給出的公司 HSF 方針原文。" },
|
||||
{ "id": "q18", "type": "boolean", "prompt": "EHS(Environment、Health、Safety)指環境健康安全。", "answer": "true", "explanation": "EHS 是環境、健康、安全三個維度的統一簡稱。" },
|
||||
{ "id": "q19", "type": "boolean", "prompt": "對於外來文件,組織不需對其進行控制與管理。", "answer": "false", "explanation": "外來文件同樣需要受控管理,確保版本與使用正確。" },
|
||||
{ "id": "q20", "type": "boolean", "prompt": "與產品有關的要求應包括有關法律法規規定的要求及顧客的要求等。", "answer": "true", "explanation": "產品要求必須同時覆蓋法規和客戶要求,這是品質體系基礎。" }
|
||||
]
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user