YZProjectCloud/yanzhu-ui-vue3/src/views/indexCompents/navAttLaborerRate.vue

116 lines
2.6 KiB
Vue
Raw Normal View History

2025-07-09 18:09:23 +08:00
<template>
<div class="index-nav-body">
2025-07-10 14:54:38 +08:00
<div class="index-nav-body-title">劳务人员出勤率</div>
2025-07-10 16:36:44 +08:00
<div class="chart-content" v-if="sum > 0">
2025-07-10 14:54:38 +08:00
<my-chart ref="chart" id="navAttLaborerRateChart" width="100%" height="100%" :render="renderChart" />
2025-07-09 18:09:23 +08:00
</div>
2025-07-10 16:36:44 +08:00
<div class="no-data" v-if="sum == 0">
2025-07-10 14:54:38 +08:00
<svg-icon icon-class="nodata" />
<div>暂无数据</div>
2025-07-09 18:09:23 +08:00
</div>
</div>
</template>
<script>
import MyChart from "@/components/Chart/MyChart";
export default {
components: {
MyChart,
},
2025-07-10 14:54:38 +08:00
props: {
attInfo: {
type: Object,
default: () => {
return null;
},
},
},
2025-07-09 18:09:23 +08:00
data() {
return {
2025-07-10 14:54:38 +08:00
chartData: [],
2025-07-10 16:36:44 +08:00
sum:0
2025-07-09 18:09:23 +08:00
};
},
mounted() {
this.init();
},
methods: {
renderChart(opt) {
let pieOption = {
tooltip: {
trigger: "item",
formatter: "{b} <br/> {c} 人 ({d}%)",
textStyle: {
fontSize: 12,
},
},
legend: {
orient: "horizontal",
left: "center",
top: "10",
2025-07-10 14:54:38 +08:00
data: this.chartData.map((d) => d.name),
2025-07-09 18:09:23 +08:00
textStyle: {
color: "#444",
fontSize: 12,
},
},
series: [
{
type: "pie",
2025-07-10 14:54:38 +08:00
radius: ["30%", "60%"], // 设置为圆环图
2025-07-09 18:09:23 +08:00
center: ["50%", "50%"],
avoidLabelOverlap: false,
data: this.chartData,
label: {
normal: {
formatter: "{b}\n{c}",
textStyle: {
color: "#444",
fontSize: 12,
},
},
emphasis: {
formatter: "{b}\n{c}",
textStyle: {
color: "#444",
fontSize: 12,
},
},
},
emphasis: {
itemStyle: {
shadowBlur: 10,
shadowOffsetX: 0,
},
},
},
],
};
return pieOption;
},
init() {
setTimeout(() => {
2025-07-10 14:54:38 +08:00
let total = this.attInfo ? this.attInfo.job.worker : 0;
let totalAtt = this.attInfo ? this.attInfo.att.worker : 0;
2025-07-10 16:36:44 +08:00
this.sum=totalAtt+total;
2025-07-10 14:54:38 +08:00
this.chartData = [
{
name: "出勤人数",
value: totalAtt,
},
{
name: "未出勤人数",
value: total - totalAtt,
},
];
if (this.$refs.chart) {
this.$refs.chart.reLoad();
}
}, 400);
2025-07-09 18:09:23 +08:00
},
},
};
</script>
2025-07-10 14:54:38 +08:00
<style></style>