2022-09-17 17:01:58 +08:00

106 lines
2.2 KiB
Vue

<template>
<Card title="人员概况">
<div class="container" ref="chart"></div>
</Card>
</template>
<script>
import echarts from 'echarts4'
import { getPersonnelNumApi } from '@/assets/js/api/zhongjianFourth'
import Card from '../components/Card'
export default {
components: { Card },
data() {
return {
projectSn: "",
xdata:{
sumNumber:"",
realNameNumber:'',
lwNumber:'',
attendanceNumber:"",
exitNumber:""
}
}
},
mounted() {
this.getData()
},
methods: {
getData(){
getPersonnelNumApi({ projectSn: this.$store.state.projectSn }).then((res)=>{
this.xdata = res.result
this.initChart()
})
},
initChart() {
const myChart = echarts.init(this.$refs.chart)
const option = {
grid: {
top: '20px',
left: '30px',
right: '20px',
bottom: '40px'
},
xAxis: {
boundaryGap: true,
type: 'category',
data: ['总人数', '实名制人数', '劳务人数', '出勤人数', '退场人数'],
axisLabel: {
textStyle: {
show: true,
color: '#fff'
}
}
},
yAxis: {
type: 'value',
splitLine: {
show: true,
lineStyle: {
type: 'dashed',
color: '#4a6290'
}
},
axisLabel: {
textStyle: {
show: true,
color: '#fff'
}
}
},
series: [
{
name: '报警',
data: Object.values(this.xdata),
type: 'bar',
barWidth: '25%',
itemStyle: {
color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
{
offset: 0,
color: '#fb6e34'
},
{
offset: 1,
color: '#252d3f'
}
])
}
}
]
}
myChart.setOption(option)
}
}
}
</script>
<style lang="less" scoped>
.container {
width: 100%;
height: 100%;
}
</style>