fix:添加评审时间控制
This commit is contained in:
parent
41e0550589
commit
39f0d074a2
@ -5,36 +5,34 @@
|
||||
</a-card>
|
||||
|
||||
<!-- 数据表格 -->
|
||||
<a-table
|
||||
:columns="columns"
|
||||
:data-source="dataSource"
|
||||
:loading="loading"
|
||||
:pagination="false"
|
||||
row-key="contestId"
|
||||
>
|
||||
<a-table :columns="columns" :data-source="dataSource" :loading="loading" :pagination="false" row-key="contestId">
|
||||
<template #bodyCell="{ column, record, index }">
|
||||
<template v-if="column.key === 'index'">
|
||||
{{ index + 1 }}
|
||||
</template>
|
||||
<template v-else-if="column.key === 'contestName'">
|
||||
<a @click="handleViewDetail(record)">{{ record.contestName }}</a>
|
||||
<span v-if="!isWithinReviewWindow(record)">{{ record.contestName }}</span>
|
||||
<a v-else @click="handleViewDetail(record)">{{ record.contestName }}</a>
|
||||
</template>
|
||||
<template v-else-if="column.key === 'progress'">
|
||||
<a-progress
|
||||
:percent="getProgressPercent(record)"
|
||||
:status="getProgressStatus(record)"
|
||||
size="small"
|
||||
style="width: 120px"
|
||||
/>
|
||||
<a-progress :percent="getProgressPercent(record)" :status="getProgressStatus(record)" size="small"
|
||||
style="width: 120px" />
|
||||
<span class="progress-text">{{ record.reviewed }}/{{ record.totalAssigned }}</span>
|
||||
</template>
|
||||
<template v-else-if="column.key === 'reviewStatus'">
|
||||
<a-tag v-if="record.totalAssigned > 0 && record.pending === 0" color="success">已完成</a-tag>
|
||||
<a-tag v-else-if="record.totalAssigned === 0" color="default">无分配</a-tag>
|
||||
<a-tag v-else-if="!isWithinReviewWindow(record)" color="processing">评审待开始</a-tag>
|
||||
<a-tag v-else color="processing">评审中</a-tag>
|
||||
|
||||
</template>
|
||||
<template v-else-if="column.key === 'action'">
|
||||
<a-button type="link" size="small" @click="handleViewDetail(record)">
|
||||
<a-tooltip v-if="!isWithinReviewWindow(record)" :title="getReviewActionTooltip(record)">
|
||||
<span class="review-action-wrap">
|
||||
<a-button type="link" size="small" disabled>进入评审</a-button>
|
||||
</span>
|
||||
</a-tooltip>
|
||||
<a-button v-else type="link" size="small" @click="handleViewDetail(record)">
|
||||
进入评审
|
||||
</a-button>
|
||||
</template>
|
||||
@ -107,6 +105,43 @@ const getProgressStatus = (record: any) => {
|
||||
return "active"
|
||||
}
|
||||
|
||||
/** 与后端 getJudgeContests 返回的 reviewStartTime / reviewEndTime 对齐;均未配置时不限制 */
|
||||
const isWithinReviewWindow = (record: {
|
||||
reviewStartTime?: string | null
|
||||
reviewEndTime?: string | null
|
||||
}): boolean => {
|
||||
const now = Date.now()
|
||||
const tStart = record.reviewStartTime
|
||||
? new Date(record.reviewStartTime).getTime()
|
||||
: null
|
||||
const tEnd = record.reviewEndTime ? new Date(record.reviewEndTime).getTime() : null
|
||||
if (tStart == null && tEnd == null) return true
|
||||
if (tStart != null && !Number.isNaN(tStart) && now < tStart) return false
|
||||
if (tEnd != null && !Number.isNaN(tEnd) && now > tEnd) return false
|
||||
return true
|
||||
}
|
||||
|
||||
const fmtTime = (iso?: string | null) => {
|
||||
if (!iso) return ""
|
||||
const d = new Date(iso)
|
||||
return Number.isNaN(d.getTime()) ? String(iso) : d.toLocaleString("zh-CN", { hour12: false })
|
||||
}
|
||||
|
||||
const getReviewActionTooltip = (record: any): string => {
|
||||
const now = Date.now()
|
||||
const tStart = record.reviewStartTime
|
||||
? new Date(record.reviewStartTime).getTime()
|
||||
: null
|
||||
const tEnd = record.reviewEndTime ? new Date(record.reviewEndTime).getTime() : null
|
||||
if (tStart != null && !Number.isNaN(tStart) && now < tStart) {
|
||||
return `评审尚未开始${record.reviewStartTime ? `(${fmtTime(record.reviewStartTime)} 起)` : ""}`
|
||||
}
|
||||
if (tEnd != null && !Number.isNaN(tEnd) && now > tEnd) {
|
||||
return `评审已结束${record.reviewEndTime ? `(已于 ${fmtTime(record.reviewEndTime)} 截止)` : ""}`
|
||||
}
|
||||
return "当前不在评审时间范围内"
|
||||
}
|
||||
|
||||
// 加载数据
|
||||
const fetchList = async () => {
|
||||
loading.value = true
|
||||
@ -184,21 +219,21 @@ $gradient-primary: linear-gradient(135deg, $primary 0%, $primary-dark 100%);
|
||||
overflow: hidden;
|
||||
|
||||
.ant-table {
|
||||
.ant-table-thead > tr > th {
|
||||
.ant-table-thead>tr>th {
|
||||
background: #fafafa;
|
||||
font-weight: 600;
|
||||
color: rgba(0, 0, 0, 0.85);
|
||||
border-bottom: 1px solid #f0f0f0;
|
||||
}
|
||||
|
||||
.ant-table-tbody > tr {
|
||||
.ant-table-tbody>tr {
|
||||
transition: all 0.2s ease;
|
||||
|
||||
&:hover > td {
|
||||
&:hover>td {
|
||||
background: rgba($primary, 0.04);
|
||||
}
|
||||
|
||||
> td {
|
||||
>td {
|
||||
border-bottom: 1px solid #f5f5f5;
|
||||
}
|
||||
}
|
||||
@ -220,4 +255,9 @@ $gradient-primary: linear-gradient(135deg, $primary 0%, $primary-dark 100%);
|
||||
font-size: 12px;
|
||||
color: #666;
|
||||
}
|
||||
|
||||
.review-action-wrap {
|
||||
display: inline-block;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
</style>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user