Merge branch 'feature/add-warehouse-e-shop-order-items' into 'master'

Feature/add warehouse e shop order items

See merge request fronk/thetool!537
This commit is contained in:
Luca Haid
2024-07-31 10:26:10 +00:00
4 changed files with 54 additions and 2 deletions

View File

@@ -43,7 +43,29 @@ class WarehouseEShopOrderController extends TTCrud {
$this->columns[8]['modal']['items'] = $users;
}
protected function getAllItemsPerOrderAction() {
$items = WarehouseEShopOrderItemModel::getAll();
$articles = WarehouseArticleModel::getAll();
$articlePackets = WarehouseArticlePacketModel::getAll();
$orderItems = [];
foreach ($items as $item) {
$item = (array) $item;
if (!isset($orderItems[$item['orderId']])) {
$orderItems[$item['orderId']] = [];
}
$orderItems[$item['orderId']][] = [
'id' => $item['id'],
'articleId' => $item['articleId'],
'articleTitle' => isset($articles[$item['articleId']]) ? $articles[$item['articleId']]->title : null,
'articlePacketId' => $item['articlePacketId'],
'articlePacketTitle' => isset($articlePackets[$item['articlePacketId']]) ? $articlePackets[$item['articlePacketId']]->title : null,
'quantity' => $item['quantity']
];
}
self::returnJson($orderItems);
}
protected function createOrderAction() {
//TODO: change this to beforeCreate and afterCreate

View File

@@ -111,6 +111,13 @@ Vue.component('warehouse-e-shop', {
if (response.data.success) {
this.window.notify('success', response.data.message || 'Erfolgreich gespeichert');
this.shoppingCart = [];
this.createOrderDialogData = {
deliveryMode: 'singleAddress',
deliveryAddressName: '',
deliveryAddressLine: '',
deliveryAddressPLZ: '',
deliveryAddressCity: '',
}
this.createOrderDialog = false;
} else {
this.window.notify('error',

View File

@@ -1,3 +1,4 @@
// noinspection JSUnusedLocalSymbols
Vue.component('warehouse-e-shop-order', {
//language=Vue
template: `
@@ -5,7 +6,17 @@ Vue.component('warehouse-e-shop-order', {
<tt-table-crud @openHistory="historyModal = true; historyModalId = $event.id">
<template v-slot:create="{ row }">
{{ new Date(row.create * 1000).toLocaleDateString() }}
{{ window.moment(row.create * 1000).format('DD.MM.YYYY HH:mm:ss') }}
</template>
<template v-slot:expandedRow="{ row }">
<div>
<ul class="list-group" v-if="articleItems && articleItems[row.id]">
<li class="list-group-item" v-for="item in articleItems[row.id]">
Menge: {{ item.quantity }} | {{ item.articlePacketTitle || item.articleTitle }}
</li>
</ul>
</div>
</template>
</tt-table-crud>
@@ -13,7 +24,13 @@ Vue.component('warehouse-e-shop-order', {
</tt-card>
`, data() {
return {
window: window, historyModal: false, historyModalId: null,
window: window, historyModal: false, historyModalId: null, articleItems: null
}
},
async mounted() {
const response = await axios.get(`${window['TT_CONFIG']['BASE_PATH']}/WarehouseEShopOrder/getAllItemsPerOrder`);
console.log(response.data);
this.articleItems = response.data;
}
})

View File

@@ -41,6 +41,12 @@ Vue.component('tt-table-crud', {
</div>
</template>
<template v-if="$scopedSlots.expandedRow" v-slot:expandedRow="{ row }">
<slot name="expandedRow" :row="row"/>
</template>
</tt-table>
<tt-modal :show.sync="crudModal"