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

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

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