window.localStorage.setItem('tt-table-WarehouseOrderRequest', JSON.stringify({ filters: { takeOverBy: null, canceled: 0 } })); window.TT_CONFIG["CRUD_CONFIG"]["additionalActions"] = [ ...window.TT_CONFIG["CRUD_CONFIG"]["additionalActions"], { "key": "cancel", "title": "Bestellwunsch stornieren", "class": "fas fa-times text-danger", "condition": (row) => window.TT_CONFIG['WAREHOUSE_ADMIN'] === '1' && row.canceled === 0, }, { "key": "uncancel", "title": "Bestellwunsch wiederherstellen", "class": "fas fa-check text-success", "condition": (row) => window.TT_CONFIG['WAREHOUSE_ADMIN'] === '1' && row.canceled === 1, }, ] Vue.component('warehouse-order-request', { //language=Vue template: ` `, data() { return { window: window, historyModal: false, historyModalId: null, showHiddenRequests: false, showCanceledRequests: false } }, async mounted() { if (this.window.TT_CONFIG.WAREHOUSE_ADMIN !== '1') return this.$refs.crud.$watch('crudModal', (value) => { return if (value) { // if id is not 'create' then check if order is set and if not set it to current date // if order is set then check if takeover is set and if not set it to current date if (!this.$refs.crud.crudModalData.id) return if (!this.$refs.crud.crudModalData.order) { this.$refs.crud.crudModalData.order = window.moment().unix() this.$refs.crud.crudModalData.orderBy = window.TT_CONFIG.user_id this.$refs.crud.$refs["order-modal-input"][0].setStartDate(window.moment().format('MM/DD/YYYY')) return } if (!this.$refs.crud.crudModalData.takeover) { this.$refs.crud.crudModalData.takeover = window.moment().unix this.$refs.crud.crudModalData.takeOverBy = window.TT_CONFIG.user_id this.$refs.crud.$refs["takeover-modal-input"][0].setStartDate(window.moment().format('MM/DD/YYYY')) } } }) }, methods: { // portected function cancelAction() { // $id = $this->request->id; // $cancel = $this->request->cancel; async cancelOrderRequest(row, cancel) { if (!window.confirm('Bestellwunsch wirklich stornieren?')) return const response = await axios.get(window.TT_CONFIG["BASE_PATH"] + '/WarehouseOrderRequest/cancel?id=' + row.id + '&cancel=' + cancel); if (response.data.success) { this.window.notify('success', response.data.message || 'Erfolgreich aktualisiert') this.$refs.crud.$refs.table.refreshTable() return } this.window.notify('error', response.data.message || 'Fehler beim aktualisieren') } }, watch: { async showHiddenRequests(value) { this.showCanceledRequests = false this.$refs.crud.$refs.table.$set(this.$refs.crud.$refs.table.filters, 'canceled', '') this.$refs.crud.$refs.table.$set(this.$refs.crud.$refs.table.filters, 'takeOverBy', value ? '' : null) }, async showCanceledRequests(value) { this.showHiddenRequests = false this.$refs.crud.$refs.table.$set(this.$refs.crud.$refs.table.filters, 'canceled', value ? '1' : '') this.$refs.crud.$refs.table.$set(this.$refs.crud.$refs.table.filters, 'takeOverBy', '') } } })