refactor(web/ms): 去掉健康档列, 健康等级(health_level)承接带色标签+分组
This commit is contained in:
parent
3da1fb1282
commit
57ff12d8d0
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ const MaterialCard: React.FC<{
|
|||
const [filterConditions, setFilterConditions] = useState<AnyObj>()
|
||||
const [details, setDetails] = useState<Partial<Material>>()
|
||||
const [selected, setSelected] = useState<Material[] | undefined>()
|
||||
// 材料排序依据(默认综合 Ypt 升序)与是否按健康档分组显示
|
||||
// 材料排序依据(默认综合 Ypt 升序)与是否按健康等级分组显示
|
||||
const [sortKey, setSortKey] = useState<string>('ypt')
|
||||
const [groupByTier, setGroupByTier] = useState<boolean>(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 ? <Tag color={health_level === 'A' ? 'green' : health_level === 'B' ? 'orange' : 'red'}>{health_level}</Tag> : '-')
|
||||
},
|
||||
{
|
||||
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 <Tag color={color}>{m.health_tier ?? '—'}</Tag>
|
||||
}
|
||||
render: (_, { health_level }) =>
|
||||
health_level ? (
|
||||
<Tag color={health_level === 'A' ? 'green' : health_level === 'B' ? 'gold' : health_level === 'C' ? 'red' : 'default'}>
|
||||
{health_level}
|
||||
</Tag>
|
||||
) : (
|
||||
'—'
|
||||
)
|
||||
},
|
||||
{
|
||||
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
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ const MaterialCard: React.FC<{
|
|||
const [details, setDetails] = useState<Material>()
|
||||
const [selected, setSelected] = useState<Material[] | undefined>()
|
||||
const [content, setContent] = useState<AnyObj>()
|
||||
// 材料排序依据(默认综合 Ypt 升序)与是否按健康档分组显示
|
||||
// 材料排序依据(默认综合 Ypt 升序)与是否按健康等级分组显示
|
||||
const [sortKey, setSortKey] = useState<string>('ypt')
|
||||
const [groupByTier, setGroupByTier] = useState<boolean>(false)
|
||||
const page = (
|
||||
|
|
@ -328,20 +328,20 @@ const MaterialCard: React.FC<{
|
|||
render: (_, { eco_level }) => (eco_level ? <Tag>{eco_level}</Tag> : '-')
|
||||
},
|
||||
{
|
||||
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 <Tag color={color}>{m.health_tier ?? '—'}</Tag>
|
||||
return m.health_level ? <Tag color={color}>{m.health_level}</Tag> : '—'
|
||||
}
|
||||
},
|
||||
{
|
||||
|
|
@ -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
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue