From 9cef3964e9062ac7b08e76611f4b4931537fa09a Mon Sep 17 00:00:00 2001 From: florianfederspiel Date: Wed, 4 Mar 2026 19:54:12 +0100 Subject: [PATCH] =?UTF-8?q?Serienrechnungen=20ausf=C3=BChrung=20sowie=20An?= =?UTF-8?q?wahl=20und=20liste?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pages/createDocument/serialInvoice.vue | 97 ++++++++++++++++--- 1 file changed, 81 insertions(+), 16 deletions(-) diff --git a/frontend/pages/createDocument/serialInvoice.vue b/frontend/pages/createDocument/serialInvoice.vue index b84c471..bf00716 100644 --- a/frontend/pages/createDocument/serialInvoice.vue +++ b/frontend/pages/createDocument/serialInvoice.vue @@ -158,13 +158,24 @@
- +
+ + + +
@@ -287,6 +301,7 @@ const executionDate = ref(dayjs().format('YYYY-MM-DD')) const selectedExecutionRows = ref([]) const isExecuting = ref(false) const modalSearch = ref("") // NEU: Suchstring für das Modal +const selectedExecutionIntervall = ref("all") // --- SerialExecutions State --- const showExecutionsSlideover = ref(false) @@ -295,7 +310,7 @@ const executionsLoading = ref(false) const finishingId = ref(null) 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() } @@ -390,30 +405,78 @@ const filteredRows = computed(() => { 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(() => { return items.value - .filter(i => i.type === "serialInvoices" && !!i.serialConfig?.active) + .filter(i => i.type === "serialInvoices" && !!i.serialConfig?.active && !i.archived) .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 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() - return activeTemplates.value.filter(row => { + return filtered.filter(row => { const customerName = row.customer?.name?.toLowerCase() || "" const contractNum = row.contract?.contractNumber?.toLowerCase() || "" const contractName = row.contract?.name?.toLowerCase() || "" + const plantName = row.plant?.name?.toLowerCase() || "" return customerName.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) const selectAllTemplates = () => { // WICHTIG: Überschreibt nicht bestehende Auswahl, sondern fügt hinzu oder ersetzt. @@ -469,6 +532,7 @@ const templateColumns = [ const executionColumns = [ {key: 'partner', label: "Kunde"}, + {key: 'plant', label: "Objekt"}, {key: 'contract', label: "Vertrag"}, {key: 'serialConfig.intervall', label: "Intervall"}, {key: "amount", label: "Betrag"}, @@ -509,8 +573,9 @@ const calculateDocSum = (row) => { const openExecutionModal = () => { executionDate.value = dayjs().format('YYYY-MM-DD') - selectedExecutionRows.value = [] modalSearch.value = "" // Reset Search + selectedExecutionIntervall.value = "all" + selectedExecutionRows.value = [] showExecutionModal.value = true } @@ -557,4 +622,4 @@ const executeSerialInvoices = async () => { } setupPage() - \ No newline at end of file +