Kaynağa Gözat

fix:修改历史分析、行业分析页面左侧树形勾选逻辑

luzhixia 1 hafta önce
ebeveyn
işleme
93c9400514

+ 5 - 5
src/views/costAudit/baseInfo/statistics/components/IndustryPanel.vue

@@ -7,11 +7,11 @@
           <el-select
             v-model="localSearchForm.projectId"
             placeholder="请选择"
-            style="width: 200px"
             clearable
             filterable
             allow-create
             default-first-option
+            style="width: 320px"
             @change="handleProjectChange"
           >
             <el-option
@@ -27,12 +27,12 @@
           <el-select
             v-model="localSearchForm.auditedUnitId"
             placeholder="请选择"
-            style="width: 200px"
             clearable
             filterable
             allow-create
             default-first-option
             :disabled="!localSearchForm.projectId"
+            style="width: 320px"
             @change="emitSearchForm"
           >
             <el-option
@@ -51,17 +51,17 @@
             placeholder="开始年份"
             format="yyyy年"
             value-format="yyyy"
-            style="width: 140px; margin-right: 10px"
+            style="width: 250px; margin-right: 10px"
             @change="emitSearchForm"
           ></el-date-picker>
-          <span style="margin: 0 5px">~</span>
+          <span style="margin: 0 10px">~</span>
           <el-date-picker
             v-model="localSearchForm.endYear"
             type="year"
             placeholder="结束年份"
             format="yyyy年"
             value-format="yyyy"
-            style="width: 140px"
+            style="width: 250px"
             @change="emitSearchForm"
           ></el-date-picker>
         </el-form-item>

+ 0 - 1
src/views/costAudit/baseInfo/statistics/historyAnalysis.vue

@@ -825,7 +825,6 @@
 
         // 处理趋势图数据
         const trendArr = this.transformTrendFromCostList(trendList)
-        console.log('trendArr999', trendArr)
         const { xAxis, series } = this.buildTrendSeries(trendArr, selectedItems)
         this.trendData = { xAxis, series }
         // 保存所有趋势图数据

+ 67 - 18
src/views/costAudit/baseInfo/statistics/index.js

@@ -274,12 +274,21 @@ export const comprehensiveMixin = {
 
       if (data && String(data.parentId ?? '').trim() === '-1') {
         // 根节点:只保留当前根及其已勾选的子节点
-        paths
-          .filter((path) => path[0] && path[0].id === data.id)
-          .forEach((path) => {
-            path.forEach((node) => sanitized.add(node.id))
+        // paths
+        //   .filter((path) => path[0] && path[0].id === data.id)
+        //   .forEach((path) => {
+        //     path.forEach((node) => sanitized.add(node.id))
+        //   })
+        // sanitized.add(data.id)
+        paths.forEach((path) => {
+          path.forEach((node) => {
+            if (node.parentId == -1) {
+              sanitized.add(node.id)
+            } else if (node.parentId != -1 && node.parentId == data.rowid) {
+              sanitized.add(node.id)
+            }
           })
-        sanitized.add(data.id)
+        })
       } else if (data) {
         // 子/孙节点:保留当前节点及其已勾选的子节点,并保留已勾选的根节点
         paths
@@ -888,13 +897,33 @@ export const comprehensiveMixin = {
 
     // 获取构成图表基础配置(historyAnalysis.vue 使用)
     getBaseCompositionChartOption(data = []) {
-      // 为每个数据项分配不同的颜色
-      const dataWithColors = data.map((item, index) => ({
-        ...item,
-        itemStyle: {
-          color: this.getColorByIndex(index),
-        },
-      }))
+      // 为每个数据项分配不同的颜色,并确保使用与tooltip一致的数值计算
+      const dataWithColors = data.map((item, index) => {
+        const surveysVos = Array.isArray(item?.surveysVos)
+          ? item.surveysVos
+          : []
+        // 计算所有年度值的总和,与tooltip中的计算逻辑保持一致
+        const totalSum = surveysVos.reduce((sum, sv) => {
+          const hasValue = sv.value !== undefined && sv.value !== null
+          const hasRvalue = sv.rvalue !== undefined && sv.rvalue !== null
+          const mainValue = hasValue
+            ? Number(sv.value) || 0
+            : hasRvalue
+            ? Number(sv.rvalue) || 0
+            : 0
+          return sum + mainValue
+        }, 0)
+        // 使用总和作为饼图的数值,如果没有年度数据则使用原始值
+        const displayValue = totalSum > 0 ? totalSum : item.value
+
+        return {
+          ...item,
+          value: displayValue, // 使用与tooltip一致的数值
+          itemStyle: {
+            color: this.getColorByIndex(index),
+          },
+        }
+      })
 
       return {
         tooltip: {
@@ -1020,12 +1049,32 @@ export const comprehensiveMixin = {
     // 获取构成图表基础配置(industryAnalysis.vue 使用)
     getIndustryCompositionChartOption(data = []) {
       // 为每个数据项分配不同的颜色,按照顺序使用 getColorByIndex
-      const dataWithColors = data.map((item, index) => ({
-        ...item,
-        itemStyle: {
-          color: this.getColorByIndex(index),
-        },
-      }))
+      const dataWithColors = data.map((item, index) => {
+        const surveysVos = Array.isArray(item?.surveysVos)
+          ? item.surveysVos
+          : []
+        // 计算所有年度值的总和,与tooltip中的计算逻辑保持一致
+        const totalSum = surveysVos.reduce((sum, sv) => {
+          const hasValue = sv.value !== undefined && sv.value !== null
+          const hasRvalue = sv.rvalue !== undefined && sv.rvalue !== null
+          const mainValue = hasValue
+            ? Number(sv.value) || 0
+            : hasRvalue
+            ? Number(sv.rvalue) || 0
+            : 0
+          return sum + mainValue
+        }, 0)
+        // 使用总和作为饼图的数值,如果没有年度数据则使用原始值
+        const displayValue = totalSum > 0 ? totalSum : item.value
+
+        return {
+          ...item,
+          value: displayValue, // 使用与tooltip一致的数值
+          itemStyle: {
+            color: this.getColorByIndex(index),
+          },
+        }
+      })
 
       return {
         tooltip: {

+ 1 - 0
src/views/costAudit/baseInfo/statistics/industryAnalysis.vue

@@ -916,6 +916,7 @@
         const selectedItemsForCharts = checkedIds
           .map((id) => this.findItemById(id, 'left'))
           .filter(Boolean)
+        // console.log(selectedItemsForCharts)/
 
         if (!selectedItemsForCharts || selectedItemsForCharts.length === 0) {
           // 如果没有选中任何指标,清空图表