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
3ac4c11d
Commit
3ac4c11d
authored
Feb 08, 2023
by
TTS Kieu Tuan Anh
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'feature/update-product-UI' into 'feature/UI-vuetify'
Feature/update product ui See merge request
!16
parents
51ae5777
8a8a1a66
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
58 additions
and
29 deletions
+58
-29
index.vue
pages/index.vue
+2
-1
login.vue
pages/login.vue
+2
-2
index.vue
pages/products/index.vue
+54
-26
No files found.
pages/index.vue
View file @
3ac4c11d
...
@@ -78,6 +78,7 @@
...
@@ -78,6 +78,7 @@
<
script
>
<
script
>
export
default
{
export
default
{
name
:
'
IndexPage
'
name
:
'
IndexPage
'
,
middleware
:
[
'
web
'
]
}
}
</
script
>
</
script
>
pages/login.vue
View file @
3ac4c11d
...
@@ -126,8 +126,8 @@ export default {
...
@@ -126,8 +126,8 @@ export default {
return
response
.
json
()
return
response
.
json
()
})
})
console
.
log
(
resp
.
status
)
console
.
log
(
resp
.
status
)
localStorage
.
setItem
(
'
token
'
,
resp
.
data
.
bearer_token
)
localStorage
.
setItem
(
'
token
'
,
'
Bearer
'
+
resp
.
data
.
bearer_token
)
this
.
$auth
.
$storage
.
setUniversal
(
'
token
'
,
resp
.
data
.
bearer_token
)
this
.
$auth
.
$storage
.
setUniversal
(
'
token
'
,
'
Bearer
'
+
resp
.
data
.
bearer_token
)
this
.
$auth
.
$storage
.
setUniversal
(
'
userName
'
,
resp
.
data
.
name
)
this
.
$auth
.
$storage
.
setUniversal
(
'
userName
'
,
resp
.
data
.
name
)
this
.
$auth
.
$storage
.
setUniversal
(
'
loggedIn
'
,
'
true
'
)
this
.
$auth
.
$storage
.
setUniversal
(
'
loggedIn
'
,
'
true
'
)
if
(
resp
.
status
==
'
success
'
)
{
if
(
resp
.
status
==
'
success
'
)
{
...
...
pages/products/index.vue
View file @
3ac4c11d
<!-- eslint-disable vue/require-v-for-key -->
<!-- eslint-disable vue/valid-v-slot -->
<
template
>
<
template
>
<div>
<div>
<div>
<div>
...
@@ -43,15 +41,16 @@
...
@@ -43,15 +41,16 @@
required
required
/>
/>
</v-col>
</v-col>
<v-col
<v-col
cols=
"12"
>
cols=
"12"
>
<v-select
<v-select
v-model=
"category_id"
v-model=
"category_id"
:items=
"categories"
:items=
"categories"
item-text=
"name"
item-text=
"name"
item-value=
"id"
item-value=
"id"
label=
"Category"
menu-props=
"auto"
label=
"Select category"
hide-details
single-line
/>
/>
</v-col>
</v-col>
<v-col
cols=
"12"
>
<v-col
cols=
"12"
>
...
@@ -302,7 +301,10 @@
...
@@ -302,7 +301,10 @@
:items=
"categories"
:items=
"categories"
item-text=
"name"
item-text=
"name"
item-value=
"id"
item-value=
"id"
label=
"Category"
menu-props=
"auto"
label=
"Select category"
hide-details
single-line
/>
/>
</v-col>
</v-col>
<v-col
cols=
"12"
>
<v-col
cols=
"12"
>
...
@@ -384,7 +386,7 @@
...
@@ -384,7 +386,7 @@
dark
dark
x-small
x-small
color=
"red"
color=
"red"
@
click=
"removeVariant(index)"
@
click=
"removeVariant(index
, variant.id
)"
>
>
<v-icon
dark
>
<v-icon
dark
>
mdi-minus
mdi-minus
...
@@ -416,12 +418,11 @@
...
@@ -416,12 +418,11 @@
</v-card-actions>
</v-card-actions>
</v-card>
</v-card>
</v-dialog>
</v-dialog>
<!-- table -->
<div>
<div>
<v-data-table
<v-data-table
:headers=
"headers"
:headers=
"headers"
:items=
"products"
:items=
"products"
sort-by=
"c
alories
"
sort-by=
"c
reated_at
"
class=
"elevation-1"
class=
"elevation-1"
>
>
<
template
#top
>
<
template
#top
>
...
@@ -431,6 +432,9 @@
...
@@ -431,6 +432,9 @@
<v-spacer
/>
<v-spacer
/>
</v-toolbar>
</v-toolbar>
</
template
>
</
template
>
<
template
#
[`
item
.
index
`
]=
"{ index }"
>
{{
index
+
1
}}
</
template
>
<
template
#
[`
item
.
actions
`
]=
"{ item }"
>
<
template
#
[`
item
.
actions
`
]=
"{ item }"
>
<v-icon
:id=
"item.id"
small
@
click=
"editProduct(item)"
>
<v-icon
:id=
"item.id"
small
@
click=
"editProduct(item)"
>
mdi-pencil
mdi-pencil
...
@@ -460,7 +464,7 @@ export default {
...
@@ -460,7 +464,7 @@ export default {
return
{
return
{
name
:
''
,
name
:
''
,
id
:
''
,
id
:
''
,
category_id
:
null
,
category_id
:
''
,
price
:
''
,
price
:
''
,
stock
:
''
,
stock
:
''
,
description
:
''
,
description
:
''
,
...
@@ -483,13 +487,13 @@ export default {
...
@@ -483,13 +487,13 @@ export default {
options
:
[],
options
:
[],
headers
:
[
headers
:
[
{
{
text
:
'
Name
'
,
text
:
'
#
'
,
align
:
'
start
'
,
align
:
'
start
'
,
sortable
:
false
,
sortable
:
false
,
value
:
'
name
'
value
:
'
index
'
},
},
{
text
:
'
id
'
,
value
:
'
id
'
},
{
text
:
'
name
'
,
value
:
'
name
'
},
{
text
:
'
category
ID
'
,
value
:
'
category_id
'
},
{
text
:
'
category
'
,
value
:
'
category.name
'
},
{
text
:
'
price
'
,
value
:
'
price
'
,
sortable
:
false
},
{
text
:
'
price
'
,
value
:
'
price
'
,
sortable
:
false
},
{
text
:
'
description
'
,
value
:
'
description
'
},
{
text
:
'
description
'
,
value
:
'
description
'
},
{
text
:
'
stock
'
,
value
:
'
stock
'
},
{
text
:
'
stock
'
,
value
:
'
stock
'
},
...
@@ -584,7 +588,7 @@ export default {
...
@@ -584,7 +588,7 @@ export default {
this
.
images
=
[]
this
.
images
=
[]
this
.
products
=
[]
this
.
products
=
[]
this
.
product
=
[]
this
.
product
=
[]
this
.
categories
=
[]
this
.
categories
=
''
this
.
sName
=
''
this
.
sName
=
''
this
.
sCategoryId
=
''
this
.
sCategoryId
=
''
this
.
sPrice
=
''
this
.
sPrice
=
''
...
@@ -596,7 +600,6 @@ export default {
...
@@ -596,7 +600,6 @@ export default {
color
:
''
,
color
:
''
,
size
:
''
,
size
:
''
,
quantity
:
''
quantity
:
''
}
}
]
]
},
},
...
@@ -703,6 +706,7 @@ export default {
...
@@ -703,6 +706,7 @@ export default {
duration
:
3000
duration
:
3000
})
})
})
})
this
.
getProducts
()
},
},
deleteProduct
(
ID
,
index
)
{
deleteProduct
(
ID
,
index
)
{
const
self
=
this
const
self
=
this
...
@@ -768,17 +772,19 @@ export default {
...
@@ -768,17 +772,19 @@ export default {
fd
.
append
(
'
price
'
,
this
.
ePrice
)
fd
.
append
(
'
price
'
,
this
.
ePrice
)
fd
.
append
(
'
category_id
'
,
this
.
eCategoryId
)
fd
.
append
(
'
category_id
'
,
this
.
eCategoryId
)
fd
.
append
(
'
description
'
,
this
.
eDescription
)
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
}
][id]`
,
this
.
eVariants
[
i
].
id
)
}
fd
.
append
(
`variants[
${
i
}
][color]`
,
this
.
eVariants
[
i
].
color
)
fd
.
append
(
`variants[
${
i
}
][color]`
,
this
.
eVariants
[
i
].
color
)
fd
.
append
(
`variants[
${
i
}
][quantity]`
,
this
.
eVariants
[
i
].
quantity
)
fd
.
append
(
`variants[
${
i
}
][quantity]`
,
this
.
eVariants
[
i
].
quantity
)
fd
.
append
(
`variants[
${
i
}
][size]`
,
this
.
eVariants
[
i
].
size
)
fd
.
append
(
`variants[
${
i
}
][size]`
,
this
.
eVariants
[
i
].
size
)
}
}
}
if
(
this
.
eImages
)
{
for
(
let
j
=
0
;
j
<
this
.
eImages
.
length
;
j
++
)
{
for
(
let
j
=
0
;
j
<
this
.
eImages
.
length
;
j
++
)
{
fd
.
append
(
`images[
${
j
}
]`
,
this
.
eImages
[
j
])
fd
.
append
(
`images[
${
j
}
]`
,
this
.
eImages
[
j
])
}
}
}
const
currentPostIndex
=
this
.
editedIndex
const
currentPostIndex
=
this
.
editedIndex
try
{
try
{
this
.
$axios
this
.
$axios
...
@@ -798,6 +804,7 @@ export default {
...
@@ -798,6 +804,7 @@ export default {
this.editedItem = response.data.data
this.editedItem = response.data.data
Object.assign(this.products[currentPostIndex], this.editedItem)
Object.assign(this.products[currentPostIndex], this.editedItem)
})
})
this.getProducts()
} catch (error) {
} catch (error) {
console.log(error)
console.log(error)
}
}
...
@@ -819,8 +826,29 @@ export default {
...
@@ -819,8 +826,29 @@ export default {
remove (index) {
remove (index) {
this.variants.splice(index, 1)
this.variants.splice(index, 1)
},
},
removeVariant (index) {
removeVariant (index, id = null) {
if (confirm('Do you really want to delete?')) {
const self = this
if (id !== null) {
try {
this.$axios.post(`
/
products
/
delete
-
variant
/
$
{
id
}
`,
{
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(index, 1)
this.eVariants.splice(index, 1)
}
},
},
seeVariant () {
seeVariant () {
console.log(this.variants)
console.log(this.variants)
...
...
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