江夏区图书馆自助查询机
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.

200 lines
6.3 KiB

6 months ago
5 months ago
6 months ago
5 months ago
6 months ago
5 months ago
6 months ago
5 months ago
6 months ago
5 months ago
6 months ago
5 months ago
6 months ago
5 months ago
6 months ago
5 months ago
6 months ago
  1. <template>
  2. <div class="content-main">
  3. <Search refs="searchRefs" search-type="noList" />
  4. <div class="box-style" style="margin: 30px 44px;">
  5. <div class="dataScreening-header">
  6. <h4 class="filter-header">图书馆总览</h4>
  7. </div>
  8. <div class="home-wrap tab-content">
  9. <swiper
  10. ref="swiperTitle"
  11. class="swiper-title"
  12. :options="swiperOptionTitle"
  13. :auto-update="true"
  14. :auto-destroy="true"
  15. >
  16. <swiper-slide
  17. v-for="(item,index) in floorOptions"
  18. :key="index"
  19. ref="swiperSlideItem"
  20. class="swiper-slide-title"
  21. >
  22. <div
  23. class="tab-name"
  24. :class="{ active: index === tabIndex }"
  25. @click="changeActiveTab(index)"
  26. >
  27. {{ item.floorName }}
  28. </div>
  29. </swiper-slide>
  30. </swiper>
  31. <!-- <ul class="tab-nav">
  32. <li v-for="(item,index) in floorOptions" :key="index" :class="{ 'active-tab-nav': tabIndex == index }" @click="changeActiveTab(index)">{{ item.floorName }}<i /></li>
  33. </ul> -->
  34. <CanvasPreview ref="previewRefs" v-loading="prewLoading" page-preview="floor" :current-mark-data="currentMarkData" :image-url="imageUrl" />
  35. </div>
  36. </div>
  37. <div class="index-ranking">
  38. <div class="box-style">
  39. <Ranking form-ranking="home" />
  40. </div>
  41. <div class="box-style">
  42. <ShelfRanking />
  43. </div>
  44. </div>
  45. </div>
  46. </template>
  47. <script>
  48. import { FetchLibraryFloorListByFondsNo, FetchRegionListByFloorId, FetchInitStockInfo } from '@/api/inquiryMachine'
  49. import CanvasPreview from './module/canvasPreview'
  50. import { positionCrud } from './mixins/index.js'
  51. import Search from './module/search'
  52. import Ranking from './module/ranking'
  53. import ShelfRanking from './module/shelfRanking'
  54. import defaultImg from '@/assets/images/default-img-bg.jpg'
  55. import { swiper, swiperSlide } from 'vue-awesome-swiper'
  56. import 'swiper/swiper-bundle.css'
  57. export default {
  58. name: 'Index',
  59. components: {
  60. Search, CanvasPreview, Ranking, ShelfRanking, swiper, swiperSlide
  61. },
  62. mixins: [positionCrud],
  63. data() {
  64. return {
  65. prewLoading: false,
  66. floorOptions: [],
  67. tabIndex: 0,
  68. defaultImg: defaultImg,
  69. imageUrl: defaultImg,
  70. imageRegionUrl: defaultImg,
  71. currentMarkData: null,
  72. allCoverData: [],
  73. baseStockDataAllShelf: [],
  74. swiperOptionTitle: {
  75. slidesPerView: 'auto',
  76. freeMode: true
  77. }
  78. }
  79. },
  80. computed: {
  81. swiperTitle() {
  82. return this.$refs.swiperTitle.$el.swiper
  83. }
  84. },
  85. created() {
  86. this.getFloorList()
  87. },
  88. mounted() {
  89. },
  90. beforeDestroy() {
  91. },
  92. methods: {
  93. getFloorList() {
  94. FetchLibraryFloorListByFondsNo({ 'fondsCode': this.libcode }).then(res => {
  95. this.floorOptions = res
  96. this.changeActiveTab(this.tabIndex)
  97. }).catch(() => {
  98. this.$message.error('接口错误')
  99. })
  100. },
  101. async changeActiveTab(index) {
  102. const baseUrl = process.env.NODE_ENV === 'production' ? window.g.ApiUrl : process.env.VUE_APP_BASE_API
  103. this.prewLoading = true
  104. if (this.$refs.previewRefs.canvasPreview.lowerCanvasEl) {
  105. this.$refs.previewRefs.canvasPreview.clear()
  106. this.$refs.previewRefs.canvasPreview.dispose()
  107. }
  108. this.allCoverData = []
  109. this.tabIndex = index
  110. this.swiperTitle.slideTo(index, 500, false)
  111. const params = {
  112. 'floorId': this.floorOptions[index].id
  113. }
  114. try {
  115. const res = await FetchRegionListByFloorId(params)
  116. console.log(res)
  117. this.allCoverData = res
  118. if (this.floorOptions[index].floorMap) {
  119. this.imageUrl = baseUrl + '/api/fileRelevant/getImg?imgId=' + this.floorOptions[index].floorMap
  120. } else {
  121. this.imageUrl = this.defaultImg
  122. }
  123. if (this.allCoverData.length !== 0) {
  124. this.currentMarkData = this.allCoverData[0]
  125. // const signPoint = this.allCoverData.find(item => item.signPoint !== null)?.signPoint
  126. const imgInfo = JSON.parse(this.allCoverData[0].signPoint).imgInfo
  127. const baseStockDataAllShelf = await this.getInitStockInfo(this.allCoverData)
  128. const parsedSignPoints = this.allCoverData.map(item => {
  129. const signPoint = item.signPoint ? JSON.parse(item.signPoint) : null
  130. return {
  131. id: item.id,
  132. name: item.regionName,
  133. floorName: this.floorOptions[index].floorName,
  134. floorId: item.floorId,
  135. pointInfo: signPoint ? signPoint.pointInfo[0].pointInfo : null
  136. }
  137. })
  138. parsedSignPoints.forEach(parsedItem => {
  139. const baseStockItem = baseStockDataAllShelf.find(baseItem => baseItem.id === parsedItem.id)
  140. if (baseStockDataAllShelf) {
  141. Object.assign(parsedItem, baseStockItem)
  142. }
  143. })
  144. const result = {
  145. pointInfo: parsedSignPoints,
  146. imgInfo: imgInfo
  147. }
  148. console.log('result', result)
  149. this.$nextTick(() => {
  150. this.$refs.previewRefs.initCanvasPreview(result, this.tabIndex)
  151. })
  152. } else {
  153. this.currentMarkData = {}
  154. setTimeout(() => {
  155. this.prewLoading = false
  156. }, 500)
  157. }
  158. } catch (error) {
  159. console.error(error)
  160. }
  161. },
  162. async getInitStockInfo(data) {
  163. const promises = data.map(item => {
  164. const params = {
  165. 'fondsCode': this.libcode,
  166. 'floorId': this.floorOptions[this.tabIndex].id,
  167. 'regionId': item.id
  168. }
  169. return FetchInitStockInfo(params)
  170. })
  171. const results = await Promise.all(promises)
  172. if (!Array.isArray(this.baseStockDataAllShelf)) {
  173. this.baseStockDataAllShelf = []
  174. }
  175. // 为每个结果对象添加id字段
  176. results.forEach((result, index) => {
  177. result.id = data[index].id
  178. })
  179. this.baseStockDataAllShelf = this.baseStockDataAllShelf.concat(results)
  180. return this.baseStockDataAllShelf
  181. }
  182. }
  183. }
  184. </script>
  185. <style lang="scss" scoped>
  186. @import "~@/assets/styles/index.scss";
  187. </style>