CreateFolderFormComponent.vue
2.37 KB
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
<template>
<v-dialog
v-model="dialog"
max-width="400px">
<template v-slot:activator="{on}">
<v-btn
flat slot="activator"
text
v-on="on">
<v-icon>add</v-icon>
<span overline class="caption">새로 만들기</span>
</v-btn>
</template>
<v-card>
<v-card-title>
<p class="title font-weight-light">폴더</p>
</v-card-title>
<v-form class="px-3" @submit.prevent="uploadFolder">
<v-card-text>
<v-text-field
outlined
label="폴더 이름"
v-model="folderName"
color="blue"
/>
</v-card-text>
<v-card-actions>
<v-spacer/>
<v-btn
depressed
class="mr-3 mb-3 text-lowercase font-weight-light"
type="submit"
@click="dialog = false">
만들기
</v-btn>
</v-card-actions>
</v-form>
</v-card>
</v-dialog>
</template>
<script>
import moment from 'moment';
export default {
name: "CreateFolderFormComponent",
computed: {
me() {
return this.$store.state.user.me;
},
currentFolder() {
return this.$store.state.file.currentFolder
}
},
data() {
return {
valid: false,
folderName: '',
dialog: false,
}
},
methods: {
folderPath(){
return this.currentFolder.path + this.folderName + '/'
},
async uploadFolder() {
try {
var now = Date.now();
now = moment(now).format("YYYY-MM-DD");
const formData = new FormData();
formData.append('name', this.folderName);
formData.append('owner', this.me.username);
formData.append('path', this.folderPath());
formData.append('isFolder', true);
// formData.append('createdDate', now);
formData.append('modifiedDate', now);
formData.append('filesize', 0);
formData.append('share', false);
formData.append('cid', this.currentFolder.id);
console.log("TEST", now, this.folderPath, this.folderName);
this.dialog = false;
await this.$store.dispatch('file/uploadFolder', {formData});
this.folderName = '';
} catch (e) {
console.error(e);
}
},
}
}
</script>
<style scoped>
</style>