forked from ddrilling/asb_cloud_front
Таблица на странице Наработка АКБ переработана в подсказку
This commit is contained in:
parent
28a0962793
commit
08fcf2736e
@ -19,6 +19,8 @@ export type WellViewProps = TooltipProps & {
|
|||||||
labelProps?: DetailedHTMLProps<HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>
|
labelProps?: DetailedHTMLProps<HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const getWellTitle = (well: WellDto) => `${well.deposit || '-'} / ${well.cluster || '-'} / ${well.caption || '-'}`
|
||||||
|
|
||||||
export const WellView = memo<WellViewProps>(({ well, iconProps, labelProps, ...other }) => well ? (
|
export const WellView = memo<WellViewProps>(({ well, iconProps, labelProps, ...other }) => well ? (
|
||||||
<Tooltip {...other} title={(
|
<Tooltip {...other} title={(
|
||||||
<Grid style={{ columnGap: '8px' }}>
|
<Grid style={{ columnGap: '8px' }}>
|
||||||
@ -53,7 +55,7 @@ export const WellView = memo<WellViewProps>(({ well, iconProps, labelProps, ...o
|
|||||||
<WellIcon state={wellState[well.idState || 0].enum} width={'1em'} height={'1em'} />
|
<WellIcon state={wellState[well.idState || 0].enum} width={'1em'} height={'1em'} />
|
||||||
</span>
|
</span>
|
||||||
<span {...labelProps}>
|
<span {...labelProps}>
|
||||||
{well.deposit} / {well.cluster} / {well.caption}
|
{getWellTitle(well)}
|
||||||
</span>
|
</span>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
) : (
|
) : (
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
import { memo, useCallback, useEffect, useMemo, useState } from 'react'
|
import { memo, useEffect, useMemo, useState } from 'react'
|
||||||
import {
|
import {
|
||||||
CheckOutlined,
|
CheckOutlined,
|
||||||
StopOutlined,
|
StopOutlined,
|
||||||
QuestionCircleOutlined,
|
QuestionCircleOutlined,
|
||||||
WarningOutlined,
|
WarningOutlined,
|
||||||
} from '@ant-design/icons'
|
} from '@ant-design/icons'
|
||||||
import { Card, Empty } from 'antd'
|
import { Card, Empty, Popover } from 'antd'
|
||||||
|
|
||||||
import { WellView } from '@components/views'
|
import { getWellTitle, WellView } from '@components/views'
|
||||||
import LoaderPortal from '@components/LoaderPortal'
|
import LoaderPortal from '@components/LoaderPortal'
|
||||||
import { DateRangeWrapper, makeNumericColumn, makeNumericRender, makeTextColumn, Table } from '@components/Table'
|
import { DateRangeWrapper, makeNumericColumn, makeNumericRender, makeTextColumn, Table } from '@components/Table'
|
||||||
import { invokeWebApiWrapperAsync } from '@components/factory'
|
import { invokeWebApiWrapperAsync } from '@components/factory'
|
||||||
@ -68,18 +68,17 @@ const generateSubsystem = (subsystem) => {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
const GeneralSubsystemStatistics = memo(() => {
|
const onRow = (record) => {
|
||||||
const [data, setData] = useState([])
|
|
||||||
const [isLoading, setIsLoading] = useState(false)
|
|
||||||
const [selected, setSelected] = useState(null)
|
|
||||||
const [dates, setDates] = useState([null, null])
|
|
||||||
|
|
||||||
const onRow = useCallback((record) => {
|
|
||||||
const state = getSubsystemState(record)
|
const state = getSubsystemState(record)
|
||||||
if (state === null) return null
|
if (state === null) return null
|
||||||
const color = getSubsystemColor(state)
|
const color = getSubsystemColor(state)
|
||||||
return { style: { backgroundColor: color } }
|
return { style: { backgroundColor: color, color: 'white' } }
|
||||||
}, [selected])
|
}
|
||||||
|
|
||||||
|
const GeneralSubsystemStatistics = memo(() => {
|
||||||
|
const [data, setData] = useState([])
|
||||||
|
const [isLoading, setIsLoading] = useState(false)
|
||||||
|
const [dates, setDates] = useState([null, null])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
invokeWebApiWrapperAsync(
|
invokeWebApiWrapperAsync(
|
||||||
@ -97,29 +96,45 @@ const GeneralSubsystemStatistics = memo(() => {
|
|||||||
)
|
)
|
||||||
}, [dates])
|
}, [dates])
|
||||||
|
|
||||||
const makeOnCardClick = useCallback((row) => () => {
|
|
||||||
setSelected((prev) => (prev?.well.id === row.well.id) ? null : row)
|
|
||||||
}, [])
|
|
||||||
|
|
||||||
const cards = useMemo(() => {
|
const cards = useMemo(() => {
|
||||||
return data.map((row) => {
|
return data.map((row) => {
|
||||||
const state = getCardState(row.subsystems)
|
const state = getCardState(row.subsystems)
|
||||||
const isSelected = row.well.id === selected?.well.id
|
|
||||||
|
|
||||||
const cardStyle = {
|
const cardStyle = {
|
||||||
boxShadow: `0 0 5px 2px ${isSelected ? 'gray' : getSubsystemColor(state)}`,
|
boxShadow: `0 0 5px 2px ${getSubsystemColor(state)}`,
|
||||||
userSelect: 'none',
|
userSelect: 'none',
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
const card = (
|
||||||
<Card key={row.well.id} title={<WellView well={row.well} />} onClick={state ? makeOnCardClick(row) : null} style={cardStyle}>
|
<Card key={row.well.id} title={getWellTitle(row.well)} style={cardStyle}>
|
||||||
<div style={{ display: 'flex', flexDirection: 'column', gap: 10 }}>
|
<div style={{ display: 'flex', flexDirection: 'column', gap: 10 }}>
|
||||||
{state ? row.subsystems.map((ss) => generateSubsystem(ss)) : <Empty />}
|
{state ? row.subsystems.map((ss) => generateSubsystem(ss)) : <Empty />}
|
||||||
</div>
|
</div>
|
||||||
</Card>
|
</Card>
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if (!state) return card
|
||||||
|
|
||||||
|
const detailTitle = (
|
||||||
|
<>
|
||||||
|
<span style={{ paddingRight: 15 }}>Детальная информация по скважине</span>
|
||||||
|
<WellView well={row.well} />
|
||||||
|
</>
|
||||||
|
)
|
||||||
|
|
||||||
|
const detailContent = (
|
||||||
|
<Table
|
||||||
|
size={'small'}
|
||||||
|
pagination={false}
|
||||||
|
dataSource={row.subsystems}
|
||||||
|
columns={columns}
|
||||||
|
onRow={onRow}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
|
||||||
|
return <Popover title={detailTitle} content={detailContent}>{card}</Popover>
|
||||||
})
|
})
|
||||||
}, [data, selected])
|
}, [data])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<LoaderPortal show={isLoading} style={{ flex: 1 }}>
|
<LoaderPortal show={isLoading} style={{ flex: 1 }}>
|
||||||
@ -128,27 +143,10 @@ const GeneralSubsystemStatistics = memo(() => {
|
|||||||
<span>Диапазон дат:</span>
|
<span>Диапазон дат:</span>
|
||||||
<DateRangeWrapper allowClear onChange={setDates} value={dates} />
|
<DateRangeWrapper allowClear onChange={setDates} value={dates} />
|
||||||
</div>
|
</div>
|
||||||
<div style={{ flex: 1, overflowY: 'scroll' }}>
|
|
||||||
<div style={{ padding: 15, display: 'flex', flexWrap: 'wrap', alignItems: 'baseline', gap: 15 }}>
|
<div style={{ padding: 15, display: 'flex', flexWrap: 'wrap', alignItems: 'baseline', gap: 15 }}>
|
||||||
{cards}
|
{cards}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{selected && (
|
|
||||||
<div style={{ display: 'flex', flexDirection: 'column', gap: 10 }}>
|
|
||||||
<div style={{ display: 'flex', gap: 15, alignItems: 'center', justifyContent: 'center', fontSize: '1.25em', fontWeight: 600 }}>
|
|
||||||
<span>Детальная информация по скважине</span>
|
|
||||||
<WellView well={selected.well} />
|
|
||||||
</div>
|
|
||||||
<Table
|
|
||||||
size={'small'}
|
|
||||||
pagination={false}
|
|
||||||
dataSource={selected.subsystems}
|
|
||||||
columns={columns}
|
|
||||||
onRow={onRow}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
</LoaderPortal>
|
</LoaderPortal>
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user