feat: WarehouseArticle now supports showId get parameter for filtering

feat: tt-position-manager now emits displayValue if emitDisplayValue is true
feat: tt-position-manager now has slot form-actions-append
feat: WarehouseOrderController now support text-articles
feat: WarehouseOrder now showing "Zum Artikel" button if article is selected
This commit is contained in:
Luca Haid
2025-04-08 21:40:11 +02:00
parent 4c19245842
commit a299297f73
4 changed files with 43 additions and 26 deletions

View File

@@ -1,4 +1,6 @@
<?php
<?php /** @noinspection PhpUndefinedClassInspection */
/** @noinspection PhpUndefinedNamespaceInspection */
class WarehouseOrderController extends TTCrud {
protected string $headerTitle = 'Lieferantenbestellungen';
@@ -83,7 +85,7 @@ class WarehouseOrderController extends TTCrud {
foreach ($order['positions'] as &$position) {
$position['distributorName'] = WarehouseDistributorModel::get($position['distributorId'])->name;
$position['articleName'] = WarehouseArticleModel::get($position['article'])->title;
$position['articleName'] = $position['article_text'] ?? WarehouseArticleModel::get($position['article'])->title;
}
return $order;
@@ -227,7 +229,7 @@ class WarehouseOrderController extends TTCrud {
$mail->isHTML(true);
$mail->Subject = "Neue Bestellung #$orderNumber";
$mail->Body = "<!DOCTYPE html>
<html>
<html lang='de'>
<head>
<title>XINON E-Mail Template</title>
<meta charset='utf-8'/>

View File

@@ -295,7 +295,7 @@ Vue.component('warehouse-article', {
<th>Preis</th>
<th>Summe</th>
</tr>
<tr v-for="(item, index) in order.orders" :key="index">
<tr v-for="(item, index) in order.orders" :key="index + item.id">
<td>{{item.title}}</td>
<td>{{item.amount}}</td>
<td>{{item.purchasePrice}} €</td>
@@ -363,5 +363,17 @@ Vue.component('warehouse-article', {
window.location.href = `${window['TT_CONFIG']['BASE_PATH']}/WarehouseOrder`;
}, 2000);
}
},
mounted() {
const table = this.$refs.table?.$refs?.table;
if (!table) return;
const showId = new URLSearchParams(window.location.search).get('showId');
const currentFilterId = table.filters?.id;
if ((showId && currentFilterId !== showId) || (!showId && currentFilterId)) {
table.filters = showId ? { id: showId } : {};
table.refreshTable();
}
}
})

View File

@@ -278,8 +278,19 @@ Vue.component('warehouse-order-modal', {
v-model="order.positions"
:config="positionsConfig"
@updateField-article="fetchDistributors"
@updateField-article_text="fetchDistributors"
@updateField-distributorId="fetchDistributorData"
/>
>
<template #form-actions-append>
<!-- v-if $refs.positionsManager.formData.article parse is int and not NaN we show a <tt-button> with a @click to BASE_PATH /WarehouseArticle?showId-->
<tt-button
v-if="!isNaN(parseInt($refs.positionsManager.formData.article))"
text="Zum Artikel"
sm
additional-class="btn-outline-primary"
@click="window.open(window.TT_CONFIG['BASE_PATH'] + '/WarehouseArticle?showId=' + $refs.positionsManager.formData.article)"/>
</template>
</tt-positions-manager>
<hr>
<h4 class="text-center">Lieferadresse</h4>
@@ -319,6 +330,7 @@ Vue.component('warehouse-order-modal', {
return {
window: window,
showSendShippingNote: null,
lastDistributorFetch: null,
positionsConfig: {
customOrdering: 'distributorId',
fields: {
@@ -327,6 +339,7 @@ Vue.component('warehouse-order-modal', {
label: 'Artikel',
apiUrl: '/WarehouseArticle/autoComplete',
customFieldReference: 'WarehouseArticle',
emitDisplayValue: true,
},
distributorId: {type: 'select', label: 'Lieferant', options: [], customFieldReference: 'WarehouseDistributor'},
distributorArticleNumber: {type: 'input', label: 'Lieferant Art-Nr.'},
@@ -334,23 +347,12 @@ Vue.component('warehouse-order-modal', {
buyPrice: {type: 'input', label: 'Einkaufspreis', inputType: 'number'},
verwendung: {type: 'input', label: 'Verwendung'},
},
validateForm: (formData) => {
const fields = [
{key: 'amount', message: 'Bitte füllen Sie die Menge aus'},
{key: 'distributorId', message: 'Bitte füllen Sie den Lieferanten aus'},
{key: 'article', message: 'Bitte füllen Sie den Artikel aus'},
{key: 'buyPrice', message: 'Bitte füllen Sie den Einkaufspreis aus'}
];
for (const field of fields) {
if (!formData[field.key]) {
window.notify('error', field.message);
return false;
}
}
return true;
},
validateFormOptions: [
{key: 'amount', message: 'Bitte füllen Sie die Menge aus'},
{key: 'distributorId', message: 'Bitte füllen Sie den Lieferanten aus'},
{key: 'article', message: 'Bitte füllen Sie den Artikel aus'},
{key: 'buyPrice', message: 'Bitte füllen Sie den Einkaufspreis aus'}
],
},
order: {
extReference: '',
@@ -436,7 +438,9 @@ Vue.component('warehouse-order-modal', {
async fetchDistributors(article) {
const url = `${window.TT_CONFIG["BASE_PATH"]}/WarehouseOrder/getArticleDistributorData`;
const params = typeof article === 'string' ? {allDistributor: true} : {articleId: article};
if (JSON.stringify(params) === JSON.stringify(this.lastDistributorFetch)) return;
this.lastDistributorFetch = params;
const response = await axios.get(url, {params});
this.positionsConfig.fields.distributorId.options = response.data.map(distributor => ({
value: distributor.id,
@@ -573,10 +577,8 @@ Vue.component('warehouse-order', {
},
methods: {
async closeModal() {
console.log("hi");
this.orderModalId = null;
this.changeStatusModalId = null;
console.log("hi");
await new Promise(resolve => setTimeout(resolve, 250));
this.$refs.table.$refs.table.refreshTable();
},

View File

@@ -69,6 +69,7 @@ Vue.component('tt-positions-manager',
:emit-display-value="field.emitDisplayValue || false"
v-model="formData[key]"
@input="$emit('updateField-' + key, $event)"
@displayValue="$emit('updateField-' + key + '_text', $event)"
:ref="'autocomplete-' + key"
:api-url="window.TT_CONFIG['BASE_PATH'] + field.apiUrl"
sm
@@ -105,6 +106,8 @@ Vue.component('tt-positions-manager',
:additional-class="selectedIndex === null ? 'btn-primary' : 'btn-success'"
:text="selectedIndex === null ? 'Hinzufügen' : 'Aktualisieren'"/>
</div>
<slot name="form-actions-append"></slot>
</div>
@@ -170,9 +173,7 @@ Vue.component('tt-positions-manager',
},
checkEmitDisplayValueAutocomplete() {
for (const [key, field] of Object.entries(this.config.fields)) {
console.log("HI");
if ((typeof field.showCondition === 'function' && field.showCondition(this.formData) === true || !field.showCondition) && field.type === 'autocomplete' && field.emitDisplayValue && (isNaN(this.formData[key]) || !this.formData[key]) && this.$refs['autocomplete-' + key][0]) {
console.log("hi");
this.$set(this.formData, key + '_text', this.$refs['autocomplete-' + key][0].displayValue);
this.$delete(this.formData, key);
}