From f55b6dff6735dd535e4b2cda384733138f4c1efc Mon Sep 17 00:00:00 2001
From: xuhuajiao <13476289682@163.com>
Date: Tue, 22 Jul 2025 11:27:09 +0800
Subject: [PATCH] =?UTF-8?q?=E9=9C=80=E6=B1=82=E6=9B=B4=E6=96=B0?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.env.development | 4 +-
src/api/library.js | 34 +++-
src/components/echart/lineChartService.vue | 11 +-
src/main.js | 7 +
src/utils/index.js | 192 +++++++++++----------
src/views/lengingRanking/index.vue | 40 ++++-
src/views/newBookRecommend/index.vue | 10 --
src/views/readStar/index.vue | 41 ++++-
src/views/todayBorrowed/index.vue | 130 ++++++++------
vue.config.js | 129 +++++++-------
10 files changed, 366 insertions(+), 232 deletions(-)
diff --git a/.env.development b/.env.development
index 038e4da..1034b12 100644
--- a/.env.development
+++ b/.env.development
@@ -8,8 +8,8 @@ ENV = 'development'
#VUE_APP_CAMERA_API = '192.168.99.107'
# 许镇-本地服地址
-VUE_APP_BASE_API = 'http://192.168.99.67:8080'
-VUE_APP_WS_API = 'ws://192.168.99.67:8081'
+VUE_APP_BASE_API = 'http://192.168.99.72:8080'
+VUE_APP_WS_API = 'ws://192.168.99.72:8081'
# 是否启用 babel-plugin-dynamic-import-node插件
VUE_CLI_BABEL_TRANSPILE_MODULES = true
diff --git a/src/api/library.js b/src/api/library.js
index 8c1b755..a30790d 100644
--- a/src/api/library.js
+++ b/src/api/library.js
@@ -1,5 +1,5 @@
import request from '@/utils/request'
-// import qs from 'qs'
+import qs from 'qs'
// 总借阅量
export function FetchHalfYearBorrowNum(params) {
@@ -83,6 +83,33 @@ export function FetchCoverByISBN(params) {
})
}
+// 获取当日每小时借还信息
+export function FetchTodayJH(params) {
+ return request({
+ url: '/qyzt/getTodayJH' + '?' + qs.stringify(params, { indices: false }),
+ method: 'get',
+ urlType: 'local'
+ })
+}
+
+// 借阅排行榜
+export function FetchSync36(params) {
+ return request({
+ url: '/qyzt/sync36' + '?' + qs.stringify(params, { indices: false }),
+ method: 'get',
+ urlType: 'local'
+ })
+}
+
+// page2 读者借阅排行榜
+export function FetchReadRanking(params) {
+ return request({
+ url: '/qyzt/sync37' + '?' + qs.stringify(params, { indices: false }),
+ method: 'get',
+ urlType: 'local'
+ })
+}
+
export default {
FetchHalfYearBorrowNum,
FetchBorrowRank,
@@ -91,5 +118,8 @@ export default {
FetchInitNotice,
FetchInitIntoNum,
FetchHalfYearBRNum,
- FetchShowFileList
+ FetchShowFileList,
+ FetchTodayJH,
+ FetchSync36,
+ FetchReadRanking
}
diff --git a/src/components/echart/lineChartService.vue b/src/components/echart/lineChartService.vue
index 2b38271..591b1ee 100644
--- a/src/components/echart/lineChartService.vue
+++ b/src/components/echart/lineChartService.vue
@@ -59,8 +59,8 @@ export default {
this.chart = echarts.init(dom, 'dark')
this.setOptions(this.chartData)
},
- setOptions({ returnData, borrowedData } = {}) {
- const time = ['00:00', '01:00', '02:00', '03:00', '04:00', '05:00', '06:00', '07:00', '08:00', '09:00', '10:00', '11:00', '12:00', '13:00', '14:00', '15:00', '16:00', '17:00', '18:00', '19:00', '20:00', '21:00', '22:00', '23:00', '24:00']
+ setOptions({ timeData, returnData, borrowedData } = {}) {
+ // const time = ['00:00', '01:00', '02:00', '03:00', '04:00', '05:00', '06:00', '07:00', '08:00', '09:00', '10:00', '11:00', '12:00', '13:00', '14:00', '15:00', '16:00', '17:00', '18:00', '19:00', '20:00', '21:00', '22:00', '23:00', '24:00']
this.chart.setOption({
backgroundColor: '#010326',
tooltip: {
@@ -92,11 +92,10 @@ export default {
},
xAxis: [{
type: 'category',
- data: time.map(function(item) {
- return item
- }),
+ data: timeData,
axisLabel: {
- interval: 5,
+ show: true,
+ // interval: 5,
formatter: function(value, idx) {
return value
},
diff --git a/src/main.js b/src/main.js
index 915ed3c..84a19b6 100644
--- a/src/main.js
+++ b/src/main.js
@@ -19,6 +19,13 @@ import './assets/fonts/fonts.css'
import { Message } from 'element-ui'
Vue.prototype.$message = Message
+// 全局注册过滤 - 时间
+import { parseTime, getFormattedDate } from '@/utils/index.js'
+Vue.filter('parseTime', function(time, cFormat) {
+ return parseTime(time, cFormat)
+})
+Vue.prototype.getFormattedDate = getFormattedDate
+
// 馆代码 1201为东西湖馆代码 / 本地测试用FTZN
// Vue.prototype.libcode = 'FTZN'
Vue.prototype.libcode = '1201'
diff --git a/src/utils/index.js b/src/utils/index.js
index 114fe35..6f2d4e5 100644
--- a/src/utils/index.js
+++ b/src/utils/index.js
@@ -1,92 +1,100 @@
-export function debounce(func, wait, immediate) {
- let timeout, args, context, timestamp, result
-
- const later = function() {
- // 据上一次触发时间间隔
- const last = +new Date() - timestamp
-
- // 上次被包装函数被调用时间间隔 last 小于设定时间间隔 wait
- if (last < wait && last > 0) {
- timeout = setTimeout(later, wait - last)
- } else {
- timeout = null
- // 如果设定为immediate===true,因为开始边界已经调用过了此处无需调用
- if (!immediate) {
- result = func.apply(context, args)
- if (!timeout) context = args = null
- }
- }
- }
-
- return function(...args) {
- context = this
- timestamp = +new Date()
- const callNow = immediate && !timeout
- // 如果延时不存在,重新设定延时
- if (!timeout) timeout = setTimeout(later, wait)
- if (callNow) {
- result = func.apply(context, args)
- context = args = null
- }
-
- return result
- }
-}
-
-/**
- * Parse the time to string
- * @param {(Object|string|number)} time
- * @param {string} cFormat
- * @returns {string}
- */
-export function parseTime(time, cFormat) {
- if (arguments.length === 0) {
- return null
- }
- const format = cFormat || '{y}-{m}-{d} {h}:{i}:{s}'
- let date
- if (typeof time === 'undefined' || time === null || time === 'null') {
- return ''
- } else if (typeof time === 'object') {
- date = time
- } else {
- if ((typeof time === 'string') && (/^[0-9]+$/.test(time))) {
- time = parseInt(time)
- }
- if ((typeof time === 'number') && (time.toString().length === 10)) {
- time = time * 1000
- }
- date = new Date(time)
- }
- const formatObj = {
- y: date.getFullYear(),
- m: date.getMonth() + 1,
- d: date.getDate(),
- h: date.getHours(),
- i: date.getMinutes(),
- s: date.getSeconds(),
- a: date.getDay()
- }
- const time_str = format.replace(/{(y|m|d|h|i|s|a)+}/g, (result, key) => {
- let value = formatObj[key]
- // Note: getDay() returns 0 on Sunday
- if (key === 'a') { return ['日', '一', '二', '三', '四', '五', '六'][value ] }
- if (result.length > 0 && value < 10) {
- value = '0' + value
- }
- return value || 0
- })
- return time_str
-}
-
-// 获取当前日期时间
-export function getCurrentTime() {
- const yy = new Date().getFullYear()
- const mm = new Date().getMonth() + 1
- const dd = new Date().getDate()
- const hh = new Date().getHours()
- const mf = new Date().getMinutes() < 10 ? '0' + new Date().getMinutes() : new Date().getMinutes()
- const ss = new Date().getSeconds() < 10 ? '0' + new Date().getSeconds() : new Date().getSeconds()
- const time = yy + '年' + mm + '月' + dd + '日 ' + hh + ':' + mf + ':' + ss
- return time
-}
+export function debounce(func, wait, immediate) {
+ let timeout, args, context, timestamp, result
+
+ const later = function() {
+ // 据上一次触发时间间隔
+ const last = +new Date() - timestamp
+
+ // 上次被包装函数被调用时间间隔 last 小于设定时间间隔 wait
+ if (last < wait && last > 0) {
+ timeout = setTimeout(later, wait - last)
+ } else {
+ timeout = null
+ // 如果设定为immediate===true,因为开始边界已经调用过了此处无需调用
+ if (!immediate) {
+ result = func.apply(context, args)
+ if (!timeout) context = args = null
+ }
+ }
+ }
+
+ return function(...args) {
+ context = this
+ timestamp = +new Date()
+ const callNow = immediate && !timeout
+ // 如果延时不存在,重新设定延时
+ if (!timeout) timeout = setTimeout(later, wait)
+ if (callNow) {
+ result = func.apply(context, args)
+ context = args = null
+ }
+
+ return result
+ }
+}
+
+/**
+ * Parse the time to string
+ * @param {(Object|string|number)} time
+ * @param {string} cFormat
+ * @returns {string}
+ */
+export function parseTime(time, cFormat) {
+ if (arguments.length === 0) {
+ return null
+ }
+ const format = cFormat || '{y}-{m}-{d} {h}:{i}:{s}'
+ let date
+ if (typeof time === 'undefined' || time === null || time === 'null') {
+ return ''
+ } else if (typeof time === 'object') {
+ date = time
+ } else {
+ if ((typeof time === 'string') && (/^[0-9]+$/.test(time))) {
+ time = parseInt(time)
+ }
+ if ((typeof time === 'number') && (time.toString().length === 10)) {
+ time = time * 1000
+ }
+ date = new Date(time)
+ }
+ const formatObj = {
+ y: date.getFullYear(),
+ m: date.getMonth() + 1,
+ d: date.getDate(),
+ h: date.getHours(),
+ i: date.getMinutes(),
+ s: date.getSeconds(),
+ a: date.getDay()
+ }
+ const time_str = format.replace(/{(y|m|d|h|i|s|a)+}/g, (result, key) => {
+ let value = formatObj[key]
+ // Note: getDay() returns 0 on Sunday
+ if (key === 'a') { return ['日', '一', '二', '三', '四', '五', '六'][value ] }
+ if (result.length > 0 && value < 10) {
+ value = '0' + value
+ }
+ return value || 0
+ })
+ return time_str
+}
+
+// 获取当前日期时间
+export function getCurrentTime() {
+ const yy = new Date().getFullYear()
+ const mm = new Date().getMonth() + 1
+ const dd = new Date().getDate()
+ const hh = new Date().getHours()
+ const mf = new Date().getMinutes() < 10 ? '0' + new Date().getMinutes() : new Date().getMinutes()
+ const ss = new Date().getSeconds() < 10 ? '0' + new Date().getSeconds() : new Date().getSeconds()
+ const time = yy + '年' + mm + '月' + dd + '日 ' + hh + ':' + mf + ':' + ss
+ return time
+}
+
+export function getFormattedDate(date, yearOffset = 0) {
+ date.setFullYear(date.getFullYear() + yearOffset)
+ const year = date.getFullYear()
+ const month = (date.getMonth() + 1).toString().padStart(2, '0')
+ const day = date.getDate().toString().padStart(2, '0')
+ return `${year}-${month}-${day}`
+}
diff --git a/src/views/lengingRanking/index.vue b/src/views/lengingRanking/index.vue
index 7d155f2..3bc20ce 100644
--- a/src/views/lengingRanking/index.vue
+++ b/src/views/lengingRanking/index.vue
@@ -17,8 +17,8 @@
{{ item.author }}
+{{ item.AUTHOR }}