Commit a802f028 authored by vietanh-0511's avatar vietanh-0511

fix bug parent_id and images

parent 3a409ea6
...@@ -139,6 +139,7 @@ ...@@ -139,6 +139,7 @@
prepend-icon="mdi-camera" prepend-icon="mdi-camera"
/> />
</v-col> </v-col>
<v-img v-if="typeof eImage === 'string'" :src="eImage" />
</v-row> </v-row>
</v-container> </v-container>
<small>*indicates required field</small> <small>*indicates required field</small>
...@@ -248,7 +249,7 @@ export default { ...@@ -248,7 +249,7 @@ export default {
middleware: ['web'], middleware: ['web'],
data: () => { data: () => {
return { return {
parent_id: null, parent_id: '',
name: '', name: '',
ordering: '', ordering: '',
image: null, image: null,
...@@ -385,14 +386,12 @@ export default { ...@@ -385,14 +386,12 @@ export default {
}) })
}, },
createCategory () { createCategory () {
const set = new Set([this.image])
const image = Array.from(set)
const self = this const self = this
const fd = new FormData() const fd = new FormData()
fd.append('name', this.name) fd.append('name', this.name)
fd.append('ordering', this.ordering) fd.append('ordering', this.ordering)
fd.append('parent_id', this.parent_id) fd.append('parent_id', this.parent_id)
fd.append('images', image) fd.append('images', this.image)
this.$axios this.$axios
.post('/categories/', .post('/categories/',
fd, fd,
...@@ -463,14 +462,16 @@ export default { ...@@ -463,14 +462,16 @@ export default {
console.log(item) console.log(item)
}, },
updateCategory (userID) { updateCategory (userID) {
const set = new Set([this.eImage])
const image = Array.from(set)
const self = this const self = this
const fd = new FormData() const fd = new FormData()
if (this.eParentId === null) {
fd.append('parent_id', '')
} else {
fd.append('parent_id', this.eParentId)
}
fd.append('name', this.eName) fd.append('name', this.eName)
fd.append('ordering', this.eOrdering) fd.append('ordering', this.eOrdering)
fd.append('parent_id', this.eParentId) fd.append('images', this.eImage)
fd.append('images', image)
try { try {
this.$axios this.$axios
.post(`categories/update/${this?.eID}`, .post(`categories/update/${this?.eID}`,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment