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

resolve

parent 08b143ed
......@@ -52,36 +52,6 @@
</div>
</template>
</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 cols="12">
<v-file-input
......@@ -110,7 +80,6 @@
</v-row>
</v-form>
</v-container>
<small>*indicates required field</small>
</v-card-text>
<v-card-actions>
<v-spacer />
......@@ -212,37 +181,6 @@
</template>
</v-autocomplete>
</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-file-input
v-model="image"
......@@ -256,7 +194,6 @@
</v-col>
</v-row>
</v-container>
<small>*indicates required field</small>
</v-card-text>
<v-card-actions>
<v-spacer />
......
......@@ -11,86 +11,6 @@
</v-breadcrumbs>
</div>
<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 -->
<v-dialog
v-model="dialog"
......@@ -120,14 +40,29 @@
<v-col
cols="12"
>
<v-select
<!-- <v-select
v-model="eCategoryId"
:items="categories"
item-text="name"
item-value="id"
label="Category"
: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 cols="12">
<v-textarea
......@@ -169,9 +104,18 @@
:src="file"
>
</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-container>
<small>*indicates required field</small>
</v-card-text>
<v-card-actions>
<v-spacer />
......@@ -213,7 +157,7 @@
</v-dialog>
<!-- table -->
<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>
<v-toolbar flat>
<v-text-field
......@@ -265,14 +209,22 @@
<v-col
cols="12"
>
<v-select
<v-autocomplete
v-model="category_id"
:items="categories"
:search="search"
:filter="filter"
item-text="name"
item-value="id"
label="Category"
:rules="requiredRules"
/>
>
<template #item="{item}">
<div :class="`category-${item.depth}`">
{{ item.name }}
</div>
</template>
</v-autocomplete>
</v-col>
<v-col cols="12">
<v-textarea
......@@ -317,7 +269,6 @@
</v-col>
</v-row>
</v-container>
<small>*indicates required field</small>
</v-card-text>
<v-card-actions>
<v-spacer />
......@@ -361,9 +312,6 @@
<v-icon :id="item.id" small @click="dialogDelete = true; getID(item)">
mdi-delete
</v-icon>
<v-icon :id="item.id" small @click="showPost(item)">
mdi-account-details
</v-icon>
</template>
<template #no-data>
<v-btn color="primary" @click="initialize">
......@@ -383,16 +331,17 @@ export default {
middleware: ['web'],
data: () => {
return {
filter: '',
search: '',
searchTable: '',
file: null,
dialog1: false,
dialog2: false,
title: '',
category_id: null,
content: '',
user_id: '',
status: null,
images: [],
images: null,
dialog: false,
dialogDelete: false,
headers: [
......@@ -437,19 +386,13 @@ export default {
posts: [],
categories: [],
users: [],
sTitle: '',
sCategoryId: '',
sContent: '',
sUserId: '',
sStatus: [],
sImages: [],
eId: '',
eTitle: '',
eCategoryId: [],
eContent: '',
eUserId: '',
eStatus: '',
eImages: [],
eImages: null,
message: [],
editedIndex: -1,
editedItem: {
......@@ -620,14 +563,14 @@ export default {
})
},
getID (item) {
this.eID = item.id
this.eId = item.id
this.editedIndex = this.categories.indexOf(item)
},
deletePost () {
const self = this
const currentPostIndex = this.editedIndex
this.$axios
.delete(`/posts/${this.eID}`, {
.delete(`/posts/${this.eId}`, {
headers: {
Authorization: `Bearer ${this.$auth.$storage.getUniversal('token')}`
}
......@@ -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) {
this.eId = item.id
this.eTitle = item.title
this.eCategoryId = item.category_id
this.eContent = item.content
this.eStatus = item.status
this.eImages = []
this.eImages = item.images
this.editedIndex = this.posts.indexOf(item)
console.log(this.editedIndex)
this.dialog = true
......@@ -733,6 +658,15 @@ export default {
</script>
<style>
.category-1 {
padding-left: 30px !important;
}
.category-2 {
padding-left: 60px !important;
}
.category-3 {
padding-left: 90px !important;
}
img {
width: 100%;
height: 100%;
......
......@@ -7,112 +7,6 @@
</template>
</v-breadcrumbs>
</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 -->
<v-dialog
v-model="dialog3"
......@@ -270,7 +164,6 @@
</v-row>
</v-row>
</v-container>
<small>*indicates required field</small>
</v-card-text>
<v-card-actions>
<v-spacer />
......@@ -428,15 +321,15 @@
@click:clear="clearImage"
/>
</v-col>
<v-col v-if="files" cols="12" style="display:flex; text-align:left">
<v-img
<v-col v-if="files" cols="12" style="display:flex; justify-content: space-around;">
<img
v-for="(image, index) in files"
:key="index"
:src="image"
contain
height="100px"
width="150px"
/>
>
</v-col>
<v-col cols="12">
<v-btn
......@@ -507,7 +400,6 @@
</v-row>
</v-row>
</v-container>
<small>*indicates required field</small>
</v-card-text>
<v-card-actions>
<v-spacer />
......@@ -551,9 +443,6 @@
<v-icon :id="item.id" small @click="dialogDelete = true; getID(item)">
mdi-delete
</v-icon>
<v-icon :id="item.id" small @click="showProduct(item)">
mdi-account-details
</v-icon>
</template>
<template #no-data>
<v-btn color="primary" @click="initialize">
......@@ -593,7 +482,6 @@ export default {
quantity: '',
dialog: false,
dialog1: false,
dialog2: false,
dialog3: false,
dialogDelete: false,
dialogDeleteVariant: false,
......@@ -631,19 +519,6 @@ export default {
product: [],
categories: [],
categoryTrees: [],
sName: '',
sCategoryId: '',
sPrice: '',
sDescription: '',
sStock: '',
sImages: [],
sVariants: [
{
color: '',
size: '',
quantity: ''
}
],
idVariant: '',
editedVariantIndex: '',
eId: '',
......@@ -875,27 +750,6 @@ export default {
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) {
this.eId = item.id
this.eName = item.name
......@@ -973,27 +827,8 @@ export default {
this.idVariant = item.id
},
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)
}
},
fileSelected (event) {
if (event) {
......
......@@ -38,7 +38,6 @@
</v-row>
</v-form>
</v-container>
<small>*indicates required field</small>
</v-card-text>
<v-card-actions>
<v-spacer />
......@@ -150,7 +149,6 @@
</v-row>
</v-form>
</v-container>
<small>*indicates required field</small>
</v-card-text>
<v-card-actions>
<v-spacer />
......
......@@ -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({
headers: {
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