Browse Source

页面更新修改

master
xuhuajiao 7 months ago
parent
commit
466f72cecc
  1. 3
      .env.development
  2. 20
      src/api/library.js
  3. 31
      src/components/echart/barEcharts.vue
  4. 39
      src/components/echart/lineChart.vue
  5. 19
      src/components/echart/todayCircle.vue
  6. 31
      src/views/index.vue
  7. 27
      src/views/map/index.vue
  8. 9
      src/views/pageFour/index.vue
  9. 133
      src/views/pageOne/index.vue
  10. 126
      src/views/pageThree/index.vue

3
.env.development

@ -3,7 +3,8 @@ ENV = 'development'
# 接口地址 # 接口地址
# 许镇-本地服地址 # 许镇-本地服地址
VUE_APP_BASE_API = 'http://192.168.99.67:8080'
# VUE_APP_BASE_API = 'http://192.168.99.67:8080'
VUE_APP_BASE_API = 'http://27.19.209.92:13244'
VUE_APP_LIB_API = 'http://118.253.150.248:8099' VUE_APP_LIB_API = 'http://118.253.150.248:8099'
# 是否启用 babel-plugin-dynamic-import-node插件 # 是否启用 babel-plugin-dynamic-import-node插件

20
src/api/library.js

@ -64,6 +64,15 @@ export function FetchNewBook(params) {
}) })
} }
// 通过isbn获取图书详细信息
export function FetchMarcByISBN(params) {
return request({
url: '/qyzt/marcByISBN' + '?' + qs.stringify(params, { indices: false }),
method: 'get',
urlType: 'local'
})
}
// page2 获取分馆显示内容 // page2 获取分馆显示内容
export function FetchLibcodeDetails(params) { export function FetchLibcodeDetails(params) {
return request({ return request({
@ -73,6 +82,15 @@ export function FetchLibcodeDetails(params) {
}) })
} }
// 获取分馆图片资料
export function FetchLibcodeResouceDetails(params) {
return request({
url: '/qyzt/getLibcodeResouceDetails' + '?' + qs.stringify(params, { indices: false }),
method: 'get',
urlType: 'local'
})
}
// page2 读者借阅排行榜 // page2 读者借阅排行榜
export function FetchReadRanking(params) { export function FetchReadRanking(params) {
return request({ return request({
@ -135,8 +153,10 @@ export default {
FetchInitSetting, FetchInitSetting,
FetchHotSearch, FetchHotSearch,
FetchNewBook, FetchNewBook,
FetchMarcByISBN,
FetchReadRanking, FetchReadRanking,
FetchLibcodeDetails, FetchLibcodeDetails,
FetchLibcodeResouceDetails,
FetchNoticeList, FetchNoticeList,
FetchSync36, FetchSync36,
FetchTotalResource, FetchTotalResource,

31
src/components/echart/barEcharts.vue

@ -152,29 +152,17 @@ export default {
name: {} name: {}
} }
} }
// //
// var today = new Date()
// //
// var startDayOfWeek = new Date(today.getFullYear(), today.getMonth(), today.getDate() - today.getDay() + 1)
// //
// var xAxisData = []
// for (var i = 0; i < 7; i++) {
// xAxisData.push(new Date(startDayOfWeek.getFullYear(), startDayOfWeek.getMonth(), startDayOfWeek.getDate() + i).toLocaleDateString())
// }
//
function getLastWeekDates() {
var dates = []
//
var today = new Date() var today = new Date()
//
var oneWeekAgo = new Date(today.getTime() - (7 * 24 * 60 * 60 * 1000))
// X使
var xAxisData = []
for (var i = 0; i < 7; i++) { for (var i = 0; i < 7; i++) {
var day = new Date(today - i * 24 * 60 * 60 * 1000)
var dayOfWeek = day.getDay()
if (dayOfWeek === 0) {
day.setTime(day.getTime() - 5 * 24 * 60 * 60 * 1000)
}
dates.unshift(day.toLocaleDateString())
}
return dates
var day = new Date(oneWeekAgo.getTime() + (i * 24 * 60 * 60 * 1000))
xAxisData.push(echarts.format.formatTime('yyyy-MM-dd', day))
} }
option = { option = {
@ -223,7 +211,7 @@ export default {
xAxis: [{ xAxis: [{
type: 'category', type: 'category',
axisTick: { show: false }, axisTick: { show: false },
data: getLastWeekDates(),
data: this.chartWeeklyData.date,
axisLine: { // 线 axisLine: { // 线
lineStyle: { lineStyle: {
color: '#113D72' color: '#113D72'
@ -231,6 +219,7 @@ export default {
}, },
axisLabel: { // x axisLabel: { // x
show: true, show: true,
interval: 0,
textStyle: { textStyle: {
color: '#79B8FF', color: '#79B8FF',
fontSize: 16, fontSize: 16,

39
src/components/echart/lineChart.vue

@ -1,5 +1,5 @@
<template> <template>
<div id="main2" :style="{height:height,width:width}" />
<div id="main2" ref="chartContainer" :style="{height:height,width:width}" />
</template> </template>
<script> <script>
@ -69,7 +69,8 @@ export default {
}, 8000) }, 8000)
}, },
initChart() { initChart() {
const dom = document.getElementById('main2')
// const dom = document.getElementById('main2')
const dom = this.$refs.chartContainer
this.chart = echarts.init(dom, 'dark') this.chart = echarts.init(dom, 'dark')
this.setOptions(this.chartDayData) this.setOptions(this.chartDayData)
}, },
@ -199,59 +200,59 @@ export default {
], ],
series: [ series: [
{ {
name: '归还',
name: '借出',
type: 'line', type: 'line',
stack: 'Total', stack: 'Total',
itemStyle: {
color: '#41A3FF'
},
lineStyle: { lineStyle: {
width: 3, width: 3,
color: '#FFD14F'
color: '#41A3FF'
}, },
showSymbol: false, showSymbol: false,
itemStyle: {
color: '#FFD14F'
},
areaStyle: { areaStyle: {
opacity: 0.6, opacity: 0.6,
color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [ color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
{ {
offset: 0, offset: 0,
color: 'rgba(24, 176, 143, 0)'
color: 'rgba(254, 128, 66, 0)'
}, },
{ {
offset: 1, offset: 1,
color: '#FFD14F'
color: '#41A3FF'
} }
]) ])
}, },
data: returnData
data: borrowedData
}, },
{ {
name: '借出',
name: '归还',
type: 'line', type: 'line',
stack: 'Total', stack: 'Total',
itemStyle: {
color: '#41A3FF'
},
lineStyle: { lineStyle: {
width: 3, width: 3,
color: '#41A3FF'
color: '#FFD14F'
}, },
showSymbol: false, showSymbol: false,
itemStyle: {
color: '#FFD14F'
},
areaStyle: { areaStyle: {
opacity: 0.6, opacity: 0.6,
color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [ color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
{ {
offset: 0, offset: 0,
color: 'rgba(254, 128, 66, 0)'
color: 'rgba(24, 176, 143, 0)'
}, },
{ {
offset: 1, offset: 1,
color: '#41A3FF'
color: '#FFD14F'
} }
]) ])
}, },
data: borrowedData
data: returnData
} }
] ]
}) })

19
src/components/echart/todayCircle.vue

@ -86,8 +86,12 @@ export default {
const count = arrCount(optionData) const count = arrCount(optionData)
if (optionData) { if (optionData) {
const flag = optionData?.find(item => name === item.name) const flag = optionData?.find(item => name === item.name)
if (flag) return [`{name|${name}}`, `{num|${((flag.value / count * 100).toFixed(0)) + '%'}}`]
} else return name
if (flag) {
const percentage = count > 0 ? ((flag.value / count) * 100).toFixed(0) + '%' : '0%'
return [`{name|${name}}`, `{num|${percentage}}`]
}
}
return name
}, },
textStyle: { textStyle: {
rich: { rich: {
@ -106,17 +110,6 @@ export default {
} }
} }
} }
// formatter: function(name) {
// let tarValue
// const count = arrCount(optionData)
// for (let i = 0; i < optionData.length; i++) {
// if (data[i].name === name) {
// tarValue = data[i].value
// }
// }
// return [`{name|${name}}`, `{num|${((tarValue / count).toFixed(2)) * 100 + '%'}}`].join('\n')
// }
}, },
// () // ()
graphic: [ graphic: [

31
src/views/index.vue

@ -13,7 +13,15 @@
<PageTwo v-if="currentIndex === 1" /> <PageTwo v-if="currentIndex === 1" />
<PageThree v-if="currentIndex=== 2" /> <PageThree v-if="currentIndex=== 2" />
<PageFour v-if="currentIndex === 3" /> --> <PageFour v-if="currentIndex === 3" /> -->
<!-- <keep-alive exclude="PageFour">
<component :is="shouldCacheComponent" />
</keep-alive>
<component :is="currentPageComponent" /> -->
<keep-alive>
<component :is="currentPage && currentPage.title" /> <component :is="currentPage && currentPage.title" />
</keep-alive>
<!-- bottom --> <!-- bottom -->
<div class="bottom-bg"> <div class="bottom-bg">
<div class="bottom-content"> <div class="bottom-content">
@ -76,15 +84,28 @@ export default {
}, },
computed: { computed: {
shouldCacheComponent() { shouldCacheComponent() {
return this.currentPage && this.currentPage.title === 'PageOne'
if (this.currentPage) {
switch (this.currentPage.title) {
case 'PageOne':
return 'PageOne'
case 'PageFour':
return 'PageFour'
default:
return null
}
}
return null
}, },
currentPageComponent() { currentPageComponent() {
if (this.currentPage && this.currentPage.title === 'PageTwo') {
if (this.currentPage) {
switch (this.currentPage.title) {
case 'PageTwo':
return 'PageTwo' return 'PageTwo'
} else if (this.currentPage && this.currentPage.title === 'PageThree') {
case 'PageThree':
return 'PageThree' return 'PageThree'
} else if (this.currentPage && this.currentPage.title === 'PageFour') {
return 'PageFour'
default:
return null
}
} }
return null return null
} }

27
src/views/map/index.vue

@ -5,6 +5,7 @@
<div class="lib-info"> <div class="lib-info">
<div class="database-title">{{ libCurrent && libCurrent.name }}</div> <div class="database-title">{{ libCurrent && libCurrent.name }}</div>
<div class="lib-content"> <div class="lib-content">
<div style="width: 5.175rem; height: 3rem; overflow: hidden;">
<swiper v-if="swiperOption" :key="swiperKey" ref="mySwiper" class="swiperLib" :options="swiperOption"> <swiper v-if="swiperOption" :key="swiperKey" ref="mySwiper" class="swiperLib" :options="swiperOption">
<swiper-slide v-for="(item,index) in displayedImages" :key="index"> <swiper-slide v-for="(item,index) in displayedImages" :key="index">
<div class="book-img" style="width: 100%; height: 3rem;"> <div class="book-img" style="width: 100%; height: 3rem;">
@ -14,6 +15,7 @@
<!-- 标页码 --> <!-- 标页码 -->
<div slot="pagination" class="swiper-pagination" /> <div slot="pagination" class="swiper-pagination" />
</swiper> </swiper>
</div>
<ul class="lib-cont-item lib-cont01"> <ul class="lib-cont-item lib-cont01">
<li> <li>
<img src="@/assets/images/map_18.png" alt=""> <img src="@/assets/images/map_18.png" alt="">
@ -39,7 +41,7 @@
</p> </p>
</li> </li>
</ul> </ul>
<div class="scroll-container">
<div ref="scrollInfo" class="scroll-container">
<div ref="marquee" class="lib-text" :style="{ top: position + 'px' }">{{ libCurrent && libCurrent.explain }}</div> <div ref="marquee" class="lib-text" :style="{ top: position + 'px' }">{{ libCurrent && libCurrent.explain }}</div>
</div> </div>
</div> </div>
@ -84,7 +86,7 @@
</template> </template>
<script> <script>
import { FetchLibBookTotal, FetchUsertotal, FetchLibcodeDetails, FetchReadRanking, FetchLendingTotal } from '@/api/library'
import { FetchLibBookTotal, FetchUsertotal, FetchLibcodeDetails, FetchLibcodeResouceDetails, FetchReadRanking, FetchLendingTotal } from '@/api/library'
import mapJson from '@/assets/json/qy.json' import mapJson from '@/assets/json/qy.json'
import libJson from '@/assets/json/lib.json' import libJson from '@/assets/json/lib.json'
import { debounce } from 'lodash' // js, import { debounce } from 'lodash' // js,
@ -146,6 +148,9 @@ export default {
this.getReadRanking() this.getReadRanking()
this.getLendingTotal() this.getLendingTotal()
}, },
activated() {
this.getLibBookTotal()
},
mounted() { mounted() {
}, },
methods: { methods: {
@ -153,13 +158,16 @@ export default {
this.timer = setInterval(() => { this.timer = setInterval(() => {
this.position -= this.speed this.position -= this.speed
// //
const containerHeight = document.getElementsByClassName('scroll-container')[0].offsetHeight
// const containerHeight = document.getElementsByClassName('scroll-container')[0].offsetHeight
this.$nextTick(() => {
const containerHeight = this.$refs.scrollInfo.offsetHeight
const contentHeight = this.$refs.marquee.offsetHeight const contentHeight = this.$refs.marquee.offsetHeight
if (contentHeight <= containerHeight) { if (contentHeight <= containerHeight) {
this.position = 20 this.position = 20
} else if (Math.abs(this.position) >= contentHeight) { } else if (Math.abs(this.position) >= contentHeight) {
this.position = containerHeight this.position = containerHeight
} }
})
}, 40) }, 40)
}, },
getReadRanking() { getReadRanking() {
@ -340,7 +348,7 @@ export default {
}).sort((a, b) => a.sort - b.sort) }).sort((a, b) => a.sort - b.sort)
this.libInfoData = updatedLibraries this.libInfoData = updatedLibraries
// console.log('this.libInfoData', this.libInfoData)
console.log('this.libInfoData', this.libInfoData)
if (localStorage.getItem('countItem')) { if (localStorage.getItem('countItem')) {
this.count = parseInt(localStorage.getItem('countItem')) this.count = parseInt(localStorage.getItem('countItem'))
} else { } else {
@ -826,8 +834,14 @@ export default {
this.myChart.resize() this.myChart.resize()
}, },
updatePageWithData() { updatePageWithData() {
this.displayedImages = []
const linkSrc = process.env.VUE_APP_BASE_API const linkSrc = process.env.VUE_APP_BASE_API
this.displayedImages = this.libCurrent.resouce.map((item, index) => {
const params = {
'branchId': this.libCurrent.id
}
FetchLibcodeResouceDetails(params).then(res => {
const result = JSON.parse(res.data)
this.displayedImages = result.map((item, index) => {
if (item.filePath) { if (item.filePath) {
item.cover = linkSrc + '/downloadFile' + item.filePath item.cover = linkSrc + '/downloadFile' + item.filePath
} else { } else {
@ -846,6 +860,9 @@ export default {
this.autohover() this.autohover()
}, 5000) }, 5000)
} }
}).catch(error => {
console.error('Error', error)
})
}, },
initSwiper() { initSwiper() {
const _self = this const _self = this

9
src/views/pageFour/index.vue

@ -146,6 +146,9 @@ export default {
this.getNotice() this.getNotice()
this.getBookRanking() this.getBookRanking()
}, },
activated() {
this.load()
},
mounted() { mounted() {
// //
if (localStorage.getItem('wecharQrCodeSrc')) { if (localStorage.getItem('wecharQrCodeSrc')) {
@ -162,6 +165,12 @@ export default {
} }
}, },
methods: { methods: {
load() {
const video = this.$refs.videos
if (video) {
video.load()
}
},
getInitData() { getInitData() {
// wecharQrCode /downloadFile/+wecharQrCode // wecharQrCode /downloadFile/+wecharQrCode
const linkSrc = process.env.VUE_APP_BASE_API const linkSrc = process.env.VUE_APP_BASE_API

133
src/views/pageOne/index.vue

@ -101,7 +101,7 @@
<div class="database-right"> <div class="database-right">
<h3 class="database-title">热门搜索</h3> <h3 class="database-title">热门搜索</h3>
<div class="tagcloud-main"> <div class="tagcloud-main">
<div id="tagscloud" ref="tagcloudall" class="tagscloud">
<div v-if="tagList.length !== 0" id="tagscloud" ref="tagcloudall" class="tagscloud">
<!-- <a v-for="(item,index) in hotTagData" :key="index" :class="'tagc' + ((index % 4) + 1)"> <!-- <a v-for="(item,index) in hotTagData" :key="index" :class="'tagc' + ((index % 4) + 1)">
{{ item }} {{ item }}
</a> --> </a> -->
@ -160,7 +160,7 @@
</template> </template>
<script> <script>
import { FetchInitSetting, FetchUsertotal, FetchLibBookTotal, FetchHotSearch, FetchFansCount, FetchLendingTotal, FetchNewBook } from '@/api/library'
import { FetchInitSetting, FetchUsertotal, FetchLibBookTotal, FetchHotSearch, FetchFansCount, FetchLendingTotal, FetchNewBook, FetchMarcByISBN } from '@/api/library'
export default { export default {
name: 'PageOne', name: 'PageOne',
data() { data() {
@ -250,8 +250,18 @@ export default {
beforeDestroy() { beforeDestroy() {
clearInterval(this.intervalLeft) clearInterval(this.intervalLeft)
this.intervalLeft = null this.intervalLeft = null
},
activated() {
this.pageOneVisitBase = 0
this.getInitData()
},
deactivated() {
}, },
mounted() { mounted() {
if (localStorage.getItem('wecharQrCodeSrc')) {
this.wecharQrCodeSrc = localStorage.getItem('wecharQrCodeSrc')
}
}, },
methods: { methods: {
getInitData() { getInitData() {
@ -272,18 +282,6 @@ export default {
initLeftPreview(result) { initLeftPreview(result) {
this.progressData = [] this.progressData = []
this.leftData = [] this.leftData = []
// /12=
// /28293031=
// =+-2050
// =+-100200
// 8:00-18:0010
// 8:00-9:00 19:00-10:002
// /10=
// = * N+-510
// = * dd/+ -100200
// =*+-100200
//
// visitBase // visitBase
// visitBaseCheck 0false 1true // visitBaseCheck 0false 1true
@ -304,19 +302,29 @@ export default {
const baseTotal = this.pageOneVisitBase // const baseTotal = this.pageOneVisitBase //
console.log('假设本年到馆人数', baseTotal) console.log('假设本年到馆人数', baseTotal)
// /12 =
const monthBase = Math.floor(baseTotal / 12) // const monthBase = Math.floor(baseTotal / 12) //
console.log('月基数', monthBase) console.log('月基数', monthBase)
// -100200
const randomMonth = Math.floor(Math.random() * (200 - (-100) + 1)) + (-100)
const now = new Date() const now = new Date()
const year = now.getFullYear() // const year = now.getFullYear() //
const month = now.getMonth() + 1 // const month = now.getMonth() + 1 //
const daysInMonth = new Date(year, month, 0).getDate() // const daysInMonth = new Date(year, month, 0).getDate() //
console.log('当月天数', daysInMonth) console.log('当月天数', daysInMonth)
const dayBase = Math.floor(baseTotal / daysInMonth) //
// /28293031=
const dayBase = Math.floor(monthBase / daysInMonth) //
console.log('日基数', dayBase) console.log('日基数', dayBase)
// =*+-100200
let nowYearCount
if (result.visitBaseCheck === '1') {
nowYearCount = result.visitBase
} else {
nowYearCount = Math.floor(monthBase * month + randomMonth) //
}
console.log('本年累计', nowYearCount)
// =+-2050
let yesterdayCount = 0 let yesterdayCount = 0
if (result.yesterdayVisitBaseCheck === '1') { if (result.yesterdayVisitBaseCheck === '1') {
yesterdayCount = result.yesterdayVisitBase yesterdayCount = result.yesterdayVisitBase
@ -325,8 +333,7 @@ export default {
yesterdayCount = localStorage.getItem('yesterdayCountCache') ? localStorage.getItem('yesterdayCountCache') : dayBase + randomDay // yesterdayCount = localStorage.getItem('yesterdayCountCache') ? localStorage.getItem('yesterdayCountCache') : dayBase + randomDay //
} }
console.log('昨日到馆', yesterdayCount) console.log('昨日到馆', yesterdayCount)
const randomMonth = Math.floor(Math.random() * (200 - (-100) + 1)) + (-100) // -100200
// =+-100200
let lastMonthCount = 0 let lastMonthCount = 0
if (result.lastMonthVisitBaseCheck === '1') { if (result.lastMonthVisitBaseCheck === '1') {
lastMonthCount = result.lastMonthVisitBase lastMonthCount = result.lastMonthVisitBase
@ -335,18 +342,23 @@ export default {
} }
console.log('上月到馆', lastMonthCount) console.log('上月到馆', lastMonthCount)
// /10=
const hourBase = Math.floor(dayBase / 10) // const hourBase = Math.floor(dayBase / 10) //
console.log('小时基数', hourBase) console.log('小时基数', hourBase)
// 8:00-18:0010
// 8:00-9:00 19:00-10:002
const openTime = 8 // const openTime = 8 //
const closeTime = 18 // const closeTime = 18 //
const currentHour = now.getHours() // const currentHour = now.getHours() //
// = * N+-510
let todayCount = 0 let todayCount = 0
if (result.todayVisitBaseCheck === '1') { if (result.todayVisitBaseCheck === '1') {
todayCount = result.todayVisitBase todayCount = result.todayVisitBase
} else { } else {
if (currentHour < openTime || currentHour >= closeTime) { if (currentHour < openTime || currentHour >= closeTime) {
console.log('当前时间不在图书馆营业时间内') console.log('当前时间不在图书馆营业时间内')
todayCount = 0
} else { } else {
const N = currentHour - openTime const N = currentHour - openTime
console.log('第N个小时', N) console.log('第N个小时', N)
@ -355,7 +367,7 @@ export default {
} }
} }
console.log('今日到馆', todayCount) console.log('今日到馆', todayCount)
// = * dd/+ -100200
let nowMonthCount = 0 let nowMonthCount = 0
if (result.thisMonthVisitBaseCheck === '1') { if (result.thisMonthVisitBaseCheck === '1') {
nowMonthCount = result.thisMonthVisitBase nowMonthCount = result.thisMonthVisitBase
@ -364,9 +376,6 @@ export default {
} }
console.log('本月到馆', nowMonthCount) console.log('本月到馆', nowMonthCount)
const nowYearCount = Math.floor(monthBase * month + randomMonth) //
console.log('本年累计', nowYearCount)
this.progressData.push( this.progressData.push(
{ {
name: '今日到馆', name: '今日到馆',
@ -405,6 +414,7 @@ export default {
this.$parent.timedRefresh(this.leftData, 'left') this.$parent.timedRefresh(this.leftData, 'left')
//
localStorage.setItem('yesterdayCountCache', yesterdayCount) localStorage.setItem('yesterdayCountCache', yesterdayCount)
localStorage.setItem('lastMonthCountCache', lastMonthCount) localStorage.setItem('lastMonthCountCache', lastMonthCount)
}, },
@ -543,41 +553,38 @@ export default {
FetchNewBook(params).then(res => { FetchNewBook(params).then(res => {
// http://192.168.99.67:8080/downloadFile/qytsg/ae281b90-b100-4541-9379-3e104854652c.png // http://192.168.99.67:8080/downloadFile/qytsg/ae281b90-b100-4541-9379-3e104854652c.png
const linkSrc = process.env.VUE_APP_BASE_API const linkSrc = process.env.VUE_APP_BASE_API
// res.data.push({
// 'nbName': '222',
// 'nbRecno': '',
// 'isbn': '9787545559804',
// 'nbImgPath': '',
// 'nbExplain': '',
// 'nbAuthor': '',
// 'updateTime': '2024-07-05T05:22:33.307+0000',
// 'updater': 'f8ccafbb791cb89e017968aae4470000',
// 'rownum': 1,
// 'nbBooktype': '',
// 'nbPublisher': '',
// 'libcode': 'FTZN',
// 'sortmark': '',
// 'createTime': '2024-07-05T05:22:33.307+0000',
// 'creater': 'f8ccafbb791cb89e017968aae4470000',
// 'nbId': '4028e3c39080e175019081581b1c008f',
// 'nbPublisherdate': ''
// })
this.newList = res.data.filter((item) => {
this.newList = res.data.map(item => {
if (item.nbImgPath) { if (item.nbImgPath) {
item.nbImgPath = linkSrc + '/downloadFile' + item.nbImgPath item.nbImgPath = linkSrc + '/downloadFile' + item.nbImgPath
return true
return Promise.resolve(item)
} else {
const params = {
'sIsbn': item.isbn
}
return FetchMarcByISBN(params).then(response => {
const result = JSON.parse(response.data)[0]
if (result.srcurl) {
item.nbImgPath = result.srcurl
return item
} else if (result.img) {
item.nbImgPath = 'data:image/png;base64,' + result.img
return item
} else { } else {
// 'nbImgPath/srcurl/base64
return false
return null //
}
})
} }
}) })
Promise.all(this.newList).then(results => {
//
this.newList = results.filter(item => item !== null)
//
const halfLength = Math.ceil(this.newList.length / 2) const halfLength = Math.ceil(this.newList.length / 2)
this.listData1 = this.newList.slice(0, halfLength) this.listData1 = this.newList.slice(0, halfLength)
this.listData2 = this.newList.slice(halfLength) this.listData2 = this.newList.slice(halfLength)
}) })
})
}, },
getType1Value() { getType1Value() {
const type1Item = this.progressData.find(item => item.type === 1) const type1Item = this.progressData.find(item => item.type === 1)
@ -784,29 +791,31 @@ export default {
text-wrap: nowrap; text-wrap: nowrap;
} }
#tagscloud a.tagc1{ #tagscloud a.tagc1{
border: 1px solid #30ADA6;
background-color: #106B66;
color: #51EAE2;
// border: 1px solid #30ADA6;
// background-color: #106B66;
// color: #51EAE2;
color: #F4C263;
} }
#tagscloud a.tagc2{ #tagscloud a.tagc2{
font-size: 16px;
border: 1px solid #3A64BE;
background: rgba(16,45,107,0.7);
font-size: 22px;
// border: 1px solid #3A64BE;
// background: rgba(16,45,107,0.7);
color: #7EA7FF; color: #7EA7FF;
} }
#tagscloud a.tagc3{ #tagscloud a.tagc3{
font-size: 22px;
border: 1px solid #9439B6;
background: rgba(74,18,95,0.8);
color: #CD63F4;
font-size: 18px;
// border: 1px solid #9439B6;
// background: rgba(74,18,95,0.8);
// color: #CD63F4;
color: #7EA7FF;
} }
#tagscloud a.tagc4{ #tagscloud a.tagc4{
font-size: 26px; font-size: 26px;
border: 1px solid #C2943C;
background: rgba(107,76,16,0.7);
// border: 1px solid #C2943C;
// background: rgba(107,76,16,0.7);
color: #F4C263; color: #F4C263;
} }

126
src/views/pageThree/index.vue

@ -1,3 +1,4 @@
<!-- eslint-disable no-prototype-builtins -->
<template> <template>
<div class="page-wrapper "> <div class="page-wrapper ">
<div class="page-three"> <div class="page-three">
@ -132,6 +133,7 @@ export default {
borrowedData: [] borrowedData: []
}, },
chartWeeklyData: { chartWeeklyData: {
date: [],
inchartWeeklyData: [], inchartWeeklyData: [],
outchartWeeklyData: [] outchartWeeklyData: []
}, },
@ -253,7 +255,23 @@ export default {
}) })
}, },
rankingDataComputed(rankingData, numType) { rankingDataComputed(rankingData, numType) {
const firstPlaceNum = rankingData[0][numType]
if (!rankingData || rankingData.length === 0) {
console.log('没有数据')
return []
}
// eslint-disable-next-line no-prototype-builtins
if (typeof rankingData[0] !== 'object' || !rankingData[0].hasOwnProperty(numType)) {
return []
}
const firstPlaceNum = rankingData[0][numType] // NAN
if (firstPlaceNum === 0) {
// 0
console.log('firstPlaceNum为0,不可用于被除')
return []
}
return rankingData.map(item => { return rankingData.map(item => {
const percentage = (item[numType] / firstPlaceNum) * 100 const percentage = (item[numType] / firstPlaceNum) * 100
return { ...item, percentage } return { ...item, percentage }
@ -264,13 +282,27 @@ export default {
FetchTodayJH().then(res => { FetchTodayJH().then(res => {
const result = res.data const result = res.data
if (result.length !== 0) { if (result.length !== 0) {
this.chartDayData.timeData = result.map(item => {
const hour = item.logHour.toString().padStart(2, '0')
return `${hour}:00`
this.chartDayData = {
timeData: [],
returnData: [],
borrowedData: []
}
const time = ['07:00', '08:00', '09:00', '10:00', '11:00', '12:00', '13:00', '14:00', '15:00', '16:00', '17:00', '18:00']
time.forEach((hour, index) => {
// result logHour
const foundItem = result.find(item => item.logHour === index + 7) // logHour 7 7
if (foundItem) {
// logHour chartDayData
this.chartDayData.timeData.push(`${foundItem.logHour}:00`)
this.chartDayData.returnData.push(foundItem.hccDay)
this.chartDayData.borrowedData.push(foundItem.jccDay)
} else {
// logHour chartDayData
this.chartDayData.timeData.push(`${hour}`)
this.chartDayData.returnData.push(0) // 0
this.chartDayData.borrowedData.push(0) // 0
}
}) })
this.chartDayData.returnData = result.map(item => item.jccDay)
this.chartDayData.borrowedData = result.map(item => item.hccDay)
// console.log('this.chartDayData ', this.chartDayData)
} else { } else {
this.chartDayData = { this.chartDayData = {
timeData: [], timeData: [],
@ -284,15 +316,56 @@ export default {
}, },
getWeekJH() { getWeekJH() {
FetchWeekJH().then(res => { FetchWeekJH().then(res => {
// console.log(res)
const result = res.data const result = res.data
if (result.length !== 0) { if (result.length !== 0) {
//
const currentDate = new Date()
const today = currentDate.toISOString().slice(0, 10)
//
const filteredData = result.filter(entry => {
const entryDate = new Date(entry.createTime).toISOString().slice(0, 10)
return entryDate !== today
})
//
const pastWeekDates = []
for (let i = 1; i <= 7; i++) {
const date = new Date()
date.setDate(currentDate.getDate() - i)
pastWeekDates.push(date.toISOString().slice(0, 10))
}
const matchData = filteredData.reduce((accData, item) => {
//
const entryDate = new Date(item.createTime).toISOString().slice(0, 10)
if (accData[entryDate]) {
accData[entryDate].jccDayTotal += item.jccDayTotal
accData[entryDate].hccDayTotal += item.hccDayTotal
} else {
accData[entryDate] = {
jccDayTotal: item.jccDayTotal,
hccDayTotal: item.hccDayTotal
}
}
return accData
}, {})
const completeData = pastWeekDates.map(date => ({
date: date.split('-').join('/'),
jccDayTotal: matchData[date] ? matchData[date].jccDayTotal : 0,
hccDayTotal: matchData[date] ? matchData[date].hccDayTotal : 0
}))
//
completeData.sort((a, b) => new Date(a.date) - new Date(b.date))
// X
this.chartWeeklyData.date = completeData.map(item => item.date)
// in // in
this.chartWeeklyData.inchartWeeklyData = this.barSevenDaysData(result).map(item => item.hccDayTotal)
// out
this.chartWeeklyData.outchartWeeklyData = this.barSevenDaysData(result).map(item => item.jccDayTotal)
this.chartWeeklyData.inchartWeeklyData = completeData.map(item => item.hccDayTotal)
// // out
this.chartWeeklyData.outchartWeeklyData = completeData.map(item => item.jccDayTotal)
} else { } else {
this.chartWeeklyData = { this.chartWeeklyData = {
date: [],
inchartWeeklyData: [], inchartWeeklyData: [],
outchartWeeklyData: [] outchartWeeklyData: []
} }
@ -300,37 +373,6 @@ export default {
}).catch(error => { }).catch(error => {
console.error('Error', error) console.error('Error', error)
}) })
},
// 2024-7-21
barSevenDaysData(data) {
const currentDate = new Date()
currentDate.setUTCHours(0, 0, 0, 0)
const dateRange = []
for (let i = 0; i < 7; i++) {
const date = new Date(currentDate)
date.setDate(date.getDate() - i)
dateRange.push(date.toISOString().slice(0, 10))
}
const datesInData = data.map(item => item.createTime.slice(0, 10))
for (const date of dateRange) {
if (!datesInData.includes(date)) {
data.push({
'jccDayTotal': 0,
'hccDayTotal': 0,
'createTime': date
})
}
}
data.sort((a, b) => {
if (a.createTime < b.createTime) return -1
if (a.createTime > b.createTime) return 1
return 0
})
if (data.length > 7) {
data = data.slice(data.length - 7)
}
return data
} }
} }
} }

Loading…
Cancel
Save