|
@@ -4,6 +4,7 @@ import { getProblemController } from '@/api/problem-controller'
|
|
|
import type {
|
|
import type {
|
|
|
ContestDto,
|
|
ContestDto,
|
|
|
ContestProblemDto,
|
|
ContestProblemDto,
|
|
|
|
|
+ ContestProblemVo,
|
|
|
ContestRegistrationVo,
|
|
ContestRegistrationVo,
|
|
|
ContestVo,
|
|
ContestVo,
|
|
|
ProblemVo,
|
|
ProblemVo,
|
|
@@ -14,7 +15,6 @@ import { ElMessage, ElMessageBox, type FormInstance, type FormRules } from 'elem
|
|
|
import { Delete, Edit, Plus, RefreshRight, Search, UserFilled, View } from '@element-plus/icons-vue'
|
|
import { Delete, Edit, Plus, RefreshRight, Search, UserFilled, View } from '@element-plus/icons-vue'
|
|
|
import { computed, onMounted, reactive, ref } from 'vue'
|
|
import { computed, onMounted, reactive, ref } from 'vue'
|
|
|
import { useLoginUserStore } from '@/store'
|
|
import { useLoginUserStore } from '@/store'
|
|
|
-import type { ContestDetail, ContestProblem } from '@/type/contest'
|
|
|
|
|
|
|
|
|
|
const api = getContestController()
|
|
const api = getContestController()
|
|
|
const problemApi = getProblemController()
|
|
const problemApi = getProblemController()
|
|
@@ -222,8 +222,8 @@ const configType = ref<ContestVo['type']>('public')
|
|
|
const configPassword = ref('')
|
|
const configPassword = ref('')
|
|
|
const configLoaded = ref(false)
|
|
const configLoaded = ref(false)
|
|
|
const configSaving = ref(false)
|
|
const configSaving = ref(false)
|
|
|
-const configProblems = ref<ContestProblem[]>([])
|
|
|
|
|
-const existingProblems = ref<ContestProblem[]>([])
|
|
|
|
|
|
|
+const configProblems = ref<ContestProblemVo[]>([])
|
|
|
|
|
+const existingProblems = ref<ContestProblemVo[]>([])
|
|
|
|
|
|
|
|
const candSearch = reactive({ title: '' })
|
|
const candSearch = reactive({ title: '' })
|
|
|
const candData = ref<ProblemVo[]>([])
|
|
const candData = ref<ProblemVo[]>([])
|
|
@@ -274,7 +274,7 @@ const loadConfig = async () => {
|
|
|
try {
|
|
try {
|
|
|
const res = await api.getDetail1(configContestId.value, configPassword.value ? { password: configPassword.value } : undefined)
|
|
const res = await api.getDetail1(configContestId.value, configPassword.value ? { password: configPassword.value } : undefined)
|
|
|
if (res?.code === 200 && res.data) {
|
|
if (res?.code === 200 && res.data) {
|
|
|
- const d = res.data as unknown as ContestDetail
|
|
|
|
|
|
|
+ const d = res.data
|
|
|
if (d.type === 'password' && !d.creatorUsername) {
|
|
if (d.type === 'password' && !d.creatorUsername) {
|
|
|
ElMessage.error('比赛密码错误')
|
|
ElMessage.error('比赛密码错误')
|
|
|
return
|
|
return
|
|
@@ -300,7 +300,7 @@ const toggleConfigure = (row: ProblemVo, checked: boolean) => {
|
|
|
configProblems.value.push({
|
|
configProblems.value.push({
|
|
|
problemId: row.id,
|
|
problemId: row.id,
|
|
|
title: row.title || '',
|
|
title: row.title || '',
|
|
|
- difficulty: row.difficulty || '',
|
|
|
|
|
|
|
+ difficulty: row.difficulty,
|
|
|
displayOrder: configProblems.value.length + 1,
|
|
displayOrder: configProblems.value.length + 1,
|
|
|
score: 100
|
|
score: 100
|
|
|
})
|
|
})
|
|
@@ -331,7 +331,7 @@ const saveConfig = async () => {
|
|
|
|
|
|
|
|
for (const cp of current) {
|
|
for (const cp of current) {
|
|
|
const old = existingMap.get(cp.problemId)
|
|
const old = existingMap.get(cp.problemId)
|
|
|
- const dto: ContestProblemDto = { problemId: cp.problemId, score: cp.score, displayOrder: cp.displayOrder }
|
|
|
|
|
|
|
+ const dto: ContestProblemDto = { problemId: cp.problemId!, score: cp.score ?? 0, displayOrder: cp.displayOrder ?? 1 }
|
|
|
if (!old) {
|
|
if (!old) {
|
|
|
const res = await api.addProblem(id, dto)
|
|
const res = await api.addProblem(id, dto)
|
|
|
if (res?.code !== 200) {
|
|
if (res?.code !== 200) {
|
|
@@ -349,7 +349,7 @@ const saveConfig = async () => {
|
|
|
|
|
|
|
|
for (const ex of existing) {
|
|
for (const ex of existing) {
|
|
|
if (!currentMap.has(ex.problemId)) {
|
|
if (!currentMap.has(ex.problemId)) {
|
|
|
- const res = await api.removeProblem(id, { problemId: ex.problemId })
|
|
|
|
|
|
|
+ const res = await api.removeProblem(id, { problemId: ex.problemId! })
|
|
|
if (res?.code !== 200) {
|
|
if (res?.code !== 200) {
|
|
|
ElMessage.error(res?.message || `移除题目 ${ex.title} 失败`)
|
|
ElMessage.error(res?.message || `移除题目 ${ex.title} 失败`)
|
|
|
return
|
|
return
|