Vue.component('warehouse-distributor-modal', { //language=Vue template: ` Lieferant hinzufügen `, 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({distributorId: undefined, 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('') : 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('') : 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: ` Schwellenwert hinzufügen `, 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('') : 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('') : 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: ` Preis hinzufügen `, 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('') : 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('') : response.data.message); await this.fetchLocationThreshold(); } }, watch: { show(newVal) { this.showModal = newVal; if (!newVal) { this.rows = []; return; } this.rows = []; this.fetchLocationThreshold().then(); } } }) // noinspection EqualityComparisonWithCoercionJS Vue.component('warehouse-article', { //language=Vue template: ` {{price.title}}: {{(price.price)}} € {{(price.price)}} € {{(row.cheapestPurchasePrice * row.sellPriceMultiplier).toFixed(2)}} € Es werden Bestellungen an folgende Lieferanten gesendet: {{order.distributor[0].name}} - {{order.orderAmount}} € Artikel Menge Preis Summe {{item.title}} {{item.amount}} {{item.purchasePrice}} € {{item.sum.toFixed(2)}} € `, data() { return { window: window, historyModal: false, historyModalId: null, distributorModal: false, distributorModalId: null, thresholdModal: false, thresholdModalId: null, priceModal: false, priceModalId: null, shoppingCart: [], addShoppingCartModal: false, addShoppingCartModalId: null, addShoppingCartModalCount: '', confirmOrderModal: false, confirmOrderModalData: null, } }, methods: { refreshTable() { this.$refs.table.$refs.table.refreshTable(); }, async addToShoppingCart() { if (this.addShoppingCartModalCount < 1) { // Check if amount is set window.notify('error', 'Bitte geben Sie eine Menge ein.'); return; } if (this.shoppingCart.some(item => item.itemId === this.addShoppingCartModalId)) { // Check if same article is already in cart window.notify('error', 'Artikel bereits im Warenkorb.'); return; } const response = await axios.get(`${window['TT_CONFIG']['BASE_PATH']}/WarehouseArticle/getById?id=${this.addShoppingCartModalId}`); this.shoppingCart.push({amount: parseInt(this.addShoppingCartModalCount), itemId: this.addShoppingCartModalId, title: response.data.title}); this.addShoppingCartModal = false; this.addShoppingCartModalId = null; this.addShoppingCartModalCount = ''; window.notify('success', 'Artikel erfolgreich hinzugefügt.'); }, async prepareOrder() { const response = await axios.post(`${window['TT_CONFIG']['BASE_PATH']}/WarehouseArticle/prepareOrder`, this.shoppingCart); this.confirmOrderModal = true; this.confirmOrderModalData = response.data; }, async createOrder() { const response = await axios.post(`${window['TT_CONFIG']['BASE_PATH']}/WarehouseOrder/createOrder`, this.confirmOrderModalData); this.confirmOrderModal = false; this.confirmOrderModalData = null; this.shoppingCart = []; window.notify(response.data.success ? 'success' : 'error', response.data.message); setTimeout(() => { window.location.href = `${window['TT_CONFIG']['BASE_PATH']}/WarehouseOrder`; }, 2000); } } })