Files
CNCEC_APP/pages/index/board/safe/educationCard.vue
T
2026-08-17 11:01:21 +08:00

82 lines
1.5 KiB
Vue

<template>
<ChartCard margin="0 0 30rpx 0" title="培训数据">
<view class="charts-box" @click="router.push('/pages/index/training/index')">
<qiun-data-charts type="area" :opts="opts" :canvas2d="false" :chartData="chartData" @getIndex="handleTap" />
</view>
</ChartCard>
</template>
<script setup>
import ChartCard from '@/components/chartCard.vue';
import { ref, onMounted, watch } from 'vue';
import { router } from '@/utils';
let props = defineProps({
educationData: {
type: Array,
default: () => []
}
});
const opts = ref({
padding: [15, 15, 0, 15],
enableScroll: false,
legend: {
show: false
},
xAxis: {
disableGrid: true,
rotateLabel: true,
rotateAngle: -30,
fontSize: 9
},
yAxis: {
gridType: 'dash',
dashLength: 2
},
extra: {
tooltip: {
showBox: false
},
area: {
type: 'curve',
opacity: 0.2,
addLine: true,
width: 2,
gradient: true,
activeType: 'hollow'
}
}
});
const chartData = ref({});
const handleTap = (e) => {
console.log(e);
};
watch(
() => props.educationData,
(newVal) => {
if (newVal && newVal.length) {
// 只有当数据存在时才赋值
let res = {
categories: ['专项培训', '三级安全教育\n培训人次', '特种作业\n培训人次', '安全技术\n交底人次'],
series: [
{
data: newVal
}
]
};
chartData.value = JSON.parse(JSON.stringify(res));
}
},
{ deep: true, immediate: true }
);
</script>
<style scoped>
.charts-box {
width: 100%;
height: 400rpx;
}
</style>