Merge branch 'dev' into hugo-shipping-notice
This commit is contained in:
commit
331cfdc361
14 files changed
+769
-83
No files matched your search
@@ -85,7 +85,7 @@ def _normalize_exam_mode(value: Any) -> str:
|
||||
return text
|
||||
|
||||
|
||||
def _build_default_safety_progress(safety_stage: str) -> dict[str, str]:
|
||||
def _build_default_safety_progress(safety_stage: str) -> dict[str, Any]:
|
||||
"""
|
||||
根据安全培训当前阶段推导三级学习进度。
|
||||
|
||||
@@ -94,7 +94,7 @@ def _build_default_safety_progress(safety_stage: str) -> dict[str, str]:
|
||||
Returns:
|
||||
company、department、team 三个级别的状态快照。
|
||||
"""
|
||||
progress: dict[str, str] = {key: "pending" for key in SAFETY_LEVEL_KEYS}
|
||||
progress: dict[str, Any] = {key: "pending" for key in SAFETY_LEVEL_KEYS}
|
||||
if safety_stage == "company":
|
||||
progress["company"] = "active"
|
||||
return progress
|
||||
@@ -128,7 +128,7 @@ def _normalize_safety_stage(value: Any) -> str:
|
||||
return text
|
||||
|
||||
|
||||
def _normalize_safety_progress(value: Any, safety_stage: str) -> dict[str, str]:
|
||||
def _normalize_safety_progress(value: Any, safety_stage: str) -> dict[str, Any]:
|
||||
"""
|
||||
规范安全培训三级进度对象。
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
"""
|
||||
backend/migrations/versions/1b2c3d4e5f6a_rebuild_shipping_field_governance.py
|
||||
|
||||
用途:重建货代字段资产治理——全局标准/扩展字段、Schema 族约束放宽、审计扩展;清空旧配置并种子 57 标准资产。
|
||||
用途:重建货代字段资产治理——全局标准/扩展字段、Schema 族约束放宽、审计扩展;清空旧配置并种子 58 标准资产。
|
||||
依赖:前序 head 0a1b2c3d4e5f;standard_field_registry。
|
||||
逻辑:
|
||||
upgrade — 软化**历史运行域**硬 FK(Extraction/Run/Snapshot/Artifact/Review 等保留 orphan ID,
|
||||
@@ -230,7 +230,7 @@ def _revert_shipping_order_fields_structure(is_sqlite: bool) -> None:
|
||||
batch.drop_column(column)
|
||||
if not _column_exists('shipping_order_fields', 'schema_id'):
|
||||
batch.add_column(sa.Column('schema_id', sa.Integer(), nullable=True))
|
||||
batch.drop_constraint('uq_shipping_order_fields_field_code', type_='unique')
|
||||
batch.drop_constraint('uq_shipping_order_fields_code_scope', type_='unique')
|
||||
batch.create_unique_constraint(
|
||||
'uq_shipping_order_fields_schema_code',
|
||||
['schema_id', 'field_code'],
|
||||
@@ -253,7 +253,7 @@ def _revert_shipping_order_fields_structure(is_sqlite: bool) -> None:
|
||||
op.execute(sa.text('DROP INDEX IF EXISTS ix_shipping_order_fields_scope_status'))
|
||||
op.execute(sa.text('DROP INDEX IF EXISTS ix_shipping_order_fields_asset_kind'))
|
||||
op.execute(sa.text(
|
||||
'ALTER TABLE shipping_order_fields DROP CONSTRAINT IF EXISTS uq_shipping_order_fields_field_code'
|
||||
'ALTER TABLE shipping_order_fields DROP CONSTRAINT IF EXISTS uq_shipping_order_fields_code_scope'
|
||||
))
|
||||
op.execute(sa.text(
|
||||
'ALTER TABLE shipping_order_fields DROP CONSTRAINT IF EXISTS ck_shipping_order_fields_asset_kind'
|
||||
@@ -427,7 +427,10 @@ def upgrade() -> None:
|
||||
batch.add_column(sa.Column('retired_at', sa.DateTime(), nullable=True))
|
||||
batch.add_column(sa.Column('restored_by_id', sa.Integer(), nullable=True))
|
||||
batch.add_column(sa.Column('restored_at', sa.DateTime(), nullable=True))
|
||||
batch.create_unique_constraint('uq_shipping_order_fields_field_code', ['field_code'])
|
||||
batch.create_unique_constraint(
|
||||
'uq_shipping_order_fields_code_scope',
|
||||
['field_code', 'scope'],
|
||||
)
|
||||
batch.create_check_constraint(
|
||||
'ck_shipping_order_fields_category',
|
||||
"field_category IN ('order_header', 'order_line')",
|
||||
@@ -472,7 +475,11 @@ def upgrade() -> None:
|
||||
op.add_column('shipping_order_fields', sa.Column('retired_at', sa.DateTime(), nullable=True))
|
||||
op.add_column('shipping_order_fields', sa.Column('restored_by_id', sa.Integer(), sa.ForeignKey('users.id'), nullable=True))
|
||||
op.add_column('shipping_order_fields', sa.Column('restored_at', sa.DateTime(), nullable=True))
|
||||
op.create_unique_constraint('uq_shipping_order_fields_field_code', 'shipping_order_fields', ['field_code'])
|
||||
op.create_unique_constraint(
|
||||
'uq_shipping_order_fields_code_scope',
|
||||
'shipping_order_fields',
|
||||
['field_code', 'scope'],
|
||||
)
|
||||
op.create_index('ix_shipping_order_fields_scope_status', 'shipping_order_fields', ['scope', 'status'])
|
||||
op.create_index('ix_shipping_order_fields_asset_kind', 'shipping_order_fields', ['asset_kind'])
|
||||
# 放宽/替换字段分类与采集模式约束:去掉 general_context
|
||||
@@ -515,7 +522,7 @@ def upgrade() -> None:
|
||||
op.alter_column('shipping_order_schema_audit_events', 'schema_id', existing_type=sa.Integer(), nullable=True)
|
||||
op.add_column('shipping_order_schema_audit_events', sa.Column('field_id', sa.String(36), nullable=True))
|
||||
|
||||
# [STEP 5] 种子 57 标准字段 + 空默认族
|
||||
# [STEP 5] 种子 58 标准字段 + 空默认族
|
||||
from app.services.shipping_notice.standard_field_registry import (
|
||||
DEFAULT_SCHEMA_FAMILY_CODE,
|
||||
DEFAULT_SCHEMA_FAMILY_NAME,
|
||||
|
||||
@@ -4,7 +4,7 @@ backend/tests/test_shipping_field_governance_migration.py
|
||||
用途:验证字段资产治理重建迁移(1b2c3d4e5f6a)在 SQLite 上可升级/降级并种子默认族。
|
||||
依赖:Alembic Operations、临时内存库、standard_field_registry。
|
||||
逻辑:构造迁移前 fields(含 schema_id)、schemas、Excel 模板与导出产物对 schema_version 的 FK 依赖图 →
|
||||
upgrade → 断言无 schema_id、57 标准资产、空默认族、CHECK 约束同步;downgrade → 断言结构回退
|
||||
upgrade → 断言无 schema_id、58 标准资产、Header/Line 同名字段可共存、空默认族、CHECK 约束同步;downgrade → 断言结构回退
|
||||
(schema_id 恢复、asset_kind 消失) 且种子行清空;下游 orphan 引用不阻断迁移。
|
||||
"""
|
||||
|
||||
@@ -117,7 +117,7 @@ def _build_pre_migration_schema(metadata: sa.MetaData) -> None:
|
||||
|
||||
|
||||
def test_field_governance_rebuild_migration_seeds_global_assets(monkeypatch):
|
||||
"""关键断言:清空旧配置后种子 57 标准资产与 STANDARD_SHIPPING_NOTICE 空族,fields 无 schema_id。"""
|
||||
"""关键断言:清空旧配置后种子 58 标准资产与 STANDARD_SHIPPING_NOTICE 空族,fields 无 schema_id。"""
|
||||
migration = importlib.import_module(
|
||||
'migrations.versions.1b2c3d4e5f6a_rebuild_shipping_field_governance',
|
||||
)
|
||||
@@ -183,9 +183,11 @@ def test_field_governance_rebuild_migration_seeds_global_assets(monkeypatch):
|
||||
assert "collection_mode IN ('llm_extraction')" in ck_sql
|
||||
|
||||
field_rows = connection.execute(sa.text(
|
||||
"SELECT field_code, asset_kind, status FROM shipping_order_fields"
|
||||
"SELECT field_code, scope, asset_kind, status FROM shipping_order_fields"
|
||||
)).mappings().all()
|
||||
assert len(field_rows) == len(STANDARD_FIELD_SPECS) == 58
|
||||
reservation_rows = [row for row in field_rows if row['field_code'] == 'reservation_id']
|
||||
assert {row['scope'] for row in reservation_rows} == {'header', 'line'}
|
||||
assert all(row['asset_kind'] == 'system_standard' for row in field_rows)
|
||||
assert all(row['status'] == 'active' for row in field_rows)
|
||||
assert 'legacy_po' not in {row['field_code'] for row in field_rows}
|
||||
|
||||
Generated
+255
@@ -15,6 +15,7 @@
|
||||
"@vue-office/pdf": "^1.6.5",
|
||||
"cron-parser": "^5.5.0",
|
||||
"highlight.js": "^11.11.1",
|
||||
"html2pdf.js": "^0.14.0",
|
||||
"lucide-vue-next": "^0.575.0",
|
||||
"marked": "^17.0.3",
|
||||
"pdfjs-dist": "^5.6.205",
|
||||
@@ -26,6 +27,7 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^24.10.1",
|
||||
"@types/pdfjs-dist": "^2.10.377",
|
||||
"@vitejs/plugin-vue": "^6.0.2",
|
||||
"@vue/test-utils": "^2.4.11",
|
||||
"@vue/tsconfig": "^0.8.1",
|
||||
@@ -135,6 +137,15 @@
|
||||
"node": ">=6.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@babel/runtime": {
|
||||
"version": "7.29.7",
|
||||
"resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.29.7.tgz",
|
||||
"integrity": "sha512-Nq8OhGWiZIZGV6hLHoyAKLLcJihP/xFeBMGJoUrxTX2psI8dCifzLhZISFb+VWS3wFMRDmCGw5R+dOySCqPLhw==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=6.9.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@babel/types": {
|
||||
"version": "7.29.7",
|
||||
"resolved": "https://registry.npmmirror.com/@babel/types/-/types-7.29.7.tgz",
|
||||
@@ -1152,6 +1163,36 @@
|
||||
"undici-types": "~7.18.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@types/pako": {
|
||||
"version": "2.0.4",
|
||||
"resolved": "https://registry.npmjs.org/@types/pako/-/pako-2.0.4.tgz",
|
||||
"integrity": "sha512-VWDCbrLeVXJM9fihYodcLiIv0ku+AlOa/TQ1SvYOaBuyrSKgEcro95LJyIsJ4vSo6BXIxOKxiJAat04CmST9Fw==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@types/pdfjs-dist": {
|
||||
"version": "2.10.377",
|
||||
"resolved": "https://registry.npmjs.org/@types/pdfjs-dist/-/pdfjs-dist-2.10.377.tgz",
|
||||
"integrity": "sha512-RNBWpazVTkC5aiUIIo6d7ojlL0hJSoeQP1QCvTsVLW6qkNEpTALiI0DNGCYAGDfhbL0r17c/zNPQ15lk948UXg==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"pdfjs-dist": "*"
|
||||
}
|
||||
},
|
||||
"node_modules/@types/raf": {
|
||||
"version": "3.4.3",
|
||||
"resolved": "https://registry.npmjs.org/@types/raf/-/raf-3.4.3.tgz",
|
||||
"integrity": "sha512-c4YAvMedbPZ5tEyxzQdMoOhhJ4RD3rngZIdwC2/qDN3d7JpEhB6fiBRKVY1lg5B7Wk+uPBjn5f39j1/2MY1oOw==",
|
||||
"license": "MIT",
|
||||
"optional": true
|
||||
},
|
||||
"node_modules/@types/trusted-types": {
|
||||
"version": "2.0.7",
|
||||
"resolved": "https://registry.npmjs.org/@types/trusted-types/-/trusted-types-2.0.7.tgz",
|
||||
"integrity": "sha512-ScaPdn1dQczgbl0QFTeTOmVHFULt394XJgOQNoyVhZ6r2vLnMLJfBPd53SB52T/3G36VI1/g2MZaX0cwDuXsfw==",
|
||||
"license": "MIT",
|
||||
"optional": true
|
||||
},
|
||||
"node_modules/@vitejs/plugin-vue": {
|
||||
"version": "6.0.8",
|
||||
"resolved": "https://registry.npmmirror.com/@vitejs/plugin-vue/-/plugin-vue-6.0.8.tgz",
|
||||
@@ -1695,6 +1736,15 @@
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/base64-arraybuffer": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/base64-arraybuffer/-/base64-arraybuffer-1.0.2.tgz",
|
||||
"integrity": "sha512-I3yl4r9QB5ZRY3XuJVEPfc2XhZO6YweFPI+UovAzn+8/hb3oJ6lnysaFcjVpkCPfVWFUDvoZ8kmVDP7WyRtYtQ==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.6.0"
|
||||
}
|
||||
},
|
||||
"node_modules/baseline-browser-mapping": {
|
||||
"version": "2.11.0",
|
||||
"resolved": "https://registry.npmmirror.com/baseline-browser-mapping/-/baseline-browser-mapping-2.11.0.tgz",
|
||||
@@ -1825,6 +1875,26 @@
|
||||
],
|
||||
"license": "CC-BY-4.0"
|
||||
},
|
||||
"node_modules/canvg": {
|
||||
"version": "3.0.11",
|
||||
"resolved": "https://registry.npmjs.org/canvg/-/canvg-3.0.11.tgz",
|
||||
"integrity": "sha512-5ON+q7jCTgMp9cjpu4Jo6XbvfYwSB2Ow3kzHKfIyJfaCAOHLbdKPQqGKgfED/R5B+3TFFfe8pegYA+b423SRyA==",
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.12.5",
|
||||
"@types/raf": "^3.4.0",
|
||||
"core-js": "^3.8.3",
|
||||
"raf": "^3.4.1",
|
||||
"regenerator-runtime": "^0.13.7",
|
||||
"rgbcolor": "^1.0.1",
|
||||
"stackblur-canvas": "^2.0.0",
|
||||
"svg-pathdata": "^6.0.3"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=10.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/cfb": {
|
||||
"version": "1.2.2",
|
||||
"resolved": "https://registry.npmmirror.com/cfb/-/cfb-1.2.2.tgz",
|
||||
@@ -1955,6 +2025,21 @@
|
||||
"url": "https://github.com/sponsors/mesqueeb"
|
||||
}
|
||||
},
|
||||
"node_modules/core-js": {
|
||||
"version": "3.50.0",
|
||||
"resolved": "https://registry.npmjs.org/core-js/-/core-js-3.50.0.tgz",
|
||||
"integrity": "sha512-BRWgOLKkFeCgRudR6zrs8p9XJZcE14grzKMMssoYrk6krtuEZ7MTKPIY5RzOnqsEKIR9kst7wNzphttraT+Yqw==",
|
||||
"hasInstallScript": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"engines": {
|
||||
"node": "*"
|
||||
},
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/core-js"
|
||||
}
|
||||
},
|
||||
"node_modules/crc-32": {
|
||||
"version": "1.2.2",
|
||||
"resolved": "https://registry.npmmirror.com/crc-32/-/crc-32-1.2.2.tgz",
|
||||
@@ -1994,6 +2079,15 @@
|
||||
"node": ">= 8"
|
||||
}
|
||||
},
|
||||
"node_modules/css-line-break": {
|
||||
"version": "2.1.0",
|
||||
"resolved": "https://registry.npmjs.org/css-line-break/-/css-line-break-2.1.0.tgz",
|
||||
"integrity": "sha512-FHcKFCZcAha3LwfVBhCQbW2nCNbkZXn7KVUJcsT5/P8YmfsVja0FMPJr0B903j/E69HUphKiV9iQArX8SDYA4w==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"utrie": "^1.0.2"
|
||||
}
|
||||
},
|
||||
"node_modules/css-tree": {
|
||||
"version": "3.2.1",
|
||||
"resolved": "https://registry.npmjs.org/css-tree/-/css-tree-3.2.1.tgz",
|
||||
@@ -2069,6 +2163,15 @@
|
||||
"integrity": "sha512-+HlytyjlPKnIG8XuRG8WvmBP8xs8P71y+SKKS6ZXWoEgLuePxtDoUEiH7WkdePWrQ5JBpE6aoVqfZfJUQkjXwA==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/dompurify": {
|
||||
"version": "3.4.13",
|
||||
"resolved": "https://registry.npmjs.org/dompurify/-/dompurify-3.4.13.tgz",
|
||||
"integrity": "sha512-2vmYIoqjze2d+kakP8S/nS5shfsl587kzwEjcGlTdiksUVgFHnFCsLYDVj/JNqJVOQZGSYBTmuycv0PodwmnMQ==",
|
||||
"license": "(MPL-2.0 OR Apache-2.0)",
|
||||
"optionalDependencies": {
|
||||
"@types/trusted-types": "^2.0.7"
|
||||
}
|
||||
},
|
||||
"node_modules/eastasianwidth": {
|
||||
"version": "0.2.0",
|
||||
"resolved": "https://registry.npmjs.org/eastasianwidth/-/eastasianwidth-0.2.0.tgz",
|
||||
@@ -2205,6 +2308,17 @@
|
||||
"node": ">= 6"
|
||||
}
|
||||
},
|
||||
"node_modules/fast-png": {
|
||||
"version": "6.4.0",
|
||||
"resolved": "https://registry.npmjs.org/fast-png/-/fast-png-6.4.0.tgz",
|
||||
"integrity": "sha512-kAqZq1TlgBjZcLr5mcN6NP5Rv4V2f22z00c3g8vRrwkcqjerx7BEhPbOnWCPqaHUl2XWQBJQvOT/FQhdMT7X/Q==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@types/pako": "^2.0.3",
|
||||
"iobuffer": "^5.3.2",
|
||||
"pako": "^2.1.0"
|
||||
}
|
||||
},
|
||||
"node_modules/fastq": {
|
||||
"version": "1.20.1",
|
||||
"resolved": "https://registry.npmmirror.com/fastq/-/fastq-1.20.1.tgz",
|
||||
@@ -2231,6 +2345,12 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/fflate": {
|
||||
"version": "0.8.3",
|
||||
"resolved": "https://registry.npmjs.org/fflate/-/fflate-0.8.3.tgz",
|
||||
"integrity": "sha512-tbZNuJrLwGUp3zshBtdy4W+ORxZuIh8a5ilyIEQDC5rY1f3U20JMry0Ll3WBzU58EZKsEuJFXhb5gwv8CsPvgA==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/fill-range": {
|
||||
"version": "7.1.1",
|
||||
"resolved": "https://registry.npmmirror.com/fill-range/-/fill-range-7.1.1.tgz",
|
||||
@@ -2380,6 +2500,30 @@
|
||||
"node": "^20.19.0 || ^22.12.0 || >=24.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/html2canvas": {
|
||||
"version": "1.4.1",
|
||||
"resolved": "https://registry.npmjs.org/html2canvas/-/html2canvas-1.4.1.tgz",
|
||||
"integrity": "sha512-fPU6BHNpsyIhr8yyMpTLLxAbkaK8ArIBcmZIRiBLiDhjeqvXolaEmDGmELFuX9I4xDcaKKcJl+TKZLqruBbmWA==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"css-line-break": "^2.1.0",
|
||||
"text-segmentation": "^1.0.3"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=8.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/html2pdf.js": {
|
||||
"version": "0.14.0",
|
||||
"resolved": "https://registry.npmjs.org/html2pdf.js/-/html2pdf.js-0.14.0.tgz",
|
||||
"integrity": "sha512-yvNJgE/8yru2UeGflkPdjW8YEY+nDH5X7/2WG4uiuSCwYiCp8PZ8EKNiTAa6HxJ1NjC51fZSIEq6xld5CADKBQ==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"dompurify": "^3.3.1",
|
||||
"html2canvas": "^1.0.0",
|
||||
"jspdf": "^4.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/ini": {
|
||||
"version": "1.3.8",
|
||||
"resolved": "https://registry.npmjs.org/ini/-/ini-1.3.8.tgz",
|
||||
@@ -2387,6 +2531,12 @@
|
||||
"dev": true,
|
||||
"license": "ISC"
|
||||
},
|
||||
"node_modules/iobuffer": {
|
||||
"version": "5.4.0",
|
||||
"resolved": "https://registry.npmjs.org/iobuffer/-/iobuffer-5.4.0.tgz",
|
||||
"integrity": "sha512-DRebOWuqDvxunfkNJAlc3IzWIPD5xVxwUNbHr7xKB8E6aLJxIPfNX3CoMJghcFjpv6RWQsrcJbghtEwSPoJqMA==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/is-binary-path": {
|
||||
"version": "2.1.0",
|
||||
"resolved": "https://registry.npmmirror.com/is-binary-path/-/is-binary-path-2.1.0.tgz",
|
||||
@@ -2575,6 +2725,23 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/jspdf": {
|
||||
"version": "4.2.1",
|
||||
"resolved": "https://registry.npmjs.org/jspdf/-/jspdf-4.2.1.tgz",
|
||||
"integrity": "sha512-YyAXyvnmjTbR4bHQRLzex3CuINCDlQnBqoSYyjJwTP2x9jDLuKDzy7aKUl0hgx3uhcl7xzg32agn5vlie6HIlQ==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.28.6",
|
||||
"fast-png": "^6.2.0",
|
||||
"fflate": "^0.8.1"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"canvg": "^3.0.11",
|
||||
"core-js": "^3.6.0",
|
||||
"dompurify": "^3.3.1",
|
||||
"html2canvas": "^1.0.0-rc.5"
|
||||
}
|
||||
},
|
||||
"node_modules/lightningcss": {
|
||||
"version": "1.33.0",
|
||||
"resolved": "https://registry.npmmirror.com/lightningcss/-/lightningcss-1.33.0.tgz",
|
||||
@@ -3102,6 +3269,22 @@
|
||||
"dev": true,
|
||||
"license": "BlueOak-1.0.0"
|
||||
},
|
||||
"node_modules/pako": {
|
||||
"version": "2.2.0",
|
||||
"resolved": "https://registry.npmjs.org/pako/-/pako-2.2.0.tgz",
|
||||
"integrity": "sha512-zJq6RP/5q+TO2OpFV3FHzlPnFjmkb7Nc99a5SNjJE+uu/PkpChs+NIZSSzbBoD+6kjiISXjfYdwj1ZRQ81dz/w==",
|
||||
"funding": [
|
||||
{
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/puzrin"
|
||||
},
|
||||
{
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/nodeca"
|
||||
}
|
||||
],
|
||||
"license": "(MIT AND Zlib)"
|
||||
},
|
||||
"node_modules/parse5": {
|
||||
"version": "8.0.1",
|
||||
"resolved": "https://registry.npmjs.org/parse5/-/parse5-8.0.1.tgz",
|
||||
@@ -3201,6 +3384,13 @@
|
||||
"integrity": "sha512-xCy9V055GLEqoFaHoC1SoLIaLmWctgCUaBaWxDZ7/Zx4CTyX7cJQLJOok/orfjZAh9kEYpjJa4d0KcJmCbctZA==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/performance-now": {
|
||||
"version": "2.1.0",
|
||||
"resolved": "https://registry.npmjs.org/performance-now/-/performance-now-2.1.0.tgz",
|
||||
"integrity": "sha512-7EAHlyLHI56VEIdK57uwHdHKIaAGbnXPiw0yWbarQZOKaKpvUIgW0jWRVLiatnM+XXlSwsanIBH/hzGMJulMow==",
|
||||
"license": "MIT",
|
||||
"optional": true
|
||||
},
|
||||
"node_modules/picocolors": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmmirror.com/picocolors/-/picocolors-1.1.1.tgz",
|
||||
@@ -3469,6 +3659,16 @@
|
||||
],
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/raf": {
|
||||
"version": "3.4.1",
|
||||
"resolved": "https://registry.npmjs.org/raf/-/raf-3.4.1.tgz",
|
||||
"integrity": "sha512-Sq4CW4QhwOHE8ucn6J34MqtZCeWFP2aQSmrlroYgqAV1PjStIhJXxYuTgUIfkEk7zTLjmIjLmU5q+fbD1NnOJA==",
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"dependencies": {
|
||||
"performance-now": "^2.1.0"
|
||||
}
|
||||
},
|
||||
"node_modules/read-cache": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmmirror.com/read-cache/-/read-cache-1.0.0.tgz",
|
||||
@@ -3502,6 +3702,13 @@
|
||||
"url": "https://github.com/sponsors/jonschlinkert"
|
||||
}
|
||||
},
|
||||
"node_modules/regenerator-runtime": {
|
||||
"version": "0.13.11",
|
||||
"resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.13.11.tgz",
|
||||
"integrity": "sha512-kY1AZVr2Ra+t+piVaJ4gxaFaReZVH40AKNo7UCX6W+dEwBo/2oZJzqfuN1qLq1oL45o56cPaTXELwrTh8Fpggg==",
|
||||
"license": "MIT",
|
||||
"optional": true
|
||||
},
|
||||
"node_modules/require-from-string": {
|
||||
"version": "2.0.2",
|
||||
"resolved": "https://registry.npmjs.org/require-from-string/-/require-from-string-2.0.2.tgz",
|
||||
@@ -3549,6 +3756,16 @@
|
||||
"integrity": "sha512-q1b3N5QkRUWUl7iyylaaj3kOpIT0N2i9MqIEQXP73GVsN9cw3fdx8X63cEmWhJGi2PPCF23Ijp7ktmd39rawIA==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/rgbcolor": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/rgbcolor/-/rgbcolor-1.0.1.tgz",
|
||||
"integrity": "sha512-9aZLIrhRaD97sgVhtJOW6ckOEh6/GnvQtdVNfdZ6s67+3/XwLS9lBcQYzEEhYVeUowN7pRzMLsyGhK2i/xvWbw==",
|
||||
"license": "MIT OR SEE LICENSE IN FEEL-FREE.md",
|
||||
"optional": true,
|
||||
"engines": {
|
||||
"node": ">= 0.8.15"
|
||||
}
|
||||
},
|
||||
"node_modules/rolldown": {
|
||||
"version": "1.1.5",
|
||||
"resolved": "https://registry.npmmirror.com/rolldown/-/rolldown-1.1.5.tgz",
|
||||
@@ -3712,6 +3929,16 @@
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/stackblur-canvas": {
|
||||
"version": "2.7.0",
|
||||
"resolved": "https://registry.npmjs.org/stackblur-canvas/-/stackblur-canvas-2.7.0.tgz",
|
||||
"integrity": "sha512-yf7OENo23AGJhBriGx0QivY5JP6Y1HbrrDI6WLt6C5auYZXlQrheoY8hD4ibekFKz1HOfE48Ww8kMWMnJD/zcQ==",
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"engines": {
|
||||
"node": ">=0.1.14"
|
||||
}
|
||||
},
|
||||
"node_modules/std-env": {
|
||||
"version": "4.2.0",
|
||||
"resolved": "https://registry.npmmirror.com/std-env/-/std-env-4.2.0.tgz",
|
||||
@@ -3869,6 +4096,16 @@
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"node_modules/svg-pathdata": {
|
||||
"version": "6.0.3",
|
||||
"resolved": "https://registry.npmjs.org/svg-pathdata/-/svg-pathdata-6.0.3.tgz",
|
||||
"integrity": "sha512-qsjeeq5YjBZ5eMdFuUa4ZosMLxgr5RZ+F+Y1OrDhuOCEInRMA3x74XdBtggJcj9kOeInz0WE+LgCPDkZFlBYJw==",
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"engines": {
|
||||
"node": ">=12.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/symbol-tree": {
|
||||
"version": "3.2.4",
|
||||
"resolved": "https://registry.npmjs.org/symbol-tree/-/symbol-tree-3.2.4.tgz",
|
||||
@@ -3926,6 +4163,15 @@
|
||||
"node": ">=4"
|
||||
}
|
||||
},
|
||||
"node_modules/text-segmentation": {
|
||||
"version": "1.0.3",
|
||||
"resolved": "https://registry.npmjs.org/text-segmentation/-/text-segmentation-1.0.3.tgz",
|
||||
"integrity": "sha512-iOiPUo/BGnZ6+54OsWxZidGCsdU8YbE4PSpdPinp7DeMtUJNJBoJ/ouUSTJjHkh1KntHaltHl/gDs2FC4i5+Nw==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"utrie": "^1.0.2"
|
||||
}
|
||||
},
|
||||
"node_modules/thenify": {
|
||||
"version": "3.3.1",
|
||||
"resolved": "https://registry.npmmirror.com/thenify/-/thenify-3.3.1.tgz",
|
||||
@@ -4130,6 +4376,15 @@
|
||||
"integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/utrie": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/utrie/-/utrie-1.0.2.tgz",
|
||||
"integrity": "sha512-1MLa5ouZiOmQzUbjbu9VmjLzn1QLXBhwpUa7kdLUQK+KQ5KA9I1vk5U4YHe/X2Ch7PYnJfWuWT+VbuxbGwljhw==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"base64-arraybuffer": "^1.0.2"
|
||||
}
|
||||
},
|
||||
"node_modules/vite": {
|
||||
"version": "8.1.5",
|
||||
"resolved": "https://registry.npmmirror.com/vite/-/vite-8.1.5.tgz",
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
"@vue-office/pdf": "^1.6.5",
|
||||
"cron-parser": "^5.5.0",
|
||||
"highlight.js": "^11.11.1",
|
||||
"html2pdf.js": "^0.14.0",
|
||||
"lucide-vue-next": "^0.575.0",
|
||||
"marked": "^17.0.3",
|
||||
"pdfjs-dist": "^5.6.205",
|
||||
@@ -28,6 +29,7 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^24.10.1",
|
||||
"@types/pdfjs-dist": "^2.10.377",
|
||||
"@vitejs/plugin-vue": "^6.0.2",
|
||||
"@vue/test-utils": "^2.4.11",
|
||||
"@vue/tsconfig": "^0.8.1",
|
||||
|
||||
@@ -205,6 +205,7 @@ function mapTrainingRecord(data: TrainingRecordApi): TrainingRecord {
|
||||
score: progress.score,
|
||||
attempts: progress.attempts,
|
||||
status: progress.status,
|
||||
answerDetails: progress.answerDetails,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -16,12 +16,12 @@ import {
|
||||
ChevronUp,
|
||||
ClipboardCheck,
|
||||
Download,
|
||||
FileText,
|
||||
PlayCircle,
|
||||
RefreshCcw,
|
||||
ShieldCheck,
|
||||
Target,
|
||||
User,
|
||||
FileText,
|
||||
Video,
|
||||
Lock,
|
||||
XCircle,
|
||||
@@ -30,6 +30,9 @@ import { useTrainingWorkspace } from '@/features/chat/composables/useTrainingWor
|
||||
import FilePreviewModal from '@/shared/components/FilePreviewModal.vue';
|
||||
import { useMessage } from '@/shared/composables/useMessage';
|
||||
import { resolveTrainingExamPdfGuide, type TrainingGuideLike } from '@/features/chat/training/trainingWorkspace.utils';
|
||||
import { getMyTrainingConfig } from '@/features/chat/api/training.api';
|
||||
import type { TrainingRecord } from '@/features/chat/training/training.types';
|
||||
import html2pdf from 'html2pdf.js';
|
||||
|
||||
import { getAuthHeaders } from '@/shared/utils/auth';
|
||||
|
||||
@@ -98,6 +101,74 @@ const handleVideoEnded = () => {
|
||||
workspace.stopMaterialTimer();
|
||||
};
|
||||
|
||||
const reportModalVisible = ref(false);
|
||||
const currentReportRecord = ref<TrainingRecord | null>(null);
|
||||
const reportQuestions = ref<Record<string, any>>({});
|
||||
const reportLoading = ref(false);
|
||||
|
||||
const openReport = async (record: TrainingRecord) => {
|
||||
currentReportRecord.value = record;
|
||||
reportModalVisible.value = true;
|
||||
reportLoading.value = true;
|
||||
try {
|
||||
const config = await getMyTrainingConfig(record.trainingType || 'onboarding');
|
||||
const qMap: Record<string, any> = {};
|
||||
if (config?.resources) {
|
||||
config.resources.forEach(r => {
|
||||
if (Array.isArray(r.inlineQuestions)) {
|
||||
r.inlineQuestions.forEach((q: any) => {
|
||||
qMap[q.id] = q;
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
reportQuestions.value = qMap;
|
||||
} catch (err) {
|
||||
console.error('Failed to load config for report', err);
|
||||
} finally {
|
||||
reportLoading.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
const closeReport = () => {
|
||||
reportModalVisible.value = false;
|
||||
currentReportRecord.value = null;
|
||||
};
|
||||
|
||||
const printReport = async () => {
|
||||
const element = document.getElementById('report-modal-content');
|
||||
const report = currentReportRecord.value;
|
||||
if (!element || !report) return;
|
||||
const fileName = `${report.name}_${report.trainingType === 'onboarding' ? t('chat.training.hr.filters.typeOnboarding') : report.trainingType === 'safety' ? t('chat.training.hr.filters.typeSafety') : report.trainingType}_考试报告.pdf`;
|
||||
|
||||
const opt = {
|
||||
margin: [15, 15, 15, 15] as [number, number, number, number],
|
||||
filename: fileName,
|
||||
image: { type: 'jpeg' as const, quality: 0.98 },
|
||||
html2canvas: {
|
||||
scale: 2,
|
||||
useCORS: true,
|
||||
letterRendering: true,
|
||||
windowWidth: 794,
|
||||
scrollX: 0,
|
||||
scrollY: 0,
|
||||
},
|
||||
pagebreak: {
|
||||
mode: ['css', 'legacy'] as const,
|
||||
avoid: ['.report-question', '.report-header-info', '.report-option'] as string[],
|
||||
},
|
||||
jsPDF: { unit: 'mm', format: 'a4', orientation: 'portrait' as const }
|
||||
};
|
||||
|
||||
try {
|
||||
await html2pdf().set(opt).from(element).save();
|
||||
msg.success(t('chat.training.hr.report.downloadSuccess') || 'PDF 下载成功');
|
||||
} catch (error) {
|
||||
console.error('Failed to generate PDF:', error);
|
||||
msg.error(t('chat.training.hr.report.downloadFailed') || 'PDF 生成失败');
|
||||
}
|
||||
};
|
||||
|
||||
const reportVideoDebugEvent = (event: Event) => {
|
||||
const video = event.target as HTMLVideoElement;
|
||||
// #region debug-point A-E:ios-video-runtime
|
||||
@@ -247,6 +318,36 @@ const isMaterialCompleted = (material: any) => {
|
||||
|
||||
const currentPreviewVideoUrl = ref('');
|
||||
|
||||
const videoCountdownSeconds = ref(0);
|
||||
let videoCountdownTimer: ReturnType<typeof setInterval> | null = null;
|
||||
|
||||
const startVideoCountdown = () => {
|
||||
if (videoCountdownTimer) {
|
||||
clearInterval(videoCountdownTimer);
|
||||
videoCountdownTimer = null;
|
||||
}
|
||||
const requiredDuration = workspace.currentViewingMaterialRequiredDuration;
|
||||
if (requiredDuration && requiredDuration > 0) {
|
||||
videoCountdownSeconds.value = requiredDuration * 60;
|
||||
videoCountdownTimer = setInterval(() => {
|
||||
if (videoCountdownSeconds.value > 0) {
|
||||
videoCountdownSeconds.value--;
|
||||
} else {
|
||||
if (videoCountdownTimer) clearInterval(videoCountdownTimer);
|
||||
}
|
||||
}, 1000);
|
||||
} else {
|
||||
videoCountdownSeconds.value = 0;
|
||||
}
|
||||
};
|
||||
|
||||
const stopVideoCountdown = () => {
|
||||
if (videoCountdownTimer) {
|
||||
clearInterval(videoCountdownTimer);
|
||||
videoCountdownTimer = null;
|
||||
}
|
||||
};
|
||||
|
||||
const handleMaterialClick = (material: any) => {
|
||||
const url = material.resource?.fileUrl;
|
||||
if (!url) {
|
||||
@@ -255,18 +356,18 @@ const handleMaterialClick = (material: any) => {
|
||||
}
|
||||
|
||||
if (material.resource?.fileType === 'video') {
|
||||
workspace.currentViewingMaterialId = material.id;
|
||||
workspace.showVideoModal = true;
|
||||
currentPreviewVideoUrl.value = url;
|
||||
// 当点击视频资料时,我们应该记录正在观看的资源ID,以便后续更新进度
|
||||
workspace.currentViewingMaterialId = material.id;
|
||||
startVideoCountdown();
|
||||
} else {
|
||||
workspace.currentViewingMaterialId = material.id;
|
||||
previewFile.value = {
|
||||
name: material.title || material.resource?.fileName || '资料预览',
|
||||
url: url,
|
||||
actualExt: material.resource?.fileType,
|
||||
};
|
||||
showFilePreview.value = true;
|
||||
workspace.currentViewingMaterialId = material.id;
|
||||
}
|
||||
workspace.startMaterialTimer(material.id);
|
||||
};
|
||||
@@ -281,6 +382,7 @@ const handlePreviewClose = (val: boolean) => {
|
||||
const handleVideoModalClose = () => {
|
||||
workspace.showVideoModal = false;
|
||||
currentPreviewVideoUrl.value = '';
|
||||
stopVideoCountdown();
|
||||
workspace.stopMaterialTimer();
|
||||
};
|
||||
const jumpToExamQuestion = (index: number) => {
|
||||
@@ -858,10 +960,6 @@ const currentSafetyStageText = computed(() => {
|
||||
{{ $t('chat.training.safety.progressHint') }}
|
||||
</div>
|
||||
</div>
|
||||
<div class="rounded-lg bg-surface-soft px-2.5 py-1 text-center">
|
||||
<div class="text-xs text-muted">{{ $t('chat.training.progressPercent') }}</div>
|
||||
<div class="text-base font-semibold leading-none text-primary">{{ workspace.safetyProgressPercent }}%</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mt-2 grid grid-cols-2 gap-1 lg:grid-cols-4">
|
||||
@@ -1269,11 +1367,13 @@ const currentSafetyStageText = computed(() => {
|
||||
<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.trainingType') }}</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.trainingReport') }}</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>
|
||||
@@ -1281,11 +1381,18 @@ const currentSafetyStageText = computed(() => {
|
||||
<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.trainingType === 'onboarding' ? $t('chat.training.hr.filters.typeOnboarding') : record.trainingType === 'safety' ? $t('chat.training.hr.filters.typeSafety') : (record.trainingType || '--') }}</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 text-secondary">
|
||||
<button v-if="record.status === 'passed' || record.status === 'failed'" @click="openReport(record)" class="text-brand-600 hover:text-brand-700 transition" :title="$t('chat.training.hr.report.title')">
|
||||
<FileText class="w-5 h-5" />
|
||||
</button>
|
||||
<span v-else class="text-muted">--</span>
|
||||
</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"
|
||||
@@ -1314,9 +1421,14 @@ const currentSafetyStageText = computed(() => {
|
||||
<Teleport to="body">
|
||||
<div v-if="workspace.showVideoModal" class="fixed inset-0 z-[100] flex items-center justify-center bg-slate-950/80 p-4 backdrop-blur-sm" @click.self="handleVideoModalClose">
|
||||
<div class="relative w-full max-w-4xl overflow-hidden rounded-3xl bg-black shadow-2xl">
|
||||
<button @click="handleVideoModalClose" 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="absolute top-4 right-4 z-10 flex items-center gap-2">
|
||||
<div v-if="videoCountdownSeconds > 0" class="flex items-center justify-center h-10 w-10 rounded-full border border-red-200 bg-red-50 text-red-500 font-semibold text-xs shadow-sm backdrop-blur-md">
|
||||
{{ videoCountdownSeconds }}s
|
||||
</div>
|
||||
<button @click="handleVideoModalClose" class="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>
|
||||
<div class="aspect-video bg-black">
|
||||
<video
|
||||
controls
|
||||
@@ -1346,7 +1458,199 @@ const currentSafetyStageText = computed(() => {
|
||||
:file="previewFile"
|
||||
:agent-id="workspace.currentTrainingAgentId || undefined"
|
||||
:auth-headers="getAuthHeaders()"
|
||||
:required-duration="workspace.currentViewingMaterialRequiredDuration"
|
||||
@update:modelValue="handlePreviewClose"
|
||||
/>
|
||||
|
||||
<div v-if="reportModalVisible" class="fixed inset-0 z-[100] flex items-center justify-center bg-slate-950/80 p-4 backdrop-blur-sm" @click.self="closeReport">
|
||||
<div class="relative w-full max-w-4xl max-h-[90vh] flex flex-col overflow-hidden rounded-3xl bg-white shadow-2xl">
|
||||
<div class="flex items-center justify-between border-b border-default px-6 py-4">
|
||||
<h3 class="text-lg font-semibold text-primary">{{ $t('chat.training.hr.report.title') }}</h3>
|
||||
<div class="flex items-center gap-3">
|
||||
<button @click="printReport" class="flex items-center gap-2 rounded-xl bg-brand-50 px-4 py-2 text-sm font-medium text-brand-600 transition hover:bg-brand-100">
|
||||
<Download class="w-4 h-4" />
|
||||
{{ $t('chat.training.hr.report.download') }}
|
||||
</button>
|
||||
<button @click="closeReport" class="flex h-8 w-8 items-center justify-center rounded-full bg-surface-soft text-secondary hover:bg-surface hover:text-primary transition">
|
||||
<XCircle class="h-5 w-5" />
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="flex-1 overflow-y-auto p-6 report-print-container" id="report-modal-content">
|
||||
<div class="report-pdf-page">
|
||||
<div v-if="reportLoading" class="flex h-full items-center justify-center">
|
||||
<div class="h-8 w-8 animate-spin rounded-full border-4 border-brand-200 border-t-brand-600"></div>
|
||||
</div>
|
||||
<div v-else-if="currentReportRecord">
|
||||
<!-- Header Info -->
|
||||
<div class="report-header-info mb-8 rounded-2xl bg-surface-soft p-6">
|
||||
<h2 class="mb-4 text-center text-2xl font-bold text-primary">{{ currentReportRecord.trainingType === 'onboarding' ? $t('chat.training.hr.filters.typeOnboarding') : currentReportRecord.trainingType === 'safety' ? $t('chat.training.hr.filters.typeSafety') : currentReportRecord.trainingType }} {{ $t('chat.training.hr.report.title') }}</h2>
|
||||
<div class="grid grid-cols-2 gap-4 sm:grid-cols-4">
|
||||
<div>
|
||||
<div class="text-xs text-secondary">{{ $t('chat.training.hr.columns.name') }}</div>
|
||||
<div class="font-medium text-primary">{{ currentReportRecord.name }}</div>
|
||||
</div>
|
||||
<div>
|
||||
<div class="text-xs text-secondary">{{ $t('chat.training.hr.columns.department') }}</div>
|
||||
<div class="font-medium text-primary">{{ currentReportRecord.department }}</div>
|
||||
</div>
|
||||
<div>
|
||||
<div class="text-xs text-secondary">{{ $t('chat.training.hr.columns.employeeId') }}</div>
|
||||
<div class="font-medium text-primary">{{ currentReportRecord.employeeId }}</div>
|
||||
</div>
|
||||
<div>
|
||||
<div class="text-xs text-secondary">{{ $t('chat.training.hr.columns.score') }}</div>
|
||||
<div class="font-medium" :class="currentReportRecord.status === 'passed' ? 'text-emerald-600' : 'text-rose-600'">
|
||||
{{ currentReportRecord.score ?? '--' }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Exam Details -->
|
||||
<div class="space-y-6">
|
||||
<div v-for="(answer, idx) in currentReportRecord.answerDetails || []" :key="answer.questionId" class="report-question rounded-xl border border-default p-4">
|
||||
<div class="report-question-header mb-3">
|
||||
<div class="report-question-title font-medium text-primary">
|
||||
<span class="mr-2 text-secondary">{{ idx + 1 }}.</span>
|
||||
{{ reportQuestions[answer.questionId]?.prompt || `[ID: ${answer.questionId}]` }}
|
||||
</div>
|
||||
<div class="report-question-result">
|
||||
<span v-if="answer.correct" class="inline-flex rounded-full bg-emerald-50 px-2 py-1 text-xs font-semibold text-emerald-700">正确</span>
|
||||
<span v-else class="inline-flex rounded-full bg-rose-50 px-2 py-1 text-xs font-semibold text-rose-700">错误</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="report-options pl-6">
|
||||
<div v-for="(opt, optIdx) in reportQuestions[answer.questionId]?.options || []" :key="opt.id"
|
||||
class="report-option text-sm"
|
||||
:class="{
|
||||
'font-semibold text-emerald-600': opt.id === reportQuestions[answer.questionId]?.answer,
|
||||
'text-rose-600': !answer.correct && opt.id === answer.selectedOptionId,
|
||||
'text-secondary': opt.id !== reportQuestions[answer.questionId]?.answer && opt.id !== answer.selectedOptionId
|
||||
}"
|
||||
>
|
||||
<span class="report-option-marker"
|
||||
:class="{
|
||||
'border-emerald-200 bg-emerald-50 text-emerald-600': opt.id === reportQuestions[answer.questionId]?.answer,
|
||||
'border-rose-200 bg-rose-50 text-rose-600': !answer.correct && opt.id === answer.selectedOptionId,
|
||||
'border-default': opt.id !== reportQuestions[answer.questionId]?.answer && opt.id !== answer.selectedOptionId
|
||||
}"
|
||||
> {{ String.fromCharCode(65 + Number(optIdx)) }}</span>
|
||||
<span class="report-option-text">{{ opt.label }}</span>
|
||||
</div>
|
||||
|
||||
<div v-if="!reportQuestions[answer.questionId]" class="text-sm text-secondary">
|
||||
<div class="mb-1">Selected Option: {{ answer.selectedOptionId }}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="!currentReportRecord.answerDetails?.length" class="text-center text-sm text-secondary py-8">
|
||||
{{ $t('chat.training.hr.report.noReport') }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</Teleport>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.report-pdf-page {
|
||||
width: 100%;
|
||||
max-width: 794px;
|
||||
min-height: 1123px;
|
||||
margin: 0 auto;
|
||||
box-sizing: border-box;
|
||||
background: #fff;
|
||||
}
|
||||
|
||||
.report-question-header {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(0, 1fr) auto;
|
||||
align-items: start;
|
||||
gap: 1rem;
|
||||
}
|
||||
|
||||
.report-question-title {
|
||||
min-width: 0;
|
||||
overflow-wrap: anywhere;
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
.report-question-result {
|
||||
flex-shrink: 0;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.report-options {
|
||||
display: grid;
|
||||
gap: 0.5rem;
|
||||
}
|
||||
|
||||
.report-header-info,
|
||||
.report-question,
|
||||
.report-option {
|
||||
break-inside: avoid;
|
||||
page-break-inside: avoid;
|
||||
}
|
||||
|
||||
.report-question {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.report-option {
|
||||
display: grid;
|
||||
grid-template-columns: 1.25rem minmax(0, 1fr);
|
||||
align-items: start;
|
||||
column-gap: 0.5rem;
|
||||
min-width: 0;
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
.report-option-marker {
|
||||
display: inline-flex;
|
||||
width: 1.25rem;
|
||||
height: 1.25rem;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
flex-shrink: 0;
|
||||
border-width: 1px;
|
||||
border-radius: 9999px;
|
||||
font-size: 0.75rem;
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
.report-option-text {
|
||||
min-width: 0;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
@media print {
|
||||
body > *:not(.report-print-container) {
|
||||
display: none !important;
|
||||
}
|
||||
.report-print-container {
|
||||
position: absolute !important;
|
||||
left: 0 !important;
|
||||
top: 0 !important;
|
||||
width: 794px !important;
|
||||
max-width: none !important;
|
||||
min-height: 1123px !important;
|
||||
margin: 0 !important;
|
||||
padding: 0 !important;
|
||||
overflow: visible !important;
|
||||
background: white !important;
|
||||
}
|
||||
.report-pdf-page {
|
||||
width: 794px !important;
|
||||
max-width: none !important;
|
||||
min-height: 1123px !important;
|
||||
margin: 0 !important;
|
||||
padding: 32px !important;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -273,12 +273,26 @@ export function useTrainingWorkspace(options: UseTrainingWorkspaceOptions) {
|
||||
));
|
||||
const canEnterResultStage = computed(() => stage.value === 'result');
|
||||
const safetyProgressPercent = computed(() => {
|
||||
if (safetyStage.value === 'company') return 25;
|
||||
if (safetyStage.value === 'department') return 50;
|
||||
if (safetyStage.value === 'team') return 75;
|
||||
if (safetyStage.value === 'exam') return 90;
|
||||
return 100;
|
||||
if (safetyStage.value === 'result') return 100;
|
||||
|
||||
let completedCount = 0;
|
||||
if (isStageCompleted('company')) completedCount++;
|
||||
if (isStageCompleted('department')) completedCount++;
|
||||
if (isStageCompleted('team')) completedCount++;
|
||||
|
||||
return Math.round((completedCount / 3) * 75) || 10; // Start at 10% or just based on completed
|
||||
});
|
||||
const isStageCompleted = (stageKey: SafetyLearningStage) => {
|
||||
const materials = resolveSafetyStageMaterials(stageKey);
|
||||
if (!materials.length) return true;
|
||||
return materials.every(m => {
|
||||
if (m.id == null) return true;
|
||||
const progress = safetyProgress.value.resource_progress?.[String(m.id)];
|
||||
return progress?.completed;
|
||||
});
|
||||
};
|
||||
|
||||
const safetyStepItems = computed(() => {
|
||||
const base: Array<{ id: SafetyStage extends infer U ? U : never; labelKey: string }> = [
|
||||
{ id: 'company', labelKey: 'chat.training.safety.steps.company' },
|
||||
@@ -288,26 +302,22 @@ export function useTrainingWorkspace(options: UseTrainingWorkspaceOptions) {
|
||||
];
|
||||
return base.map((item) => {
|
||||
let status: 'completed' | 'active' | 'pending' | 'locked' = 'pending';
|
||||
if (item.id === 'company') {
|
||||
status = safetyProgress.value.company === 'completed'
|
||||
? 'completed'
|
||||
: safetyProgress.value.company === 'active' ? 'active' : 'pending';
|
||||
} else if (item.id === 'department') {
|
||||
status = safetyProgress.value.department === 'completed'
|
||||
? 'completed'
|
||||
: safetyProgress.value.department === 'active' ? 'active' : 'pending';
|
||||
} else if (item.id === 'team') {
|
||||
status = safetyProgress.value.team === 'completed'
|
||||
? 'completed'
|
||||
: safetyProgress.value.team === 'active' ? 'active' : 'pending';
|
||||
if (item.id === 'company' || item.id === 'department' || item.id === 'team') {
|
||||
const completed = isStageCompleted(item.id);
|
||||
if (safetyViewStage.value === item.id) {
|
||||
status = 'active';
|
||||
} else if (completed) {
|
||||
status = 'completed';
|
||||
} else {
|
||||
status = 'pending';
|
||||
}
|
||||
} else if (item.id === 'exam') {
|
||||
status = ['exam', 'result'].includes(safetyStage.value)
|
||||
? (safetyStage.value === 'exam' ? 'active' : 'completed')
|
||||
: (safetyProgress.value.company === 'completed'
|
||||
&& safetyProgress.value.department === 'completed'
|
||||
&& safetyProgress.value.team === 'completed'
|
||||
? 'pending'
|
||||
: 'locked');
|
||||
const allCompleted = isStageCompleted('company') && isStageCompleted('department') && isStageCompleted('team');
|
||||
if (['exam', 'result'].includes(safetyStage.value)) {
|
||||
status = safetyStage.value === 'exam' ? 'active' : 'completed';
|
||||
} else {
|
||||
status = allCompleted ? 'pending' : 'locked';
|
||||
}
|
||||
}
|
||||
return {
|
||||
id: item.id,
|
||||
@@ -519,8 +529,30 @@ export function useTrainingWorkspace(options: UseTrainingWorkspaceOptions) {
|
||||
examMode.value = record.examMode || 'unified';
|
||||
if (learnerTab.value === 'safety') {
|
||||
safetyStage.value = record.safetyStage || 'company';
|
||||
safetyProgress.value = record.safetyProgress;
|
||||
safetyViewStage.value = record.safetyStage || 'company';
|
||||
// Ensure resource_progress is preserved when merging from backend
|
||||
safetyProgress.value = {
|
||||
...record.safetyProgress,
|
||||
resource_progress: record.safetyProgress?.resource_progress || safetyProgress.value.resource_progress || {}
|
||||
};
|
||||
|
||||
// Sync legacy fields with actual resource completion
|
||||
safetyProgress.value.company = isStageCompleted('company') ? 'completed' : 'active';
|
||||
safetyProgress.value.department = isStageCompleted('department') ? 'completed' : 'active';
|
||||
safetyProgress.value.team = isStageCompleted('team') ? 'completed' : 'active';
|
||||
|
||||
if (safetyStage.value !== 'exam' && safetyStage.value !== 'result') {
|
||||
if (!isStageCompleted('company')) {
|
||||
safetyViewStage.value = 'company';
|
||||
} else if (!isStageCompleted('department')) {
|
||||
safetyViewStage.value = 'department';
|
||||
} else if (!isStageCompleted('team')) {
|
||||
safetyViewStage.value = 'team';
|
||||
} else {
|
||||
safetyViewStage.value = 'company';
|
||||
}
|
||||
} else {
|
||||
safetyViewStage.value = record.safetyStage || 'company';
|
||||
}
|
||||
}
|
||||
stage.value = record.stage;
|
||||
syncExamQuestionIndex(record.currentQuestionIndex);
|
||||
@@ -735,15 +767,7 @@ export function useTrainingWorkspace(options: UseTrainingWorkspaceOptions) {
|
||||
const markVideoCompleted = () => {
|
||||
if (!hasPublishedTrainingConfig.value || !videoUrl.value) return;
|
||||
if (learnerTab.value === 'safety') {
|
||||
if (safetyStage.value === 'company') {
|
||||
resetSafetyProgress('department');
|
||||
} else if (safetyStage.value === 'department') {
|
||||
resetSafetyProgress('team');
|
||||
} else if (safetyStage.value === 'team') {
|
||||
resetSafetyProgress('exam');
|
||||
enterSafetyExam();
|
||||
}
|
||||
void persistProgress();
|
||||
checkAndAdvanceStage();
|
||||
return;
|
||||
}
|
||||
stage.value = 'summary';
|
||||
@@ -861,7 +885,13 @@ export function useTrainingWorkspace(options: UseTrainingWorkspaceOptions) {
|
||||
if (!hasPublishedTrainingConfig.value) return;
|
||||
const target = safetyStepItems.value.find((item) => item.id === nextStage);
|
||||
if (!target || target.status === 'locked') return;
|
||||
safetyViewStage.value = nextStage;
|
||||
|
||||
if (nextStage === 'exam' && safetyStage.value !== 'exam' && safetyStage.value !== 'result') {
|
||||
enterSafetyExam();
|
||||
void persistProgress();
|
||||
} else {
|
||||
safetyViewStage.value = nextStage;
|
||||
}
|
||||
};
|
||||
|
||||
const exportRecords = async () => {
|
||||
@@ -930,6 +960,12 @@ export function useTrainingWorkspace(options: UseTrainingWorkspaceOptions) {
|
||||
const currentViewingMaterialId = ref<number | null>(null);
|
||||
const materialStartTime = ref<number>(0);
|
||||
|
||||
const currentViewingMaterialRequiredDuration = computed(() => {
|
||||
if (!currentViewingMaterialId.value) return 0;
|
||||
const resource = (publishedConfig.value?.resources || []).find((item) => String(item.id) === String(currentViewingMaterialId.value));
|
||||
return resource?.requiredDuration || 0;
|
||||
});
|
||||
|
||||
const startMaterialTimer = (materialId: number) => {
|
||||
currentViewingMaterialId.value = materialId;
|
||||
materialStartTime.value = Date.now();
|
||||
@@ -963,32 +999,32 @@ export function useTrainingWorkspace(options: UseTrainingWorkspaceOptions) {
|
||||
};
|
||||
|
||||
const checkAndAdvanceStage = () => {
|
||||
const activeStageMaterials = learnerTab.value === 'safety'
|
||||
? resolveSafetyStageMaterials(activeSafetyLearningStage.value)
|
||||
: publishedTrainingMaterials.value;
|
||||
if (!activeStageMaterials.length) return;
|
||||
const allCompleted = activeStageMaterials.every(m => {
|
||||
if (m.id == null) return true;
|
||||
const progress = safetyProgress.value.resource_progress?.[String(m.id)];
|
||||
return progress?.completed;
|
||||
});
|
||||
|
||||
if (allCompleted) {
|
||||
if (learnerTab.value === 'safety') {
|
||||
if (safetyStage.value === 'company') {
|
||||
resetSafetyProgress('department');
|
||||
} else if (safetyStage.value === 'department') {
|
||||
resetSafetyProgress('team');
|
||||
} else if (safetyStage.value === 'team') {
|
||||
resetSafetyProgress('exam');
|
||||
enterSafetyExam();
|
||||
}
|
||||
} else {
|
||||
stage.value = 'summary';
|
||||
}
|
||||
void persistProgress();
|
||||
// Update legacy string fields to reflect real status based on resources
|
||||
safetyProgress.value.company = isStageCompleted('company') ? 'completed' : 'active';
|
||||
safetyProgress.value.department = isStageCompleted('department') ? 'completed' : 'active';
|
||||
safetyProgress.value.team = isStageCompleted('team') ? 'completed' : 'active';
|
||||
|
||||
if (learnerTab.value === 'safety') {
|
||||
const allSafetyCompleted = isStageCompleted('company') && isStageCompleted('department') && isStageCompleted('team');
|
||||
|
||||
if (allSafetyCompleted && safetyStage.value !== 'exam' && safetyStage.value !== 'result') {
|
||||
safetyStage.value = 'exam';
|
||||
enterSafetyExam();
|
||||
}
|
||||
void persistProgress();
|
||||
} else {
|
||||
void persistProgress();
|
||||
const activeStageMaterials = publishedTrainingMaterials.value;
|
||||
if (!activeStageMaterials.length) return;
|
||||
const allCompleted = activeStageMaterials.every(m => {
|
||||
if (m.id == null) return true;
|
||||
const progress = safetyProgress.value.resource_progress?.[String(m.id)];
|
||||
return progress?.completed;
|
||||
});
|
||||
|
||||
if (allCompleted) {
|
||||
stage.value = 'summary';
|
||||
}
|
||||
void persistProgress();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1084,6 +1120,7 @@ export function useTrainingWorkspace(options: UseTrainingWorkspaceOptions) {
|
||||
startMaterialTimer,
|
||||
stopMaterialTimer,
|
||||
currentViewingMaterialId,
|
||||
currentViewingMaterialRequiredDuration,
|
||||
currentTrainingAgentId,
|
||||
};
|
||||
}
|
||||
@@ -102,6 +102,7 @@ export interface TrainingRecord {
|
||||
score: number | null;
|
||||
attempts: number;
|
||||
status: TrainingRecordStatus;
|
||||
answerDetails?: TrainingAnswerRecord[];
|
||||
}
|
||||
|
||||
export interface TrainingProgressRecord extends TrainingRecord {
|
||||
|
||||
@@ -1129,13 +1129,23 @@
|
||||
"columns": {
|
||||
"joinDate": "Join date",
|
||||
"completionDate": "Completion date",
|
||||
"trainingType": "Training Type",
|
||||
"department": "Department",
|
||||
"name": "Name",
|
||||
"employeeId": "Employee ID",
|
||||
"score": "Score",
|
||||
"attempts": "Attempts",
|
||||
"trainingReport": "Training Report",
|
||||
"status": "Status"
|
||||
},
|
||||
"report": {
|
||||
"title": "Exam Report",
|
||||
"download": "Download PDF",
|
||||
"noReport": "No Report",
|
||||
"downloading": "Generating PDF, please wait...",
|
||||
"downloadSuccess": "PDF downloaded successfully",
|
||||
"downloadFailed": "Failed to generate PDF"
|
||||
},
|
||||
"status": {
|
||||
"passed": "Passed",
|
||||
"failed": "Failed",
|
||||
|
||||
@@ -1129,13 +1129,23 @@
|
||||
"columns": {
|
||||
"joinDate": "วันที่เริ่มงาน",
|
||||
"completionDate": "วันที่เสร็จสิ้น",
|
||||
"trainingType": "ประเภทการฝึกอบรม",
|
||||
"department": "แผนก",
|
||||
"name": "ชื่อ",
|
||||
"employeeId": "รหัสพนักงาน",
|
||||
"score": "คะแนน",
|
||||
"attempts": "จำนวนครั้ง",
|
||||
"trainingReport": "รายงานการฝึกอบรม",
|
||||
"status": "สถานะ"
|
||||
},
|
||||
"report": {
|
||||
"title": "รายงานการสอบ",
|
||||
"download": "ดาวน์โหลด PDF",
|
||||
"noReport": "ไม่มีรายงาน",
|
||||
"downloading": "กำลังสร้าง PDF กรุณารอสักครู่...",
|
||||
"downloadSuccess": "ดาวน์โหลด PDF สำเร็จ",
|
||||
"downloadFailed": "สร้าง PDF ไม่สำเร็จ"
|
||||
},
|
||||
"status": {
|
||||
"passed": "ผ่านแล้ว",
|
||||
"failed": "ไม่ผ่าน",
|
||||
|
||||
@@ -1236,13 +1236,23 @@
|
||||
"columns": {
|
||||
"joinDate": "入职日期",
|
||||
"completionDate": "完成日期",
|
||||
"trainingType": "培训类型",
|
||||
"department": "部门",
|
||||
"name": "姓名",
|
||||
"employeeId": "工号",
|
||||
"score": "分数",
|
||||
"attempts": "考试次数",
|
||||
"trainingReport": "培训报告",
|
||||
"status": "状态"
|
||||
},
|
||||
"report": {
|
||||
"title": "考试报告",
|
||||
"download": "下载 PDF",
|
||||
"noReport": "暂无报告",
|
||||
"downloading": "正在生成 PDF,请稍候...",
|
||||
"downloadSuccess": "PDF 下载成功",
|
||||
"downloadFailed": "PDF 生成失败"
|
||||
},
|
||||
"status": {
|
||||
"passed": "已通过",
|
||||
"failed": "未通过",
|
||||
|
||||
@@ -1129,13 +1129,23 @@
|
||||
"columns": {
|
||||
"joinDate": "入職日期",
|
||||
"completionDate": "完成日期",
|
||||
"trainingType": "培訓類型",
|
||||
"department": "部門",
|
||||
"name": "姓名",
|
||||
"employeeId": "工號",
|
||||
"score": "分數",
|
||||
"attempts": "考試次數",
|
||||
"trainingReport": "培訓報告",
|
||||
"status": "狀態"
|
||||
},
|
||||
"report": {
|
||||
"title": "考試報告",
|
||||
"download": "下載 PDF",
|
||||
"noReport": "暫無報告",
|
||||
"downloading": "正在生成 PDF,請稍候...",
|
||||
"downloadSuccess": "PDF 下載成功",
|
||||
"downloadFailed": "PDF 生成失敗"
|
||||
},
|
||||
"status": {
|
||||
"passed": "已通過",
|
||||
"failed": "未通過",
|
||||
|
||||
@@ -41,6 +41,7 @@ const props = defineProps<{
|
||||
currentIndex?: number;
|
||||
agentId?: number | null;
|
||||
authHeaders?: Record<string, string>;
|
||||
requiredDuration?: number;
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
@@ -49,6 +50,35 @@ const emit = defineEmits<{
|
||||
}>();
|
||||
const { t } = useI18n();
|
||||
|
||||
const countdownSeconds = ref(0);
|
||||
let countdownTimer: ReturnType<typeof setInterval> | null = null;
|
||||
|
||||
const startCountdown = () => {
|
||||
if (countdownTimer) {
|
||||
clearInterval(countdownTimer);
|
||||
countdownTimer = null;
|
||||
}
|
||||
if (props.requiredDuration && props.requiredDuration > 0) {
|
||||
countdownSeconds.value = props.requiredDuration * 60;
|
||||
countdownTimer = setInterval(() => {
|
||||
if (countdownSeconds.value > 0) {
|
||||
countdownSeconds.value--;
|
||||
} else {
|
||||
if (countdownTimer) clearInterval(countdownTimer);
|
||||
}
|
||||
}, 1000);
|
||||
} else {
|
||||
countdownSeconds.value = 0;
|
||||
}
|
||||
};
|
||||
|
||||
const stopCountdown = () => {
|
||||
if (countdownTimer) {
|
||||
clearInterval(countdownTimer);
|
||||
countdownTimer = null;
|
||||
}
|
||||
};
|
||||
|
||||
const isLoading = ref(false);
|
||||
const error = ref('');
|
||||
const markdownHtml = ref('');
|
||||
@@ -647,6 +677,9 @@ const loadContent = async () => {
|
||||
watch(
|
||||
() => [props.modelValue, activeFile.value?.url, activeFile.value?.name, activeIndex.value, activeFiles.value.length],
|
||||
() => {
|
||||
if (props.modelValue) {
|
||||
startCountdown();
|
||||
}
|
||||
loadContent();
|
||||
},
|
||||
{ immediate: true }
|
||||
@@ -657,6 +690,7 @@ watch(
|
||||
(v) => {
|
||||
if (!v) {
|
||||
clearOfficeObjectUrl();
|
||||
stopCountdown();
|
||||
}
|
||||
}
|
||||
);
|
||||
@@ -674,6 +708,9 @@ watch(
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex shrink-0 items-center gap-2">
|
||||
<div v-if="countdownSeconds > 0" class="flex items-center justify-center h-8 w-8 rounded-full border border-red-200 bg-red-50 text-red-500 font-semibold text-xs shadow-sm">
|
||||
{{ countdownSeconds }}s
|
||||
</div>
|
||||
<div v-if="isExcelPreviewFile" class="flex items-center gap-2 rounded-full border border-default bg-surface px-2 py-1">
|
||||
<button
|
||||
type="button"
|
||||
|
||||
Reference in new issue
Block a user