| | |
| | | import { BasicModal, useModalInner } from '@jnpf/ui/modal'; |
| | | |
| | | import { createEvalMode, getEvalModeInfo, updateEvalMode } from '#/api/x/tms/evalMode'; |
| | | |
| | | import { ENABLE_OPTIONS, YES_NO_OPTIONS } from './constants'; |
| | | import { useBaseStore } from '#/store'; |
| | | import { |
| | | TMS_DIC, |
| | | TMS_DIC_FIELD_NAMES, |
| | | loadTmsDic, |
| | | } from '#/views/x/tms/shared/dic'; |
| | | |
| | | defineOptions({ name: 'TmsEvalModeForm' }); |
| | | |
| | | const emit = defineEmits(['register', 'reload']); |
| | | const { createMessage } = useMessage(); |
| | | const baseStore = useBaseStore(); |
| | | |
| | | const state = reactive({ id: '' }); |
| | | const { id } = toRefs(state); |
| | |
| | | label: '需要试卷', |
| | | component: 'Select', |
| | | defaultValue: '0', |
| | | componentProps: { placeholder: '请选择', options: YES_NO_OPTIONS }, |
| | | componentProps: { |
| | | placeholder: '请选择', |
| | | options: [], |
| | | fieldNames: TMS_DIC_FIELD_NAMES, |
| | | }, |
| | | rules: [{ required: true, message: '必填', trigger: 'change' }], |
| | | }, |
| | | { |
| | |
| | | label: '需要提问预设', |
| | | component: 'Select', |
| | | defaultValue: '0', |
| | | componentProps: { placeholder: '请选择', options: YES_NO_OPTIONS }, |
| | | componentProps: { |
| | | placeholder: '请选择', |
| | | options: [], |
| | | fieldNames: TMS_DIC_FIELD_NAMES, |
| | | }, |
| | | rules: [{ required: true, message: '必填', trigger: 'change' }], |
| | | }, |
| | | { |
| | |
| | | label: '需要实操评分', |
| | | component: 'Select', |
| | | defaultValue: '0', |
| | | componentProps: { placeholder: '请选择', options: YES_NO_OPTIONS }, |
| | | componentProps: { |
| | | placeholder: '请选择', |
| | | options: [], |
| | | fieldNames: TMS_DIC_FIELD_NAMES, |
| | | }, |
| | | rules: [{ required: true, message: '必填', trigger: 'change' }], |
| | | }, |
| | | { |
| | |
| | | label: '启用状态', |
| | | component: 'Select', |
| | | defaultValue: '1', |
| | | componentProps: { placeholder: '请选择', options: ENABLE_OPTIONS }, |
| | | componentProps: { |
| | | placeholder: '请选择', |
| | | options: [], |
| | | fieldNames: TMS_DIC_FIELD_NAMES, |
| | | }, |
| | | rules: [{ required: true, message: '必填', trigger: 'change' }], |
| | | }, |
| | | { |
| | |
| | | }); |
| | | |
| | | const [registerModal, { closeModal, changeLoading, changeOkLoading }] = useModalInner(init); |
| | | |
| | | async function loadDicOptions() { |
| | | const [yesNo, enable] = await Promise.all([ |
| | | loadTmsDic(baseStore, TMS_DIC.yesNo), |
| | | loadTmsDic(baseStore, TMS_DIC.enableStatus), |
| | | ]); |
| | | updateSchema( |
| | | ['needPaper', 'needQuiz', 'needPractice'].map((field) => ({ |
| | | field, |
| | | componentProps: { placeholder: '请选择', options: yesNo, fieldNames: TMS_DIC_FIELD_NAMES }, |
| | | })), |
| | | ); |
| | | updateSchema({ |
| | | field: 'enabled', |
| | | componentProps: { placeholder: '请选择', options: enable, fieldNames: TMS_DIC_FIELD_NAMES }, |
| | | }); |
| | | } |
| | | |
| | | async function init(data: { id?: string }) { |
| | | changeLoading(true); |
| | |
| | | }, |
| | | }); |
| | | try { |
| | | await loadDicOptions(); |
| | | if (state.id) setFieldsValue(await getEvalModeInfo(state.id)); |
| | | } finally { |
| | | changeLoading(false); |