|
@@ -1,123 +0,0 @@
|
|
|
-<template>
|
|
|
- <TechCard>
|
|
|
- <template #extra>
|
|
|
- <div class="toggle-group">
|
|
|
- <button :class="{ active: mode === 'day' }" @click="mode = 'day'">按日</button>
|
|
|
- <button :class="{ active: mode === 'month' }" @click="mode = 'month'">按月</button>
|
|
|
- </div>
|
|
|
- </template>
|
|
|
-
|
|
|
- <div class="card-title">历史跌倒统计</div>
|
|
|
- <BaseChart :option="chartOption" :height="175" />
|
|
|
- </TechCard>
|
|
|
-</template>
|
|
|
-
|
|
|
-<script setup lang="ts">
|
|
|
-import { computed, ref } from 'vue'
|
|
|
-import * as echarts from 'echarts'
|
|
|
-import TechCard from '../TechCard/index.vue'
|
|
|
-
|
|
|
-defineOptions({ name: 'FallingHistoryCard' })
|
|
|
-
|
|
|
-// 切换模式:按日 / 按月
|
|
|
-const mode = ref<'day' | 'month'>('day')
|
|
|
-
|
|
|
-// 模拟接口数据结构
|
|
|
-const rawData = ref({
|
|
|
- dayStatInfo: [
|
|
|
- { date: '2024-07-01', fallingCount: 5 },
|
|
|
- { date: '2024-07-02', fallingCount: 8 },
|
|
|
- { date: '2024-07-03', fallingCount: 6 },
|
|
|
- { date: '2024-07-04', fallingCount: 10 },
|
|
|
- { date: '2024-07-05', fallingCount: 7 },
|
|
|
- ],
|
|
|
- monthStatInfo: [
|
|
|
- { month: '2024-06', fallingCount: 32 },
|
|
|
- { month: '2024-07', fallingCount: 41 },
|
|
|
- ],
|
|
|
-})
|
|
|
-
|
|
|
-// 根据模式转换图表数据
|
|
|
-const fallingHistoryData = computed(() => {
|
|
|
- const source = mode.value === 'day' ? rawData.value.dayStatInfo : rawData.value.monthStatInfo
|
|
|
- const dates = source.map((item) => ('date' in item ? item.date : item.month))
|
|
|
- const values = source.map((item) => item.fallingCount ?? 0)
|
|
|
- return { dates, values }
|
|
|
-})
|
|
|
-
|
|
|
-// 图表配置项
|
|
|
-const chartOption = computed(() => ({
|
|
|
- grid: { top: 10, right: 20, bottom: 30, left: 30 },
|
|
|
- tooltip: {
|
|
|
- trigger: 'axis',
|
|
|
- axisPointer: { type: 'shadow' },
|
|
|
- },
|
|
|
- xAxis: {
|
|
|
- type: 'category',
|
|
|
- data: fallingHistoryData.value.dates,
|
|
|
- axisLine: { lineStyle: { color: '#2a3b5a' } },
|
|
|
- axisLabel: { color: '#9cc5e0', fontSize: 12 },
|
|
|
- },
|
|
|
- yAxis: {
|
|
|
- type: 'value',
|
|
|
- axisLine: { lineStyle: { color: '#2a3b5a' } },
|
|
|
- axisLabel: { color: '#9cc5e0', fontSize: 12 },
|
|
|
- splitLine: { lineStyle: { color: 'rgba(42, 59, 90, 0.3)' } },
|
|
|
- },
|
|
|
- series: [
|
|
|
- {
|
|
|
- name: '跌倒次数',
|
|
|
- type: 'line',
|
|
|
- smooth: true,
|
|
|
- symbol: 'circle',
|
|
|
- symbolSize: 8,
|
|
|
- data: fallingHistoryData.value.values,
|
|
|
- itemStyle: { color: '#e74c3c' },
|
|
|
- lineStyle: {
|
|
|
- width: 3,
|
|
|
- color: new echarts.graphic.LinearGradient(0, 0, 1, 0, [
|
|
|
- { offset: 0, color: '#e74c3c' },
|
|
|
- { offset: 1, color: '#c0392b' },
|
|
|
- ]),
|
|
|
- },
|
|
|
- areaStyle: {
|
|
|
- color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
|
|
|
- { offset: 0, color: 'rgba(231, 76, 60, 0.3)' },
|
|
|
- { offset: 1, color: 'rgba(231, 76, 60, 0.1)' },
|
|
|
- ]),
|
|
|
- },
|
|
|
- },
|
|
|
- ],
|
|
|
-}))
|
|
|
-</script>
|
|
|
-
|
|
|
-<style scoped lang="less">
|
|
|
-.card-title {
|
|
|
- font-size: 16px;
|
|
|
- font-weight: bold;
|
|
|
- color: #e74c3c;
|
|
|
- margin-bottom: 12px;
|
|
|
- text-align: center;
|
|
|
-}
|
|
|
-
|
|
|
-.toggle-group {
|
|
|
- display: flex;
|
|
|
- gap: 8px;
|
|
|
- justify-content: flex-end;
|
|
|
-
|
|
|
- button {
|
|
|
- background: none;
|
|
|
- border: 1px solid #e74c3c;
|
|
|
- color: #e74c3c;
|
|
|
- padding: 4px 10px;
|
|
|
- border-radius: 4px;
|
|
|
- font-size: 12px;
|
|
|
- cursor: pointer;
|
|
|
-
|
|
|
- &.active {
|
|
|
- background-color: #e74c3c;
|
|
|
- color: #fff;
|
|
|
- }
|
|
|
- }
|
|
|
-}
|
|
|
-</style>
|