大数据展示系统-前端
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.

163 lines
4.8 KiB

3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
  1. <template>
  2. <div id="bookshelf">
  3. <div class="bookshelf-header" style="height:120px">
  4. <!-- <router-link to="/">
  5. <span class="icon iconfont icon-l">&#xe631;</span>
  6. </router-link> -->
  7. <span class="icon iconfont icon-l" @click="goBack()">&#xe631;</span>
  8. <h2>本架图书</h2>
  9. <div class="rack-direct">
  10. <span :class="classnameL" @click="handleDirect(-1)"></span>
  11. <span :class="classnameR" @click="handleDirect(1)"></span>
  12. </div>
  13. </div>
  14. <div v-loading="loading" class="rack-box">
  15. <div v-for="(item, index) in listData" :key="index" class="rack-item">
  16. <div v-if="bookList[item]" :class="['swiper'+index,'rack-box-list']">
  17. <div class="swiper-wrapper">
  18. <div v-for="eitem in bookList[item]" :key="eitem.id" class="list-item swiper-slide" @click="handleDetails(eitem)">
  19. <div class="box-txt">
  20. <span class="book-name">{{ eitem.bookName }}</span>
  21. <span class="book-writer">{{ eitem.bookAuthor }}</span>
  22. </div>
  23. </div>
  24. </div>
  25. </div>
  26. <div class="rack-floor">
  27. <span :class="['icon','iconfont','icon-l'+index]" @click="handlePage(-1)">&#xe631;</span>
  28. <p><span style="margin-right:25px">{{ index+1 }}</span><span>({{ bookList[item].length }})</span></p>
  29. <span :class="['icon','iconfont','icon-r'+index]" @click="handlePage(1)">&#xe62f;</span>
  30. </div>
  31. </div>
  32. </div>
  33. <BookDetails ref="detailDom" />
  34. </div>
  35. </template>
  36. <script>
  37. import { initBookshelfDetails, getBookDetailsByISBN } from '@/api/bookshelf'
  38. import BookDetails from './module/bookDetails.vue'
  39. import { Swiper } from 'vue-awesome-swiper'
  40. import 'swiper/swiper-bundle.css'
  41. export default {
  42. name: 'CurrentRackBook',
  43. components: {
  44. BookDetails
  45. },
  46. data() {
  47. return {
  48. loading: false,
  49. listData: [],
  50. bookList: {},
  51. classnameL: 'rack-direct-active',
  52. classnameR: null
  53. }
  54. },
  55. created() {
  56. this.initBookshelfDetails(-1)
  57. },
  58. mounted() {
  59. },
  60. methods: {
  61. initSwiper() {
  62. this.$nextTick(() => {
  63. for (const key in this.bookList) {
  64. this.bookList[key].forEach((el, index) => {
  65. new Swiper('.swiper' + index, {
  66. slidesPerView: 'auto',
  67. slidesPerGroup: 15,
  68. observer: true,
  69. navigation: {
  70. nextEl: '.icon-r' + index,
  71. prevEl: '.icon-l' + index
  72. }
  73. })
  74. })
  75. }
  76. })
  77. },
  78. // 左右架切换之后,初始化swiper位置
  79. setSwiperInit() {
  80. setTimeout(() => {
  81. this.listData.forEach((item, index) => {
  82. document.getElementsByClassName('swiper-wrapper')[index].style.transform = 'translate3d(0px, 0px, 0px)'
  83. })
  84. }, 50)
  85. },
  86. handleDetails(itemData) {
  87. const params = {
  88. isbn: itemData.isbn.replace(/\-/g, '')
  89. }
  90. getBookDetailsByISBN(params).then(res => {
  91. this.$refs.detailDom.bookData = res
  92. this.$refs.detailDom.dialogVisible = true
  93. })
  94. },
  95. // 翻页
  96. handlePage(page) {
  97. if (page === 1) {
  98. // 下一页
  99. } else {
  100. // 上一页
  101. }
  102. },
  103. // 控制左右
  104. handleDirect(n) {
  105. if (n === -1) { // 左
  106. this.classnameR = null
  107. this.classnameL = 'rack-direct-active'
  108. } else { // 右
  109. this.classnameL = null
  110. this.classnameR = 'rack-direct-active'
  111. }
  112. this.initBookshelfDetails(n)
  113. },
  114. goBack() {
  115. this.$router.go(-1)
  116. },
  117. initBookshelfDetails(n) {
  118. this.loading = true
  119. const params = {}
  120. if (n === -1) { // 左
  121. params.shelfNo = this.$route.query.leftShelfNo
  122. } else { // 右
  123. params.shelfNo = this.$route.query.rightShelfNo
  124. }
  125. initBookshelfDetails(params).then((res) => {
  126. console.log(this.listData)
  127. // if (res.shelfs.length === 0) {
  128. // res.shelfs.push('firstShelf', 'secondShelf', 'thirdShelf', 'fourthShelf', 'fivethShelf')
  129. // for (let index = 0; index < res.shelfs.length; index++) {
  130. // const shelfNo = res.shelfs[index]
  131. // res.shelfBook[shelfNo] = []
  132. // }
  133. // }
  134. this.listData.splice(0, this.listData.length, ...res.shelfAll)
  135. for (let index = 0; index < res.shelfAll.length; index++) {
  136. const shelfNo = res.shelfAll[index]
  137. this.$set(this.bookList, shelfNo, res.shelfBook[shelfNo])
  138. }
  139. if (this.listData.length > 0) {
  140. this.initSwiper()
  141. this.setSwiperInit()
  142. }
  143. setTimeout(() => {
  144. this.loading = false
  145. }, 1000)
  146. })
  147. }
  148. }
  149. }
  150. </script>
  151. <style lang="scss">
  152. @import "~@/assets/styles/index.scss";
  153. .swiper-container {
  154. position: relative;
  155. width: 100%;
  156. }
  157. .swiper-slide {
  158. width: 65px !important;
  159. }
  160. </style>