mirror of
https://bitbucket.org/studiotem/jandl-taskmanager-app.git
synced 2026-10-21 14:29:34 +00:00
62 lines
1.3 KiB
Vue
62 lines
1.3 KiB
Vue
<template>
|
|
<input type="file" name="file" id="fileInput" class="hidden-input" accept="*"
|
|
@change="onChange" ref="fileUpload"
|
|
/>
|
|
|
|
<br>
|
|
<br>
|
|
<v-btn @click="createWithoutFile()">CREATE without file</v-btn>
|
|
<br>
|
|
<br>
|
|
<v-btn @click="createWithFile()">CREATE with file</v-btn>
|
|
</template>
|
|
|
|
<script>
|
|
import moment from 'moment'
|
|
import axios from 'axios'
|
|
|
|
export default {
|
|
data() {
|
|
return {
|
|
files: null
|
|
}
|
|
},
|
|
|
|
methods: {
|
|
onChange($event) {
|
|
this.files = $event.target.files
|
|
},
|
|
|
|
async createWithoutFile() {
|
|
const masterTask = this._getMastertaskObject()
|
|
|
|
await axios.post('https://taskmanager.internal.studiotem.com/api/v1/mastertasks', this._objectToFormData(masterTask))
|
|
console.log(await this.$axios.get_data('v1/mastertasks'))
|
|
},
|
|
|
|
async createWithFile() {
|
|
if (!this.files) return alert('No files uploaded')
|
|
|
|
const masterTask = this._getMastertaskObject()
|
|
masterTask.files = this.files
|
|
|
|
console.log(await this.$axios.post_auth_data('v1/mastertasks', masterTask))
|
|
},
|
|
|
|
_getMastertaskObject() {
|
|
return {
|
|
name: `name-${3}`,
|
|
description: `description`,
|
|
duration: 1231,
|
|
deadline: moment().format('YYYY-MM-DD HH:MM:SS'),
|
|
project_id: 1,
|
|
team_id: 1,
|
|
employees: [{
|
|
id: 1,
|
|
duration: 1000
|
|
}]
|
|
}
|
|
}
|
|
}
|
|
}
|
|
</script> |