Commit 30845731 authored by TTS Kieu Tuan Anh's avatar TTS Kieu Tuan Anh

Merge branch 'dev' of...

Merge branch 'dev' of https://gitlab.kiaisoft.com/kiaisoft.anh.tran2/kiaisoft_tuananh_nuxt into feature/manage-products
parents 85eca19f c2d2891c
...@@ -23,13 +23,12 @@ ...@@ -23,13 +23,12 @@
min="1" min="1"
required required
/> />
<label>Parent ID :</label> <label>Parent :</label>
<input <b-form-select v-model="parent_id">
type="text" <option v-for="item in categories" :value="item.id">
class="form-control mb-2" {{item.name}}
placeholder="Parent ID" </option>
v-model="parent_id" </b-form-select>
/>
<label>Ordering :</label> <label>Ordering :</label>
<input <input
type="text" type="text"
...@@ -65,20 +64,21 @@ ...@@ -65,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>
...@@ -179,7 +179,7 @@ ...@@ -179,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>
...@@ -204,7 +204,7 @@ export default { ...@@ -204,7 +204,7 @@ export default {
middleware: ["web"], middleware: ["web"],
data: () => { data: () => {
return { return {
parent_id:'', parent_id: null,
name:'', name:'',
ordering:'', ordering:'',
image: null, image: null,
...@@ -230,7 +230,7 @@ export default { ...@@ -230,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,
...@@ -319,13 +319,15 @@ export default { ...@@ -319,13 +319,15 @@ export default {
}); });
}, },
createCategory() { createCategory() {
const self = this const set = new Set([this.image]);
const image = Array.from(set);
const self = this;
axios axios
.post('http://127.0.0.1:8000/api/categories/',{ .post('http://127.0.0.1:8000/api/categories/',{
name: this.name, name: this.name,
ordering: this.ordering, ordering: this.ordering,
parent_id: this.parent_id, parent_id: this.parent_id,
image: this.image, images: image,
}, { }, {
headers: { headers: {
"Content-Type": "multipart/form-data", "Content-Type": "multipart/form-data",
...@@ -375,13 +377,19 @@ export default { ...@@ -375,13 +377,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);
...@@ -391,8 +399,8 @@ export default { ...@@ -391,8 +399,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