<template>
|
<div class="workOrder">
|
<div class="card-title">
|
<div class="cardtotal">
|
<p>工单统计占比</p>
|
<img @click="refresh" src="/src/assets/images/workbench/st1.svg" alt="" />
|
</div>
|
<div class="time-card">
|
<div
|
class="card-item"
|
:class="item === checked ? 'active' : ''"
|
v-for="(item, index) in timeListEnum"
|
:key="index"
|
@click="timeClick(item, index)"
|
>
|
{{ timeListStr[index] }}
|
</div>
|
</div>
|
</div>
|
<div class="workorderbox">
|
<div class="card-group">
|
<div class="main-card">
|
<div class="status-grid">
|
<div class="status-item" v-for="(item, index) in eventTypeList" :key="index">
|
<div class="statusCon">
|
<div class="status-label">{{ item.name }}</div>
|
<div class="status-value">{{ item.value }}<span>个</span></div>
|
<div class="ratio">
|
占比
|
<span :style="{ color: item.color }"
|
>{{ ((item.rate * 100) / 100).toFixed(2) }}%</span
|
>
|
</div>
|
</div>
|
<img :src="item.img" alt="" />
|
</div>
|
</div>
|
</div>
|
</div>
|
<div class="charts">
|
<div class="chart" ref="echartsRef"></div>
|
</div>
|
</div>
|
</div>
|
</template>
|
|
<script setup>
|
import useEchartsResize from '@/hooks/useEchartsResize';
|
import { getJobEventByStatus } from '@/api/home/index';
|
import overviewImg2 from '@/assets/images/workbench/tc2.svg';
|
import overviewImg3 from '@/assets/images/workbench/tc3.svg';
|
import overviewImg4 from '@/assets/images/workbench/tc4.svg';
|
import overviewImg5 from '@/assets/images/workbench/tc5.svg';
|
let checked = ref('CURRENT_YEAR');
|
let timeListStr = ['本周', '本月', '本年'];
|
let timeListEnum = ['CURRENT_WEEK', 'CURRENT_MONTH', 'CURRENT_YEAR'];
|
const params = ref({
|
date_enum: 'CURRENT_YEAR',
|
device_sn: '',
|
end_date: undefined,
|
start_date: undefined,
|
});
|
const dateSelect = ref('CURRENT_YEAR');
|
const eventTypeList = ref([
|
{ name: '待审核', value: 0, img: overviewImg2, color: '#FF472F', status: '2', rate: 0 },
|
{ name: '待处理', value: 0, img: overviewImg3, color: '#FF7411', status: '0', rate: 0 },
|
{ name: '处理中', value: 0, img: overviewImg4, color: '#FFC300', status: '3', rate: 0 },
|
{ name: '已完成', value: 0, img: overviewImg5, color: '#0291A1', status: '4', rate: 0 },
|
]);
|
// 工单统计
|
const getTypeData = () => {
|
getJobEventByStatus(params.value).then(res => {
|
const resList = res?.data?.data || [];
|
resList.forEach(item => {
|
eventTypeList.value.forEach(item1 => {
|
if (item1.name === item.name) {
|
item1.value = item.num;
|
item1.rate = item.rate;
|
}
|
});
|
});
|
initChart(resList);
|
});
|
};
|
const refresh = () => {
|
// params.value.date_enum = 'CURRENT_YEAR';
|
// checked.value = 'CURRENT_YEAR';
|
// dateSelect.value = 'CURRENT_YEAR';
|
getTypeData();
|
};
|
|
let timeClick = (item, index) => {
|
checked.value = item;
|
params.value.date_enum = item;
|
dateSelect.value = item;
|
getTypeData();
|
};
|
// 图表
|
const echartsRef = ref(null);
|
let { chart } = useEchartsResize(echartsRef);
|
const initChart = val => {
|
const totalNum = val.reduce((sum, item) => sum + item.num, 0);
|
const data = {
|
total: {
|
title: '总计',
|
figure: totalNum.toString(), // 动态计算总数
|
},
|
data: val.map(item => ({
|
value: item.num,
|
name: item.name,
|
rate: item.rate,
|
})),
|
};
|
const containerWidth = chart.value.clientWidth;
|
const isSmallScreen = containerWidth < 768; // 移动端判断
|
const echartsOption = {
|
color: ['#FF472F', '#FF7411', '#FFC300', '#0291A1'],
|
tooltip: {
|
trigger: 'item',
|
padding: 0,
|
borderWidth: 0,
|
formatter: params => {
|
return `<div style="background-color: rgba($color: #FFFFFF, $alpha: 0.95);
|
box-shadow: 0 0.4rem 0.9rem 0 rgba($color: #000000, $alpha: 0.1);
|
padding:0 1.2rem;
|
display: flex;
|
align-items: center;
|
border-radius: 0.4rem;
|
font-size: 1.2rem;" class="tooltip-area">
|
<p>${params.marker}${params.name}</p>
|
<h4 style="margin-left: 1rem;">${params.data.rate || params.percent}%</h4>
|
</div>`;
|
},
|
},
|
legend: {
|
show: false,
|
},
|
title: {
|
text: data.total.title,
|
textStyle: {
|
color: 'rgba(28, 31, 35, 0.80)',
|
fontSize: '1.2rem',
|
fontWeight: 'bold',
|
},
|
subtext: data.total.figure,
|
subtextStyle: {
|
color: '#1C1F23',
|
fontSize: '2rem',
|
fontWeight: '600',
|
},
|
top: '40%',
|
left: '48%',
|
textAlign: 'center', // 文本对齐
|
},
|
series: [
|
{
|
name: '',
|
type: 'pie',
|
radius: ['55%', '83%'],
|
|
label: {
|
show: false,
|
},
|
labelLine: {
|
show: false,
|
length: 3, // 调整引导线长度
|
length2: 5,
|
lineStyle: {
|
cap: 'round',
|
},
|
minTurnAngle: 45, // 防止小角度重叠
|
},
|
data: data.data,
|
},
|
],
|
};
|
|
chart.value.setOption(echartsOption);
|
};
|
onMounted(() => {
|
getTypeData();
|
});
|
</script>
|
|
<style scoped lang="scss">
|
.workOrder {
|
border-radius: 8px 8px 8px 8px;
|
padding: 4px 14px 0 15px;
|
background: #ffffff !important;
|
|
height: pxToVh(282);
|
margin-bottom: 10px;
|
.card-title {
|
display: flex;
|
margin-bottom: 4px;
|
align-items: center;
|
justify-content: space-between;
|
.cardtotal {
|
display: flex;
|
align-items: center;
|
margin-left: 9px;
|
img {
|
width: 17px;
|
height: 17px;
|
margin-left: 6px;
|
cursor: pointer;
|
}
|
p {
|
font-weight: bold;
|
font-size: 14px;
|
color: #363636;
|
}
|
|
span {
|
font-weight: 400;
|
font-size: 14px;
|
color: #7c8091;
|
}
|
|
.total-number {
|
font-family: 'Source Han Sans CN';
|
|
font-weight: bold;
|
font-size: 32px;
|
color: #2a54ff;
|
}
|
}
|
|
img {
|
width: 36px;
|
height: 40px;
|
}
|
}
|
.workorderbox {
|
display: flex;
|
justify-content: space-between;
|
.card-group {
|
width: 60%;
|
|
.status-grid {
|
display: grid;
|
grid-template-columns: repeat(2, 1fr);
|
.status-item {
|
display: flex;
|
text-align: center;
|
justify-content: space-between;
|
height: pxToVh(97);
|
margin-bottom: 10px;
|
margin-right: 14px;
|
width: 144px;
|
background: #f6f8fe;
|
border-radius: 8px 8px 8px 8px;
|
|
img {
|
width: 26px;
|
height: 26px;
|
padding: 9px 10px 9px 2px;
|
}
|
|
.statusCon {
|
box-sizing: border-box;
|
display: flex;
|
flex-direction: column;
|
justify-content: space-between;
|
padding: 10px 4px 39px 10px;
|
text-align: left;
|
|
.status-label {
|
font-weight: 400;
|
font-size: 14px;
|
text-align: left;
|
color: #383838;
|
margin: 0;
|
}
|
|
.ratio {
|
font-weight: 400;
|
font-size: 12px;
|
color: #363636;
|
white-space: nowrap;
|
text-align: left;
|
margin-top: 10px;
|
}
|
|
.status-value {
|
font-family: 'Source Han Sans CN';
|
font-weight: bold;
|
font-size: 28px;
|
height: 28px;
|
color: #363636;
|
margin-top: -6px;
|
display: inline-block;
|
transform: skewX(-5deg);
|
|
span {
|
font-weight: 400;
|
font-size: 14px;
|
color: #7c8091;
|
}
|
}
|
}
|
}
|
}
|
}
|
|
.charts {
|
margin-top: 20px;
|
width: 40%;
|
height: auto;
|
|
.chart {
|
width: 100%;
|
height: 100%;
|
}
|
}
|
}
|
}
|
.time-card {
|
text-align: center;
|
// height: 30px;
|
height: pxToVh(30);
|
background: #ffffff;
|
|
border: 1px solid #e5e5e5;
|
font-weight: 400;
|
font-size: 14px;
|
color: #7c8091;
|
display: flex;
|
width: 282px;
|
margin-left: 15px;
|
border-radius: 4px;
|
|
.card-item {
|
width: 94px;
|
height: 100%;
|
line-height: 28px;
|
cursor: pointer;
|
font-family: 'Source Han Sans CN';
|
font-weight: 400;
|
font-size: 14px;
|
color: #7c8091;
|
}
|
|
.card-item:first-child {
|
border-right: 1px solid #e5e5e5;
|
}
|
|
.card-item:nth-child(2) {
|
border-right: 1px solid #e5e5e5;
|
}
|
|
.card-item.active {
|
color: #1441ff;
|
border: 1px solid #1c5cff;
|
}
|
}
|
</style>
|