Feature/warehouse
This commit is contained in:
@@ -0,0 +1,287 @@
|
||||
Vue.component('warehouse-distributor-modal', {
|
||||
//language=Vue
|
||||
template: `
|
||||
<tt-modal :show.sync="showModal" title="Lieferanten" :delete="false" :save="false"
|
||||
@close="$emit('update:show', false)">
|
||||
<div v-for="(row, index) in rows" :key="index" style="display:grid;grid-template-columns: auto auto">
|
||||
<div style="display:grid; grid-template-columns: auto auto auto">
|
||||
<tt-autocomplete v-model="row.distributorId"
|
||||
:api-url="window['TT_CONFIG']['BASE_PATH'] + '/WarehouseDistributor/autocomplete'"></tt-autocomplete>
|
||||
<tt-input v-model="row.purchasePrice" placeholder="Price" type="number" sm></tt-input>
|
||||
<tt-input v-model="row.externalArticleNumber" placeholder="External Article Number" sm></tt-input>
|
||||
</div>
|
||||
<div class="btn-group mb-4">
|
||||
<a class="btn btn-sm btn-primary" href="#" @click="saveRow(index)" title="Save Row">
|
||||
<i class="fas fa-check"></i>
|
||||
</a>
|
||||
<a class="btn btn-sm btn-danger" href="#" @click="deleteRow(index)" title="Delete Row">
|
||||
<i class="fas fa-trash"></i>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<a href="#" @click="addRow"><i class="fas fa-plus"></i>Lieferant hinzufügen</a>
|
||||
|
||||
</tt-modal>
|
||||
`, props: {
|
||||
show: {type: Boolean, default: false}, id: {type: Number, default: null},
|
||||
}, data() {
|
||||
return {
|
||||
window: window, showModal: false, rows: []
|
||||
};
|
||||
}, async mounted() {
|
||||
|
||||
}, methods: {
|
||||
async fetchArticleDistributor() {
|
||||
const response = await axios.post(window['TT_CONFIG']['BASE_PATH'] + '/WarehouseArticleDistributor/get', {filters: {articleId: this.id}});
|
||||
|
||||
this.rows = response.data.rows
|
||||
}, addRow() {
|
||||
this.rows.push({distributor: null, price: null, externalArticleNumber: null});
|
||||
}, async saveRow(index) {
|
||||
// post to /WarehouseArticleDistributor/save with rows data and articleId
|
||||
const row = this.rows[index];
|
||||
|
||||
const data = {
|
||||
articleId: this.id, distributorId: row.distributorId, purchasePrice: row.purchasePrice, externalArticleNumber: row.externalArticleNumber
|
||||
}
|
||||
|
||||
if (row.id) {
|
||||
data.id = row.id;
|
||||
}
|
||||
|
||||
const response = await axios.post(`${window['TT_CONFIG']['BASE_PATH']}/WarehouseArticleDistributor/${row.id ? 'update' : 'create'}`, data);
|
||||
this.$emit('doUpdate');
|
||||
this.window.notify(response.data.success ? 'success' : 'error',
|
||||
response.data.errors ? Object.values(response.data.errors).join('<br>') : response.data.message);
|
||||
await this.fetchArticleDistributor();
|
||||
}, async deleteRow(index) {
|
||||
const row = this.rows[index];
|
||||
|
||||
if (!row.id) {
|
||||
this.window.notify('error', 'Eintrag hat keine ID');
|
||||
}
|
||||
|
||||
const response = axios.post(window['TT_CONFIG']['BASE_PATH'] + '/WarehouseArticleDistributor/delete', {id: row.id});
|
||||
this.$emit('doUpdate');
|
||||
this.window.notify(response.data.success ? 'success' : 'error',
|
||||
response.data.errors ? Object.values(response.data.errors).join('<br>') : response.data.message);
|
||||
await this.fetchArticleDistributor();
|
||||
}
|
||||
}, watch: {
|
||||
show(newVal) {
|
||||
this.showModal = newVal;
|
||||
if (!newVal) {
|
||||
this.rows = [];
|
||||
return;
|
||||
}
|
||||
this.rows = [];
|
||||
this.fetchArticleDistributor().then();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Vue.component('warehouse-threshold-modal', {
|
||||
//language=Vue
|
||||
template: `
|
||||
<tt-modal :show.sync="showModal" title="Schwellenwerte" :delete="false" :save="false" @close="$emit('update:show', false)">
|
||||
<div v-for="(row, index) in rows" :key="index" style="display:grid;grid-template-columns: auto auto">
|
||||
<div style="display:grid; grid-template-columns: auto auto auto">
|
||||
<tt-autocomplete v-model="row.locationId"
|
||||
:api-url="window['TT_CONFIG']['BASE_PATH'] + '/WarehouseLocation/autocomplete'"></tt-autocomplete>
|
||||
<tt-input v-model="row.warningAmount" placeholder="Warnmenge" type="number" sm></tt-input>
|
||||
<tt-input v-model="row.criticalAmount" placeholder="Kritische Menge" type="number" sm></tt-input>
|
||||
</div>
|
||||
<div class="btn-group mb-4">
|
||||
<a class="btn btn-sm btn-primary" href="#" @click="saveRow(index)" title="Save Row">
|
||||
<i class="fas fa-check"></i>
|
||||
</a>
|
||||
<a class="btn btn-sm btn-danger" href="#" @click="deleteRow(index)" title="Delete Row">
|
||||
<i class="fas fa-trash"></i>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<a href="#" @click="addRow"><i class="fas fa-plus"></i>Schwellenwert hinzufügen</a>
|
||||
|
||||
</tt-modal>
|
||||
`, props: {
|
||||
show: {type: Boolean, default: false}, id: {type: Number, default: null},
|
||||
}, data() {
|
||||
return {
|
||||
window: window, showModal: false, rows: []
|
||||
};
|
||||
}, async mounted() {
|
||||
|
||||
}, methods: {
|
||||
async fetchLocationThreshold() {
|
||||
const response = await axios.post(window['TT_CONFIG']['BASE_PATH'] + '/WarehouseLocationThresholdOverride/get', {filters: {articleId: this.id}});
|
||||
|
||||
this.rows = response.data.rows
|
||||
}, addRow() {
|
||||
this.rows.push({distributor: null, price: null, externalArticleNumber: null});
|
||||
}, async saveRow(index) {
|
||||
// post to /WarehouseArticleDistributor/save with rows data and articleId
|
||||
const row = this.rows[index];
|
||||
|
||||
const data = {
|
||||
articleId: this.id, locationId: row.locationId, warningAmount: row.warningAmount, criticalAmount: row.criticalAmount
|
||||
}
|
||||
|
||||
if (row.id) {
|
||||
data.id = row.id;
|
||||
}
|
||||
|
||||
const response = await axios.post(`${window['TT_CONFIG']['BASE_PATH']}/WarehouseLocationThresholdOverride/${row.id ? 'update' : 'create'}`, data);
|
||||
this.$emit('doUpdate');
|
||||
this.window.notify(response.data.success ? 'success' : 'error',
|
||||
response.data.errors ? Object.values(response.data.errors).join('<br>') : response.data.message);
|
||||
await this.fetchLocationThreshold()
|
||||
}, async deleteRow(index) {
|
||||
const row = this.rows[index];
|
||||
|
||||
if (!row.id) {
|
||||
this.window.notify('error', 'Eintrag hat keine ID');
|
||||
}
|
||||
|
||||
const response = axios.post(window['TT_CONFIG']['BASE_PATH'] + '/WarehouseLocationThresholdOverride/delete', {id: row.id});
|
||||
this.$emit('doUpdate');
|
||||
this.window.notify(response.data.success ? 'success' : 'error',
|
||||
response.data.errors ? Object.values(response.data.errors).join('<br>') : response.data.message);
|
||||
await this.fetchLocationThreshold();
|
||||
}
|
||||
}, watch: {
|
||||
show(newVal) {
|
||||
this.showModal = newVal;
|
||||
if (!newVal) {
|
||||
this.rows = [];
|
||||
return;
|
||||
}
|
||||
this.rows = [];
|
||||
this.fetchLocationThreshold().then();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Vue.component('warehouse-article-price-modal', {
|
||||
//language=Vue
|
||||
template: `
|
||||
<tt-modal :show.sync="showModal" title="Artikel-Preise" :delete="false" :save="false" @close="$emit('update:show', false)">
|
||||
<div v-for="(row, index) in rows" :key="index" style="display:grid;grid-template-columns: auto auto">
|
||||
<div style="display:grid; grid-template-columns: auto auto auto">
|
||||
<tt-autocomplete v-model="row.articlePriceTypeId"
|
||||
:api-url="window['TT_CONFIG']['BASE_PATH'] + '/WarehouseArticlePriceType/autocomplete'"></tt-autocomplete>
|
||||
<tt-input v-model="row.priceMultiplier" placeholder="Preis Multiplikator" type="number" sm></tt-input>
|
||||
<tt-input v-model="row.priceOverride" placeholder="Preis" type="number" sm></tt-input>
|
||||
</div>
|
||||
<div class="btn-group mb-4">
|
||||
<a class="btn btn-sm btn-primary" href="#" @click="saveRow(index)" title="Save Row">
|
||||
<i class="fas fa-check"></i>
|
||||
</a>
|
||||
<a class="btn btn-sm btn-danger" href="#" @click="deleteRow(index)" title="Delete Row">
|
||||
<i class="fas fa-trash"></i>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<a href="#" @click="addRow"><i class="fas fa-plus"></i>Preis hinzufügen</a>
|
||||
|
||||
</tt-modal>
|
||||
`, props: {
|
||||
show: {type: Boolean, default: false}, id: {type: Number, default: null},
|
||||
}, data() {
|
||||
return {
|
||||
window: window, showModal: false, rows: []
|
||||
};
|
||||
}, async mounted() {
|
||||
|
||||
}, methods: {
|
||||
async fetchLocationThreshold() {
|
||||
const response = await axios.post(window['TT_CONFIG']['BASE_PATH'] + '/WarehouseArticlePrice/get', {filters: {articleId: this.id}});
|
||||
|
||||
this.rows = response.data.rows
|
||||
}, addRow() {
|
||||
this.rows.push({articlePriceTypeId: null, priceMultiplier: null, priceOverride: null});
|
||||
}, async saveRow(index) {
|
||||
// post to /WarehouseArticleDistributor/save with rows data and articleId
|
||||
const row = this.rows[index];
|
||||
|
||||
const data = {
|
||||
articleId: this.id, articlePriceTypeId: row.articlePriceTypeId, priceMultiplier: row.priceMultiplier, priceOverride: row.priceOverride
|
||||
}
|
||||
|
||||
if (row.id) {
|
||||
data.id = row.id;
|
||||
}
|
||||
|
||||
const response = await axios.post(`${window['TT_CONFIG']['BASE_PATH']}/WarehouseArticlePrice/${row.id ? 'update' : 'create'}`, data);
|
||||
this.$emit('doUpdate');
|
||||
this.window.notify(response.data.success ? 'success' : 'error',
|
||||
response.data.errors ? Object.values(response.data.errors).join('<br>') : response.data.message);
|
||||
await this.fetchLocationThreshold()
|
||||
}, async deleteRow(index) {
|
||||
const row = this.rows[index];
|
||||
|
||||
if (!row.id) {
|
||||
this.window.notify('error', 'Eintrag hat keine ID');
|
||||
}
|
||||
|
||||
const response = axios.post(window['TT_CONFIG']['BASE_PATH'] + '/WarehouseArticlePrice/delete', {id: row.id});
|
||||
this.$emit('doUpdate');
|
||||
this.window.notify(response.data.success ? 'success' : 'error',
|
||||
response.data.errors ? Object.values(response.data.errors).join('<br>') : response.data.message);
|
||||
await this.fetchLocationThreshold();
|
||||
}
|
||||
}, watch: {
|
||||
show(newVal) {
|
||||
this.showModal = newVal;
|
||||
if (!newVal) {
|
||||
this.rows = [];
|
||||
return;
|
||||
}
|
||||
this.rows = [];
|
||||
this.fetchLocationThreshold().then();
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
Vue.component('warehouse-article', {
|
||||
//language=Vue
|
||||
template: `
|
||||
<tt-card>
|
||||
<tt-table-crud ref="table"
|
||||
@openHistory="historyModal = true; historyModalId = $event.id"
|
||||
@editDistributorEntries="distributorModal = true; distributorModalId = $event.id"
|
||||
@editPricesEntries="priceModal = true; priceModalId = $event.id"
|
||||
@editThresholdEntries="thresholdModal = true; thresholdModalId = $event.id">
|
||||
|
||||
<template v-slot:cheapestPurchasePrice="{ row }">
|
||||
<span>{{(row.cheapestPurchasePrice * row.sellPriceMultiplier).toFixed(2)}} €</span>
|
||||
</template>
|
||||
|
||||
</tt-table-crud>
|
||||
|
||||
<warehouse-distributor-modal :show.sync="distributorModal" :id="distributorModalId" @doUpdate="refreshTable"/>
|
||||
<warehouse-threshold-modal :show.sync="thresholdModal" :id="thresholdModalId" @doUpdate="refreshTable"/>
|
||||
<warehouse-article-price-modal :show.sync="priceModal" :id="priceModalId" @doUpdate="refreshTable"/>
|
||||
<warehouse-history-modal :show.sync="historyModal" :id="historyModalId"/>
|
||||
</tt-card>
|
||||
`, data() {
|
||||
return {
|
||||
window: window,
|
||||
historyModal: false,
|
||||
historyModalId: null,
|
||||
distributorModal: false,
|
||||
distributorModalId: null,
|
||||
thresholdModal: false,
|
||||
thresholdModalId: null,
|
||||
priceModal: false,
|
||||
priceModalId: null
|
||||
}
|
||||
}, methods: {
|
||||
refreshTable() {
|
||||
this.$refs.table.$refs.table.refreshTable();
|
||||
}
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user