Commit 7ae0989e authored by TTS Kieu Tuan Anh's avatar TTS Kieu Tuan Anh

add search

parent 6cc1f845
......@@ -9,28 +9,28 @@
<v-app-bar-nav-icon />
<v-toolbar-title>
<v-btn href="/users">
<v-btn to="/users">
<span>USER</span>
<v-icon dense>
mdi-account
</v-icon>
</v-btn>
<v-btn href="/categories">
<v-btn to="/categories">
<span>CATEGORY</span>
<v-icon dense>
mdi-heart
</v-icon>
</v-btn>
<v-btn href="/products">
<v-btn to="/products">
<span>PRODUCT</span>
<v-icon dense>
mdi-briefcase
</v-icon>
</v-btn>
<v-btn href="/posts">
<v-btn to="/posts">
<span>POST</span>
<v-icon dense>
mdi-newspaper
......
......@@ -37,16 +37,16 @@
/>
</v-col>
<v-col cols="12">
<!-- <v-select
v-model="eParentId"
:items="
categories.filter((category) => category.id !== eID)
"
item-text="name"
item-value="id"
label="Parent"
/> -->
<v-card class="mx-auto" max-width="500" dark>
<v-autocomplete
v-model="eParentId"
:items="
categories.filter((category) => category.id !== eID)
"
item-text="name"
item-value="id"
label="Parent"
/>
<!-- <v-card class="mx-auto" max-width="500" dark>
<v-sheet>
<v-text-field
v-model="search"
......@@ -76,30 +76,31 @@
/>
</v-card-text>
</v-card>
</v-col>
<v-col cols="12">
<v-file-input
v-model="eImage"
accept="image/*"
label="Image"
prepend-icon="mdi-camera"
@change="fileSelected"
/>
</v-col>
<v-col cols="12">
<img
v-if="file"
:src="file"
>
</v-col>
<v-col cols="12" text-align=" left">
<v-img
v-if="typeof eImage === 'string'"
contain
height="100px"
width="150px"
:src="eImage"
/>
</v-col> -->
<v-col cols="12">
<v-file-input
v-model="eImage"
accept="image/*"
label="Image"
prepend-icon="mdi-camera"
@change="fileSelected"
/>
</v-col>
<v-col cols="12">
<img
v-if="file"
:src="file"
>
</v-col>
<v-col cols="12" text-align=" left">
<v-img
v-if="typeof eImage === 'string'"
contain
height="100px"
width="150px"
:src="eImage"
/>
</v-col>
</v-col>
</v-row>
</v-form>
......@@ -180,17 +181,19 @@
required
/>
</v-col>
<!-- <v-col cols="12">
<v-select
<v-col cols="12">
<v-autocomplete
v-model="parent_id"
:items="categories"
:search="search"
:filter="filter"
item-text="name"
item-value="id"
label="Parent*"
:rules="requiredRules"
/>
</v-col> -->
<v-col cols="12">
</v-col>
<!-- <v-col cols="12">
<v-card class="mx-auto" max-width="500" dark>
<v-sheet>
<v-text-field
......@@ -220,7 +223,7 @@
/>
</v-card-text>
</v-card>
</v-col>
</v-col> -->
<v-col cols="12">
<v-file-input
v-model="image"
......@@ -384,7 +387,7 @@ export default {
open: [1, 2],
search: null,
file: null,
parent_id: [],
parent_id: '',
name: '',
ordering: '',
image: null,
......@@ -417,7 +420,7 @@ export default {
eID: '',
eName: '',
eOrdering: '',
eParentId: [],
eParentId: '',
eImage: null,
message: [],
editedIndex: -1,
......@@ -458,10 +461,6 @@ export default {
numberRules: [
v => !!v || 'This field is required',
v => v > 0 || 'value must be a positive integer'
],
singleRules: [
v => !!v || 'This field is required',
v => v.length < 2 || 'Chose 1 pls -____-'
]
}
},
......@@ -481,20 +480,6 @@ export default {
},
dialogDelete (val) {
val || this.closeDelete()
},
eParentId: function () {
if (this.eParentId.length > 1) {
this.$toast.error('please chose 1 -___-!', {
duration: 3000
})
}
},
parent_id: function () {
if (this.parent_id.length > 1) {
this.$toast.error('please chose 1 -___-!', {
duration: 3000
})
}
}
},
created () {
......@@ -644,7 +629,7 @@ export default {
this.eID = item.id
this.eName = item.name
this.eOrdering = item.ordering
this.eParentId.push(item.parent_id)
this.eParentId = item.parent_id
this.eImage = item.image
this.editedIndex = this.categories.indexOf(item)
console.log(this.eID)
......@@ -685,13 +670,13 @@ export default {
}
},
clearData () {
this.parent_id.length = 0
this.parent_id = ''
this.name = ''
this.ordering = ''
this.image = null
},
clearEditData () {
this.eParentId.length = 0
this.eParentId = ''
this.eName = ''
this.eOrdering = ''
this.eImage = null
......@@ -706,22 +691,22 @@ export default {
},
clearFile () {
this.file = null
},
onOpen (e) {
if (!this.__initial) {
this.__initial = true
return
}
// this.eParentId.length = 0
console.log('toggle arrow clicked', e)
},
selectCategory (e) {
console.log(e[0])
console.log(this.eParentId)
// this.eParentId.length = 0
// this.eParentId.push(e[0])
}
// onOpen (e) {
// if (!this.__initial) {
// this.__initial = true
// return
// }
// // this.eParentId.length = 0
// console.log('toggle arrow clicked', e)
// },
// selectCategory (e) {
// console.log(e[0])
// console.log(this.eParentId)
// // this.eParentId.length = 0
// // this.eParentId.push(e[0])
// }
}
}
</script>
......
......@@ -174,13 +174,20 @@
@click:clear="clearImage"
/>
</v-col>
<v-col v-if="files" cols="12">
<v-col v-for="(image, index) in files" :key="index" cols="12">
<v-img :src="image" contain height="100px" width="150px" display:flex/>
</v-col>
<v-col v-if="files" cols="12" style="display:flex; text-align:left">
<v-img
v-for="(image, index) in files"
:key="index"
:src="image"
contain
height="100px"
width="150px"
/>
</v-col>
<v-col v-for="(imageEdit, index) in eImages" :key="index" cols="12" text-align=" left" style="display:flex" >
<v-col cols="12" style="display:flex; text-align:left">
<v-img
v-for="(imageEdit, index) in eImages"
:key="index"
contain
height="100px"
width="150px"
......@@ -400,10 +407,15 @@
@click:clear="clearImage"
/>
</v-col>
<v-col v-if="files" cols="12">
<v-col v-for="(image, index) in files" :key="index" cols="12">
<v-img :src="image" contain />
</v-col>
<v-col v-if="files" cols="12" style="display:flex; text-align:left">
<v-img
v-for="(image, index) in files"
:key="index"
:src="image"
contain
height="100px"
width="150px"
/>
</v-col>
<v-col cols="12">
<v-btn
......@@ -596,6 +608,7 @@ export default {
products: [],
product: [],
categories: [],
categoryTrees: [],
sName: '',
sCategoryId: '',
sPrice: '',
......@@ -632,7 +645,8 @@ export default {
category_id: '',
price: '',
description: '',
stock: ''
stock: '',
variants_count: ''
},
defaultItem: {
name: '',
......@@ -675,6 +689,7 @@ export default {
this.initialize()
this.getProducts()
this.getCategories()
this.getCategoryTrees()
},
methods: {
initialize () {
......@@ -732,6 +747,22 @@ export default {
}
this.close()
},
getCategoryTrees () {
this.$axios
.get('/categories-tree/', {
headers: {
Authorization: `Bearer ${this.$auth.$storage.getUniversal(
'token'
)}`
}
})
.then((response) => {
this.categoryTrees = response.data.data
})
.catch(function (error) {
console.log(error)
})
},
getCategories () {
this.$axios
.get('/categories/', {
......@@ -785,6 +816,7 @@ export default {
duration: 3000
})
this.editedItem = response.data.data
this.editedItem.variants_count = response.data.data.variants.length
console.log(this.editedItem)
this.products.push(this.editedItem)
this.clearData()
......@@ -973,24 +1005,26 @@ export default {
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')}`
}
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
})
}
)
.then((response) => {
console.log(response)
self.$toast.success('Updated status successfully!', {
duration: 3000
})
} catch (error) {
console.log(error)
}
})
.catch((error) => {
console.log(error)
self.$toast.error('ERR!', {
duration: 3000
})
})
}
}
}
......
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