| | |
| | | import type { QuestionBankOption } from '#/views/x/tms/question/types'; |
| | | import type { SelfTestFormModel } from './types'; |
| | | |
| | | import { computed, onMounted, reactive, ref } from 'vue'; |
| | | import { computed, onActivated, onMounted, reactive, ref } from 'vue'; |
| | | import { useRouter } from 'vue-router'; |
| | | |
| | | import { useMessage } from '@jnpf/hooks'; |
| | | import { useTabbarStore } from '@vben/stores'; |
| | | |
| | | import { getSelfTestBanks, startSelfTest } from '#/api/x/tms/selfTest'; |
| | | |
| | |
| | | |
| | | const router = useRouter(); |
| | | const { createMessage } = useMessage(); |
| | | const tabbarStore = useTabbarStore(); |
| | | |
| | | const banks = ref<QuestionBankOption[]>([]); |
| | | const loading = ref(false); |
| | | const formRef = ref(); |
| | | const pageReady = ref(false); |
| | | |
| | | function defaultSetting() { |
| | | return { count: 0, difficulty: 'normal' as SelfTestDifficulty }; |
| | |
| | | () => Number(dataForm.single.count || 0) + Number(dataForm.multi.count || 0) + Number(dataForm.judge.count || 0), |
| | | ); |
| | | |
| | | onMounted(async () => { |
| | | async function loadBanks() { |
| | | try { |
| | | banks.value = (await getSelfTestBanks()) || []; |
| | | if (banks.value.length === 1) { |
| | | if (!dataForm.bankId && banks.value.length === 1) { |
| | | dataForm.bankId = banks.value[0].id; |
| | | } |
| | | } catch (e: any) { |
| | | banks.value = []; |
| | | createMessage.error(e?.message || '加载题库失败'); |
| | | } finally { |
| | | pageReady.value = true; |
| | | } |
| | | } |
| | | |
| | | onMounted(() => { |
| | | tabbarStore.renderRouteView = true; |
| | | loadBanks(); |
| | | }); |
| | | onActivated(() => { |
| | | tabbarStore.renderRouteView = true; |
| | | if (!pageReady.value || !banks.value.length) { |
| | | loadBanks(); |
| | | } |
| | | }); |
| | | |
| | |
| | | loading.value = false; |
| | | } |
| | | } |
| | | |
| | | function goRecords() { |
| | | router.push('/tms/selfTest/records'); |
| | | } |
| | | </script> |
| | | |
| | | <template> |
| | |
| | | <div class="jnpf-content-wrapper-center"> |
| | | <div class="jnpf-content-wrapper-content tms-self-test-page"> |
| | | <div class="tms-self-test-header"> |
| | | <div> |
| | | <div class="text-base font-medium">自我检测</div> |
| | | <div class="mt-1 text-gray-400 text-sm">设置查询条件,从题库中筛选题目进行自我检测。</div> |
| | | </div> |
| | | <a-button @click="goRecords">我的检测记录</a-button> |
| | | </div> |
| | | |
| | | <a-form |
| | |
| | | } |
| | | |
| | | .tms-self-test-header { |
| | | display: flex; |
| | | justify-content: space-between; |
| | | align-items: flex-start; |
| | | margin-bottom: 24px; |
| | | padding-bottom: 12px; |
| | | border-bottom: 1px solid #f0f0f0; |