generated from VLADIMIR/template_frontend
up
This commit is contained in:
@@ -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">
|
||||
|
||||
Reference in New Issue
Block a user