78 lines
1.4 KiB
Vue
78 lines
1.4 KiB
Vue
<template>
|
|
<ChartCard margin="0 0 30rpx 0" title="应急数据">
|
|
<view class="emergencyCard" @click="router.push('/pages/index/emergency/index')">
|
|
<qiun-data-charts type="column" :opts="opts" :canvas2d="false" :chartData="chartData" @getIndex="handleTap" />
|
|
</view>
|
|
</ChartCard>
|
|
</template>
|
|
|
|
<script setup>
|
|
import ChartCard from '@/components/chartCard.vue';
|
|
import { ref, watch } from 'vue';
|
|
import { router } from '@/utils';
|
|
let props = defineProps({
|
|
emergencyData: {
|
|
type: Array,
|
|
default: () => []
|
|
}
|
|
});
|
|
const opts = ref({
|
|
padding: [15, 15, 0, 5],
|
|
enableScroll: false,
|
|
legend: { show: false },
|
|
xAxis: {
|
|
disableGrid: true,
|
|
rotateLabel: true,
|
|
fontSize: 10,
|
|
rotateAngle: -30
|
|
},
|
|
yAxis: {
|
|
data: [
|
|
{
|
|
min: 0
|
|
}
|
|
]
|
|
},
|
|
extra: {
|
|
column: {
|
|
type: 'group',
|
|
width: 20,
|
|
activeBgColor: '#000000',
|
|
activeBgOpacity: 0.08
|
|
}
|
|
}
|
|
});
|
|
|
|
const chartData = ref({});
|
|
|
|
const handleTap = (e) => {
|
|
console.log(e);
|
|
};
|
|
watch(
|
|
() => props.emergencyData,
|
|
(newVal) => {
|
|
if (newVal && newVal.length) {
|
|
// 只有当数据存在时才赋值
|
|
let res = {
|
|
categories: ['综合预案', '专项预案', '现场处置\n预案', '演练次数 ', '参演人数'],
|
|
series: [
|
|
{
|
|
data: newVal,
|
|
color: '#eef82f'
|
|
}
|
|
]
|
|
};
|
|
chartData.value = JSON.parse(JSON.stringify(res));
|
|
}
|
|
},
|
|
{ deep: true, immediate: true }
|
|
);
|
|
</script>
|
|
|
|
<style lang="scss">
|
|
.emergencyCard {
|
|
width: 100%;
|
|
height: 400rpx;
|
|
}
|
|
</style>
|