图书馆综合管理系统
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

172 lines
4.2 KiB

5 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
  1. <template>
  2. <div>
  3. <swiper
  4. ref="swiperTitle"
  5. class="swiper-title"
  6. :options="swiperOptionTitle"
  7. :auto-update="true"
  8. :auto-destroy="true"
  9. :delete-instance-on-destroy="true"
  10. :cleanup-styles-on-destroy="true"
  11. >
  12. <swiper-slide
  13. v-for="(item, index) in tabListData"
  14. ref="swiperSlideItem"
  15. :key="'name' + index"
  16. class="swiper-slide-title"
  17. >
  18. <div
  19. class="tab-name"
  20. :class="{ active: index === swiperActiveIndex }"
  21. @click="handleSlidClickFun(index)"
  22. >
  23. {{ item.name }}
  24. </div>
  25. </swiper-slide>
  26. </swiper>
  27. <swiper
  28. ref="swiperContent"
  29. class="swiper-content"
  30. :options="swiperOptionContent"
  31. :auto-update="true"
  32. :auto-destroy="true"
  33. :delete-instance-on-destroy="true"
  34. :cleanup-styles-on-destroy="true"
  35. >
  36. <swiper-slide
  37. v-for="(item, index) in tabListData"
  38. :key="'content' + index"
  39. class="swiper-slide-content"
  40. >
  41. <el-table
  42. :data="bookList"
  43. stripe
  44. style="width: 100%"
  45. height="150"
  46. >
  47. <el-table-column
  48. prop="title"
  49. :label="swiperActiveIndex === 1 ? '书架' :'书名'"
  50. >
  51. <template slot-scope="scope">
  52. {{ swiperActiveIndex === 0 ? scope.row.title : scope.row.grid_name }}
  53. </template>
  54. </el-table-column>
  55. <el-table-column
  56. prop="downNum"
  57. label="出架册次"
  58. width="80"
  59. align="center"
  60. />
  61. </el-table>
  62. </swiper-slide>
  63. </swiper>
  64. </div>
  65. </template>
  66. <script>
  67. import { FetchInitHotBookList, FetchInitHotShelfList } from '@/api/stockTask/index'
  68. import { mapGetters } from 'vuex'
  69. import { swiper, swiperSlide } from 'vue-awesome-swiper'
  70. import 'swiper/dist/css/swiper.css'
  71. export default {
  72. name: 'BookSwiper',
  73. components: { swiper, swiperSlide },
  74. props: {
  75. },
  76. data() {
  77. const _this = this
  78. return {
  79. swiperActiveIndex: 0,
  80. swiperOptionContent: {
  81. slidesPerView: 'auto',
  82. on: {
  83. slideChangeTransitionStart: function() {
  84. _this.swiperActiveIndex = this.activeIndex
  85. _this.swiperTitle.slideTo(this.activeIndex, 500, false)
  86. }
  87. }
  88. },
  89. swiperOptionTitle: {
  90. slidesPerView: 'auto',
  91. freeMode: true
  92. },
  93. tabListData: [{ name: '热门图书' }, { name: '热门架位' }],
  94. bookList: [],
  95. swiperParams: {},
  96. swiperShelfParams: {}
  97. }
  98. },
  99. computed: {
  100. ...mapGetters([
  101. 'baseApi'
  102. ]),
  103. swiperContent() {
  104. return this.$refs.swiperContent.$el.swiper
  105. },
  106. swiperTitle() {
  107. return this.$refs.swiperTitle.$el.swiper
  108. }
  109. },
  110. mounted() {
  111. // if (this.swiperActiveIndex === 0) {
  112. // this.getInitHotBookList()
  113. // } else {
  114. // this.getInitHotShelfList()
  115. // }
  116. },
  117. methods: {
  118. handleSlidClickFun(index) {
  119. this.handleSlideToFun(index)
  120. },
  121. handleSlideToFun(index) {
  122. this.bookList = []
  123. this.swiperActiveIndex = index
  124. if (this.swiperActiveIndex === 0) {
  125. this.getInitHotBookList()
  126. } else {
  127. this.getInitHotShelfList()
  128. }
  129. this.swiperContent.slideTo(index, 500, false)
  130. this.swiperTitle.slideTo(index, 500, false)
  131. },
  132. getInitHotBookList() {
  133. const params = this.swiperParams
  134. FetchInitHotBookList(params).then(res => {
  135. this.bookList = res
  136. }).catch(() => {
  137. })
  138. },
  139. getInitHotShelfList() {
  140. const params = this.swiperShelfParams
  141. FetchInitHotShelfList(params).then(res => {
  142. this.bookList = res
  143. }).catch(() => {
  144. })
  145. }
  146. }
  147. }
  148. </script>
  149. <style lang="scss" scoped>
  150. .swiper-title{
  151. font-size: 14px;
  152. ::v-deep .swiper-wrapper{
  153. margin: 10px 0;
  154. border-bottom: 1px solid #EDEFF3;
  155. }
  156. }
  157. .swiper-slide-title {
  158. width: auto !important;
  159. margin-right: 20px;
  160. cursor: pointer;
  161. .tab-name {
  162. padding: 10px;
  163. &.active {
  164. color: #0348F3;
  165. border-bottom: 3px solid #0348F3;
  166. }
  167. }
  168. }
  169. </style>