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
Show 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 @@
...
@@ -183,7 +183,7 @@
color=
"blue darken-1"
color=
"blue darken-1"
text
text
type=
"submit"
type=
"submit"
@
click=
"dialog2 = false;
createPost();
"
@
click=
"dialog2 = false;"
>
>
Save
Save
</v-btn>
</v-btn>
...
...
pages/products/index.vue
View file @
02906955
...
@@ -71,6 +71,7 @@
...
@@ -71,6 +71,7 @@
label=
"File input"
label=
"File input"
small-chips
small-chips
dense
dense
accept=
"image/*"
multiple
multiple
/>
/>
</v-col>
</v-col>
...
@@ -276,7 +277,7 @@
...
@@ -276,7 +277,7 @@
>
>
<v-card>
<v-card>
<v-card-title>
<v-card-title>
<span
class=
"text-h5"
>
CREA
T PRODUCT
</span>
<span
class=
"text-h5"
>
EDI
T PRODUCT
</span>
</v-card-title>
</v-card-title>
<v-card-text>
<v-card-text>
<v-container>
<v-container>
...
@@ -323,7 +324,6 @@
...
@@ -323,7 +324,6 @@
small-chips
small-chips
dense
dense
multiple
multiple
:state=
"Boolean(images)"
/>
/>
</v-col>
</v-col>
<v-col
cols=
"12"
>
<v-col
cols=
"12"
>
...
@@ -407,7 +407,7 @@
...
@@ -407,7 +407,7 @@
color=
"blue darken-1"
color=
"blue darken-1"
text
text
type=
"submit"
type=
"submit"
@
click=
"dialog3 = false;
edit
Product();"
@
click=
"dialog3 = false;
update
Product();"
>
>
Save
Save
</v-btn>
</v-btn>
...
@@ -758,6 +758,9 @@ export default {
...
@@ -758,6 +758,9 @@ export default {
quantity
:
''
quantity
:
''
}
}
],
],
color
:
''
,
size
:
''
,
quantity
:
''
,
dialog1
:
false
,
dialog1
:
false
,
dialog2
:
false
,
dialog2
:
false
,
dialog3
:
false
,
dialog3
:
false
,
...
@@ -790,6 +793,7 @@ export default {
...
@@ -790,6 +793,7 @@ export default {
href
:
'
/products
'
href
:
'
/products
'
}
}
],
],
i
:
''
,
products
:
[],
products
:
[],
product
:
[],
product
:
[],
categories
:
[],
categories
:
[],
...
@@ -945,15 +949,19 @@ export default {
...
@@ -945,15 +949,19 @@ export default {
},
},
createProduct
()
{
createProduct
()
{
const
self
=
this
const
self
=
this
// const set = new Set([this.images])
// const images = Array.from(set)
const
fd
=
new
FormData
()
const
fd
=
new
FormData
()
fd
.
append
(
'
name
'
,
this
.
name
)
fd
.
append
(
'
name
'
,
this
.
name
)
fd
.
append
(
'
price
'
,
this
.
price
)
fd
.
append
(
'
price
'
,
this
.
price
)
fd
.
append
(
'
category_id
'
,
this
.
category_id
)
fd
.
append
(
'
category_id
'
,
this
.
category_id
)
fd
.
append
(
'
description
'
,
this
.
description
)
fd
.
append
(
'
description
'
,
this
.
description
)
fd
.
append
(
'
image
'
,
this
.
images
)
for
(
let
i
=
0
;
i
<
this
.
variants
.
length
;
i
++
)
{
fd
.
append
(
'
variants
'
,
this
.
variants
)
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
this
.
$axios
.
post
(
'
/products/
'
,
.
post
(
'
/products/
'
,
fd
fd
...
@@ -1039,16 +1047,23 @@ export default {
...
@@ -1039,16 +1047,23 @@ export default {
},
},
updateProduct
(
ID
)
{
updateProduct
(
ID
)
{
const
self
=
this
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
{
try
{
this
.
$axios
this
.
$axios
.
post
(
`/products/update/
${
this
?.
eId
}
`, {
.
post
(
`/products/update/
${
this
?.
eId
}
`,
name: this.eName,
fd, {
price: this.ePrice,
category_id: this.eCategoryId,
description: this.eDescription,
images: this.eImages,
variants: this.eVariants
}, {
headers: {
headers: {
'Content-Type': 'multipart/form-data',
'Content-Type': 'multipart/form-data',
Authorization: `
Bearer
$
{
this
.
$auth
.
$storage
.
getUniversal
(
'
token
'
)}
`
Authorization: `
Bearer
$
{
this
.
$auth
.
$storage
.
getUniversal
(
'
token
'
)}
`
...
...
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