liuyu
21 小时以前 93c133349a5ccd7a328371fa113dce69d5611f21
apps/jnpf-web-apps-main/src/views/x/tms/course/Form.vue
@@ -11,19 +11,20 @@
  getCoursePaperOptions,
  updateCourse,
} from '#/api/x/tms/course';
import { useBaseStore } from '#/store';
import {
  CATEGORY_OPTIONS,
  ENABLE_OPTIONS,
  EVAL_MODE_OPTIONS,
  TRAIN_MODE_OPTIONS,
  evalModeNeedPaper,
} from './constants';
  TMS_DIC,
  TMS_DIC_FIELD_NAMES,
  loadTmsDic,
} from '#/views/x/tms/shared/dic';
import { evalModeNeedPaper } from './constants';
defineOptions({ name: 'TmsCourseForm' });
const emit = defineEmits(['register', 'reload']);
const { createMessage } = useMessage();
const baseStore = useBaseStore();
const state = reactive({ id: '' });
const { id } = toRefs(state);
@@ -56,7 +57,8 @@
        componentProps: {
          allowClear: true,
          placeholder: '请选择',
          options: CATEGORY_OPTIONS,
          options: [],
          fieldNames: TMS_DIC_FIELD_NAMES,
        },
      },
      {
@@ -66,7 +68,8 @@
        componentProps: {
          allowClear: true,
          placeholder: '请选择',
          options: TRAIN_MODE_OPTIONS,
          options: [],
          fieldNames: TMS_DIC_FIELD_NAMES,
        },
      },
      {
@@ -76,7 +79,8 @@
        componentProps: {
          allowClear: true,
          placeholder: '请选择',
          options: EVAL_MODE_OPTIONS,
          options: [],
          fieldNames: TMS_DIC_FIELD_NAMES,
          onChange: (val: string) => syncPaperRequired(val),
        },
      },
@@ -110,7 +114,11 @@
        label: '启用状态',
        component: 'Select',
        defaultValue: '1',
        componentProps: { placeholder: '请选择', options: ENABLE_OPTIONS },
        componentProps: {
          placeholder: '请选择',
          options: [],
          fieldNames: TMS_DIC_FIELD_NAMES,
        },
        rules: [{ required: true, message: '必填', trigger: 'change' }],
      },
      {
@@ -136,6 +144,53 @@
  }
}
async function loadDicOptions() {
  const [category, trainMode, evalMode, enable] = await Promise.all([
    loadTmsDic(baseStore, TMS_DIC.courseCategory),
    loadTmsDic(baseStore, TMS_DIC.trainMode),
    loadTmsDic(baseStore, TMS_DIC.evalMode),
    loadTmsDic(baseStore, TMS_DIC.enableStatus),
  ]);
  updateSchema([
    {
      field: 'category',
      componentProps: {
        allowClear: true,
        placeholder: '请选择',
        options: category,
        fieldNames: TMS_DIC_FIELD_NAMES,
      },
    },
    {
      field: 'trainMode',
      componentProps: {
        allowClear: true,
        placeholder: '请选择',
        options: trainMode,
        fieldNames: TMS_DIC_FIELD_NAMES,
      },
    },
    {
      field: 'evalMode',
      componentProps: {
        allowClear: true,
        placeholder: '请选择',
        options: evalMode,
        fieldNames: TMS_DIC_FIELD_NAMES,
        onChange: (val: string) => syncPaperRequired(val),
      },
    },
    {
      field: 'enabled',
      componentProps: {
        placeholder: '请选择',
        options: enable,
        fieldNames: TMS_DIC_FIELD_NAMES,
      },
    },
  ]);
}
async function loadPaperOptions() {
  const list = await getCoursePaperOptions();
  updateSchema({
@@ -156,7 +211,7 @@
  resetFields();
  state.id = data?.id || '';
  try {
    await loadPaperOptions();
    await Promise.all([loadDicOptions(), loadPaperOptions()]);
    if (state.id) {
      const info = await getCourseInfo(state.id);
      setFieldsValue(info);