123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159 |
- <template lang="html">
- <div class="component-wrapper">
- <v-tabs>
- <v-tab link to="sliders/slider-create">
- Создать слайдер
- </v-tab>
- </v-tabs>
- <v-expansion-panels multiple v-if="sliders">
- <v-expansion-panel v-for="slider in sliders" :key="slider.id" class="section__wrapper">
- <v-btn
- color="primary"
- @click="copy(slider.id)"
- class="inject-button"
- fab
- dark
- small
- >
- <v-icon class="mx-auto" left> mdi-content-copy </v-icon>
- </v-btn>
- <v-btn
- color="warning"
- @click="deleteSlider(slider.id)"
- class="delete-button"
- fab
- dark
- small
- >
- <v-icon class="mx-auto" left> mdi-delete </v-icon>
- </v-btn>
- <v-btn
- fab
- dark
- small
- color="success"
- class="add-button mx-2"
- @click="addNews(slider.id)"
- >
- <v-icon dark>
- mdi-plus
- </v-icon>
- </v-btn>
- <v-expansion-panel-header>
- {{slider.name }}
- </v-expansion-panel-header>
- <v-expansion-panel-content max-width="500">
- <div v-for="news in slider.news" >
- <SectionNews @update="update" :news="news" :news_container_id="slider.id" />
- </div>
- </v-expansion-panel-content>
- </v-expansion-panel>
- </v-expansion-panels>
- </div>
- </template>
- <script>
- export default {
- mounted() {
- this.$axios.get("admin/containers/type_slider").then((res) => {
- console.log(res.data);
- this.sliders = res.data.data;
- return res.data.data;
- });
- },
- data() {
- return {
- sliders: false,
- };
- },
- methods: {
- copy(id) {
- this.$clipboard(id)
- },
- async deleteSlider(id) {
- await this.$axios.$post("admin/containers/remove", {id: id}).then(() => {
- this.$axios.get("admin/containers/type_slider").then((res) => {
- this.sliders = res.data.data;
- return res.data.data;
- });
- })
- },
- async addNews(container_id) {
- // const newsReplace1 = news.replaceAll('##', '')
- // const newsReplace2 = newsReplace1.replaceAll('news_', '')
- // console.log(newsReplace2)
- const { value: text } = await this.$swal.fire({
- title: "Вставьте инжект новости",
- input: "text",
- inputPlaceholder: "Инжект",
- });
- if (text) {
- const newsReplace1 = text.replaceAll("##", "");
- const newsReplace2 = newsReplace1.replaceAll("news_", "");
- this.$axios
- .post("admin/containers/add/news", {
- news_id: newsReplace2,
- news_container_id: container_id,
- })
- .then(() => {
- this.$swal.fire(`Новость добавлена!`);
- this.update();
- return;
- }).then(() => {
- this.$axios.get("admin/containers/type_slider").then((res) => {
- this.sliders = res.data.data;
- return res.data.data;
- });
- });
- }
- },
- update() {
- this.$axios.get("admin/containers/type_slider").then((res) => {
- console.log(res.data);
- this.sliders = res.data.data;
- return res.data.data;
- }).then(() => {
- this.$axios.get("admin/containers/type_slider").then((res) => {
- this.sliders = res.data.data;
- return res.data.data;
- });
- })
- },
- },
- layout: "admin",
- };
- </script>
- <style lang="scss" scope>
- .v-sheet.v-card {
- width: 200px;
- margin-bottom: 55px;
- margin-right: 55px;
- }
- .v-expansion-panel-content__wrap {
- max-width: 100%;
- display: flex;
- flex-wrap: wrap;
- justify-content: flex-start;
- }
- .v-card__actions > .v-btn.v-btn {
- padding: 0 8px;
- margin: 0 auto;
- }
- .add-button {
- position: absolute;
- right: 50px;
- z-index: 10;
- }
- .inject-button {
- position: absolute;
- right: 120px;
- z-index: 10;
- }
- .delete-button {
- position: absolute;
- right: 190px;
- z-index: 10;
- }
- </style>
|