1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- <template>
- <v-container>
- <v-text-field
- v-model="category.alias"
- label="Alias"
- required
- ></v-text-field>
- <v-text-field
- v-model="category.title"
- label="Название"
- required
- ></v-text-field>
- <v-autocomplete
- v-model="category.parent_id"
- label="Родительская категория"
- required
- :items="categories"
- item-text="title"
- item-value="id"
- clearable
- no-data-text="Не найдено"
- ></v-autocomplete>
- <v-btn @click="createCategory">Добавить</v-btn>
- </v-container>
- </template>
- <script>
- export default {
- layout: "admin",
- data() {
- return {
- category: {
- title: "",
- alias: "",
- parent_id: null
- },
- categories: [],
- };
- },
- methods: {
- async createCategory({ $axios }) {
- let response = await this.$axios.$post(
- "/admin/categories/create",
- this.category
- );
- },
- },
- async mounted() {
- await this.$axios.$get("/admin/categories").then((res) => {
- console.log(res.data);
- this.categories = res.data;
- });
- },
- };
- </script>
- <style>
- </style>
|