fixed cancelling order and minified component

This commit is contained in:
Luca Haid
2025-04-07 15:42:27 +02:00
parent 3e462a6632
commit 1ac70d907d
@@ -91,38 +91,33 @@ Vue.component('order-request-log', {
logs: [] logs: []
}), }),
async mounted() { async mounted() {
const response = await axios.get(`${window.TT_CONFIG["BASE_PATH"]}/WarehouseOrderRequest/getLogById`, {params: {orderRequestId: this.orderRequestId}}); const [{data: logs}, {data: order}] = await Promise.all([
this.logs = response.data; axios.get(`${window.TT_CONFIG["BASE_PATH"]}/WarehouseOrderRequest/getLogById`, {params: {orderRequestId: this.orderRequestId}}),
axios.get(`${window.TT_CONFIG["BASE_PATH"]}/WarehouseOrderRequest/getById`, {params: {id: this.orderRequestId}})
]);
this.logs = logs;
const response2 = await axios.get(`${window.TT_CONFIG["BASE_PATH"]}/WarehouseOrderRequest/getById`, {params: {id: this.orderRequestId}}); if (typeof order.linkedOrderIds === 'string') try {
// check if linkedOrderIds is set and if set length > 0 and if so, get the linked orders logs order.linkedOrderIds = JSON.parse(order.linkedOrderIds);
// and add them to the logs array and sort them by create date
// if response2.data.linkedOrderIds is a string try to parse it
if (typeof response2.data.linkedOrderIds === 'string') {
try {
response2.data.linkedOrderIds = JSON.parse(response2.data.linkedOrderIds);
} catch { } catch {
} order.linkedOrderIds = [];
} }
if (response2.data.linkedOrderIds && response2.data.linkedOrderIds.length > 0) { if (!order.linkedOrderIds?.length) return;
const linkedOrdersLogs = await Promise.all(
response2.data.linkedOrderIds.map(async (id) => {
const res1 = await axios.get(`${window.TT_CONFIG["BASE_PATH"]}/WarehouseOrder/getById`, {params: {id}});
const res2 = await axios.get(`${window.TT_CONFIG["BASE_PATH"]}/WarehouseOrder/getLogById`, {params: {id}});
return res2.data.map(log => { const linkedLogs = (await Promise.all(
log.message = `${res1.data.orderNumber} - ${log.message}`; order.linkedOrderIds.map(async id => {
return log; const [{data: order}, {data: orderLogs}] = await Promise.all([
axios.get(`${window.TT_CONFIG["BASE_PATH"]}/WarehouseOrder/getById`, {params: {id}}),
axios.get(`${window.TT_CONFIG["BASE_PATH"]}/WarehouseOrder/getLogById`, {params: {id}})
]);
return orderLogs.map(log => ({...log, message: `${order.orderNumber} - ${log.message}`}));
}) })
}) )).flat();
);
this.logs = this.logs.concat(...linkedOrdersLogs).sort((a, b) => b.create - a.create); this.logs = [...logs, ...linkedLogs].sort((a, b) => b.create - a.create);
} }
,
},
methods: { methods: {
formatDate: date => window.moment(date * 1000).format('DD.MM.YYYY HH:mm'), formatDate: date => window.moment(date * 1000).format('DD.MM.YYYY HH:mm'),
getUserName: id => window.TT_CONFIG.CRUD_CONFIG.columns.find(col => col.key === 'createBy')?.modal.items.find(u => u.value === id)?.text getUserName: id => window.TT_CONFIG.CRUD_CONFIG.columns.find(col => col.key === 'createBy')?.modal.items.find(u => u.value === id)?.text
@@ -241,7 +236,7 @@ Vue.component('warehouse-order-request', {
this.historyModal = true; this.historyModal = true;
this.historyModalId = e.id; this.historyModalId = e.id;
}, },
async cancelRequest(row, cancel) { async cancelRequest(row, cancel = '1') {
if (!confirm('Bestellwunsch wirklich stornieren?')) return; if (!confirm('Bestellwunsch wirklich stornieren?')) return;
const res = await axios.get(`${window.TT_CONFIG.BASE_PATH}/WarehouseOrderRequest/cancel?id=${row.id}&cancel=${cancel}`); const res = await axios.get(`${window.TT_CONFIG.BASE_PATH}/WarehouseOrderRequest/cancel?id=${row.id}&cancel=${cancel}`);
window.notify(res.data.success ? 'success' : 'error', window.notify(res.data.success ? 'success' : 'error',