图书馆综合管理系统
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.

308 lines
11 KiB

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
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 class="app-container">
  3. <div class="venue-header dataScreening-header">
  4. <h4><i class="iconfont icon-shuju" />区域总览</h4>
  5. <div class="bookshelf-area">
  6. <!-- <span class="bookshelf-area">{{ floorName }} </span> -->
  7. <router-link :to="{ path: '/check/check/dataScreening', query: {floorTabIndex: floorTabIndex }}">
  8. {{ floorName }}
  9. </router-link>
  10. <div class="double-click-btn"><span>点击左侧位置返回</span></div>
  11. </div>
  12. <p><i class="iconfont icon-gongsi" />{{ user.fonds.fondsName }}</p>
  13. </div>
  14. <div class="venue-content dataScreening-content">
  15. <crudOperation :permission="permission">
  16. <template v-slot:middle>
  17. <el-button v-permission="permission.add" class="check-btn" size="mini" @click="toAdd(2)">
  18. <i class="iconfont icon-shengchengpandiandan" />
  19. 区域盘点
  20. </el-button>
  21. </template>
  22. <template v-slot:right>
  23. <el-button :loading="crud.downloadLoading" size="mini" @click="doExport(2)">
  24. <i class="iconfont icon-daochu" />
  25. 导出
  26. </el-button>
  27. </template>
  28. </crudOperation>
  29. <div class="venue-left">
  30. <div class="container-right tab-content">
  31. <span class="right-top-line" />
  32. <span class="left-bottom-line" />
  33. <ul class="tab-nav">
  34. <li v-for="(item,index) in regionOptions" :key="index" :class="{ 'active-tab-nav': tabIndex == index }" @click="changeActiveTab(index)">{{ item.regionName }}<i /></li>
  35. <!-- 最右侧装饰img -->
  36. <span class="tab-right-img" />
  37. </ul>
  38. <CanvasPreview ref="previewRefs" v-loading="prewLoading" page-preview="region" :current-mark-data="currentMarkData" :image-url="imageUrl" />
  39. </div>
  40. </div>
  41. <div class="venue-right">
  42. <div class="lib-right-item lib-info">
  43. <h4>本区概况</h4>
  44. <ul class="data-right-list">
  45. <li><p>书架</p><span><i>{{ baseData.shelfCount }}</i></span></li>
  46. <li><p>摄像头</p><span><i>{{ baseData.deviceCount }}</i></span></li>
  47. </ul>
  48. </div>
  49. <div class="lib-right-item">
  50. <h4>本区盘点概况</h4>
  51. <!-- <div class="refresh-date">2024-11-28 09:46</div> -->
  52. <ul class="data-right-list">
  53. <li><p>在架</p><span><i>{{ baseStockData.onShelfNum }}</i></span></li>
  54. <li><p>错架</p><span><i>{{ baseStockData.errorShelfNum }}</i></span> <span class="percentage">{{ baseStockData.errorShelfProbo }}</span></li>
  55. <li><p>错序</p><span><i>{{ baseStockData.errorOrderNum }}</i></span><span class="percentage">{{ baseStockData.errorOrderProbo }}</span></li>
  56. </ul>
  57. </div>
  58. <div class="lib-right-item">
  59. <h4>本区流通统计</h4>
  60. <div class="refresh-date">2024-11-28 09:46</div>
  61. <bookSwiper ref="bookSwiperRefs" />
  62. </div>
  63. </div>
  64. </div>
  65. <eForm ref="eform" />
  66. <exportForm ref="exportform" export-type="regions" />
  67. </div>
  68. </template>
  69. <script>
  70. import { FetchInitStockInfo } from '@/api/stockTask/index'
  71. import { dataScreeningCrud } from '@/views/visualCheck/mixins/index'
  72. import crudRegion from '@/api/area/index'
  73. import { FetchInitBookShelfList } from '@/api/shelf/index'
  74. import CRUD, { presenter, header, crud } from '@crud/crud'
  75. import crudOperation from '@crud/CRUD.operation'
  76. import { mapGetters } from 'vuex'
  77. import defaultImg from '@/assets/images/system/default-img.jpg'
  78. import bookSwiper from '@/views/components/bookSwiper.vue'
  79. import CanvasPreview from '@/views/components/canvasPreview.vue'
  80. import eForm from './module/form'
  81. import exportForm from './module/export'
  82. export default {
  83. name: 'DataScreening',
  84. components: { crudOperation, bookSwiper, CanvasPreview, eForm, exportForm },
  85. cruds() {
  86. return CRUD({ title: '区域总览', url: 'api/libraryRegion/initLibraryRegionList', crudMethod: { ...crudRegion }, sort: [], optShow: {
  87. add: false,
  88. edit: false,
  89. del: false,
  90. download: false,
  91. group: false,
  92. reset: false
  93. }
  94. })
  95. },
  96. mixins: [presenter(), header(), crud(), dataScreeningCrud],
  97. data() {
  98. const _this = this
  99. return {
  100. prewLoading: false,
  101. regionOptions: [],
  102. floorName: null,
  103. currentRegionId: null,
  104. tabIndex: 0,
  105. floorTabIndex: 0,
  106. defaultImg: defaultImg,
  107. imageUrl: defaultImg,
  108. imageRegionUrl: defaultImg,
  109. currentMarkData: null,
  110. allCoverData: [],
  111. swiperActiveIndex: 0,
  112. rightDataIndex: null,
  113. swiperOptionContent: {
  114. slidesPerView: 'auto',
  115. on: {
  116. slideChangeTransitionStart: function() {
  117. _this.rightDataIndex = null
  118. _this.swiperActiveIndex = this.activeIndex
  119. _this.swiperTitle.slideTo(this.activeIndex, 500, false)
  120. }
  121. }
  122. },
  123. swiperOptionTitle: {
  124. slidesPerView: 'auto',
  125. freeMode: true
  126. },
  127. tabListData: [{ name: '热门图书' }, { name: '热门架位' }, { name: '冷面图书' }],
  128. permission: {
  129. add: ['admin', 'floor:add'],
  130. edit: ['admin', 'floor:edit'],
  131. del: ['admin', 'floor:del']
  132. },
  133. baseStockDataAllShelf: [],
  134. swiperParams: {},
  135. swiperShelfParams: {}
  136. }
  137. },
  138. computed: {
  139. ...mapGetters([
  140. 'user',
  141. 'baseApi'
  142. ]),
  143. swiperContent() {
  144. return this.$refs.swiperContent.$el.swiper
  145. }
  146. },
  147. methods: {
  148. handleToShelfs() {
  149. this.$router.push({ path: '/dataScreening/shelf', query: { }})
  150. },
  151. [CRUD.HOOK.beforeRefresh]() {
  152. const data = JSON.parse(localStorage.getItem('dataScreenFloor'))
  153. this.crud.query.floorId = data.floorId
  154. this.currentRegionId = data.id
  155. },
  156. [CRUD.HOOK.afterRefresh](crud) {
  157. if (localStorage.getItem('dataScreenFloorTableIndex')) {
  158. this.floorTabIndex = localStorage.getItem('dataScreenFloorTableIndex')
  159. }
  160. this.regionOptions = crud.data
  161. const item = this.regionOptions.find(element => element.id === this.currentRegionId)
  162. let index
  163. if (this.$route.query.regionTabIndex) {
  164. index = this.$route.query.regionTabIndex
  165. } else {
  166. index = item ? this.regionOptions.indexOf(item) : -1
  167. }
  168. this.floorName = this.regionOptions[index].floorName
  169. this.tabIndex = index
  170. this.changeActiveTab(index)
  171. // 盘点概况
  172. const params = {
  173. 'floorId': this.regionOptions[this.tabIndex].floorId,
  174. 'regionId': this.regionOptions[this.tabIndex].id
  175. }
  176. this.handleInitStockInfo(params)
  177. this.$nextTick(() => {
  178. this.$refs.bookSwiperRefs.swiperParams = params
  179. this.$refs.bookSwiperRefs.swiperShelfParams = params
  180. if (this.$refs.bookSwiperRefs.swiperActiveIndex === 0) {
  181. this.$refs.bookSwiperRefs.getInitHotBookList()
  182. } else {
  183. this.$refs.bookSwiperRefs.getInitHotShelfList()
  184. }
  185. })
  186. },
  187. // 提交前的验证
  188. [CRUD.HOOK.afterValidateCU](crud) {
  189. return true
  190. },
  191. toAdd(type) {
  192. this.$refs.eform.formVisible = true
  193. this.$refs.eform.form.regionId = this.regionOptions[this.tabIndex].id
  194. this.$refs.eform.form.stockRegion = this.regionOptions[this.tabIndex].floorName + this.regionOptions[this.tabIndex].regionName
  195. this.$refs.eform.setData(type)
  196. },
  197. doExport(type) {
  198. this.$refs.exportform.formExportVisible = true
  199. this.$refs.exportform.type = 2
  200. this.$refs.exportform.params = {
  201. 'regionId': this.regionOptions[this.tabIndex].id
  202. }
  203. },
  204. async getInitStockInfo(data) {
  205. const promises = data.map(item => {
  206. const params = {
  207. 'floorId': this.floorId,
  208. 'regionId': this.regionId,
  209. 'shelfId': item.shelfId
  210. }
  211. return FetchInitStockInfo(params)
  212. })
  213. const results = await Promise.all(promises)
  214. if (!Array.isArray(this.baseStockDataAllShelf)) {
  215. this.baseStockDataAllShelf = []
  216. }
  217. // 为每个结果对象添加id字段
  218. results.forEach((result, index) => {
  219. result.id = data[index].shelfId
  220. })
  221. this.baseStockDataAllShelf = this.baseStockDataAllShelf.concat(results)
  222. return this.baseStockDataAllShelf
  223. },
  224. async changeActiveTab(index) {
  225. this.prewLoading = true
  226. this.tabIndex = index
  227. const params = {
  228. 'floorId': this.regionOptions[index].floorId,
  229. 'regionId': this.regionOptions[index].id
  230. }
  231. try {
  232. const res = await FetchInitBookShelfList(params)
  233. console.log(res)
  234. this.allCoverData = res.content
  235. if (this.regionOptions[index].regionMap) {
  236. this.imageUrl = this.baseApi + '/api/fileRelevant/getImg?imgId=' + this.regionOptions[index].regionMap
  237. } else {
  238. this.imageUrl = this.defaultImg
  239. }
  240. if (this.allCoverData.length !== 0) {
  241. this.currentMarkData = this.regionOptions[index]
  242. const signPoint = this.allCoverData.find(item => item.signPoint !== null)?.signPoint
  243. const imgInfo = signPoint ? JSON.parse(signPoint).imgInfo : null
  244. const baseStockDataAllShelf = await this.getInitStockInfo(this.allCoverData)
  245. const parsedSignPoints = this.allCoverData.map(item => {
  246. const signPoint = item.signPoint ? JSON.parse(item.signPoint) : null
  247. return {
  248. id: item.shelfId,
  249. name: item.shelfName,
  250. rowType: item.rowType,
  251. toward: item.toward,
  252. floorName: item.floorName,
  253. regionName: item.regionName,
  254. shelfFloor: item.shelfFloor,
  255. shelfShelf: item.shelfShelf,
  256. floorId: this.regionOptions[index].floorId,
  257. regionId: this.regionOptions[index].id,
  258. pointInfo: signPoint ? signPoint.pointInfo[0].pointInfo : null
  259. }
  260. })
  261. parsedSignPoints.forEach(parsedItem => {
  262. const baseStockItem = baseStockDataAllShelf.find(baseItem => baseItem.id === parsedItem.id)
  263. if (baseStockItem) {
  264. Object.assign(parsedItem, baseStockItem)
  265. }
  266. })
  267. const result = {
  268. pointInfo: parsedSignPoints,
  269. imgInfo: imgInfo
  270. }
  271. console.log('result', result)
  272. this.$nextTick(() => {
  273. this.$refs.previewRefs.initCanvasPreview(result, this.tabIndex)
  274. })
  275. } else {
  276. this.currentMarkData = {}
  277. setTimeout(() => {
  278. this.prewLoading = false
  279. }, 500)
  280. }
  281. } catch (error) {
  282. console.error(error)
  283. }
  284. },
  285. handleSlidClickFun(index) {
  286. this.rightDataIndex = null
  287. this.handleSlideToFun(index)
  288. },
  289. handleSlideToFun(index) {
  290. this.swiperActiveIndex = index
  291. this.swiperContent.slideTo(index, 500, false)
  292. this.swiperTitle.slideTo(index, 500, false)
  293. }
  294. }
  295. }
  296. </script>
  297. <style lang="scss" scoped>
  298. </style>