提交 030b547a authored 作者: 王鹏飞's avatar 王鹏飞

feat: 添加大赛模式选择功能,优化提交逻辑

上级 290131a3
......@@ -22,6 +22,7 @@ const gradeRuleList = [
{ label: '直播总结汇报', value: 6 },
]
const defaultConfig = {
mode: 'formal',
min_submit_time: '',
practical_question: '',
rules: [] as any[],
......@@ -77,7 +78,7 @@ watch(
(value) => {
if (value) fetchInfo()
},
{ immediate: true }
{ immediate: true },
)
// 提交
......@@ -195,6 +196,12 @@ function disabledMinSubmitDate(time: Date) {
:value="item.value"></el-option>
</el-select>
</el-form-item>
<el-form-item label="大赛模式">
<el-radio-group v-model="form.config.mode">
<el-radio label="test">训练</el-radio>
<el-radio label="formal">正赛</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item label="开始时间" prop="start_time">
<el-date-picker
v-model="form.start_time"
......@@ -211,7 +218,7 @@ function disabledMinSubmitDate(time: Date) {
value-format="YYYY-MM-DD HH:mm:ss"
style="width: 100%" />
</el-form-item>
<el-form-item label="最短交卷时间" prop="config.min_submit_time">
<el-form-item label="最短交卷时间" prop="config.min_submit_time" v-if="false">
<el-date-picker
v-model="form.config.min_submit_time"
type="datetime"
......@@ -220,16 +227,13 @@ function disabledMinSubmitDate(time: Date) {
:disabled-date="disabledMinSubmitDate"
style="width: 100%" />
</el-form-item>
<el-form-item label="试题" prop="questions">
<el-form-item label="试题" prop="questions" v-if="false">
<el-select v-model="form.questions" style="width: 100%" placeholder="请选择" filterable>
<el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value"></el-option>
</el-select>
</el-form-item>
<el-form-item label="实操试题" prop="config.practical_question">
<AppEditor
v-model="form.config.practical_question"
:height="320"
placeholder="请输入实操试题内容" />
<AppEditor v-model="form.config.practical_question" :height="320" placeholder="请输入实操试题内容" />
</el-form-item>
<el-divider />
<el-form-item label-width="0">
......
......@@ -60,24 +60,31 @@ const handleSubmit = async () => {
await submit()
ElMessage.success('提交成功')
isEntry.value = false
}
},
)
}
const tabActive = ref('bi')
const practicalQuestionHtml = computed(() => {
const competitionConfig = computed(() => {
const rawConfig = competition.value?.config
if (!rawConfig) return ''
if (!rawConfig) return {}
try {
const config = typeof rawConfig === 'string' ? JSON.parse(rawConfig) : rawConfig
return config?.practical_question || ''
return typeof rawConfig === 'string' ? JSON.parse(rawConfig) : rawConfig
} catch (error) {
console.error(error)
return ''
return {}
}
})
const isFormalMode = computed(() => {
return competitionConfig.value?.mode === 'formal'
})
const practicalQuestionHtml = computed(() => {
return competitionConfig.value?.practical_question || ''
})
useEventListener(window, 'message', async (event) => {
console.log(event)
const { data } = event
......@@ -102,17 +109,31 @@ useEventListener(window, 'message', async (event) => {
<template v-if="competition?.competition == '4'">
<AppCard>
<el-button :type="tabActive === 'bi' ? 'primary' : 'default'" @click="tabActive = 'bi'">实操环境</el-button>
<el-button :type="tabActive === 'exam' ? 'primary' : 'default'" @click="tabActive = 'exam'">理论试题</el-button>
<el-button :type="tabActive === 'exam' ? 'primary' : 'default'" @click="tabActive = 'exam'"
>理论试题</el-button
>
</AppCard>
<div class="iframe-box">
<iframe allow="camera; microphone" allowfullscreen :src="biURL" frameborder="0" class="iframe" ref="iframeRef"
<iframe
allow="camera; microphone"
allowfullscreen
:src="biURL"
frameborder="0"
class="iframe"
ref="iframeRef"
v-show="tabActive === 'bi'"></iframe>
<iframe allow="camera; microphone" allowfullscreen :src="examURL" frameborder="0" class="iframe"
ref="iframeRef" v-show="tabActive === 'exam'"></iframe>
<iframe
allow="camera; microphone"
allowfullscreen
:src="examURL"
frameborder="0"
class="iframe"
ref="iframeRef"
v-show="tabActive === 'exam'"></iframe>
</div>
</template>
<template v-else>
<AppCard>
<AppCard v-if="isFormalMode">
<div class="competition-header">
<div class="time">
<div class="label">倒计时:</div>
......@@ -122,7 +143,12 @@ useEventListener(window, 'message', async (event) => {
</div>
</AppCard>
<div class="iframe-box">
<iframe allow="camera; microphone" allowfullscreen :src="LAB_URL" frameborder="0" class="iframe"
<iframe
allow="camera; microphone"
allowfullscreen
:src="LAB_URL"
frameborder="0"
class="iframe"
ref="iframeRef"></iframe>
</div>
</template>
......@@ -138,7 +164,9 @@ useEventListener(window, 'message', async (event) => {
<p>{{ competition?.start_time }} ~ {{ competition?.end_time }}</p>
</div>
</div>
<el-button v-if="canEnter" type="primary" size="large" @click="handleEntry" class="entry-btn">进入实操考试</el-button>
<el-button v-if="canEnter" type="primary" size="large" @click="handleEntry" class="entry-btn"
>进入实操考试</el-button
>
<el-button plain v-if="isSubmitted" type="primary" size="large" class="entry-btn">考试已提交</el-button>
</div>
<el-empty description="暂无比赛" v-else />
......@@ -308,7 +336,9 @@ useEventListener(window, 'message', async (event) => {
p {
font-size: 18px;
font-family: PingFangSC-Regular, PingFang SC;
font-family:
PingFangSC-Regular,
PingFang SC;
font-weight: 400;
color: #fff;
line-height: 25px;
......
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论