feat: füge Auswahl für Spielplan-Team-ID hinzu und lade Teams von der API
This commit is contained in:
@@ -204,15 +204,18 @@
|
|||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<label class="block text-sm font-medium text-gray-700 mb-2">Spielplan-Team-ID</label>
|
<label class="block text-sm font-medium text-gray-700 mb-2">Spielplan-Team-ID</label>
|
||||||
<input
|
<select
|
||||||
v-model="formData.spielplan_mannschaft_id"
|
v-model="formData.spielplan_mannschaft_id"
|
||||||
type="text"
|
|
||||||
class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-primary-500"
|
class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-primary-500"
|
||||||
placeholder="myTischtennis-Team-ID"
|
|
||||||
:disabled="isSaving"
|
:disabled="isSaving"
|
||||||
>
|
>
|
||||||
|
<option value="">Keine ID auswählen</option>
|
||||||
|
<option v-for="team in spielplanTeams" :key="team.id" :value="team.id">
|
||||||
|
{{ team.label }}
|
||||||
|
</option>
|
||||||
|
</select>
|
||||||
<p class="mt-1 text-xs text-gray-500">
|
<p class="mt-1 text-xs text-gray-500">
|
||||||
Verknüpft diese Mannschaft eindeutig mit dem importierten Spielplan.
|
Nach dem myTischtennis-Import das passende Team auswählen.
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
@@ -424,6 +427,7 @@ const isLoading = ref(true)
|
|||||||
const isSaving = ref(false)
|
const isSaving = ref(false)
|
||||||
const isCreatingSeason = ref(false)
|
const isCreatingSeason = ref(false)
|
||||||
const mannschaften = ref([])
|
const mannschaften = ref([])
|
||||||
|
const spielplanTeams = ref([])
|
||||||
const seasons = ref([])
|
const seasons = ref([])
|
||||||
const selectedSeason = ref('')
|
const selectedSeason = ref('')
|
||||||
const showModal = ref(false)
|
const showModal = ref(false)
|
||||||
@@ -516,6 +520,27 @@ const loadMannschaften = async () => {
|
|||||||
} catch (error) { console.error('Fehler beim Laden:', error); errorMessage.value = 'Fehler beim Laden der Mannschaften'; throw error } finally { isLoading.value = false }
|
} catch (error) { console.error('Fehler beim Laden:', error); errorMessage.value = 'Fehler beim Laden der Mannschaften'; throw error } finally { isLoading.value = false }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const loadSpielplanTeams = async () => {
|
||||||
|
try {
|
||||||
|
const response = await fetch('/api/spielplan', { cache: 'no-store' })
|
||||||
|
const result = await response.json()
|
||||||
|
if (!result.success || !Array.isArray(result.data)) return
|
||||||
|
const teams = new Map()
|
||||||
|
for (const row of result.data) {
|
||||||
|
for (const side of ['Heim', 'Gast']) {
|
||||||
|
const isHarheimer = String(row[`${side}VereinNr`] || '') === '43030' || String(row[`${side}VereinName`] || '') === 'Harheimer TC'
|
||||||
|
const id = String(row[`${side}MannschaftId`] || '').trim()
|
||||||
|
if (!isHarheimer || !id || teams.has(id)) continue
|
||||||
|
const label = [row[`${side}Mannschaft`], row[`${side}MannschaftAltersklasse`], row[`${side}MannschaftNr`] ? `Nr. ${row[`${side}MannschaftNr`]}` : ''].filter(Boolean).join(' · ')
|
||||||
|
teams.set(id, { id, label: `${label} [${id}]` })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
spielplanTeams.value = [...teams.values()].sort((a, b) => a.label.localeCompare(b.label, 'de'))
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Spielplan-Teams konnten nicht geladen werden:', error)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const onSeasonChange = async () => {
|
const onSeasonChange = async () => {
|
||||||
await loadMannschaften().catch(() => {})
|
await loadMannschaften().catch(() => {})
|
||||||
}
|
}
|
||||||
@@ -691,7 +716,7 @@ const confirmDelete = (mannschaft, index) => {
|
|||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
await loadSeasons()
|
await loadSeasons()
|
||||||
await loadMannschaften().catch(() => {})
|
await Promise.all([loadMannschaften().catch(() => {}), loadSpielplanTeams()])
|
||||||
})
|
})
|
||||||
|
|
||||||
// Expose load function to parent components
|
// Expose load function to parent components
|
||||||
|
|||||||
Reference in New Issue
Block a user