2026-04-29 23:36:18 +08:00
|
|
|
|
<template>
|
|
|
|
|
|
<div class="trend-chart">
|
|
|
|
|
|
<div class="chart-legend">
|
2026-05-27 09:17:57 +08:00
|
|
|
|
<span><i :style="{ background: chartColors.primary }"></i>申请量(单)</span>
|
|
|
|
|
|
<span><i :style="{ background: chartColors.blue }"></i>审批完成量(单)</span>
|
|
|
|
|
|
<span><i :style="{ background: chartColors.purple }"></i>平均审批时长(小时)</span>
|
2026-04-29 23:36:18 +08:00
|
|
|
|
</div>
|
2026-05-28 16:24:59 +08:00
|
|
|
|
<div ref="chartElement" class="chart-body" role="img" :aria-label="ariaLabel"></div>
|
2026-04-29 23:36:18 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
|
|
<script setup>
|
2026-05-28 16:24:59 +08:00
|
|
|
|
import { computed, shallowRef } from 'vue'
|
|
|
|
|
|
import { BarChart as EChartsBarChart, LineChart as EChartsLineChart } from 'echarts/charts'
|
|
|
|
|
|
import { GridComponent, TooltipComponent } from 'echarts/components'
|
|
|
|
|
|
import { use } from 'echarts/core'
|
|
|
|
|
|
import { CanvasRenderer } from 'echarts/renderers'
|
|
|
|
|
|
|
|
|
|
|
|
import { useEcharts } from '../../composables/useEcharts.js'
|
2026-05-27 09:17:57 +08:00
|
|
|
|
import { useThemeColors } from '../../composables/useThemeColors.js'
|
2026-04-29 23:36:18 +08:00
|
|
|
|
|
2026-05-28 16:24:59 +08:00
|
|
|
|
use([GridComponent, TooltipComponent, EChartsBarChart, EChartsLineChart, CanvasRenderer])
|
2026-04-29 23:36:18 +08:00
|
|
|
|
|
|
|
|
|
|
const props = defineProps({
|
|
|
|
|
|
labels: { type: Array, required: true },
|
|
|
|
|
|
applications: { type: Array, required: true },
|
|
|
|
|
|
approved: { type: Array, required: true },
|
|
|
|
|
|
avgHours: { type: Array, required: true }
|
|
|
|
|
|
})
|
|
|
|
|
|
|
2026-05-28 16:24:59 +08:00
|
|
|
|
const chartElement = shallowRef(null)
|
2026-05-27 09:17:57 +08:00
|
|
|
|
const themeColors = useThemeColors()
|
|
|
|
|
|
const chartColors = computed(() => ({
|
|
|
|
|
|
primary: themeColors.value.chartPrimary,
|
|
|
|
|
|
blue: themeColors.value.chartBlue,
|
|
|
|
|
|
purple: themeColors.value.chartPurple
|
|
|
|
|
|
}))
|
2026-05-01 00:39:24 +08:00
|
|
|
|
|
2026-05-28 16:24:59 +08:00
|
|
|
|
const ariaLabel = computed(() =>
|
|
|
|
|
|
props.labels.map((label, index) => (
|
|
|
|
|
|
`${label}申请${props.applications[index] || 0}单,审批${props.approved[index] || 0}单,平均${props.avgHours[index] || 0}小时`
|
|
|
|
|
|
)).join(';')
|
|
|
|
|
|
)
|
2026-05-01 00:39:24 +08:00
|
|
|
|
|
2026-05-28 16:24:59 +08:00
|
|
|
|
const chartOptions = computed(() => ({
|
|
|
|
|
|
backgroundColor: 'transparent',
|
2026-05-28 22:33:53 +08:00
|
|
|
|
animation: true,
|
|
|
|
|
|
animationDuration: 1200,
|
|
|
|
|
|
animationDurationUpdate: 1200,
|
|
|
|
|
|
animationEasing: 'linear',
|
|
|
|
|
|
animationEasingUpdate: 'linear',
|
2026-05-28 16:24:59 +08:00
|
|
|
|
grid: {
|
|
|
|
|
|
top: 18,
|
|
|
|
|
|
right: 38,
|
|
|
|
|
|
bottom: 22,
|
|
|
|
|
|
left: 36,
|
|
|
|
|
|
containLabel: true
|
2026-04-29 23:36:18 +08:00
|
|
|
|
},
|
2026-05-28 16:24:59 +08:00
|
|
|
|
tooltip: {
|
|
|
|
|
|
trigger: 'axis',
|
|
|
|
|
|
confine: true,
|
|
|
|
|
|
appendToBody: true,
|
|
|
|
|
|
backgroundColor: 'rgba(255, 255, 255, 0.98)',
|
|
|
|
|
|
borderColor: 'rgba(148, 163, 184, 0.24)',
|
|
|
|
|
|
borderWidth: 1,
|
|
|
|
|
|
padding: [9, 10],
|
|
|
|
|
|
textStyle: {
|
|
|
|
|
|
color: '#334155',
|
|
|
|
|
|
fontSize: 12,
|
|
|
|
|
|
fontWeight: 700
|
2026-04-29 23:36:18 +08:00
|
|
|
|
},
|
2026-05-28 16:24:59 +08:00
|
|
|
|
extraCssText: 'border-radius:4px;box-shadow:0 12px 28px rgba(15,23,42,.12);'
|
|
|
|
|
|
},
|
|
|
|
|
|
xAxis: {
|
|
|
|
|
|
type: 'category',
|
|
|
|
|
|
data: props.labels,
|
|
|
|
|
|
boundaryGap: true,
|
|
|
|
|
|
axisTick: { show: false },
|
|
|
|
|
|
axisLine: { lineStyle: { color: 'rgba(148, 163, 184, 0.28)' } },
|
|
|
|
|
|
axisLabel: {
|
|
|
|
|
|
color: '#64748b',
|
|
|
|
|
|
fontSize: 11,
|
|
|
|
|
|
fontWeight: 700
|
2026-04-29 23:36:18 +08:00
|
|
|
|
}
|
|
|
|
|
|
},
|
2026-05-28 16:24:59 +08:00
|
|
|
|
yAxis: [
|
|
|
|
|
|
{
|
|
|
|
|
|
type: 'value',
|
|
|
|
|
|
min: 0,
|
2026-04-29 23:36:18 +08:00
|
|
|
|
max: 250,
|
2026-05-28 16:24:59 +08:00
|
|
|
|
splitNumber: 5,
|
|
|
|
|
|
axisLabel: {
|
2026-04-29 23:36:18 +08:00
|
|
|
|
color: '#64748b',
|
2026-05-28 16:24:59 +08:00
|
|
|
|
fontSize: 11,
|
|
|
|
|
|
fontWeight: 700
|
|
|
|
|
|
},
|
|
|
|
|
|
splitLine: { lineStyle: { color: 'rgba(226, 232, 240, 0.75)' } }
|
2026-04-29 23:36:18 +08:00
|
|
|
|
},
|
2026-05-28 16:24:59 +08:00
|
|
|
|
{
|
|
|
|
|
|
type: 'value',
|
|
|
|
|
|
min: 0,
|
2026-04-29 23:36:18 +08:00
|
|
|
|
max: 15,
|
2026-05-28 16:24:59 +08:00
|
|
|
|
splitNumber: 5,
|
|
|
|
|
|
axisLabel: {
|
2026-04-29 23:36:18 +08:00
|
|
|
|
color: '#64748b',
|
2026-05-28 16:24:59 +08:00
|
|
|
|
fontSize: 11,
|
|
|
|
|
|
fontWeight: 700
|
|
|
|
|
|
},
|
|
|
|
|
|
splitLine: { show: false }
|
|
|
|
|
|
}
|
|
|
|
|
|
],
|
|
|
|
|
|
series: [
|
|
|
|
|
|
{
|
|
|
|
|
|
name: '申请量(单)',
|
|
|
|
|
|
type: 'bar',
|
2026-05-28 22:33:53 +08:00
|
|
|
|
data: props.applications,
|
2026-05-28 16:24:59 +08:00
|
|
|
|
barWidth: 12,
|
|
|
|
|
|
barGap: '28%',
|
|
|
|
|
|
itemStyle: {
|
|
|
|
|
|
color: chartColors.value.primary,
|
|
|
|
|
|
borderRadius: [4, 4, 0, 0]
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
name: '审批完成量(单)',
|
|
|
|
|
|
type: 'bar',
|
2026-05-28 22:33:53 +08:00
|
|
|
|
data: props.approved,
|
2026-05-28 16:24:59 +08:00
|
|
|
|
barWidth: 12,
|
|
|
|
|
|
itemStyle: {
|
|
|
|
|
|
color: chartColors.value.blue,
|
|
|
|
|
|
borderRadius: [4, 4, 0, 0]
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
name: '平均审批时长(小时)',
|
|
|
|
|
|
type: 'line',
|
|
|
|
|
|
yAxisIndex: 1,
|
2026-05-28 22:33:53 +08:00
|
|
|
|
data: props.avgHours,
|
2026-05-28 16:24:59 +08:00
|
|
|
|
smooth: true,
|
|
|
|
|
|
symbol: 'circle',
|
|
|
|
|
|
symbolSize: 7,
|
|
|
|
|
|
lineStyle: {
|
|
|
|
|
|
width: 2.5,
|
|
|
|
|
|
color: chartColors.value.purple
|
|
|
|
|
|
},
|
|
|
|
|
|
itemStyle: {
|
|
|
|
|
|
color: '#ffffff',
|
|
|
|
|
|
borderColor: chartColors.value.purple,
|
|
|
|
|
|
borderWidth: 2.5
|
|
|
|
|
|
},
|
|
|
|
|
|
areaStyle: {
|
|
|
|
|
|
color: {
|
|
|
|
|
|
type: 'linear',
|
|
|
|
|
|
x: 0,
|
|
|
|
|
|
y: 0,
|
|
|
|
|
|
x2: 0,
|
|
|
|
|
|
y2: 1,
|
|
|
|
|
|
colorStops: [
|
|
|
|
|
|
{ offset: 0, color: toRgba(chartColors.value.purple, 0.14) },
|
|
|
|
|
|
{ offset: 1, color: toRgba(chartColors.value.purple, 0.02) }
|
|
|
|
|
|
]
|
|
|
|
|
|
}
|
2026-04-29 23:36:18 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2026-05-28 16:24:59 +08:00
|
|
|
|
]
|
|
|
|
|
|
}))
|
2026-04-29 23:36:18 +08:00
|
|
|
|
|
2026-05-28 16:24:59 +08:00
|
|
|
|
useEcharts(chartElement, chartOptions)
|
2026-04-29 23:36:18 +08:00
|
|
|
|
|
2026-05-28 16:24:59 +08:00
|
|
|
|
function toRgba(color, alpha) {
|
|
|
|
|
|
const normalized = String(color || '').trim()
|
|
|
|
|
|
const hex = normalized.replace('#', '')
|
|
|
|
|
|
if (/^[\da-f]{6}$/i.test(hex)) {
|
|
|
|
|
|
const r = parseInt(hex.slice(0, 2), 16)
|
|
|
|
|
|
const g = parseInt(hex.slice(2, 4), 16)
|
|
|
|
|
|
const b = parseInt(hex.slice(4, 6), 16)
|
|
|
|
|
|
return `rgba(${r}, ${g}, ${b}, ${alpha})`
|
2026-04-29 23:36:18 +08:00
|
|
|
|
}
|
2026-05-28 16:24:59 +08:00
|
|
|
|
return `rgba(58, 124, 165, ${alpha})`
|
2026-04-29 23:36:18 +08:00
|
|
|
|
}
|
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
|
|
<style scoped>
|
|
|
|
|
|
.trend-chart {
|
|
|
|
|
|
height: 280px;
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
flex-direction: column;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.chart-legend {
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
gap: 16px;
|
|
|
|
|
|
color: #475569;
|
|
|
|
|
|
font-size: 12px;
|
|
|
|
|
|
margin-bottom: 12px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.chart-legend i {
|
|
|
|
|
|
display: inline-block;
|
|
|
|
|
|
width: 8px;
|
|
|
|
|
|
height: 8px;
|
|
|
|
|
|
border-radius: 2px;
|
|
|
|
|
|
margin-right: 4px;
|
|
|
|
|
|
vertical-align: middle;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.chart-body {
|
|
|
|
|
|
flex: 1;
|
|
|
|
|
|
min-height: 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
</style>
|