This commit is contained in:
sjl
2025-01-22 16:28:09 +08:00
parent b603ac9bdb
commit 1ad1a0198e
3 changed files with 67 additions and 23 deletions

View File

@@ -44,7 +44,6 @@
:customData="{
title: '设备检测状态',
textAlign: 'left',
}"
:legendData="{
icon: 'circle',
@@ -149,6 +148,7 @@ const tableHeight = ref('calc(100% - 50px)') // 初始高度
const isTimeCheck = ref<boolean>(false)
const planList = ref<ResultData<Plan.ReqPlan[]>>()
const select_Plan = ref<Plan.ReqPlan>()
const isLabelLineShow = ref(true)
const handleCollapseChange = (val: CollapseModelValue) => {
// 计算新的高度
@@ -301,7 +301,6 @@ const getPieData = async (id: string) => {
const plan = findPlanById(planList.value?.data || [], id)
planName.value = '所选计划:' + plan.name
select_Plan.value = plan
if (plan) {
//isTimeCheck.value = plan.timeCheck === 1; // 将 1 转换为 true0 转换为 false
@@ -310,7 +309,7 @@ const getPieData = async (id: string) => {
// 处理未找到计划的情况
isTimeCheck.value = false // 或者其他默认值
}
console.log('饼图getBoundPqDevList')
const pqDevList_Result2 = await getBoundPqDevList({ 'planId': id, 'checkStateList': [0, 1, 2, 3] })
boundPqDevList.value = pqDevList_Result2.data as Device.ResPqDev[]
// 遍历 boundPqDevList 并更新计数对象
@@ -329,33 +328,65 @@ const getPieData = async (id: string) => {
reportStateCount[t.reportState]++
}
})
// 检查 checkStateCount 是否全为 0
const allZero = Object.values(checkStateCount).every(count => count === 0);
chartsData1.value = [
if(boundPqDevList.value.length != 0){
isLabelLineShow.value = true;
const allZero = Object.values(checkStateCount).every(count => count === 0);
chartsData1.value = [
{ value: allZero ? 0 : checkStateCount[0] === 0 ? null : checkStateCount[0], name: '未检', itemStyle: { color: '#fac858' } },
{ value: allZero ? 0 : checkStateCount[1] === 0 ? null : checkStateCount[1], name: '检测中', itemStyle: { color: '#ee6666' } },
{ value: allZero ? 0 : checkStateCount[2] === 0 ? null : checkStateCount[2], name: '检测完成', itemStyle: { color: '#91cc75' } },
{ value: allZero ? 0 : checkStateCount[3] === 0 ? null : checkStateCount[3], name: '归档', itemStyle: { color: '#5470c6' } },
];
// 同样处理 chartsData2 和 chartsData3
const allZeroResult = Object.values(checkResultCount).every(count => count === 0);
chartsData2.value = [
{ value: allZeroResult ? 0 : checkResultCount[2] === 0 ? null : checkResultCount[2], name: '未检', itemStyle: { color: '#fac858' } },
{ value: allZeroResult ? 0 : checkResultCount[0] === 0 ? null : checkResultCount[0], name: '不符合', itemStyle: { color: '#ee6666' } },
{ value: allZeroResult ? 0 : checkResultCount[1] === 0 ? null : checkResultCount[1], name: '符合', itemStyle: { color: '#91cc75' } },
];
// 检查 reportStateCount 是否全为 0
const allZeroReport = Object.values(reportStateCount).every(count => count === 0);
chartsData3.value = [
{ value: allZeroReport ? 0 : reportStateCount[2] === 0 ? null : reportStateCount[2], name: '未检', itemStyle: { color: '#fac858' } },
{ value: allZeroReport ? 0 : reportStateCount[0] === 0 ? null : reportStateCount[0], name: '未生成', itemStyle: { color: '#ee6666' } },
{ value: allZeroReport ? 0 : reportStateCount[1] === 0 ? null : reportStateCount[1], name: '已生成', itemStyle: { color: '#91cc75' } },
];
}else{
isLabelLineShow.value = false;//不展示引导线
chartsData1.value = [
{ value: null , name: '未检', itemStyle: { color: '#fac858' } },
{ value: null , name: '检测中', itemStyle: { color: '#ee6666' } },
{ value: null , name: '检测完成', itemStyle: { color: '#91cc75' } },
{ value: null , name: '归档', itemStyle: { color: '#5470c6' } },
{ value: 0 , itemStyle: { color: '#eeeeee' } },
];
// 同样处理 chartsData2 和 chartsData3
const allZeroResult = Object.values(checkResultCount).every(count => count === 0);
chartsData2.value = [
{ value: allZeroResult ? 0 : checkResultCount[2] === 0 ? null : checkResultCount[2], name: '未检', itemStyle: { color: '#fac858' } },
{ value: allZeroResult ? 0 : checkResultCount[0] === 0 ? null : checkResultCount[0], name: '不符合', itemStyle: { color: '#ee6666' } },
{ value: allZeroResult ? 0 : checkResultCount[1] === 0 ? null : checkResultCount[1], name: '符合', itemStyle: { color: '#91cc75' } },
];
{ value: null, name: '未检', itemStyle: { color: '#fac858' } },
{ value: null, name: '不符合', itemStyle: { color: '#ee6666' } },
{ value: null, name: '符合', itemStyle: { color: '#91cc75' } },
{ value: 0 , itemStyle: { color: '#eeeeee' } },
];
chartsData3.value = [
{ value: null, name: '未检', itemStyle: { color: '#fac858' } },
{ value: null, name: '未生成', itemStyle: { color: '#ee6666' } },
{ value: null, name: '已生成', itemStyle: { color: '#91cc75' } },
{ value: 0 , itemStyle: { color: '#eeeeee' } },
];
}
// 检查 reportStateCount 是否全为 0
const allZeroReport = Object.values(reportStateCount).every(count => count === 0);
chartsData3.value = [
{ value: allZeroReport ? 0 : reportStateCount[2] === 0 ? null : reportStateCount[2], name: '未检', itemStyle: { color: '#fac858' } },
{ value: allZeroReport ? 0 : reportStateCount[0] === 0 ? null : reportStateCount[0], name: '未生成', itemStyle: { color: '#ee6666' } },
{ value: allZeroReport ? 0 : reportStateCount[1] === 0 ? null : reportStateCount[1], name: '已生成', itemStyle: { color: '#91cc75' } },
];
}else{
planName.value = '所选计划:'