Commit 41585dec authored by TTS Kieu Tuan Anh's avatar TTS Kieu Tuan Anh

rs category

parent 189df397
...@@ -17,26 +17,27 @@ ...@@ -17,26 +17,27 @@
</v-card-title> </v-card-title>
<v-card-text> <v-card-text>
<v-container> <v-container>
<v-row> <v-form ref="formEdit">
<v-col cols="12"> <v-row>
<v-text-field <v-col cols="12">
v-model="eName" <v-text-field
label="Name" v-model="eName"
:rules="nameRules" label="Name"
required :rules="nameRules"
/> required
</v-col> />
<v-col cols="12"> </v-col>
<v-text-field <v-col cols="12">
v-model="eOrdering" <v-text-field
label="Ordering" v-model="eOrdering"
type="number" label="Ordering"
:rules="requiredRules" type="number"
required :rules="requiredRules"
/> required
</v-col> />
<v-col cols="12"> </v-col>
<!-- <v-select <v-col cols="12">
<!-- <v-select
v-model="eParentId" v-model="eParentId"
:items=" :items="
categories.filter((category) => category.id !== eID) categories.filter((category) => category.id !== eID)
...@@ -45,60 +46,63 @@ ...@@ -45,60 +46,63 @@
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"
label="Search Category" label="Search Category"
dark dark
flat flat
solo-inverted solo-inverted
hide-details hide-details
clearable clearable
clear-icon="mdi-close-circle-outline" clear-icon="mdi-close-circle-outline"
/> />
</v-sheet> </v-sheet>
<v-card-text> <v-card-text>
<v-treeview <v-treeview
v-model="eParentId" v-model="eParentId"
:items="categoryTrees" :items="categoryTrees"
:search="search" :search="search"
:filter="filter" :filter="filter"
:open.sync="open" :open.sync="open"
selectable selectable
transition transition
item-value="id" item-value="id"
selected-color="primary" selected-color="primary"
selection-type="independent" selection-type="independent"
/> @update:open="onOpen"
</v-card-text> @input="selectCategory"
</v-card> />
</v-col> </v-card-text>
<v-col cols="12"> </v-card>
<v-file-input </v-col>
v-model="eImage" <v-col cols="12">
accept="image/*" <v-file-input
label="Image" v-model="eImage"
prepend-icon="mdi-camera" accept="image/*"
@change="fileSelected" label="Image"
/> prepend-icon="mdi-camera"
</v-col> @change="fileSelected"
<v-col cols="12"> />
<img </v-col>
v-if="file" <v-col cols="12">
:src="file" <img
> v-if="file"
</v-col> :src="file"
<v-col cols="12" text-align=" left"> >
<v-img </v-col>
v-if="typeof eImage === 'string'" <v-col cols="12" text-align=" left">
contain <v-img
height="100px" v-if="typeof eImage === 'string'"
width="150px" contain
:src="eImage" height="100px"
/> width="150px"
</v-col> :src="eImage"
</v-row> />
</v-col>
</v-row>
</v-form>
</v-container> </v-container>
<small>*indicates required field</small> <small>*indicates required field</small>
</v-card-text> </v-card-text>
...@@ -212,7 +216,7 @@ ...@@ -212,7 +216,7 @@
item-value="id" item-value="id"
selected-color="primary" selected-color="primary"
selection-type="independent" selection-type="independent"
:rule="singleRules" :rules="singleRules"
/> />
</v-card-text> </v-card-text>
</v-card> </v-card>
...@@ -448,8 +452,7 @@ export default { ...@@ -448,8 +452,7 @@ export default {
], ],
nameRules: [ nameRules: [
v => !!v || 'Name is required', v => !!v || 'Name is required',
v => v => (v && v.length <= 255) || 'Name must be less than 255 characters'
(v && v.length <= 255) || 'Name must be less than 255 characters'
], ],
requiredRules: [v => !!v || 'This field is required'], requiredRules: [v => !!v || 'This field is required'],
numberRules: [ numberRules: [
...@@ -478,6 +481,20 @@ export default { ...@@ -478,6 +481,20 @@ 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 () {
...@@ -573,9 +590,7 @@ export default { ...@@ -573,9 +590,7 @@ export default {
this.$axios this.$axios
.post('/categories/', fd, { .post('/categories/', fd, {
headers: { headers: {
Authorization: `Bearer ${this.$auth.$storage.getUniversal( Authorization: `Bearer ${this.$auth.$storage.getUniversal('token')}`
'token'
)}`
} }
}) })
.then((response) => { .then((response) => {
...@@ -691,6 +706,21 @@ export default { ...@@ -691,6 +706,21 @@ export default {
}, },
clearFile () { clearFile () {
this.file = null 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])
} }
} }
} }
......
...@@ -128,8 +128,6 @@ ...@@ -128,8 +128,6 @@
<v-row> <v-row>
<v-col <v-col
cols="12" cols="12"
sm="6"
md="4"
> >
<v-text-field <v-text-field
v-model="eName" v-model="eName"
...@@ -178,10 +176,17 @@ ...@@ -178,10 +176,17 @@
</v-col> </v-col>
<v-col v-if="files" cols="12"> <v-col v-if="files" cols="12">
<v-col v-for="(image, index) in files" :key="index" cols="12"> <v-col v-for="(image, index) in files" :key="index" cols="12">
<v-img :src="image" contain /> <v-img :src="image" contain height="100px" width="150px" display:flex/>
</v-col> </v-col>
</v-col> </v-col>
<!-- <v-img v-if="typeof eImages === 'string'" :src="eImages" /> --> <v-col v-for="(imageEdit, index) in eImages" :key="index" cols="12" text-align=" left" style="display:flex" >
<v-img
contain
height="100px"
width="150px"
:src="imageEdit"
/>
</v-col>
<v-col cols="12"> <v-col cols="12">
<v-btn <v-btn
class="mx-2" class="mx-2"
...@@ -345,8 +350,6 @@ ...@@ -345,8 +350,6 @@
<v-row> <v-row>
<v-col <v-col
cols="12" cols="12"
sm="6"
md="4"
> >
<v-text-field <v-text-field
v-model="name" v-model="name"
...@@ -835,6 +838,7 @@ export default { ...@@ -835,6 +838,7 @@ export default {
this.eStock = item.stock this.eStock = item.stock
this.eDescription = item.description this.eDescription = item.description
this.eVariants = item.variants this.eVariants = item.variants
this.eImages = item.images
this.editedIndex = this.products.indexOf(item) this.editedIndex = this.products.indexOf(item)
console.log(item.variants) console.log(item.variants)
this.dialog3 = true this.dialog3 = true
...@@ -955,3 +959,9 @@ export default { ...@@ -955,3 +959,9 @@ export default {
} }
} }
</script> </script>
<style>
img {
width: 100px;
height: 150px;
}
</style>
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