Commit 5b0c67dc authored by vietanh-0511's avatar vietanh-0511

update categories

parent 9201a8ba
...@@ -64,20 +64,21 @@ ...@@ -64,20 +64,21 @@
v-model="eName" v-model="eName"
max="255" max="255"
min="1" min="1"
value="this?.eName"
/> />
<label>Parent ID :</label> <label>Parent :</label>
<input <b-form-select v-model="eParentId">
type="text" <option v-for="item in categories" :value="item.id" :key="item.id">
class="form-control mb-2" {{item.name}}
placeholder="Parent ID" </option>
v-model="eParent_id" </b-form-select>
/>
<label>Ordering :</label> <label>Ordering :</label>
<input <input
type="text" type="text"
class="form-control mb-2" class="form-control mb-2"
placeholder="Ordering" placeholder="Ordering"
v-model="eOrdering" v-model="eOrdering"
value="this?.eOrdering"
/> />
<!-- <b-form-select v-model="selected" :options="options"></b-form-select> --> <!-- <b-form-select v-model="selected" :options="options"></b-form-select> -->
<label>Image :</label> <label>Image :</label>
...@@ -178,7 +179,7 @@ ...@@ -178,7 +179,7 @@
</v-toolbar> </v-toolbar>
</template> </template>
<template v-slot:item.actions="{ item }"> <template v-slot:item.actions="{ item }">
<v-icon small class="mr-2" @click=" editCategory(item.id)" :id ="item.id"> mdi-pencil </v-icon> <v-icon small class="mr-2" @click="editCategory(item)" :id ="item.id"> mdi-pencil </v-icon>
<v-icon small @click="deleteCategory(item.id,item)" :id ="item.id"> mdi-delete </v-icon> <v-icon small @click="deleteCategory(item.id,item)" :id ="item.id"> mdi-delete </v-icon>
</template> </template>
<template v-slot:no-data> <template v-slot:no-data>
...@@ -229,7 +230,7 @@ export default { ...@@ -229,7 +230,7 @@ export default {
eID: '', eID: '',
eName:'', eName:'',
eOrdering:'', eOrdering:'',
eParent_id:'', eParentId:null,
eImage: null, eImage: null,
message: [], message: [],
editedIndex: -1, editedIndex: -1,
...@@ -326,7 +327,7 @@ export default { ...@@ -326,7 +327,7 @@ export default {
name: this.name, name: this.name,
ordering: this.ordering, ordering: this.ordering,
parent_id: this.parent_id, parent_id: this.parent_id,
image: image, images: image,
}, { }, {
headers: { headers: {
"Content-Type": "multipart/form-data", "Content-Type": "multipart/form-data",
...@@ -377,13 +378,19 @@ export default { ...@@ -377,13 +378,19 @@ export default {
getID(item) { getID(item) {
console.log(this.categories.indexOf(item)) console.log(this.categories.indexOf(item))
}, },
editCategory(userID) { editCategory(item) {
this.$bvModal.show('modal-edit'); this.$bvModal.show('modal-edit');
this.eID = userID; this.eID = item.id;
this.eName= item.name,
this.eOrdering= item.ordering,
this.eParentId= item.parent_id,
this.eImage= item.images,
console.log(this?.eID); console.log(this?.eID);
console.log(this.eName); console.log(item);
}, },
updateCategory(userID) { updateCategory(userID) {
const set = new Set([this.eImage]);
const image = Array.from(set);
const self = this const self = this
console.log(this.eName); console.log(this.eName);
console.log(this.eOrdering); console.log(this.eOrdering);
...@@ -393,8 +400,8 @@ export default { ...@@ -393,8 +400,8 @@ export default {
.post(`http://127.0.0.1:8000/api/categories/update/${this?.eID}`,{ .post(`http://127.0.0.1:8000/api/categories/update/${this?.eID}`,{
name: this.eName, name: this.eName,
ordering: this.eOrdering, ordering: this.eOrdering,
parent_id: this.eParent_id, parent_id: this.eParentId,
image: this.eImage }, { images: image }, {
headers: { headers: {
"Content-Type": "multipart/form-data", "Content-Type": "multipart/form-data",
"Authorization": this.$auth.$storage.getUniversal("token") "Authorization": this.$auth.$storage.getUniversal("token")
......
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