From 57ff12d8d05d5cac0a1131f985c4f37039ab804c Mon Sep 17 00:00:00 2001 From: zty Date: Sun, 12 Jul 2026 21:48:08 -0400 Subject: [PATCH] =?UTF-8?q?refactor(web/ms):=20=E5=8E=BB=E6=8E=89=E5=81=A5?= =?UTF-8?q?=E5=BA=B7=E6=A1=A3=E5=88=97,=20=E5=81=A5=E5=BA=B7=E7=AD=89?= =?UTF-8?q?=E7=BA=A7(health=5Flevel)=E6=89=BF=E6=8E=A5=E5=B8=A6=E8=89=B2?= =?UTF-8?q?=E6=A0=87=E7=AD=BE+=E5=88=86=E7=BB=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../用户端/iapip-web/src/common/types.ts | 1 - .../src/components/material-card/index.tsx | 30 ++++++++----------- .../管理端/iapip-ms/src/common/types.ts | 2 +- .../src/components/material-card/index.tsx | 24 +++++++-------- 4 files changed, 26 insertions(+), 31 deletions(-) diff --git a/空气质量预测/源码/用户端/iapip-web/src/common/types.ts b/空气质量预测/源码/用户端/iapip-web/src/common/types.ts index a7a1b3a..9e64fd9 100644 --- a/空气质量预测/源码/用户端/iapip-web/src/common/types.ts +++ b/空气质量预测/源码/用户端/iapip-web/src/common/types.ts @@ -131,7 +131,6 @@ export type Material = { eco_level?: ECO_LEVEL health_level?: string ypt?: number | null - health_tier?: 'A' | 'B' | 'C' | null sort_order?: number unit?: MTRL_UNIT qty?: number diff --git a/空气质量预测/源码/用户端/iapip-web/src/components/material-card/index.tsx b/空气质量预测/源码/用户端/iapip-web/src/components/material-card/index.tsx index a1644e6..a221225 100644 --- a/空气质量预测/源码/用户端/iapip-web/src/components/material-card/index.tsx +++ b/空气质量预测/源码/用户端/iapip-web/src/components/material-card/index.tsx @@ -34,7 +34,7 @@ const MaterialCard: React.FC<{ const [filterConditions, setFilterConditions] = useState() const [details, setDetails] = useState>() const [selected, setSelected] = useState() - // 材料排序依据(默认综合 Ypt 升序)与是否按健康档分组显示 + // 材料排序依据(默认综合 Ypt 升序)与是否按健康等级分组显示 const [sortKey, setSortKey] = useState('ypt') const [groupByTier, setGroupByTier] = useState(false) const { initialState } = useModel('@@initialState') @@ -412,18 +412,14 @@ const MaterialCard: React.FC<{ dataIndex: 'health_level', align: 'center', width: 90, - render: (_, { health_level }) => (health_level ? {health_level} : '-') - }, - { - title: '健康档', - dataIndex: 'health_tier', - align: 'center', - width: 70, - render: (_, m) => { - const color = - m.health_tier === 'A' ? 'green' : m.health_tier === 'B' ? 'gold' : m.health_tier === 'C' ? 'red' : 'default' - return {m.health_tier ?? '—'} - } + render: (_, { health_level }) => + health_level ? ( + + {health_level} + + ) : ( + '—' + ) }, { title: '最近更新时间', @@ -581,12 +577,12 @@ const MaterialCard: React.FC<{ data.sort((a, b) => (a.category ?? '').localeCompare(b.category ?? '')) } if (gbtParam) { - // 分组开时后端已按档排序;为每档第一条打标,供「材料名称」列渲染分区小标题 + // 分组开时后端已按健康等级排序;为每档第一条打标,供「材料名称」列渲染分区小标题 let last: string | null | undefined = undefined data.forEach((m) => { - if (m.health_tier !== last) { - ;(m as Material & { __tierHead?: string }).__tierHead = m.health_tier ?? '数据不全' - last = m.health_tier + if (m.health_level !== last) { + ;(m as Material & { __tierHead?: string }).__tierHead = m.health_level ?? '未定级' + last = m.health_level } }) } diff --git a/空气质量预测/源码/管理端/iapip-ms/src/common/types.ts b/空气质量预测/源码/管理端/iapip-ms/src/common/types.ts index 395d169..9bb4d72 100644 --- a/空气质量预测/源码/管理端/iapip-ms/src/common/types.ts +++ b/空气质量预测/源码/管理端/iapip-ms/src/common/types.ts @@ -141,7 +141,7 @@ export type Material = { qty?: number display?: number ypt?: number | null - health_tier?: 'A' | 'B' | 'C' | null + health_level?: 'A' | 'B' | 'C' | null collectors?: { user_id: string; project_id: string }[] methanal?: number methanal_min_be?: number diff --git a/空气质量预测/源码/管理端/iapip-ms/src/components/material-card/index.tsx b/空气质量预测/源码/管理端/iapip-ms/src/components/material-card/index.tsx index be0a67d..d60f781 100644 --- a/空气质量预测/源码/管理端/iapip-ms/src/components/material-card/index.tsx +++ b/空气质量预测/源码/管理端/iapip-ms/src/components/material-card/index.tsx @@ -35,7 +35,7 @@ const MaterialCard: React.FC<{ const [details, setDetails] = useState() const [selected, setSelected] = useState() const [content, setContent] = useState() - // 材料排序依据(默认综合 Ypt 升序)与是否按健康档分组显示 + // 材料排序依据(默认综合 Ypt 升序)与是否按健康等级分组显示 const [sortKey, setSortKey] = useState('ypt') const [groupByTier, setGroupByTier] = useState(false) const page = ( @@ -328,20 +328,20 @@ const MaterialCard: React.FC<{ render: (_, { eco_level }) => (eco_level ? {eco_level} : '-') }, { - title: '健康档', - dataIndex: 'health_tier', + title: '健康等级', + dataIndex: 'health_level', align: 'center', - width: 70, + width: 90, render: (_, m) => { const color = - m.health_tier === 'A' + m.health_level === 'A' ? 'green' - : m.health_tier === 'B' + : m.health_level === 'B' ? 'gold' - : m.health_tier === 'C' + : m.health_level === 'C' ? 'red' : 'default' - return {m.health_tier ?? '—'} + return m.health_level ? {m.health_level} : '—' } }, { @@ -446,12 +446,12 @@ const MaterialCard: React.FC<{ data.sort((a, b) => (a.category ?? '').localeCompare(b.category ?? '')) } if (gbtParam) { - // 分组开时后端已按档排序;为每档第一条打标,供「材料名称」列渲染分区小标题 + // 分组开时后端已按健康等级排序;为每档第一条打标,供「材料名称」列渲染分区小标题 let last: string | null | undefined = undefined data.forEach((m) => { - if (m.health_tier !== last) { - ;(m as Material & { __tierHead?: string }).__tierHead = m.health_tier ?? '数据不全' - last = m.health_tier + if (m.health_level !== last) { + ;(m as Material & { __tierHead?: string }).__tierHead = m.health_level ?? '未定级' + last = m.health_level } }) }