Browse Source

Enable to upload file

pull/341/head
Hironsan 5 years ago
parent
commit
80bd91074d
2 changed files with 14 additions and 5 deletions
  1. 5
      frontend/components/organisms/documents/DocumentUploadForm.vue
  2. 14
      frontend/store/documents.js

5
frontend/components/organisms/documents/DocumentUploadForm.vue

@ -24,7 +24,7 @@
/>
</v-radio-group>
<v-file-input
:value="file"
v-model="file"
:accept="acceptType"
:rules="uploadFileRules"
label="File input"
@ -87,7 +87,8 @@ export default {
create() {
if (this.validate()) {
this.uploadDocument({
format: this.selectedFormat,
projectId: this.$route.params.id,
format: this.selectedFormat.type,
file: this.file
})
this.reset()

14
frontend/store/documents.js

@ -123,11 +123,19 @@ export const actions = {
commit('setLoading', false)
})
},
uploadDocument({ commit }, data) {
uploadDocument({ commit, dispatch }, data) {
commit('setLoading', true)
DocumentService.uploadFile(data.projectId, data)
const formData = new FormData()
formData.append('file', data.file)
formData.append('format', data.format)
const config = {
headers: {
'Content-Type': 'multipart/form-data'
}
}
DocumentService.uploadFile(data.projectId, formData, config)
.then((response) => {
commit('addDocument', response)
dispatch('getDocumentList', data)
})
.catch((error) => {
alert(error)

Loading…
Cancel
Save