This commit is contained in:
2026-10-12 15:58:46 +07:00
parent 4a89dd1d74
commit c153ee817a
4 changed files with 63 additions and 0 deletions
+29
View File
@@ -66,6 +66,7 @@ const emit = defineEmits<{ resultsApplied: [] }>()
const client = getAuthClient()
const binaryClient = getBinaryClient()
const isDownloadingQR = ref(false)
const isDownloadingPrintMaterials = ref(false)
const router = useRouter()
const route = useRoute()
const gameId = route.params.id
@@ -731,6 +732,27 @@ async function applyResults() {
}
}
async function downloadPrintMaterials() {
const id = game.value.ID
if (!canManageGame.value || !id || isDownloadingPrintMaterials.value) return
isDownloadingPrintMaterials.value = true
try {
const { blob, filename } = await binaryClient.downloadGamePrintMaterials(id)
const url = URL.createObjectURL(blob)
const link = document.createElement('a')
link.href = url
link.download = filename
document.body.appendChild(link)
link.click()
link.remove()
setTimeout(() => URL.revokeObjectURL(url), 1000)
} catch (err) {
message.error(err instanceof Error ? err.message : 'Не удалось скачать материалы для печати')
} finally {
isDownloadingPrintMaterials.value = false
}
}
async function downloadTeamQR() {
if (isDownloadingQR.value || !game.value.teams?.length) return
isDownloadingQR.value = true
@@ -1073,6 +1095,13 @@ useSimplePolling(() => {
<div class="game-tab-content">
<UiBlock>
<n-flex justify="end">
<n-button
:loading="isDownloadingPrintMaterials"
:disabled="!game.ID || isDownloadingPrintMaterials"
@click="downloadPrintMaterials"
>
Скачать материалы для печати
</n-button>
<n-button quaternary @click="openQR(url, 'Админка')">QR</n-button>
<n-button v-if="game.status == 'finish'" quaternary @click="toResults()">
<Icon class="settings-icon">