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
|
eco_level?: ECO_LEVEL
|
||||||
health_level?: string
|
health_level?: string
|
||||||
ypt?: number | null
|
ypt?: number | null
|
||||||
health_tier?: 'A' | 'B' | 'C' | null
|
|
||||||
sort_order?: number
|
sort_order?: number
|
||||||
unit?: MTRL_UNIT
|
unit?: MTRL_UNIT
|
||||||
qty?: number
|
qty?: number
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@ const MaterialCard: React.FC<{
|
||||||
const [filterConditions, setFilterConditions] = useState<AnyObj>()
|
const [filterConditions, setFilterConditions] = useState<AnyObj>()
|
||||||
const [details, setDetails] = useState<Partial<Material>>()
|
const [details, setDetails] = useState<Partial<Material>>()
|
||||||
const [selected, setSelected] = useState<Material[] | undefined>()
|
const [selected, setSelected] = useState<Material[] | undefined>()
|
||||||
// 材料排序依据(默认综合 Ypt 升序)与是否按健康档分组显示
|
// 材料排序依据(默认综合 Ypt 升序)与是否按健康等级分组显示
|
||||||
const [sortKey, setSortKey] = useState<string>('ypt')
|
const [sortKey, setSortKey] = useState<string>('ypt')
|
||||||
const [groupByTier, setGroupByTier] = useState<boolean>(false)
|
const [groupByTier, setGroupByTier] = useState<boolean>(false)
|
||||||
const { initialState } = useModel('@@initialState')
|
const { initialState } = useModel('@@initialState')
|
||||||
|
|
@ -412,18 +412,14 @@ const MaterialCard: React.FC<{
|
||||||
dataIndex: 'health_level',
|
dataIndex: 'health_level',
|
||||||
align: 'center',
|
align: 'center',
|
||||||
width: 90,
|
width: 90,
|
||||||
render: (_, { health_level }) => (health_level ? <Tag color={health_level === 'A' ? 'green' : health_level === 'B' ? 'orange' : 'red'}>{health_level}</Tag> : '-')
|
render: (_, { health_level }) =>
|
||||||
},
|
health_level ? (
|
||||||
{
|
<Tag color={health_level === 'A' ? 'green' : health_level === 'B' ? 'gold' : health_level === 'C' ? 'red' : 'default'}>
|
||||||
title: '健康档',
|
{health_level}
|
||||||
dataIndex: 'health_tier',
|
</Tag>
|
||||||
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>
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: '最近更新时间',
|
title: '最近更新时间',
|
||||||
|
|
@ -581,12 +577,12 @@ const MaterialCard: React.FC<{
|
||||||
data.sort((a, b) => (a.category ?? '').localeCompare(b.category ?? ''))
|
data.sort((a, b) => (a.category ?? '').localeCompare(b.category ?? ''))
|
||||||
}
|
}
|
||||||
if (gbtParam) {
|
if (gbtParam) {
|
||||||
// 分组开时后端已按档排序;为每档第一条打标,供「材料名称」列渲染分区小标题
|
// 分组开时后端已按健康等级排序;为每档第一条打标,供「材料名称」列渲染分区小标题
|
||||||
let last: string | null | undefined = undefined
|
let last: string | null | undefined = undefined
|
||||||
data.forEach((m) => {
|
data.forEach((m) => {
|
||||||
if (m.health_tier !== last) {
|
if (m.health_level !== last) {
|
||||||
;(m as Material & { __tierHead?: string }).__tierHead = m.health_tier ?? '数据不全'
|
;(m as Material & { __tierHead?: string }).__tierHead = m.health_level ?? '未定级'
|
||||||
last = m.health_tier
|
last = m.health_level
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -141,7 +141,7 @@ export type Material = {
|
||||||
qty?: number
|
qty?: number
|
||||||
display?: number
|
display?: number
|
||||||
ypt?: number | null
|
ypt?: number | null
|
||||||
health_tier?: 'A' | 'B' | 'C' | null
|
health_level?: 'A' | 'B' | 'C' | null
|
||||||
collectors?: { user_id: string; project_id: string }[]
|
collectors?: { user_id: string; project_id: string }[]
|
||||||
methanal?: number
|
methanal?: number
|
||||||
methanal_min_be?: number
|
methanal_min_be?: number
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,7 @@ const MaterialCard: React.FC<{
|
||||||
const [details, setDetails] = useState<Material>()
|
const [details, setDetails] = useState<Material>()
|
||||||
const [selected, setSelected] = useState<Material[] | undefined>()
|
const [selected, setSelected] = useState<Material[] | undefined>()
|
||||||
const [content, setContent] = useState<AnyObj>()
|
const [content, setContent] = useState<AnyObj>()
|
||||||
// 材料排序依据(默认综合 Ypt 升序)与是否按健康档分组显示
|
// 材料排序依据(默认综合 Ypt 升序)与是否按健康等级分组显示
|
||||||
const [sortKey, setSortKey] = useState<string>('ypt')
|
const [sortKey, setSortKey] = useState<string>('ypt')
|
||||||
const [groupByTier, setGroupByTier] = useState<boolean>(false)
|
const [groupByTier, setGroupByTier] = useState<boolean>(false)
|
||||||
const page = (
|
const page = (
|
||||||
|
|
@ -328,20 +328,20 @@ const MaterialCard: React.FC<{
|
||||||
render: (_, { eco_level }) => (eco_level ? <Tag>{eco_level}</Tag> : '-')
|
render: (_, { eco_level }) => (eco_level ? <Tag>{eco_level}</Tag> : '-')
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: '健康档',
|
title: '健康等级',
|
||||||
dataIndex: 'health_tier',
|
dataIndex: 'health_level',
|
||||||
align: 'center',
|
align: 'center',
|
||||||
width: 70,
|
width: 90,
|
||||||
render: (_, m) => {
|
render: (_, m) => {
|
||||||
const color =
|
const color =
|
||||||
m.health_tier === 'A'
|
m.health_level === 'A'
|
||||||
? 'green'
|
? 'green'
|
||||||
: m.health_tier === 'B'
|
: m.health_level === 'B'
|
||||||
? 'gold'
|
? 'gold'
|
||||||
: m.health_tier === 'C'
|
: m.health_level === 'C'
|
||||||
? 'red'
|
? 'red'
|
||||||
: 'default'
|
: '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 ?? ''))
|
data.sort((a, b) => (a.category ?? '').localeCompare(b.category ?? ''))
|
||||||
}
|
}
|
||||||
if (gbtParam) {
|
if (gbtParam) {
|
||||||
// 分组开时后端已按档排序;为每档第一条打标,供「材料名称」列渲染分区小标题
|
// 分组开时后端已按健康等级排序;为每档第一条打标,供「材料名称」列渲染分区小标题
|
||||||
let last: string | null | undefined = undefined
|
let last: string | null | undefined = undefined
|
||||||
data.forEach((m) => {
|
data.forEach((m) => {
|
||||||
if (m.health_tier !== last) {
|
if (m.health_level !== last) {
|
||||||
;(m as Material & { __tierHead?: string }).__tierHead = m.health_tier ?? '数据不全'
|
;(m as Material & { __tierHead?: string }).__tierHead = m.health_level ?? '未定级'
|
||||||
last = m.health_tier
|
last = m.health_level
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue