1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
|
<template>
<div>
<EditFormBox
v-bind:form-type="formType"
v-bind:table-row="formData"
@close-form="hideForm"
@show-popup="showPopup($event)"
v-if="isFormShown"
/>
<Table v-bind:table-data="tableData" @show-form="showForm('update', $event)"/>
<UploadFileButton v-if="!isFormShown"/>
<AddNewEntryButton v-if="!isFormShown" @show-form="showForm('create', $event)"/>
<transition name="fade">
<PopupMessage v-if="isPopupShown" v-bind:message="popupMessage"/>
</transition>
</div>
</template>
<script>
import EditFormBox from "./components/EditFormBox.vue";
import Table from "./components/Table.vue";
import UploadFileButton from "./components/UploadFileButton.vue";
import AddNewEntryButton from './components/AddNewEntryButton.vue';
import PopupMessage from './components/PopupMessage.vue'
import axios from 'axios';
export default {
name: "App",
components: {PopupMessage, EditFormBox, Table, UploadFileButton, AddNewEntryButton},
data() {
return {
tableData: [],
formType: null,
formData: null,
isFormShown: false,
isPopupShown: false,
popupMessage: '',
}
},
mounted() {
this.updateTable();
},
methods: {
updateTable() {
axios
.request({
url: '/api/get/',
method: 'post',
headers: {'Content-Type': 'application/json'},
data: JSON.stringify({'type': 'full'})
})
.then(response => {
this.tableData = response.data;
})
},
showPopup(message) {
if (!this.isPopupShown) {
this.isPopupShown = true;
this.popupMessage = message;
setTimeout(() => {
this.isPopupShown = false;
this.popupMessage = '';
}, 2000)
}
},
showForm(formType, formData) {
this.formType = formType;
this.formData = formData;
this.isFormShown = true;
},
hideForm() {
this.formType = null;
this.formData = null;
this.isFormShown = false;
this.updateTable()
}
}
}
</script>
<style scoped>
.fade-enter-active, .fade-leave-active {
transition: opacity .5s;
}
.fade-enter, .fade-leave-to {
opacity: 0;
}
</style>
|