fixed warehousearticlepacket editing

This commit is contained in:
Luca Haid
2025-06-05 11:17:36 +02:00
parent 45811a3e24
commit 858d528525
4 changed files with 46 additions and 77 deletions
@@ -17,6 +17,15 @@ Vue.component('tt-resolver', {
<span v-else>{{ text }}</span>
`,
async created() {
const cacheKey = `${this.reference}_${this.value}_${this.autocomplete}`;
const cached = JSON.parse(localStorage.getItem(cacheKey) || 'null');
if (cached && Date.now() - cached.timestamp < 1800000) {
this.text = cached.text;
this.loading = false;
return;
}
const endpoint = this.autocomplete
? `${window.TT_CONFIG["BASE_PATH"]}${this.reference}?searchedID=${this.value}`
: `${window.TT_CONFIG["BASE_PATH"]}/${this.reference}/getById?id=${this.value}`;
@@ -25,6 +34,8 @@ Vue.component('tt-resolver', {
if (this.reference === 'WarehouseArticle') this.text = `${data.articleNumber} | ${data.title}`;
else this.text = this.autocomplete ? data[0]?.text : data.name ?? data.title ?? data.text ?? '[E] Key not found';
localStorage.setItem(cacheKey, JSON.stringify({ text: this.text, timestamp: Date.now() }));
this.loading = false;
}
});