Commit 4b0a2154 authored by TTS Kieu Tuan Anh's avatar TTS Kieu Tuan Anh

resolve

parent 08b143ed
...@@ -52,36 +52,6 @@ ...@@ -52,36 +52,6 @@
</div> </div>
</template> </template>
</v-autocomplete> </v-autocomplete>
<!-- <v-card class="mx-auto" max-width="500" dark>
<v-sheet>
<v-text-field
v-model="search"
label="Search Category"
dark
flat
solo-inverted
hide-details
clearable
clear-icon="mdi-close-circle-outline"
/>
</v-sheet>
<v-card-text>
<v-treeview
v-model="eParentId"
:items="categoryTrees"
:search="search"
:filter="filter"
:open.sync="open"
selectable
transition
item-value="id"
selected-color="primary"
selection-type="independent"
@update:open="onOpen"
@input="selectCategory"
/>
</v-card-text>
</v-card> -->
</v-col> </v-col>
<v-col cols="12"> <v-col cols="12">
<v-file-input <v-file-input
...@@ -110,7 +80,6 @@ ...@@ -110,7 +80,6 @@
</v-row> </v-row>
</v-form> </v-form>
</v-container> </v-container>
<small>*indicates required field</small>
</v-card-text> </v-card-text>
<v-card-actions> <v-card-actions>
<v-spacer /> <v-spacer />
...@@ -212,37 +181,6 @@ ...@@ -212,37 +181,6 @@
</template> </template>
</v-autocomplete> </v-autocomplete>
</v-col> </v-col>
<!-- <v-col cols="12">
<v-card class="mx-auto" max-width="500" dark>
<v-sheet>
<v-text-field
v-model="search"
label="Search Category"
dark
flat
solo-inverted
hide-details
clearable
clear-icon="mdi-close-circle-outline"
/>
</v-sheet>
<v-card-text>
<v-treeview
v-model="parent_id"
:items="categoryTrees"
:search="search"
:filter="filter"
:open.sync="open"
selectable
transition
item-value="id"
selected-color="primary"
selection-type="independent"
:rules="singleRules"
/>
</v-card-text>
</v-card>
</v-col> -->
<v-col cols="12"> <v-col cols="12">
<v-file-input <v-file-input
v-model="image" v-model="image"
...@@ -256,7 +194,6 @@ ...@@ -256,7 +194,6 @@
</v-col> </v-col>
</v-row> </v-row>
</v-container> </v-container>
<small>*indicates required field</small>
</v-card-text> </v-card-text>
<v-card-actions> <v-card-actions>
<v-spacer /> <v-spacer />
......
...@@ -11,86 +11,6 @@ ...@@ -11,86 +11,6 @@
</v-breadcrumbs> </v-breadcrumbs>
</div> </div>
<div style="float: right" /> <div style="float: right" />
<!-- modal-show -->
<v-dialog
v-model="dialog2"
persistent
max-width="600px"
>
<v-card>
<v-card-title>
<span class="text-h5">POST</span>
</v-card-title>
<v-card-text>
<v-container>
<v-row>
<v-col
cols="12"
sm="6"
md="4"
>
<v-text-field
v-model="sTitle"
label="Title"
readonly
/>
</v-col>
<v-col
cols="12"
>
<v-select
v-model="sCategoryId"
:items="categories"
item-text="name"
item-value="id"
label="Category"
readonly
/>
</v-col>
<v-col cols="12">
<v-textarea
v-model="sContent"
label="Content"
word-break="break-word"
readonly
/>
</v-col>
<v-col
cols="12"
>
<v-select
v-model="sStatus"
:items="statusDefault"
item-text="name"
item-value="id"
label="Status"
readonly
/>
</v-col>
<v-col cols="12">
<!-- <v-col v-for="(image, index) in sImages" :key="index" cols="12">
<v-img :src="image"/> </v-col> -->
<v-img
v-if="typeof sImages == 'string'"
:src="sImages"
/>
</v-col>
</v-row>
</v-container>
<small>*indicates required field</small>
</v-card-text>
<v-card-actions>
<v-spacer />
<v-btn
color="blue darken-1"
text
@click="dialog2 = false"
>
Close
</v-btn>
</v-card-actions>
</v-card>
</v-dialog>
<!-- modal-edit --> <!-- modal-edit -->
<v-dialog <v-dialog
v-model="dialog" v-model="dialog"
...@@ -120,14 +40,29 @@ ...@@ -120,14 +40,29 @@
<v-col <v-col
cols="12" cols="12"
> >
<v-select <!-- <v-select
v-model="eCategoryId" v-model="eCategoryId"
:items="categories" :items="categories"
item-text="name" item-text="name"
item-value="id" item-value="id"
label="Category" label="Category"
:rules="requiredRules" :rules="requiredRules"
/> /> -->
<v-autocomplete
v-model="eCategoryId"
:items="
categories.filter((category) => category.id !== eId)
"
item-text="name"
item-value="id"
label="Category"
>
<template #item="{item}">
<div :class="`category-${item.depth}`">
{{ item.name }}
</div>
</template>
</v-autocomplete>
</v-col> </v-col>
<v-col cols="12"> <v-col cols="12">
<v-textarea <v-textarea
...@@ -169,9 +104,18 @@ ...@@ -169,9 +104,18 @@
:src="file" :src="file"
> >
</v-col> </v-col>
<v-col cols="12" text-align=" left">
<v-img
v-for="(imageEdit, index) in eImages"
:key="index"
contain
height="100px"
width="150px"
:src="imageEdit"
/>
</v-col>
</v-row> </v-row>
</v-container> </v-container>
<small>*indicates required field</small>
</v-card-text> </v-card-text>
<v-card-actions> <v-card-actions>
<v-spacer /> <v-spacer />
...@@ -213,7 +157,7 @@ ...@@ -213,7 +157,7 @@
</v-dialog> </v-dialog>
<!-- table --> <!-- table -->
<div> <div>
<v-data-table :headers="headers" :items="posts" :search="searchTable" sort-by="calories" class="elevation-1" > <v-data-table :headers="headers" :items="posts" :search="searchTable" sort-by="calories" class="elevation-1">
<template #top> <template #top>
<v-toolbar flat> <v-toolbar flat>
<v-text-field <v-text-field
...@@ -265,14 +209,22 @@ ...@@ -265,14 +209,22 @@
<v-col <v-col
cols="12" cols="12"
> >
<v-select <v-autocomplete
v-model="category_id" v-model="category_id"
:items="categories" :items="categories"
:search="search"
:filter="filter"
item-text="name" item-text="name"
item-value="id" item-value="id"
label="Category" label="Category"
:rules="requiredRules" :rules="requiredRules"
/> >
<template #item="{item}">
<div :class="`category-${item.depth}`">
{{ item.name }}
</div>
</template>
</v-autocomplete>
</v-col> </v-col>
<v-col cols="12"> <v-col cols="12">
<v-textarea <v-textarea
...@@ -317,7 +269,6 @@ ...@@ -317,7 +269,6 @@
</v-col> </v-col>
</v-row> </v-row>
</v-container> </v-container>
<small>*indicates required field</small>
</v-card-text> </v-card-text>
<v-card-actions> <v-card-actions>
<v-spacer /> <v-spacer />
...@@ -361,9 +312,6 @@ ...@@ -361,9 +312,6 @@
<v-icon :id="item.id" small @click="dialogDelete = true; getID(item)"> <v-icon :id="item.id" small @click="dialogDelete = true; getID(item)">
mdi-delete mdi-delete
</v-icon> </v-icon>
<v-icon :id="item.id" small @click="showPost(item)">
mdi-account-details
</v-icon>
</template> </template>
<template #no-data> <template #no-data>
<v-btn color="primary" @click="initialize"> <v-btn color="primary" @click="initialize">
...@@ -383,16 +331,17 @@ export default { ...@@ -383,16 +331,17 @@ export default {
middleware: ['web'], middleware: ['web'],
data: () => { data: () => {
return { return {
filter: '',
search: '',
searchTable: '', searchTable: '',
file: null, file: null,
dialog1: false, dialog1: false,
dialog2: false,
title: '', title: '',
category_id: null, category_id: null,
content: '', content: '',
user_id: '', user_id: '',
status: null, status: null,
images: [], images: null,
dialog: false, dialog: false,
dialogDelete: false, dialogDelete: false,
headers: [ headers: [
...@@ -437,19 +386,13 @@ export default { ...@@ -437,19 +386,13 @@ export default {
posts: [], posts: [],
categories: [], categories: [],
users: [], users: [],
sTitle: '',
sCategoryId: '',
sContent: '',
sUserId: '',
sStatus: [],
sImages: [],
eId: '', eId: '',
eTitle: '', eTitle: '',
eCategoryId: [], eCategoryId: [],
eContent: '', eContent: '',
eUserId: '', eUserId: '',
eStatus: '', eStatus: '',
eImages: [], eImages: null,
message: [], message: [],
editedIndex: -1, editedIndex: -1,
editedItem: { editedItem: {
...@@ -620,14 +563,14 @@ export default { ...@@ -620,14 +563,14 @@ export default {
}) })
}, },
getID (item) { getID (item) {
this.eID = item.id this.eId = item.id
this.editedIndex = this.categories.indexOf(item) this.editedIndex = this.categories.indexOf(item)
}, },
deletePost () { deletePost () {
const self = this const self = this
const currentPostIndex = this.editedIndex const currentPostIndex = this.editedIndex
this.$axios this.$axios
.delete(`/posts/${this.eID}`, { .delete(`/posts/${this.eId}`, {
headers: { headers: {
Authorization: `Bearer ${this.$auth.$storage.getUniversal('token')}` Authorization: `Bearer ${this.$auth.$storage.getUniversal('token')}`
} }
...@@ -645,31 +588,13 @@ export default { ...@@ -645,31 +588,13 @@ export default {
}) })
}) })
}, },
async showPost (item) {
const ID = item.id
try {
const resp = await this.$axios.get(`/posts/${ID}`, {
headers: {
Authorization: `Bearer ${this.$auth.$storage.getUniversal('token')}`
}
})
this.sTitle = resp.data.data.title
this.sContent = resp.data.data.content
this.sCategoryId = resp.data.data.category_id
this.sStatus = resp.data.data.status
this.sImages = resp.data.data.images
} catch (error) {
console.log(error)
}
this.dialog2 = true
},
editPost (item) { editPost (item) {
this.eId = item.id this.eId = item.id
this.eTitle = item.title this.eTitle = item.title
this.eCategoryId = item.category_id this.eCategoryId = item.category_id
this.eContent = item.content this.eContent = item.content
this.eStatus = item.status this.eStatus = item.status
this.eImages = [] this.eImages = item.images
this.editedIndex = this.posts.indexOf(item) this.editedIndex = this.posts.indexOf(item)
console.log(this.editedIndex) console.log(this.editedIndex)
this.dialog = true this.dialog = true
...@@ -733,6 +658,15 @@ export default { ...@@ -733,6 +658,15 @@ export default {
</script> </script>
<style> <style>
.category-1 {
padding-left: 30px !important;
}
.category-2 {
padding-left: 60px !important;
}
.category-3 {
padding-left: 90px !important;
}
img { img {
width: 100%; width: 100%;
height: 100%; height: 100%;
......
...@@ -7,112 +7,6 @@ ...@@ -7,112 +7,6 @@
</template> </template>
</v-breadcrumbs> </v-breadcrumbs>
</div> </div>
<!-- show-modal -->
<v-dialog
v-model="dialog2"
persistent
max-width="600px"
>
<v-card>
<v-card-title>
<span class="text-h5">PRODUCT</span>
</v-card-title>
<v-card-text>
<v-container>
<v-row>
<v-col
cols="12"
sm="6"
md="4"
>
<v-text-field
v-model="sName"
label="Name"
readonly
/>
</v-col>
<v-col
cols="12"
>
<v-select
v-model="sCategoryId"
:items="categories"
item-text="name"
item-value="id"
label="Category"
readonly
/>
</v-col>
<v-col cols="12">
<v-text-field
v-model="sPrice"
label="Price"
readonly
/>
</v-col>
<v-col cols="12">
<v-text-field
v-model="sDescription"
label="Description"
readonly
/>
</v-col>
<v-col v-for="(image, index) in sImages" :key="index" cols="12">
<v-img :src="image" contain />
</v-col>
<v-col cols="12" />
<v-row v-for="(variant, index) in sVariants" :key="'A' +index">
<v-col
cols="12"
sm="6"
md="4"
>
<v-text-field
v-model="variant.color"
label="Color"
readonly
/>
</v-col>
<v-col
cols="12"
sm="6"
md="4"
>
<v-text-field
v-model="variant.size"
label="Size"
readonly
/>
</v-col>
<v-col
cols="12"
sm="6"
md="4"
>
<v-text-field
v-model="variant.quantity"
label="Quantity"
readonly
/>
</v-col>
<v-col />
</v-row>
</v-row>
</v-container>
</v-card-text>
<v-card-actions>
<v-spacer />
<v-btn
color="blue darken-1"
text
type="submit"
@click="dialog2 = false"
>
Close
</v-btn>
</v-card-actions>
</v-card>
</v-dialog>
<!-- edit-modal --> <!-- edit-modal -->
<v-dialog <v-dialog
v-model="dialog3" v-model="dialog3"
...@@ -270,7 +164,6 @@ ...@@ -270,7 +164,6 @@
</v-row> </v-row>
</v-row> </v-row>
</v-container> </v-container>
<small>*indicates required field</small>
</v-card-text> </v-card-text>
<v-card-actions> <v-card-actions>
<v-spacer /> <v-spacer />
...@@ -428,15 +321,15 @@ ...@@ -428,15 +321,15 @@
@click:clear="clearImage" @click:clear="clearImage"
/> />
</v-col> </v-col>
<v-col v-if="files" cols="12" style="display:flex; text-align:left"> <v-col v-if="files" cols="12" style="display:flex; justify-content: space-around;">
<v-img <img
v-for="(image, index) in files" v-for="(image, index) in files"
:key="index" :key="index"
:src="image" :src="image"
contain contain
height="100px" height="100px"
width="150px" width="150px"
/> >
</v-col> </v-col>
<v-col cols="12"> <v-col cols="12">
<v-btn <v-btn
...@@ -507,7 +400,6 @@ ...@@ -507,7 +400,6 @@
</v-row> </v-row>
</v-row> </v-row>
</v-container> </v-container>
<small>*indicates required field</small>
</v-card-text> </v-card-text>
<v-card-actions> <v-card-actions>
<v-spacer /> <v-spacer />
...@@ -551,9 +443,6 @@ ...@@ -551,9 +443,6 @@
<v-icon :id="item.id" small @click="dialogDelete = true; getID(item)"> <v-icon :id="item.id" small @click="dialogDelete = true; getID(item)">
mdi-delete mdi-delete
</v-icon> </v-icon>
<v-icon :id="item.id" small @click="showProduct(item)">
mdi-account-details
</v-icon>
</template> </template>
<template #no-data> <template #no-data>
<v-btn color="primary" @click="initialize"> <v-btn color="primary" @click="initialize">
...@@ -593,7 +482,6 @@ export default { ...@@ -593,7 +482,6 @@ export default {
quantity: '', quantity: '',
dialog: false, dialog: false,
dialog1: false, dialog1: false,
dialog2: false,
dialog3: false, dialog3: false,
dialogDelete: false, dialogDelete: false,
dialogDeleteVariant: false, dialogDeleteVariant: false,
...@@ -631,19 +519,6 @@ export default { ...@@ -631,19 +519,6 @@ export default {
product: [], product: [],
categories: [], categories: [],
categoryTrees: [], categoryTrees: [],
sName: '',
sCategoryId: '',
sPrice: '',
sDescription: '',
sStock: '',
sImages: [],
sVariants: [
{
color: '',
size: '',
quantity: ''
}
],
idVariant: '', idVariant: '',
editedVariantIndex: '', editedVariantIndex: '',
eId: '', eId: '',
...@@ -875,27 +750,6 @@ export default { ...@@ -875,27 +750,6 @@ export default {
console.log(error) console.log(error)
} }
}, },
async showProduct (item) {
const ID = item.id
try {
const resp = await this.$axios.get(`/products/${ID}`, {
method: 'GET',
headers: {
Authorization: `Bearer ${this.$auth.$storage.getUniversal('token')}`
}
})
this.sName = resp.data.data.name
this.sPrice = resp.data.data.price
this.sCategoryId = resp.data.data.category_id
this.sDescription = resp.data.data.description
this.sStock = resp.data.data.stock
this.sVariants = resp.data.data.variants
this.sImages = resp.data.data.images
} catch (error) {
console.log(error)
}
this.dialog2 = true
},
editProduct (item) { editProduct (item) {
this.eId = item.id this.eId = item.id
this.eName = item.name this.eName = item.name
...@@ -973,27 +827,8 @@ export default { ...@@ -973,27 +827,8 @@ export default {
this.idVariant = item.id this.idVariant = item.id
}, },
removeVariant () { removeVariant () {
const self = this
const currentVariantIndex = this.editedVariantIndex 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) this.eVariants.splice(currentVariantIndex, 1)
}
}, },
fileSelected (event) { fileSelected (event) {
if (event) { if (event) {
......
...@@ -38,7 +38,6 @@ ...@@ -38,7 +38,6 @@
</v-row> </v-row>
</v-form> </v-form>
</v-container> </v-container>
<small>*indicates required field</small>
</v-card-text> </v-card-text>
<v-card-actions> <v-card-actions>
<v-spacer /> <v-spacer />
...@@ -150,7 +149,6 @@ ...@@ -150,7 +149,6 @@
</v-row> </v-row>
</v-form> </v-form>
</v-container> </v-container>
<small>*indicates required field</small>
</v-card-text> </v-card-text>
<v-card-actions> <v-card-actions>
<v-spacer /> <v-spacer />
......
...@@ -12,6 +12,13 @@ export default function ({ $axios }, inject, redirect) { ...@@ -12,6 +12,13 @@ export default function ({ $axios }, inject, redirect) {
} }
}) })
$axios.onError((error) => {
const code = parseInt(error.response && error.response.status)
if (code === 403) {
redirect('/login')
}
})
const api = $axios.create({ const api = $axios.create({
headers: { headers: {
common: { common: {
......
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