Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Sign in
Toggle navigation
K
kiaisoft_tuananh_nuxt
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
TTS Tran Viet Anh
kiaisoft_tuananh_nuxt
Commits
02906955
Commit
02906955
authored
Feb 02, 2023
by
TTS Kieu Tuan Anh
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix formdata
parent
8f5824af
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
20 deletions
+35
-20
index.vue
pages/posts/index.vue
+1
-1
index.vue
pages/products/index.vue
+34
-19
No files found.
pages/posts/index.vue
View file @
02906955
...
...
@@ -183,7 +183,7 @@
color=
"blue darken-1"
text
type=
"submit"
@
click=
"dialog2 = false;
createPost();
"
@
click=
"dialog2 = false;"
>
Save
</v-btn>
...
...
pages/products/index.vue
View file @
02906955
...
...
@@ -71,6 +71,7 @@
label=
"File input"
small-chips
dense
accept=
"image/*"
multiple
/>
</v-col>
...
...
@@ -276,7 +277,7 @@
>
<v-card>
<v-card-title>
<span
class=
"text-h5"
>
CREA
T PRODUCT
</span>
<span
class=
"text-h5"
>
EDI
T PRODUCT
</span>
</v-card-title>
<v-card-text>
<v-container>
...
...
@@ -323,7 +324,6 @@
small-chips
dense
multiple
:state=
"Boolean(images)"
/>
</v-col>
<v-col
cols=
"12"
>
...
...
@@ -407,7 +407,7 @@
color=
"blue darken-1"
text
type=
"submit"
@
click=
"dialog3 = false;
edit
Product();"
@
click=
"dialog3 = false;
update
Product();"
>
Save
</v-btn>
...
...
@@ -758,6 +758,9 @@ export default {
quantity
:
''
}
],
color
:
''
,
size
:
''
,
quantity
:
''
,
dialog1
:
false
,
dialog2
:
false
,
dialog3
:
false
,
...
...
@@ -790,6 +793,7 @@ export default {
href
:
'
/products
'
}
],
i
:
''
,
products
:
[],
product
:
[],
categories
:
[],
...
...
@@ -945,15 +949,19 @@ export default {
},
createProduct
()
{
const
self
=
this
// const set = new Set([this.images])
// const images = Array.from(set)
const
fd
=
new
FormData
()
fd
.
append
(
'
name
'
,
this
.
name
)
fd
.
append
(
'
price
'
,
this
.
price
)
fd
.
append
(
'
category_id
'
,
this
.
category_id
)
fd
.
append
(
'
description
'
,
this
.
description
)
fd
.
append
(
'
image
'
,
this
.
images
)
fd
.
append
(
'
variants
'
,
this
.
variants
)
for
(
let
i
=
0
;
i
<
this
.
variants
.
length
;
i
++
)
{
fd
.
append
(
`variants[
${
i
}
][color]`
,
this
.
variants
[
i
].
color
)
fd
.
append
(
`variants[
${
i
}
][quantity]`
,
this
.
variants
[
i
].
quantity
)
fd
.
append
(
`variants[
${
i
}
][size]`
,
this
.
variants
[
i
].
size
)
}
for
(
let
j
=
0
;
j
<
this
.
images
.
length
;
j
++
)
{
fd
.
append
(
`images[
${
j
}
]`
,
this
.
images
[
j
])
}
this
.
$axios
.
post
(
'
/products/
'
,
fd
...
...
@@ -1039,21 +1047,28 @@ export default {
},
updateProduct
(
ID
)
{
const
self
=
this
const
fd
=
new
FormData
()
fd
.
append
(
'
name
'
,
this
.
eName
)
fd
.
append
(
'
price
'
,
this
.
ePrice
)
fd
.
append
(
'
category_id
'
,
this
.
eCategoryId
)
fd
.
append
(
'
description
'
,
this
.
eDescription
)
for
(
let
i
=
0
;
i
<
this
.
eVariants
.
length
;
i
++
)
{
fd
.
append
(
`variants[
${
i
}
][color]`
,
this
.
eVariants
[
i
].
color
)
fd
.
append
(
`variants[
${
i
}
][quantity]`
,
this
.
eVariants
[
i
].
quantity
)
fd
.
append
(
`variants[
${
i
}
][size]`
,
this
.
eVariants
[
i
].
size
)
}
for
(
let
j
=
0
;
j
<
this
.
eImages
.
length
;
j
++
)
{
fd
.
append
(
`images[
${
j
}
]`
,
this
.
eImages
[
j
])
}
try
{
this
.
$axios
.
post
(
`/products/update/
${
this
?.
eId
}
`, {
name: this.eName,
price: this.ePrice,
category_id: this.eCategoryId,
description: this.eDescription,
images: this.eImages,
variants: this.eVariants
}, {
headers: {
'Content-Type': 'multipart/form-data',
Authorization: `
Bearer
$
{
this
.
$auth
.
$storage
.
getUniversal
(
'
token
'
)}
`
.
post
(
`/products/update/
${
this
?.
eId
}
`,
fd, {
headers: {
'Content-Type': 'multipart/form-data',
Authorization: `
Bearer
$
{
this
.
$auth
.
$storage
.
getUniversal
(
'
token
'
)}
`
}
}
}
)
.then((response) => {
self.$toast.success('User updated successfully!', {
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment