Merge branch 'WarehouseOrder/improve-article-handling' into 'master'
feat: WarehouseArticle now supports showId get parameter for filtering See merge request fronk/thetool!1187
This commit is contained in:
@@ -1,4 +1,6 @@
|
|||||||
<?php
|
<?php /** @noinspection PhpUndefinedClassInspection */
|
||||||
|
|
||||||
|
/** @noinspection PhpUndefinedNamespaceInspection */
|
||||||
|
|
||||||
class WarehouseOrderController extends TTCrud {
|
class WarehouseOrderController extends TTCrud {
|
||||||
protected string $headerTitle = 'Lieferantenbestellungen';
|
protected string $headerTitle = 'Lieferantenbestellungen';
|
||||||
@@ -83,7 +85,7 @@ class WarehouseOrderController extends TTCrud {
|
|||||||
|
|
||||||
foreach ($order['positions'] as &$position) {
|
foreach ($order['positions'] as &$position) {
|
||||||
$position['distributorName'] = WarehouseDistributorModel::get($position['distributorId'])->name;
|
$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;
|
return $order;
|
||||||
@@ -227,7 +229,7 @@ class WarehouseOrderController extends TTCrud {
|
|||||||
$mail->isHTML(true);
|
$mail->isHTML(true);
|
||||||
$mail->Subject = "Neue Bestellung #$orderNumber";
|
$mail->Subject = "Neue Bestellung #$orderNumber";
|
||||||
$mail->Body = "<!DOCTYPE html>
|
$mail->Body = "<!DOCTYPE html>
|
||||||
<html>
|
<html lang='de'>
|
||||||
<head>
|
<head>
|
||||||
<title>XINON E-Mail Template</title>
|
<title>XINON E-Mail Template</title>
|
||||||
<meta charset='utf-8'/>
|
<meta charset='utf-8'/>
|
||||||
|
|||||||
@@ -295,7 +295,7 @@ Vue.component('warehouse-article', {
|
|||||||
<th>Preis</th>
|
<th>Preis</th>
|
||||||
<th>Summe</th>
|
<th>Summe</th>
|
||||||
</tr>
|
</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.title}}</td>
|
||||||
<td>{{item.amount}}</td>
|
<td>{{item.amount}}</td>
|
||||||
<td>{{item.purchasePrice}} €</td>
|
<td>{{item.purchasePrice}} €</td>
|
||||||
@@ -363,5 +363,17 @@ Vue.component('warehouse-article', {
|
|||||||
window.location.href = `${window['TT_CONFIG']['BASE_PATH']}/WarehouseOrder`;
|
window.location.href = `${window['TT_CONFIG']['BASE_PATH']}/WarehouseOrder`;
|
||||||
}, 2000);
|
}, 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();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -278,8 +278,19 @@ Vue.component('warehouse-order-modal', {
|
|||||||
v-model="order.positions"
|
v-model="order.positions"
|
||||||
:config="positionsConfig"
|
:config="positionsConfig"
|
||||||
@updateField-article="fetchDistributors"
|
@updateField-article="fetchDistributors"
|
||||||
|
@updateField-article_text="fetchDistributors"
|
||||||
@updateField-distributorId="fetchDistributorData"
|
@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>
|
<hr>
|
||||||
<h4 class="text-center">Lieferadresse</h4>
|
<h4 class="text-center">Lieferadresse</h4>
|
||||||
@@ -319,6 +330,7 @@ Vue.component('warehouse-order-modal', {
|
|||||||
return {
|
return {
|
||||||
window: window,
|
window: window,
|
||||||
showSendShippingNote: null,
|
showSendShippingNote: null,
|
||||||
|
lastDistributorFetch: null,
|
||||||
positionsConfig: {
|
positionsConfig: {
|
||||||
customOrdering: 'distributorId',
|
customOrdering: 'distributorId',
|
||||||
fields: {
|
fields: {
|
||||||
@@ -327,6 +339,7 @@ Vue.component('warehouse-order-modal', {
|
|||||||
label: 'Artikel',
|
label: 'Artikel',
|
||||||
apiUrl: '/WarehouseArticle/autoComplete',
|
apiUrl: '/WarehouseArticle/autoComplete',
|
||||||
customFieldReference: 'WarehouseArticle',
|
customFieldReference: 'WarehouseArticle',
|
||||||
|
emitDisplayValue: true,
|
||||||
},
|
},
|
||||||
distributorId: {type: 'select', label: 'Lieferant', options: [], customFieldReference: 'WarehouseDistributor'},
|
distributorId: {type: 'select', label: 'Lieferant', options: [], customFieldReference: 'WarehouseDistributor'},
|
||||||
distributorArticleNumber: {type: 'input', label: 'Lieferant Art-Nr.'},
|
distributorArticleNumber: {type: 'input', label: 'Lieferant Art-Nr.'},
|
||||||
@@ -334,23 +347,12 @@ Vue.component('warehouse-order-modal', {
|
|||||||
buyPrice: {type: 'input', label: 'Einkaufspreis', inputType: 'number'},
|
buyPrice: {type: 'input', label: 'Einkaufspreis', inputType: 'number'},
|
||||||
verwendung: {type: 'input', label: 'Verwendung'},
|
verwendung: {type: 'input', label: 'Verwendung'},
|
||||||
},
|
},
|
||||||
validateForm: (formData) => {
|
validateFormOptions: [
|
||||||
const fields = [
|
|
||||||
{key: 'amount', message: 'Bitte füllen Sie die Menge aus'},
|
{key: 'amount', message: 'Bitte füllen Sie die Menge aus'},
|
||||||
{key: 'distributorId', message: 'Bitte füllen Sie den Lieferanten aus'},
|
{key: 'distributorId', message: 'Bitte füllen Sie den Lieferanten aus'},
|
||||||
{key: 'article', message: 'Bitte füllen Sie den Artikel aus'},
|
{key: 'article', message: 'Bitte füllen Sie den Artikel aus'},
|
||||||
{key: 'buyPrice', message: 'Bitte füllen Sie den Einkaufspreis 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;
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
order: {
|
order: {
|
||||||
extReference: '',
|
extReference: '',
|
||||||
@@ -436,7 +438,9 @@ Vue.component('warehouse-order-modal', {
|
|||||||
async fetchDistributors(article) {
|
async fetchDistributors(article) {
|
||||||
const url = `${window.TT_CONFIG["BASE_PATH"]}/WarehouseOrder/getArticleDistributorData`;
|
const url = `${window.TT_CONFIG["BASE_PATH"]}/WarehouseOrder/getArticleDistributorData`;
|
||||||
const params = typeof article === 'string' ? {allDistributor: true} : {articleId: article};
|
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});
|
const response = await axios.get(url, {params});
|
||||||
this.positionsConfig.fields.distributorId.options = response.data.map(distributor => ({
|
this.positionsConfig.fields.distributorId.options = response.data.map(distributor => ({
|
||||||
value: distributor.id,
|
value: distributor.id,
|
||||||
@@ -573,10 +577,8 @@ Vue.component('warehouse-order', {
|
|||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
async closeModal() {
|
async closeModal() {
|
||||||
console.log("hi");
|
|
||||||
this.orderModalId = null;
|
this.orderModalId = null;
|
||||||
this.changeStatusModalId = null;
|
this.changeStatusModalId = null;
|
||||||
console.log("hi");
|
|
||||||
await new Promise(resolve => setTimeout(resolve, 250));
|
await new Promise(resolve => setTimeout(resolve, 250));
|
||||||
this.$refs.table.$refs.table.refreshTable();
|
this.$refs.table.$refs.table.refreshTable();
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -69,6 +69,7 @@ Vue.component('tt-positions-manager',
|
|||||||
:emit-display-value="field.emitDisplayValue || false"
|
:emit-display-value="field.emitDisplayValue || false"
|
||||||
v-model="formData[key]"
|
v-model="formData[key]"
|
||||||
@input="$emit('updateField-' + key, $event)"
|
@input="$emit('updateField-' + key, $event)"
|
||||||
|
@displayValue="$emit('updateField-' + key + '_text', $event)"
|
||||||
:ref="'autocomplete-' + key"
|
:ref="'autocomplete-' + key"
|
||||||
:api-url="window.TT_CONFIG['BASE_PATH'] + field.apiUrl"
|
:api-url="window.TT_CONFIG['BASE_PATH'] + field.apiUrl"
|
||||||
sm
|
sm
|
||||||
@@ -105,6 +106,8 @@ Vue.component('tt-positions-manager',
|
|||||||
:additional-class="selectedIndex === null ? 'btn-primary' : 'btn-success'"
|
:additional-class="selectedIndex === null ? 'btn-primary' : 'btn-success'"
|
||||||
:text="selectedIndex === null ? 'Hinzufügen' : 'Aktualisieren'"/>
|
:text="selectedIndex === null ? 'Hinzufügen' : 'Aktualisieren'"/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<slot name="form-actions-append"></slot>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
@@ -170,9 +173,7 @@ Vue.component('tt-positions-manager',
|
|||||||
},
|
},
|
||||||
checkEmitDisplayValueAutocomplete() {
|
checkEmitDisplayValueAutocomplete() {
|
||||||
for (const [key, field] of Object.entries(this.config.fields)) {
|
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]) {
|
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.$set(this.formData, key + '_text', this.$refs['autocomplete-' + key][0].displayValue);
|
||||||
this.$delete(this.formData, key);
|
this.$delete(this.formData, key);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user