diff --git a/src/views/jsc/leader.vue b/src/views/jsc/leader.vue index c1f3e9c..4b31371 100644 --- a/src/views/jsc/leader.vue +++ b/src/views/jsc/leader.vue @@ -211,7 +211,7 @@ export default { methods: { // 获取统计数据 async getChartData() { - const res = await fenleiCharts() + await fenleiCharts() // 保留调用,但不再使用返回数据 const home = await homeCharts() // 顶部数据 this.topObj.map(item => { @@ -226,15 +226,6 @@ export default { // this.yData.push(home.rate[item.id]) // }) console.log(this.xData, this.yData) - res.upList.map(item => { - item.img = this.imgList[item.name] - }) - this.upList = this.mergeAndRename(res.upList) - - // res.upListByFloodMaterials.map(item => { - // item.img = this.imgList[item.name] - // }) - // this.upListByFloodMaterials = this.mergeAndRename(res.upListByFloodMaterials) // 处理队伍数量数据 if (home.teamArea && Array.isArray(home.teamArea)) { @@ -252,6 +243,36 @@ export default { floodMaterials: item.floodMaterials || [] })) + // 计算重点防汛物资统计:由各地重点防汛物资中每一个区县同类物资数据之和 + // 保持与区县下物资类型一致,不进行名称转换 + const materialMap = new Map() + home.teamArea.forEach(area => { + if (area.floodMaterials && Array.isArray(area.floodMaterials)) { + area.floodMaterials.forEach(material => { + const materialName = material.value + const materialTotal = material.flood_materials_total || 0 + const materialUnit = material.remark || '' + + if (materialMap.has(materialName)) { + // 累加同类物资的数量 + materialMap.get(materialName).value += materialTotal + } else { + // 新增物资类型 + const imgKey = this.getImgKey(materialName) + materialMap.set(materialName, { + name: materialName, + value: materialTotal, + unit: materialUnit, + img: this.imgList[imgKey] || this.imgList['动力及照明类'] + }) + } + }) + } + }) + + // 转换为数组,保持与区县下物资类型一致 + this.upList = Array.from(materialMap.values()) + // 初始化第一个区域的物资数据 if (this.areaList.length > 0) { this.currentArea = this.areaList[0].id