From 89c23cae2cfd9d4eb9ebefcc93d018191f1e9911 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A2=81=E6=B3=BD=E5=86=9B?= <5654792+tcubic21@user.noreply.gitee.com> Date: Thu, 20 Mar 2025 18:06:23 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env.development | 4 +- .../pages/article_list/article_list.vue | 1 - src/pages/overview/_components/chart.vue | 15 ++- src/pages/overview/_components/pie-chart.vue | 60 ++++++------ src/pages/overview/overview.vue | 92 +++++++++++++++---- 5 files changed, 116 insertions(+), 56 deletions(-) diff --git a/.env.development b/.env.development index 882e7b5..a71af95 100644 --- a/.env.development +++ b/.env.development @@ -2,6 +2,6 @@ VITE_MODE = dev # 请求域名 -VITE_APP_BASE_URL='http://192.168.1.249:8084/ai-agent-server' -# VITE_APP_BASE_URL='https://info.xglpa.com/ai-agent-server' +# VITE_APP_BASE_URL='http://192.168.1.249:8084/ai-agent-server' +VITE_APP_BASE_URL='https://info.xglpa.com/ai-agent-server' diff --git a/src/packages/pages/article_list/article_list.vue b/src/packages/pages/article_list/article_list.vue index 4c75a45..5091c94 100644 --- a/src/packages/pages/article_list/article_list.vue +++ b/src/packages/pages/article_list/article_list.vue @@ -30,7 +30,6 @@ import NewsList from './component/news-list.vue' import { getArticleCate } from '@/api/news' import Tabs from '@/packages/components/tabs/tabs.vue' import Tab from '@/packages/components/tab/tab.vue' - const tabList = ref([]) const current = ref(0) diff --git a/src/pages/overview/_components/chart.vue b/src/pages/overview/_components/chart.vue index 7d6f41a..c6cc80e 100644 --- a/src/pages/overview/_components/chart.vue +++ b/src/pages/overview/_components/chart.vue @@ -67,7 +67,7 @@ const options = { xAxis: { type: 'value', axisLabel: { - formatter: '{value} 次' + formatter: '{value} ' } }, yAxis: { @@ -86,7 +86,6 @@ const options = { boundaryGap: [0.1, 0.1] // 上下留白比例 }, series: [{ - silent: true, // 禁用系列交互 type: 'bar', barWidth: '60%', itemStyle: { @@ -131,7 +130,7 @@ const handleResize = () => { onMounted(() => { initChart() - chartRef.value.style.touchAction = 'none' + // chartRef.value.style.touchAction = 'none' window.addEventListener('resize', updateSize) }) @@ -152,20 +151,20 @@ const updateSize = () => { // 监听配置变化 watch(() => props.data, (newVal) => { - chartInstance.value?.setOption(newVal) + options.dataset.source = newVal + chartInstance.value?.setOption(options) }, { deep: true }) \ No newline at end of file diff --git a/src/pages/overview/overview.vue b/src/pages/overview/overview.vue index 042ae76..ad83aef 100644 --- a/src/pages/overview/overview.vue +++ b/src/pages/overview/overview.vue @@ -6,15 +6,32 @@ - - - - - - - + + + + + + + + + + + + + + + + + + + + + + @@ -28,27 +45,55 @@ import VerticalBarChart from './_components/chart.vue' import VerticalPieChart from './_components/pie-chart.vue' import { PageStatusEnum } from '@/enums/appEnums' import { cloneDeep } from 'lodash-es' +import Tabs from '@/packages/components/tabs/tabs.vue' +import Tab from '@/packages/components/tab/tab.vue' +import uCalendar from '@/uni_modules/vk-uview-ui/components/u-calendar/u-calendar.vue' +import uField from '@/uni_modules/vk-uview-ui/components/u-field/u-field.vue' + + + +// 获取昨天往前7天的日期范围 +const getDateRange = () => { + const today = new Date() + const yesterday = new Date(today) + yesterday.setDate(today.getDate() - 1) + const startDate = new Date(yesterday) + startDate.setDate(startDate.getDate() - 6) + const start = formatDate(startDate) + const end = formatDate(yesterday) + return `${start} ~ ${end}` +} + + +// 格式化日期 +const formatDate = (date: Date) => { + const year = date.getFullYear() + const month = String(date.getMonth() + 1).padStart(2, '0') + const day = String(date.getDate()).padStart(2, '0') + return `${year}-${month}-${day}` +} + const status = ref(PageStatusEnum.LOADING) - - +const dateRange = ref(getDateRange()) +const showCalendar = ref(false) +const mode = ref('range') const queryParams = ref({ - startTime: "2025-03-18 00:00:00", - endTime: "2025-03-19 00:00:00", + startTime: getDateRange().split(' ~ ')[0] + ' 00:00:00', + endTime: getDateRange().split(' ~ ')[1] + ' 23:59:59', }) -const data = ref([]) +const current = ref(0) +const handleChange = (index: number) => { + current.value = Number(index) +} + const chartData = ref([]) const chartData2 = ref([]) const chartData3 = ref([]) - -const chartData4 = ref([ - { name: '分类A', value: 335 }, - { name: '分类B', value: 310 }, - { name: '分类C', value: 234 } -]) +const chartData4 = ref([]) // 获取数据 const getData = async () => { @@ -61,6 +106,7 @@ const getData = async () => { chartData3.value = responseData.userUseTotalList.map((item: any) => ([item.name, item.total])) chartData4.value = responseData.companyTotalList.map((item: any) => ({ name: item.name, value: item.total })) + status.value = PageStatusEnum.NORMAL } catch (error) { status.value = PageStatusEnum.ERROR @@ -70,6 +116,14 @@ onLoad(() => { getData() }) +// 选择日期 +const changeCalendar = (e: Object) => { + console.log('range', e); + dateRange.value = e.startDate + ' ~ ' + e.endDate + queryParams.value.startTime = e.startDate + ' 00:00:00' + queryParams.value.endTime = e.endDate + ' 23:59:59' + getData() +} @@ -98,7 +152,7 @@ page { } .ai-creation { - height: 100%; + // height: 100%; display: flex; flex-direction: column; background: linear-gradient(44.7deg, #eaffff 0%, #faf6ff 50%, #f2f3ff 63%, #eaffff 100%);