58 lines
2.7 KiB
JavaScript
58 lines
2.7 KiB
JavaScript
Vue.component('warehouse-order-request', {
|
|
//language=Vue
|
|
template: `
|
|
<tt-card>
|
|
<tt-table-crud @openHistory="historyModal = true; historyModalId = $event.id" ref="crud">
|
|
<template v-slot:create="{ row }">
|
|
{{ row.create ? window.moment(row.create * 1000).format('DD.MM.YYYY') : '' }}
|
|
</template>
|
|
|
|
<template v-slot:order="{ row }">
|
|
{{ row.order ? window.moment(row.order * 1000).format('DD.MM.YYYY') : '' }}
|
|
</template>
|
|
|
|
<template v-slot:takeover="{ row }">
|
|
{{ row.takeover ? window.moment(row.takeover * 1000).format('DD.MM.YYYY') : '' }}
|
|
</template>
|
|
|
|
<template v-slot:note="{ row }">
|
|
<span v-if="row.note && row.note.length > 45" :title="row.note">{{ row.note.substring(0, 45) }}...</span>
|
|
<span v-else>{{ row.note }}</span>
|
|
</template>
|
|
|
|
</tt-table-crud>
|
|
<warehouse-history-modal :show.sync="historyModal" :id="historyModalId"/>
|
|
</tt-card>
|
|
`, data() {
|
|
return {
|
|
window: window, historyModal: false, historyModalId: null,
|
|
}
|
|
},
|
|
async mounted() {
|
|
// set a watch to ref.crud crudModal and if crudModal and then log ref crudModalData
|
|
this.$refs.crud.$watch('crudModal', (value) => {
|
|
if (value) {
|
|
console.log(this.$refs.crud.crudModalData)
|
|
// 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'))
|
|
}
|
|
|
|
|
|
}
|
|
})
|
|
}
|
|
})
|