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
bbfba7ba
Commit
bbfba7ba
authored
Feb 01, 2023
by
Kemm23
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix UI Category
parent
fd18168c
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
561 additions
and
470 deletions
+561
-470
index.vue
pages/categories/index.vue
+1
-7
index.vue
pages/posts/index.vue
+177
-107
index.vue
pages/products/index.vue
+383
-356
No files found.
pages/categories/index.vue
View file @
bbfba7ba
...
...
@@ -107,13 +107,6 @@
<v-card-text>
<v-container>
<v-row>
<v-col
cols=
"12"
>
<v-text-field
v-model=
"eID"
label=
"ID"
required
/>
</v-col>
<v-col
cols=
"12"
>
<v-text-field
v-model=
"eName"
...
...
@@ -125,6 +118,7 @@
<v-text-field
v-model=
"eOrdering"
label=
"Ordering"
type=
"number"
required
/>
</v-col>
...
...
pages/posts/index.vue
View file @
bbfba7ba
<!-- eslint-disable vue/valid-v-slot -->
<!-- eslint-disable no-sequences -->
<!-- eslint-disable no-unused-expressions -->
<!-- eslint-disable no-unused-expressions -->
<!-- eslint-disable vue/require-v-for-key -->
<
template
>
<div>
<b-breadcrumb>
<b-breadcrumb-item
href=
"/home"
>
<b-icon
icon=
"house-fill"
scale=
"1.25"
shift-v=
"1.25"
aria-hidden=
"true"
></b-icon
>
<b-icon
icon=
"house-fill"
scale=
"1.25"
shift-v=
"1.25"
aria-hidden=
"true"
/
>
Home
</b-breadcrumb-item>
<b-breadcrumb-item
href=
"/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>
<b-button
v-b-modal
.
modal-create
class=
"text-white"
>
New Post
</b-button>
</div>
<b-modal
id=
"modal-create"
title=
"create Post"
class=
"modal fade"
>
<div
class=
"w-full mt-4 p-10"
>
<form>
<label
for=
"input-live"
>
Title :
</label>
<b-form-input
id=
"input-live"
type=
"text"
class=
"form-control mb-2"
placeholder=
"name"
aria-describedby=
"input-live-help input-live-feedback"
v-model=
"title"
max=
"255"
min=
"1"
trim
>
</b-form-input>
<b-form-input
id=
"input-live"
v-model=
"title"
type=
"text"
class=
"form-control mb-2"
placeholder=
"name"
aria-describedby=
"input-live-help input-live-feedback"
max=
"255"
min=
"1"
trim
/>
<label>
Category ID :
</label>
<b-form-select
v-model=
"category_id"
>
<option
v-for=
"item in categories"
:value=
"item.id"
>
...
...
@@ -24,21 +41,40 @@
</option>
</b-form-select>
<label>
Content :
</label>
<input
type=
"text"
class=
"form-control mb-2"
placeholder=
"Ordering"
v-model=
"content"
size=
"sm"
required
/>
<input
v-model=
"content"
type=
"text"
class=
"form-control mb-2"
placeholder=
"Ordering"
size=
"sm"
required
>
<label>
Author :
</label>
<input
type=
"text"
class=
"form-control mb-2"
placeholder=
"Description"
v-model=
"user_id"
size=
"sm"
required
/>
<input
v-model=
"user_id"
type=
"text"
class=
"form-control mb-2"
placeholder=
"Description"
size=
"sm"
required
>
<label>
Status :
</label>
<b-form-select
v-model=
"status"
:options=
"options"
></b-form-select
>
<b-form-select
v-model=
"status"
:options=
"options"
/
>
<label>
Image :
</label>
<b-form-file
v-model=
"images"
multiple
:state=
"Boolean(images)"
placeholder=
"Choose a image or drop it here..."
drop-placeholder=
"Drop file here..."
></b-form-file>
<b-form-file
v-model=
"images"
multiple
:state=
"Boolean(images)"
placeholder=
"Choose a image or drop it here..."
drop-placeholder=
"Drop file here..."
/>
</form>
</div>
<template
#modal-footer
>
<button
v-b-modal
.
modal-close_visit
@
click=
"$bvModal.hide('modal-create')"
class=
"btn btn-danger btn-sm m-1
"
>
<button
v-b-modal
.
modal-close_visit
class=
"btn btn-danger btn-sm m-1"
@
click=
"$bvModal.hide('modal-create')
"
>
Close
</button>
<button
@
click=
"createPost()"
v-b-modal
.
modal-close_visit
class=
"btn btn-success btn-sm m-1
"
>
<button
v-b-modal
.
modal-close_visit
class=
"btn btn-success btn-sm m-1"
@
click=
"createPost()
"
>
Submit
</button>
</
template
>
...
...
@@ -48,23 +84,30 @@
<div
class=
"w-full mt-4 p-10"
>
<form>
<label>
Title :
</label>
<input
type=
"text"
class=
"form-control mb-2"
v-model=
"sTitle"
size=
"sm"
disabled
/
>
<input
v-model=
"sTitle"
type=
"text"
class=
"form-control mb-2"
size=
"sm"
disabled
>
<label>
Category ID :
</label>
<input
type=
"text"
class=
"form-control mb-2"
v-model=
"sCategoryId"
size=
"sm"
disabled
/
>
<input
v-model=
"sCategoryId"
type=
"text"
class=
"form-control mb-2"
size=
"sm"
disabled
>
<label>
Content :
</label>
<input
type=
"text"
class=
"form-control mb-2"
v-model=
"sContent"
size=
"sm"
disabled
/
>
<input
v-model=
"sContent"
type=
"text"
class=
"form-control mb-2"
size=
"sm"
disabled
>
<label>
Author :
</label>
<input
type=
"text"
class=
"form-control mb-2"
placeholder=
"Description"
v-model=
"sUserId"
size=
"sm"
disabled
/>
<input
v-model=
"sUserId"
type=
"text"
class=
"form-control mb-2"
placeholder=
"Description"
size=
"sm"
disabled
>
<label>
Status :
</label>
<b-form-select
v-model=
"sStatus"
:options=
"options"
disabled
></b-form-select
>
<b-form-select
v-model=
"sStatus"
:options=
"options"
disabled
/
>
<label>
Image :
</label>
<div
v-for=
"(image, index) in sImages"
:key=
"index"
>
<b-img
:src=
"image"
fluid
alt=
"Fluid image"
></b-img
>
<b-img
:src=
"image"
fluid
alt=
"Fluid image"
/
>
</div>
</form>
</div>
<
template
#modal-footer
>
<button
v-b-modal
.
modal-close_visit
@
click=
"$bvModal.hide('modal-show')"
class=
"btn btn-danger btn-sm m-1
"
>
<button
v-b-modal
.
modal-close_visit
class=
"btn btn-danger btn-sm m-1"
@
click=
"$bvModal.hide('modal-show')
"
>
Close
</button>
</
template
>
...
...
@@ -74,8 +117,16 @@
<div
class=
"w-full mt-4 p-10"
>
<form>
<label>
Title :
</label>
<input
type=
"text"
class=
"form-control mb-2"
placeholder=
"name"
v-model=
"eTitle"
max=
"255"
min=
"1"
size=
"sm"
required
/>
<input
v-model=
"eTitle"
type=
"text"
class=
"form-control mb-2"
placeholder=
"name"
max=
"255"
min=
"1"
size=
"sm"
required
>
<label>
Category ID :
</label>
<b-form-select
v-model=
"eCategoryId"
>
<option
v-for=
"item in categories"
:value=
"item.id"
>
...
...
@@ -83,21 +134,33 @@
</option>
</b-form-select>
<label>
Content :
</label>
<input
type=
"text"
class=
"form-control mb-2"
placeholder=
"Ordering"
v-model=
"eContent"
size=
"sm"
required
/>
<input
v-model=
"eContent"
type=
"text"
class=
"form-control mb-2"
placeholder=
"Ordering"
size=
"sm"
required
>
<label>
Author :
</label>
<input
type=
"text"
class=
"form-control mb-2"
placeholder=
"Description"
v-model=
"eUserId"
size=
"sm"
/
>
<input
v-model=
"eUserId"
type=
"text"
class=
"form-control mb-2"
placeholder=
"Description"
size=
"sm"
>
<label>
Status :
</label>
<b-form-select
v-model=
"eStatus"
:options=
"options"
></b-form-select
>
<b-form-select
v-model=
"eStatus"
:options=
"options"
/
>
<label>
Image :
</label>
<b-form-file
v-model=
"eImages"
multiple
:state=
"Boolean(eImages)"
placeholder=
"Choose a image or drop it here..."
drop-placeholder=
"Drop file here..."
></b-form-file>
<b-form-file
v-model=
"eImages"
multiple
:state=
"Boolean(eImages)"
placeholder=
"Choose a image or drop it here..."
drop-placeholder=
"Drop file here..."
/>
</form>
</div>
<
template
#modal-footer
>
<button
v-b-modal
.
modal-close_visit
@
click=
"$bvModal.hide('modal-edit')"
class=
"btn btn-danger btn-sm m-1
"
>
<button
v-b-modal
.
modal-close_visit
class=
"btn btn-danger btn-sm m-1"
@
click=
"$bvModal.hide('modal-edit')
"
>
Close
</button>
<button
@
click=
"updatePost()"
v-b-modal
.
modal-close_visit
class=
"btn btn-success btn-sm m-1
"
>
<button
v-b-modal
.
modal-close_visit
class=
"btn btn-success btn-sm m-1"
@
click=
"updatePost()
"
>
Submit
</button>
</
template
>
...
...
@@ -105,26 +168,28 @@
<!-- table -->
<div>
<v-data-table
:headers=
"headers"
:items=
"posts"
sort-by=
"calories"
class=
"elevation-1"
>
<
template
v-slot:
top
>
<
template
#
top
>
<v-toolbar
flat
>
<v-toolbar-title>
Post Manage
</v-toolbar-title>
<v-divider
class=
"mx-4"
inset
vertical
></v-divider
>
<v-spacer
></v-spacer
>
<v-divider
class=
"mx-4"
inset
vertical
/
>
<v-spacer
/
>
</v-toolbar>
</
template
>
<
template
v-slot:
item.actions=
"{ item }"
>
<v-icon
small
@
click=
"editPost(item)"
:id=
"item.id
"
>
<
template
#
item.actions=
"{ item }"
>
<v-icon
:id=
"item.id"
small
@
click=
"editPost(item)
"
>
mdi-pencil
</v-icon>
<v-icon
small
@
click=
"deletePost(item.id, item)"
:id=
"item.id
"
>
<v-icon
:id=
"item.id"
small
@
click=
"deletePost(item.id, item)
"
>
mdi-delete
</v-icon>
<v-icon
small
@
click=
"showPost(item)"
:id=
"item.id
"
>
<v-icon
:id=
"item.id"
small
@
click=
"showPost(item)
"
>
mdi-account-details
</v-icon>
</
template
>
<
template
v-slot:no-data
>
<v-btn
color=
"primary"
@
click=
"initialize"
>
Reset
</v-btn>
<
template
#no-data
>
<v-btn
color=
"primary"
@
click=
"initialize"
>
Reset
</v-btn>
</
template
>
</v-data-table>
</div>
...
...
@@ -134,8 +199,8 @@
<
script
>
export
default
{
layout
:
'
admin
'
,
name
:
'
App
'
,
layout
:
'
admin
'
,
middleware
:
[
'
web
'
],
data
:
()
=>
{
return
{
...
...
@@ -150,20 +215,20 @@ export default {
options
:
[
{
value
:
1
,
text
:
'
Draft
'
},
{
value
:
2
,
text
:
'
Publish
'
},
{
value
:
3
,
text
:
'
UnPublish
'
}
,
{
value
:
3
,
text
:
'
UnPublish
'
}
],
headers
:
[
{
text
:
'
Title
'
,
align
:
'
start
'
,
sortable
:
false
,
value
:
'
title
'
,
value
:
'
title
'
},
{
text
:
'
Category ID
'
,
value
:
'
category_id
'
},
{
text
:
'
content
'
,
value
:
'
content
'
,
sortable
:
false
},
{
text
:
'
author
'
,
value
:
'
user_id
'
},
{
text
:
'
status
'
,
value
:
'
status
'
},
{
text
:
'
Actions
'
,
value
:
'
actions
'
,
sortable
:
false
}
,
{
text
:
'
Actions
'
,
value
:
'
actions
'
,
sortable
:
false
}
],
posts
:
[],
categories
:
[],
...
...
@@ -187,7 +252,7 @@ export default {
category_id
:
''
,
content
:
''
,
user_id
:
''
,
status
:
''
,
status
:
''
},
defaultItem
:
{
name
:
''
,
...
...
@@ -195,70 +260,72 @@ export default {
ordering
:
''
,
status
:
''
,
created_at
:
''
,
updated_at
:
''
,
}
,
updated_at
:
''
}
}
},
computed
:
{
formTitle
()
{
formTitle
()
{
return
this
.
editedIndex
===
-
1
?
'
New Item
'
:
'
Edit Item
'
},
nameState
()
{
return
this
.
name
.
length
>
2
?
true
:
false
}
,
nameState
()
{
return
this
.
name
.
length
>
2
}
},
watch
:
{
dialog
(
val
)
{
dialog
(
val
)
{
val
||
this
.
close
()
},
dialogDelete
(
val
)
{
dialogDelete
(
val
)
{
val
||
this
.
closeDelete
()
}
},
},
created
()
{
this
.
initialize
(),
this
.
getposts
(),
this
.
getCategories
()
created
()
{
this
.
initialize
()
this
.
getposts
()
this
.
getCategories
()
},
methods
:
{
initialize
()
{
this
.
posts
=
[]
,
this
.
product
=
[],
this
.
categories
=
[],
this
.
sTitle
=
''
,
this
.
sCategoryId
=
''
,
this
.
sContent
=
''
,
this
.
sUserId
=
''
,
this
.
sStatus
=
''
,
initialize
()
{
this
.
posts
=
[]
this
.
product
=
[]
this
.
categories
=
[]
this
.
sTitle
=
''
this
.
sCategoryId
=
''
this
.
sContent
=
''
this
.
sUserId
=
''
this
.
sStatus
=
''
this
.
sImages
=
null
},
editItem
(
item
)
{
editItem
(
item
)
{
this
.
editedIndex
=
this
.
posts
.
indexOf
(
item
)
this
.
editedItem
=
Object
.
assign
({},
item
)
this
.
dialog
=
true
},
deleteItem
(
item
)
{
deleteItem
(
item
)
{
this
.
editedIndex
=
this
.
posts
.
indexOf
(
item
)
this
.
editedItem
=
Object
.
assign
({},
item
)
this
.
dialogDelete
=
true
},
deleteItemConfirm
()
{
deleteItemConfirm
()
{
this
.
posts
.
splice
(
this
.
editedIndex
,
1
)
this
.
closeDelete
()
},
close
()
{
close
()
{
this
.
dialog
=
false
this
.
$nextTick
(()
=>
{
this
.
editedItem
=
Object
.
assign
({},
this
.
defaultItem
)
this
.
editedIndex
=
-
1
})
},
closeDelete
()
{
closeDelete
()
{
this
.
dialogDelete
=
false
this
.
$nextTick
(()
=>
{
this
.
editedItem
=
Object
.
assign
({},
this
.
defaultItem
)
this
.
editedIndex
=
-
1
})
},
save
()
{
save
()
{
if
(
this
.
editedIndex
>
-
1
)
{
Object
.
assign
(
this
.
posts
[
this
.
editedIndex
],
this
.
editedItem
)
}
else
{
...
...
@@ -266,31 +333,33 @@ export default {
}
this
.
close
()
},
getCategories
()
{
getCategories
()
{
this
.
$axios
.
get
(
"
/categories/
"
,
{
.
get
(
'
/categories/
'
,
{
headers
:
{
'
Content-Type
'
:
'
application/json
'
,
Authorization
:
`Bearer
${
this
.
$auth
.
$storage
.
getUniversal
(
"
token
"
)}
`
,
}})
.
then
((
response
)
=>
(
this
.
categories
=
response
.
data
.
data
))
Authorization
:
`Bearer
${
this
.
$auth
.
$storage
.
getUniversal
(
'
token
'
)}
`
}
})
.
then
(
response
=>
(
this
.
categories
=
response
.
data
.
data
))
.
catch
(
function
(
error
)
{
console
.
log
(
error
)
})
},
getposts
()
{
getposts
()
{
this
.
$axios
.
get
(
"
/posts/
"
,
{
.
get
(
'
/posts/
'
,
{
headers
:
{
'
Content-Type
'
:
'
application/json
'
,
Authorization
:
`Bearer
${
this
.
$auth
.
$storage
.
getUniversal
(
"
token
"
)}
`
,
}})
.
then
((
response
)
=>
(
this
.
posts
=
response
.
data
.
data
))
Authorization
:
`Bearer
${
this
.
$auth
.
$storage
.
getUniversal
(
'
token
'
)}
`
}
})
.
then
(
response
=>
(
this
.
posts
=
response
.
data
.
data
))
.
catch
(
function
(
error
)
{
console
.
log
(
error
)
})
},
createPost
()
{
createPost
()
{
const
self
=
this
this
.
$axios
.
post
(
'
/posts/
'
,
...
...
@@ -300,19 +369,19 @@ export default {
content
:
this
.
content
,
images
:
this
.
images
,
user_id
:
this
.
user_id
,
status
:
this
.
status
,
status
:
this
.
status
},
{
headers
:
{
"
Content-Type
"
:
"
multipart/form-data
"
,
Authorization
:
`Bearer
${
this
.
$auth
.
$storage
.
getUniversal
(
"
token
"
)}
`
,
}
,
'
Content-Type
'
:
'
multipart/form-data
'
,
Authorization
:
`Bearer
${
this
.
$auth
.
$storage
.
getUniversal
(
'
token
'
)}
`
}
}
)
.
then
((
response
)
=>
{
this
.
$bvModal
.
hide
(
'
modal-create
'
)
self
.
$toast
.
success
(
'
Post created successfully!
'
,
{
duration
:
3000
,
duration
:
3000
})
this
.
editedItem
=
response
.
data
.
data
console
.
log
(
this
.
editedItem
)
...
...
@@ -323,43 +392,44 @@ export default {
console
.
log
(
errors
.
response
.
data
.
message
)
this
.
message
=
errors
.
response
.
data
.
message
self
.
$toast
.
error
(
'
something went wrong while trying create!
'
,
{
duration
:
3000
,
duration
:
3000
})
})
},
deletePost
(
ID
,
index
)
{
deletePost
(
ID
,
index
)
{
const
self
=
this
this
.
editedIndex
=
this
.
posts
.
indexOf
(
index
)
if
(
confirm
(
'
Do you really want to delete?
'
))
{
this
.
$axios
.
delete
(
`/posts/
${
ID
}
`
,{
.
delete
(
`/posts/
${
ID
}
`
,
{
headers
:
{
'
Content-Type
'
:
'
application/json
'
,
Authorization
:
`Bearer
${
this
.
$auth
.
$storage
.
getUniversal
(
"
token
"
)}
`
,
}})
Authorization
:
`Bearer
${
this
.
$auth
.
$storage
.
getUniversal
(
'
token
'
)}
`
}
})
.
then
((
response
)
=>
{
this
.
posts
.
splice
(
this
.
editedIndex
,
1
)
self
.
$toast
.
success
(
'
Post deleted successfully!
'
,
{
duration
:
3000
,
duration
:
3000
})
})
.
catch
((
error
)
=>
{
console
.
log
(
error
)
self
.
$toast
.
error
(
'
Error!
'
,
{
duration
:
3000
,
duration
:
3000
})
})
}
},
async
showPost
(
item
)
{
async
showPost
(
item
)
{
const
ID
=
item
.
id
try
{
const
resp
=
await
this
.
$axios
.
get
(
`/posts/
${
ID
}
`
,
{
method
:
'
GET
'
,
headers
:
{
"
Content-Type
"
:
"
multipart/form-data
"
,
Authorization
:
`Bearer
${
this
.
$auth
.
$storage
.
getUniversal
(
"
token
"
)}
`
,
}
,
'
Content-Type
'
:
'
multipart/form-data
'
,
Authorization
:
`Bearer
${
this
.
$auth
.
$storage
.
getUniversal
(
'
token
'
)}
`
}
})
console
.
log
(
resp
.
data
)
this
.
sTitle
=
resp
.
data
.
data
.
title
...
...
@@ -373,7 +443,7 @@ export default {
}
this
.
$bvModal
.
show
(
'
modal-show
'
)
},
editPost
(
item
)
{
editPost
(
item
)
{
this
.
$bvModal
.
show
(
'
modal-edit
'
)
this
.
eId
=
item
.
id
this
.
eTitle
=
item
.
title
...
...
@@ -383,7 +453,7 @@ export default {
this
.
eUserId
=
item
.
user_id
this
.
editedIndex
=
this
.
posts
.
indexOf
(
item
)
},
updatePost
()
{
updatePost
()
{
const
self
=
this
this
.
$axios
.
post
(
...
...
@@ -394,19 +464,19 @@ export default {
content: this.eContent,
images: this.eImages,
user_id: this.eUserId,
status: this.eStatus
,
status: this.eStatus
},
{
headers: {
"Content-Type": "multipart/form-data"
,
Authorization: `
Bearer
$
{
this
.
$auth
.
$storage
.
getUniversal
(
"
token
"
)}
`,
}
,
'Content-Type': 'multipart/form-data'
,
Authorization: `
Bearer
$
{
this
.
$auth
.
$storage
.
getUniversal
(
'
token
'
)}
`
}
}
)
.then((response) => {
this.$bvModal.hide('modal-edit')
self.$toast.success('Post updated successfully!', {
duration: 3000
,
duration: 3000
})
console.log(response)
this.editedItem = response.data.data
...
...
@@ -417,11 +487,11 @@ export default {
console.log(error)
this.$bvModal.hide('modal-edit')
self.$toast.error('something went wrong while trying create!', {
duration: 3000
,
duration: 3000
})
})
}
,
}
,
}
}
}
</
script
>
...
...
pages/products/index.vue
View file @
bbfba7ba
<!-- eslint-disable vue/require-v-for-key -->
<!-- eslint-disable vue/valid-v-slot -->
<
template
>
<div>
<b-breadcrumb>
<b-breadcrumb-item
href=
"/home"
>
<b-icon
icon=
"house-fill"
scale=
"1.25"
shift-v=
"1.25"
aria-hidden=
"true"
></b-icon
>
<b-icon
icon=
"house-fill"
scale=
"1.25"
shift-v=
"1.25"
aria-hidden=
"true"
/
>
Home
</b-breadcrumb-item>
<b-breadcrumb-item
href=
"/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>
<b-modal
id=
"modal-create"
title=
"create Product"
class=
"modal fade"
>
<b-button
v-b-modal
.
modal-create
class=
"text-white"
>
New Product
</b-button>
</div>
<b-modal
id=
"modal-create"
title=
"create Product"
class=
"modal fade"
>
<div
class=
"w-full mt-4 p-10"
>
<form
>
<form
>
<label
for=
"input-live"
>
Name :
</label>
<b-form-input
id=
"input-live"
v-model=
"name"
type=
"text"
class=
"form-control mb-2"
placeholder=
"name"
aria-describedby=
"input-live-help input-live-feedback"
v-model=
"name"
max=
"255"
min=
"1"
trim
>
</b-form-input>
/>
<b-form-invalid-feedback
id=
"input-live-feedback"
>
Enter at least 3 letters
</b-form-invalid-feedback>
<label>
Category ID :
</label>
<b-form-select
v-model=
"category_id"
>
<option
v-for=
"item in categories"
:value=
"item.id"
>
{{
item
.
name
}}
{{
item
.
name
}}
</option>
</b-form-select>
<label>
Price :
</label>
<input
v-model=
"price"
type=
"text"
class=
"form-control mb-2"
placeholder=
"Ordering"
v-model=
"price"
size=
"sm"
required
/
>
>
<label>
Description :
</label>
<input
v-model=
"description"
type=
"text"
class=
"form-control mb-2"
placeholder=
"Description"
v-model=
"description"
size=
"sm"
required
/
>
>
<label>
Stock :
</label>
<input
v-model=
"stock"
type=
"text"
class=
"form-control mb-2"
placeholder=
"Stock"
v-model=
"stock"
size=
"sm"
required
/
>
>
<label>
Image :
</label>
<b-form-file
v-model=
"images"
...
...
@@ -69,7 +75,7 @@
:state=
"Boolean(images)"
placeholder=
"Choose a image or drop it here..."
drop-placeholder=
"Drop file here..."
></b-form-file
>
/
>
<button
type=
"button"
class=
"btn-primary flex justify-start ml-2 mt-2 rounded-md border px-3 py-2 bg-pink-600 text-white"
...
...
@@ -83,83 +89,87 @@
v-model=
"variant.color"
placeholder=
"Color"
class=
"w-full py-2 border border-indigo-500 rounded"
/
>
>
<input
v-model=
"variant.size"
placeholder=
"Size"
class=
"w-full py-2 border border-indigo-500 rounded"
/
>
>
<input
v-model=
"variant.quantity"
placeholder=
"Quantity"
class=
"w-full py-2 border border-indigo-500 rounded"
/
>
>
<button
v-show=
"index != 0"
type=
"button"
class=
"ml-2 rounded-md mt-2 "
@
click=
"remove(index)"
v-show=
"index != 0"
>
<b-icon
icon=
"dash-circle-fill"
class=
"h5"
variant=
"danger"
></b-icon>
<b-icon
icon=
"dash-circle-fill"
class=
"h5"
variant=
"danger"
/>
</button>
</div>
</div>
</form>
</div>
<template
#modal-footer
>
<button
v-b-modal
.
modal-close_visit
@
click=
"$bvModal.hide('modal-create')"
class=
"btn btn-danger btn-sm m-1"
>
Close
</button>
<button
@
click=
"createProduct()"
v-b-modal
.
modal-close_visit
class=
"btn btn-success btn-sm m-1"
>
Submit
</button>
<button
v-b-modal
.
modal-close_visit
class=
"btn btn-danger btn-sm m-1"
@
click=
"$bvModal.hide('modal-create')"
>
Close
</button>
<button
v-b-modal
.
modal-close_visit
class=
"btn btn-success btn-sm m-1"
@
click=
"createProduct()"
>
Submit
</button>
</
template
>
</b-modal>
<!-- modal-show -->
<b-modal
id=
"modal-show"
title=
"PRODUCT"
class=
"modal fade"
>
<b-modal
id=
"modal-show"
title=
"PRODUCT"
class=
"modal fade"
>
<div
class=
"w-full mt-4 p-10"
>
<form
>
<form
>
<label>
Name :
</label>
<input
v-model=
"sName"
type=
"text"
class=
"form-control mb-2"
v-model=
"sName"
size=
"sm"
disabled
/
>
>
<label>
Category ID :
</label>
<input
v-model=
"sCategoryId"
type=
"text"
class=
"form-control mb-2"
v-model=
"sCategoryId"
size=
"sm"
disabled
/
>
>
<label>
Price :
</label>
<input
v-model=
"sPrice"
type=
"text"
class=
"form-control mb-2"
v-model=
"sPrice"
size=
"sm"
disabled
/
>
>
<label>
Description :
</label>
<input
v-model=
"sDescription"
type=
"text"
class=
"form-control mb-2"
placeholder=
"Description"
v-model=
"sDescription"
size=
"sm"
disabled
/
>
>
<label>
Stock :
</label>
<input
v-model=
"sStock"
type=
"text"
class=
"form-control mb-2"
placeholder=
"Stock"
v-model=
"sStock"
size=
"sm"
disabled
/
>
>
<label>
Image :
</label>
<div
v-for=
"(image, index) in sImages"
:key=
"index"
>
<b-img
:src=
"image"
fluid
alt=
"Fluid image"
></b-img
>
<b-img
:src=
"image"
fluid
alt=
"Fluid image"
/
>
</div>
<label>
Variant :
</label>
<div
v-for=
"(variant, index) in sVariants"
:key=
"'A' +index"
>
...
...
@@ -169,75 +179,77 @@
placeholder=
"Color"
class=
"w-full py-2 border border-indigo-500 rounded"
disabled
/
>
>
<input
v-model=
"variant.size"
placeholder=
"Size"
class=
"w-full py-2 border border-indigo-500 rounded"
disabled
/
>
>
<input
v-model=
"variant.quantity"
placeholder=
"Quantity"
class=
"w-full py-2 border border-indigo-500 rounded"
disabled
/
>
>
</div>
</div>
</form>
</div>
<
template
#modal-footer
>
<button
v-b-modal
.
modal-close_visit
@
click=
"$bvModal.hide('modal-show')"
class=
"btn btn-danger btn-sm m-1"
>
Close
</button>
<button
v-b-modal
.
modal-close_visit
class=
"btn btn-danger btn-sm m-1"
@
click=
"$bvModal.hide('modal-show')"
>
Close
</button>
</
template
>
</b-modal>
<!-- modal-edit -->
<b-modal
id=
"modal-edit"
title=
"Edit Product"
class=
"modal fade"
>
<b-modal
id=
"modal-edit"
title=
"Edit Product"
class=
"modal fade"
>
<div
class=
"w-full mt-4 p-10"
>
<form
>
<form
>
<label>
Name :
</label>
<input
v-model=
"eName"
type=
"text"
class=
"form-control mb-2"
placeholder=
"name"
v-model=
"eName"
max=
"255"
min=
"1"
size=
"sm"
required
/
>
>
<label>
Category ID :
</label>
<b-form-select
v-model=
"eCategoryId"
>
<option
v-for=
"item in categories"
:value=
"item.id"
>
{{
item.name
}}
{{
item.name
}}
</option>
</b-form-select>
<label>
Price :
</label>
<input
v-model=
"ePrice"
type=
"text"
class=
"form-control mb-2"
placeholder=
"Ordering"
v-model=
"ePrice"
size=
"sm"
required
/
>
>
<label>
Description :
</label>
<input
v-model=
"eDescription"
type=
"text"
class=
"form-control mb-2"
placeholder=
"Description"
v-model=
"eDescription"
size=
"sm"
required
/
>
>
<label>
Stock :
</label>
<input
v-model=
"eStock"
type=
"text"
class=
"form-control mb-2"
placeholder=
"Stock"
v-model=
"eStock"
size=
"sm"
required
/
>
>
<label>
Image :
</label>
<b-form-file
v-model=
"eImages"
...
...
@@ -245,7 +257,7 @@
:state=
"Boolean(eImages)"
placeholder=
"Choose a image or drop it here..."
drop-placeholder=
"Drop file here..."
></b-form-file
>
/
>
<button
type=
"button"
class=
"btn-primary flex justify-start ml-2 mt-2 rounded-md border px-3 py-2 bg-pink-600 text-white"
...
...
@@ -259,32 +271,36 @@
v-model=
"variant.color"
placeholder=
"Color"
class=
"w-full py-2 border border-indigo-500 rounded"
/
>
>
<input
v-model=
"variant.size"
placeholder=
"Size"
class=
"w-full py-2 border border-indigo-500 rounded"
/
>
>
<input
v-model=
"variant.quantity"
placeholder=
"Quantity"
class=
"w-full py-2 border border-indigo-500 rounded"
/
>
>
<button
v-show=
"index != 0"
type=
"button"
class=
"ml-2 rounded-md mt-2 "
@
click=
"removeVariant(index)"
v-show=
"index != 0"
>
<b-icon
icon=
"dash-circle-fill"
class=
"h5"
variant=
"danger"
></b-icon>
<b-icon
icon=
"dash-circle-fill"
class=
"h5"
variant=
"danger"
/>
</button>
</div>
</div>
</form>
</div>
<
template
#modal-footer
>
<button
v-b-modal
.
modal-close_visit
@
click=
"$bvModal.hide('modal-edit')"
class=
"btn btn-danger btn-sm m-1"
>
Close
</button>
<button
@
click=
"updateProduct()"
v-b-modal
.
modal-close_visit
class=
"btn btn-success btn-sm m-1"
>
Submit
</button>
<button
v-b-modal
.
modal-close_visit
class=
"btn btn-danger btn-sm m-1"
@
click=
"$bvModal.hide('modal-edit')"
>
Close
</button>
<button
v-b-modal
.
modal-close_visit
class=
"btn btn-success btn-sm m-1"
@
click=
"updateProduct()"
>
Submit
</button>
</
template
>
</b-modal>
<!-- table -->
...
...
@@ -295,20 +311,28 @@
sort-by=
"calories"
class=
"elevation-1"
>
<
template
v-slot:top
>
<
template
#top
>
<v-toolbar
flat
>
<v-toolbar-title>
Product Manage
</v-toolbar-title>
<v-divider
class=
"mx-4"
inset
vertical
></v-divider
>
<v-spacer></v-spacer
>
<v-divider
class=
"mx-4"
inset
vertical
/
>
<v-spacer
/
>
</v-toolbar>
</
template
>
<
template
v-slot:item.actions=
"{ item }"
>
<v-icon
small
@
click=
"editProduct(item)"
:id =
"item.id"
>
mdi-pencil
</v-icon>
<v-icon
small
@
click=
"deleteProduct(item.id,item)"
:id =
"item.id"
>
mdi-delete
</v-icon>
<v-icon
small
@
click=
"showProduct(item)"
:id =
"item.id"
>
mdi-account-details
</v-icon>
<
template
#item.actions=
"{ item }"
>
<v-icon
:id=
"item.id"
small
@
click=
"editProduct(item)"
>
mdi-pencil
</v-icon>
<v-icon
:id=
"item.id"
small
@
click=
"deleteProduct(item.id,item)"
>
mdi-delete
</v-icon>
<v-icon
:id=
"item.id"
small
@
click=
"showProduct(item)"
>
mdi-account-details
</v-icon>
</
template
>
<
template
v-slot:no-data
>
<v-btn
color=
"primary"
@
click=
"initialize"
>
Reset
</v-btn>
<
template
#no-data
>
<v-btn
color=
"primary"
@
click=
"initialize"
>
Reset
</v-btn>
</
template
>
</v-data-table>
</div>
...
...
@@ -317,8 +341,8 @@
<
script
>
export
default
{
layout
:
'
admin
'
,
name
:
'
App
'
,
layout
:
'
admin
'
,
middleware
:
[
'
web
'
],
data
:
()
=>
{
return
{
...
...
@@ -333,8 +357,8 @@ export default {
{
color
:
''
,
size
:
''
,
quantity
:
''
,
}
,
quantity
:
''
}
],
dialog
:
false
,
dialogDelete
:
false
,
...
...
@@ -344,14 +368,14 @@ export default {
text
:
'
Name
'
,
align
:
'
start
'
,
sortable
:
false
,
value
:
'
name
'
,
value
:
'
name
'
},
{
text
:
'
id
'
,
value
:
'
id
'
},
{
text
:
'
category ID
'
,
value
:
'
category_id
'
},
{
text
:
'
price
'
,
value
:
'
price
'
,
sortable
:
false
},
{
text
:
'
description
'
,
value
:
'
description
'
},
{
text
:
'
stock
'
,
value
:
'
stock
'
},
{
text
:
'
Actions
'
,
value
:
'
actions
'
,
sortable
:
false
},
{
text
:
'
Actions
'
,
value
:
'
actions
'
,
sortable
:
false
}
],
products
:
[],
product
:
[],
...
...
@@ -366,8 +390,8 @@ export default {
{
color
:
''
,
size
:
''
,
quantity
:
''
,
}
,
quantity
:
''
}
],
eId
:
''
,
eName
:
''
,
...
...
@@ -380,8 +404,8 @@ export default {
{
color
:
''
,
size
:
''
,
quantity
:
''
,
}
,
quantity
:
''
}
],
message
:
[],
editedIndex
:
-
1
,
...
...
@@ -390,7 +414,7 @@ export default {
category_id
:
''
,
price
:
''
,
description
:
''
,
stock
:
''
,
stock
:
''
},
defaultItem
:
{
name
:
''
,
...
...
@@ -398,80 +422,80 @@ export default {
ordering
:
''
,
status
:
''
,
created_at
:
''
,
updated_at
:
''
,
},
updated_at
:
''
}
}
},
computed
:
{
formTitle
()
{
formTitle
()
{
return
this
.
editedIndex
===
-
1
?
'
New Item
'
:
'
Edit Item
'
},
nameState
()
{
return
this
.
name
.
length
>
2
?
true
:
false
nameState
()
{
return
this
.
name
.
length
>
2
}
},
watch
:
{
dialog
(
val
)
{
dialog
(
val
)
{
val
||
this
.
close
()
},
dialogDelete
(
val
)
{
dialogDelete
(
val
)
{
val
||
this
.
closeDelete
()
}
},
},
created
()
{
this
.
initialize
(),
this
.
getProducts
(),
created
()
{
this
.
initialize
()
this
.
getProducts
()
this
.
getCategories
()
},
methods
:
{
initialize
()
{
this
.
products
=
[],
this
.
product
=
[],
this
.
categories
=
[],
this
.
sName
=
''
,
this
.
sCategoryId
=
''
,
this
.
sPrice
=
''
,
this
.
sDescription
=
''
,
this
.
sStock
=
''
,
this
.
sImages
=
null
,
this
.
sVariants
=
[
initialize
()
{
this
.
products
=
[]
this
.
product
=
[]
this
.
categories
=
[]
this
.
sName
=
''
this
.
sCategoryId
=
''
this
.
sPrice
=
''
this
.
sDescription
=
''
this
.
sStock
=
''
this
.
sImages
=
null
this
.
sVariants
=
[
{
color
:
''
,
size
:
''
,
quantity
:
''
,
quantity
:
''
}
,
}
]
},
editItem
(
item
)
{
editItem
(
item
)
{
this
.
editedIndex
=
this
.
products
.
indexOf
(
item
)
this
.
editedItem
=
Object
.
assign
({},
item
)
this
.
dialog
=
true
},
deleteItem
(
item
)
{
deleteItem
(
item
)
{
this
.
editedIndex
=
this
.
products
.
indexOf
(
item
)
this
.
editedItem
=
Object
.
assign
({},
item
)
this
.
dialogDelete
=
true
},
deleteItemConfirm
()
{
deleteItemConfirm
()
{
this
.
products
.
splice
(
this
.
editedIndex
,
1
)
this
.
closeDelete
()
},
close
()
{
close
()
{
this
.
dialog
=
false
this
.
$nextTick
(()
=>
{
this
.
editedItem
=
Object
.
assign
({},
this
.
defaultItem
)
this
.
editedIndex
=
-
1
})
},
closeDelete
()
{
closeDelete
()
{
this
.
dialogDelete
=
false
this
.
$nextTick
(()
=>
{
this
.
editedItem
=
Object
.
assign
({},
this
.
defaultItem
)
this
.
editedIndex
=
-
1
})
},
save
()
{
save
()
{
if
(
this
.
editedIndex
>
-
1
)
{
Object
.
assign
(
this
.
products
[
this
.
editedIndex
],
this
.
editedItem
)
}
else
{
...
...
@@ -479,49 +503,51 @@ export default {
}
this
.
close
()
},
getCategories
()
{
getCategories
()
{
this
.
$axios
.
get
(
"
/categories/
"
,
{
.
get
(
'
/categories/
'
,
{
headers
:
{
'
Content-Type
'
:
'
application/json
'
,
Authorization
:
`Bearer
${
this
.
$auth
.
$storage
.
getUniversal
(
"
token
"
)}
`
,
}})
.
then
((
response
)
=>
(
this
.
categories
=
response
.
data
.
data
))
Authorization
:
`Bearer
${
this
.
$auth
.
$storage
.
getUniversal
(
'
token
'
)}
`
}
})
.
then
(
response
=>
(
this
.
categories
=
response
.
data
.
data
))
.
catch
(
function
(
error
)
{
console
.
log
(
error
)
})
},
getProducts
()
{
getProducts
()
{
this
.
$axios
.
get
(
"
/products/
"
,
{
.
get
(
'
/products/
'
,
{
headers
:
{
'
Content-Type
'
:
'
application/json
'
,
Authorization
:
`Bearer
${
this
.
$auth
.
$storage
.
getUniversal
(
"
token
"
)}
`
,
}})
.
then
((
response
)
=>
(
this
.
products
=
response
.
data
.
data
))
Authorization
:
`Bearer
${
this
.
$auth
.
$storage
.
getUniversal
(
'
token
'
)}
`
}
})
.
then
(
response
=>
(
this
.
products
=
response
.
data
.
data
))
.
catch
(
function
(
error
)
{
console
.
log
(
error
)
})
},
createProduct
()
{
createProduct
()
{
const
self
=
this
// const set = new Set([this.images])
// const images = Array.from(set)
this
.
$axios
.
post
(
'
/products/
'
,
{
.
post
(
'
/products/
'
,
{
name
:
this
.
name
,
price
:
this
.
price
,
category_id
:
this
.
category_id
,
description
:
this
.
description
,
images
:
this
.
images
,
variants
:
this
.
variants
,
variants
:
this
.
variants
},
{
headers
:
{
'
Content-Type
'
:
'
multipart/form-data
'
,
Authorization
:
`Bearer
${
this
.
$auth
.
$storage
.
getUniversal
(
"
token
"
)}
`
,
Authorization
:
`Bearer
${
this
.
$auth
.
$storage
.
getUniversal
(
'
token
'
)}
`
}
})
.
then
(
response
=>
{
.
then
((
response
)
=>
{
this
.
$bvModal
.
hide
(
'
modal-create
'
)
self
.
$toast
.
success
(
'
Product created successfully!
'
,
{
duration
:
3000
...
...
@@ -530,46 +556,47 @@ export default {
console
.
log
(
this
.
editedItem
)
this
.
products
.
push
(
this
.
editedItem
)
})
.
catch
(
errors
=>
{
.
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!
'
,
{
self
.
$toast
.
error
(
'
something went wrong while trying create!
'
,
{
duration
:
3000
})
})
},
deleteProduct
(
ID
,
index
)
{
deleteProduct
(
ID
,
index
)
{
const
self
=
this
this
.
editedIndex
=
this
.
products
.
indexOf
(
index
)
if
(
confirm
(
'
Do you really want to delete?
'
))
{
try
{
if
(
confirm
(
'
Do you really want to delete?
'
))
{
try
{
this
.
$axios
.
delete
(
`/products/
${
ID
}
`
,
{
.
delete
(
`/products/
${
ID
}
`
,
{
headers
:
{
'
Content-Type
'
:
'
application/json
'
,
Authorization
:
`Bearer
${
this
.
$auth
.
$storage
.
getUniversal
(
"
token
"
)}
`
,
}})
.
then
(
response
=>
{
Authorization
:
`Bearer
${
this
.
$auth
.
$storage
.
getUniversal
(
'
token
'
)}
`
}
})
.
then
((
response
)
=>
{
this
.
products
.
splice
(
this
.
editedIndex
,
1
)
self
.
$toast
.
success
(
'
Category deleted successfully!
'
,
{
self
.
$toast
.
success
(
'
Category deleted successfully!
'
,
{
duration
:
3000
})
})
}
catch
(
error
)
{
}
catch
(
error
)
{
console
.
log
(
error
)
}
}
},
async
showProduct
(
item
)
{
async
showProduct
(
item
)
{
const
ID
=
item
.
id
try
{
const
resp
=
await
this
.
$axios
.
get
(
`/products/
${
ID
}
`
,
{
method
:
'
GET
'
,
headers
:
{
"
Content-Type
"
:
"
multipart/form-data
"
,
Authorization
:
`Bearer
${
this
.
$auth
.
$storage
.
getUniversal
(
"
token
"
)}
`
,
}
,
'
Content-Type
'
:
'
multipart/form-data
'
,
Authorization
:
`Bearer
${
this
.
$auth
.
$storage
.
getUniversal
(
'
token
'
)}
`
}
})
this
.
sName
=
resp
.
data
.
data
.
name
this
.
sPrice
=
resp
.
data
.
data
.
price
...
...
@@ -583,7 +610,7 @@ export default {
}
this
.
$bvModal
.
show
(
'
modal-show
'
)
},
editProduct
(
item
)
{
editProduct
(
item
)
{
this
.
$bvModal
.
show
(
'
modal-edit
'
)
this
.
eId
=
item
.
id
this
.
eName
=
item
.
name
...
...
@@ -594,26 +621,26 @@ export default {
this
.
eVariants
=
item
.
variants
this
.
editedIndex
=
this
.
products
.
indexOf
(
item
)
},
updateProduct
(
ID
)
{
updateProduct
(
ID
)
{
const
self
=
this
try
{
try
{
this
.
$axios
.
post
(
`/products/update/
${
this
?.
eId
}
`,{
.
post
(
`/products/update/
${
this
?.
eId
}
`,
{
name: this.eName,
price: this.ePrice,
category_id: this.eCategoryId,
description: this.eDescription,
images: this.eImages,
variants: this.eVariants
,
variants: this.eVariants
}, {
headers: {
"Content-Type": "multipart/form-data"
,
Authorization: `
Bearer
$
{
this
.
$auth
.
$storage
.
getUniversal
(
"
token
"
)}
`,
'Content-Type': 'multipart/form-data'
,
Authorization: `
Bearer
$
{
this
.
$auth
.
$storage
.
getUniversal
(
'
token
'
)}
`
}
}
)
.then(response
=> {
self.$toast.success('User updated successfully!',
{
.then((response)
=> {
self.$toast.success('User updated successfully!',
{
duration: 3000
})
console.log(response)
...
...
@@ -621,30 +648,30 @@ export default {
this.$bvModal.hide('modal-edit')
Object.assign(this.products[this.editedIndex], this.editedItem)
})
} catch
(error)
{
} catch
(error)
{
console.log(error)
}
},
addMore() {
addMore
() {
this.variants.push({
color: '',
size: '',
quantity: ''
,
quantity: ''
})
},
addMoreVariant() {
addMoreVariant
() {
this.eVariants.push({
color: '',
size: '',
quantity: ''
,
quantity: ''
})
},
remove(index) {
remove
(index) {
this.variants.splice(index, 1)
},
removeVariant(index) {
removeVariant
(index) {
this.eVariants.splice(index, 1)
}
,
}
,
}
}
}
</
script
>
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