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/question/constants.ts |   61 +++++++++++++++++-------------
 1 files changed, 34 insertions(+), 27 deletions(-)

diff --git a/apps/jnpf-web-apps-main/src/views/x/tms/question/constants.ts b/apps/jnpf-web-apps-main/src/views/x/tms/question/constants.ts
index 2b54ca1..d62eaca 100644
--- a/apps/jnpf-web-apps-main/src/views/x/tms/question/constants.ts
+++ b/apps/jnpf-web-apps-main/src/views/x/tms/question/constants.ts
@@ -1,45 +1,52 @@
-import type { Difficulty, QuestionStatus, QuestionType, SourceType } from './types';
+import { ref } from 'vue';
 
-export const QUESTION_TYPE_OPTIONS: { id: QuestionType; fullName: string }[] = [
-  { id: 'single', fullName: '鍗曢�夐' },
-  { id: 'multi', fullName: '澶氶�夐' },
-  { id: 'judge', fullName: '鍒ゆ柇棰�' },
-  { id: 'blank', fullName: '濉┖棰�' },
-  { id: 'essay', fullName: '闂瓟棰�' },
-];
+import { useBaseStore } from '#/store';
+import { TMS_DIC, labelOfDic, loadTmsDic, type TmsDicOpt } from '#/views/x/tms/shared/dic';
 
-export const DIFFICULTY_OPTIONS: { id: Difficulty; fullName: string }[] = [
-  { id: 'easy', fullName: '绠�鍗�' },
-  { id: 'normal', fullName: '涓�鑸�' },
-  { id: 'hard', fullName: '鍥伴毦' },
-];
+type StatusOpt = TmsDicOpt & { tip?: string; tipColor?: string };
 
-export const SOURCE_OPTIONS: { id: SourceType; fullName: string }[] = [
-  { id: 'self', fullName: '鑷富鍛介' },
-  { id: 'import', fullName: '瀵煎叆' },
-  { id: 'external', fullName: '澶栬喘' },
-];
+function withStatusTip(list: TmsDicOpt[]): StatusOpt[] {
+  return list.map((x) => {
+    const code = x.enCode || x.id;
+    if (code === 'open') return { ...x, tip: '瀛︾敓鍙互妯℃嫙', tipColor: 'green' };
+    if (code === 'closed') return { ...x, tip: '瀛︾敓涓嶈兘妯℃嫙', tipColor: 'red' };
+    return x;
+  });
+}
 
-export const STATUS_OPTIONS: { id: QuestionStatus; fullName: string; tip?: string; tipColor?: string }[] = [
-  { id: 'open', fullName: '寮�鏀�', tip: '瀛︾敓鍙互妯℃嫙', tipColor: 'green' },
-  { id: 'closed', fullName: '涓嶅紑鏀�', tip: '瀛︾敓涓嶈兘妯℃嫙', tipColor: 'red' },
-  { id: 'invalid', fullName: '搴熷純' },
-];
+export const QUESTION_TYPE_OPTIONS = ref<TmsDicOpt[]>([]);
+export const DIFFICULTY_OPTIONS = ref<TmsDicOpt[]>([]);
+export const SOURCE_OPTIONS = ref<TmsDicOpt[]>([]);
+export const STATUS_OPTIONS = ref<StatusOpt[]>([]);
+
+export async function loadQuestionDics() {
+  const baseStore = useBaseStore();
+  const [questionType, difficulty, source, status] = await Promise.all([
+    loadTmsDic(baseStore, TMS_DIC.questionType),
+    loadTmsDic(baseStore, TMS_DIC.difficulty),
+    loadTmsDic(baseStore, TMS_DIC.questionSource),
+    loadTmsDic(baseStore, TMS_DIC.openClosedInvalid),
+  ]);
+  QUESTION_TYPE_OPTIONS.value = questionType;
+  DIFFICULTY_OPTIONS.value = difficulty;
+  SOURCE_OPTIONS.value = source;
+  STATUS_OPTIONS.value = withStatusTip(status);
+}
 
 export const OPTION_LABELS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'.split('');
 
 export function labelOfType(type?: string) {
-  return QUESTION_TYPE_OPTIONS.find((x) => x.id === type)?.fullName ?? type ?? '-';
+  return labelOfDic(QUESTION_TYPE_OPTIONS.value, type);
 }
 
 export function labelOfStatus(status?: string) {
-  return STATUS_OPTIONS.find((x) => x.id === status)?.fullName ?? status ?? '-';
+  return labelOfDic(STATUS_OPTIONS.value, status);
 }
 
 export function labelOfDifficulty(v?: string) {
-  return DIFFICULTY_OPTIONS.find((x) => x.id === v)?.fullName ?? v ?? '-';
+  return labelOfDic(DIFFICULTY_OPTIONS.value, v);
 }
 
 export function labelOfSource(v?: string) {
-  return SOURCE_OPTIONS.find((x) => x.id === v)?.fullName ?? v ?? '-';
+  return labelOfDic(SOURCE_OPTIONS.value, v);
 }

--
Gitblit v1.8.0