| | |
| | | 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); |
| | |
| | | componentProps: { |
| | | allowClear: true, |
| | | placeholder: '请选择', |
| | | options: CATEGORY_OPTIONS, |
| | | options: [], |
| | | fieldNames: TMS_DIC_FIELD_NAMES, |
| | | }, |
| | | }, |
| | | { |
| | |
| | | componentProps: { |
| | | allowClear: true, |
| | | placeholder: '请选择', |
| | | options: TRAIN_MODE_OPTIONS, |
| | | options: [], |
| | | fieldNames: TMS_DIC_FIELD_NAMES, |
| | | }, |
| | | }, |
| | | { |
| | |
| | | componentProps: { |
| | | allowClear: true, |
| | | placeholder: '请选择', |
| | | options: EVAL_MODE_OPTIONS, |
| | | options: [], |
| | | fieldNames: TMS_DIC_FIELD_NAMES, |
| | | onChange: (val: string) => syncPaperRequired(val), |
| | | }, |
| | | }, |
| | |
| | | label: '启用状态', |
| | | component: 'Select', |
| | | defaultValue: '1', |
| | | componentProps: { placeholder: '请选择', options: ENABLE_OPTIONS }, |
| | | componentProps: { |
| | | placeholder: '请选择', |
| | | options: [], |
| | | fieldNames: TMS_DIC_FIELD_NAMES, |
| | | }, |
| | | rules: [{ required: true, message: '必填', trigger: 'change' }], |
| | | }, |
| | | { |
| | |
| | | } |
| | | } |
| | | |
| | | 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({ |
| | |
| | | resetFields(); |
| | | state.id = data?.id || ''; |
| | | try { |
| | | await loadPaperOptions(); |
| | | await Promise.all([loadDicOptions(), loadPaperOptions()]); |
| | | if (state.id) { |
| | | const info = await getCourseInfo(state.id); |
| | | setFieldsValue(info); |