From 8534025c45b4736975730678b9ccf23570a75f95 Mon Sep 17 00:00:00 2001
From: liuyu <yu.liu@cqgbkj.com>
Date: 星期二, 22 九月 2026 09:25:48 +0800
Subject: [PATCH] feat(tms): 新增试卷、培训任务、个人任务页面
---
apps/jnpf-web-apps-main/src/views/x/tms/onlineExam/constants.ts | 63 +++++++++++++++++++++++++------
1 files changed, 51 insertions(+), 12 deletions(-)
diff --git a/apps/jnpf-web-apps-main/src/views/x/tms/onlineExam/constants.ts b/apps/jnpf-web-apps-main/src/views/x/tms/onlineExam/constants.ts
index f2dab78..0a09640 100644
--- a/apps/jnpf-web-apps-main/src/views/x/tms/onlineExam/constants.ts
+++ b/apps/jnpf-web-apps-main/src/views/x/tms/onlineExam/constants.ts
@@ -1,19 +1,58 @@
-import type { MyPaperStatus } from './types';
+import { ref } from 'vue';
-export const MY_PAPER_STATUS_OPTIONS: {
- id: MyPaperStatus;
- fullName: string;
- color?: string;
-}[] = [
- { id: 'notStarted', fullName: '鏈紑濮�', color: '#8c8c8c' },
- { id: 'doing', fullName: '鑰冭瘯涓�', color: '#1890ff' },
- { id: 'submitted', fullName: '宸蹭氦鍗�', color: '#52c41a' },
-];
+import { useBaseStore } from '#/store';
+import { TMS_DIC, labelOfDic, loadTmsDic, type TmsDicOpt } from '#/views/x/tms/shared/dic';
+
+/** 鎴戠殑璇曞嵎銆屾湭寮�濮嬨�嶄负鍓嶇鎬侊紝瀛楀吀 tmsExamStatus 涓嶅惈璇ラ」 */
+const NOT_STARTED: TmsDicOpt = { id: 'notStarted', enCode: 'notStarted', fullName: '鏈紑濮�' };
+
+const STATUS_COLOR: Record<string, string> = {
+ notStarted: '#8c8c8c',
+ doing: '#1890ff',
+ submitted: '#52c41a',
+ cancelled: '#ff4d4f',
+};
+
+export const MY_PAPER_STATUS_OPTIONS = ref<TmsDicOpt[]>([NOT_STARTED]);
+export const PASS_FLAG_OPTIONS = ref<TmsDicOpt[]>([]);
+
+export async function loadOnlineExamDics() {
+ const baseStore = useBaseStore();
+ const [examStatus, passFlag] = await Promise.all([
+ loadTmsDic(baseStore, TMS_DIC.examStatus),
+ loadTmsDic(baseStore, TMS_DIC.passFlag),
+ ]);
+ const rest = examStatus.filter((x) => (x.enCode || x.id) !== 'notStarted');
+ MY_PAPER_STATUS_OPTIONS.value = [NOT_STARTED, ...rest];
+ PASS_FLAG_OPTIONS.value = passFlag;
+}
export function labelOfMyPaperStatus(v?: string) {
- return MY_PAPER_STATUS_OPTIONS.find((x) => x.id === v)?.fullName ?? v ?? '-';
+ return labelOfDic(MY_PAPER_STATUS_OPTIONS.value, v);
}
export function colorOfMyPaperStatus(v?: string) {
- return MY_PAPER_STATUS_OPTIONS.find((x) => x.id === v)?.color;
+ return (v && STATUS_COLOR[v]) || undefined;
+}
+
+export function labelOfPassFlag(v?: string | null) {
+ if (v == null || v === '') return '-';
+ const code = String(v);
+ if (code === '1') return '鍚堟牸';
+ if (code === '0') return '涓嶅悎鏍�';
+ return labelOfDic(PASS_FLAG_OPTIONS.value, code);
+}
+
+export function colorOfPassFlag(v?: string | null) {
+ if (v === '1') return '#52c41a';
+ if (v === '0') return '#ff4d4f';
+ return undefined;
+}
+
+export function labelOfGradeStatus(v?: string | null) {
+ if (!v) return '-';
+ if (v === 'auto') return '鑷姩闃呭嵎';
+ if (v === 'pending') return '寰呴槄鍗�';
+ if (v === 'graded') return '宸查槄鍗�';
+ return v;
}
--
Gitblit v1.8.0