Browse Source

需求更新优化

master
xuhuajiao 1 month ago
parent
commit
5d799d194e
  1. 3
      src/assets/json/lib.json
  2. 8
      src/components/echart/todayCircle.vue
  3. 8
      src/components/echart/yearCircle.vue
  4. 2
      src/views/index.vue
  5. 67
      src/views/map/index.vue
  6. 15
      src/views/pageOne/index.vue
  7. 18
      src/views/pageThree/index.vue

3
src/assets/json/lib.json

@ -1,3 +1,4 @@
{
"葛店城市书房":[114.664064,30.478882]
"大湾城市书房":[114.664064,30.478882],
"张家湾城市书房":[114.635376,30.532215]
}

8
src/components/echart/todayCircle.vue

@ -40,8 +40,8 @@ export default {
methods: {
initTodayCircle() {
const optionData = [
{ value: this.todayAllNum.headerLib || 0, name: '总馆' },
{ value: this.todayAllNum.branchLib || 0, name: '分馆' }
{ value: this.todayAllNum.headerLib || 0, name: '大湾' },
{ value: this.todayAllNum.branchLib || 0, name: '张家湾' }
]
const myChart = this.$echarts.init(document.getElementById('todayType'))
@ -70,7 +70,7 @@ export default {
},
legend: {
orient: 'vertical',
right: 70,
right: 40,
top: 55,
// textStyle: {
// color: '#EEF6FF',
@ -81,7 +81,7 @@ export default {
itemHeight: 10,
icon: 'circle',
selectedMode: false,
data: ['总馆', '分馆'],
data: ['大湾', '张家湾'],
formatter: (name) => {
// `${name} ${((flag.value / count).toFixed(2)) * 100 + '%'}`
const count = arrCount(optionData)

8
src/components/echart/yearCircle.vue

@ -40,8 +40,8 @@ export default {
methods: {
initYearCircle() {
const optionData = [
{ value: this.yearAllNum.headerLib || 0, name: '总馆' },
{ value: this.yearAllNum.branchLib || 0, name: '分馆' }
{ value: this.yearAllNum.headerLib || 0, name: '大湾' },
{ value: this.yearAllNum.branchLib || 0, name: '张家湾' }
]
const myChart = this.$echarts.init(document.getElementById('modelType'))
@ -70,7 +70,7 @@ export default {
},
legend: {
orient: 'vertical',
right: 70,
right: 40,
top: 55,
// textStyle: {
// color: '#EEF6FF',
@ -81,7 +81,7 @@ export default {
itemHeight: 10,
icon: 'circle',
selectedMode: false,
data: ['总馆', '分馆'],
data: ['大湾', '张家湾'],
formatter: (name) => {
// `${name} ${((flag.value / count).toFixed(2)) * 100 + '%'}`
const count = arrCount(optionData)

2
src/views/index.vue

@ -12,7 +12,7 @@
</keep-alive>
<PageTwo v-if="currentIndex === 1" />
<PageThree v-if="currentIndex=== 2" />
<PageFour v-if="currentIndex === 2" /> -->
<PageFour v-if="currentIndex === 3" /> -->
<keep-alive>
<component :is="currentPage && currentPage.title" />

67
src/views/map/index.vue

@ -208,7 +208,7 @@ export default {
this.currentHover = (this.currentHover + 1) % this.rankingData.length
}, 1000)
} else {
throw new Error('Failed' + libcode)
throw new Error('Failed')
}
}).catch(error => {
console.error('Error', error)
@ -237,7 +237,7 @@ export default {
const result = JSON.parse(res.data)
if (result.success & result.resultlist.length !== 0) {
// BZL_YEAR
this.cardTotal = result.resultlist.filter(item => item.LIBCODE === 'DWSF').reduce((acc, obj) => acc + obj.BZL_YEAR, 0)
this.cardTotal = result.resultlist.filter(item => item.LIBCODE === 'GD').reduce((acc, obj) => acc + obj.BZL_YEAR, 0)
} else {
this.cardTotal = 0
}
@ -252,36 +252,61 @@ export default {
'starttime': '2000-01-01',
'endtime': '2034-01-01'
}
FetchLibBookTotal(params).then(res => {
//
this.libALLNum = []
FetchLibBookTotal(params)
.then(res => {
const result = JSON.parse(res.data)
if (result.success & result.resultlist.length !== 0) {
//
if (result.success && result.resultlist.length !== 0) {
this.libALLNum = result.resultlist
} else {
this.libALLNum = []
}
this.getUserTotal()
return this.getUserTotal()
})
.then(userTotals => {
console.log('userTotal', userTotals)
if (Array.isArray(userTotals) && userTotals.length > 0) {
userTotals.forEach(userTotal => {
const libCode = Object.keys(userTotal)[0]
const count = userTotal[libCode]
const foundItem = this.libALLNum.find(item => item.LIBCODE === libCode)
if (foundItem) {
foundItem.countCard = count
} else {
this.libALLNum.push({
LIBCODE: libCode,
countCard: count
})
}
})
}
//
this.getLibcodeDetails()
})
.catch(error => {
console.error('Error', error)
this.getLibcodeDetails()
// 使 getUserTotal countCard
this.getUserTotal()
.then(userTotals => {
console.log('userTotal (error case)', userTotals)
if (Array.isArray(userTotals) && userTotals.length > 0) {
userTotals.forEach(userTotal => {
const libCode = Object.keys(userTotal)[0]
const count = userTotal[libCode]
this.libALLNum.push({
LIBCODE: libCode,
countCard: count
})
}).catch(error => {
console.error('Error', error)
this.libALLNum = []
})
}
})
.finally(() => {
this.getLibcodeDetails()
})
})
},
//
getTotalForLibcode(libcode) {
@ -304,7 +329,7 @@ export default {
})
},
getUserTotal() {
const libraries = ['DWSF']
const libraries = ['GD']
const getTotalPromises = libraries.map(libcode => this.getTotalForLibcode(libcode))
return Promise.all(getTotalPromises)
.then(results => {
@ -321,11 +346,13 @@ export default {
const result = JSON.parse(res.data)
if (result.length !== 0) {
const libCode = {
'DWSF': [114.664064, 30.478882]
'DWSF': [114.664064, 30.478882],
'ZJWSF': [114.635376, 30.532215]
}
// console.log('this.libALLNum', this.libALLNum)
const updatedLibraries = result.map(library => {
const matchingData = this.libALLNum.find(item => item.LIBCODE === library.tcId)
console.log('matchingData', matchingData)
const gdData = this.libALLNum.find(item => item.LIBCODE === 'GD')
if (matchingData) {
return {
...library,
@ -337,10 +364,10 @@ export default {
} else {
return {
...library,
GCL: 0,
GCL: 10000,
sort: Object.keys(libCode).indexOf(library.tcId) + 1,
coordinate: libCode[library.tcId],
countCard: 0
countCard: gdData?.countCard || 0
}
}
}).sort((a, b) => a.sort - b.sort)
@ -376,7 +403,7 @@ export default {
mapImg.src = require('../../assets/images/map-bg2.png')
var XAData = this.libInfoData.map(item => {
return [
{ name: '葛店城市书房' },
{ name: '大湾城市书房' },
{ name: item.name, value: item.address }
]
})
@ -399,7 +426,7 @@ export default {
}
var series = [];
[
['葛店城市书房', XAData]
['大湾城市书房', XAData]
].forEach(function(item, i) {
series.push(
{

15
src/views/pageOne/index.vue

@ -267,9 +267,7 @@ export default {
FetchInitIntoNum()
.then(res => {
console.log('InitIntoNum response:', res)
const result = res?.data || {}
const progressDataConfig = [
// { name: '', key: 'dayOutNUm', type: 3 },
{ name: '本月到馆', key: 'monthPeopleNum', type: 3 },
@ -486,7 +484,8 @@ export default {
'size': 40
}
FetchHotSearch(params).then(res => {
this.hotTagData = res.data.replace(/^\[|\]$/g, '').split(', ')
// this.hotTagData = res.data.replace(/^\[|\]$/g, '').split(', ')
this.hotTagData = ['儒林外史', '七色花', '灰尘的旅行', '余华', '伍美珍', '石刻', '龙族', '骆驼祥子', '克雷洛夫寓言', '东野圭吾', '郁雨君', '汤姆索亚历险记', '中国古代寓言故事', '哪吒闹海', '三毛流浪记', '神笔马良', '中国古代寓言', '伊索寓言', '爱的教育', '看看我们的地球', '查理', '小鲤鱼跳龙门', '尼尔斯骑鹅旅行记', '窄门', '童年', '白洋淀纪事', '愿望的实现', '宝葫芦的秘密', '张居正', '许三观卖血记', '山海经', '查理九世', '论语', '红鞋子', '孤独的小螃蟹', '兄弟', '阳光姐姐', '李四光', '乡土中国', '读读童谣和儿歌']
this.$nextTick(() => {
this.tagList = this.hotTagData
this.onReady()
@ -546,7 +545,7 @@ export default {
if (result.success & result.resultlist.length !== 0) {
return result.resultlist.reduce((acc, obj) => acc + obj.GCL, 0)
} else {
return 0
return 10000
}
}).catch(error => {
console.error('Error', error)
@ -554,9 +553,9 @@ export default {
})
},
//
getTotalForLibcode(libcode) {
getTotalForLibcode() {
const params = {
'libcode': libcode,
'libcode': 'GD',
// 'startdate': this.getFormattedDate(new Date(), -1),
// 'enddate': this.getFormattedDate(new Date()),
'startdate': '2010-01-01',
@ -568,10 +567,10 @@ export default {
if (result.success && result.pagedata.length > 0) {
return result.pagedata[0].count
} else {
throw new Error('Failed' + libcode)
throw new Error('Failed')
}
}).catch(error => {
console.error('Error' + libcode, error)
console.error('Error', error)
return 0
})
},

18
src/views/pageThree/index.vue

@ -37,7 +37,7 @@
<ul class="ranking-list">
<li v-for="(item,index) in rankingYearWithPercentage" :key="index" :class="{ 'hovered': index === currentHover }">
<div style="width: .625rem; color: #79B8FF;" :class="[{'ranking-num1':index===0},{'ranking-num2':index===1},{'ranking-num3':index===2}]">{{ index>=3 ? index+1 : null }}</div>
<div style="width: 1.5rem; text-align: left;">{{ item.name }}</div>
<div style="width: 1.75rem; text-align: left;">{{ item.name }}</div>
<div class="ranking-progress" style="flex:1; align-self: center;">
<el-progress :percentage="item.percentage" :stroke-width="8" :show-text="false" color="#009afb" />
</div>
@ -255,18 +255,18 @@ export default {
this.yearTotal.push({
id: 'yearTotal',
name: '本年累计借阅',
value: this.$parent.formatter(yearNum),
valueArr: this.$parent.formatter(yearNum).split('')
value: this.$parent.formatter(this.paddingNum(yearNum, 5)),
valueArr: this.$parent.formatter(this.paddingNum(yearNum, 5)).split('')
})
// QYTSG999
this.yearAllNum = {
'headerLib': result.resultlist.filter(item => item.LIBCODE === 'DWSF')[0].JCC_YEAR,
'branchLib': result.resultlist.filter(item => item.LIBCODE !== 'DWSF' && item.LIBCODE !== '999').reduce((acc, obj) => acc + obj.JCC_YEAR, 0)
'branchLib': result.resultlist.filter(item => item.LIBCODE === 'ZJWSF' && item.LIBCODE !== '999').reduce((acc, obj) => acc + obj.JCC_YEAR, 0)
}
this.todayAllNum = {
'headerLib': result.resultlist.filter(item => item.LIBCODE === 'DWSF')[0].JCC_DAY,
'branchLib': result.resultlist.filter(item => item.LIBCODE !== 'DWSF' && item.LIBCODE !== '999').reduce((acc, obj) => acc + obj.JCC_DAY, 0)
'branchLib': result.resultlist.filter(item => item.LIBCODE === 'ZJWSF' && item.LIBCODE !== '999').reduce((acc, obj) => acc + obj.JCC_DAY, 0)
}
// 6
@ -383,6 +383,7 @@ export default {
outchartWeeklyData: []
}
const result = res.data
console.log('result', result)
//
const currentDate = new Date()
const today = currentDate.toISOString().slice(0, 10)
@ -398,6 +399,7 @@ export default {
date.setDate(currentDate.getDate() - i)
pastWeekDates.push(date.toISOString().slice(0, 10))
}
console.log('filteredData', filteredData)
const matchData = filteredData.reduce((accData, item) => {
//
@ -414,6 +416,8 @@ export default {
return accData
}, {})
console.log('matchData', matchData)
const completeData = pastWeekDates.map(date => ({
date: date.split('-').join('/'),
jccDayTotal: matchData[date] ? matchData[date].jccDayTotal : 0,
@ -422,12 +426,16 @@ export default {
//
completeData.sort((a, b) => new Date(a.date) - new Date(b.date))
console.log('completeData', completeData)
// X
this.chartWeeklyData.date = completeData.map(item => item.date)
// in
this.chartWeeklyData.inchartWeeklyData = completeData.map(item => item.hccDayTotal)
// // out
this.chartWeeklyData.outchartWeeklyData = completeData.map(item => item.jccDayTotal)
console.log('this.chartWeeklyData', this.chartWeeklyData)
}).catch(error => {
console.error('Error', error)
})

Loading…
Cancel
Save