fixed cancelling order and minified component
This commit is contained in:
@@ -5,35 +5,35 @@ window['TT_CONFIG']['CRUD_CONFIG']['editCondition'] = (row) => {
|
|||||||
window.TT_CONFIG["CRUD_CONFIG"]["additionalActions"] = [
|
window.TT_CONFIG["CRUD_CONFIG"]["additionalActions"] = [
|
||||||
...window.TT_CONFIG["CRUD_CONFIG"]["additionalActions"],
|
...window.TT_CONFIG["CRUD_CONFIG"]["additionalActions"],
|
||||||
{
|
{
|
||||||
key: "cancelRequest",
|
key: "cancelRequest",
|
||||||
title: "Bestellwunsch stornieren",
|
title: "Bestellwunsch stornieren",
|
||||||
class: "fas fa-ban text-danger", // Instead of fa-times, use a ban icon
|
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,
|
condition: (row) => window.TT_CONFIG['WAREHOUSE_ADMIN'] === '1' && row.cancelled === 0,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: "uncancelRequest",
|
key: "uncancelRequest",
|
||||||
title: "Bestellwunsch wiederherstellen",
|
title: "Bestellwunsch wiederherstellen",
|
||||||
class: "fas fa-undo text-warning", // Use an undo icon for restore, with a warning color
|
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,
|
condition: (row) => window.TT_CONFIG['WAREHOUSE_ADMIN'] === '1' && row.cancelled === 1,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: "createOrder",
|
key: "createOrder",
|
||||||
title: "Bestellung erstellen",
|
title: "Bestellung erstellen",
|
||||||
class: "fas fa-shopping-cart text-primary", // Use shopping-cart to indicate order creation
|
class: "fas fa-shopping-cart text-primary", // Use shopping-cart to indicate order creation
|
||||||
condition: (row) => window.TT_CONFIG['WAREHOUSE_ADMIN'] === '1'
|
condition: (row) => window.TT_CONFIG['WAREHOUSE_ADMIN'] === '1'
|
||||||
&& row.cancelled === 0 && (!row.linkedOrderIds || row.linkedOrderIds.length === 0)
|
&& row.cancelled === 0 && (!row.linkedOrderIds || row.linkedOrderIds.length === 0)
|
||||||
&& JSON.parse(row.positions).filter(position => position.articleId_text).length === 0,
|
&& JSON.parse(row.positions).filter(position => position.articleId_text).length === 0,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: "doneOrder",
|
key: "doneOrder",
|
||||||
title: "Bestellwunsch erledigt",
|
title: "Bestellwunsch erledigt",
|
||||||
class: "fas fa-check-circle text-success", // Use check-circle for marking as done
|
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,
|
condition: (row) => window.TT_CONFIG['WAREHOUSE_ADMIN'] === '1' && row.done === 0,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: "undoneOrder",
|
key: "undoneOrder",
|
||||||
title: "Bestellwunsch wieder offen",
|
title: "Bestellwunsch wieder offen",
|
||||||
class: "fas fa-redo-alt text-info", // Use redo-alt to indicate reopening the order
|
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,
|
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', {
|
Vue.component('add-log-modal', {
|
||||||
props: {
|
props: {
|
||||||
orderRequestId: {type: Number, required: true},
|
orderRequestId: {type: Number, required: true},
|
||||||
type: {type: String, default: 'accept'}
|
type: {type: String, default: 'accept'}
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
orderRequest: null,
|
orderRequest: null,
|
||||||
note: '',
|
note: '',
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
async mounted() {
|
async mounted() {
|
||||||
@@ -58,11 +58,11 @@ Vue.component('add-log-modal', {
|
|||||||
window.notify('error', 'Bestellwunsch wurde storniert');
|
window.notify('error', 'Bestellwunsch wurde storniert');
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
async submit() {
|
async submit() {
|
||||||
const response = await axios.post(`${window.TT_CONFIG["BASE_PATH"]}/WarehouseOrderRequest/createNewLogAction`, {
|
const response = await axios.post(`${window.TT_CONFIG["BASE_PATH"]}/WarehouseOrderRequest/createNewLogAction`, {
|
||||||
orderRequestId: this.orderRequestId,
|
orderRequestId: this.orderRequestId,
|
||||||
note: this.note,
|
note: this.note,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (response.data.success) {
|
if (response.data.success) {
|
||||||
@@ -75,85 +75,80 @@ Vue.component('add-log-modal', {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
template: `
|
template: `
|
||||||
<tt-modal :show="true" :delete="false" @submit="submit" @update:show="$emit('close')" title="Status ändern">
|
<tt-modal :show="true" :delete="false" @submit="submit" @update:show="$emit('close')" title="Status ändern">
|
||||||
<tt-loader :absolute="false" v-if="!orderRequest"/>
|
<tt-loader :absolute="false" v-if="!orderRequest"/>
|
||||||
<template v-else>
|
<template v-else>
|
||||||
<tt-textarea label="Bemerkung*" v-model="note" sm/>
|
<tt-textarea label="Bemerkung*" v-model="note" sm/>
|
||||||
</template>
|
</template>
|
||||||
</tt-modal>
|
</tt-modal>
|
||||||
|
|
||||||
`
|
`
|
||||||
})
|
})
|
||||||
|
|
||||||
Vue.component('order-request-log', {
|
Vue.component('order-request-log', {
|
||||||
props: {orderRequestId: {type: Number, required: true}},
|
props: {orderRequestId: {type: Number, required: true}},
|
||||||
data: () => ({
|
data: () => ({
|
||||||
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
|
} catch {
|
||||||
|
order.linkedOrderIds = [];
|
||||||
// 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 (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}})
|
||||||
);
|
]);
|
||||||
this.logs = this.logs.concat(...linkedOrdersLogs).sort((a, b) => b.create - a.create);
|
return orderLogs.map(log => ({...log, message: `${order.orderNumber} - ${log.message}`}));
|
||||||
}
|
})
|
||||||
|
)).flat();
|
||||||
|
|
||||||
|
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
|
||||||
},
|
},
|
||||||
//language=Vue
|
//language=Vue
|
||||||
template: `
|
template: `
|
||||||
<div>
|
<div>
|
||||||
<template v-if="logs.length > 0">
|
<template v-if="logs.length > 0">
|
||||||
<hr>
|
<hr>
|
||||||
<h3>Log</h3>
|
<h3>Log</h3>
|
||||||
<div v-for="log in logs" :key="log.id" class="alert alert-light">
|
<div v-for="log in logs" :key="log.id" class="alert alert-light">
|
||||||
{{ formatDate(log.create) }} ({{ getUserName(log.createBy) }}) | {{ log.message }}
|
{{ formatDate(log.create) }} ({{ getUserName(log.createBy) }}) | {{ log.message }}
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
</div>
|
</div>
|
||||||
`
|
`
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
Vue.component('linked-order-status', {
|
Vue.component('linked-order-status', {
|
||||||
props: ['linkedOrders'],
|
props: ['linkedOrders'],
|
||||||
data: () => ({
|
data: () => ({
|
||||||
orders: [],
|
orders: [],
|
||||||
statusTranslations: {
|
statusTranslations: {
|
||||||
new: 'Neu',
|
new: 'Neu',
|
||||||
accepted: 'Akzeptiert',
|
accepted: 'Akzeptiert',
|
||||||
ordered: 'Bestellt',
|
ordered: 'Bestellt',
|
||||||
sent: 'Versendet',
|
sent: 'Versendet',
|
||||||
partiallyDelivered: 'Teilweise geliefert',
|
partiallyDelivered: 'Teilweise geliefert',
|
||||||
fullyDelivered: 'Geliefert',
|
fullyDelivered: 'Geliefert',
|
||||||
cancelled: 'Storniert',
|
cancelled: 'Storniert',
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
async mounted() {
|
async mounted() {
|
||||||
@@ -163,85 +158,85 @@ Vue.component('linked-order-status', {
|
|||||||
},
|
},
|
||||||
//language=Vue
|
//language=Vue
|
||||||
template: `
|
template: `
|
||||||
<div>
|
<div>
|
||||||
<span v-for="(order, index) in orders" :key="order.id" :class="{ 'mt-1': index > 0 }"
|
<span v-for="(order, index) in orders" :key="order.id" :class="{ 'mt-1': index > 0 }"
|
||||||
class="badge badge-pill badge-primary mr-1">{{ order.orderNumber }} - {{ statusTranslations[order.status] }}</span>
|
class="badge badge-pill badge-primary mr-1">{{ order.orderNumber }} - {{ statusTranslations[order.status] }}</span>
|
||||||
</div>`
|
</div>`
|
||||||
});
|
});
|
||||||
|
|
||||||
Vue.component('warehouse-order-request-detail', {
|
Vue.component('warehouse-order-request-detail', {
|
||||||
props: {
|
props: {
|
||||||
positions: {
|
positions: {
|
||||||
type: Array,
|
type: Array,
|
||||||
required: true
|
required: true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
//language=Vue
|
//language=Vue
|
||||||
template: `
|
template: `
|
||||||
<div style="display: flex; justify-content: center; margin-bottom: 10px">
|
<div style="display: flex; justify-content: center; margin-bottom: 10px">
|
||||||
<div class="WarehouseOrderRequestDetailTable">
|
<div class="WarehouseOrderRequestDetailTable">
|
||||||
<div>ARTIKEL</div>
|
<div>ARTIKEL</div>
|
||||||
<div>MENGE</div>
|
<div>MENGE</div>
|
||||||
<div>ZWECK</div>
|
<div>ZWECK</div>
|
||||||
<template v-for="position in positions">
|
<template v-for="position in positions">
|
||||||
<div>
|
<div>
|
||||||
<tt-resolver v-if="position.articleId" reference="WarehouseArticle" :value="position.articleId"/>
|
<tt-resolver v-if="position.articleId" reference="WarehouseArticle" :value="position.articleId"/>
|
||||||
<span v-else>{{ position.articleId_text }}</span>
|
<span v-else>{{ position.articleId_text }}</span>
|
||||||
</div>
|
</div>
|
||||||
<div>{{ position.amount }}</div>
|
<div>{{ position.amount }}</div>
|
||||||
<div>{{ position.purpose }}</div>
|
<div>{{ position.purpose }}</div>
|
||||||
</template>
|
</template>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
`
|
`
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
Vue.component('warehouse-order-request', {
|
Vue.component('warehouse-order-request', {
|
||||||
//language=Vue
|
//language=Vue
|
||||||
template: `
|
template: `
|
||||||
<tt-card>
|
<tt-card>
|
||||||
<tt-table-crud @openHistory="openHistory"
|
<tt-table-crud @openHistory="openHistory"
|
||||||
@cancelRequest="cancelRequest"
|
@cancelRequest="cancelRequest"
|
||||||
@uncancelRequest="uncancelRequest"
|
@uncancelRequest="uncancelRequest"
|
||||||
@doneOrder="doneOrder"
|
@doneOrder="doneOrder"
|
||||||
@undoneOrder="undoneOrder"
|
@undoneOrder="undoneOrder"
|
||||||
@createLog="createLog"
|
@createLog="createLog"
|
||||||
@createOrder="createOrder"
|
@createOrder="createOrder"
|
||||||
ref="crud">
|
ref="crud">
|
||||||
<template #linkedorderids="{row}">
|
<template #linkedorderids="{row}">
|
||||||
<linked-order-status :linkedOrders="row.linkedOrderIds" v-if="row.linkedOrderIds"/>
|
<linked-order-status :linkedOrders="row.linkedOrderIds" v-if="row.linkedOrderIds"/>
|
||||||
</template>
|
</template>
|
||||||
<template #expandedRow="{row}">
|
<template #expandedRow="{row}">
|
||||||
<warehouse-order-request-detail :positions="JSON.parse(row['positions'])"/>
|
<warehouse-order-request-detail :positions="JSON.parse(row['positions'])"/>
|
||||||
<order-request-log :orderRequestId="row.id"/>
|
<order-request-log :orderRequestId="row.id"/>
|
||||||
<hr>
|
<hr>
|
||||||
<h4>Notiz</h4>
|
<h4>Notiz</h4>
|
||||||
<span>{{ row.note }}</span>
|
<span>{{ row.note }}</span>
|
||||||
</template>
|
</template>
|
||||||
</tt-table-crud>
|
</tt-table-crud>
|
||||||
<warehouse-history-modal :show.sync="historyModal" :id="historyModalId"/>
|
<warehouse-history-modal :show.sync="historyModal" :id="historyModalId"/>
|
||||||
<add-log-modal v-if="addLogModalId"
|
<add-log-modal v-if="addLogModalId"
|
||||||
:orderRequestId="addLogModalId"
|
:orderRequestId="addLogModalId"
|
||||||
@close="addLogModal = false; addLogModalId = null; $refs.crud.$refs.table.refreshTable()"/>
|
@close="addLogModal = false; addLogModalId = null; $refs.crud.$refs.table.refreshTable()"/>
|
||||||
</tt-card>
|
</tt-card>
|
||||||
`,
|
`,
|
||||||
data: () => ({
|
data: () => ({
|
||||||
window,
|
window,
|
||||||
historyModal: false,
|
historyModal: false,
|
||||||
historyModalId: null,
|
historyModalId: null,
|
||||||
addLogModal: false,
|
addLogModal: false,
|
||||||
addLogModalId: null,
|
addLogModalId: null,
|
||||||
showHiddenRequests: false,
|
showHiddenRequests: false,
|
||||||
showCanceledRequests: false,
|
showCanceledRequests: false,
|
||||||
orderRequestModalId: null
|
orderRequestModalId: null
|
||||||
}),
|
}),
|
||||||
methods: {
|
methods: {
|
||||||
openHistory(e) {
|
openHistory(e) {
|
||||||
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',
|
||||||
|
|||||||
Reference in New Issue
Block a user