diff --git a/public/js/pages/WarehouseOrderRequest/WarehouseOrderRequest.js b/public/js/pages/WarehouseOrderRequest/WarehouseOrderRequest.js
index 9756fdf32..3a1b94baf 100644
--- a/public/js/pages/WarehouseOrderRequest/WarehouseOrderRequest.js
+++ b/public/js/pages/WarehouseOrderRequest/WarehouseOrderRequest.js
@@ -5,35 +5,35 @@ window['TT_CONFIG']['CRUD_CONFIG']['editCondition'] = (row) => {
window.TT_CONFIG["CRUD_CONFIG"]["additionalActions"] = [
...window.TT_CONFIG["CRUD_CONFIG"]["additionalActions"],
{
- key: "cancelRequest",
- title: "Bestellwunsch stornieren",
- class: "fas fa-ban text-danger", // Instead of fa-times, use a ban icon
+ key: "cancelRequest",
+ title: "Bestellwunsch stornieren",
+ class: "fas fa-ban text-danger", // Instead of fa-times, use a ban icon
condition: (row) => window.TT_CONFIG['WAREHOUSE_ADMIN'] === '1' && row.cancelled === 0,
},
{
- key: "uncancelRequest",
- title: "Bestellwunsch wiederherstellen",
- class: "fas fa-undo text-warning", // Use an undo icon for restore, with a warning color
+ key: "uncancelRequest",
+ title: "Bestellwunsch wiederherstellen",
+ class: "fas fa-undo text-warning", // Use an undo icon for restore, with a warning color
condition: (row) => window.TT_CONFIG['WAREHOUSE_ADMIN'] === '1' && row.cancelled === 1,
},
{
- key: "createOrder",
- title: "Bestellung erstellen",
- class: "fas fa-shopping-cart text-primary", // Use shopping-cart to indicate order creation
+ key: "createOrder",
+ title: "Bestellung erstellen",
+ class: "fas fa-shopping-cart text-primary", // Use shopping-cart to indicate order creation
condition: (row) => window.TT_CONFIG['WAREHOUSE_ADMIN'] === '1'
&& row.cancelled === 0 && (!row.linkedOrderIds || row.linkedOrderIds.length === 0)
&& JSON.parse(row.positions).filter(position => position.articleId_text).length === 0,
},
{
- key: "doneOrder",
- title: "Bestellwunsch erledigt",
- class: "fas fa-check-circle text-success", // Use check-circle for marking as done
+ key: "doneOrder",
+ title: "Bestellwunsch erledigt",
+ class: "fas fa-check-circle text-success", // Use check-circle for marking as done
condition: (row) => window.TT_CONFIG['WAREHOUSE_ADMIN'] === '1' && row.done === 0,
},
{
- key: "undoneOrder",
- title: "Bestellwunsch wieder offen",
- class: "fas fa-redo-alt text-info", // Use redo-alt to indicate reopening the order
+ key: "undoneOrder",
+ title: "Bestellwunsch wieder offen",
+ class: "fas fa-redo-alt text-info", // Use redo-alt to indicate reopening the order
condition: (row) => window.TT_CONFIG['WAREHOUSE_ADMIN'] === '1' && row.done === 1,
},
];
@@ -41,12 +41,12 @@ window.TT_CONFIG["CRUD_CONFIG"]["additionalActions"] = [
Vue.component('add-log-modal', {
props: {
orderRequestId: {type: Number, required: true},
- type: {type: String, default: 'accept'}
+ type: {type: String, default: 'accept'}
},
data() {
return {
orderRequest: null,
- note: '',
+ note: '',
};
},
async mounted() {
@@ -58,11 +58,11 @@ Vue.component('add-log-modal', {
window.notify('error', 'Bestellwunsch wurde storniert');
}
},
- methods: {
+ methods: {
async submit() {
const response = await axios.post(`${window.TT_CONFIG["BASE_PATH"]}/WarehouseOrderRequest/createNewLogAction`, {
orderRequestId: this.orderRequestId,
- note: this.note,
+ note: this.note,
});
if (response.data.success) {
@@ -75,85 +75,80 @@ Vue.component('add-log-modal', {
}
},
template: `
-
-
-
-
-
-
+
+
+
+
+
+
- `
+ `
})
Vue.component('order-request-log', {
props: {orderRequestId: {type: Number, required: true}},
- data: () => ({
+ data: () => ({
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);
- } catch {
- }
+ 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;
- })
- })
- );
- this.logs = this.logs.concat(...linkedOrdersLogs).sort((a, b) => b.create - a.create);
- }
+ 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}`}));
+ })
+ )).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'),
+ 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
},
//language=Vue
template: `
-
-
-
- Log
-
- {{ formatDate(log.create) }} ({{ getUserName(log.createBy) }}) | {{ log.message }}
-
-
-
- `
+
+
+
+ Log
+
+ {{ formatDate(log.create) }} ({{ getUserName(log.createBy) }}) | {{ log.message }}
+
+
+
+ `
})
Vue.component('linked-order-status', {
props: ['linkedOrders'],
- data: () => ({
- orders: [],
+ data: () => ({
+ orders: [],
statusTranslations: {
- new: 'Neu',
- accepted: 'Akzeptiert',
- ordered: 'Bestellt',
- sent: 'Versendet',
+ new: 'Neu',
+ accepted: 'Akzeptiert',
+ ordered: 'Bestellt',
+ sent: 'Versendet',
partiallyDelivered: 'Teilweise geliefert',
- fullyDelivered: 'Geliefert',
- cancelled: 'Storniert',
+ fullyDelivered: 'Geliefert',
+ cancelled: 'Storniert',
}
}),
async mounted() {
@@ -163,85 +158,85 @@ Vue.component('linked-order-status', {
},
//language=Vue
template: `
-
+
{{ order.orderNumber }} - {{ statusTranslations[order.status] }}
-
`
+
`
});
Vue.component('warehouse-order-request-detail', {
props: {
positions: {
- type: Array,
+ type: Array,
required: true
}
},
//language=Vue
template: `
-
-
-
ARTIKEL
-
MENGE
-
ZWECK
-
-
-
- {{ position.articleId_text }}
-
- {{ position.amount }}
- {{ position.purpose }}
-
-
-
- `
+
+
+
ARTIKEL
+
MENGE
+
ZWECK
+
+
+
+ {{ position.articleId_text }}
+
+ {{ position.amount }}
+ {{ position.purpose }}
+
+
+
+ `
});
Vue.component('warehouse-order-request', {
//language=Vue
template: `
-
-
-
-
-
-
-
-
-
- Notiz
- {{ row.note }}
-
-
-
-
-
- `,
- data: () => ({
+
+
+
+
+
+
+
+
+
+ Notiz
+ {{ row.note }}
+
+
+
+
+
+ `,
+ data: () => ({
window,
- historyModal: false,
- historyModalId: null,
- addLogModal: false,
- addLogModalId: null,
- showHiddenRequests: false,
+ historyModal: false,
+ historyModalId: null,
+ addLogModal: false,
+ addLogModalId: null,
+ showHiddenRequests: false,
showCanceledRequests: false,
- orderRequestModalId: null
+ orderRequestModalId: null
}),
- methods: {
+ methods: {
openHistory(e) {
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',