index.vue 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <template>
  2. <v-container>
  3. <v-text-field
  4. v-model="category.alias"
  5. label="Alias"
  6. required
  7. ></v-text-field>
  8. <v-text-field
  9. v-model="category.title"
  10. label="Название"
  11. required
  12. ></v-text-field>
  13. <v-autocomplete
  14. v-model="category.parent_id"
  15. label="Родительская категория"
  16. required
  17. :items="categories"
  18. item-text="title"
  19. item-value="id"
  20. clearable
  21. no-data-text="Не найдено"
  22. ></v-autocomplete>
  23. <v-btn @click="createCategory">Добавить</v-btn>
  24. </v-container>
  25. </template>
  26. <script>
  27. export default {
  28. layout: "admin",
  29. data() {
  30. return {
  31. category: {
  32. title: "",
  33. alias: "",
  34. parent_id: null
  35. },
  36. categories: [],
  37. };
  38. },
  39. methods: {
  40. async createCategory({ $axios }) {
  41. let response = await this.$axios.$post(
  42. "/admin/categories/create",
  43. this.category
  44. );
  45. },
  46. },
  47. async mounted() {
  48. await this.$axios.$get("/admin/categories").then((res) => {
  49. console.log(res.data);
  50. this.categories = res.data;
  51. });
  52. },
  53. };
  54. </script>
  55. <style>
  56. </style>