Added supplier and updated dependencies.

This commit is contained in:
2026-07-22 19:26:57 +02:00
parent cddd9a3956
commit 581439150f
16 changed files with 3585 additions and 3068 deletions
+70
View File
@@ -7,6 +7,7 @@ import type {Variant} from "~/types/variant";
import {Unit} from "~/types/unit";
import type {Label} from "~/types/label";
import type {Settings} from "~/types/settings";
import type {Supplier} from "~/types/supplier";
interface State {
config: RuntimeConfig,
@@ -29,6 +30,8 @@ interface State {
origins: Array<Origin>,
units: Array<Unit>,
suppliers: Array<Supplier>,
}
export const useLabelEditorStore = defineStore('label_editor_store', {
@@ -64,6 +67,8 @@ export const useLabelEditorStore = defineStore('label_editor_store', {
Unit.L,
Unit.Stk,
],
suppliers: [],
}),
actions: {
// Notification
@@ -385,5 +390,70 @@ export const useLabelEditorStore = defineStore('label_editor_store', {
this.addNotification(true, 'Kann Variante nicht gelöscht werden. Es ist kein Artikel ausgewählt.');
}
},
// Supplier:
async loadSuppliers() {
try {
const suppliers: Array<Supplier> = await $fetch<Array<Supplier>>(this.config.public.url + '/supplier', {
method: 'GET',
});
this.suppliers = suppliers;
this.addNotification(false, 'Lieferanten geladen');
} catch {
this.addNotification(true, 'Fehler beim laden der Lieferanten');
}
},
async createSupplier(supplier: Supplier) {
try {
let createdSupplier = await $fetch<Supplier>(this.config.public.url + '/supplier', {
method: 'POST',
body: JSON.stringify(supplier),
});
this.suppliers.push(createdSupplier);
this.addNotification(false, 'Lieferant "' + createdSupplier.name + '" erstellt');
} catch {
this.addNotification(true, 'Fehler beim erstellen des Lieferant: ' + supplier.name);
}
},
async updateSupplier(supplier: Supplier) {
let labelIndex = this.labels.findIndex(i => i.id === supplier.id);
try {
let updatedSupplier = await $fetch<Supplier>(this.config.public.url + '/supplier/' + supplier.id, {
method: 'POST',
body: JSON.stringify(supplier),
});
this.labels[labelIndex] = updatedSupplier;
this.addNotification(false, 'Lieferant aktualisiert.');
} catch {
this.addNotification(true, 'Fehler beim aktualisieren des Lieferanten.');
}
},
async deleteSupplier(supplierID: number) {
let supplierIndex = this.suppliers.findIndex(i => i.id === supplierID);
try {
await $fetch(this.config.public.url + '/supplier/' + supplierID, {
method: 'DELETE',
});
this.suppliers.splice(supplierIndex, 1);
this.addNotification(false, 'Lieferant gelöscht.');
} catch {
this.addNotification(true, 'Fehler beim löschen des Lieferanten.');
}
},
},
});