forked from ddrilling/asb_cloud_front
Исправлена работа фильтра подсистем
This commit is contained in:
parent
1f8bf12821
commit
a965a9b693
@ -129,11 +129,11 @@ const D3HorizontalChart = memo((
|
|||||||
//@ts-ignore
|
//@ts-ignore
|
||||||
.transition(t)
|
.transition(t)
|
||||||
//@ts-ignore
|
//@ts-ignore
|
||||||
.attr('width', d => x(d.data.percent))
|
.attr('width', d => d.data.percent >= 0 ? x(d.data.percent) : 0)
|
||||||
})
|
})
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
svg.selectAll("g").selectAll("*").remove()
|
svg.remove()
|
||||||
}
|
}
|
||||||
}, [width, height, data])
|
}, [width, height, data])
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import React, { ReactNode, useEffect, useState } from 'react'
|
import React, { memo, ReactNode, useCallback, useEffect, useState } from 'react'
|
||||||
import { Col, Row, Select } from 'antd'
|
import { Col, Row, Select } from 'antd'
|
||||||
import { Moment } from 'moment'
|
import { Moment } from 'moment'
|
||||||
|
|
||||||
@ -55,9 +55,10 @@ const tableColumns = [
|
|||||||
makeColumn('Кол-во запусков', 'operationCount'),
|
makeColumn('Кол-во запусков', 'operationCount'),
|
||||||
]
|
]
|
||||||
|
|
||||||
const OperationTime = () => {
|
const OperationTime = memo(() => {
|
||||||
const [showLoader, setShowLoader] = useState(false)
|
const [showLoader, setShowLoader] = useState(false)
|
||||||
const [data, setData] = useState<DataType[]>([])
|
const [data, setData] = useState<DataType[]>([])
|
||||||
|
const [selectedData, setSelectedData] = useState<DataType[]>([])
|
||||||
const [dateRange, setDateRange] = useState<Moment[]>([])
|
const [dateRange, setDateRange] = useState<Moment[]>([])
|
||||||
const [childrenData, setChildrenData] = useState<ReactNode[]>([])
|
const [childrenData, setChildrenData] = useState<ReactNode[]>([])
|
||||||
const [well] = useWell()
|
const [well] = useWell()
|
||||||
@ -65,17 +66,18 @@ const OperationTime = () => {
|
|||||||
const errorNotifyText = `Не удалось загрузить данные`
|
const errorNotifyText = `Не удалось загрузить данные`
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|
||||||
invokeWebApiWrapperAsync(
|
invokeWebApiWrapperAsync(
|
||||||
async () => {
|
async () => {
|
||||||
if (!well.id) return
|
if (!well.id) return
|
||||||
try {
|
try {
|
||||||
setData(arrayOrDefault(await SubsystemOperationTimeService.getStat(
|
const responseData:DataType[] = arrayOrDefault(await SubsystemOperationTimeService.getStat(
|
||||||
well.id,
|
well.id,
|
||||||
undefined,
|
undefined,
|
||||||
dateRange[1] ? dateRange[0]?.toISOString() : undefined,
|
dateRange[1] ? dateRange[0]?.toISOString() : undefined,
|
||||||
dateRange[1]?.toISOString(),
|
dateRange[1]?.toISOString(),
|
||||||
)))
|
))
|
||||||
|
setData(responseData)
|
||||||
|
setSelectedData(responseData)
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
setData([])
|
setData([])
|
||||||
throw e
|
throw e
|
||||||
@ -95,16 +97,15 @@ const OperationTime = () => {
|
|||||||
)))
|
)))
|
||||||
}, [data])
|
}, [data])
|
||||||
|
|
||||||
const selectChange = (value: string[]) => {
|
const selectChange = useCallback((value: string[]) => {
|
||||||
|
setSelectedData(selectedData.reduce((previousValue: DataType[], currentValue) => {
|
||||||
setData(data.reduce((previousValue: DataType[], currentValue) => {
|
|
||||||
if (value.includes(currentValue.subsystemName)) {
|
if (value.includes(currentValue.subsystemName)) {
|
||||||
previousValue.push(currentValue)
|
previousValue.push(currentValue)
|
||||||
}
|
}
|
||||||
return previousValue
|
return previousValue
|
||||||
}, []))
|
}, []))
|
||||||
|
|
||||||
}
|
},[data]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<LoaderPortal show={showLoader}>
|
<LoaderPortal show={showLoader}>
|
||||||
@ -112,8 +113,9 @@ const OperationTime = () => {
|
|||||||
<Row align={'middle'} justify={'space-between'} wrap={false} style={{ backgroundColor: 'white' }}>
|
<Row align={'middle'} justify={'space-between'} wrap={false} style={{ backgroundColor: 'white' }}>
|
||||||
<Col span={18}>
|
<Col span={18}>
|
||||||
<Select
|
<Select
|
||||||
|
allowClear
|
||||||
mode="multiple"
|
mode="multiple"
|
||||||
defaultValue={data.map(d => d.subsystemName)}
|
value={selectedData.map(d => d.subsystemName)}
|
||||||
onChange={selectChange}
|
onChange={selectChange}
|
||||||
style={{ width: '100%' }}
|
style={{ width: '100%' }}
|
||||||
>
|
>
|
||||||
@ -129,7 +131,7 @@ const OperationTime = () => {
|
|||||||
</Row>
|
</Row>
|
||||||
<div style={{width: '100%', height: '50vh'}}>
|
<div style={{width: '100%', height: '50vh'}}>
|
||||||
<D3HorizontalChart
|
<D3HorizontalChart
|
||||||
data={data.map(item => ({name: item.subsystemName, percent: item.kUsage * 100}))}
|
data={selectedData.map(item => ({name: item.subsystemName, percent: item.kUsage * 100}))}
|
||||||
colors={subsystemColors}
|
colors={subsystemColors}
|
||||||
width={'100%'}
|
width={'100%'}
|
||||||
height={'50vh'}
|
height={'50vh'}
|
||||||
@ -138,13 +140,13 @@ const OperationTime = () => {
|
|||||||
<Table
|
<Table
|
||||||
size={'small'}
|
size={'small'}
|
||||||
columns={tableColumns}
|
columns={tableColumns}
|
||||||
dataSource={data.map((d, i) => ({...d, color: subsystemColors[i]}))}
|
dataSource={selectedData.map((d, i) => ({...d, color: subsystemColors[i]}))}
|
||||||
scroll={{ y: '25vh', x: true }}
|
scroll={{ y: '25vh', x: true }}
|
||||||
pagination={false}
|
pagination={false}
|
||||||
/>
|
/>
|
||||||
</LoaderPortal>
|
</LoaderPortal>
|
||||||
)
|
)
|
||||||
}
|
})
|
||||||
|
|
||||||
export default wrapPrivateComponent(OperationTime, {
|
export default wrapPrivateComponent(OperationTime, {
|
||||||
requirements: [],
|
requirements: [],
|
||||||
|
Loading…
Reference in New Issue
Block a user