fixed cancelling order and minified component
This commit is contained in:
@@ -91,38 +91,33 @@ Vue.component('order-request-log', {
|
||||
logs: []
|
||||
}),
|
||||
async mounted() {
|
||||
const response = await axios.get(`${window.TT_CONFIG["BASE_PATH"]}/WarehouseOrderRequest/getLogById`, {params: {orderRequestId: this.orderRequestId}});
|
||||
this.logs = response.data;
|
||||
const [{data: logs}, {data: order}] = await Promise.all([
|
||||
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}});
|
||||
// check if linkedOrderIds is set and if set length > 0 and if so, get the linked orders logs
|
||||
// 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);
|
||||
if (typeof order.linkedOrderIds === 'string') try {
|
||||
order.linkedOrderIds = JSON.parse(order.linkedOrderIds);
|
||||
} catch {
|
||||
}
|
||||
order.linkedOrderIds = [];
|
||||
}
|
||||
|
||||
if (response2.data.linkedOrderIds && response2.data.linkedOrderIds.length > 0) {
|
||||
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}});
|
||||
if (!order.linkedOrderIds?.length) return;
|
||||
|
||||
return res2.data.map(log => {
|
||||
log.message = `${res1.data.orderNumber} - ${log.message}`;
|
||||
return log;
|
||||
const linkedLogs = (await Promise.all(
|
||||
order.linkedOrderIds.map(async id => {
|
||||
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}`}));
|
||||
})
|
||||
})
|
||||
);
|
||||
this.logs = this.logs.concat(...linkedOrdersLogs).sort((a, b) => b.create - a.create);
|
||||
)).flat();
|
||||
|
||||
this.logs = [...logs, ...linkedLogs].sort((a, b) => b.create - a.create);
|
||||
}
|
||||
|
||||
|
||||
},
|
||||
,
|
||||
methods: {
|
||||
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
|
||||
@@ -241,7 +236,7 @@ Vue.component('warehouse-order-request', {
|
||||
this.historyModal = true;
|
||||
this.historyModalId = e.id;
|
||||
},
|
||||
async cancelRequest(row, cancel) {
|
||||
async cancelRequest(row, cancel = '1') {
|
||||
if (!confirm('Bestellwunsch wirklich stornieren?')) return;
|
||||
const res = await axios.get(`${window.TT_CONFIG.BASE_PATH}/WarehouseOrderRequest/cancel?id=${row.id}&cancel=${cancel}`);
|
||||
window.notify(res.data.success ? 'success' : 'error',
|
||||
|
||||
Reference in New Issue
Block a user