gz-att-web/src/views/dashboard/bottomTwo.vue

135 lines
3.4 KiB
Vue
Raw Normal View History

<template>
<div class="content">
<div class="content-box">
<div class="title-box">
<div style="margin-left: 10px;font-size: 22px;font-weight: bold;">当月异常统计</div>
</div>
2024-10-16 15:09:57 +08:00
<div class="chart-box" @click="toggleDialog(12)">
2024-10-28 11:05:42 +08:00
<div id="barBox" style="width: 100%;height: 400px;"></div>
</div>
</div>
</div>
</template>
<script>
import * as echarts from 'echarts';
export default {
components: {
},
2024-10-22 18:50:14 +08:00
name: 'bottomTwo',
props: {
pageData: {
// required: true,
type: Object,
default:{
2024-10-28 11:05:42 +08:00
addressErrorNum:0,
earlyNum:0,
einErrorNum:0,
lateNum:0,
leaveNum:0,
skippingNum:0
2024-10-22 18:50:14 +08:00
}
},
},
data() {
return {
pieCharts: null,
dateTime:"",
2024-10-22 18:50:14 +08:00
barYData:[22, 18, 11, 23, 29, 33]
}
},
2024-10-28 11:05:42 +08:00
watch: {
pageData: {
handler() {
this.getInitData()
},
immediate: true
}
},
created() {
},
mounted() {
2024-10-28 11:05:42 +08:00
this.getInitData()
},
methods: {
getInitData(){
2024-10-28 11:05:42 +08:00
setTimeout(()=>{
this.barYData=[Number(this.pageData.lateNum),Number(this.pageData.earlyNum),Number(this.pageData.skippingNum),Number(this.pageData.leaveNum),Number(this.pageData.addressErrorNum),Number(this.pageData.einErrorNum)]
console.log(this.barYData)
this.initChart()
},500)
},
initChart(){
this.pieCharts = echarts.init(document.getElementById('barBox'))
var option = {
2024-10-28 11:05:42 +08:00
grid: {
left: '5%',
right: '5%',
bottom: '5%',
top: '5%',
containLabel: true,
},
xAxis: {
data: ['迟到', '早退', '旷工', '请假', '打卡地异常', '出入异常']
},
yAxis: {},
series: [{
type: 'bar',
2024-10-28 11:05:42 +08:00
data:this.barYData,
itemStyle:{
color:"#157DF3"
}
}]
};
2024-10-28 11:05:42 +08:00
this.pieCharts.setOption(option)
// 监听柱状图的点击事件
this.pieCharts.on('click', function (params) {
// 控制台输出点击的数据的信息
console.log(params);
// 在这里添加你的点击事件逻辑
// 例如:弹窗显示点击的数据的详细信息
// alert('你点击的是:' + params.name);
});
},
toggleDialog(v) {
this.$emit('openDialog', { order: v })
},
},
}
</script>
<style lang="scss" scoped>
.content{
width: 100%;
height: 100%;
// padding-top: 20px;
.content-box{
width: 100%;
height: 100%;
padding: 10px;
background-color: #fff;
border-radius: 10px;
}
.title-box{
width: 100%;
height: 30px;
display: flex;
justify-content: space-between;
align-items: center;
}
.chart-box{
width: 100%;
2024-10-28 11:05:42 +08:00
height: 450px;
}
}
</style>