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

add search

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