Commit 6cc1f845 authored by TTS Tran Viet Anh's avatar TTS Tran Viet Anh

Merge branch 'feature/product-ui' into 'feature/UI-vuetify'

update product ui

See merge request !18
parents 41585dec c8125a6f
...@@ -502,6 +502,15 @@ ...@@ -502,6 +502,15 @@
<template #[`item.index`]="{ index }"> <template #[`item.index`]="{ index }">
{{ index + 1 }} {{ index + 1 }}
</template> </template>
<template #[`item.variants`]="{ item }">
{{ item.variants_count }}
</template>
<template #[`item.status`]="{ item }">
<v-switch
v-model="item.status"
@click="switchStatus(item)"
/>
</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
...@@ -537,6 +546,7 @@ export default { ...@@ -537,6 +546,7 @@ export default {
stock: '', stock: '',
description: '', description: '',
images: [], images: [],
status: '',
variants: [ variants: [
{ {
color: '', color: '',
...@@ -565,6 +575,8 @@ export default { ...@@ -565,6 +575,8 @@ export default {
{ text: 'Category', value: 'category.name' }, { text: 'Category', value: 'category.name' },
{ text: 'Price', value: 'price' }, { text: 'Price', value: 'price' },
{ text: 'Stock', value: 'stock' }, { text: 'Stock', value: 'stock' },
{ text: 'Variants', value: 'variants' },
{ text: 'Status', value: 'status' },
{ text: 'Actions', value: 'actions', sortable: false } { text: 'Actions', value: 'actions', sortable: false }
], ],
items: [ items: [
...@@ -874,7 +886,7 @@ export default { ...@@ -874,7 +886,7 @@ export default {
} }
) )
.then((response) => { .then((response) => {
self.$toast.success('User updated successfully!', { self.$toast.success('Product updated successfully!', {
duration: 3000 duration: 3000
}) })
console.log(response) console.log(response)
...@@ -955,6 +967,30 @@ export default { ...@@ -955,6 +967,30 @@ export default {
}, },
clearImage () { clearImage () {
this.files.length = 0 this.files.length = 0
},
switchStatus (item) {
const status = item.status ? 1 : 0
const self = this
const fd = new FormData()
fd.append('status', status)
try {
this.$axios
.post(`/products/update-status/${item.id}`,
fd, {
headers: {
Authorization: `Bearer ${this.$auth.$storage.getUniversal('token')}`
}
}
)
.then((response) => {
console.log(response)
self.$toast.success('Updated status successfully!', {
duration: 3000
})
})
} catch (error) {
console.log(error)
}
} }
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment