added new calendar meta to shipping note

This commit is contained in:
Luca Haid
2025-09-01 11:32:12 +02:00
parent b887830988
commit f2d5517b85
5 changed files with 109 additions and 15 deletions
@@ -306,6 +306,11 @@ Vue.component('warehouse-shipping-note-see-through', {
</template>
</template>
</div>
<div v-if="calendarEventType" style="margin-top: 10px; font-style: italic; color: #555;">
<i class="fas fa-calendar-alt" style="margin-right: 5px;"></i>
Erstellt aus Kalendereintrag: {{ calendarEventType }}
</div>
</div>
<div v-if="activeTab === 'Editieren'" style="flex: 1; overflow: auto;" class="see-through-test-modal">
@@ -341,6 +346,21 @@ Vue.component('warehouse-shipping-note-see-through', {
computed: {
currentRow() {
return this.rows[0];
},
calendarEventType() {
if (!this.currentRow || !this.currentRow.metadata) {
return null;
}
try {
const metadata = JSON.parse(this.currentRow.metadata);
if (metadata && metadata.from_calendar === true && metadata.event_type_text) {
return metadata.event_type_text;
}
} catch (e) {
console.error("Could not parse shipping note metadata:", e);
return null;
}
return null;
}
},
methods: {
@@ -550,10 +570,40 @@ Vue.component('warehouse-shipping-note', {
const locationParts = event.location.split(',');
const line = locationParts.slice(0, -1).join(',').trim();
const plzCityRaw = locationParts.slice(-1)[0].trim();
const plzMatch = plzCityRaw.match(/^(\d+)/);
const plzMatch = plzCityRaw.match(/^(\\d+)/);
const plz = plzMatch ? plzMatch[1] : '';
const city = plzCityRaw.replace(/^\d+\s*/, '').trim();
const city = plzCityRaw.replace(/^\\d+\\s*/, '').trim();
// Create metadata object
const eventTypeMap = {
'2': 'Xinon Inbetriebnahmen',
'3': 'ESTMK Inbetriebnahmen',
'7': 'Sbidi Inbetriebnahmen',
'4': 'SNOPP',
'5': 'Störungen',
'6': 'Support Gespräch'
};
const eventTypeText = eventTypeMap[event.event_type] || 'Unbekannter Termintyp';
const metadata = {
from_calendar: true,
event_type_id: event.event_type,
event_type_text: eventTypeText
};
// Check for default positions for SBIDI event type
let defaultPositions = [];
if (event.event_type === '7') {
defaultPositions = [
{"article": 56, "amount": "1", "isEnergieMaterial": 1},
{"article": 71, "amount": "1", "isEnergieMaterial": 1},
{"article": 134, "amount": "1", "isEnergieMaterial": 1},
{"article": 324, "isEnergieMaterial": 1, "amount": "1"},
{"article": 325, "amount": "1", "isEnergieMaterial": 1},
{"article": 539, "amount": "1", "isEnergieMaterial": 1},
{"article": 660, "amount": "1", "isEnergieMaterial": 1}
];
}
// Directly set the data in the modal's `shippingNote` object
const modalData = this.$refs.modal.shippingNote;
@@ -561,6 +611,11 @@ Vue.component('warehouse-shipping-note', {
this.$set(modalData, 'deliveryAddressLine', line);
this.$set(modalData, 'deliveryAddressPLZ', plz);
this.$set(modalData, 'deliveryAddressCity', city);
this.$set(modalData, 'metadata', metadata); // Set metadata
if (defaultPositions.length > 0) {
this.$set(modalData, 'positions', defaultPositions); // Set default positions
}
}
},
closeDropdown(event) {
@@ -18,6 +18,7 @@ Vue.component('warehouse-shipping-note-modal', {
deliveryAddressPLZ: '',
deliveryAddressCity: '',
status: 'new',
metadata: null,
positions: [],
textElements: [],
hoursEntries: [],
@@ -196,7 +197,12 @@ Vue.component('warehouse-shipping-note-modal', {
if (this.id === 'create') return;
const {data} = await axios.get(`${window.TT_CONFIG["BASE_PATH"]}/WarehouseShippingNote/getById`, {params: {id: this.id}});
this.shippingNote = {...data, positions: JSON.parse(data.positions), hoursEntries: JSON.parse(data.hoursEntries)};
this.shippingNote = {
...data,
positions: JSON.parse(data.positions),
hoursEntries: JSON.parse(data.hoursEntries),
metadata: data.metadata ? JSON.parse(data.metadata) : null
};
},
watch: {
geoAddr: async function() {