From fe8bc407d32e80bd46e2213e93a25ddd28ad1794 Mon Sep 17 00:00:00 2001 From: caozehui <2427765068@qq.com> Date: Tue, 17 Dec 2024 13:57:18 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A5=BC=E5=9B=BE=E6=95=B0=E6=8D=AE=E9=BB=98?= =?UTF-8?q?=E8=AE=A4=EF=BC=8C=E9=A5=BC=E5=9B=BE=E6=95=B0=E6=8D=AE=E8=AE=A1?= =?UTF-8?q?=E7=AE=97=E6=96=B9=E5=BC=8F=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/views/home/tabs/dashboard.vue | 63 +++++++++------------- 1 file changed, 25 insertions(+), 38 deletions(-) diff --git a/frontend/src/views/home/tabs/dashboard.vue b/frontend/src/views/home/tabs/dashboard.vue index c56e073..1e643fa 100644 --- a/frontend/src/views/home/tabs/dashboard.vue +++ b/frontend/src/views/home/tabs/dashboard.vue @@ -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([])//根据检测计划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([])//根据检测计划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(() => {