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
d51cedb6
Commit
d51cedb6
authored
Feb 02, 2023
by
Kemm23
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
save code
parent
28205971
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
39 deletions
+17
-39
index.vue
pages/categories/index.vue
+17
-39
No files found.
pages/categories/index.vue
View file @
d51cedb6
...
...
@@ -67,7 +67,6 @@
accept=
"image/*"
label=
"Image"
prepend-icon=
"mdi-camera"
@
change=
"testLog()"
/>
</v-col>
</v-row>
...
...
@@ -125,25 +124,21 @@
</v-col>
<v-col
cols=
"12"
>
<v-select
v-model=
"
parent_i
d"
v-model=
"
eParentI
d"
:items=
"categories.filter(category => category.parent_id === null)"
item-text=
"name"
item-value=
"id"
label=
"Parent_id"
@
input=
"testLog()"
/>
</v-col>
<v-col
cols=
"12"
>
<v-file-input
v-model=
"eImage"
accept=
"image/*"
label=
"Image"
prepend-icon=
"mdi-camera"
/>
</v-col>
<v-col
cols=
"12"
>
<v-file-input
label=
"File input"
/>
</v-col>
</v-row>
</v-container>
<small>
*indicates required field
</small>
...
...
@@ -161,7 +156,7 @@
color=
"blue darken-1"
text
type=
"submit"
@
click=
"dialog2 = false; update
User
();"
@
click=
"dialog2 = false; update
Category
();"
>
Save
</v-btn>
...
...
@@ -333,9 +328,7 @@ export default {
this
.
getCategories
()
},
methods
:
{
testLog
()
{
console
.
log
(
this
.
image
)
},
testLog
()
{},
initialize
()
{
this
.
users
=
[]
this
.
categories
=
[]
...
...
@@ -395,20 +388,14 @@ export default {
const
set
=
new
Set
([
this
.
image
])
const
image
=
Array
.
from
(
set
)
const
self
=
this
console
.
log
({
name
:
this
.
name
,
ordering
:
this
.
ordering
,
parent_id
:
this
.
parent_id
,
images
:
image
})
const
fd
=
new
FormData
()
fd
.
append
(
'
name
'
,
this
.
name
)
fd
.
append
(
'
ordering
'
,
this
.
ordering
)
fd
.
append
(
'
parent_id
'
,
this
.
parent_id
)
fd
.
append
(
'
images
'
,
image
)
this
.
$axios
.
post
(
'
/categories/
'
,
{
name
:
this
.
name
,
ordering
:
this
.
ordering
,
parent_id
:
this
.
parent_id
,
images
:
image
},
fd
,
{
headers
:
{
'
Content-Type
'
:
'
multipart/form-data
'
,
...
...
@@ -417,16 +404,13 @@ export default {
}
)
.
then
((
response
)
=>
{
this
.
$bvModal
.
hide
(
'
modal-create
'
)
self
.
$toast
.
success
(
'
Category created successfully!
'
,
{
duration
:
3000
})
this
.
editedItem
=
response
.
data
.
data
console
.
log
(
this
.
editedItem
)
this
.
categories
.
push
(
this
.
editedItem
)
})
.
catch
((
errors
)
=>
{
this
.
$bvModal
.
hide
(
'
modal-create
'
)
console
.
log
(
errors
.
response
.
data
.
message
)
this
.
message
=
errors
.
response
.
data
.
message
self
.
$toast
.
error
(
'
something went wrong while trying create!
'
,
{
...
...
@@ -476,25 +460,21 @@ export default {
this
.
eParentId
=
item
.
parent_id
this
.
eImage
=
item
.
images
this
.
editedIndex
=
this
.
categories
.
indexOf
(
item
)
console
.
log
(
this
?.
eID
)
console
.
log
(
item
)
},
updateCategory
(
userID
)
{
const
set
=
new
Set
([
this
.
eImage
])
const
image
=
Array
.
from
(
set
)
const
self
=
this
console
.
log
(
this
.
eName
)
console
.
log
(
this
.
eOrdering
)
console
.
log
(
this
?.
eID
)
const
fd
=
new
FormData
()
fd
.
append
(
'
name
'
,
this
.
eName
)
fd
.
append
(
'
ordering
'
,
this
.
eOrdering
)
fd
.
append
(
'
parent_id
'
,
this
.
eParentId
)
fd
.
append
(
'
images
'
,
image
)
try
{
this
.
$axios
.
post
(
`categories/update/
${
this
?.
eID
}
`,
{
name: this.eName,
ordering: this.eOrdering,
parent_id: this.eParentId,
images: image
},
fd,
{
headers: {
'Content-Type': 'multipart/form-data',
...
...
@@ -506,9 +486,7 @@ export default {
self.$toast.success('User updated successfully!', {
duration: 3000
})
console.log(response)
this.editedItem = response.data.data
this.$bvModal.hide('modal-edit')
Object.assign(this.categories[this.editedIndex], this.editedItem)
})
} catch (error) {
...
...
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