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
a415f7f3
Commit
a415f7f3
authored
Feb 08, 2023
by
TTS Kieu Tuan Anh
Browse files
Options
Browse Files
Download
Plain Diff
add validate user screen
parents
4fd1bcfe
3ac4c11d
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
9847 additions
and
9789 deletions
+9847
-9789
index.vue
pages/categories/index.vue
+16
-11
index.vue
pages/index.vue
+2
-1
login.vue
pages/login.vue
+1
-1
index.vue
pages/posts/index.vue
+29
-35
index.vue
pages/products/index.vue
+72
-30
index.vue
pages/users/index.vue
+21
-5
yarn.lock
yarn.lock
+9706
-9706
No files found.
pages/categories/index.vue
View file @
a415f7f3
...
...
@@ -283,6 +283,9 @@
</v-dialog>
</v-toolbar>
</template>
<
template
#
[`
item
.
index
`
]=
"{ index }"
>
{{
index
+
1
}}
</
template
>
<
template
#item.created_at=
"{ item }"
>
<span>
{{
formatDate
(
item
.
created_at
)
}}
</span>
</
template
>
...
...
@@ -329,11 +332,12 @@ export default {
options
:
[],
headers
:
[
{
text
:
'
Name
'
,
text
:
'
#
'
,
align
:
'
start
'
,
value
:
'
name
'
,
value
:
'
index
'
,
groupable
:
false
},
{
text
:
'
Name
'
,
value
:
'
name
'
,
groupable
:
false
},
{
text
:
'
Odering
'
,
value
:
'
ordering
'
,
groupable
:
false
},
{
text
:
'
Created
'
,
value
:
'
created_at
'
,
groupable
:
false
},
{
text
:
'
Updated
'
,
value
:
'
updated_at
'
,
groupable
:
false
},
...
...
@@ -484,6 +488,7 @@ export default {
duration
:
3000
})
})
this
.
getCategories
()
},
deleteCategory
()
{
const
self
=
this
...
...
@@ -574,19 +579,19 @@ export default {
padding-left
:
30px
!important
;
background-color
:
rgba
(
211
,
211
,
211
,
0.133
);
}
.depth-1
>
td
:
first-child
{
.depth-1
>
td
:
nth-child
(
2
)
{
padding-left
:
30px
!important
;
}
.depth-2
>
td
:first-child
{
padding-left
:
45px
!important
;
}
.depth-3
>
td
:first-child
{
.depth-2
>
td
:nth-child
(
2
)
{
padding-left
:
60px
!important
;
}
.depth-4
>
td
:first-child
{
padding-left
:
75px
!important
;
}
.depth-5
>
td
:first-child
{
.depth-3
>
td
:nth-child
(
2
)
{
padding-left
:
90px
!important
;
}
.depth-4
>
td
:nth-child
(
2
)
{
padding-left
:
120px
!important
;
}
.depth-5
>
td
:nth-child
(
2
)
{
padding-left
:
150px
!important
;
}
</
style
>
pages/index.vue
View file @
a415f7f3
...
...
@@ -78,6 +78,7 @@
<
script
>
export
default
{
name
:
'
IndexPage
'
name
:
'
IndexPage
'
,
middleware
:
[
'
web
'
]
}
</
script
>
pages/login.vue
View file @
a415f7f3
...
...
@@ -127,7 +127,7 @@ export default {
})
console
.
log
(
resp
.
status
)
localStorage
.
setItem
(
'
token
'
,
resp
.
data
.
bearer_token
)
this
.
$auth
.
$storage
.
setUniversal
(
'
token
'
,
resp
.
data
.
bearer_token
)
this
.
$auth
.
$storage
.
setUniversal
(
'
token
'
,
resp
.
data
.
bearer_token
)
this
.
$auth
.
$storage
.
setUniversal
(
'
userName
'
,
resp
.
data
.
name
)
this
.
$auth
.
$storage
.
setUniversal
(
'
loggedIn
'
,
'
true
'
)
if
(
resp
.
status
==
'
success
'
)
{
...
...
pages/posts/index.vue
View file @
a415f7f3
<!-- 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>
...
...
@@ -50,7 +47,7 @@
/>
</v-col>
<v-col
cols=
"12"
>
<v-text
-field
<v-text
area
v-model=
"sContent"
label=
"Content"
word-break=
"break-word"
...
...
@@ -70,9 +67,12 @@
/>
</v-col>
<v-col
cols=
"12"
>
<v-col
v-for=
"(image, index) in sImages"
:key=
"index"
cols=
"12"
>
<v-img
:src=
"image"
contain
/>
</v-col>
<!-- <v-col v-for="(image, index) in sImages" :key="index" cols="12">
<v-img :src="image"/> -->
<v-img
v-if=
"typeof sImages === 'string'"
:src=
"sImages"
/>
</v-col>
</v-row>
</v-container>
...
...
@@ -87,14 +87,6 @@
>
Close
</v-btn>
<v-btn
color=
"blue darken-1"
text
type=
"submit"
@
click=
"dialog2 = false;"
>
Save
</v-btn>
</v-card-actions>
</v-card>
</v-dialog>
...
...
@@ -134,7 +126,7 @@
/>
</v-col>
<v-col
cols=
"12"
>
<v-text
-field
<v-text
area
v-model=
"eContent"
label=
"Content"
required
...
...
@@ -148,7 +140,7 @@
:items=
"statusDefaul"
item-text=
"name"
item-value=
"id"
label=
"
Category
"
label=
"
Status
"
/>
</v-col>
<v-col
cols=
"12"
>
...
...
@@ -258,7 +250,7 @@
/>
</v-col>
<v-col
cols=
"12"
>
<v-text
-field
<v-text
area
v-model=
"content"
label=
"Content"
required
...
...
@@ -313,10 +305,16 @@
</v-toolbar-title>
</v-toolbar>
</template>
<
template
#item.category_id=
"{ item }"
>
<
template
#
[`
item
.
index
`
]=
"{ index }"
>
{{
index
+
1
}}
</
template
>
<
template
#
[`
item
.
category_id
`
]=
"{ item }"
>
{{
categories
.
find
(
x
=>
x
.
id
===
item
.
category_id
)?.
name
}}
</
template
>
<
template
#item.user_id=
"{ item }"
>
<
template
#
[`
item
.
status
`
]=
"{ item }"
>
{{
statusDefaul
.
find
(
x
=>
x
.
id
==
item
.
status
)?.
name
}}
</
template
>
<
template
#
[`
item
.
user_id
`
]=
"{ item }"
>
{{
users
.
find
(
x
=>
x
.
id
===
item
.
user_id
)?.
name
}}
</
template
>
<
template
#
[`
item
.
actions
`
]=
"{ item }"
>
...
...
@@ -361,15 +359,14 @@ export default {
dialogDelete
:
false
,
headers
:
[
{
text
:
'
Title
'
,
text
:
'
#
'
,
align
:
'
start
'
,
sortable
:
false
,
value
:
'
title
'
value
:
'
index
'
},
{
text
:
'
id
'
,
value
:
'
id
'
},
{
text
:
'
Category
ID
'
,
value
:
'
category_id
'
},
{
text
:
'
a
uthor
'
,
value
:
'
user_id
'
},
{
text
:
'
s
tatus
'
,
value
:
'
status
'
},
{
text
:
'
Title
'
,
value
:
'
title
'
},
{
text
:
'
Category
'
,
value
:
'
category_id
'
},
{
text
:
'
A
uthor
'
,
value
:
'
user_id
'
},
{
text
:
'
S
tatus
'
,
value
:
'
status
'
},
{
text
:
'
Actions
'
,
value
:
'
actions
'
,
sortable
:
false
}
],
items
:
[
...
...
@@ -406,8 +403,8 @@ export default {
sCategoryId
:
''
,
sContent
:
''
,
sUserId
:
''
,
sStatus
:
''
,
sImages
:
null
,
sStatus
:
[]
,
sImages
:
[]
,
eId
:
''
,
eTitle
:
''
,
eCategoryId
:
[],
...
...
@@ -465,8 +462,8 @@ export default {
this
.
sCategoryId
=
''
this
.
sContent
=
''
this
.
sUserId
=
''
this
.
sStatus
=
''
this
.
sImages
=
null
this
.
sStatus
=
[]
this
.
sImages
=
[]
},
editItem
(
item
)
{
this
.
editedIndex
=
this
.
posts
.
indexOf
(
item
)
...
...
@@ -520,7 +517,6 @@ export default {
this
.
$axios
.
get
(
'
/categories/
'
,
{
headers
:
{
'
Content-Type
'
:
'
application/json
'
,
Authorization
:
`Bearer
${
this
.
$auth
.
$storage
.
getUniversal
(
'
token
'
)}
`
}
})
...
...
@@ -533,7 +529,6 @@ export default {
this
.
$axios
.
get
(
'
/posts/
'
,
{
headers
:
{
'
Content-Type
'
:
'
application/json
'
,
Authorization
:
`Bearer
${
this
.
$auth
.
$storage
.
getUniversal
(
'
token
'
)}
`
}
})
...
...
@@ -603,7 +598,6 @@ export default {
const
ID
=
item
.
id
try
{
const
resp
=
await
this
.
$axios
.
get
(
`/posts/
${
ID
}
`
,
{
method
:
'
GET
'
,
headers
:
{
Authorization
:
`Bearer
${
this
.
$auth
.
$storage
.
getUniversal
(
'
token
'
)}
`
}
...
...
pages/products/index.vue
View file @
a415f7f3
<!-- eslint-disable vue/require-v-for-key -->
<!-- eslint-disable vue/valid-v-slot -->
<
template
>
<div>
<div>
...
...
@@ -9,7 +7,6 @@
</
template
>
</v-breadcrumbs>
</div>
<div
style=
"float: right"
/>
<!-- show-modal -->
<v-dialog
v-model=
"dialog2"
...
...
@@ -230,7 +227,7 @@
dark
x-small
color=
"red"
@
click=
"
removeVariant(index, variant)
"
@
click=
"
getVariant(index, variant); dialogDeleteVariant = true
"
>
<v-icon
dark
>
mdi-minus
...
...
@@ -280,6 +277,23 @@
</v-card-actions>
</v-card>
</v-dialog>
<v-dialog
v-model=
"dialogDeleteVariant"
max-width=
"500px"
>
<v-card>
<v-card-title
class=
"text-h5"
>
Are you sure you want to delete this item?
</v-card-title>
<v-card-actions>
<v-spacer
/>
<v-btn
color=
"blue darken-1"
text
@
click=
"closeDelete"
>
Cancel
</v-btn>
<v-btn
color=
"blue darken-1"
text
@
click=
"removeVariant(); dialogDeleteVariant=false"
>
OK
</v-btn>
<v-spacer
/>
</v-card-actions>
</v-card>
</v-dialog>
<!-- table -->
<div>
<v-data-table
...
...
@@ -451,6 +465,9 @@
</v-toolbar-title>
</v-toolbar>
</template>
<
template
#
[`
item
.
index
`
]=
"{ index }"
>
{{
index
+
1
}}
</
template
>
<
template
#
[`
item
.
actions
`
]=
"{ item }"
>
<v-icon
:id=
"item.id"
small
@
click=
"editProduct(item)"
>
mdi-pencil
...
...
@@ -480,7 +497,7 @@ export default {
return
{
name
:
''
,
id
:
''
,
category_id
:
null
,
category_id
:
''
,
price
:
''
,
stock
:
''
,
description
:
''
,
...
...
@@ -500,18 +517,19 @@ export default {
dialog2
:
false
,
dialog3
:
false
,
dialogDelete
:
false
,
dialogDeleteVariant
:
false
,
options
:
[],
headers
:
[
{
text
:
'
Name
'
,
text
:
'
#
'
,
align
:
'
start
'
,
sortable
:
false
,
value
:
'
name
'
value
:
'
index
'
},
{
text
:
'
id
'
,
value
:
'
id
'
},
{
text
:
'
category ID
'
,
value
:
'
category_id
'
},
{
text
:
'
p
rice
'
,
value
:
'
price
'
,
sortable
:
false
},
{
text
:
'
s
tock
'
,
value
:
'
stock
'
},
{
text
:
'
Name
'
,
value
:
'
name
'
},
{
text
:
'
Category
'
,
value
:
'
category.name
'
},
{
text
:
'
P
rice
'
,
value
:
'
price
'
,
sortable
:
false
},
{
text
:
'
S
tock
'
,
value
:
'
stock
'
},
{
text
:
'
Actions
'
,
value
:
'
actions
'
,
sortable
:
false
}
],
items
:
[
...
...
@@ -544,6 +562,8 @@ export default {
quantity
:
''
}
],
idVariant
:
''
,
editedVariantIndex
:
''
,
eId
:
''
,
eName
:
''
,
eCategoryId
:
''
,
...
...
@@ -603,7 +623,7 @@ export default {
this
.
images
=
[]
this
.
products
=
[]
this
.
product
=
[]
this
.
categories
=
[]
this
.
categories
=
''
this
.
sName
=
''
this
.
sCategoryId
=
''
this
.
sPrice
=
''
...
...
@@ -615,7 +635,6 @@ export default {
color
:
''
,
size
:
''
,
quantity
:
''
}
]
},
...
...
@@ -659,7 +678,6 @@ export default {
this
.
$axios
.
get
(
'
/categories/
'
,
{
headers
:
{
'
Content-Type
'
:
'
application/json
'
,
Authorization
:
`Bearer
${
this
.
$auth
.
$storage
.
getUniversal
(
'
token
'
)}
`
}
})
...
...
@@ -672,7 +690,6 @@ export default {
this
.
$axios
.
get
(
'
/products/
'
,
{
headers
:
{
'
Content-Type
'
:
'
application/json
'
,
Authorization
:
`Bearer
${
this
.
$auth
.
$storage
.
getUniversal
(
'
token
'
)}
`
}
})
...
...
@@ -702,9 +719,7 @@ export default {
,
{
headers
:
{
'
Content-Type
'
:
'
multipart/form-data
'
,
Authorization
:
`Bearer
${
this
.
$auth
.
$storage
.
getUniversal
(
'
token
'
)}
`
,
Accept
:
'
application/json; multipart/form-data
'
Authorization
:
`Bearer
${
this
.
$auth
.
$storage
.
getUniversal
(
'
token
'
)}
`
}
})
.
then
((
response
)
=>
{
...
...
@@ -734,7 +749,6 @@ export default {
this
.
$axios
.
delete
(
`/products/
${
this
.
eID
}
`
,
{
headers
:
{
'
Content-Type
'
:
'
application/json
'
,
Authorization
:
`Bearer
${
this
.
$auth
.
$storage
.
getUniversal
(
'
token
'
)}
`
}
})
...
...
@@ -754,7 +768,6 @@ export default {
const
resp
=
await
this
.
$axios
.
get
(
`/products/
${
ID
}
`
,
{
method
:
'
GET
'
,
headers
:
{
'
Content-Type
'
:
'
multipart/form-data
'
,
Authorization
:
`Bearer
${
this
.
$auth
.
$storage
.
getUniversal
(
'
token
'
)}
`
}
})
...
...
@@ -789,16 +802,18 @@ export default {
fd
.
append
(
'
price
'
,
this
.
ePrice
)
fd
.
append
(
'
category_id
'
,
this
.
eCategoryId
)
fd
.
append
(
'
description
'
,
this
.
eDescription
)
if
(
this
.
eVariants
)
{
for
(
let
i
=
0
;
i
<
this
.
eVariants
.
length
;
i
++
)
{
for
(
let
i
=
0
;
i
<
this
.
eVariants
.
length
;
i
++
)
{
if
(
typeof
this
.
eVariants
[
i
].
id
!==
'
undefined
'
)
{
fd
.
append
(
`variants[
${
i
}
][id]`
,
this
.
eVariants
[
i
].
id
)
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
)
}
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
])
if
(
this
.
eImages
)
{
for
(
let
j
=
0
;
j
<
this
.
eImages
.
length
;
j
++
)
{
fd
.
append
(
`images[
${
j
}
]`
,
this
.
eImages
[
j
])
}
}
const
currentPostIndex
=
this
.
editedIndex
try
{
...
...
@@ -806,7 +821,6 @@ export default {
.
post
(
`/products/update/
${
this
?.
eId
}
`,
fd, {
headers: {
'Content-Type': 'multipart/form-data',
Authorization: `
Bearer
$
{
this
.
$auth
.
$storage
.
getUniversal
(
'
token
'
)}
`
}
}
...
...
@@ -840,8 +854,36 @@ export default {
remove (index) {
this.variants.splice(index, 1)
},
removeVariant (index, variant) {
this.eVariants.splice(index, 1)
getVariant (index, item) {
this.editedVariantIndex = index
this.idVariant = item.id
console.log(this.idVariant)
},
removeVariant () {
const self = this
const currentVariantIndex = this.editedVariantIndex
if (this.idVariant !== null) {
try {
this.$axios.delete(`
/
products
/
delete
-
variant
/
$
{
this
.
idVariant
}
`,
{
headers: {
Authorization: `
Bearer
$
{
this
.
$auth
.
$storage
.
getUniversal
(
'
token
'
)}
`
}
}
).then((response) => {
self.$toast.success('Remove variant successfully!', {
duration: 3000
})
})
this.getProducts()
} catch (error) {
console.log(error)
}
this.eVariants.splice(currentVariantIndex, 1)
}
},
seeVariant () {
console.log(this.variants)
}
}
}
...
...
pages/users/index.vue
View file @
a415f7f3
...
...
@@ -11,7 +11,7 @@
</v-breadcrumbs>
</div>
<!-- modal-create -->
<v-dialog
v-model=
"dialog2"
persistent
max-width=
"600px"
>
<v-dialog
v-model=
"dialog2"
persistent
max-width=
"600px"
lazy-validation
>
<v-card>
<v-card-title>
<span
class=
"text-h5"
>
User Edit
</span>
...
...
@@ -20,16 +20,17 @@
<v-container>
<v-row>
<v-col
cols=
"12"
sm=
"6"
md=
"4"
>
<v-text-field
v-model=
"eName"
label=
"Legal name*"
required
/>
<v-text-field
v-model=
"eName"
label=
"Legal name*"
:rules=
"nameRules"
required
/>
</v-col>
<v-col
cols=
"12"
>
<v-text-field
v-model=
"eEmail"
label=
"Email*"
required
/>
<v-text-field
v-model=
"eEmail"
label=
"Email*"
:rules=
"emailRules"
required
/>
</v-col>
<v-col
cols=
"12"
>
<v-text-field
v-model=
"ePassword"
label=
"Password*"
type=
"password"
:rules=
"passwordRules"
required
/>
</v-col>
...
...
@@ -98,6 +99,7 @@
persistent
max-width=
"600px"
@
submit.prevent=
"createUser"
lazy-validation
>
<template
#activator
="
{ on, attrs }">
<v-btn
color=
"primary"
dark
v-bind=
"attrs"
v-on=
"on"
>
...
...
@@ -115,6 +117,7 @@
<v-text-field
v-model=
"name"
label=
"Legal name*"
:rules=
"nameRules"
required
/>
</v-col>
...
...
@@ -122,6 +125,7 @@
<v-text-field
v-model=
"email"
label=
"Email*"
:rules=
"emailRules"
required
/>
</v-col>
...
...
@@ -130,6 +134,7 @@
v-model=
"password"
label=
"Password*"
type=
"password"
:rules=
"passwordRules"
required
/>
</v-col>
...
...
@@ -259,7 +264,19 @@ export default {
status
:
''
,
created_at
:
''
,
updated_at
:
''
}
},
nameRules
:
[
v
=>
!!
v
||
'
Name is required
'
,
v
=>
(
v
&&
v
.
length
<=
10
)
||
'
Name must be less than 10 characters
'
],
emailRules
:
[
v
=>
!!
v
||
'
E-mail is required
'
,
v
=>
/.+@.+
\.
.+/
.
test
(
v
)
||
'
E-mail must be valid
'
],
passwordRules
:
[
v
=>
!!
v
||
'
Password is required
'
,
v
=>
(
v
&&
v
.
length
>=
6
)
||
'
Password must be more than 6 characters
'
]
}
},
computed
:
{
...
...
@@ -367,7 +384,6 @@ export default {
this
.
users
.
push
(
this
.
editedItem
)
})
.
catch
((
errors
)
=>
{
this
.
$bvModal
.
hide
(
'
modal-login
'
)
console
.
log
(
errors
.
response
.
data
.
message
)
this
.
message
=
errors
.
response
.
data
.
message
self
.
$toast
.
error
(
'
something went wrong while trying create!
'
,
{
...
...
yarn.lock
View file @
a415f7f3
This source diff could not be displayed because it is too large. You can
view the blob
instead.
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