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

rs category

parent 189df397
......@@ -17,26 +17,27 @@
</v-card-title>
<v-card-text>
<v-container>
<v-row>
<v-col cols="12">
<v-text-field
v-model="eName"
label="Name"
:rules="nameRules"
required
/>
</v-col>
<v-col cols="12">
<v-text-field
v-model="eOrdering"
label="Ordering"
type="number"
:rules="requiredRules"
required
/>
</v-col>
<v-col cols="12">
<!-- <v-select
<v-form ref="formEdit">
<v-row>
<v-col cols="12">
<v-text-field
v-model="eName"
label="Name"
:rules="nameRules"
required
/>
</v-col>
<v-col cols="12">
<v-text-field
v-model="eOrdering"
label="Ordering"
type="number"
:rules="requiredRules"
required
/>
</v-col>
<v-col cols="12">
<!-- <v-select
v-model="eParentId"
:items="
categories.filter((category) => category.id !== eID)
......@@ -45,60 +46,63 @@
item-value="id"
label="Parent"
/> -->
<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"
/>
</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-row>
<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
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-row>
</v-form>
</v-container>
<small>*indicates required field</small>
</v-card-text>
......@@ -212,7 +216,7 @@
item-value="id"
selected-color="primary"
selection-type="independent"
:rule="singleRules"
:rules="singleRules"
/>
</v-card-text>
</v-card>
......@@ -448,8 +452,7 @@ export default {
],
nameRules: [
v => !!v || 'Name is required',
v =>
(v && v.length <= 255) || 'Name must be less than 255 characters'
v => (v && v.length <= 255) || 'Name must be less than 255 characters'
],
requiredRules: [v => !!v || 'This field is required'],
numberRules: [
......@@ -478,6 +481,20 @@ 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 () {
......@@ -573,9 +590,7 @@ export default {
this.$axios
.post('/categories/', fd, {
headers: {
Authorization: `Bearer ${this.$auth.$storage.getUniversal(
'token'
)}`
Authorization: `Bearer ${this.$auth.$storage.getUniversal('token')}`
}
})
.then((response) => {
......@@ -691,6 +706,21 @@ 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])
}
}
}
......
......@@ -128,8 +128,6 @@
<v-row>
<v-col
cols="12"
sm="6"
md="4"
>
<v-text-field
v-model="eName"
......@@ -178,10 +176,17 @@
</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-img :src="image" contain height="100px" width="150px" display:flex/>
</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-btn
class="mx-2"
......@@ -345,8 +350,6 @@
<v-row>
<v-col
cols="12"
sm="6"
md="4"
>
<v-text-field
v-model="name"
......@@ -835,6 +838,7 @@ export default {
this.eStock = item.stock
this.eDescription = item.description
this.eVariants = item.variants
this.eImages = item.images
this.editedIndex = this.products.indexOf(item)
console.log(item.variants)
this.dialog3 = true
......@@ -955,3 +959,9 @@ export default {
}
}
</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