|
|
@@ -172,7 +172,7 @@
|
|
|
import { Download, Refresh, RefreshLeft, Search } from '@element-plus/icons-vue'
|
|
|
import Echart from '@/components/Echart/src/Echart.vue'
|
|
|
import { exportWithCustomHeaders } from '@/utils/excel-export'
|
|
|
-import { getStrDictOptions, getDictLabel, DICT_TYPE } from '@/utils/dict'
|
|
|
+import { getDictLabel, DICT_TYPE } from '@/utils/dict'
|
|
|
import { getCampusOptions } from '../../overview/campus-data'
|
|
|
import {
|
|
|
fetchElderStructure,
|
|
|
@@ -193,8 +193,24 @@ const selectedCampusIds = ref<number[]>(campusOptions.map((item) => item.value))
|
|
|
const data = ref<ElderStructureData | null>(null)
|
|
|
const hasData = computed(() => (data.value?.total ?? 0) > 0)
|
|
|
|
|
|
-const educationDict = getStrDictOptions(DICT_TYPE.DEGREE_EDUCATION_ARR)
|
|
|
-const paymentDict = getStrDictOptions(DICT_TYPE.PAYMENT_METHOD_ARR)
|
|
|
+/** 后端分段短标签 → 页面展示文案映射(未匹配则原样展示) */
|
|
|
+const AGE_LABEL_MAP: Record<string, string> = {
|
|
|
+ '<60': '60岁以下',
|
|
|
+ '60-69': '60-69岁',
|
|
|
+ '70-79': '70-79岁',
|
|
|
+ '80-89': '80-89岁',
|
|
|
+ '90-99': '90-99岁',
|
|
|
+ '≥100': '100岁及以上',
|
|
|
+ 未设置: '未设置'
|
|
|
+}
|
|
|
+const STAY_LABEL_MAP: Record<string, string> = {
|
|
|
+ '<1年': '1年以内',
|
|
|
+ '1-3年': '1-3年',
|
|
|
+ '3-5年': '3-5年',
|
|
|
+ '5-10年': '5-10年',
|
|
|
+ '≥10年': '10年及以上',
|
|
|
+ 未设置: '未设置'
|
|
|
+}
|
|
|
|
|
|
/** 分段标签颜色(按顺序循环) */
|
|
|
const AGE_COLORS = ['#95d4ff', '#67b8ff', '#409eff', '#36a866', '#e6a23c', '#f56c6c', '#909399']
|
|
|
@@ -275,10 +291,17 @@ const sexOption = computed(() => {
|
|
|
}
|
|
|
})
|
|
|
|
|
|
-const barOption = (buckets: StructureBucket[], colors: string[]) => ({
|
|
|
+const barOption = (
|
|
|
+ buckets: StructureBucket[],
|
|
|
+ colors: string[],
|
|
|
+ labelMap?: Record<string, string>
|
|
|
+) => ({
|
|
|
tooltip: { trigger: 'axis', axisPointer: { type: 'shadow' }, formatter: '{b}:{c} 人' },
|
|
|
grid: { left: 48, right: 24, top: 24, bottom: 30 },
|
|
|
- xAxis: { type: 'category', data: buckets.map((b) => b.label) },
|
|
|
+ xAxis: {
|
|
|
+ type: 'category',
|
|
|
+ data: buckets.map((b) => (labelMap ? (labelMap[b.label] ?? b.label) : b.label))
|
|
|
+ },
|
|
|
yAxis: { type: 'value', name: '人', minInterval: 1 },
|
|
|
series: [
|
|
|
{
|
|
|
@@ -293,8 +316,10 @@ const barOption = (buckets: StructureBucket[], colors: string[]) => ({
|
|
|
]
|
|
|
})
|
|
|
|
|
|
-const ageOption = computed(() => barOption(data.value?.ageBuckets ?? [], AGE_COLORS))
|
|
|
-const stayOption = computed(() => barOption(data.value?.stayBuckets ?? [], ['#1fa9bf']))
|
|
|
+const ageOption = computed(() => barOption(data.value?.ageBuckets ?? [], AGE_COLORS, AGE_LABEL_MAP))
|
|
|
+const stayOption = computed(() =>
|
|
|
+ barOption(data.value?.stayBuckets ?? [], ['#1fa9bf'], STAY_LABEL_MAP)
|
|
|
+)
|
|
|
|
|
|
const nurseLevelOption = computed(() => {
|
|
|
// 后端按人数降序返回;echart 类目轴第一项在底部,反转让人数最多的显示在顶部
|
|
|
@@ -320,14 +345,14 @@ const nurseLevelOption = computed(() => {
|
|
|
}
|
|
|
})
|
|
|
|
|
|
-/** 字典类分布:后端返回字典原值,前端翻译展示 */
|
|
|
-const dictDistributionOption = (buckets: DictBucket[], dict: any[], color: string) => {
|
|
|
+/** 字典类分布:后端返回字典原值,前端按字典类型实时翻译展示 */
|
|
|
+const dictDistributionOption = (buckets: DictBucket[], dictType: string, color: string) => {
|
|
|
const list = buckets
|
|
|
.map((b) => ({
|
|
|
name:
|
|
|
b.value === null || b.value === undefined || b.value === ''
|
|
|
? '未设置'
|
|
|
- : getDictLabel(dict, String(b.value)) || '未设置',
|
|
|
+ : getDictLabel(dictType, b.value) || '未设置',
|
|
|
count: b.count
|
|
|
}))
|
|
|
.sort((a, b) => b.count - a.count)
|
|
|
@@ -353,10 +378,14 @@ const dictDistributionOption = (buckets: DictBucket[], dict: any[], color: strin
|
|
|
}
|
|
|
|
|
|
const educationOption = computed(() =>
|
|
|
- dictDistributionOption(data.value?.educationBuckets ?? [], educationDict, '#36a866')
|
|
|
+ dictDistributionOption(
|
|
|
+ data.value?.educationBuckets ?? [],
|
|
|
+ DICT_TYPE.DEGREE_EDUCATION_ARR,
|
|
|
+ '#36a866'
|
|
|
+ )
|
|
|
)
|
|
|
const paymentOption = computed(() =>
|
|
|
- dictDistributionOption(data.value?.paymentBuckets ?? [], paymentDict, '#f5851d')
|
|
|
+ dictDistributionOption(data.value?.paymentBuckets ?? [], DICT_TYPE.PAYMENT_METHOD_ARR, '#f5851d')
|
|
|
)
|
|
|
|
|
|
/* ---------------- 院区明细表 ---------------- */
|