Explorar o código

fix(contest-config): 打开弹窗自动加载候选题目、保存按钮受加载状态约束、难度显示中文

yangyi hai 2 semanas
pai
achega
445a0f9304
Modificáronse 1 ficheiros con 13 adicións e 3 borrados
  1. 13 3
      src/view/admin/ContestManageView.vue

+ 13 - 3
src/view/admin/ContestManageView.vue

@@ -52,6 +52,14 @@ const statusTag = (status?: ContestVo['status']) => {
 const statusLabel = (status?: ContestVo['status']) =>
   statusOptions.find((s) => s.value === status)?.label || status || '-'
 
+const difficultyOptions = [
+  { label: '简单', value: 'easy' },
+  { label: '中等', value: 'medium' },
+  { label: '困难', value: 'hard' }
+]
+
+const difficultyLabel = (d?: string) => difficultyOptions.find((i) => i.value === d)?.label || d || '-'
+
 // ---------- 搜索 ----------
 const searchForm = reactive({
   title: '',
@@ -365,8 +373,11 @@ const openConfig = (row: ContestVo) => {
   configLoaded.value = false
   existingProblems.value = []
   configProblems.value = []
+  candSearch.title = ''
+  candPagination.pageNum = 1
   configDialogVisible.value = true
   loadConfig()
+  loadCandidates()
 }
 
 // ---------- 报名名单 ----------
@@ -557,7 +568,7 @@ onMounted(fetchData)
             <el-table-column prop="id" label="ID" width="60" align="center" />
             <el-table-column prop="title" label="标题" min-width="150" show-overflow-tooltip />
             <el-table-column prop="difficulty" label="难度" width="80" align="center">
-              <template #default="{ row }">{{ row.difficulty || '-' }}</template>
+              <template #default="{ row }">{{ difficultyLabel(row.difficulty) }}</template>
             </el-table-column>
           </el-table>
           <div class="pagination">
@@ -576,7 +587,6 @@ onMounted(fetchData)
         <div class="config-panel">
           <div class="config-header">
             <span class="card-title">已选题目({{ configProblems.length }})</span>
-            <el-button v-if="configLoaded" type="primary" size="small" :loading="configSaving" @click="saveConfig">保存配置</el-button>
           </div>
           <el-table v-if="configProblems.length" :data="configProblems" border stripe size="small" height="420">
             <el-table-column label="题号" width="90" align="center">
@@ -601,7 +611,7 @@ onMounted(fetchData)
       </div>
       <template #footer>
         <el-button @click="configDialogVisible = false">关闭</el-button>
-        <el-button type="primary" :loading="configSaving" @click="saveConfig">保存配置</el-button>
+        <el-button type="primary" :disabled="!configLoaded" :loading="configSaving" @click="saveConfig">保存配置</el-button>
       </template>
     </el-dialog>