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
81fc4c62
Commit
81fc4c62
authored
Jan 27, 2023
by
TTS Kieu Tuan Anh
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix 6/8 options
parent
65376418
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
187 additions
and
187 deletions
+187
-187
index.vue
pages/categories/index.vue
+63
-63
index.vue
pages/posts/index.vue
+80
-80
index.vue
pages/products/index.vue
+44
-44
No files found.
pages/categories/index.vue
View file @
81fc4c62
...
...
@@ -5,10 +5,10 @@
<b-icon
icon=
"house-fill"
scale=
"1.25"
shift-v=
"1.25"
aria-hidden=
"true"
></b-icon>
Home
</b-breadcrumb-item>
<b-breadcrumb-item
href=
"/
home/
categories"
>
Category
</b-breadcrumb-item>
<b-breadcrumb-item
href=
"/categories"
>
Category
</b-breadcrumb-item>
</b-breadcrumb>
<div
style=
"float: right"
>
<b-button
v-b-modal
.
modal-create
>
New Category
</b-button></div>
<b-button
v-b-modal
.
modal-create
class=
"text-white"
>
New Category
</b-button></div>
<!-- create modal -->
<b-modal
id=
"modal-create"
title=
"Create Category"
class=
"modal fade"
>
<p
class=
"my-4"
>
...
...
@@ -192,7 +192,7 @@
<
script
>
import
Nav
from
"
@/components/Nav
"
;
import
axios
from
"
axios
"
;
import
{
BootstrapVue
,
BootstrapVueIcons
}
from
'
bootstrap-vue
'
import
{
BootstrapVue
,
BootstrapVueIcons
}
from
'
bootstrap-vue
'
;
export
default
{
layout
:
'
admin
'
,
...
...
@@ -250,76 +250,76 @@ export default {
},
computed
:
{
formTitle
()
{
return
this
.
editedIndex
===
-
1
?
"
New Item
"
:
"
Edit Item
"
;
return
this
.
editedIndex
===
-
1
?
"
New Item
"
:
"
Edit Item
"
},
},
watch
:
{
dialog
(
val
)
{
val
||
this
.
close
()
;
val
||
this
.
close
()
},
dialogDelete
(
val
)
{
val
||
this
.
closeDelete
()
;
val
||
this
.
closeDelete
()
},
},
created
()
{
this
.
initialize
()
;
this
.
getCategories
()
;
this
.
initialize
()
this
.
getCategories
()
},
methods
:
{
initialize
()
{
this
.
users
=
[]
;
this
.
categories
=
[]
;
this
.
users
=
[]
this
.
categories
=
[]
},
editItem
(
item
)
{
this
.
editedIndex
=
this
.
categories
.
indexOf
(
item
)
;
this
.
editedItem
=
Object
.
assign
({},
item
)
;
this
.
dialog
=
true
;
this
.
editedIndex
=
this
.
categories
.
indexOf
(
item
)
this
.
editedItem
=
Object
.
assign
({},
item
)
this
.
dialog
=
true
},
deleteItem
(
item
)
{
this
.
editedIndex
=
this
.
categories
.
indexOf
(
item
)
;
this
.
editedItem
=
Object
.
assign
({},
item
)
;
this
.
dialogDelete
=
true
;
this
.
editedIndex
=
this
.
categories
.
indexOf
(
item
)
this
.
editedItem
=
Object
.
assign
({},
item
)
this
.
dialogDelete
=
true
},
deleteItemConfirm
()
{
this
.
categories
.
splice
(
this
.
editedIndex
,
1
)
;
this
.
closeDelete
()
;
this
.
categories
.
splice
(
this
.
editedIndex
,
1
)
this
.
closeDelete
()
},
close
()
{
this
.
dialog
=
false
;
this
.
dialog
=
false
this
.
$nextTick
(()
=>
{
this
.
editedItem
=
Object
.
assign
({},
this
.
defaultItem
)
;
this
.
editedIndex
=
-
1
;
})
;
this
.
editedItem
=
Object
.
assign
({},
this
.
defaultItem
)
this
.
editedIndex
=
-
1
})
},
closeDelete
()
{
this
.
dialogDelete
=
false
;
this
.
dialogDelete
=
false
this
.
$nextTick
(()
=>
{
this
.
editedItem
=
Object
.
assign
({},
this
.
defaultItem
)
;
this
.
editedIndex
=
-
1
;
})
;
this
.
editedItem
=
Object
.
assign
({},
this
.
defaultItem
)
this
.
editedIndex
=
-
1
})
},
save
()
{
if
(
this
.
editedIndex
>
-
1
)
{
Object
.
assign
(
this
.
categories
[
this
.
editedIndex
],
this
.
editedItem
)
;
Object
.
assign
(
this
.
categories
[
this
.
editedIndex
],
this
.
editedItem
)
}
else
{
this
.
categories
.
push
(
this
.
editedItem
)
;
this
.
categories
.
push
(
this
.
editedItem
)
}
this
.
close
()
;
this
.
close
()
},
getCategories
()
{
axios
.
get
(
"
http://127.0.0.1:8000/api
/categories/
"
)
this
.
$
axios
.
get
(
"
/categories/
"
)
.
then
((
response
)
=>
(
this
.
categories
=
response
.
data
.
data
))
.
catch
(
function
(
error
)
{
console
.
log
(
error
)
;
})
;
console
.
log
(
error
)
})
},
createCategory
()
{
const
set
=
new
Set
([
this
.
image
])
;
const
image
=
Array
.
from
(
set
)
;
const
self
=
this
;
axios
.
post
(
'
http://127.0.0.1:8000/api
/categories/
'
,{
const
set
=
new
Set
([
this
.
image
])
const
image
=
Array
.
from
(
set
)
const
self
=
this
this
.
$
axios
.
post
(
'
/categories/
'
,{
name
:
this
.
name
,
ordering
:
this
.
ordering
,
parent_id
:
this
.
parent_id
,
...
...
@@ -341,8 +341,8 @@ export default {
})
.
catch
(
errors
=>
{
this
.
$bvModal
.
hide
(
'
modal-create
'
)
console
.
log
(
errors
.
response
.
data
.
message
)
;
this
.
message
=
errors
.
response
.
data
.
message
;
console
.
log
(
errors
.
response
.
data
.
message
)
this
.
message
=
errors
.
response
.
data
.
message
self
.
$toast
.
error
(
'
something went wrong while trying create!
'
,{
duration
:
3000
})
...
...
@@ -350,24 +350,24 @@ export default {
},
fileSelected
(
event
){
console
.
log
(
event
)
const
file
=
event
.
target
.
files
[
0
]
;
this
.
url
=
URL
.
createObjectURL
(
file
)
;
const
file
=
event
.
target
.
files
[
0
]
this
.
url
=
URL
.
createObjectURL
(
file
)
this
.
image
=
file
;
console
.
log
(
file
)
console
.
log
(
this
.
image
)
},
deleteCategory
(
ID
,
index
)
{
const
self
=
this
this
.
editedIndex
=
this
.
categories
.
indexOf
(
index
)
;
this
.
editedIndex
=
this
.
categories
.
indexOf
(
index
)
if
(
confirm
(
"
Do you really want to delete?
"
)){
try
{
axios
.
delete
(
`
http://127.0.0.1:8000/api
/categories/
${
ID
}
`
)
this
.
$
axios
.
delete
(
`/categories/
${
ID
}
`
)
.
then
(
response
=>
{
this
.
categories
.
splice
(
this
.
editedIndex
,
1
);
self
.
$toast
.
success
(
'
Category deleted successfully!
'
,{
duration
:
3000
})
;
})
})
}
catch
(
error
){
console
.
log
(
error
)
...
...
@@ -378,26 +378,26 @@ export default {
console
.
log
(
this
.
categories
.
indexOf
(
item
))
},
editCategory
(
item
)
{
this
.
$bvModal
.
show
(
'
modal-edit
'
)
;
this
.
eID
=
item
.
id
;
this
.
eName
=
item
.
name
,
this
.
eOrdering
=
item
.
ordering
,
this
.
eParentId
=
item
.
parent_id
,
this
.
eImage
=
item
.
images
,
this
.
editedIndex
=
this
.
categories
.
indexOf
(
item
)
,
console
.
log
(
this
?.
eID
)
;
console
.
log
(
item
)
;
this
.
$bvModal
.
show
(
'
modal-edit
'
)
this
.
eID
=
item
.
id
this
.
eName
=
item
.
name
this
.
eOrdering
=
item
.
ordering
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
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
)
;
console
.
log
(
this
.
eName
)
console
.
log
(
this
.
eOrdering
)
console
.
log
(
this
?.
eID
)
try
{
axios
.
post
(
`
http://127.0.0.1:8000/api/
categories/update/
${
this
?.
eID
}
`,{
this
.
$
axios
.
post
(
`categories/update/
${
this
?.
eID
}
`,{
name: this.eName,
ordering: this.eOrdering,
parent_id: this.eParentId,
...
...
@@ -410,7 +410,7 @@ export default {
.then(response => {
self.$toast.success('User updated successfully!',{
duration: 3000
})
;
})
console.log(response)
this.editedItem = response.data.data
this.$bvModal.hide('modal-edit')
...
...
pages/posts/index.vue
View file @
81fc4c62
...
...
@@ -10,7 +10,7 @@
></b-icon>
Home
</b-breadcrumb-item>
<b-breadcrumb-item
href=
"/
home/
posts"
>
Post
</b-breadcrumb-item>
<b-breadcrumb-item
href=
"/posts"
>
Post
</b-breadcrumb-item>
</b-breadcrumb>
<div
style=
"float: right"
>
<b-button
class=
"text-white"
v-b-modal
.
modal-create
>
New Post
</b-button>
...
...
@@ -315,26 +315,26 @@ export default {
created_at
:
""
,
updated_at
:
""
,
},
}
;
}
},
computed
:
{
formTitle
()
{
return
this
.
editedIndex
===
-
1
?
"
New Item
"
:
"
Edit Item
"
;
return
this
.
editedIndex
===
-
1
?
"
New Item
"
:
"
Edit Item
"
},
nameState
()
{
return
this
.
name
.
length
>
2
?
true
:
false
;
return
this
.
name
.
length
>
2
?
true
:
false
},
},
watch
:
{
dialog
(
val
)
{
val
||
this
.
close
()
;
val
||
this
.
close
()
},
dialogDelete
(
val
)
{
val
||
this
.
closeDelete
()
;
val
||
this
.
closeDelete
()
},
},
created
()
{
this
.
initialize
(),
this
.
getposts
(),
this
.
getCategories
()
;
this
.
initialize
(),
this
.
getposts
(),
this
.
getCategories
()
},
methods
:
{
initialize
()
{
...
...
@@ -349,62 +349,61 @@ export default {
this
.
sImages
=
null
},
editItem
(
item
)
{
this
.
editedIndex
=
this
.
posts
.
indexOf
(
item
)
;
this
.
editedItem
=
Object
.
assign
({},
item
)
;
this
.
dialog
=
true
;
this
.
editedIndex
=
this
.
posts
.
indexOf
(
item
)
this
.
editedItem
=
Object
.
assign
({},
item
)
this
.
dialog
=
true
},
deleteItem
(
item
)
{
this
.
editedIndex
=
this
.
posts
.
indexOf
(
item
)
;
this
.
editedItem
=
Object
.
assign
({},
item
)
;
this
.
dialogDelete
=
true
;
this
.
editedIndex
=
this
.
posts
.
indexOf
(
item
)
this
.
editedItem
=
Object
.
assign
({},
item
)
this
.
dialogDelete
=
true
},
deleteItemConfirm
()
{
this
.
posts
.
splice
(
this
.
editedIndex
,
1
)
;
this
.
closeDelete
()
;
this
.
posts
.
splice
(
this
.
editedIndex
,
1
)
this
.
closeDelete
()
},
close
()
{
this
.
dialog
=
false
;
this
.
dialog
=
false
this
.
$nextTick
(()
=>
{
this
.
editedItem
=
Object
.
assign
({},
this
.
defaultItem
)
;
this
.
editedIndex
=
-
1
;
})
;
this
.
editedItem
=
Object
.
assign
({},
this
.
defaultItem
)
this
.
editedIndex
=
-
1
})
},
closeDelete
()
{
this
.
dialogDelete
=
false
;
this
.
dialogDelete
=
false
this
.
$nextTick
(()
=>
{
this
.
editedItem
=
Object
.
assign
({},
this
.
defaultItem
)
;
this
.
editedIndex
=
-
1
;
})
;
this
.
editedItem
=
Object
.
assign
({},
this
.
defaultItem
)
this
.
editedIndex
=
-
1
})
},
save
()
{
if
(
this
.
editedIndex
>
-
1
)
{
Object
.
assign
(
this
.
posts
[
this
.
editedIndex
],
this
.
editedItem
)
;
Object
.
assign
(
this
.
posts
[
this
.
editedIndex
],
this
.
editedItem
)
}
else
{
this
.
posts
.
push
(
this
.
editedItem
)
;
this
.
posts
.
push
(
this
.
editedItem
)
}
this
.
close
()
;
this
.
close
()
},
getCategories
()
{
axios
.
get
(
"
http://127.0.0.1:8000/api
/categories/
"
)
this
.
$
axios
.
get
(
"
/categories/
"
)
.
then
((
response
)
=>
(
this
.
categories
=
response
.
data
.
data
))
.
catch
(
function
(
error
)
{
console
.
log
(
error
)
;
})
;
console
.
log
(
error
)
})
},
getposts
()
{
axios
.
get
(
"
http://127.0.0.1:8000/api
/posts/
"
)
this
.
$
axios
.
get
(
"
/posts/
"
)
.
then
((
response
)
=>
(
this
.
posts
=
response
.
data
.
data
))
.
catch
(
function
(
error
)
{
console
.
log
(
error
)
;
})
;
console
.
log
(
error
)
})
},
createPost
()
{
const
self
=
this
;
axios
.
post
(
"
http://127.0.0.1:8000/api/posts/
"
,
const
self
=
this
this
.
$axios
.
post
(
"
/posts/
"
,
{
title
:
this
.
title
,
category_id
:
this
.
category_id
,
...
...
@@ -421,7 +420,7 @@ export default {
}
)
.
then
((
response
)
=>
{
this
.
$bvModal
.
hide
(
"
modal-create
"
)
;
this
.
$bvModal
.
hide
(
"
modal-create
"
)
self
.
$toast
.
success
(
"
Post created successfully!
"
,
{
duration
:
3000
,
})
...
...
@@ -430,36 +429,36 @@ export default {
this
.
posts
.
push
(
this
.
editedItem
)
})
.
catch
((
errors
)
=>
{
this
.
$bvModal
.
hide
(
"
modal-create
"
)
;
console
.
log
(
errors
.
response
.
data
.
message
)
;
this
.
message
=
errors
.
response
.
data
.
message
;
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!
"
,
{
duration
:
3000
,
})
;
})
;
})
})
},
deletePost
(
ID
,
index
)
{
const
self
=
this
;
this
.
editedIndex
=
this
.
posts
.
indexOf
(
index
)
;
const
self
=
this
this
.
editedIndex
=
this
.
posts
.
indexOf
(
index
)
if
(
confirm
(
"
Do you really want to delete?
"
))
{
axios
.
delete
(
`
http://127.0.0.1:8000/api
/posts/
${
ID
}
`
)
this
.
$
axios
.
delete
(
`/posts/
${
ID
}
`
)
.
then
((
response
)
=>
{
this
.
posts
.
splice
(
this
.
editedIndex
,
1
)
;
this
.
posts
.
splice
(
this
.
editedIndex
,
1
)
self
.
$toast
.
success
(
"
Post deleted successfully!
"
,
{
duration
:
3000
,
})
;
})
})
.
catch
((
error
)
=>
{
console
.
log
(
error
)
;
console
.
log
(
error
)
self
.
$toast
.
error
(
"
Error!
"
,
{
duration
:
3000
,
})
;
})
;
})
})
}
},
async
showPost
(
item
)
{
const
ID
=
item
.
id
;
const
ID
=
item
.
id
try
{
const
resp
=
await
fetch
(
`http://127.0.0.1:8000/api/posts/
${
ID
}
`
,
{
method
:
"
GET
"
,
...
...
@@ -468,34 +467,34 @@ export default {
Authorization
:
this
.
$auth
.
$storage
.
getUniversal
(
"
token
"
),
},
}).
then
((
response
)
=>
{
return
response
.
json
()
;
})
;
this
.
sTitle
=
resp
.
data
.
title
;
this
.
sContent
=
resp
.
data
.
content
;
this
.
sCategoryId
=
resp
.
data
.
category_id
;
this
.
sUserId
=
resp
.
data
.
user_id
;
this
.
sStatus
=
resp
.
data
.
status
;
this
.
sImages
=
resp
.
data
.
images
;
return
response
.
json
()
})
this
.
sTitle
=
resp
.
data
.
title
this
.
sContent
=
resp
.
data
.
content
this
.
sCategoryId
=
resp
.
data
.
category_id
this
.
sUserId
=
resp
.
data
.
user_id
this
.
sStatus
=
resp
.
data
.
status
this
.
sImages
=
resp
.
data
.
images
}
catch
(
error
)
{
console
.
log
(
error
)
;
console
.
log
(
error
)
}
this
.
$bvModal
.
show
(
"
modal-show
"
)
;
this
.
$bvModal
.
show
(
"
modal-show
"
)
},
editPost
(
item
)
{
this
.
$bvModal
.
show
(
"
modal-edit
"
)
;
this
.
eId
=
item
.
id
;
this
.
eTitle
=
item
.
title
;
this
.
eCategoryId
=
item
.
category_id
;
this
.
eContent
=
item
.
content
;
this
.
eStatus
=
item
.
status
;
this
.
eUserId
=
item
.
user_id
;
this
.
$bvModal
.
show
(
"
modal-edit
"
)
this
.
eId
=
item
.
id
this
.
eTitle
=
item
.
title
this
.
eCategoryId
=
item
.
category_id
this
.
eContent
=
item
.
content
this
.
eStatus
=
item
.
status
this
.
eUserId
=
item
.
user_id
this
.
editedIndex
=
this
.
posts
.
indexOf
(
item
)
},
updatePost
()
{
const
self
=
this
;
const
self
=
this
axios
.
post
(
`
http://127.0.0.1:8000/api
/posts/update/
${
this
?.
eId
}
`,
`/posts/update/
${
this
?.
eId
}
`,
{
title: this.eTitle,
category_id: this.eCategoryId,
...
...
@@ -512,25 +511,26 @@ export default {
}
)
.then((response) => {
this.$bvModal.hide("modal-edit")
;
this.$bvModal.hide("modal-edit")
self.$toast.success("Post updated successfully!", {
duration: 3000,
})
;
})
console.log(response)
this.editedItem = response.data.data
this.$bvModal.hide('modal-edit')
Object.assign(this.posts[this.editedIndex], this.editedItem)
})
.catch((error) => {
console.log(error)
;
this.$bvModal.hide("modal-edit")
;
console.log(error)
this.$bvModal.hide("modal-edit")
self.$toast.error("something went wrong while trying create!", {
duration: 3000,
})
;
})
;
})
})
},
},
};
</
script
>
<
style
></
style
>
<
style
>
</
style
>
pages/products/index.vue
View file @
81fc4c62
...
...
@@ -5,7 +5,7 @@
<b-icon
icon=
"house-fill"
scale=
"1.25"
shift-v=
"1.25"
aria-hidden=
"true"
></b-icon>
Home
</b-breadcrumb-item>
<b-breadcrumb-item
href=
"/
home/
products"
>
Product
</b-breadcrumb-item>
<b-breadcrumb-item
href=
"/products"
>
Product
</b-breadcrumb-item>
</b-breadcrumb>
<div
style=
"float: right"
>
<b-button
class=
"text-white"
v-b-modal
.
modal-create
>
New Product
</b-button></div>
...
...
@@ -447,7 +447,7 @@ export default {
quantity
:
""
,
},
]
;
]
},
editItem
(
item
)
{
this
.
editedIndex
=
this
.
products
.
indexOf
(
item
)
...
...
@@ -455,12 +455,12 @@ export default {
this
.
dialog
=
true
},
deleteItem
(
item
)
{
this
.
editedIndex
=
this
.
products
.
indexOf
(
item
)
;
this
.
editedItem
=
Object
.
assign
({},
item
)
;
this
.
dialogDelete
=
true
;
this
.
editedIndex
=
this
.
products
.
indexOf
(
item
)
this
.
editedItem
=
Object
.
assign
({},
item
)
this
.
dialogDelete
=
true
},
deleteItemConfirm
()
{
this
.
products
.
splice
(
this
.
editedIndex
,
1
)
;
this
.
products
.
splice
(
this
.
editedIndex
,
1
)
this
.
closeDelete
()
},
close
()
{
...
...
@@ -468,45 +468,45 @@ export default {
this
.
$nextTick
(()
=>
{
this
.
editedItem
=
Object
.
assign
({},
this
.
defaultItem
)
this
.
editedIndex
=
-
1
})
;
})
},
closeDelete
()
{
this
.
dialogDelete
=
false
this
.
$nextTick
(()
=>
{
this
.
editedItem
=
Object
.
assign
({},
this
.
defaultItem
)
;
this
.
editedItem
=
Object
.
assign
({},
this
.
defaultItem
)
this
.
editedIndex
=
-
1
})
;
})
},
save
()
{
if
(
this
.
editedIndex
>
-
1
)
{
Object
.
assign
(
this
.
products
[
this
.
editedIndex
],
this
.
editedItem
)
;
Object
.
assign
(
this
.
products
[
this
.
editedIndex
],
this
.
editedItem
)
}
else
{
this
.
products
.
push
(
this
.
editedItem
)
;
this
.
products
.
push
(
this
.
editedItem
)
}
this
.
close
()
},
getCategories
()
{
axios
.
get
(
"
http://127.0.0.1:8000/api
/categories/
"
)
this
.
$
axios
.
get
(
"
/categories/
"
)
.
then
((
response
)
=>
(
this
.
categories
=
response
.
data
.
data
))
.
catch
(
function
(
error
)
{
console
.
log
(
error
)
})
;
})
},
getProducts
()
{
axios
.
get
(
"
http://127.0.0.1:8000/api
/products/
"
)
this
.
$
axios
.
get
(
"
/products/
"
)
.
then
((
response
)
=>
(
this
.
products
=
response
.
data
.
data
))
.
catch
(
function
(
error
)
{
console
.
log
(
error
)
})
;
})
},
createProduct
()
{
const
self
=
this
;
const
self
=
this
// const set = new Set([this.images]);
// const images = Array.from(set);
axios
.
post
(
'
http://127.0.0.1:8000/api
/products/
'
,{
this
.
$
axios
.
post
(
'
/products/
'
,{
name
:
this
.
name
,
price
:
this
.
price
,
category_id
:
this
.
category_id
,
...
...
@@ -531,25 +531,25 @@ export default {
.
catch
(
errors
=>
{
this
.
$bvModal
.
hide
(
'
modal-create
'
)
console
.
log
(
errors
.
response
.
data
.
message
)
this
.
message
=
errors
.
response
.
data
.
message
;
this
.
message
=
errors
.
response
.
data
.
message
self
.
$toast
.
error
(
'
something went wrong while trying create!
'
,{
duration
:
3000
})
})
},
deleteProduct
(
ID
,
index
)
{
const
self
=
this
;
this
.
editedIndex
=
this
.
products
.
indexOf
(
index
)
;
const
self
=
this
this
.
editedIndex
=
this
.
products
.
indexOf
(
index
)
if
(
confirm
(
"
Do you really want to delete?
"
)){
try
{
axios
.
delete
(
`http://127.0.0.1:8000/api
/products/
${
ID
}
`
)
.
then
(
response
=>
{
this
.
products
.
splice
(
this
.
editedIndex
,
1
);
self
.
$toast
.
success
(
'
Category deleted successfully!
'
,{
duration
:
3000
});
})
this
.
$
axios
.
delete
(
`
/products/
${
ID
}
`
)
.
then
(
response
=>
{
this
.
products
.
splice
(
this
.
editedIndex
,
1
)
self
.
$toast
.
success
(
'
Category deleted successfully!
'
,{
duration
:
3000
})
})
}
catch
(
error
){
console
.
log
(
error
)
}
...
...
@@ -566,7 +566,7 @@ export default {
}
}).
then
((
response
)
=>
{
return
response
.
json
()
})
;
})
this
.
sName
=
resp
.
data
.
name
this
.
sPrice
=
resp
.
data
.
price
this
.
sCategoryId
=
resp
.
data
.
category_id
...
...
@@ -595,15 +595,15 @@ export default {
updateProduct
(
ID
)
{
const
self
=
this
try
{
axios
.
post
(
`http://127.0.0.1:8000/api
/products/update/
${
this
?.
eId
}
`,{
name: this.eName,
price: this.ePrice,
category_id: this.eCategoryId,
description: this.eDescription,
images: this.eImages,
variants: this.eVariants,
}, {
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": this.$auth.$storage.getUniversal("token")
...
...
@@ -612,7 +612,7 @@ export default {
.then(response => {
self.$toast.success('User updated successfully!',{
duration: 3000
})
;
})
console.log(response)
this.editedItem = response.data.data
this.$bvModal.hide('modal-edit')
...
...
@@ -627,14 +627,14 @@ export default {
color: "",
size: "",
quantity: "",
})
;
})
},
addMoreVariant() {
this.eVariants.push({
color: "",
size: "",
quantity: "",
})
;
})
},
remove(index) {
this.variants.splice(index, 1)
...
...
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