98 lines
3.5 KiB
JavaScript
98 lines
3.5 KiB
JavaScript
Vue.component('warehouse-article-prices', {
|
|
props: {id: {type: Number, required: true}},
|
|
template: `
|
|
<div>
|
|
|
|
<tt-card>
|
|
<h4>Artikelpreise</h4>
|
|
|
|
<div class="warehouse-article-prices">
|
|
<div v-for="(price, index) in articlePrices" :key="index" class="article-price">
|
|
<div class="article-price-type">
|
|
<span v-if="price.isRobot" class="robot-icon"><i class="fa-solid fa-robot"></i></span>
|
|
{{ index }}
|
|
</div>
|
|
<tt-input sm v-model="price.priceMultiplier" label="Preisfaktor"/>
|
|
<tt-input sm v-model="price.priceOverride" label="Preisoverride"/>
|
|
|
|
<div>
|
|
<tt-button sm icon="fa-solid fa-trash" class="remove-price" additional-class="btn-danger"></tt-button>
|
|
<tt-button sm icon="fa-solid fa-save" class="save-price" additional-class="btn-primary"></tt-button>
|
|
</div>
|
|
|
|
</div>
|
|
</div>
|
|
</tt-card>
|
|
|
|
</div>`,
|
|
data: () => ({
|
|
window,
|
|
articlePrices: [],
|
|
}),
|
|
async mounted() {
|
|
const [res1, res2] = await Promise.all([
|
|
axios.post(window['TT_CONFIG']['BASE_PATH'] + '/WarehouseArticlePrice/get', {filters: {articleId: this.id}}),
|
|
axios.post(window['TT_CONFIG']['BASE_PATH'] + '/WarehouseArticlePriceType/get')
|
|
]);
|
|
const prices = {};
|
|
res2.data.rows.forEach(t => prices[t.title] = {
|
|
isRobot: true,
|
|
articlePriceTypeId: t.id,
|
|
priceMultiplier: t.defaultPriceFactor,
|
|
priceOverride: null
|
|
});
|
|
res1.data.rows.forEach(p => {
|
|
const t = res2.data.rows.find(t => t.id === p.articlePriceTypeId);
|
|
if (t) prices[t.title] = {
|
|
isRobot: false,
|
|
articlePriceTypeId: p.articlePriceTypeId,
|
|
priceMultiplier: p.priceMultiplier || t.defaultPriceFactor,
|
|
priceOverride: p.priceOverride
|
|
};
|
|
});
|
|
this.articlePrices = prices;
|
|
}
|
|
})
|
|
|
|
Vue.component('warehouse-article', {
|
|
//language=Vue
|
|
template: `
|
|
<tt-card>
|
|
|
|
<tt-table-crud ref="table" @openHistory="historyModal = true; historyModalId = $event.id">
|
|
|
|
<template v-slot:cheapestsellprice="{ row }">
|
|
<template v-for="price in JSON.parse(row.cheapestSellPrice)">
|
|
<span v-if="price && window.TT_CONFIG['WAREHOUSE_ADMIN'] == true">{{price.title}}: <span
|
|
style="white-space:nowrap;"> {{(price.price)}} €</span><br></span>
|
|
<span v-else-if="price && price.title === 'Verkauf'">{{(price.price)}} €</span>
|
|
</template>
|
|
</template>
|
|
|
|
<template v-slot:modal-prepend="{ crudModalData }">
|
|
<warehouse-article-prices v-if="crudModalData.id" :id="crudModalData.id"/>
|
|
</template>
|
|
|
|
</tt-table-crud>
|
|
|
|
<warehouse-history-modal :show.sync="historyModal" :id="historyModalId"/>
|
|
</tt-card>
|
|
`, data: () => ({
|
|
window,
|
|
historyModal: false,
|
|
historyModalId: null,
|
|
}),
|
|
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();
|
|
}
|
|
}
|
|
})
|