318 lines
5.6 KiB
Vue
Raw Normal View History

<template>
2023-10-17 18:13:53 +08:00
<div class="leftTop">
<Card title="安全管理">
<div id="echartsSafe" style="width: 100%; height: 100%"></div>
</Card>
</div>
</template>
<script setup lang="ts">
2023-09-07 11:27:21 +08:00
import Card from "@/components/card.vue";
import { onMounted, ref } from "vue";
2023-10-17 18:13:53 +08:00
import { GlobalStore } from "@/stores";
const store = GlobalStore();
import { getProjectInspectRecordCountApi } from "@/api/modules/projectOverview";
2023-09-07 11:27:21 +08:00
import * as echarts from "echarts";
2023-10-17 18:13:53 +08:00
let questionTotal = ref(0 as any);
2023-09-07 11:27:21 +08:00
let dataList = ref([
{
value: 30,
show: true,
name: "未整改安全问题",
itemStyle: {
normal: {
color: "#EC6266",
borderWidth: 20
}
}
},
{
value: 70,
show: true,
name: "已整改安全问题",
itemStyle: {
normal: {
color: "#6375C7",
borderWidth: 20
}
}
2023-10-17 18:13:53 +08:00
}
2023-09-07 11:27:21 +08:00
]);
function Pie() {
let dataArr = [];
for (var i = 0; i < 150; i++) {
if (i % 2 === 0) {
dataArr.push({
name: (i + 1).toString(),
value: 10,
itemStyle: {
normal: {
color: "#7cf4f1",
borderWidth: 0,
borderColor: "#7f6546"
}
}
});
} else {
dataArr.push({
name: (i + 1).toString(),
value: 10,
itemStyle: {
normal: {
color: "rgba(0,0,0,0)",
borderWidth: 0,
borderColor: "rgba(0,0,0,0)"
}
}
});
}
}
return dataArr;
}
function drawEchart() {
let echartsTest = echarts.init(document.getElementById("echartsSafe"));
let option = {
tooltip: {
trigger: "item"
},
title: {
2023-10-17 18:13:53 +08:00
text: questionTotal.value,
2023-09-07 11:27:21 +08:00
subtext: "安全问题数",
2023-10-17 18:13:53 +08:00
x: "24%",
2023-09-07 11:27:21 +08:00
y: "center",
2023-10-17 18:13:53 +08:00
textAlign: "center",
2023-09-07 11:27:21 +08:00
textStyle: {
color: "#fff",
fontSize: 26,
fontWeight: "normal",
2023-10-17 18:13:53 +08:00
// align: "center",
fontFamily: "sadigitalNumber"
2023-09-07 11:27:21 +08:00
},
subtextStyle: {
color: "#ccc",
fontSize: 12,
2023-10-21 15:27:13 +08:00
fontWeight: "normal"
2023-10-17 18:13:53 +08:00
// align: "center"
2023-09-07 11:27:21 +08:00
}
},
legend: {
selectedMode: false, // 取消图例上的点击事件
icon: "rect",
type: "plain",
orient: "vertical",
left: "50%",
top: "40%",
align: "left",
itemGap: 30,
itemWidth: 8, // 设置宽度
itemHeight: 7, // 设置高度
symbolKeepAspect: false,
textStyle: {
color: "#000",
rich: {
name: {
verticalAlign: "right",
align: "left",
fontSize: 14,
color: "#FFFFFF"
},
value: {
align: "left",
fontSize: 14,
color: "#FFFFFF"
}
}
},
data: dataList.value.map(item => {
if (item.show) {
return item.name;
}
}),
formatter: function (data) {
if (dataList.value && dataList.value.length) {
for (var i = 0; i < dataList.value.length; i++) {
if (data === dataList.value[i].name) {
var value = dataList.value[i].value;
var percentage = value + "%";
2023-10-17 18:13:53 +08:00
return "{name| " + data + "} {gap| }" + "{value|" + value + " " + "}";
2023-09-07 11:27:21 +08:00
}
}
}
}
},
series: [
// 外侧光线
{
name: "",
type: "gauge",
center: ["25%", "55%"],
radius: "90%",
startAngle: 235,
endAngle: -50,
min: 0,
max: 100,
axisLine: {
show: true,
lineStyle: {
width: 2,
color: [
[
100 / 100,
new echarts.graphic.LinearGradient(0, 0, 1, 0, [
{
offset: 0,
2023-10-21 15:27:13 +08:00
color: "#526277"
},
{
offset: 0.25,
color: "rgba(4, 14, 54,0.4)"
},
{
offset: 0.7,
color: "rgba(4, 14, 54,0.4)"
2023-09-07 11:27:21 +08:00
},
{
offset: 1,
2023-10-21 15:27:13 +08:00
color: "#526277"
2023-09-07 11:27:21 +08:00
}
])
],
[1, "rgba(255,255,255,0)"]
]
}
},
axisTick: {
show: 0
},
splitLine: {
show: 0
},
axisLabel: {
show: 0
},
pointer: {
show: 0
},
detail: {
show: 0
}
},
{
name: "",
type: "gauge",
center: ["25%", "55%"],
radius: "80%",
startAngle: 245,
endAngle: -115,
min: 0,
max: 100,
axisLine: {
show: true,
lineStyle: {
width: 2,
color: [
[
200 / 100,
new echarts.graphic.LinearGradient(0, 0, 1, 0, [
{
2023-10-21 15:27:13 +08:00
offset: 1,
2023-09-07 11:27:21 +08:00
color: "#52bef0"
},
{
2023-10-21 15:27:13 +08:00
offset: 0,
2023-09-07 11:27:21 +08:00
color: "#13356b"
}
])
],
[1, "rgba(255,255,255,0)"]
]
}
},
axisTick: {
show: 0
},
splitLine: {
show: 0
},
axisLabel: {
show: 0
},
pointer: {
show: 0
},
detail: {
show: 0
}
},
{
name: "",
type: "pie",
radius: [65, 75],
center: ["25%", "55%"],
hoverAnimation: true,
2023-09-08 16:53:53 +08:00
itemStyle: {
borderRadius: 10,
borderWidth: 10
},
2023-09-07 11:27:21 +08:00
label: {
show: false,
position: "center"
},
emphasis: {
label: {
show: false
}
},
labelLine: {
show: false
},
data: dataList.value
},
{
type: "pie",
2023-09-08 16:53:53 +08:00
radius: ["57", "60"],
2023-09-07 11:27:21 +08:00
center: ["25%", "55%"],
label: {
show: false
},
data: Pie()
}
]
};
echartsTest.setOption(option, true);
}
2023-10-17 18:13:53 +08:00
//获取安全管理
// const safeData = ref(null as any);
const getSafeInfo = async () => {
const res: any = await getProjectInspectRecordCountApi({ projectSn: store.sn });
// console.log("获取安全管理", res);
// safeData.value = res.result;
dataList.value[0].value = res.result.rectificationNum;
dataList.value[1].value = res.result.totalNum - res.result.rectificationNum;
questionTotal.value = res.result.totalNum;
drawEchart();
};
onMounted(() => {
getSafeInfo();
});
</script>
<style scoped>
2023-10-17 18:13:53 +08:00
.leftTop {
width: 100%;
height: 100%;
2023-09-07 11:27:21 +08:00
}
2023-10-17 18:13:53 +08:00
::v-deep .h-card .content {
height: 80%;
2023-09-07 11:27:21 +08:00
}
2023-10-17 18:13:53 +08:00
</style>