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
529568ba
Commit
529568ba
authored
Feb 08, 2023
by
vietanh-0511
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update product management
parent
2c2ff775
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
52 additions
and
37 deletions
+52
-37
index.vue
pages/products/index.vue
+52
-37
No files found.
pages/products/index.vue
View file @
529568ba
<!-- eslint-disable vue/require-v-for-key -->
<!-- eslint-disable vue/valid-v-slot -->
<
template
>
<div>
<div>
...
...
@@ -43,18 +41,16 @@
required
/>
</v-col>
<v-col
cols=
"12"
>
<v-treeview
<v-col
cols=
"12"
>
<v-select
v-model=
"category_id"
:items=
"categories"
:selection-type=
"independent"
:multiple-active=
"false"
shaped
hoverable
activatable
item-text=
"name"
item-value=
"id"
menu-props=
"auto"
label=
"Select category"
hide-details
single-line
/>
</v-col>
<v-col
cols=
"12"
>
...
...
@@ -301,14 +297,15 @@
<v-col
cols=
"12"
>
<v-
treeview
<v-
select
v-model=
"eCategoryId"
:items=
"categories"
:selection-type=
"independent"
:multiple-active=
"false"
shaped
hoverable
activatable
item-text=
"name"
item-value=
"id"
menu-props=
"auto"
label=
"Select category"
hide-details
single-line
/>
</v-col>
<v-col
cols=
"12"
>
...
...
@@ -389,7 +386,7 @@
dark
x-small
color=
"red"
@
click=
"removeVariant(index)"
@
click=
"removeVariant(index
, variant.id
)"
>
<v-icon
dark
>
mdi-minus
...
...
@@ -425,7 +422,7 @@
<v-data-table
:headers=
"headers"
:items=
"products"
sort-by=
"c
alories
"
sort-by=
"c
reated_at
"
class=
"elevation-1"
>
<
template
#top
>
...
...
@@ -435,6 +432,9 @@
<v-spacer
/>
</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
...
...
@@ -464,7 +464,7 @@ export default {
return
{
name
:
''
,
id
:
''
,
category_id
:
[]
,
category_id
:
''
,
price
:
''
,
stock
:
''
,
description
:
''
,
...
...
@@ -486,13 +486,13 @@ export default {
options
:
[],
headers
:
[
{
text
:
'
Name
'
,
text
:
'
#
'
,
align
:
'
start
'
,
sortable
:
false
,
value
:
'
name
'
value
:
'
index
'
},
{
text
:
'
id
'
,
value
:
'
id
'
},
{
text
:
'
category
ID
'
,
value
:
'
category_id
'
},
{
text
:
'
name
'
,
value
:
'
name
'
},
{
text
:
'
category
'
,
value
:
'
category.name
'
},
{
text
:
'
price
'
,
value
:
'
price
'
,
sortable
:
false
},
{
text
:
'
description
'
,
value
:
'
description
'
},
{
text
:
'
stock
'
,
value
:
'
stock
'
},
...
...
@@ -530,7 +530,7 @@ export default {
],
eId
:
''
,
eName
:
''
,
eCategoryId
:
[]
,
eCategoryId
:
''
,
ePrice
:
''
,
eDescription
:
''
,
eStock
:
''
,
...
...
@@ -587,7 +587,7 @@ export default {
this
.
images
=
[]
this
.
products
=
[]
this
.
product
=
[]
this
.
categories
=
[]
this
.
categories
=
''
this
.
sName
=
''
this
.
sCategoryId
=
''
this
.
sPrice
=
''
...
...
@@ -599,7 +599,6 @@ export default {
color
:
''
,
size
:
''
,
quantity
:
''
}
]
},
...
...
@@ -686,7 +685,7 @@ export default {
,
{
headers
:
{
'
Content-Type
'
:
'
application/json;
multipart/form-data
'
,
'
Content-Type
'
:
'
multipart/form-data
'
,
Authorization
:
`Bearer
${
this
.
$auth
.
$storage
.
getUniversal
(
'
token
'
)}
`
,
Accept
:
'
application/json; multipart/form-data
'
}
...
...
@@ -706,6 +705,7 @@ export default {
duration
:
3000
})
})
this
.
getProducts
()
},
deleteProduct
(
ID
,
index
)
{
const
self
=
this
...
...
@@ -803,6 +803,7 @@ export default {
this.editedItem = response.data.data
Object.assign(this.products[currentPostIndex], this.editedItem)
})
this.getProducts()
} catch (error) {
console.log(error)
}
...
...
@@ -824,18 +825,32 @@ export default {
remove (index) {
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)
}
},
seeVariant () {
console.log(this.variants)
},
fetchCategories (item) {
return this.$axios
.get('/categories/')
.then(res => res.json())
.then(json => (item.children.push(...json)))
.catch(err => console.warn(err))
}
}
}
...
...
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