Add grouped stock view with expiration and location filtering

This commit is contained in:
2026-04-07 00:41:55 +02:00
parent a2819f88d2
commit 385cd95aaf
5 changed files with 550 additions and 21 deletions
+22 -2
View File
@@ -551,6 +551,16 @@ export function labelCreatePageData(store) {
this.syncStockLevelSelect();
});
this.$watch('form.level', () => this.syncStockLevelSelect());
this.$watch('form.productionDate', () => {
if (this.form.expireDays !== '') {
this.syncExpireDateFromDays();
return;
}
if (this.form.expirationDate) {
this.syncExpireDaysFromDate();
}
});
this.syncStockTypeState(this.form.stockType);
this.syncStockTypeSelect();
this.syncStockLevelSelect();
@@ -584,6 +594,14 @@ export function labelCreatePageData(store) {
this.searchDebounced();
},
pickSuggestion(item) {
const baseProductionDate = this.form.productionDate || todayIsoDate();
const expirationDays =
typeof item.expiration_days === 'number'
? item.expiration_days
: item.date && item.expire_date
? diffDays(item.date, item.expire_date)
: null;
this.form.itemId = item.id;
this.form.search = item.name;
this.form.name = item.name;
@@ -595,9 +613,11 @@ export function labelCreatePageData(store) {
: this.form.quantity;
this.form.stockType = item.stock_type || this.form.stockType;
this.form.level = item.level || this.form.level;
this.form.expirationDate = item.expire_date || this.form.expirationDate;
if (expirationDays !== null && expirationDays >= 0) {
this.form.expireDays = String(expirationDays);
this.form.expirationDate = addDaysToIsoDate(baseProductionDate, expirationDays);
}
this.applyItemLocation(item.location_initial_uuid_b64);
this.syncExpireDaysFromDate();
this.suggestions = [];
this.persistDraft();
},