index.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. <template>
  2. <v-form max-width="400px" class="form-module">
  3. <v-text-field v-model="module.name" label="Название слайдера"> </v-text-field>
  4. <v-checkbox
  5. max-width="400"
  6. v-model="module.activity"
  7. label="Показывать слайдер"
  8. ></v-checkbox>
  9. <v-img :src="'https://api.amic.ru/'+img.relative_path"></v-img>
  10. <v-row>
  11. <v-col>
  12. <h4>Начало активности</h4>
  13. <v-date-picker v-model="date" no-title scrollable>
  14. <v-spacer></v-spacer>
  15. <v-btn text color="primary" @click="menu = false"> Cancel </v-btn>
  16. <v-btn
  17. text
  18. color="primary"
  19. @click="$refs.menu.save(startActivity.date)"
  20. >
  21. OK
  22. </v-btn>
  23. </v-date-picker>
  24. <vue-timepicker v-model="time" format="HH:mm:ss"></vue-timepicker>
  25. </v-col>
  26. <v-col>
  27. <h4>Конец активности</h4>
  28. <v-date-picker v-model="endDate" no-title scrollable>
  29. <v-spacer></v-spacer>
  30. <v-btn text color="primary" @click="menu = false"> Cancel </v-btn>
  31. <v-btn
  32. text
  33. color="primary"
  34. @click="$refs.menu.save(startActivity.date)"
  35. >
  36. OK
  37. </v-btn>
  38. </v-date-picker>
  39. <vue-timepicker v-model="endTime" format="HH:mm:ss"></vue-timepicker>
  40. </v-col>
  41. </v-row>
  42. <v-btn @click="createModule">Создать слайдер</v-btn>
  43. </v-form>
  44. </template>
  45. <script>
  46. import VueTimepicker from "vue2-timepicker";
  47. import "vue2-timepicker/dist/VueTimepicker.css";
  48. export default {
  49. layout: "admin",
  50. components: {
  51. VueTimepicker,
  52. },
  53. data() {
  54. return {
  55. module: {
  56. activity: true,
  57. type: "slider",
  58. name: "",
  59. start_activity: "",
  60. end_activity: "",
  61. },
  62. img: {},
  63. endTime: "",
  64. endDate: "",
  65. date: "",
  66. time: "",
  67. };
  68. },
  69. async asyncData({ $axios }) {
  70. const containers = await $axios
  71. .get("/admin/containers/type_slider")
  72. .then((res) => {
  73. return res.data.data;
  74. });
  75. return { containers };
  76. },
  77. methods: {
  78. createModule() {
  79. this.$axios.post("admin/containers/create", {
  80. type: "slider",
  81. name: this.module.name,
  82. start_activity: this.start_activity,
  83. end_activity: this.end_activity,
  84. activity: this.module.activity
  85. })
  86. }
  87. },
  88. computed: {
  89. start_activity() {
  90. return this.date + " " + this.time;
  91. },
  92. end_activity() {
  93. return this.endDate + ' ' + this.endTime
  94. }
  95. },
  96. };
  97. </script>
  98. <style lang="less">
  99. .form-module {
  100. margin: 0 auto;
  101. max-width: 800px;
  102. width: 100%;
  103. }
  104. </style>