饼图数据默认,饼图数据计算方式调整

This commit is contained in:
caozehui
2024-12-17 13:57:18 +08:00
parent d20cab57be
commit fe8bc407d3

View File

@@ -260,49 +260,39 @@ watch(
const pieRef1 = ref(),
pieRef2 = ref(),
pieRef3 = ref();
const changeSelect = () => {
console.log(form.value.activeTabs);
//getPieData();
};
const chartsData1: any = ref([]),
chartsData2: any = ref([]),
chartsData3: any = ref([]);
const getPieData = async (id: string) => {
console.log('饼图变了');
currentId.value = id; // 设置当前ID
//handleCheckFunction(0)//切换左侧树默认css功能是设备检测
const boundPqDevList=ref<Device.ResPqDev[]>([])//根据检测计划id查询出所有已绑定的设备
const pqDevList_Result2 = await getBoundPqDevList({'planId': id,'checkStateList':[0,1,2,3]});
boundPqDevList.value = pqDevList_Result2.data as Device.ResPqDev[];
console.log('饼图列',boundPqDevList)
// 初始化计数对象
const checkStateCount: { [key: number]: number } = { 0: 0, 1: 0, 2: 0, 3: 0 };
// 遍历 boundPqDevList 并更新计数对象
boundPqDevList.value.forEach(t => {
if (t.checkState !== undefined && t.checkState !== null && checkStateCount[t.checkState] !== undefined) {
checkStateCount[t.checkState]++;
}
});
console.log("Check", checkStateCount)
// 统计检测结果的数量
const checkResultCount: { [key: number]: number } = { 0: 0, 1: 0, 2: 0 };
boundPqDevList.value.forEach(t => {
if (t.checkResult !== undefined && t.checkResult !== null && checkResultCount[t.checkResult] !== undefined) {
checkResultCount[t.checkResult]++;
}
});
//报告状态
const reportStateCount: { [key: number]: number } = { 0: 0, 1: 0, 2: 0 };
boundPqDevList.value.forEach(t => {
if (t.reportState !== undefined && t.reportState !== null && reportStateCount[t.reportState] !== undefined) {
reportStateCount[t.reportState]++;
}
});
if (id) {
const boundPqDevList = ref<Device.ResPqDev[]>([])//根据检测计划id查询出所有已绑定的设备
const pqDevList_Result2 = await getBoundPqDevList({'planId': id, 'checkStateList': [0, 1, 2, 3]});
boundPqDevList.value = pqDevList_Result2.data as Device.ResPqDev[];
// 遍历 boundPqDevList 并更新计数对象
boundPqDevList.value.forEach(t => {
if (t.checkState !== undefined && t.checkState !== null && checkStateCount[t.checkState] !== undefined) {
checkStateCount[t.checkState]++;
}
});
boundPqDevList.value.forEach(t => {
if (t.checkResult !== undefined && t.checkResult !== null && checkResultCount[t.checkResult] !== undefined) {
checkResultCount[t.checkResult]++;
}
});
boundPqDevList.value.forEach(t => {
if (t.reportState !== undefined && t.reportState !== null && reportStateCount[t.reportState] !== undefined) {
reportStateCount[t.reportState]++;
}
});
}
chartsData1.value = [
{ value: checkStateCount[0], name: "未检", itemStyle: { color: '#fac858' } },
@@ -345,7 +335,6 @@ const planDetail = () => {
};
//功能选择css切换
const handleCheckFunction = (val: any) => {
editableTabsValue.value = '0';
form.value.activeChildTabs = 0;
tabsList.value.map((item: any, index: any) => {
@@ -357,7 +346,7 @@ const handleCheckFunction = (val: any) => {
});
tabShow.value = false;
switch (val) {
case 0://自动检测
checkStateTable.value = [0,1,2]
@@ -422,8 +411,6 @@ onBeforeMount(async () => {
code: 0,
state: 0
};
// debugger;
const planList = await getPlanListByPattern(reqPlan);
if (planList.data[0].children[0]) {
currentId.value = planList.data[0].children[0].id;
@@ -432,8 +419,8 @@ onBeforeMount(async () => {
resizeObserver.observe(chartsInfoRef.value);
}
getTree(planList.data);
console.log('挂载')
//getPieData('');
getPieData(currentId.value);
});
onUnmounted(() => {