diff --git a/src/components/views/WirelineView.tsx b/src/components/views/WirelineView.tsx new file mode 100644 index 0000000..5ea9bd0 --- /dev/null +++ b/src/components/views/WirelineView.tsx @@ -0,0 +1,50 @@ +import { Fragment, memo } from 'react' +import { Button, ButtonProps, Tooltip, TooltipProps } from 'antd' + +import { TelemetryWirelineRunOutDto } from '@api' +import { Grid, GridItem } from '../Grid' +import { formatDate } from '@utils' + +const lables: Record any, +}> = { + dateTime: { label: 'Данные актуальны на', formatter: formatDate }, + hauling: 'Наработка талевого каната с момента перетяжки каната, т*км', + haulingWarnSp: 'Наработка талевого каната до сигнализации о необходимости перетяжки, т*км', + replace: 'Наработка талевого каната с момента замены каната, т*км', + replaceWarnSp: 'Наработка талевого каната до сигнализации о необходимости замены, т*км', +} + +export type WirelineViewProps = TooltipProps & { + wireline?: TelemetryWirelineRunOutDto + buttonProps?: ButtonProps +} + +export const WirelineView = memo(({ wireline, buttonProps, ...other }) => ( + + {(Object.keys(wireline) as Array).map((key, i) => { + const label = lables[key] + return typeof label === 'string' ? ( + + {label}: + {wireline[key]} + + ) : ( + + {label?.label ?? key}: + {label?.formatter?.(wireline?.[key]) ?? wireline?.[key]} + + ) + })} + + ) : 'Нет данных'} + > + + +)) + +export default WirelineView diff --git a/src/components/views/index.ts b/src/components/views/index.ts index b535f0e..2c5e1b0 100755 --- a/src/components/views/index.ts +++ b/src/components/views/index.ts @@ -3,9 +3,11 @@ export type { TelemetryViewProps } from './TelemetryView' export type { CompanyViewProps } from './CompanyView' export type { RoleViewProps } from './RoleView' export type { UserViewProps } from './UserView' +export type { WirelineViewProps } from './WirelineView' export { PermissionView } from './PermissionView' export { TelemetryView, getTelemetryLabel } from './TelemetryView' export { CompanyView } from './CompanyView' export { RoleView } from './RoleView' -export { UserView } from './UserView' \ No newline at end of file +export { UserView } from './UserView' +export { WirelineView } from './WirelineView' diff --git a/src/pages/Telemetry/TelemetryView/WirelineRunOut.jsx b/src/pages/Telemetry/TelemetryView/WirelineRunOut.jsx new file mode 100644 index 0000000..81b31af --- /dev/null +++ b/src/pages/Telemetry/TelemetryView/WirelineRunOut.jsx @@ -0,0 +1,35 @@ +import { memo, useCallback, useEffect, useState } from 'react' + +import { TelemetryWirelineRunOutService } from '@api' +import { invokeWebApiWrapperAsync } from '@components/factory' +import { WirelineView } from '@components/views' + +export const WirelineRunOut = memo(({ idWell }) => { + const [twro, setTwro] = useState({}) + const [isLoading, setIsLoading] = useState(false) + + const update = useCallback(() => invokeWebApiWrapperAsync( + async () => { + const twro = await TelemetryWirelineRunOutService.getData(idWell) + setTwro(twro) + }, + setIsLoading, + 'Не удалось получить данные по талевому канату' + ), [idWell]) + + const onTooltipVisibleChanged = useCallback((visible) => { + if (visible) update() + }, [update]) + + useEffect(update, [update]) + + return ( + + ) +}) + +export default WirelineRunOut diff --git a/src/pages/Telemetry/TelemetryView/index.jsx b/src/pages/Telemetry/TelemetryView/index.jsx index 3a9f28e..87370e6 100755 --- a/src/pages/Telemetry/TelemetryView/index.jsx +++ b/src/pages/Telemetry/TelemetryView/index.jsx @@ -29,6 +29,7 @@ import SpinPicEnabled from '@images/SpinEnabled.png' import SpinPicDisabled from '@images/SpinDisabled.png' import '@styles/message.css' +import WirelineRunOut from './WirelineRunOut' const { Option } = Select @@ -393,6 +394,7 @@ export default function TelemetryView({ idWell }) {   + {'TorqueMaster'} {'SpinMaster'}

MSE