|
|
@@ -126,7 +126,7 @@ const formRules: FormRules = {
|
|
|
password: [
|
|
|
{
|
|
|
validator: (_rule, value, callback) => {
|
|
|
- if (contestForm.type === 'password' && !value) {
|
|
|
+ if (contestForm.type === 'password' && !value && !contestForm.id) {
|
|
|
callback(new Error('密码型比赛请输入访问密码'))
|
|
|
} else {
|
|
|
callback()
|
|
|
@@ -161,6 +161,17 @@ const handleEdit = (row: ContestVo) => {
|
|
|
contestForm.startDatetime = row.startDatetime || ''
|
|
|
contestForm.endDatetime = row.endDatetime || ''
|
|
|
dialogVisible.value = true
|
|
|
+ if (row.id !== undefined && row.type !== 'password') {
|
|
|
+ api
|
|
|
+ .getDetail2(row.id)
|
|
|
+ .then((res) => {
|
|
|
+ const d = res?.data
|
|
|
+ if (d && contestForm.id === row.id) {
|
|
|
+ contestForm.description = d.description || ''
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .catch(() => {})
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
const handleSave = async () => {
|
|
|
@@ -176,12 +187,12 @@ const handleSave = async () => {
|
|
|
title: contestForm.title!,
|
|
|
description: contestForm.description || undefined,
|
|
|
type: contestForm.type as ContestDto['type'],
|
|
|
- password: contestForm.type === 'password' ? contestForm.password : undefined,
|
|
|
+ password: contestForm.type === 'password' && contestForm.password ? contestForm.password : undefined,
|
|
|
startDatetime: contestForm.startDatetime!,
|
|
|
endDatetime: contestForm.endDatetime!
|
|
|
}
|
|
|
const res = isEdit.value ? await api.edit2(data) : await api.add2(data)
|
|
|
- if (res?.code === 200) {
|
|
|
+ if (res?.code === 0 || res?.code === 200) {
|
|
|
ElMessage.success(isEdit.value ? '修改成功' : '新增成功')
|
|
|
dialogVisible.value = false
|
|
|
fetchData()
|
|
|
@@ -196,7 +207,7 @@ const handleDelete = (row: ContestVo) => {
|
|
|
.then(async () => {
|
|
|
try {
|
|
|
const res = await api.deleteByIds1({ ids: [row.id!] })
|
|
|
- if (res?.code === 200) {
|
|
|
+ if (res?.code === 0 || res?.code === 200) {
|
|
|
ElMessage.success('删除成功')
|
|
|
fetchData()
|
|
|
}
|
|
|
@@ -206,6 +217,10 @@ const handleDelete = (row: ContestVo) => {
|
|
|
.catch(() => {})
|
|
|
}
|
|
|
|
|
|
+const handleDialogClosed = () => {
|
|
|
+ formRef.value?.resetFields()
|
|
|
+}
|
|
|
+
|
|
|
// ---------- 题目配置 ----------
|
|
|
const configDialogVisible = ref(false)
|
|
|
const configContestId = ref<number | undefined>(undefined)
|
|
|
@@ -265,7 +280,7 @@ const loadConfig = async () => {
|
|
|
}
|
|
|
try {
|
|
|
const res = await api.getDetail2(configContestId.value, configPassword.value ? { password: configPassword.value } : undefined)
|
|
|
- if (res?.code === 200 && res.data) {
|
|
|
+ if ((res?.code === 0 || res?.code === 200) && res.data) {
|
|
|
const d = res.data
|
|
|
if (d.type === 'password' && !d.creatorUsername) {
|
|
|
ElMessage.error('比赛密码错误')
|
|
|
@@ -370,7 +385,7 @@ const openRegistrations = (row: ContestVo) => {
|
|
|
api
|
|
|
.queryRegistrations(id)
|
|
|
.then((res) => {
|
|
|
- if (res?.code === 200) {
|
|
|
+ if (res?.code === 0 || res?.code === 200) {
|
|
|
regTable.value = res.data || []
|
|
|
}
|
|
|
})
|
|
|
@@ -444,7 +459,7 @@ onMounted(fetchData)
|
|
|
<el-icon><View /></el-icon>配置题目
|
|
|
</el-button>
|
|
|
<el-button type="primary" link @click="openRegistrations(row)">
|
|
|
- <el-icon><UserFilled /></el-icon>报名
|
|
|
+ <el-icon><UserFilled /></el-icon>报名名单
|
|
|
</el-button>
|
|
|
<el-button v-if="isAdmin" type="danger" link @click="handleDelete(row)">
|
|
|
<el-icon><Delete /></el-icon>删除
|
|
|
@@ -467,13 +482,14 @@ onMounted(fetchData)
|
|
|
</el-card>
|
|
|
|
|
|
<!-- 新增/编辑比赛 -->
|
|
|
- <el-dialog v-model="dialogVisible" :title="dialogTitle" width="560px" draggable>
|
|
|
+ <el-dialog v-model="dialogVisible" :title="dialogTitle" width="560px" draggable @closed="handleDialogClosed">
|
|
|
<el-form ref="formRef" :model="contestForm" :rules="formRules" label-position="top">
|
|
|
<el-form-item label="标题" prop="title">
|
|
|
<el-input v-model="contestForm.title" placeholder="请输入比赛标题" />
|
|
|
</el-form-item>
|
|
|
<el-form-item label="描述">
|
|
|
<el-input v-model="contestForm.description" type="textarea" :rows="3" placeholder="请输入比赛描述" />
|
|
|
+ <span v-if="isEdit" class="tip">留空则不修改描述</span>
|
|
|
</el-form-item>
|
|
|
<el-form-item label="类型" prop="type">
|
|
|
<el-select v-model="contestForm.type" style="width: 200px">
|
|
|
@@ -482,6 +498,7 @@ onMounted(fetchData)
|
|
|
</el-form-item>
|
|
|
<el-form-item v-if="contestForm.type === 'password'" label="访问密码" prop="password">
|
|
|
<el-input v-model="contestForm.password" type="password" show-password placeholder="请输入访问密码" />
|
|
|
+ <span v-if="isEdit" class="tip">留空则不修改密码</span>
|
|
|
</el-form-item>
|
|
|
<el-form-item label="开始时间" prop="startDatetime">
|
|
|
<el-date-picker
|
|
|
@@ -660,4 +677,10 @@ onMounted(fetchData)
|
|
|
.card-title {
|
|
|
font-weight: 600;
|
|
|
}
|
|
|
+
|
|
|
+.tip {
|
|
|
+ font-size: 12px;
|
|
|
+ color: #909399;
|
|
|
+ line-height: 1.4;
|
|
|
+}
|
|
|
</style>
|