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

remove

parent e9fccad2
<template>
<v-card class="mx-auto" height="400" width="256">
<v-navigation-drawer class="deep-purple accent-4" dark permanent>
<v-list>
<v-list-item v-for="item in items" :key="item.title" link>
<v-list-item-icon>
<v-icon>{{ item.icon }}</v-icon>
</v-list-item-icon>
<v-list-item-content>
<v-list-item-title>{{ item.title }}</v-list-item-title>
</v-list-item-content>
</v-list-item>
</v-list>
<template v-slot:append>
<div class="pa-2">
<v-btn block> Logout </v-btn>
</div>
</template>
</v-navigation-drawer>
</v-card>
</template>
<script>
export default {
name: "navigation",
data() {
return {
items: [
{ title: "Dashboard", icon: "mdi-view-dashboard" },
{ title: "Account", icon: "mdi-account-box" },
{ title: "Admin", icon: "mdi-gavel" },
],
};
},
};
</script>
<template>
<div class="notification is-danger bg-danger">
{{ message }}
</div>
</template>
<style>
.notification {
padding: 11px;
margin: 10px 0px;
}
</style>
<script>
export default {
name: "Notification",
props: ["message"],
};
</script>
...@@ -191,16 +191,12 @@ ...@@ -191,16 +191,12 @@
</template> </template>
<script> <script>
import Nav from "@/components/Nav"; import Nav from "@/components/Nav";
import Navigation from "@/components/Navigation";
import axios from "axios"; import axios from "axios";
import notification from "@/components/Notification";
import { BootstrapVue, BootstrapVueIcons } from 'bootstrap-vue' import { BootstrapVue, BootstrapVueIcons } from 'bootstrap-vue'
export default { export default {
layout: 'admin', layout: 'admin',
components: { Nav }, components: { Nav },
components: { Navigation },
components: { notification },
middleware: ["web"], middleware: ["web"],
data: () => { data: () => {
return { return {
......
...@@ -22,7 +22,6 @@ ...@@ -22,7 +22,6 @@
v-model="name" v-model="name"
max="255" max="255"
min="1" min="1"
:state="nameState"
trim trim
> >
</b-form-input> </b-form-input>
...@@ -109,7 +108,7 @@ ...@@ -109,7 +108,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(); createProduct();" v-b-modal.modal-close_visit class="btn btn-success btn-sm m-1">Submit</button> <button @click="createProduct()" v-b-modal.modal-close_visit class="btn btn-success btn-sm m-1">Submit</button>
</template> </template>
</b-modal> </b-modal>
<!-- modal-show --> <!-- modal-show -->
...@@ -132,7 +131,6 @@ ...@@ -132,7 +131,6 @@
size="sm" size="sm"
disabled disabled
/> />
<label>Price :</label> <label>Price :</label>
<input <input
type="text" type="text"
...@@ -213,7 +211,6 @@ ...@@ -213,7 +211,6 @@
{{item.name}} {{item.name}}
</option> </option>
</b-form-select> </b-form-select>
<label>Price :</label> <label>Price :</label>
<input <input
type="text" type="text"
...@@ -308,7 +305,7 @@ ...@@ -308,7 +305,7 @@
<template v-slot:item.actions="{ item }"> <template v-slot:item.actions="{ item }">
<v-icon small @click="editProduct(item)" :id ="item.id"> mdi-pencil </v-icon> <v-icon small @click="editProduct(item)" :id ="item.id"> mdi-pencil </v-icon>
<v-icon small @click="deleteProduct(item.id,item)" :id ="item.id"> mdi-delete </v-icon> <v-icon small @click="deleteProduct(item.id,item)" :id ="item.id"> mdi-delete </v-icon>
<v-icon small @click="showProduct(item); " :id ="item.id"> mdi-account-details </v-icon> <v-icon small @click="showProduct(item)" :id ="item.id"> mdi-account-details </v-icon>
</template> </template>
<template v-slot:no-data> <template v-slot:no-data>
<v-btn color="primary" @click="initialize"> Reset </v-btn> <v-btn color="primary" @click="initialize"> Reset </v-btn>
...@@ -319,19 +316,14 @@ ...@@ -319,19 +316,14 @@
</template> </template>
<script> <script>
import CreateProductModal from "../../components/CreateProductModal";
import Nav from "@/components/Nav"; import Nav from "@/components/Nav";
import Navigation from "@/components/Navigation";
import axios from "axios"; import axios from "axios";
import notification from "@/components/Notification";
export default { export default {
layout: 'admin', layout: 'admin',
name: "App", name: "App",
components: { components: {
CreateProductModal,
Nav, Nav,
Navigation,
}, },
middleware: ["web"], middleware: ["web"],
data: () => { data: () => {
...@@ -419,7 +411,7 @@ export default { ...@@ -419,7 +411,7 @@ export default {
}, },
computed: { computed: {
formTitle() { formTitle() {
return this.editedIndex === -1 ? "New Item" : "Edit Item"; return this.editedIndex === -1 ? "New Item" : "Edit Item"
}, },
nameState() { nameState() {
return this.name.length > 2 ? true : false return this.name.length > 2 ? true : false
...@@ -427,23 +419,23 @@ export default { ...@@ -427,23 +419,23 @@ export default {
}, },
watch: { watch: {
dialog(val) { dialog(val) {
val || this.close(); val || this.close()
}, },
dialogDelete(val) { dialogDelete(val) {
val || this.closeDelete(); val || this.closeDelete()
}, },
}, },
created() { created() {
this.initialize(); this.initialize(),
this.getProducts(); this.getProducts(),
this.getCategories(); this.getCategories()
}, },
methods: { methods: {
initialize() { initialize() {
this.products= []; this.products= [],
this.product= []; this.product= [],
this.categories= []; this.categories= [],
this.sName= ''; this.sName= '',
this.sCategoryId= '', this.sCategoryId= '',
this.sPrice= '', this.sPrice= '',
this.sDescription= '', this.sDescription= '',
...@@ -459,9 +451,9 @@ export default { ...@@ -459,9 +451,9 @@ export default {
]; ];
}, },
editItem(item) { editItem(item) {
this.editedIndex = this.products.indexOf(item); this.editedIndex = this.products.indexOf(item)
this.editedItem = Object.assign({}, item); this.editedItem = Object.assign({}, item)
this.dialog = true; this.dialog = true
}, },
deleteItem(item) { deleteItem(item) {
this.editedIndex = this.products.indexOf(item); this.editedIndex = this.products.indexOf(item);
...@@ -470,20 +462,20 @@ export default { ...@@ -470,20 +462,20 @@ export default {
}, },
deleteItemConfirm() { deleteItemConfirm() {
this.products.splice(this.editedIndex, 1); this.products.splice(this.editedIndex, 1);
this.closeDelete(); this.closeDelete()
}, },
close() { close() {
this.dialog = false; this.dialog = false
this.$nextTick(() => { this.$nextTick(() => {
this.editedItem = Object.assign({}, this.defaultItem); this.editedItem = Object.assign({}, this.defaultItem)
this.editedIndex = -1; this.editedIndex = -1
}); });
}, },
closeDelete() { closeDelete() {
this.dialogDelete = false; this.dialogDelete = false
this.$nextTick(() => { this.$nextTick(() => {
this.editedItem = Object.assign({}, this.defaultItem); this.editedItem = Object.assign({}, this.defaultItem);
this.editedIndex = -1; this.editedIndex = -1
}); });
}, },
save() { save() {
...@@ -492,7 +484,7 @@ export default { ...@@ -492,7 +484,7 @@ export default {
} else { } else {
this.products.push(this.editedItem); this.products.push(this.editedItem);
} }
this.close(); this.close()
}, },
getCategories() { getCategories() {
axios axios
...@@ -540,8 +532,8 @@ export default { ...@@ -540,8 +532,8 @@ export default {
this.message = errors.response.data.message; this.message = errors.response.data.message;
self.$toast.error('something went wrong while trying create!',{ self.$toast.error('something went wrong while trying create!',{
duration: 3000 duration: 3000
}); })
}); })
}, },
deleteProduct(ID,index) { deleteProduct(ID,index) {
const self = this; const self = this;
...@@ -562,7 +554,7 @@ export default { ...@@ -562,7 +554,7 @@ export default {
} }
}, },
async showProduct(item) { async showProduct(item) {
const ID = item.id; const ID = item.id
try { try {
const resp = await fetch(`http://127.0.0.1:8000/api/products/${ID}`, { const resp = await fetch(`http://127.0.0.1:8000/api/products/${ID}`, {
method: "GET", method: "GET",
...@@ -598,7 +590,7 @@ export default { ...@@ -598,7 +590,7 @@ export default {
this.eVariants = item.variants this.eVariants = item.variants
}, },
updateProduct(ID) { updateProduct(ID) {
const self = this; const self = this
try{ try{
axios axios
.post(`http://127.0.0.1:8000/api/products/update/${this?.eId}`,{ .post(`http://127.0.0.1:8000/api/products/update/${this?.eId}`,{
...@@ -639,19 +631,11 @@ export default { ...@@ -639,19 +631,11 @@ export default {
}); });
}, },
remove(index) { remove(index) {
this.variants.splice(index, 1); this.variants.splice(index, 1)
}, },
removeVariant(index) { removeVariant(index) {
this.eVariants.splice(index, 1); this.eVariants.splice(index, 1)
}, },
getInfo() {
console.log(this.name)
console.log(this.price)
console.log(this.category_id)
console.log(this.stock)
console.log(this.images)
console.log(this.variants)
}
}, },
}; };
</script> </script>
......
...@@ -194,17 +194,13 @@ ...@@ -194,17 +194,13 @@
</template> </template>
<script> <script>
import Nav from "@/components/Nav"; import Nav from "@/components/Nav";
import Navigation from "@/components/Navigation";
import axios from "axios"; import axios from "axios";
import notification from "@/components/Notification";
import Toasted from 'vue-toasted'; import Toasted from 'vue-toasted';
import { ModalPlugin } from 'bootstrap-vue'; import { ModalPlugin } from 'bootstrap-vue';
export default { export default {
layout: "admin", layout: "admin",
components: { Nav }, components: { Nav },
components: { Navigation },
components: { notification },
middleware: ["web"], middleware: ["web"],
data: () => { data: () => {
return { return {
......
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