feat: WC2026 赛事 seed、生产上线初始化脚本与目录归档
重构 seed 为 WC2026 72 场小组赛与 48 强优胜盘;新增 production 模式仅保留 admin 与赛事示例;提供 prod-init-db 全量重置脚本;管理端 i18n 分包与赛事归档能力。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, ref, watch } from 'vue';
|
||||
import { useRouter } from 'vue-router';
|
||||
import { ElMessage, ElMessageBox } from 'element-plus';
|
||||
import { useAdminLocale } from '../../composables/useAdminLocale';
|
||||
import api from '../../api';
|
||||
@@ -48,6 +49,9 @@ const emit = defineEmits<{
|
||||
}>();
|
||||
|
||||
const { t, locale } = useAdminLocale();
|
||||
const router = useRouter();
|
||||
|
||||
const matchStatus = ref('');
|
||||
|
||||
function teamDisplayName(row: { teamCode: string; teamZh: string; teamEn: string }) {
|
||||
return teamRowDisplayName(row, locale.value);
|
||||
@@ -55,8 +59,11 @@ function teamDisplayName(row: { teamCode: string; teamZh: string; teamEn: string
|
||||
|
||||
const loading = ref(false);
|
||||
const savingOdds = ref(false);
|
||||
const reopening = ref(false);
|
||||
const adding = ref(false);
|
||||
const matchId = ref('');
|
||||
const leagueIsPublished = ref(true);
|
||||
const unsettledFixtureCount = ref(0);
|
||||
const selections = ref<SelectionRow[]>([]);
|
||||
|
||||
const addVisible = ref(false);
|
||||
@@ -133,6 +140,95 @@ const sortedSelections = computed(() => {
|
||||
return rows;
|
||||
});
|
||||
|
||||
const canCloseOutright = computed(() => matchStatus.value === 'PUBLISHED');
|
||||
const canReopenOutright = computed(() =>
|
||||
['CLOSED', 'PENDING_SETTLEMENT'].includes(matchStatus.value),
|
||||
);
|
||||
const canSettleOutright = computed(() =>
|
||||
['CLOSED', 'PENDING_SETTLEMENT', 'SETTLED'].includes(matchStatus.value),
|
||||
);
|
||||
const canProceedSettle = computed(
|
||||
() => matchStatus.value === 'SETTLED' || unsettledFixtureCount.value === 0,
|
||||
);
|
||||
const showLeagueUnpublishedHint = computed(
|
||||
() => !leagueIsPublished.value && matchStatus.value === 'DRAFT',
|
||||
);
|
||||
const showUnsettledFixturesHint = computed(
|
||||
() =>
|
||||
unsettledFixtureCount.value > 0 &&
|
||||
['CLOSED', 'PENDING_SETTLEMENT'].includes(matchStatus.value),
|
||||
);
|
||||
const settleButtonLabel = computed(() =>
|
||||
matchStatus.value === 'SETTLED' ? t('common.resettle') : t('common.settle'),
|
||||
);
|
||||
const statusLabel = computed(() => {
|
||||
const key = `match.status.${matchStatus.value}`;
|
||||
const label = t(key);
|
||||
return label === key ? matchStatus.value : label;
|
||||
});
|
||||
const statusTagType = computed(() => {
|
||||
switch (matchStatus.value) {
|
||||
case 'PUBLISHED':
|
||||
return 'success';
|
||||
case 'CLOSED':
|
||||
case 'PENDING_SETTLEMENT':
|
||||
return 'warning';
|
||||
case 'SETTLED':
|
||||
return 'info';
|
||||
default:
|
||||
return 'info';
|
||||
}
|
||||
});
|
||||
|
||||
async function reopenOutright() {
|
||||
if (!matchId.value) return;
|
||||
try {
|
||||
await ElMessageBox.confirm(t('outright.confirm_reopen'), t('common.confirm'), {
|
||||
type: 'warning',
|
||||
});
|
||||
} catch {
|
||||
return;
|
||||
}
|
||||
reopening.value = true;
|
||||
try {
|
||||
await api.post(`/admin/matches/${matchId.value}/reopen`);
|
||||
ElMessage.success(t('msg.reopened'));
|
||||
await load();
|
||||
emit('updated');
|
||||
} catch (e: unknown) {
|
||||
const err = e as { response?: { data?: { error?: string } } };
|
||||
ElMessage.error(err.response?.data?.error ?? t('msg.save_failed'));
|
||||
} finally {
|
||||
reopening.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
async function closeOutright() {
|
||||
if (!matchId.value) return;
|
||||
try {
|
||||
await ElMessageBox.confirm(t('outright.confirm_close'), t('common.confirm'), {
|
||||
type: 'warning',
|
||||
});
|
||||
} catch {
|
||||
return;
|
||||
}
|
||||
await api.post(`/admin/matches/${matchId.value}/close`);
|
||||
ElMessage.success(t('msg.closed'));
|
||||
await load();
|
||||
emit('updated');
|
||||
}
|
||||
|
||||
function goSettle() {
|
||||
if (!matchId.value) return;
|
||||
if (!canProceedSettle.value) {
|
||||
ElMessage.warning(
|
||||
t('outright.unsettled_fixtures_hint', { n: unsettledFixtureCount.value }),
|
||||
);
|
||||
return;
|
||||
}
|
||||
void router.push(`/settlement/${matchId.value}`);
|
||||
}
|
||||
|
||||
async function load() {
|
||||
if (!props.leagueId) return;
|
||||
loading.value = true;
|
||||
@@ -140,6 +236,9 @@ async function load() {
|
||||
const { data } = await api.get(`/admin/leagues/${props.leagueId}/outright`);
|
||||
const payload = data.data as {
|
||||
id: string;
|
||||
status?: string;
|
||||
leagueIsPublished?: boolean;
|
||||
unsettledFixtureCount?: number;
|
||||
fixtureSyncAdded?: number;
|
||||
fixtureSyncReopened?: number;
|
||||
selections: Array<{
|
||||
@@ -154,6 +253,9 @@ async function load() {
|
||||
}>;
|
||||
};
|
||||
matchId.value = payload.id;
|
||||
matchStatus.value = payload.status ?? '';
|
||||
leagueIsPublished.value = payload.leagueIsPublished ?? true;
|
||||
unsettledFixtureCount.value = payload.unsettledFixtureCount ?? 0;
|
||||
selections.value = (payload.selections ?? [])
|
||||
.filter((s) => s.status === 'OPEN')
|
||||
.map((s) => ({
|
||||
@@ -472,8 +574,48 @@ watch(
|
||||
<template>
|
||||
<div v-loading="loading" class="outright-odds-panel">
|
||||
<div class="outright-odds-panel__head">
|
||||
<p class="outright-odds-panel__hint">{{ t('outright.odds_only_hint') }}</p>
|
||||
<div class="outright-odds-panel__head-text">
|
||||
<p class="outright-odds-panel__hint">{{ t('outright.odds_only_hint') }}</p>
|
||||
<p v-if="showLeagueUnpublishedHint" class="outright-odds-panel__workflow-hint">
|
||||
{{ t('outright.league_unpublished_hint') }}
|
||||
</p>
|
||||
<p v-if="showUnsettledFixturesHint" class="outright-odds-panel__workflow-hint">
|
||||
{{ t('outright.unsettled_fixtures_hint', { n: unsettledFixtureCount }) }}
|
||||
</p>
|
||||
</div>
|
||||
<div class="outright-odds-panel__actions">
|
||||
<el-tag v-if="matchStatus" size="small" :type="statusTagType" effect="dark">
|
||||
{{ statusLabel }}
|
||||
</el-tag>
|
||||
<el-button
|
||||
v-if="canCloseOutright"
|
||||
type="warning"
|
||||
plain
|
||||
size="small"
|
||||
@click="closeOutright"
|
||||
>
|
||||
{{ t('outright.btn.close') }}
|
||||
</el-button>
|
||||
<el-button
|
||||
v-if="canReopenOutright"
|
||||
type="primary"
|
||||
plain
|
||||
size="small"
|
||||
:loading="reopening"
|
||||
@click="reopenOutright"
|
||||
>
|
||||
{{ t('outright.btn.reopen') }}
|
||||
</el-button>
|
||||
<el-button
|
||||
v-if="canSettleOutright"
|
||||
type="success"
|
||||
plain
|
||||
size="small"
|
||||
:disabled="!canProceedSettle"
|
||||
@click="goSettle"
|
||||
>
|
||||
{{ settleButtonLabel }}
|
||||
</el-button>
|
||||
<el-button
|
||||
v-if="selections.length"
|
||||
:type="batchMode ? 'warning' : 'default'"
|
||||
@@ -763,13 +905,17 @@ watch(
|
||||
}
|
||||
.outright-odds-panel__head {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
align-items: flex-start;
|
||||
justify-content: space-between;
|
||||
gap: 12px;
|
||||
flex-wrap: wrap;
|
||||
flex-shrink: 0;
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
.outright-odds-panel__head-text {
|
||||
flex: 1;
|
||||
min-width: 200px;
|
||||
}
|
||||
.outright-odds-panel__actions {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
@@ -782,6 +928,12 @@ watch(
|
||||
color: #777;
|
||||
line-height: 1.5;
|
||||
}
|
||||
.outright-odds-panel__workflow-hint {
|
||||
margin: 6px 0 0;
|
||||
font-size: 12px;
|
||||
color: #e6a23c;
|
||||
line-height: 1.5;
|
||||
}
|
||||
.outright-odds-panel__batch {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
||||
Reference in New Issue
Block a user