Serienrechnungen ausführung sowie Anwahl und liste
This commit is contained in:
@@ -158,13 +158,24 @@
|
|||||||
<UDivider label="Vorlagen auswählen" />
|
<UDivider label="Vorlagen auswählen" />
|
||||||
|
|
||||||
<div class="flex flex-col sm:flex-row sm:items-center justify-between gap-3">
|
<div class="flex flex-col sm:flex-row sm:items-center justify-between gap-3">
|
||||||
<UInput
|
<div class="flex flex-col sm:flex-row gap-2 w-full sm:w-auto">
|
||||||
v-model="modalSearch"
|
<UInput
|
||||||
icon="i-heroicons-magnifying-glass"
|
v-model="modalSearch"
|
||||||
placeholder="Kunde oder Vertrag suchen..."
|
icon="i-heroicons-magnifying-glass"
|
||||||
class="w-full sm:w-64"
|
placeholder="Kunde oder Vertrag suchen..."
|
||||||
size="sm"
|
class="w-full sm:w-64"
|
||||||
/>
|
size="sm"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<USelectMenu
|
||||||
|
v-model="selectedExecutionIntervall"
|
||||||
|
:options="executionIntervallOptions"
|
||||||
|
option-attribute="label"
|
||||||
|
value-attribute="value"
|
||||||
|
size="sm"
|
||||||
|
class="w-full sm:w-52"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="flex items-center gap-2">
|
<div class="flex items-center gap-2">
|
||||||
<span class="text-xs text-gray-500 hidden sm:inline">
|
<span class="text-xs text-gray-500 hidden sm:inline">
|
||||||
@@ -201,11 +212,14 @@
|
|||||||
{{displayCurrency(calculateDocSum(row))}}
|
{{displayCurrency(calculateDocSum(row))}}
|
||||||
</template>
|
</template>
|
||||||
<template #serialConfig.intervall-data="{row}">
|
<template #serialConfig.intervall-data="{row}">
|
||||||
{{ row.serialConfig?.intervall }}
|
{{ getIntervallLabel(row.serialConfig?.intervall) }}
|
||||||
</template>
|
</template>
|
||||||
<template #contract-data="{row}">
|
<template #contract-data="{row}">
|
||||||
{{row.contract?.contractNumber}} - {{row.contract?.name}}
|
{{row.contract?.contractNumber}} - {{row.contract?.name}}
|
||||||
</template>
|
</template>
|
||||||
|
<template #plant-data="{row}">
|
||||||
|
{{ row.plant?.name || "-" }}
|
||||||
|
</template>
|
||||||
</UTable>
|
</UTable>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -287,6 +301,7 @@ const executionDate = ref(dayjs().format('YYYY-MM-DD'))
|
|||||||
const selectedExecutionRows = ref([])
|
const selectedExecutionRows = ref([])
|
||||||
const isExecuting = ref(false)
|
const isExecuting = ref(false)
|
||||||
const modalSearch = ref("") // NEU: Suchstring für das Modal
|
const modalSearch = ref("") // NEU: Suchstring für das Modal
|
||||||
|
const selectedExecutionIntervall = ref("all")
|
||||||
|
|
||||||
// --- SerialExecutions State ---
|
// --- SerialExecutions State ---
|
||||||
const showExecutionsSlideover = ref(false)
|
const showExecutionsSlideover = ref(false)
|
||||||
@@ -295,7 +310,7 @@ const executionsLoading = ref(false)
|
|||||||
const finishingId = ref(null)
|
const finishingId = ref(null)
|
||||||
|
|
||||||
const setupPage = async () => {
|
const setupPage = async () => {
|
||||||
items.value = await useEntities("createddocuments").select("*, customer(id,name), contract(id,name, contractNumber)","documentDate",undefined,true)
|
items.value = await useEntities("createddocuments").select("*, customer(id,name), contract(id,name, contractNumber), plant(id,name)","documentDate",undefined,true)
|
||||||
await fetchExecutions()
|
await fetchExecutions()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -390,30 +405,78 @@ const filteredRows = computed(() => {
|
|||||||
return useSearch(searchString.value, temp.slice().reverse())
|
return useSearch(searchString.value, temp.slice().reverse())
|
||||||
})
|
})
|
||||||
|
|
||||||
// Basis Liste für das Modal (nur Aktive)
|
// Basis Liste für das Modal (nur aktive und nicht archivierte Vorlagen)
|
||||||
const activeTemplates = computed(() => {
|
const activeTemplates = computed(() => {
|
||||||
return items.value
|
return items.value
|
||||||
.filter(i => i.type === "serialInvoices" && !!i.serialConfig?.active)
|
.filter(i => i.type === "serialInvoices" && !!i.serialConfig?.active && !i.archived)
|
||||||
.map(i => ({...i}))
|
.map(i => ({...i}))
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const intervallLabelMap = {
|
||||||
|
"wöchentlich": "Wöchentlich",
|
||||||
|
"2 - wöchentlich": "Alle 2 Wochen",
|
||||||
|
"monatlich": "Monatlich",
|
||||||
|
"vierteljährlich": "Quartalsweise",
|
||||||
|
"halbjährlich": "Halbjährlich",
|
||||||
|
"jährlich": "Jährlich"
|
||||||
|
}
|
||||||
|
|
||||||
|
const getIntervallLabel = (intervall) => {
|
||||||
|
if (!intervall) return "-"
|
||||||
|
return intervallLabelMap[intervall] || intervall
|
||||||
|
}
|
||||||
|
|
||||||
|
const executionIntervallOptions = computed(() => {
|
||||||
|
const availableIntervals = [...new Set(
|
||||||
|
activeTemplates.value
|
||||||
|
.map(row => row.serialConfig?.intervall)
|
||||||
|
.filter(Boolean)
|
||||||
|
)]
|
||||||
|
|
||||||
|
const sorted = availableIntervals.sort((a, b) =>
|
||||||
|
getIntervallLabel(a).localeCompare(getIntervallLabel(b), 'de')
|
||||||
|
)
|
||||||
|
|
||||||
|
return [
|
||||||
|
{label: 'Alle Intervalle', value: 'all'},
|
||||||
|
...sorted.map(intervall => ({
|
||||||
|
label: getIntervallLabel(intervall),
|
||||||
|
value: intervall
|
||||||
|
}))
|
||||||
|
]
|
||||||
|
})
|
||||||
|
|
||||||
// NEU: Gefilterte Liste für das Modal basierend auf der Suche
|
// NEU: Gefilterte Liste für das Modal basierend auf der Suche
|
||||||
const filteredExecutionList = computed(() => {
|
const filteredExecutionList = computed(() => {
|
||||||
if (!modalSearch.value) return activeTemplates.value
|
let filtered = [...activeTemplates.value]
|
||||||
|
|
||||||
|
if (selectedExecutionIntervall.value !== 'all') {
|
||||||
|
filtered = filtered.filter(
|
||||||
|
row => row.serialConfig?.intervall === selectedExecutionIntervall.value
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!modalSearch.value) return filtered
|
||||||
|
|
||||||
const term = modalSearch.value.toLowerCase()
|
const term = modalSearch.value.toLowerCase()
|
||||||
|
|
||||||
return activeTemplates.value.filter(row => {
|
return filtered.filter(row => {
|
||||||
const customerName = row.customer?.name?.toLowerCase() || ""
|
const customerName = row.customer?.name?.toLowerCase() || ""
|
||||||
const contractNum = row.contract?.contractNumber?.toLowerCase() || ""
|
const contractNum = row.contract?.contractNumber?.toLowerCase() || ""
|
||||||
const contractName = row.contract?.name?.toLowerCase() || ""
|
const contractName = row.contract?.name?.toLowerCase() || ""
|
||||||
|
const plantName = row.plant?.name?.toLowerCase() || ""
|
||||||
|
|
||||||
return customerName.includes(term) ||
|
return customerName.includes(term) ||
|
||||||
contractNum.includes(term) ||
|
contractNum.includes(term) ||
|
||||||
contractName.includes(term)
|
contractName.includes(term) ||
|
||||||
|
plantName.includes(term)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
watch(selectedExecutionIntervall, () => {
|
||||||
|
selectedExecutionRows.value = [...filteredExecutionList.value]
|
||||||
|
})
|
||||||
|
|
||||||
// NEU: Alle auswählen (nur die aktuell sichtbaren/gefilterten)
|
// NEU: Alle auswählen (nur die aktuell sichtbaren/gefilterten)
|
||||||
const selectAllTemplates = () => {
|
const selectAllTemplates = () => {
|
||||||
// WICHTIG: Überschreibt nicht bestehende Auswahl, sondern fügt hinzu oder ersetzt.
|
// WICHTIG: Überschreibt nicht bestehende Auswahl, sondern fügt hinzu oder ersetzt.
|
||||||
@@ -469,6 +532,7 @@ const templateColumns = [
|
|||||||
|
|
||||||
const executionColumns = [
|
const executionColumns = [
|
||||||
{key: 'partner', label: "Kunde"},
|
{key: 'partner', label: "Kunde"},
|
||||||
|
{key: 'plant', label: "Objekt"},
|
||||||
{key: 'contract', label: "Vertrag"},
|
{key: 'contract', label: "Vertrag"},
|
||||||
{key: 'serialConfig.intervall', label: "Intervall"},
|
{key: 'serialConfig.intervall', label: "Intervall"},
|
||||||
{key: "amount", label: "Betrag"},
|
{key: "amount", label: "Betrag"},
|
||||||
@@ -509,8 +573,9 @@ const calculateDocSum = (row) => {
|
|||||||
|
|
||||||
const openExecutionModal = () => {
|
const openExecutionModal = () => {
|
||||||
executionDate.value = dayjs().format('YYYY-MM-DD')
|
executionDate.value = dayjs().format('YYYY-MM-DD')
|
||||||
selectedExecutionRows.value = []
|
|
||||||
modalSearch.value = "" // Reset Search
|
modalSearch.value = "" // Reset Search
|
||||||
|
selectedExecutionIntervall.value = "all"
|
||||||
|
selectedExecutionRows.value = []
|
||||||
showExecutionModal.value = true
|
showExecutionModal.value = true
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -557,4 +622,4 @@ const executeSerialInvoices = async () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
setupPage()
|
setupPage()
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
Reference in New Issue
Block a user