Commit 6aecb92f authored by TTS Kieu Tuan Anh's avatar TTS Kieu Tuan Anh

create products

parent 05c812e0
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
<b-breadcrumb-item href="/home/products">Product</b-breadcrumb-item> <b-breadcrumb-item href="/home/products">Product</b-breadcrumb-item>
</b-breadcrumb> </b-breadcrumb>
<div style="float: right"> <div style="float: right">
<b-button v-b-modal.modal-create >New Product</b-button></div> <b-button class="text-white" v-b-modal.modal-create >New Product</b-button></div>
<b-modal id="modal-create" title="create Product" class="modal fade" > <b-modal id="modal-create" title="create Product" class="modal fade" >
<div class="w-full mt-4 p-10"> <div class="w-full mt-4 p-10">
<form > <form >
...@@ -105,7 +105,7 @@ ...@@ -105,7 +105,7 @@
</div> </div>
<template #modal-footer> <template #modal-footer>
<button v-b-modal.modal-close_visit @click="$bvModal.hide('modal-create')" class="btn btn-danger btn-sm m-1">Close</button> <button v-b-modal.modal-close_visit @click="$bvModal.hide('modal-create')" class="btn btn-danger btn-sm m-1">Close</button>
<button @click="getInfo();" v-b-modal.modal-close_visit class="btn btn-success btn-sm m-1">Submit</button> <button @click="getInfo(); createProduct();" v-b-modal.modal-close_visit class="btn btn-success btn-sm m-1">Submit</button>
</template> </template>
</b-modal> </b-modal>
...@@ -119,7 +119,7 @@ ...@@ -119,7 +119,7 @@
> >
<template v-slot:top > <template v-slot:top >
<v-toolbar flat> <v-toolbar flat>
<v-toolbar-title>Category Manage</v-toolbar-title> <v-toolbar-title>Product Manage</v-toolbar-title>
<v-divider class="mx-4" inset vertical></v-divider> <v-divider class="mx-4" inset vertical></v-divider>
<v-spacer></v-spacer> <v-spacer></v-spacer>
</v-toolbar> </v-toolbar>
...@@ -164,7 +164,7 @@ export default { ...@@ -164,7 +164,7 @@ export default {
price: '', price: '',
stock: '', stock: '',
description: '', description: '',
images: null, images: [],
variants: [ variants: [
{ {
color: "", color: "",
...@@ -283,15 +283,15 @@ export default { ...@@ -283,15 +283,15 @@ export default {
}, },
createProduct() { createProduct() {
const self = this; const self = this;
const set = new Set([this.images]); // const set = new Set([this.images]);
const images = Array.from(set); // const images = Array.from(set);
axios axios
.post('http://127.0.0.1:8000/api/products/',{ .post('http://127.0.0.1:8000/api/products/',{
name: this.name, name: this.name,
price: this.price, price: this.price,
category_id: this.category_id, category_id: this.category_id,
description: this.description, description: this.description,
images: images, images: this.images,
variants: this.variants, variants: this.variants,
}, { }, {
headers: { headers: {
......
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