SectionNews.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. <template lang="html">
  2. <div class="component-wrapper">
  3. <v-card elevation="2" v-bind:class="!news.is_show ? 'disable_item_list' : '' + ' ' + news.news_timing">
  4. <v-card-title>
  5. <span v-html="news.title"></span>
  6. </v-card-title>
  7. <v-card-subtitle placeholder="Значение сортировки">
  8. {{ news.sorting ? ('сортировка: ' + news.sorting) : "сортировка не задана" }}
  9. </v-card-subtitle>
  10. <v-card-text>
  11. {{ news.start_activity }}
  12. </v-card-text>
  13. <v-text-field
  14. type="nubmer"
  15. v-model="sortValue"
  16. filled
  17. placeholder="сортировка"
  18. class="sort-input"
  19. v-if="sortingInput"
  20. >Значение сортировки</v-text-field
  21. >
  22. <v-card-actions>
  23. <div class="mx-auto">
  24. <v-btn small link block class="mb-2" :href="link" target="_blank">Редактировать</v-btn>
  25. <v-btn small block v-if="!sortingInput" @click="openSorting">Задать сортировку</v-btn>
  26. <v-btn small block v-if="sortingInput" @click="saveSorting">Сохранить сортировку</v-btn>
  27. <v-btn small block class="mt-2" color="primary" @click="copy(news)">Инжект</v-btn>
  28. </div>
  29. </v-card-actions>
  30. <v-btn
  31. fab
  32. dark
  33. small
  34. color="error"
  35. class="delete-button mx-2"
  36. @click="deleteNews()"
  37. >
  38. <v-icon dark>
  39. mdi-close
  40. </v-icon>
  41. </v-btn>
  42. </v-card>
  43. </div>
  44. </template>
  45. <script>
  46. export default {
  47. props: {
  48. news: {
  49. type: Object,
  50. requied: true
  51. },
  52. news_container_id: {
  53. type: String
  54. }
  55. },
  56. data() {
  57. return {
  58. sortingInput: false,
  59. sortValue: ""
  60. };
  61. },
  62. methods: {
  63. copy(item) {
  64. let res = "##news_" + item.id + "##";
  65. this.$clipboard(res);
  66. },
  67. openSorting() {
  68. this.sortingInput = true;
  69. },
  70. saveSorting() {
  71. console.log(this.ContainerId);
  72. this.$axios.post("admin/containers/add/news", {
  73. news_container_id: this.news_container_id,
  74. news_id: this.news.id,
  75. sorting: Number(this.sortValue)
  76. });
  77. },
  78. deleteNews() {
  79. this.$axios.post("admin/containers/remove/news", {
  80. news_container_id: this.news_container_id,
  81. news_id: this.news.id
  82. }).then(() => {
  83. this.$emit('update')
  84. return true
  85. })
  86. }
  87. },
  88. computed: {
  89. link() {
  90. return '/admin/publications/' + this.news.id
  91. }
  92. }
  93. };
  94. </script>
  95. <style lang="scss" scoped>
  96. .delete-button {
  97. position: absolute;
  98. top: 0;
  99. right: -40px;
  100. z-index: 11;
  101. }
  102. .disable_item_list{
  103. opacity: 0.5;
  104. }
  105. .v-card__title {
  106. font-size: 1rem;
  107. line-height: 1.5rem;
  108. }
  109. .yesterday, .today, .tomorrow{
  110. position: relative;
  111. }
  112. .yesterday::before, .today::before, .tomorrow::before{
  113. width: 100%;
  114. height: 7px;
  115. z-index: 1;
  116. }
  117. .yesterday::before{
  118. background-color: purple;
  119. }
  120. .today::before{
  121. background-color: #4caf50;
  122. }
  123. .tomorrow::before{
  124. background-color: orange;
  125. }
  126. </style>