From 5d799d194eed421f6494b1f2a26dcb15e0a6d912 Mon Sep 17 00:00:00 2001 From: xuhuajiao <13476289682@163.com> Date: Thu, 12 Feb 2026 13:54:43 +0800 Subject: [PATCH] =?UTF-8?q?=E9=9C=80=E6=B1=82=E6=9B=B4=E6=96=B0=E4=BC=98?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/assets/json/lib.json | 3 +- src/components/echart/todayCircle.vue | 8 +-- src/components/echart/yearCircle.vue | 8 +-- src/views/index.vue | 2 +- src/views/map/index.vue | 87 ++++++++++++++++++--------- src/views/pageOne/index.vue | 15 +++-- src/views/pageThree/index.vue | 18 ++++-- 7 files changed, 88 insertions(+), 53 deletions(-) diff --git a/src/assets/json/lib.json b/src/assets/json/lib.json index 0864cbb..5514d39 100644 --- a/src/assets/json/lib.json +++ b/src/assets/json/lib.json @@ -1,3 +1,4 @@ { - "葛店城市书房":[114.664064,30.478882] + "大湾城市书房":[114.664064,30.478882], + "张家湾城市书房":[114.635376,30.532215] } \ No newline at end of file diff --git a/src/components/echart/todayCircle.vue b/src/components/echart/todayCircle.vue index 0b815c2..6e8890b 100644 --- a/src/components/echart/todayCircle.vue +++ b/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) diff --git a/src/components/echart/yearCircle.vue b/src/components/echart/yearCircle.vue index 29cf257..751f71a 100644 --- a/src/components/echart/yearCircle.vue +++ b/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) diff --git a/src/views/index.vue b/src/views/index.vue index ee61963..2351e31 100644 --- a/src/views/index.vue +++ b/src/views/index.vue @@ -12,7 +12,7 @@ - --> + --> diff --git a/src/views/map/index.vue b/src/views/map/index.vue index bd8416b..ac742df 100644 --- a/src/views/map/index.vue +++ b/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 => { - const result = JSON.parse(res.data) - if (result.success & result.resultlist.length !== 0) { - // 目的拿到馆藏量 - this.libALLNum = result.resultlist - } else { - this.libALLNum = [] - } - this.getUserTotal() - .then(userTotals => { + // 先初始化馆藏量数据,避免后续找不到对应属性 + this.libALLNum = [] + + FetchLibBookTotal(params) + .then(res => { + const result = JSON.parse(res.data) + if (result.success && result.resultlist.length !== 0) { + this.libALLNum = result.resultlist + } + 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() - }) - }).catch(error => { - console.error('Error', error) - this.libALLNum = [] - this.getLibcodeDetails() - }) + } + // 执行后续逻辑 + this.getLibcodeDetails() + }) + .catch(error => { + console.error('Error', error) + // 即使接口报错,也执行 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 + }) + }) + } + }) + .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( { diff --git a/src/views/pageOne/index.vue b/src/views/pageOne/index.vue index 25b3290..08c4436 100644 --- a/src/views/pageOne/index.vue +++ b/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 }) }, diff --git a/src/views/pageThree/index.vue b/src/views/pageThree/index.vue index afae742..0aca80f 100644 --- a/src/views/pageThree/index.vue +++ b/src/views/pageThree/index.vue @@ -37,7 +37,7 @@
  • {{ index>=3 ? index+1 : null }}
    -
    {{ item.name }}
    +
    {{ item.name }}
    @@ -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('') }) // 总管就是QYTSG的数据,分馆就是其他除去999以为的合计 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) })