|
|
|
|
@ -1,9 +1,7 @@ |
|
|
|
|
import { NATIONAL_PARK_ZONING_COLORS } from "@/config/layers" |
|
|
|
|
import { ecologicalProtectionMenu } from "@/config/ecologicalProtection" |
|
|
|
|
|
|
|
|
|
export { ecologicalProtectionMenu } |
|
|
|
|
|
|
|
|
|
const sumBy = (rows, field) => rows.reduce((sum, item) => sum + Number(item[field] || 0), 0) |
|
|
|
|
const round = (value, digits = 2) => Number(Number(value || 0).toFixed(digits)) |
|
|
|
|
|
|
|
|
|
const ecologicalDirectPanelDefinitions = { |
|
|
|
|
@ -57,60 +55,27 @@ function normalizeEcologicalRows(value = []) { |
|
|
|
|
})) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function getNationalParkRows(stats, key) { |
|
|
|
|
return stats?.[key]?.rows || [] |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function getNationalParkPanelRows(stats, key) { |
|
|
|
|
return stats?.panels?.[key]?.rows || [] |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
export function getNationalParkTopStats(stats = {}) { |
|
|
|
|
return normalizeEcologicalRows(stats.topRows).map((item, index) => ({ |
|
|
|
|
icon: item.icon || (index % 2 === 0 ? "xiaoshoujine" : "zongxiaoliang"), |
|
|
|
|
en: "", |
|
|
|
|
...item, |
|
|
|
|
})) |
|
|
|
|
return getNationalParkRows(stats, "topRows") |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
export function getNationalParkCoreRows(stats = {}) { |
|
|
|
|
return normalizeEcologicalRows(stats.coreRows) |
|
|
|
|
return getNationalParkRows(stats, "coreRows") |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
export function getNationalParkTownRows(stats = {}) { |
|
|
|
|
return normalizeEcologicalRows(stats.townRows) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function withNationalParkPercentExtra(rows = []) { |
|
|
|
|
const total = sumBy(rows, "value") |
|
|
|
|
return rows.map((item) => ({ |
|
|
|
|
...item, |
|
|
|
|
extra: item.extra || `占比 ${round((Number(item.value || 0) / Math.max(total, 1)) * 100, 1)}%`, |
|
|
|
|
})) |
|
|
|
|
return getNationalParkRows(stats, "townRows") |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
export function buildNationalParkPanels(stats = {}) { |
|
|
|
|
const townRows = getNationalParkTownRows(stats) |
|
|
|
|
const townByName = new Map(townRows.map((item) => [item.name, item])) |
|
|
|
|
const areaRows = normalizeEcologicalRows(stats.townResourceRows) |
|
|
|
|
const productivityRows = normalizeEcologicalRows(stats.townProductivityRows) |
|
|
|
|
const yakRows = withNationalParkPercentExtra(normalizeEcologicalRows(stats.townYakRows)) |
|
|
|
|
const zoningRows = withNationalParkPercentExtra( |
|
|
|
|
normalizeEcologicalRows(stats.zoningRows).map((item) => ({ |
|
|
|
|
...item, |
|
|
|
|
color: item.name === "核心保护区" |
|
|
|
|
? NATIONAL_PARK_ZONING_COLORS.core.fillColor |
|
|
|
|
: item.name === "一般控制区" |
|
|
|
|
? NATIONAL_PARK_ZONING_COLORS.general.fillColor |
|
|
|
|
: item.color, |
|
|
|
|
})), |
|
|
|
|
) |
|
|
|
|
const householdRows = normalizeEcologicalRows(stats.townHouseholdRows).map((item) => ({ |
|
|
|
|
...item, |
|
|
|
|
extra: `公益岗位 ${Number(item.ecologyJobs || 0)}户`, |
|
|
|
|
})) |
|
|
|
|
const jobColors = { |
|
|
|
|
麦洼乡: "#24f6c4", |
|
|
|
|
瓦切镇: "#32dcff", |
|
|
|
|
色地镇: "#8bf7ff", |
|
|
|
|
} |
|
|
|
|
const jobRows = normalizeEcologicalRows(stats.townJobRows).map((item) => ({ |
|
|
|
|
...item, |
|
|
|
|
color: jobColors[item.name], |
|
|
|
|
extra: `牧户 ${Number(townByName.get(item.name)?.householdCount || 0)}户`, |
|
|
|
|
})) |
|
|
|
|
return { |
|
|
|
|
left: [ |
|
|
|
|
{ |
|
|
|
|
@ -125,7 +90,7 @@ export function buildNationalParkPanels(stats = {}) { |
|
|
|
|
{ key: "grassland", name: "草地面积", color: "#24f6c4" }, |
|
|
|
|
{ key: "wetland", name: "湿地面积", color: "#8bf7ff" }, |
|
|
|
|
], |
|
|
|
|
rows: areaRows, |
|
|
|
|
rows: getNationalParkPanelRows(stats, "townResource"), |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
key: "park-town-productivity", |
|
|
|
|
@ -135,21 +100,21 @@ export function buildNationalParkPanels(stats = {}) { |
|
|
|
|
labelMode: "horizontal", |
|
|
|
|
showValues: true, |
|
|
|
|
unit: "万吨", |
|
|
|
|
rows: productivityRows, |
|
|
|
|
rows: getNationalParkPanelRows(stats, "townProductivity"), |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
key: "park-town-yak", |
|
|
|
|
title: "乡镇牦牛数量", |
|
|
|
|
type: "bar", |
|
|
|
|
variant: "parkBar", |
|
|
|
|
rows: yakRows, |
|
|
|
|
rows: getNationalParkPanelRows(stats, "townYak"), |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
key: "park-town-balance", |
|
|
|
|
title: "草畜平衡超载率", |
|
|
|
|
type: "balanceGaugeGrid", |
|
|
|
|
limit: 1, |
|
|
|
|
rows: normalizeEcologicalRows(stats.balanceGaugeRows), |
|
|
|
|
rows: getNationalParkPanelRows(stats, "balance"), |
|
|
|
|
}, |
|
|
|
|
], |
|
|
|
|
right: [ |
|
|
|
|
@ -157,20 +122,20 @@ export function buildNationalParkPanels(stats = {}) { |
|
|
|
|
key: "park-zoning-structure", |
|
|
|
|
title: "红原管控区结构", |
|
|
|
|
type: "donut", |
|
|
|
|
rows: zoningRows, |
|
|
|
|
rows: getNationalParkPanelRows(stats, "zoning"), |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
key: "park-town-household", |
|
|
|
|
title: "牧户分布", |
|
|
|
|
type: "split", |
|
|
|
|
rows: householdRows, |
|
|
|
|
rows: getNationalParkPanelRows(stats, "townHousehold"), |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
key: "park-town-ecology-job", |
|
|
|
|
title: "公益岗位分布", |
|
|
|
|
type: "column", |
|
|
|
|
variant: "plain", |
|
|
|
|
rows: jobRows, |
|
|
|
|
rows: getNationalParkPanelRows(stats, "townJob"), |
|
|
|
|
}, |
|
|
|
|
], |
|
|
|
|
} |
|
|
|
|
@ -420,7 +385,7 @@ export function getEcologicalMapRanking(viewKey, stats = {}) { |
|
|
|
|
unit: "万亩", |
|
|
|
|
rows: getNationalParkTownRows(stats).map((item) => ({ |
|
|
|
|
name: item.name, |
|
|
|
|
value: round(item.protectedAreaWanMu, 2), |
|
|
|
|
value: item.value, |
|
|
|
|
unit: "万亩", |
|
|
|
|
metricLabel: "划定面积", |
|
|
|
|
})), |
|
|
|
|
|