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/trainMode/index.vue |   77 ++++++++++++++++++++++++++++++--------
 1 files changed, 60 insertions(+), 17 deletions(-)

diff --git a/apps/jnpf-web-apps-main/src/views/x/tms/trainMode/index.vue b/apps/jnpf-web-apps-main/src/views/x/tms/trainMode/index.vue
index ed76a4a..86045a2 100644
--- a/apps/jnpf-web-apps-main/src/views/x/tms/trainMode/index.vue
+++ b/apps/jnpf-web-apps-main/src/views/x/tms/trainMode/index.vue
@@ -3,24 +3,33 @@
 
 import type { TrainModeItem } from './types';
 
+import { onMounted, ref } from 'vue';
+
 import { useMessage } from '@jnpf/hooks';
 import { useModal } from '@jnpf/ui/modal';
 import { BasicVxeTable, TableAction, useVxeTable } from '@jnpf/ui/vxeTable';
 
 import { deleteTrainMode, getTrainModeList, setTrainModeEnabled } from '#/api/x/tms/trainMode';
+import { useBaseStore } from '#/store';
 
 import Form from './Form.vue';
 import {
-  ENABLE_OPTIONS,
-  labelOfEnabled,
-  labelOfSignRule,
-  labelOfYesNo,
-} from './constants';
+  TMS_DIC,
+  TMS_DIC_FIELD_NAMES,
+  labelOfDic,
+  loadTmsDic,
+  type TmsDicOpt,
+} from '#/views/x/tms/shared/dic';
 
 defineOptions({ name: 'TmsTrainMode' });
 
 const { createMessage } = useMessage();
+const baseStore = useBaseStore();
 const [registerForm, { openModal: openFormModal }] = useModal();
+
+const signRuleOpts = ref<TmsDicOpt[]>([]);
+const yesNoOpts = ref<TmsDicOpt[]>([]);
+const enableOpts = ref<TmsDicOpt[]>([]);
 
 const columns: BasicColumn[] = [
   { title: '鏂瑰紡缂栫爜', dataIndex: 'modeCode', width: 120 },
@@ -29,28 +38,28 @@
     title: '绛惧埌瑙勫垯',
     dataIndex: 'signRule',
     width: 120,
-    customRender: ({ record }) => labelOfSignRule((record as TrainModeItem).signRule),
+    customRender: ({ record }) => labelOfDic(signRuleOpts.value, (record as TrainModeItem).signRule),
   },
   {
     title: '鍏佽鍚嶅崟澶栫鍒�',
     dataIndex: 'allowGuestSign',
     width: 130,
     align: 'center',
-    customRender: ({ record }) => labelOfYesNo((record as TrainModeItem).allowGuestSign),
+    customRender: ({ record }) => labelOfDic(yesNoOpts.value, (record as TrainModeItem).allowGuestSign),
   },
   {
     title: '璧锋椤诲悓涓�澶�',
     dataIndex: 'sameDayRequired',
     width: 120,
     align: 'center',
-    customRender: ({ record }) => labelOfYesNo((record as TrainModeItem).sameDayRequired),
+    customRender: ({ record }) => labelOfDic(yesNoOpts.value, (record as TrainModeItem).sameDayRequired),
   },
   {
     title: '鍦扮偣蹇呭~',
     dataIndex: 'placeRequired',
     width: 100,
     align: 'center',
-    customRender: ({ record }) => labelOfYesNo((record as TrainModeItem).placeRequired),
+    customRender: ({ record }) => labelOfDic(yesNoOpts.value, (record as TrainModeItem).placeRequired),
   },
   { title: '鎺掑簭', dataIndex: 'sortNo', width: 80, align: 'center' },
   {
@@ -63,10 +72,10 @@
   { title: '澶囨敞', dataIndex: 'remark', minWidth: 180 },
 ];
 
-const [registerTable, { reload }] = useVxeTable({
+const [registerTable, { reload, getForm }] = useVxeTable({
   api: fetchList,
   columns,
-  immediate: true,
+  immediate: false,
   rowKey: 'id',
   useSearchForm: true,
   formConfig: {
@@ -86,7 +95,8 @@
         componentProps: {
           allowClear: true,
           placeholder: '璇烽�夋嫨',
-          options: ENABLE_OPTIONS,
+          options: enableOpts.value,
+          fieldNames: TMS_DIC_FIELD_NAMES,
         },
       },
     ],
@@ -97,6 +107,32 @@
     dataIndex: 'action',
     fixed: 'right',
   },
+});
+
+async function loadDic() {
+  const [signRule, yesNo, enable] = await Promise.all([
+    loadTmsDic(baseStore, TMS_DIC.signRule),
+    loadTmsDic(baseStore, TMS_DIC.yesNo),
+    loadTmsDic(baseStore, TMS_DIC.enableStatus),
+  ]);
+  signRuleOpts.value = signRule;
+  yesNoOpts.value = yesNo;
+  enableOpts.value = enable;
+
+  getForm()?.updateSchema?.({
+    field: 'enabled',
+    componentProps: {
+      allowClear: true,
+      placeholder: '璇烽�夋嫨',
+      options: enableOpts.value,
+      fieldNames: TMS_DIC_FIELD_NAMES,
+    },
+  });
+}
+
+onMounted(async () => {
+  await loadDic();
+  reload();
 });
 
 async function fetchList(params: Record<string, any>) {
@@ -124,6 +160,10 @@
 }
 
 async function handleDelete(record: TrainModeItem) {
+  if (record.enabled !== '0') {
+    createMessage.warning('璇峰厛鍋滅敤鍚庡啀鍒犻櫎');
+    return;
+  }
   try {
     await deleteTrainMode(record.id);
     createMessage.success('鍒犻櫎鎴愬姛');
@@ -135,7 +175,7 @@
 
 function getTableActions(record: TrainModeItem): ActionItem[] {
   const enableLabel = record.enabled === '1' ? '鍋滅敤' : '鍚敤';
-  return [
+  const actions: ActionItem[] = [
     { label: '缂栬緫', onClick: handleEdit.bind(null, record) },
     {
       label: enableLabel,
@@ -144,15 +184,18 @@
         onOk: handleToggleEnabled.bind(null, record),
       },
     },
-    {
+  ];
+  if (record.enabled === '0') {
+    actions.push({
       label: '鍒犻櫎',
       color: 'error',
       modelConfirm: {
         content: `纭畾鍒犻櫎鍩硅鏂瑰紡銆�${record.modeName}銆嶅悧锛焋,
         onOk: handleDelete.bind(null, record),
       },
-    },
-  ];
+    });
+  }
+  return actions;
 }
 </script>
 
@@ -166,7 +209,7 @@
           </template>
           <template #enabled="{ record }">
             <a-tag :color="record.enabled === '1' ? 'success' : 'default'">
-              {{ labelOfEnabled(record.enabled) }}
+              {{ labelOfDic(enableOpts, record.enabled) }}
             </a-tag>
           </template>
           <template #action="{ record }">

--
Gitblit v1.8.0